Repository navigation
selector: the first sector - bank selection, trial and rollback, persistency; port for the STM32F7 - #152
Open
JaxCalder wants to merge 3 commits into
Open
selector: the first sector - bank selection, trial and rollback, persistency; port for the STM32F7#152JaxCalder wants to merge 3 commits into
JaxCalder wants to merge 3 commits into
Conversation
…rmation, store of the state and of the persistent items The code of the first sector of the flash. Portable C with a port made of five functions (the flash as memory, erase, program, jump, log) and a layout; nothing of the chip is in the core (2.8 kB of code on Cortex-M). * Images: a header of up to 512 bytes at the start of a bank (magic, version, size, CRC of the image, offset of the vectors - a multiple of 512, as VTOR wants), verified before every start. * Choice: the selected bank, then the one to go back to, then the others; a bank on trial gets max_tries starts and is dropped when it does not confirm; a lost state is rebuilt from the banks (the newest good image). * The store (one sector, S1): a log of CRC-protected records - the state of the banks and the persistent items (Dmod_WritePersistency / Dmod_ReadPersistency); a full store is compacted in RAM. Payload first, header last, so that a record cut short is not a record. * The functions behind Dmod_FirmwareGetBankCount / GetRunningBank / GetBankInfo / VerifyBank / SelectBank / Ready. Tests on the flash in RAM that keeps the rules of the real one (programming only on erased words; a power cut at any program): 1202 checks, run with the sanitizers in the CI. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… the table for the firmware, the image tool * selector/fw: the selector as firmware (5.4 kB of the 32 kB sector): vectors and the reset handler, the linker script (the DTCM for the RAM, the table at 0x08000100), the port (flash registers of the F7 - erase and program only in the store sector -, jump with VTOR and MSP, the independent watchdog for an image on trial), dmlog for the log (dmod's symbols that it takes are stubs), a minimal libc. * include/dmsel_table.h: the table of functions that the firmware finds at DMSEL_TABLE_ADDRESS; the state is the firmware's memory (the RAM of the selector is gone when it starts), the scratch for the store is given at init. * tools/dmsel_mkimage.py: the 512 byte header (magic, version, size, CRC) in front of the code linked at the start of the bank + 0x200; a ctest checks that the core accepts what the tool makes. * The core: the scratch is given at dmsel_init; an optional watchdog is started when an image on trial is started. * fw/testbank: a test image of a bank that reports what the table says into the RAM. Tested on the STM32F746G-DISCO (selector in S0, two test images): the newest good image is started; the persistent item is written and read back; the other bank on trial starts with tries 1, 2, 3 and at the fourth start is dropped and the first one runs again; Dmod_FirmwareReady confirms; a permanent choice holds across resets; the record is in S1. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…or uses dmlog and the config header of dmod) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The selector – the code of the first sector of the flash (S0) – with its port for the STM32F7, the table that the firmware calls, and the tool that makes the images of the banks. Nothing in dmod-boot uses it yet (the firmware is not linked for the banks); this is the base.
selector/src,include/dmsel.h– the portable core (2.8 kB): images with a 512-byte header (magic, version, size, CRC, vectors at +0x200 for VTOR), the choice of the bank, a try of an image on trial (3 starts, then dropped, back to the previous one), a lost state rebuilt from the banks, the store in one sector (a log of CRC-protected records: the state and the persistent items, compacted in RAM).selector/fw– the selector as firmware for the STM32F746 (5.4 kB of 32 kB): the flash registers (only the store sector is ever erased/programmed), the jump with VTOR and MSP, the watchdog for an image on trial (DMSEL_WATCHDOG_MS, 0 until the firmware feeds it), dmlog for the log.include/dmsel_table.h– the table of functions at0x08000100for the firmware (the SALDmod_Firmware*/Dmod_*Persistencywill be implemented over it); the state and the scratch memory are the firmware's.tools/dmsel_mkimage.py– the header and the CRC in front of the code linked at the bank + 0x200.fw/testbank– a test image of a bank (reports what the table says into RAM).Flash layout: S0 selector, S1 store (persistency + state), S2/S3 file systems of the banks, A = S4+S5, B = S6+S7 (384 kB each).
Tested
test-selectoralso builds the F7 firmware and the test images.readyconfirms; a permanent choice holds across resets.Next: link dmod-boot for the banks (origin, header, VTOR), the SAL over the table,
bootok, the update command, install.🤖 Generated with Claude Code