cancel
Showing results for 
Search instead for 
Did you mean: 

How to swap two memory regions from different banks in FLASH Memory for STM32L475?

Shetu Raj
Associate II

Hi,

I am working on B-L475E-IOT01A2 which is a STM32L475 series Discovery IoT kit and has an ARM M4 cortex. It has two banks of FLASH Memory of size 512 KB each. I am implementing two applications along with a bootloader and all of them are stored in the FLASH. Since there is very little space, the bootloader, the 1st application and some part of the 2nd application is stored in the 1st bank whereas the 2nd bank contains the remaining part of the 2nd application. So at a point in the bootloader program, I need to swap both the applications.

The problem is that only some part of both the applications is getting swapped because the 2nd Application is stored partly in both the banks. Only one page (2 KB) of memory can be written at once in the FLASH . Both the applications have a size of 384 KB and after calculation it turns out to be 192 pages. But after running the swapping program only 72 pages were swapped.

Here are the addresses of the applications and the bootloader.

BOOTLOADER_ADDRESS 0x08000000, (Size = 48K )

APPLICATION1_ADDRESS 0x0800F000 (Size = 384 KB)

APPLICATION2_ADDRESS 0x0806F800 (Size = 384 KB)

So what should I do to ensure proper swapping? Should I enable dual bank mode or store the 2nd Application in the 2nd bank or do something else? 0690X000009ZcYTQA0.pngYour help will be highly appreciated.

Thanks,

Shetu

2 REPLIES 2

I'd place them like this so I'd could select the bank, and effectively fork() the execution

BOOTLOADER_ADDRESS 0x08000000, copy at 0x08080000

APPLICATION1_ADDRESS 0x0800F000

APPLICATION2_ADDRESS 0x0808F000

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Why are you copying bootloader to the 2nd Bank? And how do you select the default Bank from which the program starts(because generally for my device the program instruction pointer always points to 0x8000000 which is the 1st address and my bootloader is placed there . So if I remove bootloader form there, then nothing will execute)? Also I read that if both banks are being used simultaneously then only one can be written and the other one can be read at a time. So in my program I do not write both the Banks simultaneously. First I copy both of them to RAM(buffer) and then from the that buffer write to the Applications one at a time. So why is it a problem if I store some part of Application 2 in Bank 1 and other in Bank 2 ?