The ARM Cortex-M4 processor bare metal project with UART implementation
- Device: NUCLEO-F303ZE
cm4bm
dependents on some third-party packages to build code and burn into processor like ARM GNU Toolchain and stlink. Therefore, before using the project, we need to install these packages.
Install ARM GNU Toolchain:
$ sudo apt-get update
$ sudo apt-get -y install gcc-arm-none-eabi
Install stlink:
$ sudo apt-get update
$ sudo apt-get -y install stlink-tools
Install OpenOCD:
$ sudo apt install openocd
Build cm4bm
:
$ make
Burn the code into processor:
$ make upload
Generate the disassembly file:
$ make disassembly
The toolchain downloaded using the command sudo apt-get -y install gcc-arm-none-eabi
does not include arm-none-eabi-gdb
. Therefore, it needs to be added separately, which can be downloaded from Arm GNU Toolchain Downloads. Then. adding arm-none-eabi-gdb
into path /usr/bin/
.
In cm4bm
, it uses cortex-debug to trace the source code and find the bugs. Before using cortex-debug, the following libraries that are necessaty for arm-none-eabi-gdb
need to be installed.
$ sudo apt-get install libncursesw5
$ sudo apt install python3.8
Install putty to communicate with the board:
$ sudo apt-get install putty
Set PD8
and PD9
as USART3 Tx and USART3 Rx respectively.
PD8
setup:GPIO Setting Mode GPIOD_MODE Alternate function mode GPIOD_OSPEEDR Low Speed GPIOD_PUPDR No Pull-up & Pull-down GPIOD_OTYPER Push-Pull GPIOD_AFRH AF7 (USART3 Tx) PD9
setup:GPIO Setting Mode GPIOD_MODE Alternate function mode GPIOD_OSPEEDR Low Speed GPIOD_PUPDR No Pull-up & Pull-down GPIOD_OTYPER Push-Pull GPIOD_AFRH AF7 (USART3 Rx)
USART3 config |
Setting |
---|---|
F_CLK | 8MHz (STM32F303ZE default clock) |
USART3_Mode | Tx/Rx Enable |
USART3_Parity | Parity disable |
USART3_StopBits | 1 |
USART3_WordLen | 8 |
USART3_Baud | 38400 |
USART3_HW_FLOW | None |
Oversampling | 16 |