The arduino development board normally embeds the bootloader code in the code, and uses the IAP function of the microcontroller to download the program through the USB port. In fact, it is also possible to download the program by properly setting the hex or bin file of the generated program and then downloading it to the MCU with the downloader. In this way, the arduino development environment and open source materials can be used to develop programs for other common MCU development boards on the market. This article takes MapleIDE to develop ordinary STM32 microcontroller programs as an example to illustrate.
In the arduino development environment, if build.path="storage path" is added to the last line of the lib\preferences.txt file, a hex or bin file will be generated in the corresponding folder after pressing shift to compile. However, since this file contains the startup process of the bootloader, it cannot be directly downloaded into the microcontroller. The following settings need to be done:
1. Add the parameters of the STM32F103RBT6 development board type in hardware\leaflabs\boards.txt as follows, the parameters can be modified according to different microcontrollers
mapleJTAG.name=LeafLabs Maple Rev 3+ to JTAG
mapleJTAG.upload.file_type=bin
mapleJTAG.upload.maximum_size=128000
mapleJTAG.upload.ram.maximum_size=20000
mapleJTAG.upload.flash.maximum_size=128000
mapleJTAG.upload.usbID=1EAF:0003
mapleJTAG.upload.altID=1
mapleJTAG.upload.uploader=dfu-util
mapleJTAG.upload.auto_reset=true
mapleJTAG.build.board=maple
mapleJTAG.build.mcu=STM32F103RB
mapleJTAG.build.family=cortex-m3
mapleJTAG.build.f_cpu=72000000L
mapleJTAG.build.core=maple
mapleJTAG.build.submdl=stm32f103
mapleJTAG.build.vect=VECT_TAB_BASE
mapleJTAG.build.linker=maple/jtag.ld
mapleJTAG.build.using=armcompiler
mapleJTAG.build.density=STM32_MEDIUM_DENSITY
mapleJTAG.build.error_led_port=GPIOA
mapleJTAG.build.error_led_pin=5
2. Note that the key contents of the program storage space in maple\jtag.ld are as follows:
MEMORY
{
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
}
After completing the above settings, program development can be carried out. After the program is developed, the serial port download software can be used to download the program into the STM32 microcontroller. Note that the MCU-ISP serial port download software commonly used by STM32 sometimes does not support .bin files well. The download software of uISP for STM32 is recommended here.