2024-06-05 06:11 AM
I want to perform the bootloader on my stm32l072kzt 192kb microcontroller without the need to use serial interfaces, my idea is to download a new firmware from the cloud and then update the computer with this new firmware. However, it seems to me that he doesn't jump from bank 1 to bank 2, can you confirm and explain this to me? Furthermore, what are the ways to bootloader the stm32l072kzt 192kb microcontroller?
2024-06-11 01:56 PM
I mean establish how slow exactly, and which clock sources it's using. This can be done by reviewing and unpacking the RCC registers. Once you know what state the system is in you can then hypothesis as to how and why.
Check also the wait state settings for the FLASH, these too may slow down code execution.
Out of the second bank it will have run the system boot loader first.
2024-06-12 03:57 AM
In fact, what I'm doing is just a test, so that I can understand better, and for me to see the jump, that's why I used the stm32 CubeProgrammer tool.
I need to perform the bootloader on my sstm32l072 microcontroller automatically, without any manual intervention, and without USB, and also without using any tools.
Does my microcontroller only have a dual bank format to carry out the bootloader?
Is there any way I can perform the bootloader, through the firmware itself?
Imagine a routine, so after a while of operation, a function arrives that tells the microcontroller whether or not it needs to bootloader. If necessary, I won't have a USB or any tool, nor any human around to make the bootloader, I'll just have the firmware itself. That's why it needs to be automatic. It is possible? What ways can I try this?
2024-06-12 04:12 AM - edited 2024-06-12 04:12 AM
How is the data magically manifesting on to the device?
The ROM based system loader has some very limited and specific functionality, see AN2606
Are you connected to some secondary MCU that can be communicating and potentially erasing and delivering software?
You can write code that does whatever you want on the MCU directly, you can use that to stage a firmware update in the secondary bank, and transfer control to other code that's on the device, think branching, jumping, function pointers, etc.
If you have some connection to a server you can presumably query that to see if there is newer firmware available, download that, and when complete/intact initiate a local update
2024-06-12 05:31 AM
Yes, I have another module, which can download a new firmware and save it in its FFS. However, it is connected via LPUART, and this other module of mine will not be able to send commands that the bootloader needs to receive via UART, such as command 0x21.
When I enter bootloader mode, does the microcontroller stop listening to the firmware and only listens to the bus (UART OR USB) and the reboot, or can it still listen to the firmware?
What I think is that the bootloader of this stm32l072 microcontroller needs the bus. If I write code in the firmware that writes firmware to bank2, marks bfb2 = 1, nboot1 = 1 I believe that the jump will not happen, due to the activation patterns, and because the computer waits for the bus in bootloader mode, or am I wrong?
When I want to make a bootloader via UART or USB, do I need to send commands, correct?
2024-06-12 06:23 AM
Wow there's a growing list of things you can't or won't do.
Start by imagining that the ROM based loader can't magically save you, or do the things you expect it to do. Especially if you can't or won't be able to interact with it.
The STM32L0 is capable of managing and writing it's own firmware images and selecting which bank to run.
Get to a point where you can fit your app in 92 KB or less so you can accommodate a 4 KB loader that can determine the integrity and newness of a given firmware image. Use a date or sequence number in your images so you know which succeeds the other, and if there's something newer available on a server/cloud
Build the loader for 0x08000000, and place it at 0x08000000 and 0x08018000
Build the app for 0x08001000..0x08017FFF
The loader then checks the integrity of the images at 0x08001000 and 0x08019000, with a CRC or ECDSA, determine the one with the larger sequence number, or newer date. Map that one's Bank into visibility at the 0x08001000 address, set the VTOR, and SP / PC and jump into it's entry point (Reset_Handler)
As both copies of the loader are identical it doesn't matter which is mapped at any given instance, and you can change on-the-fly with no consequences to the MCU's execution state.
2024-06-12 01:02 PM
I mean, because my microcontroller has an empty bank checking mechanism, perhaps this indicates that it is not possible to perform the jump directly from the application code.
2024-06-12 01:16 PM
The MCU has no particular awareness of that, it will execute whatever code stream it can see in memory mapped within it's address space.
2024-06-13 06:52 AM
Why would the voltage drop after entering the bootloader? Whenever BOOT0=0, NBOOT1=1, BFB2=1 and I reset the computer, when it comes back on, its voltage drops, and it's not because of the firmware because I've already tested this with empty memory and it also dropped, something from 3.3V to 1.7V, which could cause this drop after this process of marking BOOT0=0, NBOOT1=1, BFB2=1 and reset
2024-06-13 06:59 AM
With zero understanding of your design, I'd assume you've created some sort of short or overload of the power supply. Perhaps creating two Push-Pull driver pins against each other.
2024-06-13 07:39 AM
I need it to work like this:
I have firmware 1 programmed at 0x08000000 and I have firmware 2 programmed at 0x08018000.
With firmware 1 running on bank1, after a certain routine it must mark BFB2, BOOT0=0, NBOOT1=1 and then restart the microcontroller so that when the microcontroller returns it starts with bank2.
After bank2 starts, it should delete what is in bank1 and then reset the microcontroller again so that it can be remapped, so it would leave bank2 and go to bank1.
But I see the following problem:
The moment I made the bank1 firmware define the pins, it started to work right? and there wouldn't be time for him to do anything else like restart the computer after fixing the pins.
And besides, bank2 might not be able to initialize itself automatically. Because I cannot initialize the microcontroller manually every time after a reboot.
Note that bank2 is only initialized when I reset the microcontroller by removing power and turning it on, and then reprogramming again with CUBEPROGRAMMER and starting programming.
But I can't do anything manually.