mirror of
https://github.com/clockworkpi/PicoCalc.git
synced 2025-12-13 18:58:51 +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)
|
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);
|
uSec(100000);
|
||||||
disable_interrupts_pico();
|
disable_interrupts_pico();
|
||||||
flash_range_erase(FLASH_TARGET_OFFSET, FLASH_ERASE_SIZE);
|
flash_range_erase(FLASH_TARGET_OFFSET, FLASH_ERASE_SIZE);
|
||||||
enable_interrupts_pico();
|
enable_interrupts_pico();
|
||||||
uSec(10000);
|
uSec(10000);
|
||||||
disable_interrupts_pico();
|
disable_interrupts_pico();
|
||||||
// XXX @cuu erased 4K, but only write sizeof(option) back?
|
// save flash block back
|
||||||
flash_range_program(FLASH_TARGET_OFFSET, (const uint8_t *)&Option, sizeof(struct option_s));
|
flash_range_program(FLASH_TARGET_OFFSET, buf, FLASH_ERASE_SIZE);
|
||||||
enable_interrupts_pico();
|
enable_interrupts_pico();
|
||||||
}
|
}
|
||||||
/* @endcond */
|
/* @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
|
Option.Magic=MagicKey; //This isn't ideal but it improves the chances of a older config working in a new build
|
||||||
FileClose(fnbr);
|
FileClose(fnbr);
|
||||||
uSec(100000);
|
SaveOptions();
|
||||||
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();
|
|
||||||
_excep_code = RESET_COMMAND;
|
_excep_code = RESET_COMMAND;
|
||||||
SoftReset();
|
SoftReset();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user