From 434a9c208491a12fdf5605fc2ac29024b2096ad4 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Thu, 24 Jan 2019 16:17:37 +0100 Subject: [PATCH] storage: add norcow_config.h, reorganize storage sources in SConscript files --- SConscript.firmware | 11 +++-- SConscript.unix | 9 ++-- embed/extmod/modtrezorconfig/norcow_config.h | 49 ++++++++++++++++++++ 3 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 embed/extmod/modtrezorconfig/norcow_config.h diff --git a/SConscript.firmware b/SConscript.firmware index 03e3af463..7f810a036 100644 --- a/SConscript.firmware +++ b/SConscript.firmware @@ -10,10 +10,14 @@ SOURCE_MOD = [] PYOPT = '1' # modtrezorconfig +CPPPATH_MOD += [ + 'embed/extmod/modtrezorconfig', + 'vendor/trezor-storage', +] SOURCE_MOD += [ 'embed/extmod/modtrezorconfig/modtrezorconfig.c', - 'vendor/trezor-storage/c/norcow.c', - 'vendor/trezor-storage/c/storage.c', + 'vendor/trezor-storage/norcow.c', + 'vendor/trezor-storage/storage.c', ] # modtrezorcrypto @@ -275,8 +279,8 @@ SOURCE_TREZORHAL = [ 'embed/trezorhal/usbd_core.c', 'embed/trezorhal/usbd_ctlreq.c', 'embed/trezorhal/usbd_ioreq.c', - 'embed/trezorhal/utils.c', 'embed/trezorhal/util.s', + 'embed/trezorhal/utils.c', 'embed/trezorhal/vectortable.s', ] @@ -327,7 +331,6 @@ env.Replace( 'embed/firmware', 'embed/trezorhal', 'embed/extmod/modtrezorui', - 'vendor/trezor-storage/c', 'vendor/micropython', 'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Inc', 'vendor/micropython/lib/stm32lib/CMSIS/STM32F4xx/Include', diff --git a/SConscript.unix b/SConscript.unix index 4770d1c39..ac8cdf35e 100644 --- a/SConscript.unix +++ b/SConscript.unix @@ -9,10 +9,14 @@ SOURCE_MOD = [] LIBS_MOD = [] # modtrezorconfig +CPPPATH_MOD += [ + 'embed/extmod/modtrezorconfig', + 'vendor/trezor-storage', +] SOURCE_MOD += [ 'embed/extmod/modtrezorconfig/modtrezorconfig.c', - 'vendor/trezor-storage/c/norcow.c', - 'vendor/trezor-storage/c/storage.c', + 'vendor/trezor-storage/norcow.c', + 'vendor/trezor-storage/storage.c', ] # modtrezorcrypto @@ -296,7 +300,6 @@ env.Replace( '.', 'embed/unix', 'embed/extmod/modtrezorui', - 'vendor/trezor-storage/c', 'vendor/micropython', 'vendor/micropython/ports/unix', 'vendor/micropython/lib/mp-readline', diff --git a/embed/extmod/modtrezorconfig/norcow_config.h b/embed/extmod/modtrezorconfig/norcow_config.h new file mode 100644 index 000000000..1faafd79f --- /dev/null +++ b/embed/extmod/modtrezorconfig/norcow_config.h @@ -0,0 +1,49 @@ +/* + * This file is part of the TREZOR project, https://trezor.io/ + * + * Copyright (c) SatoshiLabs + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __NORCOW_CONFIG_H__ +#define __NORCOW_CONFIG_H__ + +#include "flash.h" + +#define NORCOW_HEADER_LEN 0 +#define NORCOW_SECTOR_COUNT 2 + +#if TREZOR_MODEL == T + +#define NORCOW_SECTOR_SIZE (64*1024) +#define NORCOW_SECTORS {FLASH_SECTOR_STORAGE_1, FLASH_SECTOR_STORAGE_2} + +#elif TREZOR_MODEL == 1 + +#define NORCOW_SECTOR_SIZE (16*1024) +#define NORCOW_SECTORS {2, 3} + +#else + +#error Unknown TREZOR Model + +#endif + +/* + * Current storage version. + */ +#define NORCOW_VERSION ((uint32_t)0x00000001) + +#endif