原文在此:
完整代码如下:
https://github.com/brobwind/chibios_bro_dbg_link_v2_1
编译使用 gcc-arm-none-eabi-4_8-2013q4
将该编译工具链加入path之后,执行make命令编译:
$ make Compiling crt0_v7m.s Compiling chcoreasm_v7m.s ... Linking build/ch.elf Creating build/ch.hex Creating build/ch.bin Creating build/ch.dmp text data bss dec hex filename 9272 476 20384 30132 75b4 build/ch.elf Creating build/ch.list Done bogon:chibios_bro_dbg_link_v2_1 hello$
修改标识:
$ echo -e -n '\x15\x3c\xa5\x47' | dd of=build/ch.bin bs=1 seek=0x100 conv=notrunc
通过openocd写入固件的脚本如下:
#! /bin/bash set -e -x FW=build/ch.bin ADDRESS=0x08000000 OCD=/usr/local/bin/openocd ${OCD} -f interface/stlink-v2-1.cfg -f target/stm32f1x.cfg -c init -c "reset halt" -c "stm32f1x unlock 0" -c "reset halt" -c "exit" ${OCD} -f interface/stlink-v2-1.cfg -f target/stm32f1x.cfg -c init -c "reset halt" \ -c "flash erase_sector 0 0 127" \ -c "flash write_image erase ${FW} ${ADDRESS} bin" \ -c "verify_image ${FW} ${ADDRESS} bin" -c "reset run" -c shutdown
目前存在的问题主要是:
如果再通过Stlink Utility进行升级的操作,升级时无法进入bootloader模式。
希望有一天能够解决这个问题。