Skip to content

Commit

Permalink
fixup! refactor(core): remove residual usage of old flash api
Browse files Browse the repository at this point in the history
  • Loading branch information
TychoVrahe committed Oct 17, 2023
1 parent 0b57d9c commit 6ebbf10
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions core/embed/bootloader/emulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ void set_core_clock(int) {}

int bootloader_main(void);

bool sector_is_empty(uint16_t sector) {
const uint8_t *storage = flash_get_address(sector, 0, 0);
size_t storage_size = flash_sector_size(sector);
bool sector_is_empty(const flash_area_t *area) {
const uint8_t *storage = flash_area_get_address(area, 0, 0);
size_t storage_size = flash_area_get_size(area);
for (size_t i = 0; i < storage_size; i++) {
if (storage[i] != 0xFF) {
return false;
Expand All @@ -39,7 +39,7 @@ __attribute__((noreturn)) int main(int argc, char **argv) {
FIRMWARE_START = (uint8_t *)flash_area_get_address(&FIRMWARE_AREA, 0, 0);

// simulate non-empty storage so that we know whether it was erased or not
if (sector_is_empty(STORAGE_AREAS[0].subarea[0].first_sector)) {
if (sector_is_empty(&STORAGE_AREAS[0])) {
secbool ret = flash_area_write_word(&STORAGE_AREAS[0], 16, 0x12345678);
(void)ret;
}
Expand Down Expand Up @@ -79,8 +79,7 @@ void mpu_config_off(void) {}

__attribute__((noreturn)) void jump_to(void *addr) {
bool storage_is_erased =
sector_is_empty(STORAGE_AREAS[0].subarea[0].first_sector) &&
sector_is_empty(STORAGE_AREAS[1].subarea[0].first_sector);
sector_is_empty(&STORAGE_AREAS[0]) && sector_is_empty(&STORAGE_AREAS[1]);

if (storage_is_erased) {
printf("STORAGE WAS ERASED\n");
Expand Down

0 comments on commit 6ebbf10

Please sign in to comment.