SPRADS1 June 2025 F29H850TU
In this section, the details of how a bank swap for CPU1 or CPU3 is triggered in bank mode 1 or bank mode 3 are described. First, the basics of the Bank Management region of flash are important to understand. The Flash BANKMGMT Region Address Map section of the F29H85x and F29P58x Real-Time Microcontrollers data sheet shows the memory map of the bank management region in all four bank modes. This document focuses on the Flash BANKMGMT Region Address Mapping (BANKMODE = 1) table, which is applicable for bank mode 1.
As shown below, the BANKMGMT region in bank mode 1 is all mapped to CPU1. There are four regions listed in the table and these are split evenly between the active (FRI1) and inactive (FRI3) region of CPU1 flash. However, the BANKMGMT regions in FRI1.RP1 and FRI3.RP1 are unused. These regions are reserved for determining the SWAP value for CPU3. Since CPU3 does not have any flash allocated in Mode 1, these regions are unused.
| FRI | READ PORT | SIZE | START ADDRESS | END ADDRESS |
FLASH BANKS (SWAP = 0) | FLASH BANKS (SWAP = 1) |
|---|---|---|---|---|---|---|
| FRI-1 (CPU1 program) | RP0 | 4KB | 0x10D80000 | 0x10D80FFF | FLC1.B0/B1 | FLC1.B2/B3 |
| RP1 | 4KB | 0x10D84000 | 0x10D84FFF | FLC2.B0/B1 | FLC2.B2/B3 | |
| RP2 | 4KB | 0x10D88000 | 0x10D88FFF | N/A | N/A | |
| RP3 | 4KB | 0x10D8C000 | 0x10D8CFFF | N/A | N/A | |
| FRI-2 (CPU3 program)#d7e950 | RP0 | 4KB | 0x10D90000 | 0x10D90FFF | N/A | N/A |
| RP1 | 4KB | 0x10D94000 | 0x10D94FFF | N/A | N/A | |
| FRI-3 (Update region) | RP0 | 4KB | 0x10D98000 | 0x10D98FFF | FLC1.B2/B3 | FLC1.B0/B1 |
| RP1 | 4KB | 0x10D9C000 | 0x10D9CFFF | FLC2.B2/B3 | FLC2.B0/B1 |
The BANKMGMT region of each bank pair contains three fields that are used to manage bank status and firmware updates. The BANKMGMT Sectors section of the F29H85x Technical Reference Manual (TRM) describes these fields in detail.
Figure 2-1 is an example BANKMGMT region of a device in bank mode 1.
Figure 2-1 BANKMGMT RegionThe 0x10D80000 region (FRI1 RP0) has the lowest BANK_UPDATE_CTR. Thus, this is selected as the active BANKMGMT region for CPU1 which puts the device in bank mode 1 (0x06). The inactive region (FRI3 RP0) has the BANKMODE field set to mode 3 (0x0C), but BANK_UPDATE_CTR is higher than FRI1 RP0 so this is not used.
Another register that can be used to track the active or inactive bank status is the SSU_GEN_REG.BANKMAP registers. Refer to the data-sheet or TRM for exact definitions. Notice that the CPU1SWAP field is set to 0x36. This is one of the two possible values and indicates which physical flash banks are active.
Figure 2-2 BANKMAP Before
SwappingTo trigger a swap, update the inactive BANKMGMT region (FRI3) to decrement the BANK_UPDATE_COUNTER such that this is lower than the value found in the active region (FRI1 RP0). As mentioned above, this can be done with CCS by the flash plugin or can be done manually using the flash API. In the flash-based SBL project, the ProgramInactiveBankManagement() function is used to do this in ex4_uart_boot_cpu1.c. At a high-level, here is the implementation of the function:
After calling this function, the inactive BANKMGMT region is updated.
Figure 2-3 Inactive BANKMGMT Updated for
SwapThe BANK_UPDATE_COUNTER is now lower than the counter in the active region and the BANKMODE field is now mode 1 (0x6). After triggering a device reset, these fields are in the active BANKMGMT address space (FRI1 RP0).
Figure 2-4 Active BANKMGMT RegionAdditionally, the BANKMAP.CPU1SWAP register also indicates that a swap has occurred.
Figure 2-5 BANKMAP SwapThe CPU1SWAP value is now 0xC9, as opposed to 0x36. This indicates that the swap has successfully occurred and the physical flash banks associated with the CPU1 flash active address space have swapped.