mirror of
https://github.com/clockworkpi/PicoCalc.git
synced 2025-12-12 10:18:54 +01:00
picomite: properly save options
This commit is contained in:
parent
763a7080a2
commit
9c449b8b03
@ -5484,14 +5484,19 @@ void ClearSavedVars(void)
|
||||
}
|
||||
void SaveOptions(void)
|
||||
{
|
||||
uint8_t buf[FLASH_ERASE_SIZE];
|
||||
// load flash content to buf
|
||||
memcpy(buf, (const void*)(XIP_BASE + FLASH_TARGET_OFFSET), FLASH_ERASE_SIZE);
|
||||
// overwrite the options
|
||||
memcpy(buf, (const uint8_t *)&Option, sizeof(struct option_s));
|
||||
uSec(100000);
|
||||
disable_interrupts_pico();
|
||||
flash_range_erase(FLASH_TARGET_OFFSET, FLASH_ERASE_SIZE);
|
||||
enable_interrupts_pico();
|
||||
uSec(10000);
|
||||
disable_interrupts_pico();
|
||||
// XXX @cuu erased 4K, but only write sizeof(option) back?
|
||||
flash_range_program(FLASH_TARGET_OFFSET, (const uint8_t *)&Option, sizeof(struct option_s));
|
||||
// save flash block back
|
||||
flash_range_program(FLASH_TARGET_OFFSET, buf, FLASH_ERASE_SIZE);
|
||||
enable_interrupts_pico();
|
||||
}
|
||||
/* @endcond */
|
||||
|
||||
@ -4653,15 +4653,7 @@ tp = checkstring(cmdline, (unsigned char *)"HEARTBEAT");
|
||||
}
|
||||
Option.Magic=MagicKey; //This isn't ideal but it improves the chances of a older config working in a new build
|
||||
FileClose(fnbr);
|
||||
uSec(100000);
|
||||
disable_interrupts_pico();
|
||||
flash_range_erase(FLASH_TARGET_OFFSET, FLASH_ERASE_SIZE);
|
||||
enable_interrupts_pico();
|
||||
uSec(10000);
|
||||
disable_interrupts_pico();
|
||||
// XXX @cuu not writing sizeof(option)?
|
||||
flash_range_program(FLASH_TARGET_OFFSET, (const uint8_t *)&Option, sizeof(struct option_s));
|
||||
enable_interrupts_pico();
|
||||
SaveOptions();
|
||||
_excep_code = RESET_COMMAND;
|
||||
SoftReset();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user