mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 06:48:16 +00:00
core: port storage to T1
This commit is contained in:
parent
2815b62838
commit
c877dc8dd6
@ -28,14 +28,10 @@
|
||||
#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
|
||||
|
||||
@ -43,6 +39,9 @@
|
||||
|
||||
#endif
|
||||
|
||||
#define NORCOW_SECTORS \
|
||||
{ FLASH_SECTOR_STORAGE_1, FLASH_SECTOR_STORAGE_2 }
|
||||
|
||||
/*
|
||||
* Current storage version.
|
||||
*/
|
||||
|
@ -39,6 +39,7 @@ static const uint32_t FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT + 1] = {
|
||||
[9] = 0x080A0000, // - 0x080BFFFF | 128 KiB
|
||||
[10] = 0x080C0000, // - 0x080DFFFF | 128 KiB
|
||||
[11] = 0x080E0000, // - 0x080FFFFF | 128 KiB
|
||||
#if TREZOR_MODEL == T
|
||||
[12] = 0x08100000, // - 0x08103FFF | 16 KiB
|
||||
[13] = 0x08104000, // - 0x08107FFF | 16 KiB
|
||||
[14] = 0x08108000, // - 0x0810BFFF | 16 KiB
|
||||
@ -52,6 +53,9 @@ static const uint32_t FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT + 1] = {
|
||||
[22] = 0x081C0000, // - 0x081DFFFF | 128 KiB
|
||||
[23] = 0x081E0000, // - 0x081FFFFF | 128 KiB
|
||||
[24] = 0x08200000, // last element - not a valid sector
|
||||
#elif TREZOR_MODEL == 1
|
||||
[12] = 0x08100000, // last element - not a valid sector
|
||||
#endif
|
||||
};
|
||||
|
||||
const uint8_t FIRMWARE_SECTORS[FIRMWARE_SECTORS_COUNT] = {
|
||||
|
@ -26,7 +26,11 @@
|
||||
|
||||
// see docs/memory.md for more information
|
||||
|
||||
#if TREZOR_MODEL == T
|
||||
#define FLASH_SECTOR_COUNT 24
|
||||
#elif TREZOR_MODEL == 1
|
||||
#define FLASH_SECTOR_COUNT 12
|
||||
#endif
|
||||
|
||||
#define FLASH_SECTOR_BOARDLOADER_START 0
|
||||
// 1
|
||||
@ -34,7 +38,13 @@
|
||||
|
||||
// 3
|
||||
|
||||
#if TREZOR_MODEL == T
|
||||
#define FLASH_SECTOR_STORAGE_1 4
|
||||
#define FLASH_SECTOR_STORAGE_2 16
|
||||
#elif TREZOR_MODEL == 1
|
||||
#define FLASH_SECTOR_STORAGE_1 2
|
||||
#define FLASH_SECTOR_STORAGE_2 3
|
||||
#endif
|
||||
|
||||
#define FLASH_SECTOR_BOOTLOADER 5
|
||||
|
||||
@ -50,8 +60,6 @@
|
||||
// 14
|
||||
#define FLASH_SECTOR_UNUSED_END 15
|
||||
|
||||
#define FLASH_SECTOR_STORAGE_2 16
|
||||
|
||||
#define FLASH_SECTOR_FIRMWARE_EXTRA_START 17
|
||||
// 18
|
||||
// 19
|
||||
|
@ -47,6 +47,7 @@ static const uint32_t FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT + 1] = {
|
||||
[9] = 0x080A0000, // - 0x080BFFFF | 128 KiB
|
||||
[10] = 0x080C0000, // - 0x080DFFFF | 128 KiB
|
||||
[11] = 0x080E0000, // - 0x080FFFFF | 128 KiB
|
||||
#if TREZOR_MODEL == T
|
||||
[12] = 0x08100000, // - 0x08103FFF | 16 KiB
|
||||
[13] = 0x08104000, // - 0x08107FFF | 16 KiB
|
||||
[14] = 0x08108000, // - 0x0810BFFF | 16 KiB
|
||||
@ -60,6 +61,9 @@ static const uint32_t FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT + 1] = {
|
||||
[22] = 0x081C0000, // - 0x081DFFFF | 128 KiB
|
||||
[23] = 0x081E0000, // - 0x081FFFFF | 128 KiB
|
||||
[24] = 0x08200000, // last element - not a valid sector
|
||||
#elif TREZOR_MODEL == 1
|
||||
[12] = 0x08100000, // last element - not a valid sector
|
||||
#endif
|
||||
};
|
||||
|
||||
const uint8_t FIRMWARE_SECTORS[FIRMWARE_SECTORS_COUNT] = {
|
||||
|
@ -4,11 +4,70 @@ usb.bus.open()
|
||||
|
||||
import trezorio as io
|
||||
from trezorui import Display
|
||||
import storage
|
||||
import storage.resident_credentials
|
||||
from trezor import config
|
||||
|
||||
d = Display()
|
||||
|
||||
d.clear()
|
||||
d.backlight(255)
|
||||
config.init(False)
|
||||
salt = None
|
||||
config.unlock(1, salt)
|
||||
storage.init_unlocked()
|
||||
storage.cache.start_session()
|
||||
print("is_initialized: ", storage.is_initialized())
|
||||
print("version: ", storage.device.is_version_stored())
|
||||
print("version: ", storage.device.get_version())
|
||||
print("needs backup: ", storage.device.needs_backup())
|
||||
storage.device.set_backed_up()
|
||||
print("needs backup: ", storage.device.needs_backup())
|
||||
flags = storage.device.get_flags()
|
||||
print("flags", flags)
|
||||
storage.device.set_flags(0x200)
|
||||
print("flags", storage.device.get_flags())
|
||||
|
||||
secret = "0"*32
|
||||
backup_type = 0
|
||||
storage.device.store_mnemonic_secret(
|
||||
secret,
|
||||
backup_type,
|
||||
needs_backup=True,
|
||||
no_backup=True,
|
||||
)
|
||||
|
||||
|
||||
storage.device.set_unfinished_backup(False)
|
||||
print("unfinished backup: ", storage.device.unfinished_backup())
|
||||
storage.device.set_unfinished_backup(True)
|
||||
print("unfinished backup: ", storage.device.unfinished_backup())
|
||||
|
||||
key54 = storage.common.get(0x1, 54, public=True)
|
||||
print("App key 54:", key54)
|
||||
storage.common.set(0x1, 54, b"asdZ", public=True)
|
||||
key54 = storage.common.get(0x1, 54, public=True)
|
||||
print("App key 54 (2):", key54)
|
||||
key54 = storage.common.delete(0x1, 54, public=True)
|
||||
key54 = storage.common.get(0x1, 54, public=True)
|
||||
print("App key 54 (3):", key54)
|
||||
delay = storage.device.get_autolock_delay_ms()
|
||||
print("delay", delay)
|
||||
storage.device.set_autolock_delay_ms(150000)
|
||||
delay = storage.device.get_autolock_delay_ms()
|
||||
print("delay", delay)
|
||||
|
||||
cache_seed = storage.cache.get(storage.cache.APP_COMMON_SEED)
|
||||
print("cache seed", cache_seed)
|
||||
storage.cache.set(storage.cache.APP_COMMON_SEED, 1234)
|
||||
cache_seed = storage.cache.get(storage.cache.APP_COMMON_SEED)
|
||||
print("cache seed", cache_seed)
|
||||
|
||||
res1 = storage.resident_credentials.get(1)
|
||||
print("Res credential 1", res1)
|
||||
res1 = storage.resident_credentials.set(1, b"0"*31 + b"F")
|
||||
res1 = storage.resident_credentials.get(1)
|
||||
print("Res credential 1", res1)
|
||||
|
||||
i = 0
|
||||
|
||||
@ -20,3 +79,4 @@ while True:
|
||||
print("TOUCH", r)
|
||||
else:
|
||||
print("NOTOUCH")
|
||||
# d.refresh()
|
||||
|
1
core/src1/storage/__init__.py
Symbolic link
1
core/src1/storage/__init__.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../src/storage/__init__.py
|
1
core/src1/storage/cache.py
Symbolic link
1
core/src1/storage/cache.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../src/storage/cache.py
|
1
core/src1/storage/common.py
Symbolic link
1
core/src1/storage/common.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../src/storage/common.py
|
1
core/src1/storage/device.py
Symbolic link
1
core/src1/storage/device.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../src/storage/device.py
|
1
core/src1/storage/resident_credentials.py
Symbolic link
1
core/src1/storage/resident_credentials.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../src/storage/resident_credentials.py
|
1
core/src1/trezor/__init__.py
Symbolic link
1
core/src1/trezor/__init__.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../src/trezor/__init__.py
|
1
core/src1/trezor/crypto/__init__.py
Symbolic link
1
core/src1/trezor/crypto/__init__.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../../src/trezor/crypto/__init__.py
|
1
core/src1/trezor/crypto/base32.py
Symbolic link
1
core/src1/trezor/crypto/base32.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../../src/trezor/crypto/base32.py
|
1
core/src1/trezor/crypto/base58.py
Symbolic link
1
core/src1/trezor/crypto/base58.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../../src/trezor/crypto/base58.py
|
1
core/src1/trezor/crypto/bech32.py
Symbolic link
1
core/src1/trezor/crypto/bech32.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../../src/trezor/crypto/bech32.py
|
1
core/src1/trezor/crypto/cashaddr.py
Symbolic link
1
core/src1/trezor/crypto/cashaddr.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../../src/trezor/crypto/cashaddr.py
|
1
core/src1/trezor/crypto/curve.py
Symbolic link
1
core/src1/trezor/crypto/curve.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../../src/trezor/crypto/curve.py
|
1
core/src1/trezor/crypto/der.py
Symbolic link
1
core/src1/trezor/crypto/der.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../../src/trezor/crypto/der.py
|
1
core/src1/trezor/crypto/hashlib.py
Symbolic link
1
core/src1/trezor/crypto/hashlib.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../../src/trezor/crypto/hashlib.py
|
1
core/src1/trezor/crypto/hmac.py
Symbolic link
1
core/src1/trezor/crypto/hmac.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../../src/trezor/crypto/hmac.py
|
1
core/src1/trezor/crypto/rlp.py
Symbolic link
1
core/src1/trezor/crypto/rlp.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../../src/trezor/crypto/rlp.py
|
1
core/src1/trezor/crypto/scripts.py
Symbolic link
1
core/src1/trezor/crypto/scripts.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../../src/trezor/crypto/scripts.py
|
1
core/src1/trezor/crypto/slip39.py
Symbolic link
1
core/src1/trezor/crypto/slip39.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../../src/trezor/crypto/slip39.py
|
1
core/src1/trezor/log.py
Symbolic link
1
core/src1/trezor/log.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../src/trezor/log.py
|
1
core/src1/trezor/messages/BackupType.py
Symbolic link
1
core/src1/trezor/messages/BackupType.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../../src/trezor/messages/BackupType.py
|
1
core/src1/trezor/utils.py
Symbolic link
1
core/src1/trezor/utils.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../src/trezor/utils.py
|
Loading…
Reference in New Issue
Block a user