Closed lydon42 closed 9 months ago
The fdisk utility should only erase the config sector if its magic header (0x01 0x01) is not found. This will initialise a new SD card (or one that was used for something completely different and now is being formatted for use with MEGA65). At the same time it will keep the configuration if an already existing SD card is reformatted.
Actually, fdisk already has code to overwrite the config sector with a fresh and valid new sector:
// Put a valid first config sector in place
build_mega65_sys_config_sector();
sdcard_writesector(sys_partition_start + 1L);
The problem is, the config sector has been moved and now always sits at sector 1 instead of where sys_partition_start + 1 is pointing to. So, essentially, fdisk is writing the default config to a wrong sector...
After internal discussion, we are going to erase the config sector to default values and trigger onboarding on next boot-up. Formatting the SD card is basically like a factory reset.
Currently the config block is not erased when formatting a card with FDISK.
This can lead to unexpected behavior, so we should zero it out (i.e. do the same that
boot to onboarding
does?)