linux下给stm32烧录程序,以imx6ull为例: 1.移植stm32flash下载地址:stm32flash download | SourceForge.net $ tar -zxvf stm32flash-0.5.tar.gz $ cd stm32flash/ $ . /opt/fsl-imx-x11/4.1.15-2.0.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabi $ make $ make install DESTDIR=./__install $ file usr/local/bin/stm32flash usr/local/bin/stm32flash: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=965f73cdeed7052db22429903bb49d32487a4356, not stripped 将usr/local/bin/stm32flash 拷贝到开发板 2.使用方法使用方法: $ ./stm32flash stm32flash 0.5 http://stm32flash.sourceforge.net/ ERROR: Device not specified Usage: ./stm32flash [-bvngfhc] [-[rw] filename] [tty_device | i2c_device] -a bus_address Bus address (e.g. for I2C port) -b rate Baud rate (default 57600) -m mode Serial port mode (default 8e1) -r filename Read flash to file (or - stdout) -w filename Write flash from file (or - stdout) -C Compute CRC of flash content -u Disable the flash write-protection -j Enable the flash read-protection -k Disable the flash read-protection -o Erase only -e n Only erase n pages before writing the flash -v Verify writes -n count Retry failed writes up to count times (default 10) -g address Start execution at specified address (0 = flash start) -S address[:length] Specify start address and optionally length for read/write/erase operations -F RX_length[:TX_length] Specify the max length of RX and TX frame -s start_page Flash at specified page (0 = flash start) -f Force binary parser -h Show this help -c Resume the connection (don't send initial INIT) *Baud rate must be kept the same as the first init* This is useful if the reset fails -i GPIO_string GPIO sequence to enter/exit bootloader mode GPIO_string=[entry_seq][:[exit_seq]] sequence=[-]n[,sequence] -R Reset device at exit. Examples: Get device information: ./stm32flash /dev/ttyS0 or: ./stm32flash /dev/i2c-0 Write with verify and then start execution: ./stm32flash -w filename -v -g 0x0 /dev/ttyS0 Read flash to file: ./stm32flash -r filename /dev/ttyS0 Read 100 bytes of flash from 0x1000 to stdout: ./stm32flash -r - -S 0x1000:100 /dev/ttyS0 Start execution: ./stm32flash -g 0x0 /dev/ttyS0 GPIO sequence: - entry sequence: GPIO_3=low, GPIO_2=low, GPIO_2=high - exit sequence: GPIO_3=high, GPIO_2=low, GPIO_2=high ./stm32flash -R -i -3,-2,2:3,-2,2 /dev/ttyS0 3.烧录使stm32进入串口烧录模式(BOOT1=0,BOOT0=1) 
BOOT1=x,BOOT0=0:从主存储器启动,就是我们常说的64K、128K、256K、512K等等的片内的Flash存储器,正常情况下我们一般这么配置,此时BOOT1引脚可以悬空; BOOT1=0,BOOT0=1:从系统存储器启动,此种启动方式会运行系统存储器内的Bootloader程序,也就是我们常说的ISP程序,这个程序是出厂内置好的,不能更改,系统存储器是一个ROM,我们使用串口下载程序就需要配置为此种启动模式; BOOT1=1,BOOT0=1:从内置SRAM启动,一般用于调试,当用户需要反复下载调试程序的时候,将程序下载到Flash很慢,此时可以选择下载到SRAM种调试,回提高效率,但是单片机一旦断电,所有程序均丢失,此种启动方式还有一个常用的用途,就是用于解除芯片的读保护功能或者擦除Flash等。
sudo stm32flash -w rtthread.hex -v -g 0x00 /dev/ttyUSB0 stm32flash 0.5 http://stm32flash.sourceforge.net/ Using Parser : Intel HEX Inte**ce serial_posix: 57600 8E1 Version : 0x31 Option 1 : 0x00 Option 2 : 0x00 Device ID : 0x0419 (STM32F42**/43**) - RAM : 192KiB (12288b reserved by bootloader) - Flash : 2048KiB (size first sector: 1x16384) - Option RAM : 65552b - System RAM : 30KiB Write to memory Erasing memory Wrote and verified address 0x08006800 (10.16%) hex或bin文件都可以烧录
|