cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L496 firmware >512 KB - dual-bank flash overlap (normal execution + OTA)

Taksh
Associate III

Hello ST Community,

I am working on an OTA firmware update implementation on STM32L496, and I am facing an issue related to dual-bank internal flash usage when the firmware size exceeds 512 KB.
I would like to explain my setup and the problem in a simple and clear way.

 

MCU and Flash Details

  • MCU: STM32L496

  • Internal Flash: 1 MB

  • Flash configured in dual-bank mode

    • Bank1: 512 KB

    • Bank2: 512 KB

 

What We Are Doing

Normal Application

  • The main application is stored in internal flash

  • Firmware is built using STM32CubeIDE

  • No OTA activity during normal operation

OTA (Current / Tested)

  • OTA is performed using NB-IoT and NFC

  • Firmware is received in chunks

  • Chunks are written to flash

  • CRC is verified

  • After successful verification, firmware is switched

This OTA flow works only when firmware size is less than 512 KB.

 

Main Issue (Occurs Even Without OTA)

When the firmware size increases beyond 512 KB (for example ~600 KB), the system starts misbehaving even if OTA is not started at all.

Observed Behavior

  • UART logs show garbage or corrupted values

  • Application does not work as expected

  • Random or unstable behavior is observed

Important Point

This happens:

  • Without erasing flash

  • Without writing flash

  • Without switching banks

  • During normal execution only

When firmware size is below 512 KB, the system works perfectly.

 

Our Understanding of the Problem

  • When firmware size is less than 512 KB, the entire code fits in Bank1

  • When firmware size exceeds 512 KB:

    • The linker places code and data in both Bank1 and Bank2

    • The application executes across both banks

According to documentation, executing code from both banks should be supported.
However, in our case, once the code spans Bank1 and Bank2, instability is observed.

 

Why This Is Important for OTA

We are planning to move OTA storage to external SPI flash (MX25R3235F, 4 MB) and use a bootloader-based OTA approach.

However, even with external flash OTA:

  • The application firmware itself will still be larger than 512 KB

  • If execution across Bank1 + Bank2 is not reliable, external OTA will also not work

So the first priority is to understand and solve this dual-bank execution issue for large firmware.

 

Questions

  1. Is it fully supported to run a single application spanning Bank1 and Bank2 on STM32L496?

  2. Are there any specific option byte settings required for firmware larger than 512 KB?

  3. Are there any known limitations or errata related to large firmware on STM32L4 series?

  4. Are there any recommended linker script examples from ST for applications larger than one bank?

 

Summary

  • Firmware <512 KB → works correctly

  • Firmware >512 KB → unstable behavior

  • Issue occurs even without OTA

  • OTA (internal or external) depends on resolving this first

Any guidance, confirmation, or reference from the community would be very helpful.

Thank you for your time and support.

Best regards,
Taksh Patel


3 REPLIES 3
TDK
Super User

Some STM32L496 chips only have 512 kB of FLASH. Which one are you using?

After updating, verify the content of the flash using STM32CubeProgrammer. If it matches what is expected, there is no issue with the update procedure.

There is no inherent problem or restriction with an application using both banks. Probably your OTA isn't working correctly here.

If you feel a post has answered your question, please click "Accept as Solution".
Taksh
Associate III

Thank you for your response @TDK .

We are using STM32L496ZG, which has 1 MB internal Flash (dual-bank enabled, 512 KB per bank).
So this is not a 512 KB flash variant.

 

Flash Verification

After programming and after OTA updates, we verify the flash content using STM32CubeProgrammer.
The programmed image matches the expected binary, and there is no mismatch observed in the flash content itself.

Also, to clarify:

  • The issue occurs even when OTA is not started

  • No erase or write operation is performed at runtime

  • The system is only executing the application normally

So the problem does not appear to be related to flash corruption during OTA programming.

 

About Using Both Banks

We understand that there is no inherent restriction in using both banks for a single application, and that execution across Bank1 and Bank2 should be supported.

However, in our case:

  • Firmware size below 512 KB → application runs correctly

  • Firmware size above 512 KB (e.g. ~600 KB) → application becomes unstable

    • Garbage values on UART logs

    • Incorrect application behavior

    • Unstable execution

This behavior is observed before any OTA activity, which suggests that the issue is related to execution across both banks, not the OTA process itself.

 

Current Status / Clarification

  • OTA flow itself works correctly when firmware fits within one bank

  • The instability appears as soon as the firmware spans Bank1 + Bank2

  • Because of this, even a future external-flash-based OTA will depend on resolving this first

At this point, we are trying to understand:

  • Whether any specific option byte configuration is required when executing code across both banks

  • Whether cache / ART / prefetch settings need special handling for large applications

  • Whether there are any known errata or recommendations for large (>512 KB) applications on STM32L496ZG

 

Any guidance on what to specifically check for large applications spanning both flash banks would be very helpful.

Thank you again for your support.

Best regards,
Taksh Patel


If flash is programmed correctly, this is not an IAP or OTA issue and you should debug your application directly to understand why it is behaving poorly. Look at the UART calls where it sends bad data and set breakpoints to understand what is going on.

If you feel a post has answered your question, please click "Accept as Solution".