RS232 | CAN | USB | TCP/IP | SD-card | Modbus RTU |
---|---|---|---|---|---|
Yes | No | No | No | No | No |
This demo is targeted towards the Nucleo-L152RE board, with 512 kB internal Flash EEPROM and 80 kB internal RAM.
To program the bootloader into the internal flash, the on-board ST-Link debugger interface was used. Firmware updates via the serial communication port are preconfigured to use the virtual COM-port offered by the ST-Link. This means that no additional hardware is needed, besides a standard micro-USB cable.
To compile the demo programs you can use the STM32CubeIDE development environment. Note that STM32CubeIDE is cross-platform. The information outlined on this page applies to both Microsoft Windows and Linux users.
Two demo projects are included in the OpenBLT bootloader package. One for the bootloader itself and one for the demo user program. This user program is configured such that it can be programmed, into the internal flash memory of the microcontroller, during a firmware update with the bootloader.
The first step in getting the the bootloader up-and-running, is the creation of the Eclipse workspace in STM32CubeIDE. After starting STM32CubeIDE, you are prompted to open a workspace. It is easiest to create a new one in the following directory: .\Target\Demo\ARMCM3_STM32L1_Nucleo_L152RE_CubeIDE\
To import the demo programs into the workspace, select File → Import from the program menu. Then select General → Existing Projects into Workspace. On the next screen you select the following directory as the root directory: .\Target\Demo\ARMCM3_STM32L1_Nucleo_L152RE_CubeIDE\. Eclipse will automatically find the Boot and Prog projects and select them:
Click the Finish button to complete the project import operation.
Before the bootloader can be used, it needs to be built and programmed into the STM32L152RE's internal flash memory. The steps in this section only need to be done once.
The bootloader program is now ready to be programmed into the internal flash memory of the STM32L152RE microcontroller. Make sure the Nucleo-L152RE board is connected to your PC via a USB cable. Next, select Run → Debug from the menu to flash the bootloader program. This will launch the Debug perspective in Eclipse. Once done, you can start the bootloader program by selecting Run → Resume from the menu.
Alternatively, you can use your favorite programmer to flash the bootloader using one of the following files, depending on what file type your programmer supports:
The output file is
To download the demo program \Target\Demo\ARMCM3_STM32L1_Nucleo_L152RE_CubeIDE\Prog\Debug\demoprog_stm32l152.srec using the bootloader, follow the instructions in the following links, depending on the communication interface you intend to use:
This demo bootloader showcases how to enable and implement support for an additional memory device. Specifically, the 16kb internal data EEPROM of the STM32L152RE.
Support for the additional memory device in the OpenBLT bootloader was enabled by setting the BOOT_NVM_HOOKS_ENABLE
configuration macro to 1
in “blt_conf.h”:
/** \brief Enable/disable the NVM hook function for supporting additional memory devices. */ #define BOOT_NVM_HOOKS_ENABLE (1)
Once enabled, this results in the following hook-functions in “hooks.c” being called during the firmware update:
NvmInitHook()
NvmWriteHook()
NvmEraseHook()
NvmDoneHook()
The actual low-level driver for operating on the internal data EEPROM is located in the files memdrv.c
and memdrv.h
. The implementation of the before mentioned hook-functions is such that it glues it to the functions in this low-level driver.
For testing purposes an extra S-record file was generated that contains random data, mapped to a location in the internal data EEPROM:
If you select this S-record file when starting a firmware update, its data contents will be stored in the STM32L152RE's internal data EEPROM.
Note that this S-record file with random data was generated with the srec_cat
tool:
srec_cat -generator 0x08080000 0x08080400 -repeat-data 0x00 -exclude 0x08080000 0x08080400 \ -random-fill 0x08080000 0x08080400 -o eeprom_data.srec -Motorola
Refer to this blog article for in-depth details on how to add support for an additional memory device: