2022-06-01 02:22 AM
I am planning to do a Over the air update for a tool.
And I'm planning to use a stm32l431cc ultra low power MCU with one flash bank.
So here we have an application which is some 100kb.
I'm confused with lot of terms.
OpenBootloader
In application programming
Custom Bootloader.
Default bootloader by stm32 in System memory.
etc.
Can you clarify these word's.
I want some idea where in i can flash my new software to some flash sections,
take backup of old software.
Then move the new software to old software's location.
is this possible?
Solved! Go to Solution.
2022-06-01 02:56 AM
>>Can you clarify these word's, stm32 is more confusing that I thought.
You have any relevant experience from some other MCU family you can leverage?
>>I want some idea where in i can flash my new software to some flash sections,
take backup of old software. Then move the new software to old software's location. is this possible?
Holding multiple concurrent images, and swapping them, probably beyond you.
On a device with 256 KB you could stage a 128KB image, and subsequently replace one with a newer one. You could break the memory space into three, and have a small loader manage the selection or replacement/update process. Generally you'd want that loader to be very small, efficient and focused, so as not to waste space for use by the application, whilst allowing for robust recovery methods so you aren't left with a bricked device in the field with no firmware on it.
If you have a secondary flash memory, ie Micron, Macronix, Winbond QSPI device, you could stage and hold multiple firmware images in a more leisurely and flexible manner.
2022-06-01 02:35 AM
In Application Programming (IAP) is where you program the device using your own code and protocols, and the FLASH API or register level interaction. So HAL or Reference Manual.
In System Programming (ISP), where a blank device is assembled on a board, and subsequently programmed via JTAG/SWD, or ROM based System Loader using ST implemented and documented protocols, think UART, USB, I2C, can etc. See App Note AN2606 and related protocol docs.
assume that you will likely need to stage the new firmware image in available memory, or partition memory so a small loader section can update or recover the application directly from the "air" connection you have minimally functional, and which you can control/pace the flow of data.
2022-06-01 02:56 AM
>>Can you clarify these word's, stm32 is more confusing that I thought.
You have any relevant experience from some other MCU family you can leverage?
>>I want some idea where in i can flash my new software to some flash sections,
take backup of old software. Then move the new software to old software's location. is this possible?
Holding multiple concurrent images, and swapping them, probably beyond you.
On a device with 256 KB you could stage a 128KB image, and subsequently replace one with a newer one. You could break the memory space into three, and have a small loader manage the selection or replacement/update process. Generally you'd want that loader to be very small, efficient and focused, so as not to waste space for use by the application, whilst allowing for robust recovery methods so you aren't left with a bricked device in the field with no firmware on it.
If you have a secondary flash memory, ie Micron, Macronix, Winbond QSPI device, you could stage and hold multiple firmware images in a more leisurely and flexible manner.
2022-06-01 02:56 AM
Thanks,
So there is already one bootloader on system memory (ROM) flashed by ST.
"And I think my task will/can be design a custom bootloader such that I receive the binary image using bootloader and put in in some flash region (probably some banks)."
Also Open Bootloader is an example of IAP.
2022-06-01 03:03 AM
I used PIC micro controller earlier to do small embedded systems. But my friend suggested to go with STM, so I purchased one nucleo-f411re and trying to use it to do some lift operations for a building.
"stm32 is more confusing than I thought" --> Not needed, i feel dizziness looking at data sheets but very informative.
I guess u r offended, I'm deleting that sentence.
2022-06-01 03:33 AM
I'm not offended, I'm simply trying to establish some context and background, from which to relate. Other MCU and platforms have used loaders and firmware updates for decades. Loaders typically covered along with Assemblers,Compilers and Linkers. Many MCU have small ROM based bootstrap loaders, some provide FLASH functions/libraries
Over-the-Air tends to be a more recent inventions with the development of the internet, and assorted wireless technologies, and evolving standards, and security threats, exploits, etc.
2022-06-01 03:41 AM
The ST one can be very awkward and inflexible at times. There are often a lot of pins in play, which needs to be considered in the board design. And the protocol is ST unique, other devices frequently use a staged approach, and support X-MODEM or Intel/Motorola Hex files directly, and can use generic Terminal applications, typical of BBS and dial-up modems from the 80's- 90's.
Some of ST's IAP examples support Y-MODEM, there are other Ethernet examples using LwIP. Use of TFTP, FTP and HTTP is also quite common. Firmwares on Cellular Modems or WiFi modules frequently support HTTP or FTP at an AT command level, from there you can fetch binary or hex files from a convenient server.
2023-09-12 10:54 AM
Hi @Vmere.1 ,
Hope you are doing fine.
I was also doing OTA for stm32l452 microcontroller in baremetal. I wrote a custom bootloader with uart rxne interrupt and timer 6 interrupt with priorities 0 and 1 respectively. As per the code if the device come from a reset it will wait for 10 seconds this waiting is done using the timer interrupt, if a uart interrupt comes within the time it will stop the timer 6 then go and do the uart ISR normally ota data, otherwise when the time limit reaches it will jump to the application code which is stored in a different memory location in the flash.
In the application code I use four interrupts RTC wakeup, Uart rxne , timer 6 and External interrupts with priorities 0,1,2,3 respectively. When the application code is test seperately it works fine without any misbehaviour. But when I jump from the custom bootloader to the application only the interrupt with higher priority is working, all other are not triggering. I cannot change the interrupt priorities in the application code.
I like to know how you performed the app jump, if used any multiple interrupt codes as application code, please let me know the result.
Thanks and Regards,
Suhaib Saiyde
2023-09-12 11:51 AM
Don't do the control transfer from an IRQ Handler, or related call-back code. Do it from the foreground task, and don't use an RTOS. This way you're not having to un-nest NVIC levels.
You can use a reset to clear the NVIC, and create an optimized control transfer to the application though the loader's Reset_Handler, and some flagging in SRAM or BKPRAM, or RTC