mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 04:18:10 +00:00
refactor(core): make translations blob handling HW agnostic
[no changelog]
This commit is contained in:
parent
eb6796059c
commit
7c800f183f
@ -197,6 +197,7 @@ SOURCE_MOD += [
|
||||
'embed/lib/image.c',
|
||||
'embed/lib/mini_printf.c',
|
||||
'embed/lib/terminal.c',
|
||||
'embed/lib/translations.c',
|
||||
'embed/lib/unit_variant.c',
|
||||
'vendor/micropython/lib/uzlib/adler32.c',
|
||||
'vendor/micropython/lib/uzlib/crc32.c',
|
||||
|
@ -197,6 +197,7 @@ SOURCE_MOD += [
|
||||
'embed/lib/fonts/fonts.c',
|
||||
'embed/lib/image.c',
|
||||
'embed/lib/terminal.c',
|
||||
'embed/lib/translations.c',
|
||||
'embed/lib/unit_variant.c',
|
||||
'vendor/micropython/lib/uzlib/adler32.c',
|
||||
'vendor/micropython/lib/uzlib/crc32.c',
|
||||
@ -375,7 +376,6 @@ SOURCE_MICROPYTHON = [
|
||||
|
||||
SOURCE_UNIX = [
|
||||
'embed/trezorhal/unix/boot_args.c',
|
||||
'embed/trezorhal/unix/translations.c',
|
||||
'embed/trezorhal/unix/common.c',
|
||||
'embed/trezorhal/unix/display-unix.c',
|
||||
'embed/trezorhal/unix/flash.c',
|
||||
|
@ -13,11 +13,24 @@ bool translations_write(const uint8_t* data, uint32_t offset, uint32_t len) {
|
||||
}
|
||||
|
||||
ensure(flash_unlock_write(), "translations_write unlock");
|
||||
for (int i = 0; i < len; i++) {
|
||||
// TODO optimize by writing by (quad)words
|
||||
ensure(flash_area_write_byte(&TRANSLATIONS_AREA, offset + i, data[i]),
|
||||
for (int i = 0; i < (len / FLASH_BLOCK_SIZE); i++) {
|
||||
// todo consider alignment
|
||||
ensure(flash_area_write_block(&TRANSLATIONS_AREA,
|
||||
offset + (i * FLASH_BLOCK_SIZE),
|
||||
(const uint32_t*)&data[i * FLASH_BLOCK_SIZE]),
|
||||
"translations_write write");
|
||||
}
|
||||
|
||||
if (len % FLASH_BLOCK_SIZE) {
|
||||
flash_block_t block = {0};
|
||||
memset(block, 0xFF, FLASH_BLOCK_SIZE);
|
||||
memcpy(block, data + (len / FLASH_BLOCK_SIZE) * FLASH_BLOCK_SIZE,
|
||||
len % FLASH_BLOCK_SIZE);
|
||||
ensure(flash_area_write_block(
|
||||
&TRANSLATIONS_AREA,
|
||||
offset + (len / FLASH_BLOCK_SIZE) * FLASH_BLOCK_SIZE, block),
|
||||
"translations_write write rest");
|
||||
}
|
||||
ensure(flash_lock_write(), "translations_write lock");
|
||||
return true;
|
||||
}
|
@ -1 +0,0 @@
|
||||
../stm32f4/translations.c
|
@ -53,7 +53,6 @@ def stm32f4_common_files(env, defines, sources, paths):
|
||||
"embed/trezorhal/stm32f4/random_delays.c",
|
||||
"embed/trezorhal/stm32f4/rng.c",
|
||||
"embed/trezorhal/stm32f4/vectortable.s",
|
||||
"embed/trezorhal/stm32f4/translations.c",
|
||||
]
|
||||
|
||||
# boardloader needs separate assembler for some function unencumbered by various FW+bootloader hacks
|
||||
|
Loading…
Reference in New Issue
Block a user