mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-27 08:38:07 +00:00
refactor: Move flash_init to emulator main.
This commit is contained in:
parent
1b43b2190a
commit
1da446a8fb
@ -81,8 +81,6 @@ const uint8_t STORAGE_SECTORS[STORAGE_SECTORS_COUNT] = {
|
||||
FLASH_SECTOR_STORAGE_2,
|
||||
};
|
||||
|
||||
void flash_init(void) {}
|
||||
|
||||
secbool flash_unlock_write(void) {
|
||||
HAL_FLASH_Unlock();
|
||||
FLASH->SR |= FLASH_STATUS_ALL_FLAGS; // clear all status flags
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
#include "extmod/misc.h"
|
||||
#include "extmod/vfs_posix.h"
|
||||
#include "flash.h"
|
||||
#include "genhdr/mpversion.h"
|
||||
#include "input.h"
|
||||
#include "py/builtin.h"
|
||||
@ -479,6 +480,9 @@ MP_NOINLINE int main_(int argc, char **argv) {
|
||||
|
||||
pre_process_options(argc, argv);
|
||||
|
||||
// Map trezor.flash to memory.
|
||||
flash_init();
|
||||
|
||||
#if MICROPY_ENABLE_GC
|
||||
char *heap = malloc(heap_size);
|
||||
gc_init(heap, heap + heap_size);
|
||||
|
@ -48,8 +48,6 @@ static secbool flash_check_success(uint32_t status) {
|
||||
: sectrue;
|
||||
}
|
||||
|
||||
void flash_init(void) {}
|
||||
|
||||
secbool flash_unlock_write(void) {
|
||||
svc_flash_unlock();
|
||||
return sectrue;
|
||||
|
@ -36,8 +36,6 @@
|
||||
(FLASH_SR_RDERR | FLASH_SR_PGSERR | FLASH_SR_PGPERR | FLASH_SR_PGAERR | \
|
||||
FLASH_SR_WRPERR | FLASH_SR_SOP | FLASH_SR_EOP)
|
||||
|
||||
void flash_init(void);
|
||||
|
||||
secbool __wur flash_unlock_write(void);
|
||||
secbool __wur flash_lock_write(void);
|
||||
|
||||
|
@ -299,7 +299,6 @@ static void compact(void) {
|
||||
* Initializes storage
|
||||
*/
|
||||
void norcow_init(uint32_t *norcow_version) {
|
||||
flash_init();
|
||||
secbool found = secfalse;
|
||||
*norcow_version = 0;
|
||||
norcow_active_sector = 0;
|
||||
|
@ -51,14 +51,10 @@ static const uint32_t FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT + 1] = {
|
||||
[23] = 0x081E0000, // - 0x081FFFFF | 128 KiB
|
||||
[24] = 0x08200000, // last element - not a valid sector
|
||||
};
|
||||
const uint32_t FLASH_SIZE = 0x200000;
|
||||
const uint32_t FLASH_SIZE =
|
||||
FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT] - FLASH_SECTOR_TABLE[0];
|
||||
uint8_t *FLASH_BUFFER = NULL;
|
||||
|
||||
void flash_init(void) {
|
||||
assert(FLASH_SIZE ==
|
||||
FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT] - FLASH_SECTOR_TABLE[0]);
|
||||
}
|
||||
|
||||
secbool flash_unlock_write(void) { return sectrue; }
|
||||
|
||||
secbool flash_lock_write(void) { return sectrue; }
|
||||
|
@ -26,8 +26,6 @@
|
||||
|
||||
#define FLASH_SECTOR_COUNT 24
|
||||
|
||||
void flash_init(void);
|
||||
|
||||
secbool __wur flash_unlock_write(void);
|
||||
secbool __wur flash_lock_write(void);
|
||||
|
||||
|
@ -52,14 +52,10 @@ static const uint32_t FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT + 1] = {
|
||||
[24] = 0x08200000, // last element - not a valid sector
|
||||
};
|
||||
|
||||
const uint32_t FLASH_SIZE = 0x200000;
|
||||
const uint32_t FLASH_SIZE =
|
||||
FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT] - FLASH_SECTOR_TABLE[0];
|
||||
uint8_t *FLASH_BUFFER = NULL;
|
||||
|
||||
void flash_init(void) {
|
||||
assert(FLASH_SIZE ==
|
||||
FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT] - FLASH_SECTOR_TABLE[0]);
|
||||
}
|
||||
|
||||
secbool flash_unlock(void) { return sectrue; }
|
||||
|
||||
secbool flash_lock(void) { return sectrue; }
|
||||
|
@ -26,8 +26,6 @@
|
||||
|
||||
#define FLASH_SECTOR_COUNT 24
|
||||
|
||||
void flash_init(void);
|
||||
|
||||
secbool __wur flash_unlock(void);
|
||||
secbool __wur flash_lock(void);
|
||||
|
||||
|
@ -220,7 +220,6 @@ static void compact() {
|
||||
* Initializes storage
|
||||
*/
|
||||
void norcow_init(void) {
|
||||
flash_init();
|
||||
secbool found = secfalse;
|
||||
// detect active sector - starts with magic
|
||||
for (uint8_t i = 0; i < NORCOW_SECTOR_COUNT; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user