1. 開発環境
参考リンク[15]と[16]はいいスタートです。
2. Compilation error: arm-none-eabi-gcc exit.c:(.text.exit+0x*): undefined reference to `_exit'
According to exit.c:(.text+0x18): undefined reference to `_exit' when using arm-none-eabi-gcc
This happens when compiling a file with arm-none-eabi-gcc in one machine/architecture to load it in an ARM target machine. Most probably you are not making use of semihosting, you want to retarget.
When not using Semihosting, can use below command
$ arm-none-eabi-gcc --specs=nosys.specs $(OTHER_LINK_OPTIONS)
3. GPIO
According [1], "The STM microcontroller used by the evaluation board provides eight GPIO ports, named A-I. Port pins PG6,7,8; PH2,3,6,7; PI10 are connected to LEDs. "
4. Cコードにアセンブラを組み込む
[10]によると、aとbが宣言されている変数であるならば、以下のようにCコードにアセンブラを組み込めます。
__asm("add a, b");
Cから見えるアセンブラ関数は以下のように書けます
__asm int add3_embasm(int i)
{
add r0, #3
bx lr
}
5. 周辺デバイスへのアクセス
[17]によると、以下のマクロで周辺アドレスレジスター(peripheral register)にアクセスできます。
#define _VAL2FLD(field, value)
Mask and shift a bit field value for assigning the result to a peripheral register. More...
#define _FLD2VAL(field, value)
Extract from a peripheral register value the a bit field value. More...
6. Instruction width selection
There are many instructions that can generate either a 16-bit encoding or a 32-bit encoding depending on the operands and destination register specified. For some of these instructions, you can force a specific instruction size by using an instruction width suffix. The .W suffix forcesa 32-bit instruction encoding. The .N suffix forces a 16-bit instruction encoding.If you specify an instruction width suffix and the assembler cannot generate an instruction encoding of the requested width, it generates an error.
BCS.W label ; creates a 32-bit instruction even for a short branch
$ srec_cat bootloader.hex -Intel app.hex -Intel -o combined.hex -Intel
Reference Links
1. Understanding the simple use of GPIO (ARM Cortex M4 CookBook)
2. General Purpose I/O Pin (PDL_GPIO) and Fast GPIO Pin (PDL_FGPIO)
3. 32-Bit Microcontroller FM4 Family Peripheral Manual
4. Programming of ARM Cortex-M microcontrollers - Part 0 - Tools and basics
5. Tips and Tricks – Jumping from the Bootloader to the Application Code Cleanly
6. Catalogue of parametrised CRC algorithms
8. C > CRC-8-CCITTを計算 > I2C通信用のCRC
10. ぐだぐだ低レベルプログラミング(5)Arm組み込みアセンブラとインラインアセンブラ
11. ARM: How to Write a Bootloader
12. How to obtain reliable Cortex M4 short delays
13. ARM® Compiler armcc User Guide
15. Programming of ARM Cortex-M microcontrollers - Part 0 - Tools and basics
16. Bare Metal Embedded Systems Build Process using GNU Toolchain
17. Peripheral Access - CMSIS-Core (Cortex-M) Version 5.5.0
18. リンカスクリプトを理解しよう - GNU Cを使いこなそう
19. INTERRUPT HANDLING IN ARM CORTEX M
20. SRecord 1.64