jsanchez-2g opened a new pull request, #20060:
URL: https://github.com/apache/nuttx/pull/20060

   ## Summary
   
   Add STM32G0 flash APIs required to switch dual-bank memory mapping and reload
   flash option bytes:
   
   - `stm32_flash_swapbanks()` toggles `FLASH_OPTR_NSWAP_BANK`
   - `stm32_flash_optload()` launches an option-byte reload
   - Bank swapping returns `-EPERM` when `FLASH_SECR_BOOT_LOCK` is active
   - The swap operation is a no-op on single-bank devices
   
   Reloading option bytes after changing the bank mapping normally causes an
   immediate system reset.
   
   ## Validation
   
   - `git diff --check`: passed
   - `tools/checkpatch.sh -g HEAD^..HEAD`: passed
   - STM32G071 single-bank configuration with `CONFIG_STM32_PROGMEM=y`:
     - Flash driver compiled successfully
     - Both APIs exported
     - Single-bank no-op path compiled
   - STM32G0B1 dual-bank configuration with `CONFIG_STM32_PROGMEM=y`:
     - Flash driver compiled successfully
     - Both APIs exported
     - Dual-bank swap path compiled
   
   ## Hardware validation
   
   Tested the equivalent existing implementation on a 2G BMS Golgi STM32G0B1
   target using two consecutive RS-485 firmware updates.
   
   Observed option-byte states:
   
   1. Initial USB DFU image:
      - `FLASH_OPTR=fef9feaa`
      - `nSWAP_BANK=1`
   2. After the first firmware update:
      - `FLASH_OPTR=fee9feaa`
      - `nSWAP_BANK=0`
   3. After the second update, initiated while the banks were swapped:
      - `FLASH_OPTR=fef9feaa`
      - `nSWAP_BANK=1`
   
   Both updates completed successfully. After each update, the target rebooted,
   mounted its filesystem, initialized its communication interfaces and BMS
   hardware, and resumed normal operation.
   
   The hardware image used the product-tree implementation from which these APIs
   were ported. The submitted code was rebased and compile-validated against
   current Apache NuttX master.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to