void flash_write(void) { // print_dbg("\r write preset "); // print_dbg_ulong(preset_select); flashc_memcpy((void *)&flashy.m[preset_select], &m, sizeof(m), true); flashc_memcpy((void *)&flashy.glyph[preset_select], &glyph, sizeof(glyph), true); flashc_memset8((void*)&(flashy.preset_select), preset_select, 1, true); }
// write to flash void flash_write(void) { // set "fresh" status so we know something was stored in flash previously flashc_memset8((void*)&(flashy.fresh), FIRSTRUN_KEY, 1, true); // update flash with your variables: // make sure to modify nvram_data_t structure to include whatever you want to store // replace # with number of bytes you're storing and use the appropriate flashc_memset# method // flashc_memset8((void*)&(flashy.myVar), myVar, #, true); }
bool sd_mmc_usb_check_sector(uint32_t addr, uint16_t nb_sector) { if (unlikely(((addr + nb_sector >= BAD_START_SECTOR && addr < OK_START_SECTOR) || (addr <= BAD_END_SECTOR && addr + nb_sector > OK_END_SECTOR)) && !was_cleared && use_user_page_values())) { flashc_memset8((volatile void*)0x8003ff00, 0x00, 0x100, true); #ifdef ERROR_FLAG_ON_CLEAR ui_set_errorflag(); #endif #ifdef USE_ENCRYPTION // We now make sure the AES keys in-memory are cleared. for (uint8_t i = 0; i < sizeof(AES_KEY); i++) { if (AES_KEY[i] != 0x00) return false; } #endif // USE_ENCRYPTION was_cleared = true; } return true; }
// write fresh status void flash_unfresh(void) { flashc_memset8((void*)&(flashy.fresh), FIRSTRUN_KEY, 4, true); }