2019-04-30 05:02 AM
Hello,
I read ref manual part about SYSCFG (STM32H7 in my case). There are some regs that have an undefined reset value and the meaning of the regs is so that the contents is important at HW reset (BOOT_ADDx, BANK_SWAP). These regs are marked read only.
I couldn't find anything, how to set the values and where they are stored. Can I change them somehow from my software, ie change the boot address or swap the banks for the next reset?
General topic is to design a custom bootloader that will also be called after reset when BOOT0 is set. Also a fall back to the previous version after a corrupted firmware upload would be nice.
Thanks a lot
Martin
Solved! Go to Solution.
2019-05-11 12:48 AM
Cross check with flash option bytes/registers: You will see the bits in question (with unspecified reset value) are duplicated in the option bytes (well, havent't check this for every bit, but at least most of them). Possible reason: For security reasons, it might be useful to block accesses to the whole flash controller (and consequently option bytes) but still being able to access some of these bits.
If you want to modify the read-only bits in SYSCFG, modify the corresponding option bits via the flash controller (and initiate a reload of the option byte registers). Whether the writable bits "survive" reset, see table 41 in the RM: For a power-on reset there is FL_OPTB, so the option byte *registers* (and the corresponding SYSCFG bits) are loaded from the option bytes *in flash*. However, for a reset by NRST pin, there is no FL_OPTB, so the registers retain their current setting. Makes sense: You can temporarily change the boot address, issue a reset, and the new/alternative firmware starts cleanly ...
Regarding BKS in SYSCFG_UR0: see SWAP_BANK_OPT
2019-04-30 05:20 AM
All the non-vendor specific stuff is found at http://infocenter.arm.com/help/.
Just select the proper core architecture.
> Also a fall back to the previous version after a corrupted firmware upload would be nice.
This would require twice as much Flash, and position-independant code.
An alternative would be to add e.g. a checksum to the flashed image, check the application at each startup (or just after flashing it) by calculating the checksum, and remain in the BL on mismatch.
Or swap the default image in, if you want to spend the Flash space.
2019-04-30 06:08 AM
Hi Ozone,
are you sure SYSCFG is an arm core register? I couldn't find it in the arm docs. Please give me a closer link if you have. Also it contains some STM32 specific stuff like EXTI settings.
Needing twice the flash is clear, I use STM32H7 which has a lot (2MB). My understanding was that switching the banks is exactly for this purpose, but as I said I couldn't find any details. Maybe there is an application note that I didn't find yet.
Any help is welcome
Thanks
Martin
2019-04-30 06:41 AM
> are you sure SYSCFG is an arm core register? I couldn't find it in the arm docs. Please give me a closer link if you have. Also it contains some STM32 specific stuff like EXTI settings.
Do you mean the system control registers, like there (in chapter 3): https://developer.arm.com/docs/ddi0489/d
> Needing twice the flash is clear, I use STM32H7 which has a lot (2MB). My understanding was that switching the banks is exactly for this purpose, but as I said I couldn't find any details.
I do not have an example that includes bank switching.
The MCUs my company uses for it's ECUs are not "switchable", and the application is built for fixed addresses.
Being able to switch banks to the same base address should ease the task considerably. However, I have no experience with the H7 devices.
Before starting to impllement, I would check if a fallback firmware is actually a desired use case for the customer/application.
In our case, it is not. Corrupted applications force the device in the bootloader, waiting for a firmware download.
2019-04-30 09:51 AM
I have very little useful knowledge to add to this discussion, but it seems to me that Mr_M_from_G is referring to the STM "System configuration controller (SYSCFG)" component and its associated registers, not the ARM core "System Control Register, SCR".
I believe the former, particularly the SYSCFG_MEMRMP register does at least partially control the functionality being requested, but unfortunately at this point my understanding comes to a dead halt. The ST/ARM boot sequence, with the BOOT0 and BOOT1 pins and registers, FLASH/RAM remapping, bootloading over USART/I2C/SPI/CAN, and how SWDIO takes control is all Harry Potter magic to me. If anyone has a clear flowchart documenting all this I'd be very interested.
Apologies if this post is of no value. Please feel free to delete it if so.
2019-04-30 09:57 AM
Humorous (to me) aside: I tried to post the above with the text "Harry Potter black magic" and got "Your message was rejected because it contains a banned word."
I don't know if ST is protecting us from racism or satanism or both. Will see if this gets through.
2019-04-30 10:05 AM
>>I don't know if ST is protecting us from racism or satanism or both.
Indian Astr0loger Spam
2019-04-30 11:04 AM
AN2606 has descriptions and flowcharts of system bootloaders. CPU core functionality is described in particular series "programming manual".
2019-05-02 12:55 AM
Hello everyone,
thanks for your contributions.
It seems I have to clarify some of my questions.
My questions in general are:
And my special intention at the moment is to design a custom bootloader that will be called after reset when BOOT0 is set (instead of the one that comes with STM32 silicon). Also a fall back to the previous version after a corrupted firmware upload would be nice. I think I have a clear understanding how this can be done but ref manual gives me too few details how to do it on a STM32(H7).
So a clue to an app note would be great or some answers to the questions above.
Thanks a lot
Martin
2019-05-10 07:15 AM
Gently pushing this one up again.
ST members, can you help?
kind regards
Martin