7.4.2.2.1 Configuring Active/Inactive Partitions
When configured for Dual Boot mode after a Reset, the NVM Controller reads the boot sequence numbers contained in the BTSEQn words of each user program partition. It compares the sequence numbers and maps the partition with the lowest sequence number into the active space (0x80_0000) and maps the other partition into the inactive space (0xC0_0000). The current mapping is indicated by the NVMCON.P2ACTIV bit.
The Boot Sequence Number (BTSEQn) is a 12-bit value that is used for automatically determining the active partition upon device Reset. For dsPIC33A devices, BTSEQn is located at the last 128-bit Flash word of each user program partition.
The Boot Sequence Number is stored in two parts: the actual value in the bit field BTSEQn[11:0], and the one’s complement of the value in the IBTSEQn bit field [23:12]. When the Boot Sequence Number is read upon a device Reset, the values of BTSEQn and IBTSEQn are automatically compared. A Boot Sequence Number word is considered to be invalid if either:
- BTSEQn [11:0] ≠ ~BTSEQn [23:12]
OR
- The Boot Sequence Number word read results in an ECC DED error.
BTSEQ [127:24] is reserved and must read as all 0’s.
The complement value is not automatically created by hardware nor is it verified by the hardware upon programming. The application must calculate and program the appropriate value.
BTSEQ active partition address = (_PROGRAM BASE_ + _PROGRAM_LENGTH -
0x10UL)
| Variant | (Calculation) | Address |
|---|---|---|
| 512K | 0x801000 + 0x3F000 - 0x10 | 0x83FFF0 |
| 256K | 0x801000 + 0x1F000 - 0x10 | 0x81FFF0 |
- An unprogrammed word will yield in an invalid Boot Sequence Number.
- If a BTSEQn word of a partition is not valid, the Boot Sequence Number for that partition is assigned the value 0xFFF for evaluation. This is the highest possible number.
- Each partition should have a unique Boot Sequence Number. If the Boot Sequence Numbers are equal, Partition 1 is mapped into the active space.
The partitions can be prepared to be swapped during run time by reprogramming the Boot Sequence Number of the inactive partition to have a lower value than the Boot Sequence Number of the active partition. When a Reset is executed, the partition that has the lower value will become active. This method can be used when the inactive partition has been updated and needs to be mapped to the active partition after a Reset.
