对于RIOT在Nucleo-144板上的运行,需要用到几个工具
openocd: 调试烧写工具,非常重要
gnu arm toolchain:arm-x86交叉编译链,用于在pc上交叉编译RIOT,生成arm可执行的二进制文件:
1.openocd安装:见博文:http://blog.csdn.net/hahachenchen789/article/details/78534199
要注意的是openocd安装完毕后,需要将openocd.udev文件拷至udev目录:
sudo cp /usr/local/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d/
2.GNU Tools for ARM Embedded Processors toolchain.安装
下载源码:https://launchpad.net/gcc-arm-embedded
解压即可。
然后将其中的bin目录和arm-none-eabi/bin目录设置成环境变量,以确保可以直接调用bin中的二进制程序。
3.编译RIOT源码:
git下载其源码。
进入其example目录中的hello world文件夹,编译:
cd ./examples/hello-world
make BOARD=nucleo144-f429
这里我的板子是144-f429,其他144系列板子也是一样,将BOARD变量替换即可。
编译成功如下,生成二进制文件:
Building application "hello-world" for "nucleo144-f429" with MCU "stm32f4".
"make" -C /home/c/ICN/RIOT/boards/nucleo144-f429
"make" -C /home/c/ICN/RIOT/core
"make" -C /home/c/ICN/RIOT/cpu/stm32f4
"make" -C /home/c/ICN/RIOT/cpu/cortexm_common
"make" -C /home/c/ICN/RIOT/cpu/cortexm_common/periph
"make" -C /home/c/ICN/RIOT/cpu/stm32_common
"make" -C /home/c/ICN/RIOT/cpu/stm32_common/periph
"make" -C /home/c/ICN/RIOT/cpu/stm32f4/periph
"make" -C /home/c/ICN/RIOT/drivers
"make" -C /home/c/ICN/RIOT/drivers/periph_common
"make" -C /home/c/ICN/RIOT/sys
"make" -C /home/c/ICN/RIOT/sys/auto_init
"make" -C /home/c/ICN/RIOT/sys/isrpipe
"make" -C /home/c/ICN/RIOT/sys/newlib_syscalls_default
"make" -C /home/c/ICN/RIOT/sys/pm_layered
"make" -C /home/c/ICN/RIOT/sys/tsrb
"make" -C /home/c/ICN/RIOT/sys/uart_stdio
text data bss dec hex filename
8856 140 2748 11744 2de0 /home/c/ICN/RIOT/examples/hello-world/bin/nucleo144-f429/hello-world.elf
4.烧写至板子
usb连接线连接pc与板子。然后:
make BOARD=nucleo144-f429 flash
Building application "hello-world" for "nucleo144-f429" with MCU "stm32f4".
"make" -C /home/c/ICN/RIOT/boards/nucleo144-f429
"make" -C /home/c/ICN/RIOT/core
"make" -C /home/c/ICN/RIOT/cpu/stm32f4
"make" -C /home/c/ICN/RIOT/cpu/cortexm_common
"make" -C /home/c/ICN/RIOT/cpu/cortexm_common/periph
"make" -C /home/c/ICN/RIOT/cpu/stm32_common
"make" -C /home/c/ICN/RIOT/cpu/stm32_common/periph
"make" -C /home/c/ICN/RIOT/cpu/stm32f4/periph
"make" -C /home/c/ICN/RIOT/drivers
"make" -C /home/c/ICN/RIOT/drivers/periph_common
"make" -C /home/c/ICN/RIOT/sys
"make" -C /home/c/ICN/RIOT/sys/auto_init
"make" -C /home/c/ICN/RIOT/sys/isrpipe
"make" -C /home/c/ICN/RIOT/sys/newlib_syscalls_default
"make" -C /home/c/ICN/RIOT/sys/pm_layered
"make" -C /home/c/ICN/RIOT/sys/tsrb
"make" -C /home/c/ICN/RIOT/sys/uart_stdio
text data bss dec hex filename
8856 140 2748 11744 2de0 /home/c/ICN/RIOT/examples/hello-world/bin/nucleo144-f429/hello-world.elf
/home/c/ICN/RIOT/dist/tools/openocd/openocd.sh flash
### Flashing Target ###
Open On-Chip Debugger 0.10.0+dev-00207-g4109263 (2017-11-14-20:14)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
hla_swd
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Info : STLINK v2 JTAG v28 API v2 SWIM v18 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 3.247431
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
TargetName Type Endian TapName State
-- ------------------ ---------- ------ ------------------ ------------
0* stm32f4x.cpu hla_target little stm32f4x.cpu running
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080004f4 msp: 0x20000200
auto erase enabled
Info : device id = 0x20016419
Info : flash size = 2048kbytes
Info : Dual Bank 2048 kiB STM32F42x/43x/469/479 found
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x20000046 msp: 0x20000200
wrote 16384 bytes from file /home/c/ICN/RIOT/examples/hello-world/bin/nucleo144-f429/hello-world.elf in 0.633606s (25.252 KiB/s)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000002e msp: 0x20000200
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000002e msp: 0x20000200
verified 8996 bytes in 0.126261s (69.579 KiB/s)
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
shutdown command invoked
Done flashing
表示程序烧写成功。
利用USB-TTL监视串口信息:
串口脚:串口3 tx: PD8 rx:PD9
波特率:115200
串口信息如下:
�main(): This is RIOT! (Version: 2018.01-devel-534-g3d52-c)
Hello World!
You are running RIOT on a(n) nucleo144-f429 board.
This board features a(n) stm32f4 MCU.
成功。
为了使得make term运行成功需要添加如下操作:
sudo pip install pyserial