From 089db2cadf12612c8e2f52e51174cd640d58f6b9 Mon Sep 17 00:00:00 2001 From: cepetr Date: Fri, 15 Nov 2024 10:07:01 +0100 Subject: [PATCH] refactor(core): restructure embed folder [no changelog] --- .github/workflows/core-hw.yml | 2 +- .gitlab-ci.yml | 2 +- Makefile | 6 +- ci/check_changelog.sh | 8 +- ci/deploy.yml | 10 +- core/Makefile | 6 +- core/SConscript.boardloader | 50 +- core/SConscript.bootloader | 63 +-- core/SConscript.bootloader_ci | 62 +-- core/SConscript.bootloader_emu | 107 +++-- core/SConscript.firmware | 77 +-- core/SConscript.kernel | 73 +-- core/SConscript.prodtest | 54 ++- core/SConscript.reflash | 48 +- core/SConscript.unix | 113 +++-- core/embed/boardloader/.towncrier.template.md | 1 - core/embed/boardloader/CHANGELOG.unreleased | 1 - core/embed/boardloader/towncrier.toml | 1 - core/embed/bootloader/.towncrier.template.md | 1 - core/embed/bootloader/CHANGELOG.unreleased | 1 - core/embed/bootloader/towncrier.toml | 1 - .../bootloader_ci/.towncrier.template.md | 1 - core/embed/bootloader_ci/CHANGELOG.unreleased | 1 - core/embed/bootloader_ci/towncrier.toml | 1 - .../{trezorhal => gfx/bitblt}/dma2d_bitblt.h | 2 +- core/embed/gfx/bitblt/gfx_bitblt.c | 32 ++ .../{lib => gfx/bitblt}/gfx_bitblt_mono8.c | 2 +- .../{lib => gfx/bitblt}/gfx_bitblt_rgb565.c | 2 +- .../{lib => gfx/bitblt}/gfx_bitblt_rgba8888.c | 2 +- .../bitblt/stm32}/dma2d_bitblt.c | 5 +- core/embed/{lib => gfx}/fonts/font_bitmap.c | 0 core/embed/{lib => gfx}/fonts/font_bitmap.h | 0 .../fonts/font_pixeloperator_bold_8.c | 0 .../fonts/font_pixeloperator_bold_8.h | 0 .../fonts/font_pixeloperator_regular_8.c | 0 .../fonts/font_pixeloperator_regular_8.h | 0 .../fonts/font_pixeloperatormono_regular_8.c | 0 .../fonts/font_pixeloperatormono_regular_8.h | 0 .../{lib => gfx}/fonts/font_roboto_bold_20.c | 0 .../{lib => gfx}/fonts/font_roboto_bold_20.h | 0 .../fonts/font_roboto_regular_20.c | 0 .../fonts/font_roboto_regular_20.h | 0 .../fonts/font_robotomono_medium_20.c | 0 .../fonts/font_robotomono_medium_20.h | 0 .../fonts/font_robotomono_medium_21.c | 0 .../fonts/font_robotomono_medium_21.h | 0 .../{lib => gfx}/fonts/font_tthoves_bold_17.c | 0 .../{lib => gfx}/fonts/font_tthoves_bold_17.h | 0 .../fonts/font_tthoves_demibold_21.c | 0 .../fonts/font_tthoves_demibold_21.h | 0 .../fonts/font_tthoves_regular_21.c | 0 .../fonts/font_tthoves_regular_21.h | 0 .../fonts/font_ttsatoshi_demibold_18.c | 0 .../fonts/font_ttsatoshi_demibold_18.h | 0 .../fonts/font_ttsatoshi_demibold_21.c | 0 .../fonts/font_ttsatoshi_demibold_21.h | 0 .../fonts/font_ttsatoshi_demibold_42.c | 0 .../fonts/font_ttsatoshi_demibold_42.h | 0 .../{lib => gfx}/fonts/font_unifont_bold_16.c | 0 .../{lib => gfx}/fonts/font_unifont_bold_16.h | 0 .../fonts/font_unifont_regular_16.c | 0 .../fonts/font_unifont_regular_16.h | 0 core/embed/{lib => gfx}/fonts/fonts.c | 0 core/embed/{lib => gfx}/fonts/fonts.h | 2 +- core/embed/{lib => gfx}/gfx_color.c | 2 +- core/embed/{lib => gfx}/gfx_draw.c | 8 +- .../dma2d_bitblt.c => gfx/inc/gfx/fonts.h} | 6 +- core/embed/{lib => gfx/inc/gfx}/gfx_bitblt.h | 8 +- core/embed/{lib => gfx/inc/gfx}/gfx_color.h | 0 core/embed/{lib => gfx/inc/gfx}/gfx_draw.h | 2 +- core/embed/{lib => gfx/inc/gfx}/terminal.h | 2 +- .../{lib/qr-code-generator => gfx/qrcode} | 0 core/embed/{lib => gfx}/terminal.c | 10 +- .../{trezorhal => io/button/inc/io}/button.h | 0 .../stm32f4 => io/button/stm32}/button.c | 2 +- .../{trezorhal => io/button}/unix/button.c | 2 +- .../display/backlight}/backlight_pwm.h | 0 .../display/backlight/stm32}/backlight_pwm.c | 5 +- .../display/bg_copy}/bg_copy.h | 0 .../display/bg_copy}/stm32u5/bg_copy.c | 14 +- .../embed/{lib => io/display}/display_utils.c | 4 +- .../display/inc/io}/display.h | 2 +- .../display/inc/io}/display_utils.h | 0 .../display}/st-7789/display_driver.c | 9 +- .../display}/st-7789/display_fb.c | 23 +- .../display}/st-7789/display_fb.h | 0 .../display}/st-7789/display_internal.h | 0 .../display}/st-7789/display_io.c | 4 +- .../display}/st-7789/display_io.h | 0 .../display}/st-7789/display_nofb.c | 2 +- .../display}/st-7789/display_panel.c | 0 .../display}/st-7789/display_panel.h | 0 .../display}/st-7789/panels/154a.c | 0 .../display}/st-7789/panels/154a.h | 0 .../display}/st-7789/panels/lhs200kb-if21.c | 0 .../display}/st-7789/panels/lhs200kb-if21.h | 0 .../display}/st-7789/panels/lx154a2411.c | 0 .../display}/st-7789/panels/lx154a2411.h | 0 .../display}/st-7789/panels/lx154a2422.c | 0 .../display}/st-7789/panels/lx154a2422.h | 0 .../display}/st-7789/panels/lx154a2482.c | 0 .../display}/st-7789/panels/lx154a2482.h | 0 .../display}/st-7789/panels/tf15411a.c | 0 .../display}/st-7789/panels/tf15411a.h | 0 .../display}/st7785ma/display_driver.c | 2 +- .../stm32f429i-disc1/display_driver.c | 5 +- .../stm32f429i-disc1/display_internal.h | 2 +- .../display}/stm32f429i-disc1/display_ltdc.c | 2 +- .../display}/stm32f429i-disc1/ili9341_spi.c | 0 .../display}/stm32f429i-disc1/ili9341_spi.h | 0 .../display}/stm32u5a9j-dk/display_driver.c | 5 +- .../display}/stm32u5a9j-dk/display_fb.c | 10 +- .../stm32u5a9j-dk/display_gfxmmu_lut.h | 0 .../display}/stm32u5a9j-dk/display_internal.h | 7 +- .../display}/stm32u5a9j-dk/display_ltdc_dsi.c | 2 +- .../display}/unix/display_driver.c | 2 +- .../display}/vg-2864/display_driver.c | 13 +- .../haptic/drv2625/actuators/vg1040003d.h | 0 .../stm32u5 => io}/haptic/drv2625/drv2625.c | 5 +- .../stm32u5 => io}/haptic/drv2625/drv2625.h | 0 .../{trezorhal => io/haptic/inc/io}/haptic.h | 0 .../i2c_bus/inc/io}/i2c_bus.h | 0 .../i2c_bus}/stm32f4/i2c_bus.c | 36 +- .../i2c_bus}/stm32u5/i2c_bus.c | 43 +- .../rgb_led/inc/io}/rgb_led.h | 0 .../rgb_led}/stm32f4/rgb_led.c | 0 core/embed/{trezorhal => io/sbu/inc/io}/sbu.h | 0 .../{trezorhal/stm32f4 => io/sbu/stm32}/sbu.c | 2 +- core/embed/{trezorhal => io/sbu}/unix/sbu.c | 2 +- .../{trezorhal => io/sdcard/inc/io}/sdcard.h | 0 .../stm32f4/sdcard-set_clr_card_detect.h | 0 .../{trezorhal => io/sdcard}/stm32f4/sdcard.c | 14 +- .../{trezorhal => io/sdcard}/stm32u5/sdcard.c | 10 +- .../{trezorhal => io/sdcard}/unix/sdcard.c | 2 +- .../touch => io/touch/ft6x36}/ft6x36.c | 6 +- .../touch => io/touch/ft6x36}/ft6x36.h | 0 .../touch/ft6x36}/panels/lhs200kb-if21.c | 2 +- .../touch/ft6x36}/panels/lhs200kb-if21.h | 0 .../touch/ft6x36}/panels/lx154a2422cpt23.c | 2 +- .../touch/ft6x36}/panels/lx154a2422cpt23.h | 0 .../{trezorhal => io/touch/inc/io}/touch.h | 0 .../touch => io/touch/sitronix}/sitronix.c | 6 +- .../touch => io/touch/stmpe811}/stmpe811.c | 4 +- .../touch => io/touch/stmpe811}/stmpe811.h | 0 .../{trezorhal => io/touch}/unix/touch.c | 2 +- core/embed/{trezorhal => io/usb/inc/io}/usb.h | 6 +- .../{trezorhal => io/usb/inc/io}/usb_hid.h | 0 .../{trezorhal => io/usb/inc/io}/usb_vcp.h | 0 .../{trezorhal => io/usb/inc/io}/usb_webusb.h | 0 .../stm32f4/usb => io/usb/stm32}/usb.c | 7 +- .../usb => io/usb/stm32}/usb_class_hid.c | 5 +- .../usb => io/usb/stm32}/usb_class_vcp.c | 3 +- .../usb => io/usb/stm32}/usb_class_webusb.c | 5 +- .../usb => io/usb/stm32}/usb_internal.h | 0 .../stm32f4/usb => io/usb/stm32}/usbd_conf.c | 28 +- .../stm32f4/usb => io/usb/stm32}/usbd_conf.h | 0 .../stm32f4/usb => io/usb/stm32}/usbd_core.c | 0 .../stm32f4/usb => io/usb/stm32}/usbd_core.h | 0 .../usb => io/usb/stm32}/usbd_ctlreq.c | 0 .../usb => io/usb/stm32}/usbd_ctlreq.h | 0 .../stm32f4/usb => io/usb/stm32}/usbd_def.h | 0 .../stm32f4/usb => io/usb/stm32}/usbd_ioreq.c | 0 .../stm32f4/usb => io/usb/stm32}/usbd_ioreq.h | 0 core/embed/{trezorhal => io/usb}/unix/usb.c | 2 +- core/embed/models/D002/model_D002.h | 2 +- core/embed/models/T3B1/model_T3B1.h | 2 +- core/embed/models/T3T1/model_T3T1.h | 2 +- core/embed/models/T3W1/model_T3W1.h | 2 +- core/embed/models/layout_common.h | 14 - core/embed/models/otp_layout.h | 28 ++ core/embed/models/trezor_model.h | 4 +- core/embed/prodtest/.towncrier.template.md | 1 - core/embed/prodtest/CHANGELOG.unreleased | 1 - core/embed/prodtest/towncrier.toml | 1 - .../boardloader/.changelog.d/.gitignore | 0 .../boardloader/.towncrier.template.md | 1 + .../{ => projects}/boardloader/CHANGELOG.md | 0 .../projects/boardloader/CHANGELOG.unreleased | 1 + core/embed/{ => projects}/boardloader/main.c | 71 ++- .../embed/projects/boardloader/towncrier.toml | 1 + .../{ => projects}/boardloader/version.h | 0 .../bootloader/.changelog.d/.gitignore | 0 .../bootloader/.towncrier.template.md | 1 + .../{ => projects}/bootloader/CHANGELOG.md | 0 .../projects/bootloader/CHANGELOG.unreleased | 1 + .../bootloader/bootloader_flash.jlink | 0 core/embed/{ => projects}/bootloader/bootui.c | 12 +- core/embed/{ => projects}/bootloader/bootui.h | 2 +- .../{ => projects}/bootloader/emulator.c | 13 +- .../{ => projects}/bootloader/emulator.h | 0 core/embed/{ => projects}/bootloader/header.S | 0 core/embed/{ => projects}/bootloader/main.c | 63 ++- .../{ => projects}/bootloader/messages.c | 16 +- .../{ => projects}/bootloader/messages.h | 2 +- .../bootloader/protob/.gitignore | 0 .../{ => projects}/bootloader/protob/Makefile | 0 .../bootloader/protob/messages.options | 0 .../bootloader/protob/messages.pb.c | 0 .../bootloader/protob/messages.pb.h | 0 .../bootloader/protob/messages.proto | 0 core/embed/projects/bootloader/towncrier.toml | 1 + .../embed/{ => projects}/bootloader/version.h | 0 .../{ => projects}/bootloader/version_check.c | 2 +- .../{ => projects}/bootloader/version_check.h | 0 .../bootloader_ci/.changelog.d/.gitignore | 0 .../bootloader_ci/.changelog.d/1049.added | 0 .../bootloader_ci/.changelog.d/1599.changed | 0 .../bootloader_ci/.changelog.d/2243.added | 0 .../bootloader_ci/.changelog.d/2414.added | 0 .../bootloader_ci/.changelog.d/2623.added | 0 .../bootloader_ci/.changelog.d/3205.added | 0 .../bootloader_ci/.changelog.d/3370.added | 0 .../bootloader_ci/.towncrier.template.md | 1 + .../{ => projects}/bootloader_ci/CHANGELOG.md | 0 .../bootloader_ci/CHANGELOG.unreleased | 1 + .../{ => projects}/bootloader_ci/README.md | 0 .../bootloader_ci/bootloader_flash.jlink | 0 .../{ => projects}/bootloader_ci/bootui.c | 10 +- .../{ => projects}/bootloader_ci/bootui.h | 0 .../{ => projects}/bootloader_ci/header.S | 0 .../{ => projects}/bootloader_ci/icon_done.h | 0 .../{ => projects}/bootloader_ci/icon_fail.h | 0 .../bootloader_ci/icon_install.h | 0 .../bootloader_ci/icon_welcome.h | 0 .../{ => projects}/bootloader_ci/icon_wipe.h | 0 .../embed/{ => projects}/bootloader_ci/main.c | 36 +- .../{ => projects}/bootloader_ci/messages.c | 8 +- .../{ => projects}/bootloader_ci/messages.h | 2 +- .../embed/{ => projects}/bootloader_ci/protob | 0 .../projects/bootloader_ci/towncrier.toml | 1 + .../{ => projects}/bootloader_ci/version.h | 0 .../bootloader_ci/version_check.c | 0 .../bootloader_ci/version_check.h | 0 core/embed/{ => projects}/firmware/header.S | 0 core/embed/{ => projects}/firmware/main.c | 6 +- .../{ => projects}/firmware/mpconfigport.h | 2 +- .../embed/{ => projects}/firmware/mphalport.c | 4 +- .../embed/{ => projects}/firmware/mphalport.h | 0 core/embed/{ => projects}/firmware/nlrthumb.c | 0 core/embed/{ => projects}/firmware/version.h | 0 core/embed/{ => projects}/kernel/main.c | 91 ++-- core/embed/{ => projects}/kernel/version.h | 0 .../prodtest/.changelog.d/.keep | 0 .../prodtest/.changelog.d/4310.fixed | 0 .../prodtest/.changelog.d/4313.fixed | 0 .../projects/prodtest/.towncrier.template.md | 1 + .../{ => projects}/prodtest/CHANGELOG.md | 0 .../projects/prodtest/CHANGELOG.unreleased | 1 + core/embed/{ => projects}/prodtest/README.md | 0 core/embed/{ => projects}/prodtest/header.S | 0 core/embed/{ => projects}/prodtest/main.c | 64 ++- .../{ => projects}/prodtest/optiga_prodtest.c | 8 +- .../{ => projects}/prodtest/optiga_prodtest.h | 0 .../{ => projects}/prodtest/prodtest_common.c | 4 +- .../{ => projects}/prodtest/prodtest_common.h | 0 core/embed/projects/prodtest/towncrier.toml | 1 + core/embed/{ => projects}/prodtest/version.h | 0 core/embed/{ => projects}/reflash/header.S | 0 core/embed/{ => projects}/reflash/main.c | 26 +- core/embed/{ => projects}/reflash/version.h | 0 core/embed/{ => projects}/unix/main.c | 24 +- core/embed/{ => projects}/unix/main_main.c | 2 +- core/embed/{ => projects}/unix/mpconfigport.h | 0 core/embed/{ => projects}/unix/profile.c | 0 core/embed/{ => projects}/unix/profile.h | 0 core/embed/{ => projects}/unix/version.h | 0 core/embed/{lib => rtl}/error_handling.c | 2 +- core/embed/{lib => rtl/inc}/assert.h | 0 core/embed/{lib => rtl/inc}/common.h | 10 +- .../{lib => rtl/inc/rtl}/compiler_traits.h | 0 .../{lib => rtl/inc/rtl}/error_handling.h | 0 core/embed/{lib => rtl/inc/rtl}/mini_printf.h | 0 core/embed/{lib => rtl/inc/rtl}/secbool.h | 0 core/embed/{lib => rtl/inc/rtl}/sizedefs.h | 0 core/embed/rtl/inc/secbool.h | 25 + core/embed/{lib => rtl/inc}/trezor_rtl.h | 3 +- core/embed/{lib => rtl/inc}/trezor_types.h | 2 +- core/embed/{lib => rtl}/mini_printf.c | 2 +- core/embed/rust/build.rs | 24 +- core/embed/rust/micropython.h | 2 +- core/embed/rust/src/micropython/macros.rs | 2 +- core/embed/rust/src/trezorhal/bitblt.rs | 7 +- core/embed/rust/src/ui/display/font.rs | 2 +- core/embed/rust/trezorhal.h | 39 +- .../inc/sec}/consumption_mask.h | 0 .../stm32f4/consumption_mask.c | 4 +- .../stm32u5/consumption_mask.c | 2 +- .../entropy/inc/sec}/entropy.h | 0 .../entropy}/stm32f4/entropy.c | 6 +- .../entropy}/stm32u5/entropy.c | 6 +- .../{trezorhal => sec/entropy}/unix/entropy.c | 2 +- .../hash_processor/inc/sec}/hash_processor.h | 0 .../hash_processor}/stm32u5/hash_processor.c | 6 +- .../monoctr/inc/sec}/monoctr.h | 0 .../monoctr}/stm32f4/monoctr.c | 6 +- .../monoctr}/stm32u5/monoctr.c | 6 +- .../{trezorhal => sec/monoctr}/unix/monoctr.c | 4 +- core/embed/sec/optiga/inc/optiga.h | 25 + .../optiga/inc/sec}/optiga.h | 0 .../optiga/inc/sec}/optiga_commands.h | 0 .../optiga/inc/sec}/optiga_common.h | 0 .../optiga/inc/sec}/optiga_hal.h | 0 .../optiga/inc/sec}/optiga_transport.h | 0 core/embed/{trezorhal => sec}/optiga/optiga.c | 6 +- .../optiga/optiga_commands.c | 4 +- .../optiga/optiga_transport.c | 8 +- .../optiga}/stm32f4/optiga_hal.c | 4 +- .../optiga}/stm32u5/optiga_hal.c | 0 .../optiga}/unix/certs/README.md | 0 .../optiga}/unix/certs/T2B1.der | Bin .../optiga}/unix/certs/T2B1.h | 0 .../optiga}/unix/certs/T3T1.der | Bin .../optiga}/unix/certs/T3T1.h | 0 .../optiga}/unix/certs/gen.sh | 0 .../{trezorhal => sec/optiga}/unix/optiga.c | 4 +- .../optiga}/unix/optiga_hal.c | 0 .../sec/random_delays/inc/random_delays.h | 25 + .../random_delays/inc/sec}/random_delays.h | 0 .../random_delays/stm32}/random_delays.c | 4 +- .../random_delays}/unix/random_delays.c | 2 +- .../{trezorhal => sec/rng/inc/sec}/rng.h | 0 .../stm32f4 => sec/rng/stm32}/rng.c | 2 +- core/embed/{trezorhal => sec/rng}/unix/rng.c | 2 +- .../secret/inc/sec}/secret.h | 0 .../secret}/stm32f4/secret.c | 6 +- .../secret}/stm32u5/secret.c | 14 +- .../{trezorhal => sec/secret}/unix/secret.c | 0 .../secure_aes/inc/sec}/secure_aes.h | 0 core/embed/sec/secure_aes/inc/secure_aes.h | 25 + .../secure_aes}/stm32u5/secure_aes.c | 13 +- .../time_estimate/inc/sec}/time_estimate.h | 0 .../sec/time_estimate/inc/time_estimate.h | 25 + .../time_estimate/stm32}/time_estimate.c | 2 +- .../time_estimate}/unix/time_estimate.c | 2 +- .../{models => sys/bsp/inc}/trezor_bsp.h | 0 .../bsp}/stm32f4/stm32f4xx_hal_conf.h | 0 .../bsp}/stm32u5/stm32u5xx_hal_conf.h | 0 .../stm32f4 => sys/irq/inc/sys}/irq.h | 17 +- .../linker/stm32f4}/boardloader.ld | 2 +- .../linker/stm32f4}/bootloader.ld | 2 +- .../linker => sys/linker/stm32f4}/firmware.ld | 2 +- .../linker => sys/linker/stm32f4}/kernel.ld | 2 +- .../linker => sys/linker/stm32f4}/memory.ld | 0 .../linker => sys/linker/stm32f4}/prodtest.ld | 2 +- .../linker/stm32u58}/boardloader.ld | 2 +- .../u58 => sys/linker/stm32u58}/bootloader.ld | 2 +- .../u58 => sys/linker/stm32u58}/firmware.ld | 2 +- .../u58 => sys/linker/stm32u58}/kernel.ld | 2 +- .../u58 => sys/linker/stm32u58}/memory.ld | 0 .../u58 => sys/linker/stm32u58}/prodtest.ld | 2 +- .../linker/stm32u5g}/boardloader.ld | 2 +- .../u5g => sys/linker/stm32u5g}/bootloader.ld | 2 +- .../u5g => sys/linker/stm32u5g}/firmware.ld | 2 +- .../u5g => sys/linker/stm32u5g}/kernel.ld | 2 +- .../u5g => sys/linker/stm32u5g}/memory.ld | 0 .../u5g => sys/linker/stm32u5g}/prodtest.ld | 2 +- .../{trezorhal => sys/mpu/inc/sys}/mpu.h | 0 .../{trezorhal => sys/mpu}/stm32f4/mpu.c | 6 +- .../{trezorhal => sys/mpu}/stm32u5/mpu.c | 8 +- core/embed/{trezorhal => sys/mpu}/unix/mpu.c | 2 +- .../{trezorhal => sys/pvd/inc/sys}/pvd.h | 0 .../stm32f4 => sys/pvd/stm32}/pvd.c | 6 +- core/embed/sys/sdram/inc/sys/sdram.h | 28 ++ .../sdram/stm32f429i-disc1/sdram_bsp.c} | 8 +- .../sdram/stm32f429i-disc1/sdram_bsp.h} | 10 - .../startup/inc/sys}/bootargs.h | 0 .../startup/inc/sys}/bootutils.h | 0 .../startup/inc/sys}/reset_flags.h | 0 .../stm32f4 => sys/startup/stm32}/bootutils.c | 14 +- .../startup}/stm32f4/limited_util.S | 0 .../startup}/stm32f4/reset_flags.c | 2 +- .../startup}/stm32f4/startup_init.c | 6 +- .../startup}/stm32f4/startup_init.h | 0 .../startup}/stm32f4/startup_stage_0.s | 0 .../startup}/stm32f4/startup_stage_1.s | 0 .../startup}/stm32f4/startup_stage_2.s | 0 .../startup}/stm32f4/startup_stage_4.s | 0 .../{trezorhal => sys/startup}/stm32f4/util.S | 0 .../startup}/stm32f4/vectortable.S | 0 .../startup}/stm32u5/limited_util.S | 0 .../startup}/stm32u5/reset_flags.c | 2 +- .../startup}/stm32u5/startup_init.c | 2 +- .../startup}/stm32u5/startup_stage_0.s | 0 .../startup}/stm32u5/startup_stage_1.s | 0 .../startup}/stm32u5/startup_stage_2.s | 0 .../startup}/stm32u5/startup_stage_4.s | 0 .../{trezorhal => sys/startup}/stm32u5/util.S | 0 .../startup}/stm32u5/vectortable.S | 0 .../startup}/unix/bootutils.c | 6 +- core/embed/sys/syscall/inc/sys/syscall.h | 78 +++ .../stm32f4 => sys/syscall/stm32}/syscall.c | 7 +- .../syscall/stm32}/syscall_dispatch.c | 64 ++- .../syscall/stm32/syscall_internal.h} | 60 +-- .../syscall/stm32}/syscall_numbers.h | 0 .../syscall/stm32}/syscall_probe.c | 3 +- .../syscall/stm32}/syscall_probe.h | 2 +- .../syscall/stm32}/syscall_stubs.c | 63 ++- .../syscall/stm32}/syscall_verifiers.c | 11 +- .../syscall/stm32}/syscall_verifiers.h | 33 +- .../systemview/inc/sys}/systemview.h | 7 - .../stm32/config}/SEGGER_RTT_Conf.h | 0 .../stm32/config}/SEGGER_SYSVIEW_Conf.h | 0 .../config}/SEGGER_SYSVIEW_Config_NoOS.c | 0 .../systemview/stm32/segger}/Global.h | 0 .../systemview/stm32/segger}/SEGGER.h | 0 .../systemview/stm32/segger}/SEGGER_RTT.c | 0 .../systemview/stm32/segger}/SEGGER_RTT.h | 0 .../stm32/segger}/SEGGER_RTT_ASM_ARMv7M.S | 0 .../stm32/segger}/SEGGER_RTT_printf.c | 0 .../systemview/stm32/segger}/SEGGER_SYSVIEW.c | 0 .../systemview/stm32/segger}/SEGGER_SYSVIEW.h | 0 .../segger}/SEGGER_SYSVIEW_ConfDefaults.h | 0 .../stm32/segger}/SEGGER_SYSVIEW_Int.h | 0 .../Syscalls/SEGGER_RTT_Syscalls_GCC.c | 0 .../{firmware => sys/systemview}/systemview.c | 2 +- .../tamper/inc/sys}/tamper.h | 0 .../tamper}/stm32u5/tamper.c | 6 +- .../{trezorhal => sys/task/inc/sys}/applet.h | 2 +- .../{trezorhal => sys/task/inc/sys}/systask.h | 2 +- .../{trezorhal => sys/task/inc/sys}/system.h | 2 +- .../stm32f4 => sys/task/stm32}/applet.c | 15 +- .../stm32f4 => sys/task/stm32}/systask.c | 23 +- .../stm32f4 => sys/task/stm32}/system.c | 21 +- .../{trezorhal => sys/task}/unix/system.c | 8 +- .../{trezorhal => sys/time/inc/sys}/systick.h | 0 .../time/inc/sys}/systimer.h | 0 .../stm32f4 => sys/time/stm32}/systick.c | 16 +- .../time/stm32}/systick_internal.h | 2 +- .../stm32f4 => sys/time/stm32}/systimer.c | 4 +- .../{trezorhal => sys/time}/unix/systick.c | 2 +- .../{trezorhal => sys/time}/unix/systimer.c | 2 +- .../trustzone/inc/sys}/trustzone.h | 0 .../trustzone}/stm32u5/trustzone.c | 8 +- core/embed/trezorhal/stm32f4/systemview.h | 1 - .../stm32f4/xdisplay/ug-2828/display_driver.c | 454 ------------------ core/embed/trezorhal/stm32u5/applet.c | 1 - core/embed/trezorhal/stm32u5/backlight_pwm.c | 1 - core/embed/trezorhal/stm32u5/backlight_pwm.h | 1 - .../trezorhal/stm32u5/board_capabilities.c | 1 - core/embed/trezorhal/stm32u5/bootutils.c | 1 - core/embed/trezorhal/stm32u5/button.c | 1 - core/embed/trezorhal/stm32u5/dma2d_bitblt.c | 1 - core/embed/trezorhal/stm32u5/fwutils.c | 1 - core/embed/trezorhal/stm32u5/irq.h | 1 - core/embed/trezorhal/stm32u5/layout_helpers.h | 1 - core/embed/trezorhal/stm32u5/pvd.c | 1 - core/embed/trezorhal/stm32u5/random_delays.c | 1 - core/embed/trezorhal/stm32u5/rng.c | 1 - core/embed/trezorhal/stm32u5/sbu.c | 1 - core/embed/trezorhal/stm32u5/syscall.c | 1 - core/embed/trezorhal/stm32u5/syscall.h | 1 - .../trezorhal/stm32u5/syscall_dispatch.c | 1 - .../embed/trezorhal/stm32u5/syscall_numbers.h | 1 - core/embed/trezorhal/stm32u5/syscall_probe.c | 1 - core/embed/trezorhal/stm32u5/syscall_probe.h | 1 - core/embed/trezorhal/stm32u5/syscall_stubs.c | 1 - .../trezorhal/stm32u5/syscall_verifiers.c | 1 - .../trezorhal/stm32u5/syscall_verifiers.h | 1 - core/embed/trezorhal/stm32u5/systask.c | 1 - core/embed/trezorhal/stm32u5/system.c | 1 - core/embed/trezorhal/stm32u5/systemview.h | 1 - core/embed/trezorhal/stm32u5/systick.c | 1 - .../trezorhal/stm32u5/systick_internal.h | 1 - core/embed/trezorhal/stm32u5/systimer.c | 1 - core/embed/trezorhal/stm32u5/time_estimate.c | 1 - core/embed/trezorhal/stm32u5/touch/ft6x36.c | 1 - core/embed/trezorhal/stm32u5/touch/ft6x36.h | 1 - core/embed/trezorhal/stm32u5/touch/panels | 1 - core/embed/trezorhal/stm32u5/touch/sitronix.h | 0 .../embed/trezorhal/stm32u5/unit_properties.c | 1 - core/embed/trezorhal/stm32u5/usb | 1 - core/embed/trezorhal/stm32u5/xdisplay/st-7789 | 1 - core/embed/trezorhal/stm32u5/xdisplay/vg-2864 | 1 - core/embed/trezorhal/unix/fwutils.c | 1 - .../modtrezorconfig/modtrezorconfig.c | 4 +- .../modtrezorconfig/norcow_config.h | 2 +- .../{extmod => upymod}/modtrezorcrypto/crc.c | 0 .../{extmod => upymod}/modtrezorcrypto/crc.h | 0 .../modtrezorcrypto/hdnode.h | 0 .../modtrezorcrypto/modtrezorcrypto-aes.h | 0 .../modtrezorcrypto/modtrezorcrypto-aesgcm.h | 0 .../modtrezorcrypto/modtrezorcrypto-bech32.h | 2 +- .../modtrezorcrypto/modtrezorcrypto-bip32.h | 2 +- .../modtrezorcrypto/modtrezorcrypto-bip340.h | 0 .../modtrezorcrypto/modtrezorcrypto-bip39.h | 0 .../modtrezorcrypto-blake256.h | 0 .../modtrezorcrypto/modtrezorcrypto-blake2b.h | 2 +- .../modtrezorcrypto/modtrezorcrypto-blake2s.h | 2 +- .../modtrezorcrypto/modtrezorcrypto-cardano.h | 2 +- .../modtrezorcrypto-chacha20poly1305.h | 0 .../modtrezorcrypto/modtrezorcrypto-crc.h | 2 +- .../modtrezorcrypto-curve25519.h | 0 .../modtrezorcrypto/modtrezorcrypto-ed25519.h | 0 .../modtrezorcrypto-elligator2.h | 2 +- .../modtrezorcrypto/modtrezorcrypto-groestl.h | 0 .../modtrezorcrypto/modtrezorcrypto-hmac.h | 0 .../modtrezorcrypto/modtrezorcrypto-monero.h | 2 +- .../modtrezorcrypto/modtrezorcrypto-nem.h | 2 +- .../modtrezorcrypto-nist256p1.h | 0 .../modtrezorcrypto/modtrezorcrypto-optiga.h | 4 +- .../modtrezorcrypto/modtrezorcrypto-pbkdf2.h | 0 .../modtrezorcrypto/modtrezorcrypto-random.h | 4 +- .../modtrezorcrypto-ripemd160.h | 0 .../modtrezorcrypto-secp256k1.h | 0 .../modtrezorcrypto/modtrezorcrypto-sha1.h | 0 .../modtrezorcrypto/modtrezorcrypto-sha256.h | 0 .../modtrezorcrypto-sha3-256.h | 0 .../modtrezorcrypto-sha3-512.h | 0 .../modtrezorcrypto/modtrezorcrypto-sha512.h | 0 .../modtrezorcrypto/modtrezorcrypto-shamir.h | 2 +- .../modtrezorcrypto/modtrezorcrypto-slip39.h | 0 .../modtrezorcrypto/modtrezorcrypto.c | 0 .../{extmod => upymod}/modtrezorcrypto/rand.c | 2 +- .../{extmod => upymod}/modtrezorio/diskio.h | 0 .../embed/{extmod => upymod}/modtrezorio/ff.c | 0 .../embed/{extmod => upymod}/modtrezorio/ff.h | 0 .../modtrezorio/ff_unifdef.sh | 0 .../{extmod => upymod}/modtrezorio/ffconf.h | 0 .../modtrezorio/ffunicode.c | 0 .../modtrezorio/modtrezorio-fatfs.h | 4 +- .../modtrezorio/modtrezorio-haptic.h | 2 +- .../modtrezorio/modtrezorio-hid.h | 2 +- .../modtrezorio/modtrezorio-poll.h | 11 +- .../modtrezorio/modtrezorio-sdcard.h | 4 +- .../modtrezorio/modtrezorio-usb.h | 0 .../modtrezorio/modtrezorio-vcp.h | 0 .../modtrezorio/modtrezorio-webusb.h | 0 .../modtrezorio/modtrezorio.c | 12 +- .../modtrezorui/modtrezorui-display.h | 6 +- .../modtrezorui/modtrezorui.c | 2 +- .../modtrezorutils/modtrezorutils-meminfo.h | 4 +- .../modtrezorutils/modtrezorutils.c | 16 +- core/embed/{extmod => upymod}/modutime.c | 0 core/embed/{extmod => upymod}/rustmods.c | 0 core/embed/{extmod => upymod}/trezorobj.c | 0 core/embed/{extmod => upymod}/trezorobj.h | 0 core/embed/{lib => util/bl_check}/bl_check.c | 8 +- .../bl_check/inc/util}/bl_check.h | 0 .../inc/util}/board_capabilities.h | 0 .../stm32}/board_capabilities.c | 4 +- core/embed/{lib => util/flash}/flash_utils.c | 4 +- core/embed/util/flash/inc/flash.h | 25 + .../flash/inc/util}/flash.h | 0 .../flash/inc/util/flash_layout.h} | 0 .../flash/inc/util}/flash_otp.h | 0 .../flash/inc/util}/flash_utils.h | 0 .../stm32f4 => util/flash}/layout_helpers.h | 0 .../{trezorhal => util/flash}/stm32f4/flash.c | 2 +- .../flash/stm32f4/flash_layout.c} | 5 +- .../flash}/stm32f4/flash_otp.c | 6 +- .../{trezorhal => util/flash}/stm32u5/flash.c | 2 +- .../flash/stm32u5/flash_layout.c} | 5 +- .../flash}/stm32u5/flash_otp.c | 6 +- .../{trezorhal => util/flash}/unix/flash.c | 2 +- .../flash}/unix/flash_otp.c | 2 +- .../stm32f4 => util/fwutils}/fwutils.c | 6 +- .../fwutils/inc/util}/fwutils.h | 0 core/embed/{lib => util/image}/image.c | 4 +- .../{lib => util/image/inc/util}/image.h | 3 +- .../image/inc/util}/image_hash_conf.h | 2 +- .../option_bytes/inc/util}/option_bytes.h | 0 .../option_bytes}/stm32f4/option_bytes.c | 6 +- .../option_bytes}/stm32u5/option_bytes.c | 4 +- core/embed/{lib => util/rsod/inc/util}/rsod.h | 2 +- core/embed/{lib => util/rsod}/rsod.c | 12 +- .../translations/inc/util}/translations.h | 0 .../{lib => util/translations}/translations.c | 6 +- .../inc/util}/unit_properties.h | 0 .../unit_properties/stm32}/unit_properties.c | 4 +- .../unit_properties}/unix/unit_properties.c | 4 +- core/mocks/generated/trezorconfig.pyi | 36 +- .../mocks/generated/trezorcrypto/__init__.pyi | 30 +- core/mocks/generated/trezorcrypto/bech32.pyi | 2 +- core/mocks/generated/trezorcrypto/bip32.pyi | 4 +- core/mocks/generated/trezorcrypto/bip340.pyi | 14 +- core/mocks/generated/trezorcrypto/bip39.pyi | 8 +- core/mocks/generated/trezorcrypto/cardano.pyi | 8 +- core/mocks/generated/trezorcrypto/crc.pyi | 2 +- .../generated/trezorcrypto/curve25519.pyi | 6 +- core/mocks/generated/trezorcrypto/ed25519.pyi | 18 +- .../generated/trezorcrypto/elligator2.pyi | 2 +- core/mocks/generated/trezorcrypto/monero.pyi | 86 ++-- core/mocks/generated/trezorcrypto/nem.pyi | 4 +- .../generated/trezorcrypto/nist256p1.pyi | 12 +- core/mocks/generated/trezorcrypto/optiga.pyi | 12 +- core/mocks/generated/trezorcrypto/random.pyi | 8 +- .../generated/trezorcrypto/secp256k1.pyi | 12 +- core/mocks/generated/trezorcrypto/shamir.pyi | 2 +- core/mocks/generated/trezorcrypto/slip39.pyi | 4 +- core/mocks/generated/trezorio/__init__.pyi | 10 +- core/mocks/generated/trezorio/fatfs.pyi | 32 +- core/mocks/generated/trezorio/haptic.pyi | 2 +- core/mocks/generated/trezorio/sdcard.pyi | 12 +- core/mocks/generated/trezorui.pyi | 2 +- core/mocks/generated/trezorutils.pyi | 28 +- core/site_scons/models/D001/discovery.py | 35 +- core/site_scons/models/D002/discovery2.py | 34 +- core/site_scons/models/T2B1/emulator.py | 13 +- core/site_scons/models/T2B1/trezor_r_v10.py | 41 +- core/site_scons/models/T2T1/emulator.py | 22 +- core/site_scons/models/T2T1/trezor_t.py | 54 ++- core/site_scons/models/T3B1/emulator.py | 13 +- .../models/T3B1/trezor_t3b1_revB.py | 43 +- core/site_scons/models/T3T1/emulator.py | 27 +- .../models/T3T1/trezor_t3t1_revE.py | 68 +-- core/site_scons/models/T3W1/emulator.py | 20 +- .../models/T3W1/trezor_t3w1_revA.py | 41 +- core/site_scons/models/stm32f4_common.py | 85 ++-- core/site_scons/models/stm32u5_common.py | 94 ++-- core/site_scons/ui/common.py | 2 +- core/src/apps/monero/README.md | 2 +- core/tools/build_mocks | 2 +- core/tools/codegen/gen_font.py | 6 +- core/tools/codegen/gen_loader.py | 2 +- core/tools/size/checker.py | 2 +- core/tools/size/groups.py | 24 +- core/tools/snippets/change_icon_format.py | 4 +- core/translations/cli.py | 2 +- docs/core/embed_debug/index.md | 2 +- docs/core/index.md | 2 +- docs/misc/changelog.md | 6 +- docs/misc/generated-files.md | 2 +- tools/bump-version.py | 2 +- tools/style.c.exclude | 4 +- 624 files changed, 2165 insertions(+), 2107 deletions(-) delete mode 120000 core/embed/boardloader/.towncrier.template.md delete mode 120000 core/embed/boardloader/CHANGELOG.unreleased delete mode 120000 core/embed/boardloader/towncrier.toml delete mode 120000 core/embed/bootloader/.towncrier.template.md delete mode 120000 core/embed/bootloader/CHANGELOG.unreleased delete mode 120000 core/embed/bootloader/towncrier.toml delete mode 120000 core/embed/bootloader_ci/.towncrier.template.md delete mode 120000 core/embed/bootloader_ci/CHANGELOG.unreleased delete mode 120000 core/embed/bootloader_ci/towncrier.toml rename core/embed/{trezorhal => gfx/bitblt}/dma2d_bitblt.h (98%) create mode 100644 core/embed/gfx/bitblt/gfx_bitblt.c rename core/embed/{lib => gfx/bitblt}/gfx_bitblt_mono8.c (99%) rename core/embed/{lib => gfx/bitblt}/gfx_bitblt_rgb565.c (99%) rename core/embed/{lib => gfx/bitblt}/gfx_bitblt_rgba8888.c (99%) rename core/embed/{trezorhal/stm32f4 => gfx/bitblt/stm32}/dma2d_bitblt.c (99%) rename core/embed/{lib => gfx}/fonts/font_bitmap.c (100%) rename core/embed/{lib => gfx}/fonts/font_bitmap.h (100%) rename core/embed/{lib => gfx}/fonts/font_pixeloperator_bold_8.c (100%) rename core/embed/{lib => gfx}/fonts/font_pixeloperator_bold_8.h (100%) rename core/embed/{lib => gfx}/fonts/font_pixeloperator_regular_8.c (100%) rename core/embed/{lib => gfx}/fonts/font_pixeloperator_regular_8.h (100%) rename core/embed/{lib => gfx}/fonts/font_pixeloperatormono_regular_8.c (100%) rename core/embed/{lib => gfx}/fonts/font_pixeloperatormono_regular_8.h (100%) rename core/embed/{lib => gfx}/fonts/font_roboto_bold_20.c (100%) rename core/embed/{lib => gfx}/fonts/font_roboto_bold_20.h (100%) rename core/embed/{lib => gfx}/fonts/font_roboto_regular_20.c (100%) rename core/embed/{lib => gfx}/fonts/font_roboto_regular_20.h (100%) rename core/embed/{lib => gfx}/fonts/font_robotomono_medium_20.c (100%) rename core/embed/{lib => gfx}/fonts/font_robotomono_medium_20.h (100%) rename core/embed/{lib => gfx}/fonts/font_robotomono_medium_21.c (100%) rename core/embed/{lib => gfx}/fonts/font_robotomono_medium_21.h (100%) rename core/embed/{lib => gfx}/fonts/font_tthoves_bold_17.c (100%) rename core/embed/{lib => gfx}/fonts/font_tthoves_bold_17.h (100%) rename core/embed/{lib => gfx}/fonts/font_tthoves_demibold_21.c (100%) rename core/embed/{lib => gfx}/fonts/font_tthoves_demibold_21.h (100%) rename core/embed/{lib => gfx}/fonts/font_tthoves_regular_21.c (100%) rename core/embed/{lib => gfx}/fonts/font_tthoves_regular_21.h (100%) rename core/embed/{lib => gfx}/fonts/font_ttsatoshi_demibold_18.c (100%) rename core/embed/{lib => gfx}/fonts/font_ttsatoshi_demibold_18.h (100%) rename core/embed/{lib => gfx}/fonts/font_ttsatoshi_demibold_21.c (100%) rename core/embed/{lib => gfx}/fonts/font_ttsatoshi_demibold_21.h (100%) rename core/embed/{lib => gfx}/fonts/font_ttsatoshi_demibold_42.c (100%) rename core/embed/{lib => gfx}/fonts/font_ttsatoshi_demibold_42.h (100%) rename core/embed/{lib => gfx}/fonts/font_unifont_bold_16.c (100%) rename core/embed/{lib => gfx}/fonts/font_unifont_bold_16.h (100%) rename core/embed/{lib => gfx}/fonts/font_unifont_regular_16.c (100%) rename core/embed/{lib => gfx}/fonts/font_unifont_regular_16.h (100%) rename core/embed/{lib => gfx}/fonts/fonts.c (100%) rename core/embed/{lib => gfx}/fonts/fonts.h (99%) rename core/embed/{lib => gfx}/gfx_color.c (98%) rename core/embed/{lib => gfx}/gfx_draw.c (98%) rename core/embed/{trezorhal/unix/dma2d_bitblt.c => gfx/inc/gfx/fonts.h} (90%) rename core/embed/{lib => gfx/inc/gfx}/gfx_bitblt.h (96%) rename core/embed/{lib => gfx/inc/gfx}/gfx_color.h (100%) rename core/embed/{lib => gfx/inc/gfx}/gfx_draw.h (99%) rename core/embed/{lib => gfx/inc/gfx}/terminal.h (97%) rename core/embed/{lib/qr-code-generator => gfx/qrcode} (100%) rename core/embed/{lib => gfx}/terminal.c (96%) rename core/embed/{trezorhal => io/button/inc/io}/button.h (100%) rename core/embed/{trezorhal/stm32f4 => io/button/stm32}/button.c (99%) rename core/embed/{trezorhal => io/button}/unix/button.c (99%) rename core/embed/{trezorhal/stm32f4 => io/display/backlight}/backlight_pwm.h (100%) rename core/embed/{trezorhal/stm32f4 => io/display/backlight/stm32}/backlight_pwm.c (99%) rename core/embed/{trezorhal => io/display/bg_copy}/bg_copy.h (100%) rename core/embed/{trezorhal => io/display/bg_copy}/stm32u5/bg_copy.c (96%) rename core/embed/{lib => io/display}/display_utils.c (95%) rename core/embed/{trezorhal => io/display/inc/io}/display.h (99%) rename core/embed/{lib => io/display/inc/io}/display_utils.h (100%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/display_driver.c (97%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/display_fb.c (97%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/display_fb.h (100%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/display_internal.h (100%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/display_io.c (99%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/display_io.h (100%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/display_nofb.c (99%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/display_panel.c (100%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/display_panel.h (100%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/panels/154a.c (100%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/panels/154a.h (100%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/panels/lhs200kb-if21.c (100%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/panels/lhs200kb-if21.h (100%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/panels/lx154a2411.c (100%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/panels/lx154a2411.h (100%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/panels/lx154a2422.c (100%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/panels/lx154a2422.h (100%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/panels/lx154a2482.c (100%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/panels/lx154a2482.h (100%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/panels/tf15411a.c (100%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/st-7789/panels/tf15411a.h (100%) rename core/embed/{trezorhal/stm32u5/xdisplay => io/display}/st7785ma/display_driver.c (96%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/stm32f429i-disc1/display_driver.c (99%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/stm32f429i-disc1/display_internal.h (98%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/stm32f429i-disc1/display_ltdc.c (99%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/stm32f429i-disc1/ili9341_spi.c (100%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/stm32f429i-disc1/ili9341_spi.h (100%) rename core/embed/{trezorhal/stm32u5/xdisplay => io/display}/stm32u5a9j-dk/display_driver.c (99%) rename core/embed/{trezorhal/stm32u5/xdisplay => io/display}/stm32u5a9j-dk/display_fb.c (97%) rename core/embed/{trezorhal/stm32u5/xdisplay => io/display}/stm32u5a9j-dk/display_gfxmmu_lut.h (100%) rename core/embed/{trezorhal/stm32u5/xdisplay => io/display}/stm32u5a9j-dk/display_internal.h (97%) rename core/embed/{trezorhal/stm32u5/xdisplay => io/display}/stm32u5a9j-dk/display_ltdc_dsi.c (99%) rename core/embed/{trezorhal => io/display}/unix/display_driver.c (99%) rename core/embed/{trezorhal/stm32f4/xdisplay => io/display}/vg-2864/display_driver.c (98%) rename core/embed/{trezorhal/stm32u5 => io}/haptic/drv2625/actuators/vg1040003d.h (100%) rename core/embed/{trezorhal/stm32u5 => io}/haptic/drv2625/drv2625.c (99%) rename core/embed/{trezorhal/stm32u5 => io}/haptic/drv2625/drv2625.h (100%) rename core/embed/{trezorhal => io/haptic/inc/io}/haptic.h (100%) rename core/embed/{trezorhal => io/i2c_bus/inc/io}/i2c_bus.h (100%) rename core/embed/{trezorhal => io/i2c_bus}/stm32f4/i2c_bus.c (98%) rename core/embed/{trezorhal => io/i2c_bus}/stm32u5/i2c_bus.c (97%) rename core/embed/{trezorhal => io/rgb_led/inc/io}/rgb_led.h (100%) rename core/embed/{trezorhal => io/rgb_led}/stm32f4/rgb_led.c (100%) rename core/embed/{trezorhal => io/sbu/inc/io}/sbu.h (100%) rename core/embed/{trezorhal/stm32f4 => io/sbu/stm32}/sbu.c (98%) rename core/embed/{trezorhal => io/sbu}/unix/sbu.c (97%) rename core/embed/{trezorhal => io/sdcard/inc/io}/sdcard.h (100%) rename core/embed/{trezorhal => io/sdcard}/stm32f4/sdcard-set_clr_card_detect.h (100%) rename core/embed/{trezorhal => io/sdcard}/stm32f4/sdcard.c (98%) rename core/embed/{trezorhal => io/sdcard}/stm32u5/sdcard.c (99%) rename core/embed/{trezorhal => io/sdcard}/unix/sdcard.c (99%) rename core/embed/{trezorhal/stm32f4/touch => io/touch/ft6x36}/ft6x36.c (99%) rename core/embed/{trezorhal/stm32f4/touch => io/touch/ft6x36}/ft6x36.h (100%) rename core/embed/{trezorhal/stm32f4/touch => io/touch/ft6x36}/panels/lhs200kb-if21.c (97%) rename core/embed/{trezorhal/stm32f4/touch => io/touch/ft6x36}/panels/lhs200kb-if21.h (100%) rename core/embed/{trezorhal/stm32f4/touch => io/touch/ft6x36}/panels/lx154a2422cpt23.c (98%) rename core/embed/{trezorhal/stm32f4/touch => io/touch/ft6x36}/panels/lx154a2422cpt23.h (100%) rename core/embed/{trezorhal => io/touch/inc/io}/touch.h (100%) rename core/embed/{trezorhal/stm32u5/touch => io/touch/sitronix}/sitronix.c (99%) rename core/embed/{trezorhal/stm32f4/touch => io/touch/stmpe811}/stmpe811.c (99%) rename core/embed/{trezorhal/stm32f4/touch => io/touch/stmpe811}/stmpe811.h (100%) rename core/embed/{trezorhal => io/touch}/unix/touch.c (99%) rename core/embed/{trezorhal => io/usb/inc/io}/usb.h (98%) rename core/embed/{trezorhal => io/usb/inc/io}/usb_hid.h (100%) rename core/embed/{trezorhal => io/usb/inc/io}/usb_vcp.h (100%) rename core/embed/{trezorhal => io/usb/inc/io}/usb_webusb.h (100%) rename core/embed/{trezorhal/stm32f4/usb => io/usb/stm32}/usb.c (99%) rename core/embed/{trezorhal/stm32f4/usb => io/usb/stm32}/usb_class_hid.c (99%) rename core/embed/{trezorhal/stm32f4/usb => io/usb/stm32}/usb_class_vcp.c (99%) rename core/embed/{trezorhal/stm32f4/usb => io/usb/stm32}/usb_class_webusb.c (99%) rename core/embed/{trezorhal/stm32f4/usb => io/usb/stm32}/usb_internal.h (100%) rename core/embed/{trezorhal/stm32f4/usb => io/usb/stm32}/usbd_conf.c (98%) rename core/embed/{trezorhal/stm32f4/usb => io/usb/stm32}/usbd_conf.h (100%) rename core/embed/{trezorhal/stm32f4/usb => io/usb/stm32}/usbd_core.c (100%) rename core/embed/{trezorhal/stm32f4/usb => io/usb/stm32}/usbd_core.h (100%) rename core/embed/{trezorhal/stm32f4/usb => io/usb/stm32}/usbd_ctlreq.c (100%) rename core/embed/{trezorhal/stm32f4/usb => io/usb/stm32}/usbd_ctlreq.h (100%) rename core/embed/{trezorhal/stm32f4/usb => io/usb/stm32}/usbd_def.h (100%) rename core/embed/{trezorhal/stm32f4/usb => io/usb/stm32}/usbd_ioreq.c (100%) rename core/embed/{trezorhal/stm32f4/usb => io/usb/stm32}/usbd_ioreq.h (100%) rename core/embed/{trezorhal => io/usb}/unix/usb.c (99%) delete mode 100644 core/embed/models/layout_common.h create mode 100644 core/embed/models/otp_layout.h delete mode 120000 core/embed/prodtest/.towncrier.template.md delete mode 120000 core/embed/prodtest/CHANGELOG.unreleased delete mode 120000 core/embed/prodtest/towncrier.toml rename core/embed/{ => projects}/boardloader/.changelog.d/.gitignore (100%) create mode 120000 core/embed/projects/boardloader/.towncrier.template.md rename core/embed/{ => projects}/boardloader/CHANGELOG.md (100%) create mode 120000 core/embed/projects/boardloader/CHANGELOG.unreleased rename core/embed/{ => projects}/boardloader/main.c (92%) create mode 120000 core/embed/projects/boardloader/towncrier.toml rename core/embed/{ => projects}/boardloader/version.h (100%) rename core/embed/{ => projects}/bootloader/.changelog.d/.gitignore (100%) create mode 120000 core/embed/projects/bootloader/.towncrier.template.md rename core/embed/{ => projects}/bootloader/CHANGELOG.md (100%) create mode 120000 core/embed/projects/bootloader/CHANGELOG.unreleased rename core/embed/{ => projects}/bootloader/bootloader_flash.jlink (100%) rename core/embed/{ => projects}/bootloader/bootui.c (97%) rename core/embed/{ => projects}/bootloader/bootui.h (99%) rename core/embed/{ => projects}/bootloader/emulator.c (97%) rename core/embed/{ => projects}/bootloader/emulator.h (100%) rename core/embed/{ => projects}/bootloader/header.S (100%) rename core/embed/{ => projects}/bootloader/main.c (96%) rename core/embed/{ => projects}/bootloader/messages.c (99%) rename core/embed/{ => projects}/bootloader/messages.h (99%) rename core/embed/{ => projects}/bootloader/protob/.gitignore (100%) rename core/embed/{ => projects}/bootloader/protob/Makefile (100%) rename core/embed/{ => projects}/bootloader/protob/messages.options (100%) rename core/embed/{ => projects}/bootloader/protob/messages.pb.c (100%) rename core/embed/{ => projects}/bootloader/protob/messages.pb.h (100%) rename core/embed/{ => projects}/bootloader/protob/messages.proto (100%) create mode 120000 core/embed/projects/bootloader/towncrier.toml rename core/embed/{ => projects}/bootloader/version.h (100%) rename core/embed/{ => projects}/bootloader/version_check.c (98%) rename core/embed/{ => projects}/bootloader/version_check.h (100%) rename core/embed/{ => projects}/bootloader_ci/.changelog.d/.gitignore (100%) rename core/embed/{ => projects}/bootloader_ci/.changelog.d/1049.added (100%) rename core/embed/{ => projects}/bootloader_ci/.changelog.d/1599.changed (100%) rename core/embed/{ => projects}/bootloader_ci/.changelog.d/2243.added (100%) rename core/embed/{ => projects}/bootloader_ci/.changelog.d/2414.added (100%) rename core/embed/{ => projects}/bootloader_ci/.changelog.d/2623.added (100%) rename core/embed/{ => projects}/bootloader_ci/.changelog.d/3205.added (100%) rename core/embed/{ => projects}/bootloader_ci/.changelog.d/3370.added (100%) create mode 120000 core/embed/projects/bootloader_ci/.towncrier.template.md rename core/embed/{ => projects}/bootloader_ci/CHANGELOG.md (100%) create mode 120000 core/embed/projects/bootloader_ci/CHANGELOG.unreleased rename core/embed/{ => projects}/bootloader_ci/README.md (100%) rename core/embed/{ => projects}/bootloader_ci/bootloader_flash.jlink (100%) rename core/embed/{ => projects}/bootloader_ci/bootui.c (96%) rename core/embed/{ => projects}/bootloader_ci/bootui.h (100%) rename core/embed/{ => projects}/bootloader_ci/header.S (100%) rename core/embed/{ => projects}/bootloader_ci/icon_done.h (100%) rename core/embed/{ => projects}/bootloader_ci/icon_fail.h (100%) rename core/embed/{ => projects}/bootloader_ci/icon_install.h (100%) rename core/embed/{ => projects}/bootloader_ci/icon_welcome.h (100%) rename core/embed/{ => projects}/bootloader_ci/icon_wipe.h (100%) rename core/embed/{ => projects}/bootloader_ci/main.c (95%) rename core/embed/{ => projects}/bootloader_ci/messages.c (99%) rename core/embed/{ => projects}/bootloader_ci/messages.h (99%) rename core/embed/{ => projects}/bootloader_ci/protob (100%) create mode 120000 core/embed/projects/bootloader_ci/towncrier.toml rename core/embed/{ => projects}/bootloader_ci/version.h (100%) rename core/embed/{ => projects}/bootloader_ci/version_check.c (100%) rename core/embed/{ => projects}/bootloader_ci/version_check.h (100%) rename core/embed/{ => projects}/firmware/header.S (100%) rename core/embed/{ => projects}/firmware/main.c (97%) rename core/embed/{ => projects}/firmware/mpconfigport.h (99%) rename core/embed/{ => projects}/firmware/mphalport.c (97%) rename core/embed/{ => projects}/firmware/mphalport.h (100%) rename core/embed/{ => projects}/firmware/nlrthumb.c (100%) rename core/embed/{ => projects}/firmware/version.h (100%) rename core/embed/{ => projects}/kernel/main.c (86%) rename core/embed/{ => projects}/kernel/version.h (100%) rename core/embed/{ => projects}/prodtest/.changelog.d/.keep (100%) rename core/embed/{ => projects}/prodtest/.changelog.d/4310.fixed (100%) rename core/embed/{ => projects}/prodtest/.changelog.d/4313.fixed (100%) create mode 120000 core/embed/projects/prodtest/.towncrier.template.md rename core/embed/{ => projects}/prodtest/CHANGELOG.md (100%) create mode 120000 core/embed/projects/prodtest/CHANGELOG.unreleased rename core/embed/{ => projects}/prodtest/README.md (100%) rename core/embed/{ => projects}/prodtest/header.S (100%) rename core/embed/{ => projects}/prodtest/main.c (96%) rename core/embed/{ => projects}/prodtest/optiga_prodtest.c (99%) rename core/embed/{ => projects}/prodtest/optiga_prodtest.h (100%) rename core/embed/{ => projects}/prodtest/prodtest_common.c (98%) rename core/embed/{ => projects}/prodtest/prodtest_common.h (100%) create mode 120000 core/embed/projects/prodtest/towncrier.toml rename core/embed/{ => projects}/prodtest/version.h (100%) rename core/embed/{ => projects}/reflash/header.S (100%) rename core/embed/{ => projects}/reflash/main.c (90%) rename core/embed/{ => projects}/reflash/version.h (100%) rename core/embed/{ => projects}/unix/main.c (98%) rename core/embed/{ => projects}/unix/main_main.c (97%) rename core/embed/{ => projects}/unix/mpconfigport.h (100%) rename core/embed/{ => projects}/unix/profile.c (100%) rename core/embed/{ => projects}/unix/profile.h (100%) rename core/embed/{ => projects}/unix/version.h (100%) rename core/embed/{lib => rtl}/error_handling.c (98%) rename core/embed/{lib => rtl/inc}/assert.h (100%) rename core/embed/{lib => rtl/inc}/common.h (84%) rename core/embed/{lib => rtl/inc/rtl}/compiler_traits.h (100%) rename core/embed/{lib => rtl/inc/rtl}/error_handling.h (100%) rename core/embed/{lib => rtl/inc/rtl}/mini_printf.h (100%) rename core/embed/{lib => rtl/inc/rtl}/secbool.h (100%) rename core/embed/{lib => rtl/inc/rtl}/sizedefs.h (100%) create mode 100644 core/embed/rtl/inc/secbool.h rename core/embed/{lib => rtl/inc}/trezor_rtl.h (96%) rename core/embed/{lib => rtl/inc}/trezor_types.h (97%) rename core/embed/{lib => rtl}/mini_printf.c (99%) rename core/embed/{trezorhal => sec/consumption_mask/inc/sec}/consumption_mask.h (100%) rename core/embed/{trezorhal => sec/consumption_mask}/stm32f4/consumption_mask.c (98%) rename core/embed/{trezorhal => sec/consumption_mask}/stm32u5/consumption_mask.c (99%) rename core/embed/{trezorhal => sec/entropy/inc/sec}/entropy.h (100%) rename core/embed/{trezorhal => sec/entropy}/stm32f4/entropy.c (96%) rename core/embed/{trezorhal => sec/entropy}/stm32u5/entropy.c (96%) rename core/embed/{trezorhal => sec/entropy}/unix/entropy.c (97%) rename core/embed/{trezorhal => sec/hash_processor/inc/sec}/hash_processor.h (100%) rename core/embed/{trezorhal => sec/hash_processor}/stm32u5/hash_processor.c (98%) rename core/embed/{trezorhal => sec/monoctr/inc/sec}/monoctr.h (100%) rename core/embed/{trezorhal => sec/monoctr}/stm32f4/monoctr.c (97%) rename core/embed/{trezorhal => sec/monoctr}/stm32u5/monoctr.c (97%) rename core/embed/{trezorhal => sec/monoctr}/unix/monoctr.c (98%) create mode 100644 core/embed/sec/optiga/inc/optiga.h rename core/embed/{trezorhal => sec/optiga/inc/sec}/optiga.h (100%) rename core/embed/{trezorhal => sec/optiga/inc/sec}/optiga_commands.h (100%) rename core/embed/{trezorhal => sec/optiga/inc/sec}/optiga_common.h (100%) rename core/embed/{trezorhal => sec/optiga/inc/sec}/optiga_hal.h (100%) rename core/embed/{trezorhal => sec/optiga/inc/sec}/optiga_transport.h (100%) rename core/embed/{trezorhal => sec}/optiga/optiga.c (99%) rename core/embed/{trezorhal => sec}/optiga/optiga_commands.c (99%) rename core/embed/{trezorhal => sec}/optiga/optiga_transport.c (99%) rename core/embed/{trezorhal => sec/optiga}/stm32f4/optiga_hal.c (94%) rename core/embed/{trezorhal => sec/optiga}/stm32u5/optiga_hal.c (100%) rename core/embed/{trezorhal => sec/optiga}/unix/certs/README.md (100%) rename core/embed/{trezorhal => sec/optiga}/unix/certs/T2B1.der (100%) rename core/embed/{trezorhal => sec/optiga}/unix/certs/T2B1.h (100%) rename core/embed/{trezorhal => sec/optiga}/unix/certs/T3T1.der (100%) rename core/embed/{trezorhal => sec/optiga}/unix/certs/T3T1.h (100%) rename core/embed/{trezorhal => sec/optiga}/unix/certs/gen.sh (100%) rename core/embed/{trezorhal => sec/optiga}/unix/optiga.c (98%) rename core/embed/{trezorhal => sec/optiga}/unix/optiga_hal.c (100%) create mode 100644 core/embed/sec/random_delays/inc/random_delays.h rename core/embed/{trezorhal => sec/random_delays/inc/sec}/random_delays.h (100%) rename core/embed/{trezorhal/stm32f4 => sec/random_delays/stm32}/random_delays.c (99%) rename core/embed/{trezorhal => sec/random_delays}/unix/random_delays.c (96%) rename core/embed/{trezorhal => sec/rng/inc/sec}/rng.h (100%) rename core/embed/{trezorhal/stm32f4 => sec/rng/stm32}/rng.c (98%) rename core/embed/{trezorhal => sec/rng}/unix/rng.c (98%) rename core/embed/{trezorhal => sec/secret/inc/sec}/secret.h (100%) rename core/embed/{trezorhal => sec/secret}/stm32f4/secret.c (97%) rename core/embed/{trezorhal => sec/secret}/stm32u5/secret.c (98%) rename core/embed/{trezorhal => sec/secret}/unix/secret.c (100%) rename core/embed/{trezorhal => sec/secure_aes/inc/sec}/secure_aes.h (100%) create mode 100644 core/embed/sec/secure_aes/inc/secure_aes.h rename core/embed/{trezorhal => sec/secure_aes}/stm32u5/secure_aes.c (98%) rename core/embed/{trezorhal => sec/time_estimate/inc/sec}/time_estimate.h (100%) create mode 100644 core/embed/sec/time_estimate/inc/time_estimate.h rename core/embed/{trezorhal/stm32f4 => sec/time_estimate/stm32}/time_estimate.c (97%) rename core/embed/{trezorhal => sec/time_estimate}/unix/time_estimate.c (96%) rename core/embed/{models => sys/bsp/inc}/trezor_bsp.h (100%) rename core/embed/{trezorhal => sys/bsp}/stm32f4/stm32f4xx_hal_conf.h (100%) rename core/embed/{trezorhal => sys/bsp}/stm32u5/stm32u5xx_hal_conf.h (100%) rename core/embed/{trezorhal/stm32f4 => sys/irq/inc/sys}/irq.h (92%) rename core/embed/{trezorhal/stm32f4/linker => sys/linker/stm32f4}/boardloader.ld (97%) rename core/embed/{trezorhal/stm32f4/linker => sys/linker/stm32f4}/bootloader.ld (97%) rename core/embed/{trezorhal/stm32f4/linker => sys/linker/stm32f4}/firmware.ld (98%) rename core/embed/{trezorhal/stm32f4/linker => sys/linker/stm32f4}/kernel.ld (98%) rename core/embed/{trezorhal/stm32f4/linker => sys/linker/stm32f4}/memory.ld (100%) rename core/embed/{trezorhal/stm32f4/linker => sys/linker/stm32f4}/prodtest.ld (97%) rename core/embed/{trezorhal/stm32u5/linker/u58 => sys/linker/stm32u58}/boardloader.ld (98%) rename core/embed/{trezorhal/stm32u5/linker/u58 => sys/linker/stm32u58}/bootloader.ld (98%) rename core/embed/{trezorhal/stm32u5/linker/u58 => sys/linker/stm32u58}/firmware.ld (97%) rename core/embed/{trezorhal/stm32u5/linker/u58 => sys/linker/stm32u58}/kernel.ld (98%) rename core/embed/{trezorhal/stm32u5/linker/u58 => sys/linker/stm32u58}/memory.ld (100%) rename core/embed/{trezorhal/stm32u5/linker/u58 => sys/linker/stm32u58}/prodtest.ld (98%) rename core/embed/{trezorhal/stm32u5/linker/u5g => sys/linker/stm32u5g}/boardloader.ld (98%) rename core/embed/{trezorhal/stm32u5/linker/u5g => sys/linker/stm32u5g}/bootloader.ld (98%) rename core/embed/{trezorhal/stm32u5/linker/u5g => sys/linker/stm32u5g}/firmware.ld (97%) rename core/embed/{trezorhal/stm32u5/linker/u5g => sys/linker/stm32u5g}/kernel.ld (98%) rename core/embed/{trezorhal/stm32u5/linker/u5g => sys/linker/stm32u5g}/memory.ld (100%) rename core/embed/{trezorhal/stm32u5/linker/u5g => sys/linker/stm32u5g}/prodtest.ld (98%) rename core/embed/{trezorhal => sys/mpu/inc/sys}/mpu.h (100%) rename core/embed/{trezorhal => sys/mpu}/stm32f4/mpu.c (99%) rename core/embed/{trezorhal => sys/mpu}/stm32u5/mpu.c (99%) rename core/embed/{trezorhal => sys/mpu}/unix/mpu.c (97%) rename core/embed/{trezorhal => sys/pvd/inc/sys}/pvd.h (100%) rename core/embed/{trezorhal/stm32f4 => sys/pvd/stm32}/pvd.c (96%) create mode 100644 core/embed/sys/sdram/inc/sys/sdram.h rename core/embed/{trezorhal/stm32f4/sdram.c => sys/sdram/stm32f429i-disc1/sdram_bsp.c} (99%) rename core/embed/{trezorhal/stm32f4/sdram.h => sys/sdram/stm32f429i-disc1/sdram_bsp.h} (94%) rename core/embed/{trezorhal => sys/startup/inc/sys}/bootargs.h (100%) rename core/embed/{trezorhal => sys/startup/inc/sys}/bootutils.h (100%) rename core/embed/{trezorhal => sys/startup/inc/sys}/reset_flags.h (100%) rename core/embed/{trezorhal/stm32f4 => sys/startup/stm32}/bootutils.c (97%) rename core/embed/{trezorhal => sys/startup}/stm32f4/limited_util.S (100%) rename core/embed/{trezorhal => sys/startup}/stm32f4/reset_flags.c (98%) rename core/embed/{trezorhal => sys/startup}/stm32f4/startup_init.c (99%) rename core/embed/{trezorhal => sys/startup}/stm32f4/startup_init.h (100%) rename core/embed/{trezorhal => sys/startup}/stm32f4/startup_stage_0.s (100%) rename core/embed/{trezorhal => sys/startup}/stm32f4/startup_stage_1.s (100%) rename core/embed/{trezorhal => sys/startup}/stm32f4/startup_stage_2.s (100%) rename core/embed/{trezorhal => sys/startup}/stm32f4/startup_stage_4.s (100%) rename core/embed/{trezorhal => sys/startup}/stm32f4/util.S (100%) rename core/embed/{trezorhal => sys/startup}/stm32f4/vectortable.S (100%) rename core/embed/{trezorhal => sys/startup}/stm32u5/limited_util.S (100%) rename core/embed/{trezorhal => sys/startup}/stm32u5/reset_flags.c (98%) rename core/embed/{trezorhal => sys/startup}/stm32u5/startup_init.c (99%) rename core/embed/{trezorhal => sys/startup}/stm32u5/startup_stage_0.s (100%) rename core/embed/{trezorhal => sys/startup}/stm32u5/startup_stage_1.s (100%) rename core/embed/{trezorhal => sys/startup}/stm32u5/startup_stage_2.s (100%) rename core/embed/{trezorhal => sys/startup}/stm32u5/startup_stage_4.s (100%) rename core/embed/{trezorhal => sys/startup}/stm32u5/util.S (100%) rename core/embed/{trezorhal => sys/startup}/stm32u5/vectortable.S (100%) rename core/embed/{trezorhal => sys/startup}/unix/bootutils.c (96%) create mode 100644 core/embed/sys/syscall/inc/sys/syscall.h rename core/embed/{trezorhal/stm32f4 => sys/syscall/stm32}/syscall.c (99%) rename core/embed/{trezorhal/stm32f4 => sys/syscall/stm32}/syscall_dispatch.c (96%) rename core/embed/{trezorhal/stm32f4/syscall.h => sys/syscall/stm32/syscall_internal.h} (74%) rename core/embed/{trezorhal/stm32f4 => sys/syscall/stm32}/syscall_numbers.h (100%) rename core/embed/{trezorhal/stm32f4 => sys/syscall/stm32}/syscall_probe.c (98%) rename core/embed/{trezorhal/stm32f4 => sys/syscall/stm32}/syscall_probe.h (98%) rename core/embed/{trezorhal/stm32f4 => sys/syscall/stm32}/syscall_stubs.c (96%) rename core/embed/{trezorhal/stm32f4 => sys/syscall/stm32}/syscall_verifiers.c (99%) rename core/embed/{trezorhal/stm32f4 => sys/syscall/stm32}/syscall_verifiers.h (94%) rename core/embed/{firmware => sys/systemview/inc/sys}/systemview.h (88%) rename core/embed/{segger/Config => sys/systemview/stm32/config}/SEGGER_RTT_Conf.h (100%) rename core/embed/{segger/Config => sys/systemview/stm32/config}/SEGGER_SYSVIEW_Conf.h (100%) rename core/embed/{segger/Config => sys/systemview/stm32/config}/SEGGER_SYSVIEW_Config_NoOS.c (100%) rename core/embed/{segger/Config => sys/systemview/stm32/segger}/Global.h (100%) rename core/embed/{segger/SEGGER => sys/systemview/stm32/segger}/SEGGER.h (100%) rename core/embed/{segger/SEGGER => sys/systemview/stm32/segger}/SEGGER_RTT.c (100%) rename core/embed/{segger/SEGGER => sys/systemview/stm32/segger}/SEGGER_RTT.h (100%) rename core/embed/{segger/SEGGER => sys/systemview/stm32/segger}/SEGGER_RTT_ASM_ARMv7M.S (100%) rename core/embed/{segger/SEGGER => sys/systemview/stm32/segger}/SEGGER_RTT_printf.c (100%) rename core/embed/{segger/SEGGER => sys/systemview/stm32/segger}/SEGGER_SYSVIEW.c (100%) rename core/embed/{segger/SEGGER => sys/systemview/stm32/segger}/SEGGER_SYSVIEW.h (100%) rename core/embed/{segger/SEGGER => sys/systemview/stm32/segger}/SEGGER_SYSVIEW_ConfDefaults.h (100%) rename core/embed/{segger/SEGGER => sys/systemview/stm32/segger}/SEGGER_SYSVIEW_Int.h (100%) rename core/embed/{segger/SEGGER => sys/systemview/stm32/segger}/Syscalls/SEGGER_RTT_Syscalls_GCC.c (100%) rename core/embed/{firmware => sys/systemview}/systemview.c (98%) rename core/embed/{trezorhal => sys/tamper/inc/sys}/tamper.h (100%) rename core/embed/{trezorhal => sys/tamper}/stm32u5/tamper.c (99%) rename core/embed/{trezorhal => sys/task/inc/sys}/applet.h (99%) rename core/embed/{trezorhal => sys/task/inc/sys}/systask.h (99%) rename core/embed/{trezorhal => sys/task/inc/sys}/system.h (99%) rename core/embed/{trezorhal/stm32f4 => sys/task/stm32}/applet.c (94%) rename core/embed/{trezorhal/stm32f4 => sys/task/stm32}/systask.c (98%) rename core/embed/{trezorhal/stm32f4 => sys/task/stm32}/system.c (97%) rename core/embed/{trezorhal => sys/task}/unix/system.c (97%) rename core/embed/{trezorhal => sys/time/inc/sys}/systick.h (100%) rename core/embed/{trezorhal => sys/time/inc/sys}/systimer.h (100%) rename core/embed/{trezorhal/stm32f4 => sys/time/stm32}/systick.c (97%) rename core/embed/{trezorhal/stm32f4 => sys/time/stm32}/systick_internal.h (92%) rename core/embed/{trezorhal/stm32f4 => sys/time/stm32}/systimer.c (99%) rename core/embed/{trezorhal => sys/time}/unix/systick.c (99%) rename core/embed/{trezorhal => sys/time}/unix/systimer.c (98%) rename core/embed/{trezorhal => sys/trustzone/inc/sys}/trustzone.h (100%) rename core/embed/{trezorhal => sys/trustzone}/stm32u5/trustzone.c (99%) delete mode 120000 core/embed/trezorhal/stm32f4/systemview.h delete mode 100644 core/embed/trezorhal/stm32f4/xdisplay/ug-2828/display_driver.c delete mode 120000 core/embed/trezorhal/stm32u5/applet.c delete mode 120000 core/embed/trezorhal/stm32u5/backlight_pwm.c delete mode 120000 core/embed/trezorhal/stm32u5/backlight_pwm.h delete mode 120000 core/embed/trezorhal/stm32u5/board_capabilities.c delete mode 120000 core/embed/trezorhal/stm32u5/bootutils.c delete mode 120000 core/embed/trezorhal/stm32u5/button.c delete mode 120000 core/embed/trezorhal/stm32u5/dma2d_bitblt.c delete mode 120000 core/embed/trezorhal/stm32u5/fwutils.c delete mode 120000 core/embed/trezorhal/stm32u5/irq.h delete mode 120000 core/embed/trezorhal/stm32u5/layout_helpers.h delete mode 120000 core/embed/trezorhal/stm32u5/pvd.c delete mode 120000 core/embed/trezorhal/stm32u5/random_delays.c delete mode 120000 core/embed/trezorhal/stm32u5/rng.c delete mode 120000 core/embed/trezorhal/stm32u5/sbu.c delete mode 120000 core/embed/trezorhal/stm32u5/syscall.c delete mode 120000 core/embed/trezorhal/stm32u5/syscall.h delete mode 120000 core/embed/trezorhal/stm32u5/syscall_dispatch.c delete mode 120000 core/embed/trezorhal/stm32u5/syscall_numbers.h delete mode 120000 core/embed/trezorhal/stm32u5/syscall_probe.c delete mode 120000 core/embed/trezorhal/stm32u5/syscall_probe.h delete mode 120000 core/embed/trezorhal/stm32u5/syscall_stubs.c delete mode 120000 core/embed/trezorhal/stm32u5/syscall_verifiers.c delete mode 120000 core/embed/trezorhal/stm32u5/syscall_verifiers.h delete mode 120000 core/embed/trezorhal/stm32u5/systask.c delete mode 120000 core/embed/trezorhal/stm32u5/system.c delete mode 120000 core/embed/trezorhal/stm32u5/systemview.h delete mode 120000 core/embed/trezorhal/stm32u5/systick.c delete mode 120000 core/embed/trezorhal/stm32u5/systick_internal.h delete mode 120000 core/embed/trezorhal/stm32u5/systimer.c delete mode 120000 core/embed/trezorhal/stm32u5/time_estimate.c delete mode 120000 core/embed/trezorhal/stm32u5/touch/ft6x36.c delete mode 120000 core/embed/trezorhal/stm32u5/touch/ft6x36.h delete mode 120000 core/embed/trezorhal/stm32u5/touch/panels delete mode 100644 core/embed/trezorhal/stm32u5/touch/sitronix.h delete mode 120000 core/embed/trezorhal/stm32u5/unit_properties.c delete mode 120000 core/embed/trezorhal/stm32u5/usb delete mode 120000 core/embed/trezorhal/stm32u5/xdisplay/st-7789 delete mode 120000 core/embed/trezorhal/stm32u5/xdisplay/vg-2864 delete mode 120000 core/embed/trezorhal/unix/fwutils.c rename core/embed/{extmod => upymod}/modtrezorconfig/modtrezorconfig.c (99%) rename core/embed/{extmod => upymod}/modtrezorconfig/norcow_config.h (97%) rename core/embed/{extmod => upymod}/modtrezorcrypto/crc.c (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/crc.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/hdnode.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-aes.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-aesgcm.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-bech32.h (98%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-bip32.h (99%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-bip340.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-bip39.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-blake256.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-blake2b.h (99%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-blake2s.h (99%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-cardano.h (99%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-chacha20poly1305.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-crc.h (98%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-curve25519.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-ed25519.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-elligator2.h (98%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-groestl.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-hmac.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-monero.h (99%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-nem.h (98%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-nist256p1.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-optiga.h (98%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-pbkdf2.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-random.h (98%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-ripemd160.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-secp256k1.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-sha1.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-sha256.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-sha3-256.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-sha3-512.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-sha512.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-shamir.h (98%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto-slip39.h (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/modtrezorcrypto.c (100%) rename core/embed/{extmod => upymod}/modtrezorcrypto/rand.c (97%) rename core/embed/{extmod => upymod}/modtrezorio/diskio.h (100%) rename core/embed/{extmod => upymod}/modtrezorio/ff.c (100%) rename core/embed/{extmod => upymod}/modtrezorio/ff.h (100%) rename core/embed/{extmod => upymod}/modtrezorio/ff_unifdef.sh (100%) rename core/embed/{extmod => upymod}/modtrezorio/ffconf.h (100%) rename core/embed/{extmod => upymod}/modtrezorio/ffunicode.c (100%) rename core/embed/{extmod => upymod}/modtrezorio/modtrezorio-fatfs.h (99%) rename core/embed/{extmod => upymod}/modtrezorio/modtrezorio-haptic.h (98%) rename core/embed/{extmod => upymod}/modtrezorio/modtrezorio-hid.h (99%) rename core/embed/{extmod => upymod}/modtrezorio/modtrezorio-poll.h (98%) rename core/embed/{extmod => upymod}/modtrezorio/modtrezorio-sdcard.h (98%) rename core/embed/{extmod => upymod}/modtrezorio/modtrezorio-usb.h (100%) rename core/embed/{extmod => upymod}/modtrezorio/modtrezorio-vcp.h (100%) rename core/embed/{extmod => upymod}/modtrezorio/modtrezorio-webusb.h (100%) rename core/embed/{extmod => upymod}/modtrezorio/modtrezorio.c (97%) rename core/embed/{extmod => upymod}/modtrezorui/modtrezorui-display.h (98%) rename core/embed/{extmod => upymod}/modtrezorui/modtrezorui.c (97%) rename core/embed/{extmod => upymod}/modtrezorutils/modtrezorutils-meminfo.h (99%) rename core/embed/{extmod => upymod}/modtrezorutils/modtrezorutils.c (98%) rename core/embed/{extmod => upymod}/modutime.c (100%) rename core/embed/{extmod => upymod}/rustmods.c (100%) rename core/embed/{extmod => upymod}/trezorobj.c (100%) rename core/embed/{extmod => upymod}/trezorobj.h (100%) rename core/embed/{lib => util/bl_check}/bl_check.c (98%) rename core/embed/{lib => util/bl_check/inc/util}/bl_check.h (100%) rename core/embed/{trezorhal => util/board_capabilities/inc/util}/board_capabilities.h (100%) rename core/embed/{trezorhal/stm32f4 => util/board_capabilities/stm32}/board_capabilities.c (97%) rename core/embed/{lib => util/flash}/flash_utils.c (98%) create mode 100644 core/embed/util/flash/inc/flash.h rename core/embed/{trezorhal => util/flash/inc/util}/flash.h (100%) rename core/embed/{trezorhal/layout.h => util/flash/inc/util/flash_layout.h} (100%) rename core/embed/{trezorhal => util/flash/inc/util}/flash_otp.h (100%) rename core/embed/{lib => util/flash/inc/util}/flash_utils.h (100%) rename core/embed/{trezorhal/stm32f4 => util/flash}/layout_helpers.h (100%) rename core/embed/{trezorhal => util/flash}/stm32f4/flash.c (99%) rename core/embed/{trezorhal/stm32f4/layout.c => util/flash/stm32f4/flash_layout.c} (96%) rename core/embed/{trezorhal => util/flash}/stm32f4/flash_otp.c (97%) rename core/embed/{trezorhal => util/flash}/stm32u5/flash.c (99%) rename core/embed/{trezorhal/stm32u5/layout.c => util/flash/stm32u5/flash_layout.c} (96%) rename core/embed/{trezorhal => util/flash}/stm32u5/flash_otp.c (97%) rename core/embed/{trezorhal => util/flash}/unix/flash.c (99%) rename core/embed/{trezorhal => util/flash}/unix/flash_otp.c (98%) rename core/embed/{trezorhal/stm32f4 => util/fwutils}/fwutils.c (97%) rename core/embed/{trezorhal => util/fwutils/inc/util}/fwutils.h (100%) rename core/embed/{lib => util/image}/image.c (99%) rename core/embed/{lib => util/image/inc/util}/image.h (99%) rename core/embed/{lib => util/image/inc/util}/image_hash_conf.h (97%) rename core/embed/{trezorhal => util/option_bytes/inc/util}/option_bytes.h (100%) rename core/embed/{trezorhal => util/option_bytes}/stm32f4/option_bytes.c (98%) rename core/embed/{trezorhal => util/option_bytes}/stm32u5/option_bytes.c (99%) rename core/embed/{lib => util/rsod/inc/util}/rsod.h (98%) rename core/embed/{lib => util/rsod}/rsod.c (96%) rename core/embed/{lib => util/translations/inc/util}/translations.h (100%) rename core/embed/{lib => util/translations}/translations.c (94%) rename core/embed/{trezorhal => util/unit_properties/inc/util}/unit_properties.h (100%) rename core/embed/{trezorhal/stm32f4 => util/unit_properties/stm32}/unit_properties.c (98%) rename core/embed/{trezorhal => util/unit_properties}/unix/unit_properties.c (97%) diff --git a/.github/workflows/core-hw.yml b/.github/workflows/core-hw.yml index 2df469b585..ffd5ff48b3 100644 --- a/.github/workflows/core-hw.yml +++ b/.github/workflows/core-hw.yml @@ -6,7 +6,7 @@ on: workflow_dispatch: # [Device tests](../tests/device-tests.md) that run against an actual physical Trezors. -# The device needs to have special bootloader, found in `core/embed/bootloader_ci`, that +# The device needs to have special bootloader, found in `core/embed/projects/bootloader_ci`, that # makes it possible to flash firmware without confirmation on the touchscreen. # # All hardware tests are run nightly on the `main` branch, diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 806ef03f89..27e0db626f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,7 +38,7 @@ before_script: - . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh || true - $NIX_SHELL --run "poetry install --sync" - export LEGACY_VERSION=$($NIX_SHELL --run "./tools/version.sh legacy/firmware/version.h") - - export CORE_VERSION=$($NIX_SHELL --run "./tools/version.sh core/embed/firmware/version.h") + - export CORE_VERSION=$($NIX_SHELL --run "./tools/version.sh core/embed/projects/firmware/version.h") include: - ci/environment.yml diff --git a/Makefile b/Makefile index 693d62e4b6..d26f384d42 100644 --- a/Makefile +++ b/Makefile @@ -53,9 +53,9 @@ pystyle: ## apply code style on application sources and tests changelog_check: ## check changelog format ./tools/generate-changelog.py --check core - ./tools/generate-changelog.py --check core/embed/boardloader - ./tools/generate-changelog.py --check core/embed/bootloader - ./tools/generate-changelog.py --check core/embed/bootloader_ci + ./tools/generate-changelog.py --check core/embed/projects/boardloader + ./tools/generate-changelog.py --check core/embed/projects/bootloader + ./tools/generate-changelog.py --check core/embed/projects/bootloader_ci ./tools/generate-changelog.py --check legacy/bootloader ./tools/generate-changelog.py --check legacy/firmware ./tools/generate-changelog.py --check legacy/intermediate_fw diff --git a/ci/check_changelog.sh b/ci/check_changelog.sh index b6662e8a23..8a6894e0f1 100755 --- a/ci/check_changelog.sh +++ b/ci/check_changelog.sh @@ -5,10 +5,10 @@ set -u base_branch=main fail=0 subdirs="core - core/embed/boardloader - core/embed/bootloader - core/embed/bootloader_ci - core/embed/prodtest + core/embed/projects/boardloader + core/embed/projects/bootloader + core/embed/projects/bootloader_ci + core/embed/projects/prodtest legacy/bootloader legacy/firmware legacy/intermediate_fw diff --git a/ci/deploy.yml b/ci/deploy.yml index 2cd163476b..6b2fdb798b 100644 --- a/ci/deploy.yml +++ b/ci/deploy.yml @@ -12,7 +12,7 @@ release core fw regular deploy: needs: - core fw regular build script: - - export VERSION=$(./tools/version.sh core/embed/firmware/version.h) + - export VERSION=$(./tools/version.sh core/embed/projects/firmware/version.h) - export NAME="firmware-T2T1-$VERSION-$CI_COMMIT_SHORT_SHA.bin" - echo "Deploying to ${DEPLOY_DIRECTORY}/$NAME" - mkdir -p "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}" @@ -34,7 +34,7 @@ release core fw btconly deploy: needs: - core fw btconly build script: - - export VERSION=$(./tools/version.sh core/embed/firmware/version.h) + - export VERSION=$(./tools/version.sh core/embed/projects/firmware/version.h) - export NAME="firmware-T2T1-btconly-$VERSION-$CI_COMMIT_SHORT_SHA.bin" - echo "Deploying to ${DEPLOY_DIRECTORY}/$NAME" - mkdir -p "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}" @@ -56,7 +56,7 @@ release core fw regular debug deploy: needs: - core fw regular debug build script: - - export VERSION=$(./tools/version.sh core/embed/firmware/version.h) + - export VERSION=$(./tools/version.sh core/embed/projects/firmware/version.h) - export NAME="firmware-T2T1-debug-$VERSION-$CI_COMMIT_SHORT_SHA.bin" - echo "Deploying to ${DEPLOY_DIRECTORY}/$NAME" - mkdir -p "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}" @@ -78,7 +78,7 @@ release core fw btconly debug deploy: needs: - core fw btconly debug build script: - - export VERSION=$(./tools/version.sh core/embed/firmware/version.h) + - export VERSION=$(./tools/version.sh core/embed/projects/firmware/version.h) - export NAME="firmware-T2T1-btconly-debug-$VERSION-$CI_COMMIT_SHORT_SHA.bin" - echo "Deploying to ${DEPLOY_DIRECTORY}/$NAME" - mkdir -p "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}" @@ -193,7 +193,7 @@ release core unix debug deploy: - core unix frozen debug build - core unix frozen debug build arm script: - - export VERSION=$(./tools/version.sh core/embed/firmware/version.h) + - export VERSION=$(./tools/version.sh core/embed/projects/firmware/version.h) - DEST="$DEPLOY_PATH/trezor-emu-core-v$VERSION" - DEST_ARM="$DEPLOY_PATH/arm/trezor-emu-core-v$VERSION-arm" - echo "Deploying to $DEST and $DEST_ARM" diff --git a/core/Makefile b/core/Makefile index 6653740355..9d5d6eef3c 100644 --- a/core/Makefile +++ b/core/Makefile @@ -401,10 +401,10 @@ flash_erase_storage: ## erase storage sectors from flash $(OPENOCD) -c "init; reset halt; flash erase_sector 0 $(STORAGE_1_SECTOR_START) $(STORAGE_1_SECTOR_END); flash erase_sector 0 $(STORAGE_2_SECTOR_START) $(STORAGE_2_SECTOR_END); exit" flash_bootloader_jlink: $(BOOTLOADER_BUILD_DIR)/bootloader.bin ## flash bootloader using JLink - JLinkExe -nogui 1 -commanderscript embed/bootloader/bootloader_flash.jlink + JLinkExe -nogui 1 -commanderscript embed/projects/bootloader/bootloader_flash.jlink flash_bootloader_ci_jlink: $(BOOTLOADER_CI_BUILD_DIR)/bootloader.bin ## flash CI bootloader using JLink - JLinkExe -nogui 1 -commanderscript embed/bootloader_ci/bootloader_flash.jlink + JLinkExe -nogui 1 -commanderscript embed/projects/bootloader_ci/bootloader_flash.jlink flash_firmware_jlink: $(FIRMWARE_BUILD_DIR)/firmware.bin ## flash firmware using JLink. file names must end in .bin for JLink cp -f $<.p1 $<.p1.bin @@ -412,7 +412,7 @@ flash_firmware_jlink: $(FIRMWARE_BUILD_DIR)/firmware.bin ## flash firmware using ## pad 2nd part so that FW integrity works after flash ## read&compare in flashing will avoid erasing unmodified sectors truncate -s $(FIRMWARE_P2_MAXSIZE) $<.p2.bin - JLinkExe -nogui 1 -commanderscript embed/firmware/firmware_flash.jlink + JLinkExe -nogui 1 -commanderscript embed/projects/firmware/firmware_flash.jlink ## openocd debug commands: diff --git a/core/SConscript.boardloader b/core/SConscript.boardloader index c267b47cde..b776b01056 100644 --- a/core/SConscript.boardloader +++ b/core/SConscript.boardloader @@ -52,20 +52,21 @@ CPPPATH_MOD += [ 'vendor/micropython/lib/uzlib', ] SOURCE_MOD += [ - 'embed/lib/display_utils.c', - 'embed/lib/error_handling.c', - 'embed/lib/flash_utils.c', - 'embed/lib/fonts/font_bitmap.c', - 'embed/lib/fonts/fonts.c', - 'embed/lib/gfx_color.c', - 'embed/lib/gfx_bitblt_rgb565.c', - 'embed/lib/gfx_bitblt_rgba8888.c', - 'embed/lib/gfx_bitblt_mono8.c', - 'embed/lib/image.c', - 'embed/lib/mini_printf.c', - 'embed/lib/rsod.c', - 'embed/lib/terminal.c', - 'embed/lib/gfx_draw.c' + 'embed/gfx/bitblt/gfx_bitblt.c', + 'embed/gfx/bitblt/gfx_bitblt_rgb565.c', + 'embed/gfx/bitblt/gfx_bitblt_rgba8888.c', + 'embed/gfx/bitblt/gfx_bitblt_mono8.c', + 'embed/gfx/fonts/font_bitmap.c', + 'embed/gfx/fonts/fonts.c', + 'embed/gfx/gfx_color.c', + 'embed/gfx/gfx_draw.c', + 'embed/gfx/terminal.c', + 'embed/io/display/display_utils.c', + 'embed/util/flash/flash_utils.c', + 'embed/util/image/image.c', + 'embed/util/rsod/rsod.c', + 'embed/rtl/error_handling.c', + 'embed/rtl/mini_printf.c', ] env = Environment(ENV=os.environ, @@ -79,8 +80,8 @@ FEATURES_AVAILABLE = models.configure_board(TREZOR_MODEL, HW_REVISION, FEATURES_ FILE_SUFFIX= env.get('ENV')['SUFFIX'] SOURCE_BOARDLOADER = [ - f"embed/trezorhal/{FILE_SUFFIX}/startup_stage_0.s", - 'embed/boardloader/main.c', + f"embed/sys/startup/{FILE_SUFFIX}/startup_stage_0.s", + 'embed/projects/boardloader/main.c', ] @@ -113,11 +114,18 @@ env.Replace( CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB', LINKFLAGS="-T build/boardloader/memory.ld -Wl,--gc-sections -Wl,-Map=build/boardloader/boardloader.map -Wl,--warn-common -Wl,--print-memory-usage", CPPPATH=[ - 'embed/boardloader', - 'embed/lib', + 'embed/projects/boardloader', + 'embed/rtl/inc', 'embed/models', - 'embed/trezorhal', - 'embed/extmod/modtrezorui', + 'embed/upymod/modtrezorui', + 'embed/gfx/inc', + 'embed/io/button/inc', + 'embed/io/haptic/inc', + 'embed/io/touch/inc', + 'embed/io/usb/inc', + 'embed/sys/bsp/inc', + 'embed/util/image/inc', + 'embed/util/rsod/inc', 'vendor/micropython/lib/cmsis/inc', ] + CPPPATH_MOD + PATH_HAL, CPPDEFINES=[ @@ -165,7 +173,7 @@ program_elf = env.Command( env.Depends(program_elf, linkerscript_gen) BINARY_NAME = f"build/boardloader/boardloader-{models.get_model_identifier(TREZOR_MODEL)}" -BINARY_NAME += "-" + tools.get_version('embed/boardloader/version.h') +BINARY_NAME += "-" + tools.get_version('embed/projects/boardloader/version.h') BINARY_NAME += "-" + tools.get_git_revision_short_hash() BINARY_NAME += "-dirty" if tools.get_git_modified() else "" BINARY_NAME += ".bin" diff --git a/core/SConscript.bootloader b/core/SConscript.bootloader index 82b3cdbd85..e2b7c04614 100644 --- a/core/SConscript.bootloader +++ b/core/SConscript.bootloader @@ -61,21 +61,22 @@ CPPPATH_MOD += [ ] SOURCE_MOD += [ - 'embed/extmod/modtrezorcrypto/rand.c', - 'embed/lib/display_utils.c', - 'embed/lib/error_handling.c', - 'embed/lib/flash_utils.c', - 'embed/lib/fonts/font_bitmap.c', - 'embed/lib/fonts/fonts.c', - 'embed/lib/gfx_color.c', - 'embed/lib/gfx_bitblt_mono8.c', - 'embed/lib/gfx_bitblt_rgb565.c', - 'embed/lib/gfx_bitblt_rgba8888.c', - 'embed/lib/image.c', - 'embed/lib/mini_printf.c', - 'embed/lib/rsod.c', - 'embed/lib/terminal.c', - 'embed/lib/gfx_draw.c', + 'embed/upymod/modtrezorcrypto/rand.c', + 'embed/gfx/bitblt/gfx_bitblt.c', + 'embed/gfx/bitblt/gfx_bitblt_mono8.c', + 'embed/gfx/bitblt/gfx_bitblt_rgb565.c', + 'embed/gfx/bitblt/gfx_bitblt_rgba8888.c', + 'embed/gfx/fonts/font_bitmap.c', + 'embed/gfx/fonts/fonts.c', + 'embed/gfx/gfx_color.c', + 'embed/gfx/gfx_draw.c', + 'embed/gfx/terminal.c', + 'embed/io/display/display_utils.c', + 'embed/util/flash/flash_utils.c', + 'embed/util/image/image.c', + 'embed/util/rsod/rsod.c', + 'embed/rtl/error_handling.c', + 'embed/rtl/mini_printf.c', 'vendor/micropython/lib/uzlib/adler32.c', 'vendor/micropython/lib/uzlib/crc32.c', 'vendor/micropython/lib/uzlib/tinflate.c', @@ -100,13 +101,13 @@ FEATURES_AVAILABLE = models.configure_board(TREZOR_MODEL, HW_REVISION, FEATURES_ FILE_SUFFIX= env.get('ENV')['SUFFIX'] SOURCE_BOOTLOADER = [ - f'embed/trezorhal/{FILE_SUFFIX}/startup_stage_1.s', - 'embed/bootloader/header.S', - 'embed/bootloader/bootui.c', - 'embed/bootloader/main.c', - 'embed/bootloader/messages.c', - 'embed/bootloader/protob/messages.pb.c', - 'embed/bootloader/version_check.c', + f'embed/sys/startup/{FILE_SUFFIX}/startup_stage_1.s', + 'embed/projects/bootloader/header.S', + 'embed/projects/bootloader/bootui.c', + 'embed/projects/bootloader/main.c', + 'embed/projects/bootloader/messages.c', + 'embed/projects/bootloader/protob/messages.pb.c', + 'embed/projects/bootloader/version_check.c', ] @@ -128,13 +129,17 @@ env.Replace( ALLPATHS = [ 'embed/rust', - 'embed/bootloader', - 'embed/bootloader/nanopb', - 'embed/bootloader/protob', - 'embed/lib', + 'embed/projects/bootloader', + 'embed/projects/bootloader/nanopb', + 'embed/projects/bootloader/protob', + 'embed/rtl/inc', 'embed/models', - 'embed/trezorhal', - 'embed/extmod/modtrezorui', + 'embed/sys/bsp/inc', + 'embed/gfx/inc', + 'embed/util/translations/inc', + 'embed/util/image/inc', + 'embed/util/rsod/inc', + 'embed/upymod/modtrezorui', 'vendor/nanopb', ] + CPPPATH_MOD + PATH_HAL @@ -253,7 +258,7 @@ env.Depends(program_elf, rust) SUFFIX = '_qa' if BOOTLOADER_QA else '' BINARY_NAME = f"build/bootloader/bootloader-{models.get_model_identifier(TREZOR_MODEL)}{SUFFIX}" -BINARY_NAME += "-" + tools.get_version('embed/bootloader/version.h') +BINARY_NAME += "-" + tools.get_version('embed/projects/bootloader/version.h') BINARY_NAME += "-" + tools.get_git_revision_short_hash() BINARY_NAME += "-dirty" if tools.get_git_modified() else "" BINARY_NAME += ".bin" diff --git a/core/SConscript.bootloader_ci b/core/SConscript.bootloader_ci index 21adec4e87..8e1583fe44 100644 --- a/core/SConscript.bootloader_ci +++ b/core/SConscript.bootloader_ci @@ -56,21 +56,22 @@ CPPPATH_MOD += [ 'vendor/micropython/lib/uzlib', ] SOURCE_MOD += [ - 'embed/extmod/modtrezorcrypto/rand.c', - 'embed/lib/display_utils.c', - 'embed/lib/error_handling.c', - 'embed/lib/flash_utils.c', - 'embed/lib/fonts/font_bitmap.c', - 'embed/lib/fonts/fonts.c', - 'embed/lib/gfx_color.c', - 'embed/lib/gfx_bitblt_mono8.c', - 'embed/lib/gfx_bitblt_rgb565.c', - 'embed/lib/gfx_bitblt_rgba8888.c', - 'embed/lib/image.c', - 'embed/lib/mini_printf.c', - 'embed/lib/rsod.c', - 'embed/lib/terminal.c', - 'embed/lib/gfx_draw.c', + 'embed/upymod/modtrezorcrypto/rand.c', + 'embed/gfx/bitblt/gfx_bitblt.c', + 'embed/gfx/bitblt/gfx_bitblt_mono8.c', + 'embed/gfx/bitblt/gfx_bitblt_rgb565.c', + 'embed/gfx/bitblt/gfx_bitblt_rgba8888.c', + 'embed/gfx/fonts/font_bitmap.c', + 'embed/gfx/fonts/fonts.c', + 'embed/gfx/gfx_color.c', + 'embed/gfx/gfx_draw.c', + 'embed/gfx/terminal.c', + 'embed/io/display/display_utils.c', + 'embed/util/flash/flash_utils.c', + 'embed/util/image/image.c', + 'embed/util/rsod/rsod.c', + 'embed/rtl/error_handling.c', + 'embed/rtl/mini_printf.c', 'vendor/micropython/lib/uzlib/adler32.c', 'vendor/micropython/lib/uzlib/crc32.c', 'vendor/micropython/lib/uzlib/tinflate.c', @@ -94,13 +95,13 @@ FEATURES_AVAILABLE = models.configure_board(TREZOR_MODEL, HW_REVISION, FEATURES_ FILE_SUFFIX= env.get('ENV')['SUFFIX'] SOURCE_BOOTLOADER = [ - f'embed/trezorhal/{FILE_SUFFIX}/startup_stage_1.s', - 'embed/bootloader_ci/header.S', - 'embed/bootloader_ci/bootui.c', - 'embed/bootloader_ci/main.c', - 'embed/bootloader_ci/messages.c', - 'embed/bootloader_ci/protob/messages.pb.c', - 'embed/bootloader_ci/version_check.c', + f'embed/sys/startup/{FILE_SUFFIX}/startup_stage_1.s', + 'embed/projects/bootloader_ci/header.S', + 'embed/projects/bootloader_ci/bootui.c', + 'embed/projects/bootloader_ci/main.c', + 'embed/projects/bootloader_ci/messages.c', + 'embed/projects/bootloader_ci/protob/messages.pb.c', + 'embed/projects/bootloader_ci/version_check.c', ] env.Replace( @@ -132,13 +133,16 @@ env.Replace( CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB', LINKFLAGS=f'-T build/bootloader_ci/memory.ld -Wl,--gc-sections -Wl,-Map=build/bootloader_ci/bootloader.map -Wl,--warn-common', CPPPATH=[ - 'embed/bootloader_ci', - 'embed/bootloader_ci/nanopb', - 'embed/bootloader_ci/protob', - 'embed/lib', + 'embed/projects/bootloader_ci', + 'embed/projects/bootloader_ci/nanopb', + 'embed/projects/bootloader_ci/protob', + 'embed/rtl/inc', 'embed/models', - 'embed/trezorhal', - 'embed/extmod/modtrezorui', + 'embed/gfx/inc', + 'embed/sys/bsp/inc', + 'embed/util/image/inc', + 'embed/util/rsod/inc', + 'embed/upymod/modtrezorui', 'vendor/nanopb', ] + CPPPATH_MOD + PATH_HAL, CPPDEFINES=[ @@ -195,7 +199,7 @@ program_elf = env.Command( env.Depends(program_elf, linkerscript_gen) BINARY_NAME = f"build/bootloader_ci/bootloader_ci-{models.get_model_identifier(TREZOR_MODEL)}" -BINARY_NAME += "-" + tools.get_version('embed/bootloader_ci/version.h') +BINARY_NAME += "-" + tools.get_version('embed/projects/bootloader_ci/version.h') BINARY_NAME += "-" + tools.get_git_revision_short_hash() BINARY_NAME += "-dirty" if tools.get_git_modified() else "" BINARY_NAME += ".bin" diff --git a/core/SConscript.bootloader_emu b/core/SConscript.bootloader_emu index f7a4ff21d2..0761b7fc74 100644 --- a/core/SConscript.bootloader_emu +++ b/core/SConscript.bootloader_emu @@ -67,21 +67,22 @@ CPPPATH_MOD += [ ] SOURCE_MOD += [ - 'embed/extmod/modtrezorcrypto/rand.c', - 'embed/lib/display_utils.c', - 'embed/lib/error_handling.c', - 'embed/lib/flash_utils.c', - 'embed/lib/fonts/font_bitmap.c', - 'embed/lib/fonts/fonts.c', - 'embed/lib/gfx_color.c', - 'embed/lib/gfx_bitblt_mono8.c', - 'embed/lib/gfx_bitblt_rgb565.c', - 'embed/lib/gfx_bitblt_rgba8888.c', - 'embed/lib/image.c', - 'embed/lib/mini_printf.c', - 'embed/lib/rsod.c', - 'embed/lib/terminal.c', - 'embed/lib/gfx_draw.c', + 'embed/upymod/modtrezorcrypto/rand.c', + 'embed/gfx/bitblt/gfx_bitblt.c', + 'embed/gfx/bitblt/gfx_bitblt_mono8.c', + 'embed/gfx/bitblt/gfx_bitblt_rgb565.c', + 'embed/gfx/bitblt/gfx_bitblt_rgba8888.c', + 'embed/gfx/fonts/font_bitmap.c', + 'embed/gfx/fonts/fonts.c', + 'embed/gfx/gfx_color.c', + 'embed/gfx/gfx_draw.c', + 'embed/gfx/terminal.c', + 'embed/io/display/display_utils.c', + 'embed/util/flash/flash_utils.c', + 'embed/util/image/image.c', + 'embed/util/rsod/rsod.c', + 'embed/rtl/error_handling.c', + 'embed/rtl/mini_printf.c', 'vendor/micropython/lib/uzlib/adler32.c', 'vendor/micropython/lib/uzlib/crc32.c', 'vendor/micropython/lib/uzlib/tinflate.c', @@ -95,33 +96,33 @@ SOURCE_NANOPB = [ ] SOURCE_BOOTLOADER = [ - 'embed/bootloader/bootui.c', - 'embed/bootloader/main.c', - 'embed/bootloader/messages.c', - 'embed/bootloader/emulator.c', - 'embed/bootloader/version_check.c', - 'embed/bootloader/protob/messages.pb.c', + 'embed/projects/bootloader/bootui.c', + 'embed/projects/bootloader/main.c', + 'embed/projects/bootloader/messages.c', + 'embed/projects/bootloader/emulator.c', + 'embed/projects/bootloader/version_check.c', + 'embed/projects/bootloader/protob/messages.pb.c', ] SOURCE_TREZORHAL = [ - 'embed/trezorhal/unix/bootutils.c', - 'embed/trezorhal/unix/flash.c', - 'embed/trezorhal/unix/flash_otp.c', - 'embed/trezorhal/unix/mpu.c', - 'embed/trezorhal/unix/monoctr.c', - 'embed/trezorhal/unix/random_delays.c', - 'embed/trezorhal/unix/rng.c', - 'embed/trezorhal/unix/secret.c', - 'embed/trezorhal/unix/system.c', - 'embed/trezorhal/unix/systick.c', - 'embed/trezorhal/unix/systimer.c', - 'embed/trezorhal/unix/unit_properties.c', - 'embed/trezorhal/unix/usb.c', - 'embed/trezorhal/unix/display_driver.c', + 'embed/io/display/unix/display_driver.c', + 'embed/io/usb/unix/usb.c', + 'embed/sec/monoctr/unix/monoctr.c', + 'embed/sec/random_delays/unix/random_delays.c', + 'embed/sec/rng/unix/rng.c', + 'embed/sec/secret/unix/secret.c', + 'embed/sys/mpu/unix/mpu.c', + 'embed/sys/startup/unix/bootutils.c', + 'embed/sys/task/unix/system.c', + 'embed/sys/time/unix/systick.c', + 'embed/sys/time/unix/systimer.c', + 'embed/util/flash/unix/flash.c', + 'embed/util/flash/unix/flash_otp.c', + 'embed/util/unit_properties/unix/unit_properties.c', ] SOURCE_UNIX = [ - 'embed/unix/profile.c', + 'embed/projects/unix/profile.c', ] ui.init_ui(TREZOR_MODEL, "bootloader", CPPDEFINES_MOD, SOURCE_MOD, RUST_UI_FEATURES) @@ -136,6 +137,7 @@ env.Replace( AR='ar', CC='gcc', LINK='ld', + SIZE='size', STRIP='strip', OBJCOPY='objcopy', @@ -146,15 +148,32 @@ MODEL_IDENTIFIER = models.get_model_identifier(TREZOR_MODEL) MODEL_AS_NUMBER = str(models.get_hw_model_as_number(MODEL_IDENTIFIER)) ALLPATHS = ['embed/rust', - 'embed/bootloader', - 'embed/bootloader/nanopb', - 'embed/bootloader/protob', - 'embed/lib', + 'embed/projects/bootloader', + 'embed/projects/bootloader/nanopb', + 'embed/projects/bootloader/protob', + 'embed/rtl/inc', 'embed/models', - 'embed/trezorhal', - 'embed/trezorhal/unix', - 'embed/unix', - 'embed/extmod/modtrezorui', + 'embed/projects/unix', + 'embed/upymod/modtrezorui', + 'embed/gfx/inc', + 'embed/io/display/inc', + 'embed/io/usb/inc', + 'embed/sec/entropy/inc', + 'embed/sec/monoctr/inc', + 'embed/sec/random_delays/inc', + 'embed/sec/rng/inc', + 'embed/sec/secret/inc', + 'embed/sys/bsp/inc', + 'embed/sys/irq/inc', + 'embed/sys/mpu/inc', + 'embed/sys/startup/inc', + 'embed/sys/task/inc', + 'embed/sys/time/inc', + 'embed/util/flash/inc', + 'embed/util/image/inc', + 'embed/util/rsod/inc', + 'embed/util/translations/inc', + 'embed/util/unit_properties/inc', 'vendor/nanopb', ] + CPPPATH_MOD + PATH_HAL diff --git a/core/SConscript.firmware b/core/SConscript.firmware index 41187ba53f..244f6a01eb 100644 --- a/core/SConscript.firmware +++ b/core/SConscript.firmware @@ -46,11 +46,11 @@ FROZEN = True # modtrezorconfig CPPPATH_MOD += [ - 'embed/extmod/modtrezorconfig', + 'embed/upymod/modtrezorconfig', 'vendor/trezor-storage', ] SOURCE_MOD += [ - 'embed/extmod/modtrezorconfig/modtrezorconfig.c', + 'embed/upymod/modtrezorconfig/modtrezorconfig.c', ] # modtrezorcrypto @@ -70,10 +70,10 @@ CPPDEFINES_MOD += [ ('USE_EOS', '1' if (EVERYTHING and TREZOR_MODEL == "T") else '0'), ] SOURCE_MOD += [ - 'embed/extmod/trezorobj.c', - 'embed/extmod/modtrezorcrypto/crc.c', - 'embed/extmod/modtrezorcrypto/modtrezorcrypto.c', - 'embed/extmod/modtrezorcrypto/rand.c', + 'embed/upymod/trezorobj.c', + 'embed/upymod/modtrezorcrypto/crc.c', + 'embed/upymod/modtrezorcrypto/modtrezorcrypto.c', + 'embed/upymod/modtrezorcrypto/rand.c', ] SOURCE_MOD_CRYPTO += [ 'vendor/trezor-crypto/address.c', @@ -185,7 +185,7 @@ if FEATURE_FLAGS["AES_GCM"]: # modtrezorio SOURCE_MOD += [ - 'embed/extmod/modtrezorio/modtrezorio.c', + 'embed/upymod/modtrezorio/modtrezorio.c', ] # modtrezorui @@ -193,21 +193,22 @@ CPPPATH_MOD += [ 'vendor/micropython/lib/uzlib', ] SOURCE_MOD += [ - 'embed/extmod/modtrezorui/modtrezorui.c', - 'embed/lib/display_utils.c', - 'embed/lib/error_handling.c', - 'embed/lib/fonts/font_bitmap.c', - 'embed/lib/fonts/fonts.c', - 'embed/lib/gfx_color.c', - 'embed/lib/gfx_bitblt_rgb565.c', - 'embed/lib/gfx_bitblt_rgba8888.c', - 'embed/lib/gfx_bitblt_mono8.c', - 'embed/lib/image.c', - 'embed/lib/mini_printf.c', - 'embed/lib/rsod.c', - 'embed/lib/terminal.c', - 'embed/lib/translations.c', - 'embed/lib/gfx_draw.c', + 'embed/upymod/modtrezorui/modtrezorui.c', + 'embed/gfx/bitblt/gfx_bitblt.c', + 'embed/gfx/bitblt/gfx_bitblt_rgb565.c', + 'embed/gfx/bitblt/gfx_bitblt_rgba8888.c', + 'embed/gfx/bitblt/gfx_bitblt_mono8.c', + 'embed/gfx/fonts/font_bitmap.c', + 'embed/gfx/fonts/fonts.c', + 'embed/gfx/gfx_color.c', + 'embed/gfx/gfx_draw.c', + 'embed/gfx/terminal.c', + 'embed/io/display/display_utils.c', + 'embed/util/image/image.c', + 'embed/util/translations/translations.c', + 'embed/util/rsod/rsod.c', + 'embed/rtl/error_handling.c', + 'embed/rtl/mini_printf.c', 'vendor/micropython/lib/uzlib/adler32.c', 'vendor/micropython/lib/uzlib/crc32.c', 'vendor/micropython/lib/uzlib/tinflate.c', @@ -220,17 +221,17 @@ CPPDEFINES_MOD += [ # modtrezorutils SOURCE_MOD += [ - 'embed/extmod/modtrezorutils/modtrezorutils.c', + 'embed/upymod/modtrezorutils/modtrezorutils.c', ] # rust mods SOURCE_MOD += [ - 'embed/extmod/rustmods.c', + 'embed/upymod/rustmods.c', ] # modutime SOURCE_MOD += [ - 'embed/extmod/modutime.c', + 'embed/upymod/modutime.c', ] SOURCE_MICROPYTHON = [ @@ -380,11 +381,11 @@ FEATURES_AVAILABLE = models.configure_board(TREZOR_MODEL, HW_REVISION, FEATURES_ FILE_SUFFIX= env.get('ENV')['SUFFIX'] SOURCE_FIRMWARE = [ - 'embed/firmware/header.S', - 'embed/firmware/main.c', - 'embed/firmware/mphalport.c', - 'embed/firmware/nlrthumb.c', - f'embed/trezorhal/{FILE_SUFFIX}/startup_stage_4.s', + 'embed/projects/firmware/header.S', + 'embed/projects/firmware/main.c', + 'embed/projects/firmware/mphalport.c', + 'embed/projects/firmware/nlrthumb.c', + f'embed/sys/startup/{FILE_SUFFIX}/startup_stage_4.s', ] if 'sd_card' in FEATURES_AVAILABLE: @@ -413,11 +414,15 @@ env.Replace( ALLPATHS = [ '.', 'embed/rust', - 'embed/firmware', - 'embed/lib', + 'embed/projects/firmware', + 'embed/rtl/inc', 'embed/models', - 'embed/trezorhal', - 'embed/extmod/modtrezorui', + 'embed/gfx/inc', + 'embed/sys/bsp/inc', + 'embed/util/image/inc', + 'embed/util/rsod/inc', + 'embed/util/translations/inc', + 'embed/upymod/modtrezorui', 'vendor/micropython', ] + CPPPATH_MOD + PATH_HAL @@ -802,7 +807,7 @@ tools.embed_raw_binary( obj_program, env, 'vendorheader', - 'embed/firmware/vendorheader.o', + 'embed/projects/firmware/vendorheader.o', VENDORHEADER, ) @@ -840,7 +845,7 @@ env.Depends(program_elf, rust) BINARY_NAME = f"build/firmware/firmware-{MODEL_IDENTIFIER}" if not EVERYTHING: BINARY_NAME += "-btconly" -BINARY_NAME += "-" + tools.get_version('embed/firmware/version.h') +BINARY_NAME += "-" + tools.get_version('embed/projects/firmware/version.h') BINARY_NAME += "-" + tools.get_git_revision_short_hash() BINARY_NAME += "-dirty" if tools.get_git_modified() else "" BINARY_NAME += ".bin" diff --git a/core/SConscript.kernel b/core/SConscript.kernel index ae051c273e..3a6a6654b0 100644 --- a/core/SConscript.kernel +++ b/core/SConscript.kernel @@ -40,12 +40,12 @@ FROZEN = True # modtrezorconfig CPPPATH_MOD += [ - 'embed/extmod/modtrezorconfig', + 'embed/upymod/modtrezorconfig', 'vendor/trezor-storage', 'vendor/micropython/lib/uzlib', ] SOURCE_MOD += [ -# 'embed/extmod/modtrezorconfig/modtrezorconfig.c', +# 'embed/upymod/modtrezorconfig/modtrezorconfig.c', 'vendor/trezor-storage/norcow.c', 'vendor/trezor-storage/storage.c', 'vendor/trezor-storage/storage_utils.c', @@ -179,22 +179,21 @@ if FEATURE_FLAGS["AES_GCM"]: ] SOURCE_MOD += [ - 'embed/lib/bl_check.c', -# 'embed/lib/display_utils.c', - 'embed/lib/error_handling.c', - 'embed/lib/fonts/font_bitmap.c', -# 'embed/lib/fonts/fonts.c', - 'embed/lib/gfx_color.c', - 'embed/lib/gfx_bitblt_rgb565.c', - 'embed/lib/gfx_bitblt_rgba8888.c', - 'embed/lib/gfx_bitblt_mono8.c', - 'embed/lib/image.c', - 'embed/lib/mini_printf.c', - 'embed/lib/rsod.c', - 'embed/lib/terminal.c', - 'embed/lib/translations.c', - 'embed/lib/gfx_draw.c', - 'embed/extmod/modtrezorcrypto/rand.c', + 'embed/gfx/bitblt/gfx_bitblt.c', + 'embed/gfx/bitblt/gfx_bitblt_rgb565.c', + 'embed/gfx/bitblt/gfx_bitblt_rgba8888.c', + 'embed/gfx/bitblt/gfx_bitblt_mono8.c', + 'embed/gfx/fonts/font_bitmap.c', + 'embed/gfx/gfx_color.c', + 'embed/gfx/gfx_draw.c', + 'embed/gfx/terminal.c', + 'embed/util/bl_check/bl_check.c', + 'embed/util/translations/translations.c', + 'embed/util/image/image.c', + 'embed/util/rsod/rsod.c', + 'embed/rtl/error_handling.c', + 'embed/rtl/mini_printf.c', + 'embed/upymod/modtrezorcrypto/rand.c', 'vendor/micropython/lib/uzlib/adler32.c', 'vendor/micropython/lib/uzlib/crc32.c', 'vendor/micropython/lib/uzlib/tinflate.c', @@ -210,16 +209,17 @@ if FEATURE_FLAGS["RDI"]: if FEATURE_FLAGS["SYSTEM_VIEW"]: SOURCE_MOD += [ - 'embed/segger/Config/SEGGER_SYSVIEW_Config_NoOS.c', - 'embed/segger/SEGGER/SEGGER_SYSVIEW.c', - 'embed/segger/SEGGER/SEGGER_RTT.c', - 'embed/segger/SEGGER/SEGGER_RTT_ASM_ARMv7M.S', - 'embed/segger/SEGGER/Syscalls/SEGGER_RTT_Syscalls_GCC.c', - 'embed/firmware/systemview.c', + 'embed/sys/systemview/stm32/config/SEGGER_SYSVIEW_Config_NoOS.c', + 'embed/sys/systemview/stm32/segger/SEGGER_SYSVIEW.c', + 'embed/sys/systemview/stm32/segger/SEGGER_RTT.c', + 'embed/sys/systemview/stm32/segger/SEGGER_RTT_ASM_ARMv7M.S', + 'embed/sys/systemview/stm32/segger/Syscalls/SEGGER_RTT_Syscalls_GCC.c', + 'embed/sys/systemview/systemview.c', ] CPPPATH_MOD += [ - 'embed/segger/SEGGER/', - 'embed/segger/Config/', + 'embed/sys/systemview/inc', + 'embed/sys/systemview/stm32/config', + 'embed/sys/systemview/stm32/segger', ] CPPDEFINES_MOD += ['SYSTEM_VIEW'] CCFLAGS_MOD += '-DSYSTEM_VIEW ' @@ -247,8 +247,8 @@ FEATURES_AVAILABLE = models.configure_board(TREZOR_MODEL, HW_REVISION, FEATURES_ FILE_SUFFIX= env.get('ENV')['SUFFIX'] SOURCE_FIRMWARE = [ - 'embed/kernel/main.c', - f'embed/trezorhal/{FILE_SUFFIX}/startup_stage_2.s', + 'embed/projects/kernel/main.c', + f'embed/sys/startup/{FILE_SUFFIX}/startup_stage_2.s', ] if 'sd_card' in FEATURES_AVAILABLE: @@ -274,10 +274,15 @@ env.Replace( ALLPATHS = [ '.', - 'embed/firmware', - 'embed/lib', + 'embed/projects/firmware', + 'embed/rtl/inc', 'embed/models', - 'embed/trezorhal', + 'embed/gfx/inc', + 'embed/sys/bsp/inc', + 'embed/util/bl_check/inc', + 'embed/util/image/inc', + 'embed/util/rsod/inc', + 'embed/util/translations/inc', ] + CPPPATH_MOD + PATH_HAL env.Replace( @@ -357,7 +362,7 @@ VENDORHEADER = f'embed/models/{MODEL_IDENTIFIER}/vendorheader/vendorheader_{vend obj_program.extend( env.Command( - target='embed/kernel/vendorheader.o', + target='embed/projects/kernel/vendorheader.o', source=VENDORHEADER, action='$OBJCOPY -I binary -O elf32-littlearm -B arm' ' --rename-section .data=.vendorheader,alloc,load,readonly,contents' @@ -367,7 +372,7 @@ tools.embed_compressed_binary( obj_program, env, 'bootloader', - 'embed/bootloaders/bootloader.o', + 'embed/projects/bootloaders/bootloader.o', f'embed/models/{MODEL_IDENTIFIER}/bootloaders/bootloader_{BOOTLOADER_SUFFIX}.bin', 'kernel' ) @@ -393,7 +398,7 @@ if CMAKELISTS != 0: BINARY_NAME = f"build/kernel/kernel-{models.get_model_identifier(TREZOR_MODEL)}" if not EVERYTHING: BINARY_NAME += "-btconly" -BINARY_NAME += "-" + tools.get_version('embed/kernel/version.h') +BINARY_NAME += "-" + tools.get_version('embed/projects/kernel/version.h') BINARY_NAME += "-" + tools.get_git_revision_short_hash() BINARY_NAME += "-dirty" if tools.get_git_modified() else "" BINARY_NAME += ".bin" diff --git a/core/SConscript.prodtest b/core/SConscript.prodtest index ad391f970a..e4fa2d57f2 100644 --- a/core/SConscript.prodtest +++ b/core/SConscript.prodtest @@ -62,20 +62,21 @@ CPPPATH_MOD += [ ] SOURCE_MOD += [ - 'embed/lib/display_utils.c', - 'embed/lib/error_handling.c', - 'embed/lib/fonts/font_bitmap.c', - 'embed/lib/fonts/fonts.c', - 'embed/lib/gfx_color.c', - 'embed/lib/gfx_bitblt_rgb565.c', - 'embed/lib/gfx_bitblt_rgba8888.c', - 'embed/lib/gfx_bitblt_mono8.c', - 'embed/lib/image.c', - 'embed/lib/mini_printf.c', - 'embed/lib/rsod.c', - 'embed/lib/qr-code-generator/qrcodegen.c', - 'embed/lib/terminal.c', - 'embed/lib/gfx_draw.c', + 'embed/gfx/bitblt/gfx_bitblt.c', + 'embed/gfx/bitblt/gfx_bitblt_rgb565.c', + 'embed/gfx/bitblt/gfx_bitblt_rgba8888.c', + 'embed/gfx/bitblt/gfx_bitblt_mono8.c', + 'embed/gfx/fonts/font_bitmap.c', + 'embed/gfx/fonts/fonts.c', + 'embed/gfx/gfx_color.c', + 'embed/gfx/gfx_draw.c', + 'embed/gfx/terminal.c', + 'embed/gfx/qrcode/qrcodegen.c', + 'embed/io/display/display_utils.c', + 'embed/util/image/image.c', + 'embed/util/rsod/rsod.c', + 'embed/rtl/error_handling.c', + 'embed/rtl/mini_printf.c', 'vendor/micropython/lib/uzlib/adler32.c', 'vendor/micropython/lib/uzlib/crc32.c', 'vendor/micropython/lib/uzlib/tinflate.c', @@ -94,15 +95,15 @@ FILE_SUFFIX= env.get('ENV')['SUFFIX'] SOURCE_PRODTEST = [ - f'embed/trezorhal/{FILE_SUFFIX}/startup_stage_2.s', - 'embed/prodtest/header.S', - 'embed/prodtest/main.c', - 'embed/prodtest/prodtest_common.c', + f'embed/sys/startup/{FILE_SUFFIX}/startup_stage_2.s', + 'embed/projects/prodtest/header.S', + 'embed/projects/prodtest/main.c', + 'embed/projects/prodtest/prodtest_common.c', ] if 'optiga' in FEATURES_AVAILABLE: SOURCE_PRODTEST += [ - 'embed/prodtest/optiga_prodtest.c', + 'embed/projects/prodtest/optiga_prodtest.c', ] env.Replace( @@ -134,11 +135,14 @@ env.Replace( CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB', LINKFLAGS=f'-T build/prodtest/memory.ld -Wl,--gc-sections -Wl,-Map=build/prodtest/prodtest.map -Wl,--warn-common', CPPPATH=[ - 'embed/prodtest', - 'embed/lib', + 'embed/projects/prodtest', + 'embed/rtl/inc', 'embed/models', - 'embed/trezorhal', - 'embed/extmod/modtrezorui', + 'embed/gfx/inc', + 'embed/sys/bsp/inc', + 'embed/util/image/inc', + 'embed/util/rsod/inc', + 'embed/upymod/modtrezorui', ] + CPPPATH_MOD + PATH_HAL, CPPDEFINES=[ 'TREZOR_PRODTEST', @@ -199,7 +203,7 @@ tools.embed_raw_binary( obj_program, env, 'vendorheader', - 'embed/firmware/vendorheader.o', + 'embed/projects/firmware/vendorheader.o', VENDORHEADER, ) @@ -219,7 +223,7 @@ program_elf = env.Command( env.Depends(program_elf, linkerscript_gen) BINARY_NAME = f"build/prodtest/prodtest-{models.get_model_identifier(TREZOR_MODEL)}" -BINARY_NAME += "-" + tools.get_version('embed/prodtest/version.h') +BINARY_NAME += "-" + tools.get_version('embed/projects/prodtest/version.h') BINARY_NAME += "-" + tools.get_git_revision_short_hash() BINARY_NAME += "-dirty" if tools.get_git_modified() else "" BINARY_NAME += ".bin" diff --git a/core/SConscript.reflash b/core/SConscript.reflash index 975d50d7fa..80f00fea0a 100644 --- a/core/SConscript.reflash +++ b/core/SConscript.reflash @@ -48,19 +48,20 @@ CPPPATH_MOD += [ 'vendor/micropython/lib/uzlib', ] SOURCE_MOD += [ - 'embed/lib/display_utils.c', - 'embed/lib/error_handling.c', - 'embed/lib/fonts/font_bitmap.c', - 'embed/lib/fonts/fonts.c', - 'embed/lib/gfx_color.c', - 'embed/lib/gfx_bitblt_mono8.c', - 'embed/lib/gfx_bitblt_rgb565.c', - 'embed/lib/gfx_bitblt_rgba8888.c', - 'embed/lib/image.c', - 'embed/lib/mini_printf.c', - 'embed/lib/rsod.c', - 'embed/lib/terminal.c', - 'embed/lib/gfx_draw.c', + 'embed/gfx/bitblt/gfx_bitblt.c', + 'embed/gfx/bitblt/gfx_bitblt_mono8.c', + 'embed/gfx/bitblt/gfx_bitblt_rgb565.c', + 'embed/gfx/bitblt/gfx_bitblt_rgba8888.c', + 'embed/gfx/fonts/font_bitmap.c', + 'embed/gfx/fonts/fonts.c', + 'embed/gfx/gfx_color.c', + 'embed/gfx/gfx_draw.c', + 'embed/gfx/terminal.c', + 'embed/io/display/display_utils.c', + 'embed/util/image/image.c', + 'embed/util/rsod/rsod.c', + 'embed/rtl/error_handling.c', + 'embed/rtl/mini_printf.c', 'vendor/micropython/lib/uzlib/adler32.c', 'vendor/micropython/lib/uzlib/crc32.c', 'vendor/micropython/lib/uzlib/tinflate.c', @@ -80,9 +81,9 @@ FEATURES_AVAILABLE = models.configure_board(TREZOR_MODEL, HW_REVISION, FEATURES_ FILE_SUFFIX= env.get('ENV')['SUFFIX'] SOURCE_REFLASH = [ - f'embed/trezorhal/{FILE_SUFFIX}/startup_stage_2.s', - 'embed/reflash/header.S', - 'embed/reflash/main.c', + f'embed/sys/startup/{FILE_SUFFIX}/startup_stage_2.s', + 'embed/projects/reflash/header.S', + 'embed/projects/reflash/main.c', ] env.Replace( @@ -114,11 +115,14 @@ env.Replace( CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB', LINKFLAGS=f'-T build/reflash/memory.ld -Wl,--gc-sections -Wl,-Map=build/reflash/reflash.map -Wl,--warn-common', CPPPATH=[ - 'embed/reflash', - 'embed/lib', + 'embed/projects/reflash', + 'embed/rtl/inc', 'embed/models', - 'embed/trezorhal', - 'embed/extmod/modtrezorui', + 'embed/gfx/inc', + 'embed/sys/bsp/inc', + 'embed/util/image/inc', + 'embed/util/rsod/inc', + 'embed/upymod/modtrezorui', ] + CPPPATH_MOD + PATH_HAL, CPPDEFINES=[ 'TREZOR_MODEL_'+TREZOR_MODEL, @@ -160,7 +164,7 @@ tools.embed_raw_binary( obj_program, env, 'vendorheader', - 'embed/firmware/vendorheader.o', + 'embed/projects/firmware/vendorheader.o', VENDORHEADER, ) @@ -180,7 +184,7 @@ program_elf = env.Command( env.Depends(program_elf, linkerscript_gen) BINARY_NAME = f"build/reflash/reflash-{models.get_model_identifier(TREZOR_MODEL)}" -BINARY_NAME += "-" + tools.get_version('embed/reflash/version.h') +BINARY_NAME += "-" + tools.get_version('embed/projects/reflash/version.h') BINARY_NAME += "-" + tools.get_git_revision_short_hash() BINARY_NAME += "-dirty" if tools.get_git_modified() else "" BINARY_NAME += ".bin" diff --git a/core/SConscript.unix b/core/SConscript.unix index 73152e1cc6..b6304ff787 100644 --- a/core/SConscript.unix +++ b/core/SConscript.unix @@ -51,11 +51,11 @@ RUST_UI_FEATURES = [] # modtrezorconfig CPPPATH_MOD += [ - 'embed/extmod/modtrezorconfig', + 'embed/upymod/modtrezorconfig', 'vendor/trezor-storage', ] SOURCE_MOD += [ - 'embed/extmod/modtrezorconfig/modtrezorconfig.c', + 'embed/upymod/modtrezorconfig/modtrezorconfig.c', 'vendor/trezor-storage/norcow.c', 'vendor/trezor-storage/storage.c', 'vendor/trezor-storage/storage_utils.c', @@ -81,9 +81,9 @@ CPPDEFINES_MOD += [ ('USE_EOS', '1' if (EVERYTHING and TREZOR_MODEL == "T") else '0'), ] SOURCE_MOD += [ - 'embed/extmod/trezorobj.c', - 'embed/extmod/modtrezorcrypto/crc.c', - 'embed/extmod/modtrezorcrypto/modtrezorcrypto.c', + 'embed/upymod/trezorobj.c', + 'embed/upymod/modtrezorcrypto/crc.c', + 'embed/upymod/modtrezorcrypto/modtrezorcrypto.c', ] SOURCE_MOD_CRYPTO += [ 'vendor/trezor-crypto/address.c', @@ -196,7 +196,7 @@ if THP: # modtrezorio SOURCE_MOD += [ - 'embed/extmod/modtrezorio/modtrezorio.c', + 'embed/upymod/modtrezorio/modtrezorio.c', ] # modtrezorui @@ -204,21 +204,22 @@ CPPPATH_MOD += [ 'vendor/micropython/lib/uzlib', ] SOURCE_MOD += [ - 'embed/extmod/modtrezorui/modtrezorui.c', - 'embed/lib/display_utils.c', - 'embed/lib/error_handling.c', - 'embed/lib/fonts/font_bitmap.c', - 'embed/lib/fonts/fonts.c', - 'embed/lib/gfx_color.c', - 'embed/lib/gfx_bitblt_rgb565.c', - 'embed/lib/gfx_bitblt_rgba8888.c', - 'embed/lib/gfx_bitblt_mono8.c', - 'embed/lib/image.c', - 'embed/lib/mini_printf.c', - 'embed/lib/rsod.c', - 'embed/lib/terminal.c', - 'embed/lib/translations.c', - 'embed/lib/gfx_draw.c', + 'embed/upymod/modtrezorui/modtrezorui.c', + 'embed/gfx/bitblt/gfx_bitblt.c', + 'embed/gfx/bitblt/gfx_bitblt_rgb565.c', + 'embed/gfx/bitblt/gfx_bitblt_rgba8888.c', + 'embed/gfx/bitblt/gfx_bitblt_mono8.c', + 'embed/gfx/fonts/font_bitmap.c', + 'embed/gfx/fonts/fonts.c', + 'embed/gfx/gfx_color.c', + 'embed/gfx/gfx_draw.c', + 'embed/gfx/terminal.c', + 'embed/io/display/display_utils.c', + 'embed/util/image/image.c', + 'embed/util/translations/translations.c', + 'embed/util/rsod/rsod.c', + 'embed/rtl/error_handling.c', + 'embed/rtl/mini_printf.c', 'vendor/micropython/lib/uzlib/adler32.c', 'vendor/micropython/lib/uzlib/crc32.c', 'vendor/micropython/lib/uzlib/tinflate.c', @@ -236,17 +237,17 @@ if RASPI: # modtrezorutils SOURCE_MOD += [ - 'embed/extmod/modtrezorutils/modtrezorutils.c', + 'embed/upymod/modtrezorutils/modtrezorutils.c', ] # rust mods SOURCE_MOD += [ - 'embed/extmod/rustmods.c', + 'embed/upymod/rustmods.c', ] # modutime SOURCE_MOD += [ - 'embed/extmod/modutime.c', + 'embed/upymod/modutime.c', ] SOURCE_MICROPYTHON = [ @@ -376,24 +377,24 @@ SOURCE_MICROPYTHON = [ ] SOURCE_UNIX = [ - 'embed/trezorhal/unix/bootutils.c', - 'embed/trezorhal/unix/entropy.c', - 'embed/trezorhal/unix/flash_otp.c', - 'embed/trezorhal/unix/flash.c', - 'embed/trezorhal/unix/fwutils.c', - 'embed/trezorhal/unix/mpu.c', - 'embed/trezorhal/unix/random_delays.c', - 'embed/trezorhal/unix/rng.c', - 'embed/trezorhal/unix/system.c', - 'embed/trezorhal/unix/systick.c', - 'embed/trezorhal/unix/systimer.c', - 'embed/trezorhal/unix/time_estimate.c', - 'embed/trezorhal/unix/unit_properties.c', - 'embed/trezorhal/unix/usb.c', - 'embed/trezorhal/unix/display_driver.c', - 'embed/unix/main_main.c', - 'embed/unix/main.c', - 'embed/unix/profile.c', + 'embed/io/display/unix/display_driver.c', + 'embed/io/usb/unix/usb.c', + 'embed/sec/entropy/unix/entropy.c', + 'embed/sec/random_delays/unix/random_delays.c', + 'embed/sec/rng/unix/rng.c', + 'embed/sec/time_estimate/unix/time_estimate.c', + 'embed/sys/mpu/unix/mpu.c', + 'embed/sys/startup/unix/bootutils.c', + 'embed/sys/task/unix/system.c', + 'embed/sys/time/unix/systick.c', + 'embed/sys/time/unix/systimer.c', + 'embed/util/flash/unix/flash.c', + 'embed/util/flash/unix/flash_otp.c', + 'embed/util/fwutils/fwutils.c', + 'embed/util/unit_properties/unix/unit_properties.c', + 'embed/projects/unix/main_main.c', + 'embed/projects/unix/main.c', + 'embed/projects/unix/profile.c', 'vendor/micropython/ports/unix/alloc.c', 'vendor/micropython/ports/unix/gccollect.c', 'vendor/micropython/ports/unix/input.c', @@ -469,12 +470,28 @@ env.Replace( ALLPATHS=['.', 'embed/rust', - 'embed/lib', + 'embed/rtl/inc', 'embed/models', - 'embed/unix', - 'embed/trezorhal', - 'embed/trezorhal/unix', - 'embed/extmod/modtrezorui', + 'embed/projects/unix', + 'embed/upymod/modtrezorui', + 'embed/gfx/inc', + 'embed/io/display/inc', + 'embed/io/usb/inc', + 'embed/sec/entropy/inc', + 'embed/sec/random_delays/inc', + 'embed/sec/time_estimate/inc', + 'embed/sys/bsp/inc', + 'embed/sec/rng/inc', + 'embed/sys/mpu/inc', + 'embed/sys/startup/inc', + 'embed/sys/task/inc', + 'embed/sys/time/inc', + 'embed/util/flash/inc', + 'embed/util/fwutils/inc', + 'embed/util/image/inc', + 'embed/util/rsod/inc', + 'embed/util/translations/inc', + 'embed/util/unit_properties/inc', 'vendor/micropython', 'vendor/micropython/ports/unix', 'vendor/micropython/lib/mp-readline', @@ -491,7 +508,7 @@ env.Replace( CPPDEFINES=[ 'TREZOR_EMULATOR', 'TREZOR_MODEL_'+TREZOR_MODEL, - ('MP_CONFIGFILE', '\\"embed/unix/mpconfigport.h\\"'), + ('MP_CONFIGFILE', '\\"embed/projects/unix/mpconfigport.h\\"'), ui.get_ui_layout(TREZOR_MODEL), ] + CPPDEFINES_MOD + CPPDEFINES_HAL, ASPPFLAGS='$CFLAGS $CCFLAGS', ) diff --git a/core/embed/boardloader/.towncrier.template.md b/core/embed/boardloader/.towncrier.template.md deleted file mode 120000 index a8bbd1d221..0000000000 --- a/core/embed/boardloader/.towncrier.template.md +++ /dev/null @@ -1 +0,0 @@ -../../../tools/towncrier.template.md \ No newline at end of file diff --git a/core/embed/boardloader/CHANGELOG.unreleased b/core/embed/boardloader/CHANGELOG.unreleased deleted file mode 120000 index 5128a0ac23..0000000000 --- a/core/embed/boardloader/CHANGELOG.unreleased +++ /dev/null @@ -1 +0,0 @@ -../../../tools/generate-changelog-unreleased.sh \ No newline at end of file diff --git a/core/embed/boardloader/towncrier.toml b/core/embed/boardloader/towncrier.toml deleted file mode 120000 index 090013b7d4..0000000000 --- a/core/embed/boardloader/towncrier.toml +++ /dev/null @@ -1 +0,0 @@ -../../../tools/towncrier.toml \ No newline at end of file diff --git a/core/embed/bootloader/.towncrier.template.md b/core/embed/bootloader/.towncrier.template.md deleted file mode 120000 index a8bbd1d221..0000000000 --- a/core/embed/bootloader/.towncrier.template.md +++ /dev/null @@ -1 +0,0 @@ -../../../tools/towncrier.template.md \ No newline at end of file diff --git a/core/embed/bootloader/CHANGELOG.unreleased b/core/embed/bootloader/CHANGELOG.unreleased deleted file mode 120000 index 5128a0ac23..0000000000 --- a/core/embed/bootloader/CHANGELOG.unreleased +++ /dev/null @@ -1 +0,0 @@ -../../../tools/generate-changelog-unreleased.sh \ No newline at end of file diff --git a/core/embed/bootloader/towncrier.toml b/core/embed/bootloader/towncrier.toml deleted file mode 120000 index 090013b7d4..0000000000 --- a/core/embed/bootloader/towncrier.toml +++ /dev/null @@ -1 +0,0 @@ -../../../tools/towncrier.toml \ No newline at end of file diff --git a/core/embed/bootloader_ci/.towncrier.template.md b/core/embed/bootloader_ci/.towncrier.template.md deleted file mode 120000 index a8bbd1d221..0000000000 --- a/core/embed/bootloader_ci/.towncrier.template.md +++ /dev/null @@ -1 +0,0 @@ -../../../tools/towncrier.template.md \ No newline at end of file diff --git a/core/embed/bootloader_ci/CHANGELOG.unreleased b/core/embed/bootloader_ci/CHANGELOG.unreleased deleted file mode 120000 index 5128a0ac23..0000000000 --- a/core/embed/bootloader_ci/CHANGELOG.unreleased +++ /dev/null @@ -1 +0,0 @@ -../../../tools/generate-changelog-unreleased.sh \ No newline at end of file diff --git a/core/embed/bootloader_ci/towncrier.toml b/core/embed/bootloader_ci/towncrier.toml deleted file mode 120000 index 090013b7d4..0000000000 --- a/core/embed/bootloader_ci/towncrier.toml +++ /dev/null @@ -1 +0,0 @@ -../../../tools/towncrier.toml \ No newline at end of file diff --git a/core/embed/trezorhal/dma2d_bitblt.h b/core/embed/gfx/bitblt/dma2d_bitblt.h similarity index 98% rename from core/embed/trezorhal/dma2d_bitblt.h rename to core/embed/gfx/bitblt/dma2d_bitblt.h index 86c0731167..b09786f8cc 100644 --- a/core/embed/trezorhal/dma2d_bitblt.h +++ b/core/embed/gfx/bitblt/dma2d_bitblt.h @@ -20,7 +20,7 @@ #ifndef TREZORHAL_DMA2D_BITBLT_H #define TREZORHAL_DMA2D_BITBLT_H -#include "gfx_bitblt.h" +#include // Initializes DMA2D peripheral void dma2d_init(void); diff --git a/core/embed/gfx/bitblt/gfx_bitblt.c b/core/embed/gfx/bitblt/gfx_bitblt.c new file mode 100644 index 0000000000..268a6924fa --- /dev/null +++ b/core/embed/gfx/bitblt/gfx_bitblt.c @@ -0,0 +1,32 @@ +/* + * 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 . + */ + +#include "dma2d_bitblt.h" + +void gfx_bitblt_init(void) { +#if defined(USE_DMA2D) && !defined(TREZOR_EMULATOR) + dma2d_init(); +#endif +} + +void gfx_bitblt_wait(void) { +#if defined(USE_DMA2D) && !defined(TREZOR_EMULATOR) + dma2d_wait(); +#endif +} diff --git a/core/embed/lib/gfx_bitblt_mono8.c b/core/embed/gfx/bitblt/gfx_bitblt_mono8.c similarity index 99% rename from core/embed/lib/gfx_bitblt_mono8.c rename to core/embed/gfx/bitblt/gfx_bitblt_mono8.c index 43603bc501..55a4fd5ab4 100644 --- a/core/embed/lib/gfx_bitblt_mono8.c +++ b/core/embed/gfx/bitblt/gfx_bitblt_mono8.c @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include "gfx_bitblt.h" +#include void gfx_mono8_fill(const gfx_bitblt_t* bb) { uint8_t* dst_ptr = (uint8_t*)bb->dst_row + bb->dst_x; diff --git a/core/embed/lib/gfx_bitblt_rgb565.c b/core/embed/gfx/bitblt/gfx_bitblt_rgb565.c similarity index 99% rename from core/embed/lib/gfx_bitblt_rgb565.c rename to core/embed/gfx/bitblt/gfx_bitblt_rgb565.c index 8648f5267a..324340ead0 100644 --- a/core/embed/lib/gfx_bitblt_rgb565.c +++ b/core/embed/gfx/bitblt/gfx_bitblt_rgb565.c @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include "gfx_bitblt.h" +#include #if USE_DMA2D #include "dma2d_bitblt.h" diff --git a/core/embed/lib/gfx_bitblt_rgba8888.c b/core/embed/gfx/bitblt/gfx_bitblt_rgba8888.c similarity index 99% rename from core/embed/lib/gfx_bitblt_rgba8888.c rename to core/embed/gfx/bitblt/gfx_bitblt_rgba8888.c index 1eab15525c..dea5c4881e 100644 --- a/core/embed/lib/gfx_bitblt_rgba8888.c +++ b/core/embed/gfx/bitblt/gfx_bitblt_rgba8888.c @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include "gfx_bitblt.h" +#include #if USE_DMA2D #include "dma2d_bitblt.h" diff --git a/core/embed/trezorhal/stm32f4/dma2d_bitblt.c b/core/embed/gfx/bitblt/stm32/dma2d_bitblt.c similarity index 99% rename from core/embed/trezorhal/stm32f4/dma2d_bitblt.c rename to core/embed/gfx/bitblt/stm32/dma2d_bitblt.c index 3668ba2e0a..7d14f4620c 100644 --- a/core/embed/trezorhal/stm32f4/dma2d_bitblt.c +++ b/core/embed/gfx/bitblt/stm32/dma2d_bitblt.c @@ -20,8 +20,9 @@ #include #include -#include "dma2d_bitblt.h" -#include "gfx_color.h" +#include + +#include "../dma2d_bitblt.h" static DMA2D_HandleTypeDef dma2d_handle = { .Instance = (DMA2D_TypeDef*)DMA2D_BASE, diff --git a/core/embed/lib/fonts/font_bitmap.c b/core/embed/gfx/fonts/font_bitmap.c similarity index 100% rename from core/embed/lib/fonts/font_bitmap.c rename to core/embed/gfx/fonts/font_bitmap.c diff --git a/core/embed/lib/fonts/font_bitmap.h b/core/embed/gfx/fonts/font_bitmap.h similarity index 100% rename from core/embed/lib/fonts/font_bitmap.h rename to core/embed/gfx/fonts/font_bitmap.h diff --git a/core/embed/lib/fonts/font_pixeloperator_bold_8.c b/core/embed/gfx/fonts/font_pixeloperator_bold_8.c similarity index 100% rename from core/embed/lib/fonts/font_pixeloperator_bold_8.c rename to core/embed/gfx/fonts/font_pixeloperator_bold_8.c diff --git a/core/embed/lib/fonts/font_pixeloperator_bold_8.h b/core/embed/gfx/fonts/font_pixeloperator_bold_8.h similarity index 100% rename from core/embed/lib/fonts/font_pixeloperator_bold_8.h rename to core/embed/gfx/fonts/font_pixeloperator_bold_8.h diff --git a/core/embed/lib/fonts/font_pixeloperator_regular_8.c b/core/embed/gfx/fonts/font_pixeloperator_regular_8.c similarity index 100% rename from core/embed/lib/fonts/font_pixeloperator_regular_8.c rename to core/embed/gfx/fonts/font_pixeloperator_regular_8.c diff --git a/core/embed/lib/fonts/font_pixeloperator_regular_8.h b/core/embed/gfx/fonts/font_pixeloperator_regular_8.h similarity index 100% rename from core/embed/lib/fonts/font_pixeloperator_regular_8.h rename to core/embed/gfx/fonts/font_pixeloperator_regular_8.h diff --git a/core/embed/lib/fonts/font_pixeloperatormono_regular_8.c b/core/embed/gfx/fonts/font_pixeloperatormono_regular_8.c similarity index 100% rename from core/embed/lib/fonts/font_pixeloperatormono_regular_8.c rename to core/embed/gfx/fonts/font_pixeloperatormono_regular_8.c diff --git a/core/embed/lib/fonts/font_pixeloperatormono_regular_8.h b/core/embed/gfx/fonts/font_pixeloperatormono_regular_8.h similarity index 100% rename from core/embed/lib/fonts/font_pixeloperatormono_regular_8.h rename to core/embed/gfx/fonts/font_pixeloperatormono_regular_8.h diff --git a/core/embed/lib/fonts/font_roboto_bold_20.c b/core/embed/gfx/fonts/font_roboto_bold_20.c similarity index 100% rename from core/embed/lib/fonts/font_roboto_bold_20.c rename to core/embed/gfx/fonts/font_roboto_bold_20.c diff --git a/core/embed/lib/fonts/font_roboto_bold_20.h b/core/embed/gfx/fonts/font_roboto_bold_20.h similarity index 100% rename from core/embed/lib/fonts/font_roboto_bold_20.h rename to core/embed/gfx/fonts/font_roboto_bold_20.h diff --git a/core/embed/lib/fonts/font_roboto_regular_20.c b/core/embed/gfx/fonts/font_roboto_regular_20.c similarity index 100% rename from core/embed/lib/fonts/font_roboto_regular_20.c rename to core/embed/gfx/fonts/font_roboto_regular_20.c diff --git a/core/embed/lib/fonts/font_roboto_regular_20.h b/core/embed/gfx/fonts/font_roboto_regular_20.h similarity index 100% rename from core/embed/lib/fonts/font_roboto_regular_20.h rename to core/embed/gfx/fonts/font_roboto_regular_20.h diff --git a/core/embed/lib/fonts/font_robotomono_medium_20.c b/core/embed/gfx/fonts/font_robotomono_medium_20.c similarity index 100% rename from core/embed/lib/fonts/font_robotomono_medium_20.c rename to core/embed/gfx/fonts/font_robotomono_medium_20.c diff --git a/core/embed/lib/fonts/font_robotomono_medium_20.h b/core/embed/gfx/fonts/font_robotomono_medium_20.h similarity index 100% rename from core/embed/lib/fonts/font_robotomono_medium_20.h rename to core/embed/gfx/fonts/font_robotomono_medium_20.h diff --git a/core/embed/lib/fonts/font_robotomono_medium_21.c b/core/embed/gfx/fonts/font_robotomono_medium_21.c similarity index 100% rename from core/embed/lib/fonts/font_robotomono_medium_21.c rename to core/embed/gfx/fonts/font_robotomono_medium_21.c diff --git a/core/embed/lib/fonts/font_robotomono_medium_21.h b/core/embed/gfx/fonts/font_robotomono_medium_21.h similarity index 100% rename from core/embed/lib/fonts/font_robotomono_medium_21.h rename to core/embed/gfx/fonts/font_robotomono_medium_21.h diff --git a/core/embed/lib/fonts/font_tthoves_bold_17.c b/core/embed/gfx/fonts/font_tthoves_bold_17.c similarity index 100% rename from core/embed/lib/fonts/font_tthoves_bold_17.c rename to core/embed/gfx/fonts/font_tthoves_bold_17.c diff --git a/core/embed/lib/fonts/font_tthoves_bold_17.h b/core/embed/gfx/fonts/font_tthoves_bold_17.h similarity index 100% rename from core/embed/lib/fonts/font_tthoves_bold_17.h rename to core/embed/gfx/fonts/font_tthoves_bold_17.h diff --git a/core/embed/lib/fonts/font_tthoves_demibold_21.c b/core/embed/gfx/fonts/font_tthoves_demibold_21.c similarity index 100% rename from core/embed/lib/fonts/font_tthoves_demibold_21.c rename to core/embed/gfx/fonts/font_tthoves_demibold_21.c diff --git a/core/embed/lib/fonts/font_tthoves_demibold_21.h b/core/embed/gfx/fonts/font_tthoves_demibold_21.h similarity index 100% rename from core/embed/lib/fonts/font_tthoves_demibold_21.h rename to core/embed/gfx/fonts/font_tthoves_demibold_21.h diff --git a/core/embed/lib/fonts/font_tthoves_regular_21.c b/core/embed/gfx/fonts/font_tthoves_regular_21.c similarity index 100% rename from core/embed/lib/fonts/font_tthoves_regular_21.c rename to core/embed/gfx/fonts/font_tthoves_regular_21.c diff --git a/core/embed/lib/fonts/font_tthoves_regular_21.h b/core/embed/gfx/fonts/font_tthoves_regular_21.h similarity index 100% rename from core/embed/lib/fonts/font_tthoves_regular_21.h rename to core/embed/gfx/fonts/font_tthoves_regular_21.h diff --git a/core/embed/lib/fonts/font_ttsatoshi_demibold_18.c b/core/embed/gfx/fonts/font_ttsatoshi_demibold_18.c similarity index 100% rename from core/embed/lib/fonts/font_ttsatoshi_demibold_18.c rename to core/embed/gfx/fonts/font_ttsatoshi_demibold_18.c diff --git a/core/embed/lib/fonts/font_ttsatoshi_demibold_18.h b/core/embed/gfx/fonts/font_ttsatoshi_demibold_18.h similarity index 100% rename from core/embed/lib/fonts/font_ttsatoshi_demibold_18.h rename to core/embed/gfx/fonts/font_ttsatoshi_demibold_18.h diff --git a/core/embed/lib/fonts/font_ttsatoshi_demibold_21.c b/core/embed/gfx/fonts/font_ttsatoshi_demibold_21.c similarity index 100% rename from core/embed/lib/fonts/font_ttsatoshi_demibold_21.c rename to core/embed/gfx/fonts/font_ttsatoshi_demibold_21.c diff --git a/core/embed/lib/fonts/font_ttsatoshi_demibold_21.h b/core/embed/gfx/fonts/font_ttsatoshi_demibold_21.h similarity index 100% rename from core/embed/lib/fonts/font_ttsatoshi_demibold_21.h rename to core/embed/gfx/fonts/font_ttsatoshi_demibold_21.h diff --git a/core/embed/lib/fonts/font_ttsatoshi_demibold_42.c b/core/embed/gfx/fonts/font_ttsatoshi_demibold_42.c similarity index 100% rename from core/embed/lib/fonts/font_ttsatoshi_demibold_42.c rename to core/embed/gfx/fonts/font_ttsatoshi_demibold_42.c diff --git a/core/embed/lib/fonts/font_ttsatoshi_demibold_42.h b/core/embed/gfx/fonts/font_ttsatoshi_demibold_42.h similarity index 100% rename from core/embed/lib/fonts/font_ttsatoshi_demibold_42.h rename to core/embed/gfx/fonts/font_ttsatoshi_demibold_42.h diff --git a/core/embed/lib/fonts/font_unifont_bold_16.c b/core/embed/gfx/fonts/font_unifont_bold_16.c similarity index 100% rename from core/embed/lib/fonts/font_unifont_bold_16.c rename to core/embed/gfx/fonts/font_unifont_bold_16.c diff --git a/core/embed/lib/fonts/font_unifont_bold_16.h b/core/embed/gfx/fonts/font_unifont_bold_16.h similarity index 100% rename from core/embed/lib/fonts/font_unifont_bold_16.h rename to core/embed/gfx/fonts/font_unifont_bold_16.h diff --git a/core/embed/lib/fonts/font_unifont_regular_16.c b/core/embed/gfx/fonts/font_unifont_regular_16.c similarity index 100% rename from core/embed/lib/fonts/font_unifont_regular_16.c rename to core/embed/gfx/fonts/font_unifont_regular_16.c diff --git a/core/embed/lib/fonts/font_unifont_regular_16.h b/core/embed/gfx/fonts/font_unifont_regular_16.h similarity index 100% rename from core/embed/lib/fonts/font_unifont_regular_16.h rename to core/embed/gfx/fonts/font_unifont_regular_16.h diff --git a/core/embed/lib/fonts/fonts.c b/core/embed/gfx/fonts/fonts.c similarity index 100% rename from core/embed/lib/fonts/fonts.c rename to core/embed/gfx/fonts/fonts.c diff --git a/core/embed/lib/fonts/fonts.h b/core/embed/gfx/fonts/fonts.h similarity index 99% rename from core/embed/lib/fonts/fonts.h rename to core/embed/gfx/fonts/fonts.h index fd4408103c..84c63dbba8 100644 --- a/core/embed/lib/fonts/fonts.h +++ b/core/embed/gfx/fonts/fonts.h @@ -22,7 +22,7 @@ #include -#include "fonts/font_bitmap.h" +#include "font_bitmap.h" #ifdef USE_RGB_COLORS #define TREZOR_FONT_BPP 4 diff --git a/core/embed/lib/gfx_color.c b/core/embed/gfx/gfx_color.c similarity index 98% rename from core/embed/lib/gfx_color.c rename to core/embed/gfx/gfx_color.c index bf5716c5a1..a96f038e57 100644 --- a/core/embed/lib/gfx_color.c +++ b/core/embed/gfx/gfx_color.c @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include "gfx_color.h" +#include const gfx_color16_t* gfx_color16_gradient_a4(gfx_color_t fg_color, gfx_color_t bg_color) { diff --git a/core/embed/lib/gfx_draw.c b/core/embed/gfx/gfx_draw.c similarity index 98% rename from core/embed/lib/gfx_draw.c rename to core/embed/gfx/gfx_draw.c index f180b791c7..a053e2d1f2 100644 --- a/core/embed/lib/gfx_draw.c +++ b/core/embed/gfx/gfx_draw.c @@ -20,9 +20,9 @@ #include #include -#include "display.h" -#include "fonts/fonts.h" -#include "gfx_draw.h" +#include +#include +#include typedef struct { int16_t dst_x; @@ -249,7 +249,7 @@ void gfx_draw_text(gfx_offset_t pos, const char* text, size_t maxlen, #ifdef TREZOR_PRODTEST -#include "qr-code-generator/qrcodegen.h" +#include "qrcode/qrcodegen.h" #define QR_MAX_VERSION 9 void gfx_draw_qrcode(gfx_offset_t offset, uint8_t scale, const char* data) { diff --git a/core/embed/trezorhal/unix/dma2d_bitblt.c b/core/embed/gfx/inc/gfx/fonts.h similarity index 90% rename from core/embed/trezorhal/unix/dma2d_bitblt.c rename to core/embed/gfx/inc/gfx/fonts.h index f92fae98dc..63094b1430 100644 --- a/core/embed/trezorhal/unix/dma2d_bitblt.c +++ b/core/embed/gfx/inc/gfx/fonts.h @@ -17,8 +17,4 @@ * along with this program. If not, see . */ -#include "dma2d_bitblt.h" - -void dma2d_init(void) {} - -void dma2d_wait(void) {} +#include "../../fonts/fonts.h" diff --git a/core/embed/lib/gfx_bitblt.h b/core/embed/gfx/inc/gfx/gfx_bitblt.h similarity index 96% rename from core/embed/lib/gfx_bitblt.h rename to core/embed/gfx/inc/gfx/gfx_bitblt.h index 88f5815526..7595a25eaf 100644 --- a/core/embed/lib/gfx_bitblt.h +++ b/core/embed/gfx/inc/gfx/gfx_bitblt.h @@ -22,7 +22,7 @@ #include -#include "gfx_color.h" +#include // These module provides low-level bit block transfer (bitblt) // operations on different bitmap/framebuffer types. @@ -75,6 +75,12 @@ typedef struct { } gfx_bitblt_t; +// Initializes bitblt operations +void gfx_bitblt_init(void); + +// If the bitblt operation is asynchronous, waits until it's finished +void gfx_bitblt_wait(void); + // Functions for RGB565 bitmap/framebuffer // Fills a rectangle with a solid color diff --git a/core/embed/lib/gfx_color.h b/core/embed/gfx/inc/gfx/gfx_color.h similarity index 100% rename from core/embed/lib/gfx_color.h rename to core/embed/gfx/inc/gfx/gfx_color.h diff --git a/core/embed/lib/gfx_draw.h b/core/embed/gfx/inc/gfx/gfx_draw.h similarity index 99% rename from core/embed/lib/gfx_draw.h rename to core/embed/gfx/inc/gfx/gfx_draw.h index 01f750a223..720516fee0 100644 --- a/core/embed/lib/gfx_draw.h +++ b/core/embed/gfx/inc/gfx/gfx_draw.h @@ -20,7 +20,7 @@ #ifndef GFX_DRAW_H #define GFX_DRAW_H -#include "gfx_color.h" +#include // 2D rectangle coordinates // diff --git a/core/embed/lib/terminal.h b/core/embed/gfx/inc/gfx/terminal.h similarity index 97% rename from core/embed/lib/terminal.h rename to core/embed/gfx/inc/gfx/terminal.h index 73d38a938c..5153406141 100644 --- a/core/embed/lib/terminal.h +++ b/core/embed/gfx/inc/gfx/terminal.h @@ -20,7 +20,7 @@ #ifndef LIB_TERMINAL_H #define LIB_TERMINAL_H -#include "gfx_color.h" +#include void term_set_color(gfx_color_t fgcolor, gfx_color_t bgcolor); void term_print(const char *text, int textlen); diff --git a/core/embed/lib/qr-code-generator b/core/embed/gfx/qrcode similarity index 100% rename from core/embed/lib/qr-code-generator rename to core/embed/gfx/qrcode diff --git a/core/embed/lib/terminal.c b/core/embed/gfx/terminal.c similarity index 96% rename from core/embed/lib/terminal.c rename to core/embed/gfx/terminal.c index ac81f84507..eef390cafa 100644 --- a/core/embed/lib/terminal.c +++ b/core/embed/gfx/terminal.c @@ -20,11 +20,11 @@ #include #include -#include "display.h" -#include "fonts/fonts.h" -#include "gfx_draw.h" -#include "mini_printf.h" -#include "terminal.h" +#include +#include +#include +#include +#include #define TERMINAL_COLS (DISPLAY_RESX / 6) #define TERMINAL_ROWS (DISPLAY_RESY / 8) diff --git a/core/embed/trezorhal/button.h b/core/embed/io/button/inc/io/button.h similarity index 100% rename from core/embed/trezorhal/button.h rename to core/embed/io/button/inc/io/button.h diff --git a/core/embed/trezorhal/stm32f4/button.c b/core/embed/io/button/stm32/button.c similarity index 99% rename from core/embed/trezorhal/stm32f4/button.c rename to core/embed/io/button/stm32/button.c index 8374598a6c..55cdfc65e3 100644 --- a/core/embed/trezorhal/stm32f4/button.c +++ b/core/embed/io/button/stm32/button.c @@ -20,7 +20,7 @@ #include #include -#include "button.h" +#include #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/unix/button.c b/core/embed/io/button/unix/button.c similarity index 99% rename from core/embed/trezorhal/unix/button.c rename to core/embed/io/button/unix/button.c index 8f5f3de166..e56d2b6c68 100644 --- a/core/embed/trezorhal/unix/button.c +++ b/core/embed/io/button/unix/button.c @@ -22,7 +22,7 @@ #include -#include "button.h" +#include // Button driver state typedef struct { diff --git a/core/embed/trezorhal/stm32f4/backlight_pwm.h b/core/embed/io/display/backlight/backlight_pwm.h similarity index 100% rename from core/embed/trezorhal/stm32f4/backlight_pwm.h rename to core/embed/io/display/backlight/backlight_pwm.h diff --git a/core/embed/trezorhal/stm32f4/backlight_pwm.c b/core/embed/io/display/backlight/stm32/backlight_pwm.c similarity index 99% rename from core/embed/trezorhal/stm32f4/backlight_pwm.c rename to core/embed/io/display/backlight/stm32/backlight_pwm.c index 8f30ef9b71..5670e5b432 100644 --- a/core/embed/trezorhal/stm32f4/backlight_pwm.c +++ b/core/embed/io/display/backlight/stm32/backlight_pwm.c @@ -20,8 +20,9 @@ #include #include -#include "backlight_pwm.h" -#include "systick.h" +#include + +#include "../backlight/backlight_pwm.h" // Requested PWM Timer clock frequency [Hz] #define TIM_FREQ 10000000 diff --git a/core/embed/trezorhal/bg_copy.h b/core/embed/io/display/bg_copy/bg_copy.h similarity index 100% rename from core/embed/trezorhal/bg_copy.h rename to core/embed/io/display/bg_copy/bg_copy.h diff --git a/core/embed/trezorhal/stm32u5/bg_copy.c b/core/embed/io/display/bg_copy/stm32u5/bg_copy.c similarity index 96% rename from core/embed/trezorhal/stm32u5/bg_copy.c rename to core/embed/io/display/bg_copy/stm32u5/bg_copy.c index be25d3b92b..07775a7f3b 100644 --- a/core/embed/trezorhal/stm32u5/bg_copy.c +++ b/core/embed/io/display/bg_copy/stm32u5/bg_copy.c @@ -1,9 +1,9 @@ #include -#include "bg_copy.h" -#include "irq.h" -#include "mpu.h" -#include "systemview.h" +#include +#include + +#include "../bg_copy/bg_copy.h" #ifdef KERNEL_MODE @@ -37,7 +37,8 @@ void HAL_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma) { } void GPDMA1_Channel0_IRQHandler(void) { - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); + mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); if ((DMA_Handle.Instance->CSR & DMA_CSR_TCF) == 0) { @@ -62,7 +63,8 @@ void GPDMA1_Channel0_IRQHandler(void) { } mpu_restore(mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + + IRQ_LOG_EXIT(); } bool bg_copy_pending(void) { return dma_transfer_remaining > 0; } diff --git a/core/embed/lib/display_utils.c b/core/embed/io/display/display_utils.c similarity index 95% rename from core/embed/lib/display_utils.c rename to core/embed/io/display/display_utils.c index ea803aa610..135c94a246 100644 --- a/core/embed/lib/display_utils.c +++ b/core/embed/io/display/display_utils.c @@ -19,8 +19,8 @@ #include -#include "display.h" -#include "systick.h" +#include +#include void display_fade(int start, int end, int delay) { #ifdef USE_BACKLIGHT diff --git a/core/embed/trezorhal/display.h b/core/embed/io/display/inc/io/display.h similarity index 99% rename from core/embed/trezorhal/display.h rename to core/embed/io/display/inc/io/display.h index d52b764efa..c64df9af68 100644 --- a/core/embed/trezorhal/display.h +++ b/core/embed/io/display/inc/io/display.h @@ -22,7 +22,7 @@ #include -#include "gfx_bitblt.h" +#include // This is a universal API for controlling different types of display // controllers. diff --git a/core/embed/lib/display_utils.h b/core/embed/io/display/inc/io/display_utils.h similarity index 100% rename from core/embed/lib/display_utils.h rename to core/embed/io/display/inc/io/display_utils.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_driver.c b/core/embed/io/display/st-7789/display_driver.c similarity index 97% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_driver.c rename to core/embed/io/display/st-7789/display_driver.c index a8a6730f37..0f9216a3fa 100644 --- a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_driver.c +++ b/core/embed/io/display/st-7789/display_driver.c @@ -19,17 +19,18 @@ #include -#include +#include +#include -#include "backlight_pwm.h" #include "display_fb.h" #include "display_internal.h" #include "display_io.h" #include "display_panel.h" -#include "mpu.h" + +#include "../backlight/backlight_pwm.h" #ifndef BOARDLOADER -#include "bg_copy.h" +#include "../bg_copy/bg_copy.h" #endif #define INTERNAL_FB_WIDTH 240 diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_fb.c b/core/embed/io/display/st-7789/display_fb.c similarity index 97% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_fb.c rename to core/embed/io/display/st-7789/display_fb.c index 2afb9c7494..a56a67421e 100644 --- a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_fb.c +++ b/core/embed/io/display/st-7789/display_fb.c @@ -21,21 +21,24 @@ #include #include -#include "display.h" +#include +#include +#include +#include + #include "display_fb.h" #include "display_internal.h" #include "display_io.h" #include "display_panel.h" -#include "gfx_bitblt.h" -#include "irq.h" -#include "mpu.h" -#include "sizedefs.h" -#include "systemview.h" -#include "trustzone.h" +#include + +#ifdef USE_TRUSTZONE +#include +#endif #ifndef BOARDLOADER -#include "bg_copy.h" +#include "../bg_copy/bg_copy.h" #endif #ifndef STM32U5 @@ -165,11 +168,11 @@ static void display_te_interrupt_handler(void) { } void DISPLAY_TE_INTERRUPT_HANDLER(void) { - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); display_te_interrupt_handler(); mpu_restore(mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + IRQ_LOG_EXIT(); } #endif diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_fb.h b/core/embed/io/display/st-7789/display_fb.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_fb.h rename to core/embed/io/display/st-7789/display_fb.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_internal.h b/core/embed/io/display/st-7789/display_internal.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_internal.h rename to core/embed/io/display/st-7789/display_internal.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_io.c b/core/embed/io/display/st-7789/display_io.c similarity index 99% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_io.c rename to core/embed/io/display/st-7789/display_io.c index 7b51894cc9..e8109fccee 100644 --- a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_io.c +++ b/core/embed/io/display/st-7789/display_io.c @@ -20,9 +20,9 @@ #include #include +#include +#include #include "display_io.h" -#include "irq.h" -#include "mpu.h" __IO DISP_MEM_TYPE *const DISPLAY_CMD_ADDRESS = (__IO DISP_MEM_TYPE *const)((uint32_t)DISPLAY_MEMORY_BASE); diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_io.h b/core/embed/io/display/st-7789/display_io.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_io.h rename to core/embed/io/display/st-7789/display_io.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_nofb.c b/core/embed/io/display/st-7789/display_nofb.c similarity index 99% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_nofb.c rename to core/embed/io/display/st-7789/display_nofb.c index f8d38dac9a..dde43a8bcf 100644 --- a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_nofb.c +++ b/core/embed/io/display/st-7789/display_nofb.c @@ -20,7 +20,7 @@ #include #include -#include +#include #include "display_io.h" #include "display_panel.h" diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_panel.c b/core/embed/io/display/st-7789/display_panel.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_panel.c rename to core/embed/io/display/st-7789/display_panel.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_panel.h b/core/embed/io/display/st-7789/display_panel.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_panel.h rename to core/embed/io/display/st-7789/display_panel.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/154a.c b/core/embed/io/display/st-7789/panels/154a.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/154a.c rename to core/embed/io/display/st-7789/panels/154a.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/154a.h b/core/embed/io/display/st-7789/panels/154a.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/154a.h rename to core/embed/io/display/st-7789/panels/154a.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lhs200kb-if21.c b/core/embed/io/display/st-7789/panels/lhs200kb-if21.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lhs200kb-if21.c rename to core/embed/io/display/st-7789/panels/lhs200kb-if21.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lhs200kb-if21.h b/core/embed/io/display/st-7789/panels/lhs200kb-if21.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lhs200kb-if21.h rename to core/embed/io/display/st-7789/panels/lhs200kb-if21.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2411.c b/core/embed/io/display/st-7789/panels/lx154a2411.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2411.c rename to core/embed/io/display/st-7789/panels/lx154a2411.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2411.h b/core/embed/io/display/st-7789/panels/lx154a2411.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2411.h rename to core/embed/io/display/st-7789/panels/lx154a2411.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2422.c b/core/embed/io/display/st-7789/panels/lx154a2422.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2422.c rename to core/embed/io/display/st-7789/panels/lx154a2422.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2422.h b/core/embed/io/display/st-7789/panels/lx154a2422.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2422.h rename to core/embed/io/display/st-7789/panels/lx154a2422.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2482.c b/core/embed/io/display/st-7789/panels/lx154a2482.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2482.c rename to core/embed/io/display/st-7789/panels/lx154a2482.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2482.h b/core/embed/io/display/st-7789/panels/lx154a2482.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2482.h rename to core/embed/io/display/st-7789/panels/lx154a2482.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/tf15411a.c b/core/embed/io/display/st-7789/panels/tf15411a.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/tf15411a.c rename to core/embed/io/display/st-7789/panels/tf15411a.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/tf15411a.h b/core/embed/io/display/st-7789/panels/tf15411a.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/tf15411a.h rename to core/embed/io/display/st-7789/panels/tf15411a.h diff --git a/core/embed/trezorhal/stm32u5/xdisplay/st7785ma/display_driver.c b/core/embed/io/display/st7785ma/display_driver.c similarity index 96% rename from core/embed/trezorhal/stm32u5/xdisplay/st7785ma/display_driver.c rename to core/embed/io/display/st7785ma/display_driver.c index 58d65e3f7e..32d6059c58 100644 --- a/core/embed/trezorhal/stm32u5/xdisplay/st7785ma/display_driver.c +++ b/core/embed/io/display/st7785ma/display_driver.c @@ -3,7 +3,7 @@ #include #include -#include "display.h" +#include #ifdef KERNEL_MODE void display_init(display_content_mode_t mode) {} diff --git a/core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/display_driver.c b/core/embed/io/display/stm32f429i-disc1/display_driver.c similarity index 99% rename from core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/display_driver.c rename to core/embed/io/display/stm32f429i-disc1/display_driver.c index 1a683e3603..24b4c1c045 100644 --- a/core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/display_driver.c +++ b/core/embed/io/display/stm32f429i-disc1/display_driver.c @@ -23,10 +23,11 @@ #ifdef KERNEL_MODE -#include "display.h" +#include +#include + #include "display_internal.h" #include "ili9341_spi.h" -#include "mpu.h" #if (DISPLAY_RESX != 240) || (DISPLAY_RESY != 320) #error "Incompatible display resolution" diff --git a/core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/display_internal.h b/core/embed/io/display/stm32f429i-disc1/display_internal.h similarity index 98% rename from core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/display_internal.h rename to core/embed/io/display/stm32f429i-disc1/display_internal.h index 17371892de..fbb15a1bad 100644 --- a/core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/display_internal.h +++ b/core/embed/io/display/stm32f429i-disc1/display_internal.h @@ -23,7 +23,7 @@ #include #include -#include "sdram.h" +#include // Frame buffer address in external SDRAM #define FRAME_BUFFER_ADDR ((uint32_t)SDRAM_DEVICE_ADDR) diff --git a/core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/display_ltdc.c b/core/embed/io/display/stm32f429i-disc1/display_ltdc.c similarity index 99% rename from core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/display_ltdc.c rename to core/embed/io/display/stm32f429i-disc1/display_ltdc.c index d0183de111..ed83a5e120 100644 --- a/core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/display_ltdc.c +++ b/core/embed/io/display/stm32f429i-disc1/display_ltdc.c @@ -21,7 +21,7 @@ #include #include -#include "display.h" +#include #include "display_internal.h" #include "ili9341_spi.h" diff --git a/core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/ili9341_spi.c b/core/embed/io/display/stm32f429i-disc1/ili9341_spi.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/ili9341_spi.c rename to core/embed/io/display/stm32f429i-disc1/ili9341_spi.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/ili9341_spi.h b/core/embed/io/display/stm32f429i-disc1/ili9341_spi.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/ili9341_spi.h rename to core/embed/io/display/stm32f429i-disc1/ili9341_spi.h diff --git a/core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_driver.c b/core/embed/io/display/stm32u5a9j-dk/display_driver.c similarity index 99% rename from core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_driver.c rename to core/embed/io/display/stm32u5a9j-dk/display_driver.c index 559db2db5e..928a9d657f 100644 --- a/core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_driver.c +++ b/core/embed/io/display/stm32u5a9j-dk/display_driver.c @@ -21,9 +21,10 @@ #include #include -#include "display.h" +#include +#include + #include "display_internal.h" -#include "mpu.h" #if (DISPLAY_RESX != 240) || (DISPLAY_RESY != 240) #error "Incompatible display resolution" diff --git a/core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_fb.c b/core/embed/io/display/stm32u5a9j-dk/display_fb.c similarity index 97% rename from core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_fb.c rename to core/embed/io/display/stm32u5a9j-dk/display_fb.c index f24e2baf99..ea22813e0f 100644 --- a/core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_fb.c +++ b/core/embed/io/display/stm32u5a9j-dk/display_fb.c @@ -21,10 +21,14 @@ #include #include -#include "display.h" +#include +#include + #include "display_internal.h" -#include "mpu.h" -#include "trustzone.h" + +#ifdef USE_TRUSTZONE +#include +#endif #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_gfxmmu_lut.h b/core/embed/io/display/stm32u5a9j-dk/display_gfxmmu_lut.h similarity index 100% rename from core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_gfxmmu_lut.h rename to core/embed/io/display/stm32u5a9j-dk/display_gfxmmu_lut.h diff --git a/core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_internal.h b/core/embed/io/display/stm32u5a9j-dk/display_internal.h similarity index 97% rename from core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_internal.h rename to core/embed/io/display/stm32u5a9j-dk/display_internal.h index 0a0c24ebe1..f800cd7cd0 100644 --- a/core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_internal.h +++ b/core/embed/io/display/stm32u5a9j-dk/display_internal.h @@ -22,8 +22,11 @@ #include -#include "sizedefs.h" -#include "trustzone.h" +#include + +#ifdef USE_TRUSTZONE +#include +#endif // Display driver context. typedef struct { diff --git a/core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_ltdc_dsi.c b/core/embed/io/display/stm32u5a9j-dk/display_ltdc_dsi.c similarity index 99% rename from core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_ltdc_dsi.c rename to core/embed/io/display/stm32u5a9j-dk/display_ltdc_dsi.c index f2c98ae102..abb765ba0d 100644 --- a/core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_ltdc_dsi.c +++ b/core/embed/io/display/stm32u5a9j-dk/display_ltdc_dsi.c @@ -61,8 +61,8 @@ #include #include +#include #include "display_internal.h" -#include "irq.h" #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/unix/display_driver.c b/core/embed/io/display/unix/display_driver.c similarity index 99% rename from core/embed/trezorhal/unix/display_driver.c rename to core/embed/io/display/unix/display_driver.c index bd0e1cc447..bdb25c787d 100644 --- a/core/embed/trezorhal/unix/display_driver.c +++ b/core/embed/io/display/unix/display_driver.c @@ -23,7 +23,7 @@ #include #include -#include "display.h" +#include #include #include diff --git a/core/embed/trezorhal/stm32f4/xdisplay/vg-2864/display_driver.c b/core/embed/io/display/vg-2864/display_driver.c similarity index 98% rename from core/embed/trezorhal/stm32f4/xdisplay/vg-2864/display_driver.c rename to core/embed/io/display/vg-2864/display_driver.c index b1f18468e6..d6db5d42a4 100644 --- a/core/embed/trezorhal/stm32f4/xdisplay/vg-2864/display_driver.c +++ b/core/embed/io/display/vg-2864/display_driver.c @@ -21,13 +21,16 @@ #include #include -#include "display.h" -#include "mpu.h" -#include "sizedefs.h" -#include "trustzone.h" +#include +#include +#include + +#ifdef USE_TRUSTZONE +#include +#endif #ifdef USE_CONSUMPTION_MASK -#include "consumption_mask.h" +#include #endif #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/stm32u5/haptic/drv2625/actuators/vg1040003d.h b/core/embed/io/haptic/drv2625/actuators/vg1040003d.h similarity index 100% rename from core/embed/trezorhal/stm32u5/haptic/drv2625/actuators/vg1040003d.h rename to core/embed/io/haptic/drv2625/actuators/vg1040003d.h diff --git a/core/embed/trezorhal/stm32u5/haptic/drv2625/drv2625.c b/core/embed/io/haptic/drv2625/drv2625.c similarity index 99% rename from core/embed/trezorhal/stm32u5/haptic/drv2625/drv2625.c rename to core/embed/io/haptic/drv2625/drv2625.c index 48729e6941..772849cdbf 100644 --- a/core/embed/trezorhal/stm32u5/haptic/drv2625/drv2625.c +++ b/core/embed/io/haptic/drv2625/drv2625.c @@ -20,9 +20,10 @@ #include #include +#include +#include + #include "drv2625.h" -#include "haptic.h" -#include "i2c_bus.h" #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/stm32u5/haptic/drv2625/drv2625.h b/core/embed/io/haptic/drv2625/drv2625.h similarity index 100% rename from core/embed/trezorhal/stm32u5/haptic/drv2625/drv2625.h rename to core/embed/io/haptic/drv2625/drv2625.h diff --git a/core/embed/trezorhal/haptic.h b/core/embed/io/haptic/inc/io/haptic.h similarity index 100% rename from core/embed/trezorhal/haptic.h rename to core/embed/io/haptic/inc/io/haptic.h diff --git a/core/embed/trezorhal/i2c_bus.h b/core/embed/io/i2c_bus/inc/io/i2c_bus.h similarity index 100% rename from core/embed/trezorhal/i2c_bus.h rename to core/embed/io/i2c_bus/inc/io/i2c_bus.h diff --git a/core/embed/trezorhal/stm32f4/i2c_bus.c b/core/embed/io/i2c_bus/stm32f4/i2c_bus.c similarity index 98% rename from core/embed/trezorhal/stm32f4/i2c_bus.c rename to core/embed/io/i2c_bus/stm32f4/i2c_bus.c index dc9136cce7..5ce6d58417 100644 --- a/core/embed/trezorhal/stm32f4/i2c_bus.c +++ b/core/embed/io/i2c_bus/stm32f4/i2c_bus.c @@ -20,12 +20,12 @@ #include #include -#include "i2c_bus.h" -#include "irq.h" -#include "mpu.h" -#include "systemview.h" -#include "systick.h" -#include "systimer.h" +#include + +#include +#include +#include +#include #ifdef KERNEL_MODE @@ -909,55 +909,55 @@ static void i2c_bus_er_handler(i2c_bus_t* bus) { #ifdef I2C_INSTANCE_0 void I2C_INSTANCE_0_EV_IRQHandler(void) { - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); i2c_bus_ev_handler(&g_i2c_bus_driver[0]); mpu_restore(mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + IRQ_LOG_EXIT(); } void I2C_INSTANCE_0_ER_IRQHandler(void) { - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); i2c_bus_er_handler(&g_i2c_bus_driver[0]); mpu_restore(mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + IRQ_LOG_EXIT(); } #endif #ifdef I2C_INSTANCE_1 void I2C_INSTANCE_1_EV_IRQHandler(void) { - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); i2c_bus_ev_handler(&g_i2c_bus_driver[1]); mpu_restore(mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + IRQ_LOG_EXIT(); } void I2C_INSTANCE_1_ER_IRQHandler(void) { - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); i2c_bus_er_handler(&g_i2c_bus_driver[1]); mpu_restore(mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + IRQ_LOG_EXIT(); } #endif #ifdef I2C_INSTANCE_2 void I2C_INSTANCE_2_EV_IRQHandler(void) { - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); i2c_bus_ev_handler(&g_i2c_bus_driver[2]); mpu_restore(mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + IRQ_LOG_EXIT(); } void I2C_INSTANCE_2_ER_IRQHandler(void) { - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); i2c_bus_er_handler(&g_i2c_bus_driver[2]); mpu_restore(mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + IRQ_LOG_EXIT(); } #endif diff --git a/core/embed/trezorhal/stm32u5/i2c_bus.c b/core/embed/io/i2c_bus/stm32u5/i2c_bus.c similarity index 97% rename from core/embed/trezorhal/stm32u5/i2c_bus.c rename to core/embed/io/i2c_bus/stm32u5/i2c_bus.c index 3f1e756200..153b4a8fc8 100644 --- a/core/embed/trezorhal/stm32u5/i2c_bus.c +++ b/core/embed/io/i2c_bus/stm32u5/i2c_bus.c @@ -20,12 +20,11 @@ #include #include -#include "i2c_bus.h" -#include "irq.h" -#include "mpu.h" -#include "systemview.h" -#include "systick.h" -#include "systimer.h" +#include +#include +#include +#include +#include #ifdef KERNEL_MODE @@ -890,73 +889,73 @@ static void i2c_bus_er_handler(i2c_bus_t* bus) { #ifdef I2C_INSTANCE_0 void I2C_INSTANCE_0_EV_IRQHandler(void) { - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); i2c_bus_ev_handler(&g_i2c_bus_driver[0]); mpu_restore(mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + IRQ_LOG_EXIT(); } void I2C_INSTANCE_0_ER_IRQHandler(void) { - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); i2c_bus_er_handler(&g_i2c_bus_driver[0]); mpu_restore(mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + IRQ_LOG_EXIT(); } #endif #ifdef I2C_INSTANCE_1 void I2C_INSTANCE_1_EV_IRQHandler(void) { - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); i2c_bus_ev_handler(&g_i2c_bus_driver[1]); mpu_restore(mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + IRQ_LOG_EXIT(); } void I2C_INSTANCE_1_ER_IRQHandler(void) { - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); i2c_bus_er_handler(&g_i2c_bus_driver[1]); mpu_restore(mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + IRQ_LOG_EXIT(); } #endif #ifdef I2C_INSTANCE_2 void I2C_INSTANCE_2_EV_IRQHandler(void) { - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); i2c_bus_ev_handler(&g_i2c_bus_driver[2]); mpu_restore(mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + IRQ_LOG_EXIT(); } void I2C_INSTANCE_2_ER_IRQHandler(void) { - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); i2c_bus_er_handler(&g_i2c_bus_driver[2]); mpu_restore(mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + IRQ_LOG_EXIT(); } #endif #ifdef I2C_INSTANCE_3 void I2C_INSTANCE_3_EV_IRQHandler(void) { - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); i2c_bus_ev_handler(&g_i2c_bus_driver[3]); mpu_restore(mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + IRQ_LOG_EXIT(); } void I2C_INSTANCE_3_ER_IRQHandler(void) { - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); i2c_bus_er_handler(&g_i2c_bus_driver[3]); mpu_restore(mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + IRQ_LOG_EXIT(); } #endif diff --git a/core/embed/trezorhal/rgb_led.h b/core/embed/io/rgb_led/inc/io/rgb_led.h similarity index 100% rename from core/embed/trezorhal/rgb_led.h rename to core/embed/io/rgb_led/inc/io/rgb_led.h diff --git a/core/embed/trezorhal/stm32f4/rgb_led.c b/core/embed/io/rgb_led/stm32f4/rgb_led.c similarity index 100% rename from core/embed/trezorhal/stm32f4/rgb_led.c rename to core/embed/io/rgb_led/stm32f4/rgb_led.c diff --git a/core/embed/trezorhal/sbu.h b/core/embed/io/sbu/inc/io/sbu.h similarity index 100% rename from core/embed/trezorhal/sbu.h rename to core/embed/io/sbu/inc/io/sbu.h diff --git a/core/embed/trezorhal/stm32f4/sbu.c b/core/embed/io/sbu/stm32/sbu.c similarity index 98% rename from core/embed/trezorhal/stm32f4/sbu.c rename to core/embed/io/sbu/stm32/sbu.c index 0ef93273b8..3c22f3a455 100644 --- a/core/embed/trezorhal/stm32f4/sbu.c +++ b/core/embed/io/sbu/stm32/sbu.c @@ -19,7 +19,7 @@ #include -#include "sbu.h" +#include #if KERNEL_MODE diff --git a/core/embed/trezorhal/unix/sbu.c b/core/embed/io/sbu/unix/sbu.c similarity index 97% rename from core/embed/trezorhal/unix/sbu.c rename to core/embed/io/sbu/unix/sbu.c index b1e48662cc..06b1bbfa34 100644 --- a/core/embed/trezorhal/unix/sbu.c +++ b/core/embed/io/sbu/unix/sbu.c @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include "sbu.h" +#include void sbu_init(void) {} diff --git a/core/embed/trezorhal/sdcard.h b/core/embed/io/sdcard/inc/io/sdcard.h similarity index 100% rename from core/embed/trezorhal/sdcard.h rename to core/embed/io/sdcard/inc/io/sdcard.h diff --git a/core/embed/trezorhal/stm32f4/sdcard-set_clr_card_detect.h b/core/embed/io/sdcard/stm32f4/sdcard-set_clr_card_detect.h similarity index 100% rename from core/embed/trezorhal/stm32f4/sdcard-set_clr_card_detect.h rename to core/embed/io/sdcard/stm32f4/sdcard-set_clr_card_detect.h diff --git a/core/embed/trezorhal/stm32f4/sdcard.c b/core/embed/io/sdcard/stm32f4/sdcard.c similarity index 98% rename from core/embed/trezorhal/stm32f4/sdcard.c rename to core/embed/io/sdcard/stm32f4/sdcard.c index 02e01acd4f..9b5d813ca7 100644 --- a/core/embed/trezorhal/stm32f4/sdcard.c +++ b/core/embed/io/sdcard/stm32f4/sdcard.c @@ -46,10 +46,10 @@ #include #include -#include "irq.h" -#include "mpu.h" +#include +#include +#include #include "sdcard-set_clr_card_detect.h" -#include "sdcard.h" #ifdef KERNEL_MODE @@ -61,11 +61,11 @@ static SD_HandleTypeDef sd_handle = {0}; static DMA_HandleTypeDef sd_dma = {0}; void DMA2_Stream3_IRQHandler(void) { - IRQ_ENTER(DMA2_Stream3_IRQn); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); HAL_DMA_IRQHandler(&sd_dma); mpu_restore(mpu_mode); - IRQ_EXIT(DMA2_Stream3_IRQn); + IRQ_LOG_EXIT(); } static inline void sdcard_default_pin_state(void) { @@ -231,13 +231,13 @@ uint64_t sdcard_get_capacity_in_bytes(void) { } void SDIO_IRQHandler(void) { - IRQ_ENTER(SDIO_IRQn); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); if (sd_handle.Instance) { HAL_SD_IRQHandler(&sd_handle); } mpu_restore(mpu_mode); - IRQ_EXIT(SDIO_IRQn); + IRQ_LOG_EXIT(); } static void sdcard_reset_periph(void) { diff --git a/core/embed/trezorhal/stm32u5/sdcard.c b/core/embed/io/sdcard/stm32u5/sdcard.c similarity index 99% rename from core/embed/trezorhal/stm32u5/sdcard.c rename to core/embed/io/sdcard/stm32u5/sdcard.c index d022441d86..0ca199e26b 100644 --- a/core/embed/trezorhal/stm32u5/sdcard.c +++ b/core/embed/io/sdcard/stm32u5/sdcard.c @@ -46,9 +46,9 @@ #include #include -#include "irq.h" -#include "mpu.h" -#include "sdcard.h" +#include +#include +#include #define SDMMC_CLK_ENABLE() __HAL_RCC_SDMMC1_CLK_ENABLE() #define SDMMC_CLK_DISABLE() __HAL_RCC_SDMMC1_CLK_DISABLE() @@ -234,13 +234,13 @@ uint64_t sdcard_get_capacity_in_bytes(void) { } void SDMMC1_IRQHandler(void) { - IRQ_ENTER(SDIO_IRQn); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); if (sd_handle.Instance) { HAL_SD_IRQHandler(&sd_handle); } mpu_restore(mpu_mode); - IRQ_EXIT(SDIO_IRQn); + IRQ_LOG_EXIT(); } static void sdcard_reset_periph(void) { diff --git a/core/embed/trezorhal/unix/sdcard.c b/core/embed/io/sdcard/unix/sdcard.c similarity index 99% rename from core/embed/trezorhal/unix/sdcard.c rename to core/embed/io/sdcard/unix/sdcard.c index a357f84102..4f16049313 100644 --- a/core/embed/trezorhal/unix/sdcard.c +++ b/core/embed/io/sdcard/unix/sdcard.c @@ -26,8 +26,8 @@ #include #include +#include #include "profile.h" -#include "sdcard.h" #ifndef SDCARD_FILE #define SDCARD_FILE profile_sdcard_path() diff --git a/core/embed/trezorhal/stm32f4/touch/ft6x36.c b/core/embed/io/touch/ft6x36/ft6x36.c similarity index 99% rename from core/embed/trezorhal/stm32f4/touch/ft6x36.c rename to core/embed/io/touch/ft6x36/ft6x36.c index 3953b3bda6..a6d1c6afec 100644 --- a/core/embed/trezorhal/stm32f4/touch/ft6x36.c +++ b/core/embed/io/touch/ft6x36/ft6x36.c @@ -22,10 +22,10 @@ #ifdef KERNEL_MODE +#include +#include +#include #include "ft6x36.h" -#include "i2c_bus.h" -#include "systick.h" -#include "touch.h" #ifdef TOUCH_PANEL_LX154A2422CPT23 #include "panels/lx154a2422cpt23.h" diff --git a/core/embed/trezorhal/stm32f4/touch/ft6x36.h b/core/embed/io/touch/ft6x36/ft6x36.h similarity index 100% rename from core/embed/trezorhal/stm32f4/touch/ft6x36.h rename to core/embed/io/touch/ft6x36/ft6x36.h diff --git a/core/embed/trezorhal/stm32f4/touch/panels/lhs200kb-if21.c b/core/embed/io/touch/ft6x36/panels/lhs200kb-if21.c similarity index 97% rename from core/embed/trezorhal/stm32f4/touch/panels/lhs200kb-if21.c rename to core/embed/io/touch/ft6x36/panels/lhs200kb-if21.c index 73553e050d..125e08998a 100644 --- a/core/embed/trezorhal/stm32f4/touch/panels/lhs200kb-if21.c +++ b/core/embed/io/touch/ft6x36/panels/lhs200kb-if21.c @@ -22,8 +22,8 @@ #include #include +#include #include "lx154a2422cpt23.h" -#include "touch.h" void lhs200kb_if21_touch_correction(uint16_t x, uint16_t y, uint16_t *x_new, uint16_t *y_new) { diff --git a/core/embed/trezorhal/stm32f4/touch/panels/lhs200kb-if21.h b/core/embed/io/touch/ft6x36/panels/lhs200kb-if21.h similarity index 100% rename from core/embed/trezorhal/stm32f4/touch/panels/lhs200kb-if21.h rename to core/embed/io/touch/ft6x36/panels/lhs200kb-if21.h diff --git a/core/embed/trezorhal/stm32f4/touch/panels/lx154a2422cpt23.c b/core/embed/io/touch/ft6x36/panels/lx154a2422cpt23.c similarity index 98% rename from core/embed/trezorhal/stm32f4/touch/panels/lx154a2422cpt23.c rename to core/embed/io/touch/ft6x36/panels/lx154a2422cpt23.c index 92bb1c8818..9417374803 100644 --- a/core/embed/trezorhal/stm32f4/touch/panels/lx154a2422cpt23.c +++ b/core/embed/io/touch/ft6x36/panels/lx154a2422cpt23.c @@ -21,8 +21,8 @@ #include #include +#include #include "lx154a2422cpt23.h" -#include "touch.h" void lx154a2422cpt23_touch_correction(uint16_t x, uint16_t y, uint16_t *x_new, uint16_t *y_new) { diff --git a/core/embed/trezorhal/stm32f4/touch/panels/lx154a2422cpt23.h b/core/embed/io/touch/ft6x36/panels/lx154a2422cpt23.h similarity index 100% rename from core/embed/trezorhal/stm32f4/touch/panels/lx154a2422cpt23.h rename to core/embed/io/touch/ft6x36/panels/lx154a2422cpt23.h diff --git a/core/embed/trezorhal/touch.h b/core/embed/io/touch/inc/io/touch.h similarity index 100% rename from core/embed/trezorhal/touch.h rename to core/embed/io/touch/inc/io/touch.h diff --git a/core/embed/trezorhal/stm32u5/touch/sitronix.c b/core/embed/io/touch/sitronix/sitronix.c similarity index 99% rename from core/embed/trezorhal/stm32u5/touch/sitronix.c rename to core/embed/io/touch/sitronix/sitronix.c index 03fdec7a8d..dbda4fb393 100644 --- a/core/embed/trezorhal/stm32u5/touch/sitronix.c +++ b/core/embed/io/touch/sitronix/sitronix.c @@ -3,8 +3,8 @@ #ifdef KERNEL_MODE -#include "i2c_bus.h" -#include "irq.h" +#include +#include /** @addtogroup STM32U5x9J_DISCOVERY * @{ @@ -1208,7 +1208,7 @@ static int32_t SITRONIX_Probe(uint32_t Instance) { #include -#include "touch.h" +#include // Touch driver typedef struct { diff --git a/core/embed/trezorhal/stm32f4/touch/stmpe811.c b/core/embed/io/touch/stmpe811/stmpe811.c similarity index 99% rename from core/embed/trezorhal/stm32f4/touch/stmpe811.c rename to core/embed/io/touch/stmpe811/stmpe811.c index 8e882214b3..6f92f3be45 100644 --- a/core/embed/trezorhal/stm32f4/touch/stmpe811.c +++ b/core/embed/io/touch/stmpe811/stmpe811.c @@ -22,9 +22,9 @@ #ifdef KERNEL_MODE -#include "i2c_bus.h" +#include +#include #include "stmpe811.h" -#include "touch.h" /* Chip IDs */ #define STMPE811_ID 0x0811 diff --git a/core/embed/trezorhal/stm32f4/touch/stmpe811.h b/core/embed/io/touch/stmpe811/stmpe811.h similarity index 100% rename from core/embed/trezorhal/stm32f4/touch/stmpe811.h rename to core/embed/io/touch/stmpe811/stmpe811.h diff --git a/core/embed/trezorhal/unix/touch.c b/core/embed/io/touch/unix/touch.c similarity index 99% rename from core/embed/trezorhal/unix/touch.c rename to core/embed/io/touch/unix/touch.c index f9008540ca..8391823a14 100644 --- a/core/embed/trezorhal/unix/touch.c +++ b/core/embed/io/touch/unix/touch.c @@ -22,7 +22,7 @@ #include -#include "touch.h" +#include extern int sdl_display_res_x, sdl_display_res_y; extern int sdl_touch_offset_x, sdl_touch_offset_y; diff --git a/core/embed/trezorhal/usb.h b/core/embed/io/usb/inc/io/usb.h similarity index 98% rename from core/embed/trezorhal/usb.h rename to core/embed/io/usb/inc/io/usb.h index d1967a2a01..a039719dc4 100644 --- a/core/embed/trezorhal/usb.h +++ b/core/embed/io/usb/inc/io/usb.h @@ -22,9 +22,9 @@ #include -#include "usb_hid.h" -#include "usb_vcp.h" -#include "usb_webusb.h" +#include +#include +#include // clang-format off // diff --git a/core/embed/trezorhal/usb_hid.h b/core/embed/io/usb/inc/io/usb_hid.h similarity index 100% rename from core/embed/trezorhal/usb_hid.h rename to core/embed/io/usb/inc/io/usb_hid.h diff --git a/core/embed/trezorhal/usb_vcp.h b/core/embed/io/usb/inc/io/usb_vcp.h similarity index 100% rename from core/embed/trezorhal/usb_vcp.h rename to core/embed/io/usb/inc/io/usb_vcp.h diff --git a/core/embed/trezorhal/usb_webusb.h b/core/embed/io/usb/inc/io/usb_webusb.h similarity index 100% rename from core/embed/trezorhal/usb_webusb.h rename to core/embed/io/usb/inc/io/usb_webusb.h diff --git a/core/embed/trezorhal/stm32f4/usb/usb.c b/core/embed/io/usb/stm32/usb.c similarity index 99% rename from core/embed/trezorhal/stm32f4/usb/usb.c rename to core/embed/io/usb/stm32/usb.c index 93dd689b18..737367f40a 100644 --- a/core/embed/trezorhal/stm32f4/usb/usb.c +++ b/core/embed/io/usb/stm32/usb.c @@ -22,9 +22,10 @@ #include #include -#include "random_delays.h" -#include "systick.h" -#include "usb.h" +#include +#include +#include + #include "usb_internal.h" #define USB_MAX_CONFIG_DESC_SIZE 256 diff --git a/core/embed/trezorhal/stm32f4/usb/usb_class_hid.c b/core/embed/io/usb/stm32/usb_class_hid.c similarity index 99% rename from core/embed/trezorhal/stm32f4/usb/usb_class_hid.c rename to core/embed/io/usb/stm32/usb_class_hid.c index 5cee8a829b..999045529c 100644 --- a/core/embed/trezorhal/stm32f4/usb/usb_class_hid.c +++ b/core/embed/io/usb/stm32/usb_class_hid.c @@ -21,8 +21,9 @@ #include -#include "random_delays.h" -#include "usb_hid.h" +#include +#include + #include "usb_internal.h" #define USB_CLASS_HID 0x03 diff --git a/core/embed/trezorhal/stm32f4/usb/usb_class_vcp.c b/core/embed/io/usb/stm32/usb_class_vcp.c similarity index 99% rename from core/embed/trezorhal/stm32f4/usb/usb_class_vcp.c rename to core/embed/io/usb/stm32/usb_class_vcp.c index 713e0c672a..7e2be20ecd 100644 --- a/core/embed/trezorhal/stm32f4/usb/usb_class_vcp.c +++ b/core/embed/io/usb/stm32/usb_class_vcp.c @@ -21,8 +21,9 @@ #include +#include + #include "usb_internal.h" -#include "usb_vcp.h" // Communications Device Class Code (bFunctionClass, bInterfaceClass) #define USB_CLASS_CDC 0x02 diff --git a/core/embed/trezorhal/stm32f4/usb/usb_class_webusb.c b/core/embed/io/usb/stm32/usb_class_webusb.c similarity index 99% rename from core/embed/trezorhal/stm32f4/usb/usb_class_webusb.c rename to core/embed/io/usb/stm32/usb_class_webusb.c index ce2d5e0730..4395e23ddb 100644 --- a/core/embed/trezorhal/stm32f4/usb/usb_class_webusb.c +++ b/core/embed/io/usb/stm32/usb_class_webusb.c @@ -21,9 +21,10 @@ #include -#include "random_delays.h" +#include +#include + #include "usb_internal.h" -#include "usb_webusb.h" #define USB_CLASS_WEBUSB 0xFF diff --git a/core/embed/trezorhal/stm32f4/usb/usb_internal.h b/core/embed/io/usb/stm32/usb_internal.h similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usb_internal.h rename to core/embed/io/usb/stm32/usb_internal.h diff --git a/core/embed/trezorhal/stm32f4/usb/usbd_conf.c b/core/embed/io/usb/stm32/usbd_conf.c similarity index 98% rename from core/embed/trezorhal/stm32f4/usb/usbd_conf.c rename to core/embed/io/usb/stm32/usbd_conf.c index 5de7e078b8..1313eeb952 100644 --- a/core/embed/trezorhal/stm32f4/usb/usbd_conf.c +++ b/core/embed/io/usb/stm32/usbd_conf.c @@ -57,11 +57,11 @@ #include #include +#include +#include +#include + #include "usbd_core.h" -#include "usb.h" -#include "irq.h" -#include "mpu.h" -#include "systemview.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ @@ -800,28 +800,24 @@ void OTG_HS_IRQHandler(void) { #else void OTG_FS_IRQHandler(void) { #endif - SEGGER_SYSVIEW_RecordEnterISR(); - IRQ_ENTER(OTG_FS_IRQn); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); if (pcd_fs_handle.Instance) { HAL_PCD_IRQHandler(&pcd_fs_handle); } mpu_restore(mpu_mode); - IRQ_EXIT(OTG_FS_IRQn); - SEGGER_SYSVIEW_RecordExitISR(); + IRQ_LOG_EXIT(); } #endif #if defined(USE_USB_HS) void OTG_HS_IRQHandler(void) { - SEGGER_SYSVIEW_RecordEnterISR(); - IRQ_ENTER(OTG_HS_IRQn); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); if (pcd_hs_handle.Instance) { HAL_PCD_IRQHandler(&pcd_hs_handle); } mpu_restore(mpu_mode); - IRQ_EXIT(OTG_HS_IRQn); - SEGGER_SYSVIEW_RecordExitISR(); + IRQ_LOG_EXIT(); } #endif @@ -871,7 +867,7 @@ static void OTG_CMD_WKUP_Handler(PCD_HandleTypeDef *pcd_handle) { */ #if defined(USE_USB_FS) void OTG_FS_WKUP_IRQHandler(void) { - IRQ_ENTER(OTG_FS_WKUP_IRQn); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); if (pcd_fs_handle.Instance) { OTG_CMD_WKUP_Handler(&pcd_fs_handle); @@ -879,12 +875,12 @@ void OTG_FS_WKUP_IRQHandler(void) { /* Clear EXTI pending Bit*/ __HAL_USB_OTG_FS_WAKEUP_EXTI_CLEAR_FLAG(); mpu_restore(mpu_mode); - IRQ_EXIT(OTG_FS_WKUP_IRQn); + IRQ_LOG_EXIT(); } #endif #if defined(USE_USB_HS) void OTG_HS_WKUP_IRQHandler(void) { - IRQ_ENTER(OTG_HS_WKUP_IRQn); + IRQ_LOG_ENTER(); mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); if (pcd_hs_handle.Instance) { OTG_CMD_WKUP_Handler(&pcd_hs_handle); @@ -892,7 +888,7 @@ void OTG_HS_WKUP_IRQHandler(void) { /* Clear EXTI pending Bit*/ __HAL_USB_HS_EXTI_CLEAR_FLAG(); mpu_restore(mpu_mode); - IRQ_EXIT(OTG_HS_WKUP_IRQn); + IRQ_LOG_EXIT(); } #endif #endif diff --git a/core/embed/trezorhal/stm32f4/usb/usbd_conf.h b/core/embed/io/usb/stm32/usbd_conf.h similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usbd_conf.h rename to core/embed/io/usb/stm32/usbd_conf.h diff --git a/core/embed/trezorhal/stm32f4/usb/usbd_core.c b/core/embed/io/usb/stm32/usbd_core.c similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usbd_core.c rename to core/embed/io/usb/stm32/usbd_core.c diff --git a/core/embed/trezorhal/stm32f4/usb/usbd_core.h b/core/embed/io/usb/stm32/usbd_core.h similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usbd_core.h rename to core/embed/io/usb/stm32/usbd_core.h diff --git a/core/embed/trezorhal/stm32f4/usb/usbd_ctlreq.c b/core/embed/io/usb/stm32/usbd_ctlreq.c similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usbd_ctlreq.c rename to core/embed/io/usb/stm32/usbd_ctlreq.c diff --git a/core/embed/trezorhal/stm32f4/usb/usbd_ctlreq.h b/core/embed/io/usb/stm32/usbd_ctlreq.h similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usbd_ctlreq.h rename to core/embed/io/usb/stm32/usbd_ctlreq.h diff --git a/core/embed/trezorhal/stm32f4/usb/usbd_def.h b/core/embed/io/usb/stm32/usbd_def.h similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usbd_def.h rename to core/embed/io/usb/stm32/usbd_def.h diff --git a/core/embed/trezorhal/stm32f4/usb/usbd_ioreq.c b/core/embed/io/usb/stm32/usbd_ioreq.c similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usbd_ioreq.c rename to core/embed/io/usb/stm32/usbd_ioreq.c diff --git a/core/embed/trezorhal/stm32f4/usb/usbd_ioreq.h b/core/embed/io/usb/stm32/usbd_ioreq.h similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usbd_ioreq.h rename to core/embed/io/usb/stm32/usbd_ioreq.h diff --git a/core/embed/trezorhal/unix/usb.c b/core/embed/io/usb/unix/usb.c similarity index 99% rename from core/embed/trezorhal/unix/usb.c rename to core/embed/io/usb/unix/usb.c index eedf618202..8ab0d1087b 100644 --- a/core/embed/trezorhal/unix/usb.c +++ b/core/embed/io/usb/unix/usb.c @@ -27,8 +27,8 @@ #include #include +#include #include "profile.h" -#include "usb.h" #include "memzero.h" diff --git a/core/embed/models/D002/model_D002.h b/core/embed/models/D002/model_D002.h index 8797c9102c..973c257652 100644 --- a/core/embed/models/D002/model_D002.h +++ b/core/embed/models/D002/model_D002.h @@ -1,8 +1,8 @@ #ifndef MODELS_MODEL_DISC2_H_ #define MODELS_MODEL_DISC2_H_ +#include #include "bootloaders/bootloader_hashes.h" -#include "sizedefs.h" #define MODEL_NAME "D002" #define MODEL_FULL_NAME "Trezor DIY 2" diff --git a/core/embed/models/T3B1/model_T3B1.h b/core/embed/models/T3B1/model_T3B1.h index 2d04f00f1b..ff90decd61 100644 --- a/core/embed/models/T3B1/model_T3B1.h +++ b/core/embed/models/T3B1/model_T3B1.h @@ -3,7 +3,7 @@ #include "bootloaders/bootloader_hashes.h" -#include "sizedefs.h" +#include #define MODEL_NAME "Safe 3" #define MODEL_FULL_NAME "Trezor Safe 3" diff --git a/core/embed/models/T3T1/model_T3T1.h b/core/embed/models/T3T1/model_T3T1.h index a66400a685..2d5d48e5d7 100644 --- a/core/embed/models/T3T1/model_T3T1.h +++ b/core/embed/models/T3T1/model_T3T1.h @@ -3,7 +3,7 @@ #include "bootloaders/bootloader_hashes.h" -#include "sizedefs.h" +#include #define MODEL_NAME "Safe 5" #define MODEL_FULL_NAME "Trezor Safe 5" diff --git a/core/embed/models/T3W1/model_T3W1.h b/core/embed/models/T3W1/model_T3W1.h index 14ce79cb1b..bb919bea3b 100644 --- a/core/embed/models/T3W1/model_T3W1.h +++ b/core/embed/models/T3W1/model_T3W1.h @@ -3,7 +3,7 @@ // #include "bootloaders/bootloader_hashes.h" -#include "sizedefs.h" +#include #define MODEL_NAME "T3W1" #define MODEL_FULL_NAME "Trezor T3W1" diff --git a/core/embed/models/layout_common.h b/core/embed/models/layout_common.h deleted file mode 100644 index 844fcd04aa..0000000000 --- a/core/embed/models/layout_common.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef LAYOUT_COMMON_H -#define LAYOUT_COMMON_H - -#include "flash_area.h" - -// OTP blocks allocation -#define FLASH_OTP_BLOCK_BATCH 0 -#define FLASH_OTP_BLOCK_BOOTLOADER_VERSION 1 -#define FLASH_OTP_BLOCK_VENDOR_HEADER_LOCK 2 -#define FLASH_OTP_BLOCK_RANDOMNESS 3 -#define FLASH_OTP_BLOCK_DEVICE_VARIANT 4 -#define FLASH_OTP_BLOCK_FIRMWARE_VERSION 5 - -#endif diff --git a/core/embed/models/otp_layout.h b/core/embed/models/otp_layout.h new file mode 100644 index 0000000000..401fffc72c --- /dev/null +++ b/core/embed/models/otp_layout.h @@ -0,0 +1,28 @@ +/* + * 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 . + */ + +#pragma once + +// OTP blocks allocation +#define FLASH_OTP_BLOCK_BATCH 0 +#define FLASH_OTP_BLOCK_BOOTLOADER_VERSION 1 +#define FLASH_OTP_BLOCK_VENDOR_HEADER_LOCK 2 +#define FLASH_OTP_BLOCK_RANDOMNESS 3 +#define FLASH_OTP_BLOCK_DEVICE_VARIANT 4 +#define FLASH_OTP_BLOCK_FIRMWARE_VERSION 5 diff --git a/core/embed/models/trezor_model.h b/core/embed/models/trezor_model.h index f178a0bb7c..ac2ea0ea89 100644 --- a/core/embed/models/trezor_model.h +++ b/core/embed/models/trezor_model.h @@ -1,8 +1,8 @@ #ifndef MODELS_MODEL_H_ #define MODELS_MODEL_H_ -#include "layout.h" -#include "layout_common.h" +#include +#include "otp_layout.h" #if defined TREZOR_MODEL_T #include "T2T1/model_T2T1.h" diff --git a/core/embed/prodtest/.towncrier.template.md b/core/embed/prodtest/.towncrier.template.md deleted file mode 120000 index a8bbd1d221..0000000000 --- a/core/embed/prodtest/.towncrier.template.md +++ /dev/null @@ -1 +0,0 @@ -../../../tools/towncrier.template.md \ No newline at end of file diff --git a/core/embed/prodtest/CHANGELOG.unreleased b/core/embed/prodtest/CHANGELOG.unreleased deleted file mode 120000 index 5128a0ac23..0000000000 --- a/core/embed/prodtest/CHANGELOG.unreleased +++ /dev/null @@ -1 +0,0 @@ -../../../tools/generate-changelog-unreleased.sh \ No newline at end of file diff --git a/core/embed/prodtest/towncrier.toml b/core/embed/prodtest/towncrier.toml deleted file mode 120000 index 090013b7d4..0000000000 --- a/core/embed/prodtest/towncrier.toml +++ /dev/null @@ -1 +0,0 @@ -../../../tools/towncrier.toml \ No newline at end of file diff --git a/core/embed/boardloader/.changelog.d/.gitignore b/core/embed/projects/boardloader/.changelog.d/.gitignore similarity index 100% rename from core/embed/boardloader/.changelog.d/.gitignore rename to core/embed/projects/boardloader/.changelog.d/.gitignore diff --git a/core/embed/projects/boardloader/.towncrier.template.md b/core/embed/projects/boardloader/.towncrier.template.md new file mode 120000 index 0000000000..387acb2f4f --- /dev/null +++ b/core/embed/projects/boardloader/.towncrier.template.md @@ -0,0 +1 @@ +../../../../tools/towncrier.template.md \ No newline at end of file diff --git a/core/embed/boardloader/CHANGELOG.md b/core/embed/projects/boardloader/CHANGELOG.md similarity index 100% rename from core/embed/boardloader/CHANGELOG.md rename to core/embed/projects/boardloader/CHANGELOG.md diff --git a/core/embed/projects/boardloader/CHANGELOG.unreleased b/core/embed/projects/boardloader/CHANGELOG.unreleased new file mode 120000 index 0000000000..12f3cc5d59 --- /dev/null +++ b/core/embed/projects/boardloader/CHANGELOG.unreleased @@ -0,0 +1 @@ +../../../../tools/generate-changelog-unreleased.sh \ No newline at end of file diff --git a/core/embed/boardloader/main.c b/core/embed/projects/boardloader/main.c similarity index 92% rename from core/embed/boardloader/main.c rename to core/embed/projects/boardloader/main.c index 4b7e30517b..84b7e3567e 100644 --- a/core/embed/boardloader/main.c +++ b/core/embed/projects/boardloader/main.c @@ -20,43 +20,46 @@ #include #include -#include "board_capabilities.h" -#include "bootutils.h" -#include "compiler_traits.h" -#include "display.h" -#include "flash.h" -#include "flash_utils.h" -#include "gfx_draw.h" -#include "image.h" -#include "mpu.h" -#include "pvd.h" -#include "reset_flags.h" -#include "rng.h" -#include "rsod.h" -#include "secret.h" -#include "system.h" -#include "systick.h" -#include "terminal.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef USE_PVD +#include +#endif #ifdef USE_SD_CARD -#include "sdcard.h" -#endif -#ifdef USE_SDRAM -#include "sdram.h" -#endif -#ifdef USE_HASH_PROCESSOR -#include "hash_processor.h" +#include #endif -#ifdef USE_DMA2D -#include "dma2d_bitblt.h" +#ifdef USE_HASH_PROCESSOR +#include +#endif + +#ifdef USE_TRUSTZONE +#include +#endif + +#ifdef USE_TAMPER +#include #endif #include "memzero.h" -#include "monoctr.h" -#include "option_bytes.h" -#include "tamper.h" -#include "trustzone.h" #include "version.h" const uint8_t BOARDLOADER_KEY_M = 2; @@ -251,17 +254,11 @@ int main(void) { secret_init(); -#ifdef USE_SDRAM - sdram_init(); -#endif - #ifdef USE_HASH_PROCESSOR hash_processor_init(); #endif -#ifdef USE_DMA2D - dma2d_init(); -#endif + gfx_bitblt_init(); display_init(DISPLAY_RESET_CONTENT); diff --git a/core/embed/projects/boardloader/towncrier.toml b/core/embed/projects/boardloader/towncrier.toml new file mode 120000 index 0000000000..09694ad2ae --- /dev/null +++ b/core/embed/projects/boardloader/towncrier.toml @@ -0,0 +1 @@ +../../../../tools/towncrier.toml \ No newline at end of file diff --git a/core/embed/boardloader/version.h b/core/embed/projects/boardloader/version.h similarity index 100% rename from core/embed/boardloader/version.h rename to core/embed/projects/boardloader/version.h diff --git a/core/embed/bootloader/.changelog.d/.gitignore b/core/embed/projects/bootloader/.changelog.d/.gitignore similarity index 100% rename from core/embed/bootloader/.changelog.d/.gitignore rename to core/embed/projects/bootloader/.changelog.d/.gitignore diff --git a/core/embed/projects/bootloader/.towncrier.template.md b/core/embed/projects/bootloader/.towncrier.template.md new file mode 120000 index 0000000000..387acb2f4f --- /dev/null +++ b/core/embed/projects/bootloader/.towncrier.template.md @@ -0,0 +1 @@ +../../../../tools/towncrier.template.md \ No newline at end of file diff --git a/core/embed/bootloader/CHANGELOG.md b/core/embed/projects/bootloader/CHANGELOG.md similarity index 100% rename from core/embed/bootloader/CHANGELOG.md rename to core/embed/projects/bootloader/CHANGELOG.md diff --git a/core/embed/projects/bootloader/CHANGELOG.unreleased b/core/embed/projects/bootloader/CHANGELOG.unreleased new file mode 120000 index 0000000000..12f3cc5d59 --- /dev/null +++ b/core/embed/projects/bootloader/CHANGELOG.unreleased @@ -0,0 +1 @@ +../../../../tools/generate-changelog-unreleased.sh \ No newline at end of file diff --git a/core/embed/bootloader/bootloader_flash.jlink b/core/embed/projects/bootloader/bootloader_flash.jlink similarity index 100% rename from core/embed/bootloader/bootloader_flash.jlink rename to core/embed/projects/bootloader/bootloader_flash.jlink diff --git a/core/embed/bootloader/bootui.c b/core/embed/projects/bootloader/bootui.c similarity index 97% rename from core/embed/bootloader/bootui.c rename to core/embed/projects/bootloader/bootui.c index 0669166e82..3ce2d26f72 100644 --- a/core/embed/bootloader/bootui.c +++ b/core/embed/projects/bootloader/bootui.c @@ -19,11 +19,11 @@ #include +#include +#include +#include +#include #include "bootui.h" -#include "display.h" -#include "display_utils.h" -#include "fonts/fonts.h" -#include "mini_printf.h" #include "rust_ui.h" #include "version.h" @@ -71,7 +71,7 @@ static bool initial_setup = true; void ui_set_initial_setup(bool initial) { initial_setup = initial; } #if defined USE_TOUCH -#include "touch.h" +#include void ui_click(void) { // flush touch events if any @@ -89,7 +89,7 @@ void ui_click(void) { } #elif defined USE_BUTTON -#include "button.h" +#include void ui_click(void) { for (;;) { diff --git a/core/embed/bootloader/bootui.h b/core/embed/projects/bootloader/bootui.h similarity index 99% rename from core/embed/bootloader/bootui.h rename to core/embed/projects/bootloader/bootui.h index a9922154af..b3fc7e082a 100644 --- a/core/embed/bootloader/bootui.h +++ b/core/embed/projects/bootloader/bootui.h @@ -22,7 +22,7 @@ #include -#include "image.h" +#include typedef enum { SCREEN_INTRO = 0, diff --git a/core/embed/bootloader/emulator.c b/core/embed/projects/bootloader/emulator.c similarity index 97% rename from core/embed/bootloader/emulator.c rename to core/embed/projects/bootloader/emulator.c index ac6791182c..b2bd30a452 100644 --- a/core/embed/bootloader/emulator.c +++ b/core/embed/projects/bootloader/emulator.c @@ -5,16 +5,17 @@ #include -#include "bootargs.h" +#include +#include +#include +#include +#include #include "bootui.h" -#include "display.h" -#include "flash.h" -#include "flash_otp.h" #include "rust_ui.h" + #ifdef USE_OPTIGA -#include "secret.h" +#include #endif -#include "systick.h" #include "emulator.h" diff --git a/core/embed/bootloader/emulator.h b/core/embed/projects/bootloader/emulator.h similarity index 100% rename from core/embed/bootloader/emulator.h rename to core/embed/projects/bootloader/emulator.h diff --git a/core/embed/bootloader/header.S b/core/embed/projects/bootloader/header.S similarity index 100% rename from core/embed/bootloader/header.S rename to core/embed/projects/bootloader/header.S diff --git a/core/embed/bootloader/main.c b/core/embed/projects/bootloader/main.c similarity index 96% rename from core/embed/bootloader/main.c rename to core/embed/projects/bootloader/main.c index db3818d016..4cec472812 100644 --- a/core/embed/bootloader/main.c +++ b/core/embed/projects/bootloader/main.c @@ -22,62 +22,59 @@ #include -#include "bootargs.h" -#include "bootutils.h" -#include "display.h" -#include "display_utils.h" -#include "flash.h" -#include "flash_otp.h" -#include "flash_utils.h" -#include "image.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "messages.pb.h" -#include "mpu.h" -#include "option_bytes.h" -#include "pvd.h" -#include "random_delays.h" -#include "rsod.h" -#include "secret.h" -#include "system.h" -#include "systick.h" -#include "systimer.h" -#ifdef USE_DMA2D -#include "dma2d_bitblt.h" +#ifdef USE_PVD +#include #endif #ifdef USE_OPTIGA -#include "optiga_hal.h" +#include #endif #ifdef USE_TOUCH -#include "touch.h" +#include #endif #ifdef USE_BUTTON -#include "button.h" +#include #endif #ifdef USE_CONSUMPTION_MASK -#include "consumption_mask.h" +#include #endif #ifdef USE_RGB_LED -#include "rgb_led.h" +#include #endif #ifdef USE_HASH_PROCESSOR -#include "hash_processor.h" +#include #endif -#include "usb.h" +#include #include "version.h" #include "bootui.h" #include "messages.h" -#include "monoctr.h" #include "rust_ui.h" -#include "unit_properties.h" #include "version_check.h" #ifdef TREZOR_EMULATOR #include "SDL.h" #include "emulator.h" -#else -#include "compiler_traits.h" #endif #define USB_IFACE_NUM 0 @@ -363,11 +360,9 @@ int bootloader_main(void) { hash_processor_init(); #endif - display_init(DISPLAY_JUMP_BEHAVIOR); + gfx_bitblt_init(); -#ifdef USE_DMA2D - dma2d_init(); -#endif + display_init(DISPLAY_JUMP_BEHAVIOR); unit_properties_init(); diff --git a/core/embed/bootloader/messages.c b/core/embed/projects/bootloader/messages.c similarity index 99% rename from core/embed/bootloader/messages.c rename to core/embed/projects/bootloader/messages.c index eeeb50c71b..a7f84fd583 100644 --- a/core/embed/bootloader/messages.c +++ b/core/embed/projects/bootloader/messages.c @@ -25,13 +25,13 @@ #include #include "messages.pb.h" -#include "bootargs.h" -#include "flash.h" -#include "flash_utils.h" -#include "image.h" -#include "secret.h" -#include "unit_properties.h" -#include "usb.h" +#include +#include +#include +#include +#include +#include +#include #include "version.h" #include "bootui.h" @@ -46,7 +46,7 @@ #endif #if USE_OPTIGA -#include "secret.h" +#include #endif #define MSG_HEADER1_LEN 9 diff --git a/core/embed/bootloader/messages.h b/core/embed/projects/bootloader/messages.h similarity index 99% rename from core/embed/bootloader/messages.h rename to core/embed/projects/bootloader/messages.h index c8fcb34c56..5623ff3b5f 100644 --- a/core/embed/bootloader/messages.h +++ b/core/embed/projects/bootloader/messages.h @@ -22,7 +22,7 @@ #include -#include "image.h" +#include #define USB_TIMEOUT 500 #define USB_PACKET_SIZE 64 diff --git a/core/embed/bootloader/protob/.gitignore b/core/embed/projects/bootloader/protob/.gitignore similarity index 100% rename from core/embed/bootloader/protob/.gitignore rename to core/embed/projects/bootloader/protob/.gitignore diff --git a/core/embed/bootloader/protob/Makefile b/core/embed/projects/bootloader/protob/Makefile similarity index 100% rename from core/embed/bootloader/protob/Makefile rename to core/embed/projects/bootloader/protob/Makefile diff --git a/core/embed/bootloader/protob/messages.options b/core/embed/projects/bootloader/protob/messages.options similarity index 100% rename from core/embed/bootloader/protob/messages.options rename to core/embed/projects/bootloader/protob/messages.options diff --git a/core/embed/bootloader/protob/messages.pb.c b/core/embed/projects/bootloader/protob/messages.pb.c similarity index 100% rename from core/embed/bootloader/protob/messages.pb.c rename to core/embed/projects/bootloader/protob/messages.pb.c diff --git a/core/embed/bootloader/protob/messages.pb.h b/core/embed/projects/bootloader/protob/messages.pb.h similarity index 100% rename from core/embed/bootloader/protob/messages.pb.h rename to core/embed/projects/bootloader/protob/messages.pb.h diff --git a/core/embed/bootloader/protob/messages.proto b/core/embed/projects/bootloader/protob/messages.proto similarity index 100% rename from core/embed/bootloader/protob/messages.proto rename to core/embed/projects/bootloader/protob/messages.proto diff --git a/core/embed/projects/bootloader/towncrier.toml b/core/embed/projects/bootloader/towncrier.toml new file mode 120000 index 0000000000..09694ad2ae --- /dev/null +++ b/core/embed/projects/bootloader/towncrier.toml @@ -0,0 +1 @@ +../../../../tools/towncrier.toml \ No newline at end of file diff --git a/core/embed/bootloader/version.h b/core/embed/projects/bootloader/version.h similarity index 100% rename from core/embed/bootloader/version.h rename to core/embed/projects/bootloader/version.h diff --git a/core/embed/bootloader/version_check.c b/core/embed/projects/bootloader/version_check.c similarity index 98% rename from core/embed/bootloader/version_check.c rename to core/embed/projects/bootloader/version_check.c index 0d96c53513..8b7298b424 100644 --- a/core/embed/bootloader/version_check.c +++ b/core/embed/projects/bootloader/version_check.c @@ -19,8 +19,8 @@ #include +#include #include "model_version.h" -#include "monoctr.h" #include "version_check.h" void ensure_bootloader_min_version(void) { diff --git a/core/embed/bootloader/version_check.h b/core/embed/projects/bootloader/version_check.h similarity index 100% rename from core/embed/bootloader/version_check.h rename to core/embed/projects/bootloader/version_check.h diff --git a/core/embed/bootloader_ci/.changelog.d/.gitignore b/core/embed/projects/bootloader_ci/.changelog.d/.gitignore similarity index 100% rename from core/embed/bootloader_ci/.changelog.d/.gitignore rename to core/embed/projects/bootloader_ci/.changelog.d/.gitignore diff --git a/core/embed/bootloader_ci/.changelog.d/1049.added b/core/embed/projects/bootloader_ci/.changelog.d/1049.added similarity index 100% rename from core/embed/bootloader_ci/.changelog.d/1049.added rename to core/embed/projects/bootloader_ci/.changelog.d/1049.added diff --git a/core/embed/bootloader_ci/.changelog.d/1599.changed b/core/embed/projects/bootloader_ci/.changelog.d/1599.changed similarity index 100% rename from core/embed/bootloader_ci/.changelog.d/1599.changed rename to core/embed/projects/bootloader_ci/.changelog.d/1599.changed diff --git a/core/embed/bootloader_ci/.changelog.d/2243.added b/core/embed/projects/bootloader_ci/.changelog.d/2243.added similarity index 100% rename from core/embed/bootloader_ci/.changelog.d/2243.added rename to core/embed/projects/bootloader_ci/.changelog.d/2243.added diff --git a/core/embed/bootloader_ci/.changelog.d/2414.added b/core/embed/projects/bootloader_ci/.changelog.d/2414.added similarity index 100% rename from core/embed/bootloader_ci/.changelog.d/2414.added rename to core/embed/projects/bootloader_ci/.changelog.d/2414.added diff --git a/core/embed/bootloader_ci/.changelog.d/2623.added b/core/embed/projects/bootloader_ci/.changelog.d/2623.added similarity index 100% rename from core/embed/bootloader_ci/.changelog.d/2623.added rename to core/embed/projects/bootloader_ci/.changelog.d/2623.added diff --git a/core/embed/bootloader_ci/.changelog.d/3205.added b/core/embed/projects/bootloader_ci/.changelog.d/3205.added similarity index 100% rename from core/embed/bootloader_ci/.changelog.d/3205.added rename to core/embed/projects/bootloader_ci/.changelog.d/3205.added diff --git a/core/embed/bootloader_ci/.changelog.d/3370.added b/core/embed/projects/bootloader_ci/.changelog.d/3370.added similarity index 100% rename from core/embed/bootloader_ci/.changelog.d/3370.added rename to core/embed/projects/bootloader_ci/.changelog.d/3370.added diff --git a/core/embed/projects/bootloader_ci/.towncrier.template.md b/core/embed/projects/bootloader_ci/.towncrier.template.md new file mode 120000 index 0000000000..387acb2f4f --- /dev/null +++ b/core/embed/projects/bootloader_ci/.towncrier.template.md @@ -0,0 +1 @@ +../../../../tools/towncrier.template.md \ No newline at end of file diff --git a/core/embed/bootloader_ci/CHANGELOG.md b/core/embed/projects/bootloader_ci/CHANGELOG.md similarity index 100% rename from core/embed/bootloader_ci/CHANGELOG.md rename to core/embed/projects/bootloader_ci/CHANGELOG.md diff --git a/core/embed/projects/bootloader_ci/CHANGELOG.unreleased b/core/embed/projects/bootloader_ci/CHANGELOG.unreleased new file mode 120000 index 0000000000..12f3cc5d59 --- /dev/null +++ b/core/embed/projects/bootloader_ci/CHANGELOG.unreleased @@ -0,0 +1 @@ +../../../../tools/generate-changelog-unreleased.sh \ No newline at end of file diff --git a/core/embed/bootloader_ci/README.md b/core/embed/projects/bootloader_ci/README.md similarity index 100% rename from core/embed/bootloader_ci/README.md rename to core/embed/projects/bootloader_ci/README.md diff --git a/core/embed/bootloader_ci/bootloader_flash.jlink b/core/embed/projects/bootloader_ci/bootloader_flash.jlink similarity index 100% rename from core/embed/bootloader_ci/bootloader_flash.jlink rename to core/embed/projects/bootloader_ci/bootloader_flash.jlink diff --git a/core/embed/bootloader_ci/bootui.c b/core/embed/projects/bootloader_ci/bootui.c similarity index 96% rename from core/embed/bootloader_ci/bootui.c rename to core/embed/projects/bootloader_ci/bootui.c index 29bffd49bd..bc58a39dc0 100644 --- a/core/embed/bootloader_ci/bootui.c +++ b/core/embed/projects/bootloader_ci/bootui.c @@ -20,17 +20,17 @@ #include #include +#include +#include +#include +#include +#include #include "bootui.h" -#include "display.h" -#include "display_utils.h" -#include "fonts/fonts.h" -#include "gfx_draw.h" #include "icon_done.h" #include "icon_fail.h" #include "icon_install.h" #include "icon_welcome.h" #include "icon_wipe.h" -#include "mini_printf.h" #define BACKLIGHT_NORMAL 150 diff --git a/core/embed/bootloader_ci/bootui.h b/core/embed/projects/bootloader_ci/bootui.h similarity index 100% rename from core/embed/bootloader_ci/bootui.h rename to core/embed/projects/bootloader_ci/bootui.h diff --git a/core/embed/bootloader_ci/header.S b/core/embed/projects/bootloader_ci/header.S similarity index 100% rename from core/embed/bootloader_ci/header.S rename to core/embed/projects/bootloader_ci/header.S diff --git a/core/embed/bootloader_ci/icon_done.h b/core/embed/projects/bootloader_ci/icon_done.h similarity index 100% rename from core/embed/bootloader_ci/icon_done.h rename to core/embed/projects/bootloader_ci/icon_done.h diff --git a/core/embed/bootloader_ci/icon_fail.h b/core/embed/projects/bootloader_ci/icon_fail.h similarity index 100% rename from core/embed/bootloader_ci/icon_fail.h rename to core/embed/projects/bootloader_ci/icon_fail.h diff --git a/core/embed/bootloader_ci/icon_install.h b/core/embed/projects/bootloader_ci/icon_install.h similarity index 100% rename from core/embed/bootloader_ci/icon_install.h rename to core/embed/projects/bootloader_ci/icon_install.h diff --git a/core/embed/bootloader_ci/icon_welcome.h b/core/embed/projects/bootloader_ci/icon_welcome.h similarity index 100% rename from core/embed/bootloader_ci/icon_welcome.h rename to core/embed/projects/bootloader_ci/icon_welcome.h diff --git a/core/embed/bootloader_ci/icon_wipe.h b/core/embed/projects/bootloader_ci/icon_wipe.h similarity index 100% rename from core/embed/bootloader_ci/icon_wipe.h rename to core/embed/projects/bootloader_ci/icon_wipe.h diff --git a/core/embed/bootloader_ci/main.c b/core/embed/projects/bootloader_ci/main.c similarity index 95% rename from core/embed/bootloader_ci/main.c rename to core/embed/projects/bootloader_ci/main.c index ab720f6173..ca521a7d75 100644 --- a/core/embed/bootloader_ci/main.c +++ b/core/embed/projects/bootloader_ci/main.c @@ -21,23 +21,25 @@ #include #include -#include "bootutils.h" -#include "display.h" -#include "flash.h" -#include "flash_otp.h" -#include "gfx_draw.h" -#include "image.h" -#include "mini_printf.h" -#include "mpu.h" -#include "random_delays.h" -#include "rng.h" -#include "rsod.h" -#include "system.h" -#include "systick.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #ifdef USE_TOUCH -#include "touch.h" +#include #endif -#include "usb.h" + #include "version.h" #include "bootui.h" @@ -45,11 +47,9 @@ #include "version_check.h" #ifdef USE_HASH_PROCESSOR -#include "hash_processor.h" +#include #endif -// #include "mpu.h" - #define USB_IFACE_NUM 0 static void usb_init_all(secbool usb21_landing) { diff --git a/core/embed/bootloader_ci/messages.c b/core/embed/projects/bootloader_ci/messages.c similarity index 99% rename from core/embed/bootloader_ci/messages.c rename to core/embed/projects/bootloader_ci/messages.c index e2b0a81d44..29ed6e9c72 100644 --- a/core/embed/bootloader_ci/messages.c +++ b/core/embed/projects/bootloader_ci/messages.c @@ -25,10 +25,10 @@ #include #include "messages.pb.h" -#include "flash.h" -#include "flash_utils.h" -#include "image.h" -#include "usb.h" +#include +#include +#include +#include #include "version.h" #include "bootui.h" diff --git a/core/embed/bootloader_ci/messages.h b/core/embed/projects/bootloader_ci/messages.h similarity index 99% rename from core/embed/bootloader_ci/messages.h rename to core/embed/projects/bootloader_ci/messages.h index 37656c5866..a4b35c4907 100644 --- a/core/embed/bootloader_ci/messages.h +++ b/core/embed/projects/bootloader_ci/messages.h @@ -22,7 +22,7 @@ #include -#include "image.h" +#include #define USB_TIMEOUT 500 #define USB_PACKET_SIZE 64 diff --git a/core/embed/bootloader_ci/protob b/core/embed/projects/bootloader_ci/protob similarity index 100% rename from core/embed/bootloader_ci/protob rename to core/embed/projects/bootloader_ci/protob diff --git a/core/embed/projects/bootloader_ci/towncrier.toml b/core/embed/projects/bootloader_ci/towncrier.toml new file mode 120000 index 0000000000..09694ad2ae --- /dev/null +++ b/core/embed/projects/bootloader_ci/towncrier.toml @@ -0,0 +1 @@ +../../../../tools/towncrier.toml \ No newline at end of file diff --git a/core/embed/bootloader_ci/version.h b/core/embed/projects/bootloader_ci/version.h similarity index 100% rename from core/embed/bootloader_ci/version.h rename to core/embed/projects/bootloader_ci/version.h diff --git a/core/embed/bootloader_ci/version_check.c b/core/embed/projects/bootloader_ci/version_check.c similarity index 100% rename from core/embed/bootloader_ci/version_check.c rename to core/embed/projects/bootloader_ci/version_check.c diff --git a/core/embed/bootloader_ci/version_check.h b/core/embed/projects/bootloader_ci/version_check.h similarity index 100% rename from core/embed/bootloader_ci/version_check.h rename to core/embed/projects/bootloader_ci/version_check.h diff --git a/core/embed/firmware/header.S b/core/embed/projects/firmware/header.S similarity index 100% rename from core/embed/firmware/header.S rename to core/embed/projects/firmware/header.S diff --git a/core/embed/firmware/main.c b/core/embed/projects/firmware/main.c similarity index 97% rename from core/embed/firmware/main.c rename to core/embed/projects/firmware/main.c index d59ace6257..3f2094ea61 100644 --- a/core/embed/firmware/main.c +++ b/core/embed/projects/firmware/main.c @@ -32,10 +32,10 @@ #include "ports/stm32/gccollect.h" #include "ports/stm32/pendsv.h" -#include "rsod.h" +#include +#include +#include #include "rust_ui_common.h" -#include "systask.h" -#include "system.h" #ifdef USE_SECP256K1_ZKP #include "zkp_context.h" diff --git a/core/embed/firmware/mpconfigport.h b/core/embed/projects/firmware/mpconfigport.h similarity index 99% rename from core/embed/firmware/mpconfigport.h rename to core/embed/projects/firmware/mpconfigport.h index 0e9e990b1b..0df34659e5 100644 --- a/core/embed/firmware/mpconfigport.h +++ b/core/embed/projects/firmware/mpconfigport.h @@ -192,7 +192,7 @@ typedef int mp_int_t; // must be pointer size typedef unsigned int mp_uint_t; // must be pointer size typedef long mp_off_t; -#include "irq.h" +#include #define MICROPY_BEGIN_ATOMIC_SECTION() irq_lock() #define MICROPY_END_ATOMIC_SECTION(state) irq_unlock(state) diff --git a/core/embed/firmware/mphalport.c b/core/embed/projects/firmware/mphalport.c similarity index 97% rename from core/embed/firmware/mphalport.c rename to core/embed/projects/firmware/mphalport.c index b3428c16a9..a02bda07b0 100644 --- a/core/embed/firmware/mphalport.c +++ b/core/embed/projects/firmware/mphalport.c @@ -21,8 +21,8 @@ #include "py/mphal.h" -#include "systick.h" -#include "usb.h" +#include +#include static int vcp_iface_num = -1; diff --git a/core/embed/firmware/mphalport.h b/core/embed/projects/firmware/mphalport.h similarity index 100% rename from core/embed/firmware/mphalport.h rename to core/embed/projects/firmware/mphalport.h diff --git a/core/embed/firmware/nlrthumb.c b/core/embed/projects/firmware/nlrthumb.c similarity index 100% rename from core/embed/firmware/nlrthumb.c rename to core/embed/projects/firmware/nlrthumb.c diff --git a/core/embed/firmware/version.h b/core/embed/projects/firmware/version.h similarity index 100% rename from core/embed/firmware/version.h rename to core/embed/projects/firmware/version.h diff --git a/core/embed/kernel/main.c b/core/embed/projects/kernel/main.c similarity index 86% rename from core/embed/kernel/main.c rename to core/embed/projects/kernel/main.c index 62894244d0..f252907bd8 100644 --- a/core/embed/kernel/main.c +++ b/core/embed/projects/kernel/main.c @@ -19,36 +19,65 @@ #include -#include "applet.h" -#include "bl_check.h" -#include "board_capabilities.h" -#include "bootutils.h" -#include "button.h" -#include "consumption_mask.h" -#include "display.h" -#include "dma2d_bitblt.h" -#include "entropy.h" -#include "haptic.h" -#include "image.h" -#include "irq.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "memzero.h" -#include "mpu.h" -#include "optiga_commands.h" -#include "optiga_transport.h" -#include "option_bytes.h" -#include "pvd.h" -#include "random_delays.h" -#include "rsod.h" -#include "sdcard.h" -#include "secret.h" -#include "secure_aes.h" -#include "system.h" -#include "systemview.h" -#include "systick.h" -#include "tamper.h" -#include "touch.h" -#include "trustzone.h" -#include "unit_properties.h" + +#ifdef USE_BUTTON +#include +#endif + +#ifdef USE_CONSUMPTION_MASK +#include +#endif + +#ifdef USE_HAPTIC +#include +#endif + +#ifdef USE_OPTIGA +#include +#include +#endif + +#ifdef USE_PVD +#include +#endif + +#ifdef USE_SD_CARD +#include +#endif + +#ifdef SYSTEM_VIEW +#include +#endif + +#ifdef USE_TAMPER +#include +#endif + +#ifdef USE_TOUCH +#include +#endif + +#ifdef USE_TRUSTZONE +#include +#endif #ifdef USE_OPTIGA #if !PYOPT @@ -93,9 +122,7 @@ void drivers_init() { hash_processor_init(); #endif -#ifdef USE_DMA2D - dma2d_init(); -#endif + gfx_bitblt_init(); display_init(DISPLAY_JUMP_BEHAVIOR); diff --git a/core/embed/kernel/version.h b/core/embed/projects/kernel/version.h similarity index 100% rename from core/embed/kernel/version.h rename to core/embed/projects/kernel/version.h diff --git a/core/embed/prodtest/.changelog.d/.keep b/core/embed/projects/prodtest/.changelog.d/.keep similarity index 100% rename from core/embed/prodtest/.changelog.d/.keep rename to core/embed/projects/prodtest/.changelog.d/.keep diff --git a/core/embed/prodtest/.changelog.d/4310.fixed b/core/embed/projects/prodtest/.changelog.d/4310.fixed similarity index 100% rename from core/embed/prodtest/.changelog.d/4310.fixed rename to core/embed/projects/prodtest/.changelog.d/4310.fixed diff --git a/core/embed/prodtest/.changelog.d/4313.fixed b/core/embed/projects/prodtest/.changelog.d/4313.fixed similarity index 100% rename from core/embed/prodtest/.changelog.d/4313.fixed rename to core/embed/projects/prodtest/.changelog.d/4313.fixed diff --git a/core/embed/projects/prodtest/.towncrier.template.md b/core/embed/projects/prodtest/.towncrier.template.md new file mode 120000 index 0000000000..387acb2f4f --- /dev/null +++ b/core/embed/projects/prodtest/.towncrier.template.md @@ -0,0 +1 @@ +../../../../tools/towncrier.template.md \ No newline at end of file diff --git a/core/embed/prodtest/CHANGELOG.md b/core/embed/projects/prodtest/CHANGELOG.md similarity index 100% rename from core/embed/prodtest/CHANGELOG.md rename to core/embed/projects/prodtest/CHANGELOG.md diff --git a/core/embed/projects/prodtest/CHANGELOG.unreleased b/core/embed/projects/prodtest/CHANGELOG.unreleased new file mode 120000 index 0000000000..12f3cc5d59 --- /dev/null +++ b/core/embed/projects/prodtest/CHANGELOG.unreleased @@ -0,0 +1 @@ +../../../../tools/generate-changelog-unreleased.sh \ No newline at end of file diff --git a/core/embed/prodtest/README.md b/core/embed/projects/prodtest/README.md similarity index 100% rename from core/embed/prodtest/README.md rename to core/embed/projects/prodtest/README.md diff --git a/core/embed/prodtest/header.S b/core/embed/projects/prodtest/header.S similarity index 100% rename from core/embed/prodtest/header.S rename to core/embed/projects/prodtest/header.S diff --git a/core/embed/prodtest/main.c b/core/embed/projects/prodtest/main.c similarity index 96% rename from core/embed/prodtest/main.c rename to core/embed/projects/prodtest/main.c index f716574a00..ee2f862651 100644 --- a/core/embed/prodtest/main.c +++ b/core/embed/projects/prodtest/main.c @@ -25,48 +25,60 @@ #include #include -#include "board_capabilities.h" -#include "bootutils.h" -#include "button.h" -#include "display.h" -#include "display_utils.h" -#include "flash.h" -#include "flash_otp.h" -#include "fonts/fonts.h" -#include "fwutils.h" -#include "gfx_draw.h" -#include "image.h" -#include "mpu.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "prodtest_common.h" -#include "random_delays.h" -#include "rsod.h" -#include "sbu.h" -#include "sdcard.h" -#include "system.h" -#include "systick.h" -#include "systimer.h" -#include "touch.h" -#include "usb.h" #include "version.h" +#ifdef USE_BUTTON +#include +#endif + +#ifdef USE_SBU +#include +#endif + +#ifdef USE_SD_CARD +#include +#endif + +#ifdef USE_TOUCH +#include +#endif + #ifdef USE_OPTIGA -#include "optiga_commands.h" +#include +#include #include "optiga_prodtest.h" -#include "optiga_transport.h" #endif #ifdef USE_HAPTIC -#include "haptic.h" +#include #endif #ifdef USE_HASH_PROCESSOR -#include "hash_processor.h" +#include #endif #include "memzero.h" #ifdef USE_STORAGE_HWKEY -#include "secure_aes.h" +#include #endif #ifdef STM32U5 diff --git a/core/embed/prodtest/optiga_prodtest.c b/core/embed/projects/prodtest/optiga_prodtest.c similarity index 99% rename from core/embed/prodtest/optiga_prodtest.c rename to core/embed/projects/prodtest/optiga_prodtest.c index a05484aebf..62cf042083 100644 --- a/core/embed/prodtest/optiga_prodtest.c +++ b/core/embed/projects/prodtest/optiga_prodtest.c @@ -19,22 +19,22 @@ #include +#include +#include +#include #include "aes/aes.h" #include "buffer.h" #include "der.h" #include "ecdsa.h" #include "memzero.h" #include "nist256p1.h" -#include "optiga_commands.h" #include "optiga_prodtest.h" -#include "optiga_transport.h" #include "prodtest_common.h" #include "rand.h" -#include "secret.h" #include "sha2.h" #ifdef USE_STORAGE_HWKEY -#include "secure_aes.h" +#include #endif typedef enum { diff --git a/core/embed/prodtest/optiga_prodtest.h b/core/embed/projects/prodtest/optiga_prodtest.h similarity index 100% rename from core/embed/prodtest/optiga_prodtest.h rename to core/embed/projects/prodtest/optiga_prodtest.h diff --git a/core/embed/prodtest/prodtest_common.c b/core/embed/projects/prodtest/prodtest_common.c similarity index 98% rename from core/embed/prodtest/prodtest_common.c rename to core/embed/projects/prodtest/prodtest_common.c index 9b9fbb93d3..8ea6b852c2 100644 --- a/core/embed/prodtest/prodtest_common.c +++ b/core/embed/projects/prodtest/prodtest_common.c @@ -18,8 +18,8 @@ */ #include "prodtest_common.h" -#include "mini_printf.h" -#include "usb.h" +#include +#include void vcp_puts(const char *s, size_t len) { int r = usb_vcp_write_blocking(VCP_IFACE, (const uint8_t *)s, len, -1); diff --git a/core/embed/prodtest/prodtest_common.h b/core/embed/projects/prodtest/prodtest_common.h similarity index 100% rename from core/embed/prodtest/prodtest_common.h rename to core/embed/projects/prodtest/prodtest_common.h diff --git a/core/embed/projects/prodtest/towncrier.toml b/core/embed/projects/prodtest/towncrier.toml new file mode 120000 index 0000000000..09694ad2ae --- /dev/null +++ b/core/embed/projects/prodtest/towncrier.toml @@ -0,0 +1 @@ +../../../../tools/towncrier.toml \ No newline at end of file diff --git a/core/embed/prodtest/version.h b/core/embed/projects/prodtest/version.h similarity index 100% rename from core/embed/prodtest/version.h rename to core/embed/projects/prodtest/version.h diff --git a/core/embed/reflash/header.S b/core/embed/projects/reflash/header.S similarity index 100% rename from core/embed/reflash/header.S rename to core/embed/projects/reflash/header.S diff --git a/core/embed/reflash/main.c b/core/embed/projects/reflash/main.c similarity index 90% rename from core/embed/reflash/main.c rename to core/embed/projects/reflash/main.c index b987687331..b6fee7865a 100644 --- a/core/embed/reflash/main.c +++ b/core/embed/projects/reflash/main.c @@ -20,22 +20,22 @@ #include #include -#include "bootutils.h" -#include "display.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "flash.h" -#include "gfx_draw.h" -#include "image.h" -#include "rng.h" -#include "rsod.h" -#include "sbu.h" -#include "sdcard.h" -#include "system.h" -#include "systimer.h" -#include "terminal.h" -#include "touch.h" #ifdef USE_HASH_PROCESSOR -#include "hash_processor.h" +#include #endif static void progress_callback(int pos, int len) { term_printf("."); } diff --git a/core/embed/reflash/version.h b/core/embed/projects/reflash/version.h similarity index 100% rename from core/embed/reflash/version.h rename to core/embed/projects/reflash/version.h diff --git a/core/embed/unix/main.c b/core/embed/projects/unix/main.c similarity index 98% rename from core/embed/unix/main.c rename to core/embed/projects/unix/main.c index 6167aab1d1..b23a72d51a 100644 --- a/core/embed/unix/main.c +++ b/core/embed/projects/unix/main.c @@ -36,19 +36,25 @@ #include #include -#include "button.h" -#include "display.h" +#include +#include +#include +#include +#include +#include +#include #include "extmod/misc.h" #include "extmod/vfs_posix.h" -#include "flash.h" -#include "flash_otp.h" #include "genhdr/mpversion.h" #include "input.h" -#include "rsod.h" -#include "system.h" -#include "systimer.h" -#include "touch.h" -#include "unit_properties.h" + +#ifdef USE_BUTTON +#include +#endif + +#ifdef USE_TOUCH +#include +#endif #include "py/builtin.h" #include "py/compile.h" diff --git a/core/embed/unix/main_main.c b/core/embed/projects/unix/main_main.c similarity index 97% rename from core/embed/unix/main_main.c rename to core/embed/projects/unix/main_main.c index 7f8ee7d9b1..537e0543e4 100644 --- a/core/embed/unix/main_main.c +++ b/core/embed/projects/unix/main_main.c @@ -7,7 +7,7 @@ #include "zkp_context.h" #endif -#include "entropy.h" +#include MP_NOINLINE int main_(int argc, char **argv); diff --git a/core/embed/unix/mpconfigport.h b/core/embed/projects/unix/mpconfigport.h similarity index 100% rename from core/embed/unix/mpconfigport.h rename to core/embed/projects/unix/mpconfigport.h diff --git a/core/embed/unix/profile.c b/core/embed/projects/unix/profile.c similarity index 100% rename from core/embed/unix/profile.c rename to core/embed/projects/unix/profile.c diff --git a/core/embed/unix/profile.h b/core/embed/projects/unix/profile.h similarity index 100% rename from core/embed/unix/profile.h rename to core/embed/projects/unix/profile.h diff --git a/core/embed/unix/version.h b/core/embed/projects/unix/version.h similarity index 100% rename from core/embed/unix/version.h rename to core/embed/projects/unix/version.h diff --git a/core/embed/lib/error_handling.c b/core/embed/rtl/error_handling.c similarity index 98% rename from core/embed/lib/error_handling.c rename to core/embed/rtl/error_handling.c index 6691d37e44..8c6288693e 100644 --- a/core/embed/lib/error_handling.c +++ b/core/embed/rtl/error_handling.c @@ -19,7 +19,7 @@ #include -#include "system.h" +#include #ifndef TREZOR_EMULATOR // Stack check guard value set in startup code. diff --git a/core/embed/lib/assert.h b/core/embed/rtl/inc/assert.h similarity index 100% rename from core/embed/lib/assert.h rename to core/embed/rtl/inc/assert.h diff --git a/core/embed/lib/common.h b/core/embed/rtl/inc/common.h similarity index 84% rename from core/embed/lib/common.h rename to core/embed/rtl/inc/common.h index a2f5826dc1..d027122fb4 100644 --- a/core/embed/lib/common.h +++ b/core/embed/rtl/inc/common.h @@ -17,15 +17,11 @@ * along with this program. If not, see . */ -#ifndef LIB_COMMON_H - -// This header is included in storage modules that expect to find common +// This header is included in storage module that expect to find common // functions like `ensure()`, `error_shutdown()`, or `hal_delay()`. // // Do not include this header or add dependencies to it unless required by // storage. -#include "error_handling.h" -#include "systick.h" - -#endif // LIB_COMMON_H +#include +#include "rtl/error_handling.h" diff --git a/core/embed/lib/compiler_traits.h b/core/embed/rtl/inc/rtl/compiler_traits.h similarity index 100% rename from core/embed/lib/compiler_traits.h rename to core/embed/rtl/inc/rtl/compiler_traits.h diff --git a/core/embed/lib/error_handling.h b/core/embed/rtl/inc/rtl/error_handling.h similarity index 100% rename from core/embed/lib/error_handling.h rename to core/embed/rtl/inc/rtl/error_handling.h diff --git a/core/embed/lib/mini_printf.h b/core/embed/rtl/inc/rtl/mini_printf.h similarity index 100% rename from core/embed/lib/mini_printf.h rename to core/embed/rtl/inc/rtl/mini_printf.h diff --git a/core/embed/lib/secbool.h b/core/embed/rtl/inc/rtl/secbool.h similarity index 100% rename from core/embed/lib/secbool.h rename to core/embed/rtl/inc/rtl/secbool.h diff --git a/core/embed/lib/sizedefs.h b/core/embed/rtl/inc/rtl/sizedefs.h similarity index 100% rename from core/embed/lib/sizedefs.h rename to core/embed/rtl/inc/rtl/sizedefs.h diff --git a/core/embed/rtl/inc/secbool.h b/core/embed/rtl/inc/secbool.h new file mode 100644 index 0000000000..4d4880fbbd --- /dev/null +++ b/core/embed/rtl/inc/secbool.h @@ -0,0 +1,25 @@ +/* + * 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 . + */ + +// This header is included in storage module +// +// Do not include this header or add dependencies to it unless required by +// storage. + +#include "rtl/secbool.h" diff --git a/core/embed/lib/trezor_rtl.h b/core/embed/rtl/inc/trezor_rtl.h similarity index 96% rename from core/embed/lib/trezor_rtl.h rename to core/embed/rtl/inc/trezor_rtl.h index 24f96875a3..75a5844a2e 100644 --- a/core/embed/lib/trezor_rtl.h +++ b/core/embed/rtl/inc/trezor_rtl.h @@ -32,7 +32,8 @@ #include #include -#include "error_handling.h" +#include "rtl/compiler_traits.h" +#include "rtl/error_handling.h" #ifndef MIN_8bits #define MIN_8bits(a, b) \ diff --git a/core/embed/lib/trezor_types.h b/core/embed/rtl/inc/trezor_types.h similarity index 97% rename from core/embed/lib/trezor_types.h rename to core/embed/rtl/inc/trezor_types.h index 03aed8fa5f..a4e8a83ebb 100644 --- a/core/embed/lib/trezor_types.h +++ b/core/embed/rtl/inc/trezor_types.h @@ -30,6 +30,6 @@ #include #include -#include "secbool.h" +#include "rtl/secbool.h" #endif // TREZOR_TYPES_H diff --git a/core/embed/lib/mini_printf.c b/core/embed/rtl/mini_printf.c similarity index 99% rename from core/embed/lib/mini_printf.c rename to core/embed/rtl/mini_printf.c index 8360d7ddc0..65731ade0c 100644 --- a/core/embed/lib/mini_printf.c +++ b/core/embed/rtl/mini_printf.c @@ -45,7 +45,7 @@ #include -#include "mini_printf.h" +#include static unsigned int mini_strlen(const char *s) diff --git a/core/embed/rust/build.rs b/core/embed/rust/build.rs index 3307460508..4a9e1da114 100644 --- a/core/embed/rust/build.rs +++ b/core/embed/rust/build.rs @@ -26,19 +26,31 @@ fn build_dir() -> String { } const DEFAULT_BINDGEN_MACROS_COMMON: &[&str] = &[ - "-I../unix", - "-I../trezorhal/unix", + "-I../projects/unix", "-I../../build/unix", "-I../../vendor/micropython/ports/unix", "-I../../../crypto", "-I../../../storage", "-I../../vendor/micropython", "-I../../vendor/micropython/lib/uzlib", - "-I../lib", - "-I../trezorhal", - "-I../trezorhal/unix", + "-I../rtl/inc", + "-I../gfx/inc", + "-I../io/button/inc", + "-I../io/display/inc", + "-I../io/haptic/inc", + "-I../io/touch/inc", + "-I../io/rgb_led/inc", + "-I../io/usb/inc", + "-I../sec/entropy/inc", + "-I../sys/time/inc", + "-I../util/flash/inc", + "-I../util/translations/inc", "-I../models", "-DTREZOR_EMULATOR", + "-DUSE_BUTTON", + "-DUSE_TOUCH", + "-DUSE_HAPTIC", + "-DUSE_RGB_LED", ]; #[cfg(feature = "model_tt")] @@ -365,7 +377,7 @@ fn generate_trezorhal_bindings() { .allowlist_function("gfx_mono8_copy_mono4") .allowlist_function("gfx_mono8_blend_mono1p") .allowlist_function("gfx_mono8_blend_mono4") - .allowlist_function("dma2d_wait") + .allowlist_function("gfx_bitblt_wait") // fonts .allowlist_function("font_height") .allowlist_function("font_max_height") diff --git a/core/embed/rust/micropython.h b/core/embed/rust/micropython.h index 9b19e64fff..01c8d02a79 100644 --- a/core/embed/rust/micropython.h +++ b/core/embed/rust/micropython.h @@ -4,4 +4,4 @@ #include "py/obj.h" #include "py/runtime.h" -#include "../extmod/trezorobj.h" +#include "../upymod/trezorobj.h" diff --git a/core/embed/rust/src/micropython/macros.rs b/core/embed/rust/src/micropython/macros.rs index 750d12dcaf..f549fdf53b 100644 --- a/core/embed/rust/src/micropython/macros.rs +++ b/core/embed/rust/src/micropython/macros.rs @@ -174,7 +174,7 @@ macro_rules! obj_type { }}; } -/// Construct an extmod definition. +/// Construct an upymod definition. macro_rules! obj_module { ($($key:expr => $val:expr),*) => ({ #[allow(unused_unsafe)] diff --git a/core/embed/rust/src/trezorhal/bitblt.rs b/core/embed/rust/src/trezorhal/bitblt.rs index c2b0414922..f11e9bf470 100644 --- a/core/embed/rust/src/trezorhal/bitblt.rs +++ b/core/embed/rust/src/trezorhal/bitblt.rs @@ -9,11 +9,8 @@ use crate::ui::{ /// Waits for the DMA2D peripheral transfer to complete. pub fn wait_for_transfer() { // SAFETY: - // `ffi::dma2d_wait()` is always safe to call. - #[cfg(feature = "dma2d")] - unsafe { - ffi::dma2d_wait() - } + // `ffi::gfx_bitblt_wait()` is always safe to call. + unsafe { ffi::gfx_bitblt_wait() } } impl Default for ffi::gfx_bitblt_t { diff --git a/core/embed/rust/src/ui/display/font.rs b/core/embed/rust/src/ui/display/font.rs index 090d22ad08..38fc4d4e97 100644 --- a/core/embed/rust/src/ui/display/font.rs +++ b/core/embed/rust/src/ui/display/font.rs @@ -107,7 +107,7 @@ impl Glyph { } /// Font constants. Keep in sync with FONT_ definitions in -/// `core/embed/lib/fonts/fonts.h`. +/// `core/embed/gfx/fonts/fonts.h`. #[derive(Copy, Clone, PartialEq, Eq, FromPrimitive)] #[repr(u8)] #[allow(non_camel_case_types)] diff --git a/core/embed/rust/trezorhal.h b/core/embed/rust/trezorhal.h index 1048d6da7c..fcec05f276 100644 --- a/core/embed/rust/trezorhal.h +++ b/core/embed/rust/trezorhal.h @@ -1,20 +1,31 @@ #include -#include "button.h" -#include "display.h" -#include "dma2d_bitblt.h" -#include "entropy.h" -#include "flash.h" -#include "fonts/fonts.h" -#include "gfx_bitblt.h" -#include "haptic.h" -#include "rgb_led.h" -#include "secbool.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "storage.h" -#include "systick.h" -#include "touch.h" -#include "translations.h" -#include "usb.h" + +#ifdef USE_BUTTON +#include +#endif + +#ifdef USE_HAPTIC +#include +#endif + +#ifdef USE_RGB_LED +#include +#endif + +#ifdef USE_TOUCH +#include +#endif #include "bip39.h" #include "rand.h" diff --git a/core/embed/trezorhal/consumption_mask.h b/core/embed/sec/consumption_mask/inc/sec/consumption_mask.h similarity index 100% rename from core/embed/trezorhal/consumption_mask.h rename to core/embed/sec/consumption_mask/inc/sec/consumption_mask.h diff --git a/core/embed/trezorhal/stm32f4/consumption_mask.c b/core/embed/sec/consumption_mask/stm32f4/consumption_mask.c similarity index 98% rename from core/embed/trezorhal/stm32f4/consumption_mask.c rename to core/embed/sec/consumption_mask/stm32f4/consumption_mask.c index 911502b2b8..5b16b1c95d 100644 --- a/core/embed/trezorhal/stm32f4/consumption_mask.c +++ b/core/embed/sec/consumption_mask/stm32f4/consumption_mask.c @@ -20,8 +20,8 @@ #include #include -#include "mpu.h" -#include "rng.h" +#include +#include #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/stm32u5/consumption_mask.c b/core/embed/sec/consumption_mask/stm32u5/consumption_mask.c similarity index 99% rename from core/embed/trezorhal/stm32u5/consumption_mask.c rename to core/embed/sec/consumption_mask/stm32u5/consumption_mask.c index ec511fd346..380dd79cac 100644 --- a/core/embed/trezorhal/stm32u5/consumption_mask.c +++ b/core/embed/sec/consumption_mask/stm32u5/consumption_mask.c @@ -19,7 +19,7 @@ #include -#include "rng.h" +#include #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/entropy.h b/core/embed/sec/entropy/inc/sec/entropy.h similarity index 100% rename from core/embed/trezorhal/entropy.h rename to core/embed/sec/entropy/inc/sec/entropy.h diff --git a/core/embed/trezorhal/stm32f4/entropy.c b/core/embed/sec/entropy/stm32f4/entropy.c similarity index 96% rename from core/embed/trezorhal/stm32f4/entropy.c rename to core/embed/sec/entropy/stm32f4/entropy.c index a2ce11ea77..495a78028c 100644 --- a/core/embed/trezorhal/stm32f4/entropy.c +++ b/core/embed/sec/entropy/stm32f4/entropy.c @@ -20,9 +20,9 @@ #include #include -#include "entropy.h" -#include "flash_otp.h" -#include "mpu.h" +#include +#include +#include #include "rand.h" #include "stm32f4xx_ll_utils.h" diff --git a/core/embed/trezorhal/stm32u5/entropy.c b/core/embed/sec/entropy/stm32u5/entropy.c similarity index 96% rename from core/embed/trezorhal/stm32u5/entropy.c rename to core/embed/sec/entropy/stm32u5/entropy.c index 398a1369cf..926c61691b 100644 --- a/core/embed/trezorhal/stm32u5/entropy.c +++ b/core/embed/sec/entropy/stm32u5/entropy.c @@ -20,9 +20,9 @@ #include #include -#include "entropy.h" -#include "flash_otp.h" -#include "mpu.h" +#include +#include +#include #include "rand.h" #include "stm32u5xx_ll_utils.h" diff --git a/core/embed/trezorhal/unix/entropy.c b/core/embed/sec/entropy/unix/entropy.c similarity index 97% rename from core/embed/trezorhal/unix/entropy.c rename to core/embed/sec/entropy/unix/entropy.c index c2bcb1cdf2..8f942c5736 100644 --- a/core/embed/trezorhal/unix/entropy.c +++ b/core/embed/sec/entropy/unix/entropy.c @@ -19,7 +19,7 @@ #include -#include "entropy.h" +#include static uint8_t g_hw_entropy[HW_ENTROPY_LEN]; diff --git a/core/embed/trezorhal/hash_processor.h b/core/embed/sec/hash_processor/inc/sec/hash_processor.h similarity index 100% rename from core/embed/trezorhal/hash_processor.h rename to core/embed/sec/hash_processor/inc/sec/hash_processor.h diff --git a/core/embed/trezorhal/stm32u5/hash_processor.c b/core/embed/sec/hash_processor/stm32u5/hash_processor.c similarity index 98% rename from core/embed/trezorhal/stm32u5/hash_processor.c rename to core/embed/sec/hash_processor/stm32u5/hash_processor.c index 89f34a51e4..7094119c4a 100644 --- a/core/embed/trezorhal/stm32u5/hash_processor.c +++ b/core/embed/sec/hash_processor/stm32u5/hash_processor.c @@ -1,10 +1,10 @@ #include #include -#include "hash_processor.h" -#include "irq.h" +#include +#include +#include #include "memzero.h" -#include "mpu.h" #include "sha2.h" #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/monoctr.h b/core/embed/sec/monoctr/inc/sec/monoctr.h similarity index 100% rename from core/embed/trezorhal/monoctr.h rename to core/embed/sec/monoctr/inc/sec/monoctr.h diff --git a/core/embed/trezorhal/stm32f4/monoctr.c b/core/embed/sec/monoctr/stm32f4/monoctr.c similarity index 97% rename from core/embed/trezorhal/stm32f4/monoctr.c rename to core/embed/sec/monoctr/stm32f4/monoctr.c index 554255e5a3..e51a6bb440 100644 --- a/core/embed/trezorhal/stm32f4/monoctr.c +++ b/core/embed/sec/monoctr/stm32f4/monoctr.c @@ -20,9 +20,9 @@ #include #include -#include "flash_otp.h" -#include "monoctr.h" -#include "mpu.h" +#include +#include +#include #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/stm32u5/monoctr.c b/core/embed/sec/monoctr/stm32u5/monoctr.c similarity index 97% rename from core/embed/trezorhal/stm32u5/monoctr.c rename to core/embed/sec/monoctr/stm32u5/monoctr.c index e538021aaf..2e759c827f 100644 --- a/core/embed/trezorhal/stm32u5/monoctr.c +++ b/core/embed/sec/monoctr/stm32u5/monoctr.c @@ -19,10 +19,10 @@ #include +#include +#include +#include #include "flash_area.h" -#include "monoctr.h" -#include "mpu.h" -#include "secret.h" #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/unix/monoctr.c b/core/embed/sec/monoctr/unix/monoctr.c similarity index 98% rename from core/embed/trezorhal/unix/monoctr.c rename to core/embed/sec/monoctr/unix/monoctr.c index 1feff33ba4..455995cd4b 100644 --- a/core/embed/trezorhal/unix/monoctr.c +++ b/core/embed/sec/monoctr/unix/monoctr.c @@ -20,8 +20,8 @@ #include #include -#include "flash_otp.h" -#include "monoctr.h" +#include +#include static int get_otp_block(monoctr_type_t type) { switch (type) { diff --git a/core/embed/sec/optiga/inc/optiga.h b/core/embed/sec/optiga/inc/optiga.h new file mode 100644 index 0000000000..3ac96f2eb8 --- /dev/null +++ b/core/embed/sec/optiga/inc/optiga.h @@ -0,0 +1,25 @@ +/* + * 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 . + */ + +// This header is included in storage module +// +// Do not include this header or add dependencies to it unless required by +// storage. + +#include "sec/optiga.h" diff --git a/core/embed/trezorhal/optiga.h b/core/embed/sec/optiga/inc/sec/optiga.h similarity index 100% rename from core/embed/trezorhal/optiga.h rename to core/embed/sec/optiga/inc/sec/optiga.h diff --git a/core/embed/trezorhal/optiga_commands.h b/core/embed/sec/optiga/inc/sec/optiga_commands.h similarity index 100% rename from core/embed/trezorhal/optiga_commands.h rename to core/embed/sec/optiga/inc/sec/optiga_commands.h diff --git a/core/embed/trezorhal/optiga_common.h b/core/embed/sec/optiga/inc/sec/optiga_common.h similarity index 100% rename from core/embed/trezorhal/optiga_common.h rename to core/embed/sec/optiga/inc/sec/optiga_common.h diff --git a/core/embed/trezorhal/optiga_hal.h b/core/embed/sec/optiga/inc/sec/optiga_hal.h similarity index 100% rename from core/embed/trezorhal/optiga_hal.h rename to core/embed/sec/optiga/inc/sec/optiga_hal.h diff --git a/core/embed/trezorhal/optiga_transport.h b/core/embed/sec/optiga/inc/sec/optiga_transport.h similarity index 100% rename from core/embed/trezorhal/optiga_transport.h rename to core/embed/sec/optiga/inc/sec/optiga_transport.h diff --git a/core/embed/trezorhal/optiga/optiga.c b/core/embed/sec/optiga/optiga.c similarity index 99% rename from core/embed/trezorhal/optiga/optiga.c rename to core/embed/sec/optiga/optiga.c index b7ad7154df..a5262bc08b 100644 --- a/core/embed/trezorhal/optiga/optiga.c +++ b/core/embed/sec/optiga/optiga.c @@ -19,12 +19,12 @@ #include +#include +#include +#include #include "hash_to_curve.h" #include "hmac.h" #include "memzero.h" -#include "optiga.h" -#include "optiga_commands.h" -#include "optiga_transport.h" #include "rand.h" #include "storage.h" diff --git a/core/embed/trezorhal/optiga/optiga_commands.c b/core/embed/sec/optiga/optiga_commands.c similarity index 99% rename from core/embed/trezorhal/optiga/optiga_commands.c rename to core/embed/sec/optiga/optiga_commands.c index e25f5b7cca..bbe26508b3 100644 --- a/core/embed/trezorhal/optiga/optiga_commands.c +++ b/core/embed/sec/optiga/optiga_commands.c @@ -25,13 +25,13 @@ #include +#include +#include #include "der.h" #include "ecdsa.h" #include "hmac.h" #include "memzero.h" #include "nist256p1.h" -#include "optiga_commands.h" -#include "optiga_transport.h" #include "sha2.h" #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/optiga/optiga_transport.c b/core/embed/sec/optiga/optiga_transport.c similarity index 99% rename from core/embed/trezorhal/optiga/optiga_transport.c rename to core/embed/sec/optiga/optiga_transport.c index 5a1413ea18..4b3011e38c 100644 --- a/core/embed/trezorhal/optiga/optiga_transport.c +++ b/core/embed/sec/optiga/optiga_transport.c @@ -25,12 +25,12 @@ #include #include +#include +#include +#include +#include #include "aes/aesccm.h" -#include "i2c_bus.h" #include "memzero.h" -#include "optiga_hal.h" -#include "optiga_transport.h" -#include "systick.h" #include "tls_prf.h" #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/stm32f4/optiga_hal.c b/core/embed/sec/optiga/stm32f4/optiga_hal.c similarity index 94% rename from core/embed/trezorhal/stm32f4/optiga_hal.c rename to core/embed/sec/optiga/stm32f4/optiga_hal.c index e1efb96651..8aa1346ec5 100644 --- a/core/embed/trezorhal/stm32f4/optiga_hal.c +++ b/core/embed/sec/optiga/stm32f4/optiga_hal.c @@ -1,8 +1,8 @@ #include #include -#include "optiga_hal.h" -#include "systick.h" +#include +#include #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/stm32u5/optiga_hal.c b/core/embed/sec/optiga/stm32u5/optiga_hal.c similarity index 100% rename from core/embed/trezorhal/stm32u5/optiga_hal.c rename to core/embed/sec/optiga/stm32u5/optiga_hal.c diff --git a/core/embed/trezorhal/unix/certs/README.md b/core/embed/sec/optiga/unix/certs/README.md similarity index 100% rename from core/embed/trezorhal/unix/certs/README.md rename to core/embed/sec/optiga/unix/certs/README.md diff --git a/core/embed/trezorhal/unix/certs/T2B1.der b/core/embed/sec/optiga/unix/certs/T2B1.der similarity index 100% rename from core/embed/trezorhal/unix/certs/T2B1.der rename to core/embed/sec/optiga/unix/certs/T2B1.der diff --git a/core/embed/trezorhal/unix/certs/T2B1.h b/core/embed/sec/optiga/unix/certs/T2B1.h similarity index 100% rename from core/embed/trezorhal/unix/certs/T2B1.h rename to core/embed/sec/optiga/unix/certs/T2B1.h diff --git a/core/embed/trezorhal/unix/certs/T3T1.der b/core/embed/sec/optiga/unix/certs/T3T1.der similarity index 100% rename from core/embed/trezorhal/unix/certs/T3T1.der rename to core/embed/sec/optiga/unix/certs/T3T1.der diff --git a/core/embed/trezorhal/unix/certs/T3T1.h b/core/embed/sec/optiga/unix/certs/T3T1.h similarity index 100% rename from core/embed/trezorhal/unix/certs/T3T1.h rename to core/embed/sec/optiga/unix/certs/T3T1.h diff --git a/core/embed/trezorhal/unix/certs/gen.sh b/core/embed/sec/optiga/unix/certs/gen.sh similarity index 100% rename from core/embed/trezorhal/unix/certs/gen.sh rename to core/embed/sec/optiga/unix/certs/gen.sh diff --git a/core/embed/trezorhal/unix/optiga.c b/core/embed/sec/optiga/unix/optiga.c similarity index 98% rename from core/embed/trezorhal/unix/optiga.c rename to core/embed/sec/optiga/unix/optiga.c index 5396e7441c..33ca8c2528 100644 --- a/core/embed/trezorhal/unix/optiga.c +++ b/core/embed/sec/optiga/unix/optiga.c @@ -19,10 +19,10 @@ #include +#include +#include #include "ecdsa.h" #include "nist256p1.h" -#include "optiga.h" -#include "optiga_common.h" #include "rand.h" #include "storage.h" diff --git a/core/embed/trezorhal/unix/optiga_hal.c b/core/embed/sec/optiga/unix/optiga_hal.c similarity index 100% rename from core/embed/trezorhal/unix/optiga_hal.c rename to core/embed/sec/optiga/unix/optiga_hal.c diff --git a/core/embed/sec/random_delays/inc/random_delays.h b/core/embed/sec/random_delays/inc/random_delays.h new file mode 100644 index 0000000000..f49da516ca --- /dev/null +++ b/core/embed/sec/random_delays/inc/random_delays.h @@ -0,0 +1,25 @@ +/* + * 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 . + */ + +// This header is included in storage module +// +// Do not include this header or add dependencies to it unless required by +// storage. + +#include diff --git a/core/embed/trezorhal/random_delays.h b/core/embed/sec/random_delays/inc/sec/random_delays.h similarity index 100% rename from core/embed/trezorhal/random_delays.h rename to core/embed/sec/random_delays/inc/sec/random_delays.h diff --git a/core/embed/trezorhal/stm32f4/random_delays.c b/core/embed/sec/random_delays/stm32/random_delays.c similarity index 99% rename from core/embed/trezorhal/stm32f4/random_delays.c rename to core/embed/sec/random_delays/stm32/random_delays.c index 0b3e25021f..1078a458e6 100644 --- a/core/embed/trezorhal/stm32f4/random_delays.c +++ b/core/embed/sec/random_delays/stm32/random_delays.c @@ -21,11 +21,11 @@ #include +#include +#include #include "chacha_drbg.h" #include "memzero.h" #include "rand.h" -#include "random_delays.h" -#include "systimer.h" #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/unix/random_delays.c b/core/embed/sec/random_delays/unix/random_delays.c similarity index 96% rename from core/embed/trezorhal/unix/random_delays.c rename to core/embed/sec/random_delays/unix/random_delays.c index 075cb5ea3c..c50f25b5b8 100644 --- a/core/embed/trezorhal/unix/random_delays.c +++ b/core/embed/sec/random_delays/unix/random_delays.c @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include "random_delays.h" +#include void random_delays_init(void) {} diff --git a/core/embed/trezorhal/rng.h b/core/embed/sec/rng/inc/sec/rng.h similarity index 100% rename from core/embed/trezorhal/rng.h rename to core/embed/sec/rng/inc/sec/rng.h diff --git a/core/embed/trezorhal/stm32f4/rng.c b/core/embed/sec/rng/stm32/rng.c similarity index 98% rename from core/embed/trezorhal/stm32f4/rng.c rename to core/embed/sec/rng/stm32/rng.c index ebc1dc73bb..f714a7c5a5 100644 --- a/core/embed/trezorhal/stm32f4/rng.c +++ b/core/embed/sec/rng/stm32/rng.c @@ -19,7 +19,7 @@ #include -#include "rng.h" +#include #if KERNEL_MODE diff --git a/core/embed/trezorhal/unix/rng.c b/core/embed/sec/rng/unix/rng.c similarity index 98% rename from core/embed/trezorhal/unix/rng.c rename to core/embed/sec/rng/unix/rng.c index bc790ddf98..c204a475c6 100644 --- a/core/embed/trezorhal/unix/rng.c +++ b/core/embed/sec/rng/unix/rng.c @@ -19,7 +19,7 @@ #include -#include "rng.h" +#include uint32_t rng_get(void) { static FILE *frand = NULL; diff --git a/core/embed/trezorhal/secret.h b/core/embed/sec/secret/inc/sec/secret.h similarity index 100% rename from core/embed/trezorhal/secret.h rename to core/embed/sec/secret/inc/sec/secret.h diff --git a/core/embed/trezorhal/stm32f4/secret.c b/core/embed/sec/secret/stm32f4/secret.c similarity index 97% rename from core/embed/trezorhal/stm32f4/secret.c rename to core/embed/sec/secret/stm32f4/secret.c index 9485173147..970f951acc 100644 --- a/core/embed/trezorhal/stm32f4/secret.c +++ b/core/embed/sec/secret/stm32f4/secret.c @@ -1,9 +1,9 @@ #include #include -#include "flash.h" -#include "mpu.h" -#include "secret.h" +#include +#include +#include #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/stm32u5/secret.c b/core/embed/sec/secret/stm32u5/secret.c similarity index 98% rename from core/embed/trezorhal/stm32u5/secret.c rename to core/embed/sec/secret/stm32u5/secret.c index 8019e4beff..3392e915ea 100644 --- a/core/embed/trezorhal/stm32u5/secret.c +++ b/core/embed/sec/secret/stm32u5/secret.c @@ -2,14 +2,14 @@ #include #include -#include "bootutils.h" -#include "flash.h" -#include "flash_utils.h" +#include +#include +#include +#include +#include +#include +#include #include "memzero.h" -#include "mpu.h" -#include "rng.h" -#include "secret.h" -#include "secure_aes.h" #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/unix/secret.c b/core/embed/sec/secret/unix/secret.c similarity index 100% rename from core/embed/trezorhal/unix/secret.c rename to core/embed/sec/secret/unix/secret.c diff --git a/core/embed/trezorhal/secure_aes.h b/core/embed/sec/secure_aes/inc/sec/secure_aes.h similarity index 100% rename from core/embed/trezorhal/secure_aes.h rename to core/embed/sec/secure_aes/inc/sec/secure_aes.h diff --git a/core/embed/sec/secure_aes/inc/secure_aes.h b/core/embed/sec/secure_aes/inc/secure_aes.h new file mode 100644 index 0000000000..8fc6526932 --- /dev/null +++ b/core/embed/sec/secure_aes/inc/secure_aes.h @@ -0,0 +1,25 @@ +/* + * 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 . + */ + +// This header is included in storage module +// +// Do not include this header or add dependencies to it unless required by +// storage. + +#include diff --git a/core/embed/trezorhal/stm32u5/secure_aes.c b/core/embed/sec/secure_aes/stm32u5/secure_aes.c similarity index 98% rename from core/embed/trezorhal/stm32u5/secure_aes.c rename to core/embed/sec/secure_aes/stm32u5/secure_aes.c index 8b94516c3f..96404de0e5 100644 --- a/core/embed/trezorhal/stm32u5/secure_aes.c +++ b/core/embed/sec/secure_aes/stm32u5/secure_aes.c @@ -23,10 +23,13 @@ #include -#include "mpu.h" -#include "secure_aes.h" -#include "syscall.h" -#include "trustzone.h" +#include +#include +#include + +#ifdef USE_TRUSTZONE +#include +#endif #include "memzero.h" @@ -35,7 +38,7 @@ #ifdef KERNEL_MODE -#include "irq.h" +#include static void secure_aes_load_bhk(void) { TAMP->BKP0R; diff --git a/core/embed/trezorhal/time_estimate.h b/core/embed/sec/time_estimate/inc/sec/time_estimate.h similarity index 100% rename from core/embed/trezorhal/time_estimate.h rename to core/embed/sec/time_estimate/inc/sec/time_estimate.h diff --git a/core/embed/sec/time_estimate/inc/time_estimate.h b/core/embed/sec/time_estimate/inc/time_estimate.h new file mode 100644 index 0000000000..620518567d --- /dev/null +++ b/core/embed/sec/time_estimate/inc/time_estimate.h @@ -0,0 +1,25 @@ +/* + * 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 . + */ + +// This header is included in storage module +// +// Do not include this header or add dependencies to it unless required by +// storage. + +#include diff --git a/core/embed/trezorhal/stm32f4/time_estimate.c b/core/embed/sec/time_estimate/stm32/time_estimate.c similarity index 97% rename from core/embed/trezorhal/stm32f4/time_estimate.c rename to core/embed/sec/time_estimate/stm32/time_estimate.c index 99732ee900..02d647cd93 100644 --- a/core/embed/trezorhal/stm32f4/time_estimate.c +++ b/core/embed/sec/time_estimate/stm32/time_estimate.c @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include "time_estimate.h" +#include // The number of CPU cycles required to execute one iteration of PBKDF2. #define PIN_PBKDF2_CYCLES_PER_ITER 11100 diff --git a/core/embed/trezorhal/unix/time_estimate.c b/core/embed/sec/time_estimate/unix/time_estimate.c similarity index 96% rename from core/embed/trezorhal/unix/time_estimate.c rename to core/embed/sec/time_estimate/unix/time_estimate.c index 803121d28f..22f1ca838c 100644 --- a/core/embed/trezorhal/unix/time_estimate.c +++ b/core/embed/sec/time_estimate/unix/time_estimate.c @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include "time_estimate.h" +#include uint32_t time_estimate_pbkdf2_ms(uint32_t iterations) { (void)iterations; diff --git a/core/embed/models/trezor_bsp.h b/core/embed/sys/bsp/inc/trezor_bsp.h similarity index 100% rename from core/embed/models/trezor_bsp.h rename to core/embed/sys/bsp/inc/trezor_bsp.h diff --git a/core/embed/trezorhal/stm32f4/stm32f4xx_hal_conf.h b/core/embed/sys/bsp/stm32f4/stm32f4xx_hal_conf.h similarity index 100% rename from core/embed/trezorhal/stm32f4/stm32f4xx_hal_conf.h rename to core/embed/sys/bsp/stm32f4/stm32f4xx_hal_conf.h diff --git a/core/embed/trezorhal/stm32u5/stm32u5xx_hal_conf.h b/core/embed/sys/bsp/stm32u5/stm32u5xx_hal_conf.h similarity index 100% rename from core/embed/trezorhal/stm32u5/stm32u5xx_hal_conf.h rename to core/embed/sys/bsp/stm32u5/stm32u5xx_hal_conf.h diff --git a/core/embed/trezorhal/stm32f4/irq.h b/core/embed/sys/irq/inc/sys/irq.h similarity index 92% rename from core/embed/trezorhal/stm32f4/irq.h rename to core/embed/sys/irq/inc/sys/irq.h index fda030524f..2248741622 100644 --- a/core/embed/trezorhal/stm32f4/irq.h +++ b/core/embed/sys/irq/inc/sys/irq.h @@ -23,17 +23,16 @@ #include #include -// Enables simple IRQ statistics for debugging -#define IRQ_ENABLE_STATS (0) +#ifdef SYSTEM_VIEW +#include +#endif -#if IRQ_ENABLE_STATS -#define IRQ_STATS_MAX (128) -extern uint32_t irq_stats[IRQ_STATS_MAX]; -#define IRQ_ENTER(irq) ++irq_stats[irq] -#define IRQ_EXIT(irq) +#ifdef SYSTEM_VIEW +#define IRQ_LOG_ENTER() SEGGER_SYSVIEW_RecordEnterISR(); +#define IRQ_LOG_EXIT() SEGGER_SYSVIEW_RecordExitISR(); #else -#define IRQ_ENTER(irq) -#define IRQ_EXIT(irq) +#define IRQ_LOG_ENTER() +#define IRQ_LOG_EXIT() #endif typedef uint32_t irq_key_t; diff --git a/core/embed/trezorhal/stm32f4/linker/boardloader.ld b/core/embed/sys/linker/stm32f4/boardloader.ld similarity index 97% rename from core/embed/trezorhal/stm32f4/linker/boardloader.ld rename to core/embed/sys/linker/stm32f4/boardloader.ld index 20db46834e..6151123037 100644 --- a/core/embed/trezorhal/stm32f4/linker/boardloader.ld +++ b/core/embed/sys/linker/stm32f4/boardloader.ld @@ -1,4 +1,4 @@ -INCLUDE "./embed/trezorhal/stm32f4/linker/memory.ld"; +INCLUDE "./embed/sys/linker/stm32f4/memory.ld"; ENTRY(reset_handler) diff --git a/core/embed/trezorhal/stm32f4/linker/bootloader.ld b/core/embed/sys/linker/stm32f4/bootloader.ld similarity index 97% rename from core/embed/trezorhal/stm32f4/linker/bootloader.ld rename to core/embed/sys/linker/stm32f4/bootloader.ld index 5c2ba4f81c..22b23cd115 100644 --- a/core/embed/trezorhal/stm32f4/linker/bootloader.ld +++ b/core/embed/sys/linker/stm32f4/bootloader.ld @@ -1,4 +1,4 @@ -INCLUDE "./embed/trezorhal/stm32f4/linker/memory.ld"; +INCLUDE "./embed/sys/linker/stm32f4/memory.ld"; ENTRY(reset_handler) diff --git a/core/embed/trezorhal/stm32f4/linker/firmware.ld b/core/embed/sys/linker/stm32f4/firmware.ld similarity index 98% rename from core/embed/trezorhal/stm32f4/linker/firmware.ld rename to core/embed/sys/linker/stm32f4/firmware.ld index bfce57b0ea..73af9276a5 100644 --- a/core/embed/trezorhal/stm32f4/linker/firmware.ld +++ b/core/embed/sys/linker/stm32f4/firmware.ld @@ -1,4 +1,4 @@ -INCLUDE "./embed/trezorhal/stm32f4/linker/memory.ld"; +INCLUDE "./embed/sys/linker/stm32f4/memory.ld"; ENTRY(reset_handler) diff --git a/core/embed/trezorhal/stm32f4/linker/kernel.ld b/core/embed/sys/linker/stm32f4/kernel.ld similarity index 98% rename from core/embed/trezorhal/stm32f4/linker/kernel.ld rename to core/embed/sys/linker/stm32f4/kernel.ld index bd13c85ad0..e62bc13628 100644 --- a/core/embed/trezorhal/stm32f4/linker/kernel.ld +++ b/core/embed/sys/linker/stm32f4/kernel.ld @@ -1,4 +1,4 @@ -INCLUDE "./embed/trezorhal/stm32f4/linker/memory.ld"; +INCLUDE "./embed/sys/linker/stm32f4/memory.ld"; ENTRY(reset_handler) diff --git a/core/embed/trezorhal/stm32f4/linker/memory.ld b/core/embed/sys/linker/stm32f4/memory.ld similarity index 100% rename from core/embed/trezorhal/stm32f4/linker/memory.ld rename to core/embed/sys/linker/stm32f4/memory.ld diff --git a/core/embed/trezorhal/stm32f4/linker/prodtest.ld b/core/embed/sys/linker/stm32f4/prodtest.ld similarity index 97% rename from core/embed/trezorhal/stm32f4/linker/prodtest.ld rename to core/embed/sys/linker/stm32f4/prodtest.ld index 050a57e4db..cd38f227e3 100644 --- a/core/embed/trezorhal/stm32f4/linker/prodtest.ld +++ b/core/embed/sys/linker/stm32f4/prodtest.ld @@ -1,4 +1,4 @@ -INCLUDE "./embed/trezorhal/stm32f4/linker/memory.ld"; +INCLUDE "./embed/sys/linker/stm32f4/memory.ld"; ENTRY(reset_handler) diff --git a/core/embed/trezorhal/stm32u5/linker/u58/boardloader.ld b/core/embed/sys/linker/stm32u58/boardloader.ld similarity index 98% rename from core/embed/trezorhal/stm32u5/linker/u58/boardloader.ld rename to core/embed/sys/linker/stm32u58/boardloader.ld index 3b60bdd056..7a60e16264 100644 --- a/core/embed/trezorhal/stm32u5/linker/u58/boardloader.ld +++ b/core/embed/sys/linker/stm32u58/boardloader.ld @@ -1,4 +1,4 @@ -INCLUDE "./embed/trezorhal/stm32u5/linker/u58/memory.ld"; +INCLUDE "./embed/sys/linker/stm32u58/memory.ld"; ENTRY(reset_handler) diff --git a/core/embed/trezorhal/stm32u5/linker/u58/bootloader.ld b/core/embed/sys/linker/stm32u58/bootloader.ld similarity index 98% rename from core/embed/trezorhal/stm32u5/linker/u58/bootloader.ld rename to core/embed/sys/linker/stm32u58/bootloader.ld index 13c0e5ae41..d8025eab0d 100644 --- a/core/embed/trezorhal/stm32u5/linker/u58/bootloader.ld +++ b/core/embed/sys/linker/stm32u58/bootloader.ld @@ -1,4 +1,4 @@ -INCLUDE "./embed/trezorhal/stm32u5/linker/u58/memory.ld"; +INCLUDE "./embed/sys/linker/stm32u58/memory.ld"; ENTRY(reset_handler) diff --git a/core/embed/trezorhal/stm32u5/linker/u58/firmware.ld b/core/embed/sys/linker/stm32u58/firmware.ld similarity index 97% rename from core/embed/trezorhal/stm32u5/linker/u58/firmware.ld rename to core/embed/sys/linker/stm32u58/firmware.ld index 7e7b741ed8..e3a8b752b2 100644 --- a/core/embed/trezorhal/stm32u5/linker/u58/firmware.ld +++ b/core/embed/sys/linker/stm32u58/firmware.ld @@ -1,4 +1,4 @@ -INCLUDE "./embed/trezorhal/stm32u5/linker/u58/memory.ld"; +INCLUDE "./embed/sys/linker/stm32u58/memory.ld"; ENTRY(reset_handler) diff --git a/core/embed/trezorhal/stm32u5/linker/u58/kernel.ld b/core/embed/sys/linker/stm32u58/kernel.ld similarity index 98% rename from core/embed/trezorhal/stm32u5/linker/u58/kernel.ld rename to core/embed/sys/linker/stm32u58/kernel.ld index e2fc8d6d74..abe5d7e926 100644 --- a/core/embed/trezorhal/stm32u5/linker/u58/kernel.ld +++ b/core/embed/sys/linker/stm32u58/kernel.ld @@ -1,4 +1,4 @@ -INCLUDE "./embed/trezorhal/stm32u5/linker/u58/memory.ld"; +INCLUDE "./embed/sys/linker/stm32u58/memory.ld"; ENTRY(reset_handler) diff --git a/core/embed/trezorhal/stm32u5/linker/u58/memory.ld b/core/embed/sys/linker/stm32u58/memory.ld similarity index 100% rename from core/embed/trezorhal/stm32u5/linker/u58/memory.ld rename to core/embed/sys/linker/stm32u58/memory.ld diff --git a/core/embed/trezorhal/stm32u5/linker/u58/prodtest.ld b/core/embed/sys/linker/stm32u58/prodtest.ld similarity index 98% rename from core/embed/trezorhal/stm32u5/linker/u58/prodtest.ld rename to core/embed/sys/linker/stm32u58/prodtest.ld index 04ea031aee..79d30c5e61 100644 --- a/core/embed/trezorhal/stm32u5/linker/u58/prodtest.ld +++ b/core/embed/sys/linker/stm32u58/prodtest.ld @@ -1,4 +1,4 @@ -INCLUDE "./embed/trezorhal/stm32u5/linker/u58/memory.ld"; +INCLUDE "./embed/sys/linker/stm32u58/memory.ld"; ENTRY(reset_handler) diff --git a/core/embed/trezorhal/stm32u5/linker/u5g/boardloader.ld b/core/embed/sys/linker/stm32u5g/boardloader.ld similarity index 98% rename from core/embed/trezorhal/stm32u5/linker/u5g/boardloader.ld rename to core/embed/sys/linker/stm32u5g/boardloader.ld index 4a60939b92..1d08012ad5 100644 --- a/core/embed/trezorhal/stm32u5/linker/u5g/boardloader.ld +++ b/core/embed/sys/linker/stm32u5g/boardloader.ld @@ -1,4 +1,4 @@ -INCLUDE "./embed/trezorhal/stm32u5/linker/u5g/memory.ld"; +INCLUDE "./embed/sys/linker/stm32u5g/memory.ld"; ENTRY(reset_handler) diff --git a/core/embed/trezorhal/stm32u5/linker/u5g/bootloader.ld b/core/embed/sys/linker/stm32u5g/bootloader.ld similarity index 98% rename from core/embed/trezorhal/stm32u5/linker/u5g/bootloader.ld rename to core/embed/sys/linker/stm32u5g/bootloader.ld index c5e3fecf9a..a6f9d1314e 100644 --- a/core/embed/trezorhal/stm32u5/linker/u5g/bootloader.ld +++ b/core/embed/sys/linker/stm32u5g/bootloader.ld @@ -1,4 +1,4 @@ -INCLUDE "./embed/trezorhal/stm32u5/linker/u5g/memory.ld"; +INCLUDE "./embed/sys/linker/stm32u5g/memory.ld"; ENTRY(reset_handler) diff --git a/core/embed/trezorhal/stm32u5/linker/u5g/firmware.ld b/core/embed/sys/linker/stm32u5g/firmware.ld similarity index 97% rename from core/embed/trezorhal/stm32u5/linker/u5g/firmware.ld rename to core/embed/sys/linker/stm32u5g/firmware.ld index 5aa19afbcf..ab09e1214b 100644 --- a/core/embed/trezorhal/stm32u5/linker/u5g/firmware.ld +++ b/core/embed/sys/linker/stm32u5g/firmware.ld @@ -1,4 +1,4 @@ -INCLUDE "./embed/trezorhal/stm32u5/linker/u5g/memory.ld"; +INCLUDE "./embed/sys/linker/stm32u5g/memory.ld"; ENTRY(reset_handler) diff --git a/core/embed/trezorhal/stm32u5/linker/u5g/kernel.ld b/core/embed/sys/linker/stm32u5g/kernel.ld similarity index 98% rename from core/embed/trezorhal/stm32u5/linker/u5g/kernel.ld rename to core/embed/sys/linker/stm32u5g/kernel.ld index cdf7e71e6f..a280d2ac4d 100644 --- a/core/embed/trezorhal/stm32u5/linker/u5g/kernel.ld +++ b/core/embed/sys/linker/stm32u5g/kernel.ld @@ -1,4 +1,4 @@ -INCLUDE "./embed/trezorhal/stm32u5/linker/u5g/memory.ld"; +INCLUDE "./embed/sys/linker/stm32u5g/memory.ld"; ENTRY(reset_handler) diff --git a/core/embed/trezorhal/stm32u5/linker/u5g/memory.ld b/core/embed/sys/linker/stm32u5g/memory.ld similarity index 100% rename from core/embed/trezorhal/stm32u5/linker/u5g/memory.ld rename to core/embed/sys/linker/stm32u5g/memory.ld diff --git a/core/embed/trezorhal/stm32u5/linker/u5g/prodtest.ld b/core/embed/sys/linker/stm32u5g/prodtest.ld similarity index 98% rename from core/embed/trezorhal/stm32u5/linker/u5g/prodtest.ld rename to core/embed/sys/linker/stm32u5g/prodtest.ld index da49ff23ce..c854c1fa9b 100644 --- a/core/embed/trezorhal/stm32u5/linker/u5g/prodtest.ld +++ b/core/embed/sys/linker/stm32u5g/prodtest.ld @@ -1,4 +1,4 @@ -INCLUDE "./embed/trezorhal/stm32u5/linker/u5g/memory.ld"; +INCLUDE "./embed/sys/linker/stm32u5g/memory.ld"; ENTRY(reset_handler) diff --git a/core/embed/trezorhal/mpu.h b/core/embed/sys/mpu/inc/sys/mpu.h similarity index 100% rename from core/embed/trezorhal/mpu.h rename to core/embed/sys/mpu/inc/sys/mpu.h diff --git a/core/embed/trezorhal/stm32f4/mpu.c b/core/embed/sys/mpu/stm32f4/mpu.c similarity index 99% rename from core/embed/trezorhal/stm32f4/mpu.c rename to core/embed/sys/mpu/stm32f4/mpu.c index 073e1553d1..1bd08bb3fb 100644 --- a/core/embed/trezorhal/stm32f4/mpu.c +++ b/core/embed/sys/mpu/stm32f4/mpu.c @@ -21,9 +21,9 @@ #include #include -#include "irq.h" -#include "mpu.h" -#include "sizedefs.h" +#include +#include +#include #include "stm32f4xx_ll_cortex.h" diff --git a/core/embed/trezorhal/stm32u5/mpu.c b/core/embed/sys/mpu/stm32u5/mpu.c similarity index 99% rename from core/embed/trezorhal/stm32u5/mpu.c rename to core/embed/sys/mpu/stm32u5/mpu.c index 6e77a4ebd7..5c9b003258 100644 --- a/core/embed/trezorhal/stm32u5/mpu.c +++ b/core/embed/sys/mpu/stm32u5/mpu.c @@ -21,10 +21,10 @@ #include #include -#include "image.h" -#include "irq.h" -#include "mpu.h" -#include "sizedefs.h" +#include +#include +#include +#include #include "stm32u5xx_ll_cortex.h" diff --git a/core/embed/trezorhal/unix/mpu.c b/core/embed/sys/mpu/unix/mpu.c similarity index 97% rename from core/embed/trezorhal/unix/mpu.c rename to core/embed/sys/mpu/unix/mpu.c index e91a8fa723..5aab12dc5e 100644 --- a/core/embed/trezorhal/unix/mpu.c +++ b/core/embed/sys/mpu/unix/mpu.c @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include "mpu.h" +#include void mpu_init(void) { // MPU functions are not fully implemented in Emulator diff --git a/core/embed/trezorhal/pvd.h b/core/embed/sys/pvd/inc/sys/pvd.h similarity index 100% rename from core/embed/trezorhal/pvd.h rename to core/embed/sys/pvd/inc/sys/pvd.h diff --git a/core/embed/trezorhal/stm32f4/pvd.c b/core/embed/sys/pvd/stm32/pvd.c similarity index 96% rename from core/embed/trezorhal/stm32f4/pvd.c rename to core/embed/sys/pvd/stm32/pvd.c index 5db6c32e65..cd94df5321 100644 --- a/core/embed/trezorhal/stm32f4/pvd.c +++ b/core/embed/sys/pvd/stm32/pvd.c @@ -20,9 +20,9 @@ #include #include -#include "bootutils.h" -#include "irq.h" -#include "mpu.h" +#include +#include +#include #if defined(KERNEL_MODE) && defined(USE_PVD) diff --git a/core/embed/sys/sdram/inc/sys/sdram.h b/core/embed/sys/sdram/inc/sys/sdram.h new file mode 100644 index 0000000000..d2bbd527ce --- /dev/null +++ b/core/embed/sys/sdram/inc/sys/sdram.h @@ -0,0 +1,28 @@ +/* + * 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 . + */ + +#pragma once + +// SDRAM device address +#define SDRAM_DEVICE_ADDR 0xD0000000 +// SDRAM size in bytes +#define SDRAM_DEVICE_SIZE 0x00800000 + +// Initialize SDRAM peripheral +void sdram_init(void); diff --git a/core/embed/trezorhal/stm32f4/sdram.c b/core/embed/sys/sdram/stm32f429i-disc1/sdram_bsp.c similarity index 99% rename from core/embed/trezorhal/stm32f4/sdram.c rename to core/embed/sys/sdram/stm32f429i-disc1/sdram_bsp.c index 3cc9360f4e..04806f9591 100644 --- a/core/embed/trezorhal/stm32f4/sdram.c +++ b/core/embed/sys/sdram/stm32f429i-disc1/sdram_bsp.c @@ -19,9 +19,11 @@ #ifdef KERNEL_MODE /* Includes ------------------------------------------------------------------*/ -#include "sdram.h" -#include "irq.h" -#include "mpu.h" +#include +#include +#include + +#include "sdram_bsp.h" /** @addtogroup BSP * @{ diff --git a/core/embed/trezorhal/stm32f4/sdram.h b/core/embed/sys/sdram/stm32f429i-disc1/sdram_bsp.h similarity index 94% rename from core/embed/trezorhal/stm32f4/sdram.h rename to core/embed/sys/sdram/stm32f429i-disc1/sdram_bsp.h index 5b3fe48495..78cbeaf3db 100644 --- a/core/embed/trezorhal/stm32f4/sdram.h +++ b/core/embed/sys/sdram/stm32f429i-disc1/sdram_bsp.h @@ -58,14 +58,6 @@ extern "C" { #define SDRAM_OK ((uint8_t)0x00) #define SDRAM_ERROR ((uint8_t)0x01) -/** - * @brief FMC SDRAM Bank address - */ -#define SDRAM_DEVICE_ADDR ((uint32_t)0xD0000000) -#define SDRAM_DEVICE_SIZE \ - ((uint32_t)0x800000) /* SDRAM device size in Bytes \ - */ - /** * @brief FMC SDRAM Memory Width */ @@ -152,8 +144,6 @@ uint8_t BSP_SDRAM_WriteData_DMA(uint32_t uwStartAddress, uint32_t* pData, uint8_t BSP_SDRAM_Sendcmd(FMC_SDRAM_CommandTypeDef* SdramCmd); void BSP_SDRAM_DMA_IRQHandler(void); -void sdram_init(void); - /** * @} */ diff --git a/core/embed/trezorhal/bootargs.h b/core/embed/sys/startup/inc/sys/bootargs.h similarity index 100% rename from core/embed/trezorhal/bootargs.h rename to core/embed/sys/startup/inc/sys/bootargs.h diff --git a/core/embed/trezorhal/bootutils.h b/core/embed/sys/startup/inc/sys/bootutils.h similarity index 100% rename from core/embed/trezorhal/bootutils.h rename to core/embed/sys/startup/inc/sys/bootutils.h diff --git a/core/embed/trezorhal/reset_flags.h b/core/embed/sys/startup/inc/sys/reset_flags.h similarity index 100% rename from core/embed/trezorhal/reset_flags.h rename to core/embed/sys/startup/inc/sys/reset_flags.h diff --git a/core/embed/trezorhal/stm32f4/bootutils.c b/core/embed/sys/startup/stm32/bootutils.c similarity index 97% rename from core/embed/trezorhal/stm32f4/bootutils.c rename to core/embed/sys/startup/stm32/bootutils.c index 602aa0c23c..ed0b1a6620 100644 --- a/core/embed/trezorhal/stm32f4/bootutils.c +++ b/core/embed/sys/startup/stm32/bootutils.c @@ -21,15 +21,15 @@ #include #include -#include "bootargs.h" -#include "bootutils.h" -#include "display.h" -#include "image.h" -#include "irq.h" -#include "mpu.h" +#include +#include +#include +#include +#include +#include #ifdef TREZOR_MODEL_T -#include "stm32f4/startup_init.h" +#include "../stm32f4/startup_init.h" #endif #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/stm32f4/limited_util.S b/core/embed/sys/startup/stm32f4/limited_util.S similarity index 100% rename from core/embed/trezorhal/stm32f4/limited_util.S rename to core/embed/sys/startup/stm32f4/limited_util.S diff --git a/core/embed/trezorhal/stm32f4/reset_flags.c b/core/embed/sys/startup/stm32f4/reset_flags.c similarity index 98% rename from core/embed/trezorhal/stm32f4/reset_flags.c rename to core/embed/sys/startup/stm32f4/reset_flags.c index 2525973c89..4bce13dda1 100644 --- a/core/embed/trezorhal/stm32f4/reset_flags.c +++ b/core/embed/sys/startup/stm32f4/reset_flags.c @@ -19,7 +19,7 @@ #include -#include "reset_flags.h" +#include #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/stm32f4/startup_init.c b/core/embed/sys/startup/stm32f4/startup_init.c similarity index 99% rename from core/embed/trezorhal/stm32f4/startup_init.c rename to core/embed/sys/startup/stm32f4/startup_init.c index 7f7aae0d6d..f1f7f79e1c 100644 --- a/core/embed/trezorhal/stm32f4/startup_init.c +++ b/core/embed/sys/startup/stm32f4/startup_init.c @@ -20,10 +20,10 @@ #include #include -#include "bootutils.h" -#include "rng.h" +#include +#include +#include #include "startup_init.h" -#include "systick.h" #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/stm32f4/startup_init.h b/core/embed/sys/startup/stm32f4/startup_init.h similarity index 100% rename from core/embed/trezorhal/stm32f4/startup_init.h rename to core/embed/sys/startup/stm32f4/startup_init.h diff --git a/core/embed/trezorhal/stm32f4/startup_stage_0.s b/core/embed/sys/startup/stm32f4/startup_stage_0.s similarity index 100% rename from core/embed/trezorhal/stm32f4/startup_stage_0.s rename to core/embed/sys/startup/stm32f4/startup_stage_0.s diff --git a/core/embed/trezorhal/stm32f4/startup_stage_1.s b/core/embed/sys/startup/stm32f4/startup_stage_1.s similarity index 100% rename from core/embed/trezorhal/stm32f4/startup_stage_1.s rename to core/embed/sys/startup/stm32f4/startup_stage_1.s diff --git a/core/embed/trezorhal/stm32f4/startup_stage_2.s b/core/embed/sys/startup/stm32f4/startup_stage_2.s similarity index 100% rename from core/embed/trezorhal/stm32f4/startup_stage_2.s rename to core/embed/sys/startup/stm32f4/startup_stage_2.s diff --git a/core/embed/trezorhal/stm32f4/startup_stage_4.s b/core/embed/sys/startup/stm32f4/startup_stage_4.s similarity index 100% rename from core/embed/trezorhal/stm32f4/startup_stage_4.s rename to core/embed/sys/startup/stm32f4/startup_stage_4.s diff --git a/core/embed/trezorhal/stm32f4/util.S b/core/embed/sys/startup/stm32f4/util.S similarity index 100% rename from core/embed/trezorhal/stm32f4/util.S rename to core/embed/sys/startup/stm32f4/util.S diff --git a/core/embed/trezorhal/stm32f4/vectortable.S b/core/embed/sys/startup/stm32f4/vectortable.S similarity index 100% rename from core/embed/trezorhal/stm32f4/vectortable.S rename to core/embed/sys/startup/stm32f4/vectortable.S diff --git a/core/embed/trezorhal/stm32u5/limited_util.S b/core/embed/sys/startup/stm32u5/limited_util.S similarity index 100% rename from core/embed/trezorhal/stm32u5/limited_util.S rename to core/embed/sys/startup/stm32u5/limited_util.S diff --git a/core/embed/trezorhal/stm32u5/reset_flags.c b/core/embed/sys/startup/stm32u5/reset_flags.c similarity index 98% rename from core/embed/trezorhal/stm32u5/reset_flags.c rename to core/embed/sys/startup/stm32u5/reset_flags.c index 7649b82d8a..3cb7d00341 100644 --- a/core/embed/trezorhal/stm32u5/reset_flags.c +++ b/core/embed/sys/startup/stm32u5/reset_flags.c @@ -19,7 +19,7 @@ #include -#include "reset_flags.h" +#include #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/stm32u5/startup_init.c b/core/embed/sys/startup/stm32u5/startup_init.c similarity index 99% rename from core/embed/trezorhal/stm32u5/startup_init.c rename to core/embed/sys/startup/stm32u5/startup_init.c index a597c794ae..77a7ade96f 100644 --- a/core/embed/trezorhal/stm32u5/startup_init.c +++ b/core/embed/sys/startup/stm32u5/startup_init.c @@ -20,7 +20,7 @@ #include #include -#include "rng.h" +#include #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/stm32u5/startup_stage_0.s b/core/embed/sys/startup/stm32u5/startup_stage_0.s similarity index 100% rename from core/embed/trezorhal/stm32u5/startup_stage_0.s rename to core/embed/sys/startup/stm32u5/startup_stage_0.s diff --git a/core/embed/trezorhal/stm32u5/startup_stage_1.s b/core/embed/sys/startup/stm32u5/startup_stage_1.s similarity index 100% rename from core/embed/trezorhal/stm32u5/startup_stage_1.s rename to core/embed/sys/startup/stm32u5/startup_stage_1.s diff --git a/core/embed/trezorhal/stm32u5/startup_stage_2.s b/core/embed/sys/startup/stm32u5/startup_stage_2.s similarity index 100% rename from core/embed/trezorhal/stm32u5/startup_stage_2.s rename to core/embed/sys/startup/stm32u5/startup_stage_2.s diff --git a/core/embed/trezorhal/stm32u5/startup_stage_4.s b/core/embed/sys/startup/stm32u5/startup_stage_4.s similarity index 100% rename from core/embed/trezorhal/stm32u5/startup_stage_4.s rename to core/embed/sys/startup/stm32u5/startup_stage_4.s diff --git a/core/embed/trezorhal/stm32u5/util.S b/core/embed/sys/startup/stm32u5/util.S similarity index 100% rename from core/embed/trezorhal/stm32u5/util.S rename to core/embed/sys/startup/stm32u5/util.S diff --git a/core/embed/trezorhal/stm32u5/vectortable.S b/core/embed/sys/startup/stm32u5/vectortable.S similarity index 100% rename from core/embed/trezorhal/stm32u5/vectortable.S rename to core/embed/sys/startup/stm32u5/vectortable.S diff --git a/core/embed/trezorhal/unix/bootutils.c b/core/embed/sys/startup/unix/bootutils.c similarity index 96% rename from core/embed/trezorhal/unix/bootutils.c rename to core/embed/sys/startup/unix/bootutils.c index 69d2b11e46..b3b36e46e6 100644 --- a/core/embed/trezorhal/unix/bootutils.c +++ b/core/embed/sys/startup/unix/bootutils.c @@ -21,9 +21,9 @@ #include -#include "bootargs.h" -#include "bootutils.h" -#include "systick.h" +#include +#include +#include // Holds the 'command' for the next reboot. static boot_command_t g_boot_command; diff --git a/core/embed/sys/syscall/inc/sys/syscall.h b/core/embed/sys/syscall/inc/sys/syscall.h new file mode 100644 index 0000000000..84606e5067 --- /dev/null +++ b/core/embed/sys/syscall/inc/sys/syscall.h @@ -0,0 +1,78 @@ +/* + * 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 TREZORHAL_SYSCALL_H + +// Reserved SVC numbers +#define SVC_SYSCALL 0 +#define SVC_SYSTASK_YIELD 1 +#define SVC_CALLBACK_RETURN 2 + +#ifdef KERNEL_MODE + +// Handles all syscall requests. +// +// `args` points to an array of six 32-bit arguments. +// `syscall` is the syscall number, which is one of the `SYSCALL_XXX` constants. +// +// Input parameters are passed in `args[0]` to `args[5]`, +// and unused arguments may have undefined values. +// +// Return values must be copied to `args[0]` and +// `args[1]` (if returning a 64-bit value). +void syscall_handler(uint32_t* args, uint32_t syscall); + +// Invokes the application callback from the syscall handler. +// +// This is a *temporary* helper function used to invoke application callbacks +// from the syscall handler. It will be removed once all callback arguments +// are eliminated from syscalls. +uint32_t invoke_app_callback(uint32_t args1, uint32_t arg2, uint32_t arg3, + void* callback); + +// Internal function for returning from an application callback. +// This function is called from an unprivileged app via an SVC call. It restores +// the stack pointer and returns control to the privileged caller. +void return_from_app_callback(uint32_t retval, uint32_t* msp); + +// Invokes an unprivileged function from privileged mode. +// +// This is a *temporary* helper function used to control the STM32 SAES +// peripheral from unprivileged mode for backward compatibility (due to +// different hardware keys being used in privileged and unprivileged modes). +uint32_t invoke_unpriv(void* func); + +#endif // KERNEL_MODE + +// Returns from an unprivileged callback. +// +// Same as `invoke_unpriv`, this function should be removed once +// we resolve the issue with `secure_aes`, which needs to jump to +// unprivileged mode. + +static void inline __attribute__((no_stack_protector)) +syscall_return_from_callback(uint32_t retval) { + register uint32_t r0 __asm__("r0") = retval; + __asm__ volatile("svc %[svid]\n" + : + : [svid] "i"(SVC_CALLBACK_RETURN), "r"(r0) + : "memory"); +} + +#endif // TREZORHAL_SYSCALL_H diff --git a/core/embed/trezorhal/stm32f4/syscall.c b/core/embed/sys/syscall/stm32/syscall.c similarity index 99% rename from core/embed/trezorhal/stm32f4/syscall.c rename to core/embed/sys/syscall/stm32/syscall.c index eadac85245..f677e9cdb8 100644 --- a/core/embed/trezorhal/stm32f4/syscall.c +++ b/core/embed/sys/syscall/stm32/syscall.c @@ -17,11 +17,12 @@ * along with this program. If not, see . */ -#include "syscall.h" -#include "mpu.h" - #ifdef SYSCALL_DISPATCH +#include + +#include "syscall_internal.h" + __attribute__((naked, no_stack_protector)) static uint32_t _invoke_app_callback( uint32_t arg1, uint32_t arg2, uint32_t arg3, void *callback) { __asm__ volatile( diff --git a/core/embed/trezorhal/stm32f4/syscall_dispatch.c b/core/embed/sys/syscall/stm32/syscall_dispatch.c similarity index 96% rename from core/embed/trezorhal/stm32f4/syscall_dispatch.c rename to core/embed/sys/syscall/stm32/syscall_dispatch.c index b1312a21a0..f085089987 100644 --- a/core/embed/trezorhal/stm32f4/syscall_dispatch.c +++ b/core/embed/sys/syscall/stm32/syscall_dispatch.c @@ -17,37 +17,51 @@ * along with this program. If not, see . */ +#ifdef SYSCALL_DISPATCH + #include -#include "syscall.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "bootutils.h" -#include "button.h" -#include "display.h" -#include "entropy.h" -#include "fwutils.h" -#include "haptic.h" -#include "irq.h" -#include "mpu.h" -#include "optiga.h" -#include "rng.h" -#include "sdcard.h" -#include "secret.h" -#include "systask.h" -#include "system.h" -#include "systick.h" -#include "touch.h" -#include "translations.h" -#include "unit_properties.h" -#include "usb.h" -#include "usb_hid.h" -#include "usb_vcp.h" -#include "usb_webusb.h" +#ifdef USE_BUTTON +#include +#endif +#ifdef USE_HAPTIC +#include +#endif + +#ifdef USE_OPTIGA +#include +#endif + +#ifdef USE_SD_CARD +#include +#endif + +#ifdef USE_TOUCH +#include +#endif + +#include "syscall_internal.h" #include "syscall_verifiers.h" -#ifdef SYSCALL_DISPATCH - static PIN_UI_WAIT_CALLBACK storage_init_callback = NULL; static secbool storage_init_callback_wrapper( diff --git a/core/embed/trezorhal/stm32f4/syscall.h b/core/embed/sys/syscall/stm32/syscall_internal.h similarity index 74% rename from core/embed/trezorhal/stm32f4/syscall.h rename to core/embed/sys/syscall/stm32/syscall_internal.h index aafdbc8f3f..f069b6b680 100644 --- a/core/embed/trezorhal/stm32f4/syscall.h +++ b/core/embed/sys/syscall/stm32/syscall_internal.h @@ -17,54 +17,17 @@ * along with this program. If not, see . */ -#ifndef TREZORHAL_SYSCALL_H -#define TREZORHAL_SYSCALL_H +#ifndef TREZORHAL_SYSCALL_INTERNAL_H +#define TREZORHAL_SYSCALL_INTERNAL_H #include -#include "applet.h" +#include +#include + #include "syscall_numbers.h" -// Reserved SVC numbers -#define SVC_SYSCALL 0 -#define SVC_SYSTASK_YIELD 1 -#define SVC_CALLBACK_RETURN 2 - -#ifdef KERNEL_MODE - -// Handles all syscall requests. -// -// `args` points to an array of six 32-bit arguments. -// `syscall` is the syscall number, which is one of the `SYSCALL_XXX` constants. -// -// Input parameters are passed in `args[0]` to `args[5]`, -// and unused arguments may have undefined values. -// -// Return values must be copied to `args[0]` and -// `args[1]` (if returning a 64-bit value). -void syscall_handler(uint32_t* args, uint32_t syscall); - -// Invokes the application callback from the syscall handler. -// -// This is a *temporary* helper function used to invoke application callbacks -// from the syscall handler. It will be removed once all callback arguments -// are eliminated from syscalls. -uint32_t invoke_app_callback(uint32_t args1, uint32_t arg2, uint32_t arg3, - void* callback); - -// Internal function for returning from an application callback. -// This function is called from an unprivileged app via an SVC call. It restores -// the stack pointer and returns control to the privileged caller. -void return_from_app_callback(uint32_t retval, uint32_t* msp); - -// Invokes an unprivileged function from privileged mode. -// -// This is a *temporary* helper function used to control the STM32 SAES -// peripheral from unprivileged mode for backward compatibility (due to -// different hardware keys being used in privileged and unprivileged modes). -uint32_t invoke_unpriv(void* func); - -#else // KERNEL_MODE +#ifndef KERNEL_MODE static inline uint32_t __attribute__((no_stack_protector)) syscall_invoke0(uint32_t syscall) { @@ -208,13 +171,4 @@ syscall_invoke6(uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4, #endif // KERNEL_MODE -static inline void __attribute__((no_stack_protector)) -syscall_return_from_callback(uint32_t retval) { - register uint32_t r0 __asm__("r0") = retval; - __asm__ volatile("svc %[svid]\n" - : - : [svid] "i"(SVC_CALLBACK_RETURN), "r"(r0) - : "memory"); -} - -#endif // TREZORHAL_SYSCALL_H +#endif // TREZORHAL_SYSCALL_INTERNAL_H diff --git a/core/embed/trezorhal/stm32f4/syscall_numbers.h b/core/embed/sys/syscall/stm32/syscall_numbers.h similarity index 100% rename from core/embed/trezorhal/stm32f4/syscall_numbers.h rename to core/embed/sys/syscall/stm32/syscall_numbers.h diff --git a/core/embed/trezorhal/stm32f4/syscall_probe.c b/core/embed/sys/syscall/stm32/syscall_probe.c similarity index 98% rename from core/embed/trezorhal/stm32f4/syscall_probe.c rename to core/embed/sys/syscall/stm32/syscall_probe.c index 6194c82eef..df1172d34f 100644 --- a/core/embed/trezorhal/stm32f4/syscall_probe.c +++ b/core/embed/sys/syscall/stm32/syscall_probe.c @@ -19,7 +19,8 @@ #include -#include "applet.h" +#include + #include "syscall_probe.h" #ifdef SYSCALL_DISPATCH diff --git a/core/embed/trezorhal/stm32f4/syscall_probe.h b/core/embed/sys/syscall/stm32/syscall_probe.h similarity index 98% rename from core/embed/trezorhal/stm32f4/syscall_probe.h rename to core/embed/sys/syscall/stm32/syscall_probe.h index f026d7e12c..8ad1dae976 100644 --- a/core/embed/trezorhal/stm32f4/syscall_probe.h +++ b/core/embed/sys/syscall/stm32/syscall_probe.h @@ -22,7 +22,7 @@ #include -#include "system.h" +#include #ifdef SYSCALL_DISPATCH diff --git a/core/embed/trezorhal/stm32f4/syscall_stubs.c b/core/embed/sys/syscall/stm32/syscall_stubs.c similarity index 96% rename from core/embed/trezorhal/stm32f4/syscall_stubs.c rename to core/embed/sys/syscall/stm32/syscall_stubs.c index fb23a4ff44..614b02378d 100644 --- a/core/embed/trezorhal/stm32f4/syscall_stubs.c +++ b/core/embed/sys/syscall/stm32/syscall_stubs.c @@ -17,15 +17,15 @@ * along with this program. If not, see . */ -#include "syscall.h" - #ifndef KERNEL_MODE +#include "syscall_internal.h" + // ============================================================================= // system.h // ============================================================================= -#include "system.h" +#include void system_exit(int exit_code) { syscall_invoke1(exit_code, SYSCALL_SYSTEM_EXIT); @@ -54,7 +54,7 @@ void system_exit_fatal_ex(const char *message, size_t message_len, // systick.h // ============================================================================= -#include "systick.h" +#include uint64_t __attribute__((no_stack_protector)) systick_cycles(void) { return syscall_invoke0_ret64(SYSCALL_SYSTICK_CYCLES); @@ -74,7 +74,7 @@ uint64_t systick_us_to_cycles(uint64_t us) { // bootutils.h // ============================================================================= -#include "bootutils.h" +#include void secure_shutdown(void) { syscall_invoke0(SYSCALL_SECURE_SHUTDOWN); @@ -104,7 +104,7 @@ void reboot_device(void) { // display.h // ============================================================================= -#include "display.h" +#include int display_set_backlight(int level) { return (int)syscall_invoke1((uint32_t)level, SYSCALL_DISPLAY_SET_BACKLIGHT); @@ -150,7 +150,7 @@ void display_refresh(void) { syscall_invoke0(SYSCALL_DISPLAY_REFRESH); } // usb.h // ============================================================================= -#include "usb.h" +#include secbool usb_init(const usb_dev_info_t *dev_info) { return (secbool)syscall_invoke1((uint32_t)dev_info, SYSCALL_USB_INIT); @@ -170,7 +170,7 @@ secbool usb_configured(void) { // usb_hid.h // ============================================================================= -#include "usb_hid.h" +#include secbool usb_hid_add(const usb_hid_info_t *hid_info) { return (secbool)syscall_invoke1((uint32_t)hid_info, SYSCALL_USB_HID_ADD); @@ -216,7 +216,7 @@ int usb_hid_write_blocking(uint8_t iface_num, const uint8_t *buf, uint32_t len, // usb_vcp.h // ============================================================================= -#include "usb_vcp.h" +#include secbool usb_vcp_add(const usb_vcp_info_t *vcp_info) { return (secbool)syscall_invoke1((uint32_t)vcp_info, SYSCALL_USB_VCP_ADD); @@ -258,7 +258,7 @@ int usb_vcp_write_blocking(uint8_t iface_num, const uint8_t *buf, uint32_t len, // usb_webusb.h // ============================================================================= -#include "usb_webusb.h" +#include secbool usb_webusb_add(const usb_webusb_info_t *webusb_info) { return (secbool)syscall_invoke1((uint32_t)webusb_info, @@ -305,7 +305,9 @@ int usb_webusb_write_blocking(uint8_t iface_num, const uint8_t *buf, // sdcard.h // ============================================================================= -#include "sdcard.h" +#ifdef USE_SD_CARD + +#include secbool sdcard_power_on(void) { return (secbool)syscall_invoke0(SYSCALL_SDCARD_POWER_ON); @@ -333,11 +335,13 @@ secbool __wur sdcard_write_blocks(const uint32_t *src, uint32_t block_num, SYSCALL_SDCARD_WRITE_BLOCKS); } +#endif // USE_SD_CARD + // ============================================================================= // unit_properties.h // ============================================================================= -#include "unit_properties.h" +#include void unit_properties_get(unit_properties_t *props) { syscall_invoke1((uint32_t)props, SYSCALL_UNIT_PROPERTIES_GET); @@ -347,7 +351,7 @@ void unit_properties_get(unit_properties_t *props) { // secret.h // ============================================================================= -#include "secret.h" +#include secbool secret_bootloader_locked(void) { return (secbool)syscall_invoke0(SYSCALL_SECRET_BOOTLOADER_LOCKED); @@ -357,27 +361,37 @@ secbool secret_bootloader_locked(void) { // button.h // ============================================================================= -#include "button.h" +#ifdef USE_BUTTON + +#include uint32_t button_get_event(void) { return syscall_invoke0(SYSCALL_BUTTON_GET_EVENT); } +#endif + // ============================================================================= // touch.h // ============================================================================= -#include "touch.h" +#ifdef USE_TOUCH + +#include uint32_t touch_get_event(void) { return syscall_invoke0(SYSCALL_TOUCH_GET_EVENT); } +#endif + // ============================================================================= // haptic.h // ============================================================================= -#include "haptic.h" +#ifdef USE_HAPTIC + +#include void haptic_set_enabled(bool enabled) { syscall_invoke1((uint32_t)enabled, SYSCALL_HAPTIC_SET_ENABLED); @@ -400,11 +414,15 @@ bool haptic_play_custom(int8_t amplitude_pct, uint16_t duration_ms) { SYSCALL_HAPTIC_PLAY_CUSTOM); } +#endif // USE_HAPTIC + // ============================================================================= // optiga.h // ============================================================================= -#include "optiga.h" +#ifdef USE_OPTIGA + +#include optiga_sign_result optiga_sign(uint8_t index, const uint8_t *digest, size_t digest_size, uint8_t *signature, @@ -439,6 +457,8 @@ void optiga_set_sec_max(void) { syscall_invoke0(SYSCALL_OPTIGA_SET_SEC_MAX); } #endif +#endif // USE_OPTIGA + // ============================================================================= // storage.h // ============================================================================= @@ -551,7 +571,7 @@ void entropy_get(uint8_t *buf) { // translations.h // ============================================================================= -#include "translations.h" +#include bool translations_write(const uint8_t *data, uint32_t offset, uint32_t len) { return (bool)syscall_invoke3((uint32_t)data, offset, len, @@ -573,7 +593,7 @@ uint32_t translations_area_bytesize(void) { // rng.h // ============================================================================= -#include "rng.h" +#include uint32_t rng_get(void) { return syscall_invoke0(SYSCALL_RNG_GET); } @@ -581,7 +601,7 @@ uint32_t rng_get(void) { return syscall_invoke0(SYSCALL_RNG_GET); } // fwutils.h // ============================================================================= -#include "fwutils.h" +#include secbool firmware_get_vendor(char *buff, size_t buff_size) { return syscall_invoke2((uint32_t)buff, buff_size, @@ -607,4 +627,5 @@ secbool firmware_calc_hash(const uint8_t *challenge, size_t challenge_len, (uint32_t)callback_context, SYSCALL_FIRMWARE_CALC_HASH); } -#endif + +#endif // KERNEL_MODE diff --git a/core/embed/trezorhal/stm32f4/syscall_verifiers.c b/core/embed/sys/syscall/stm32/syscall_verifiers.c similarity index 99% rename from core/embed/trezorhal/stm32f4/syscall_verifiers.c rename to core/embed/sys/syscall/stm32/syscall_verifiers.c index 2f95a4d93e..2f975a638b 100644 --- a/core/embed/trezorhal/stm32f4/syscall_verifiers.c +++ b/core/embed/sys/syscall/stm32/syscall_verifiers.c @@ -19,9 +19,10 @@ #include +#include + #include "syscall_probe.h" #include "syscall_verifiers.h" -#include "systask.h" #ifdef SYSCALL_DISPATCH @@ -351,6 +352,8 @@ access_violation: // --------------------------------------------------------------------- +#ifdef USE_SD_CARD + secbool __wur sdcard_read_blocks__verified(uint32_t *dest, uint32_t block_num, uint32_t num_blocks) { if (num_blocks >= (UINT32_MAX / SDCARD_BLOCK_SIZE)) { @@ -386,6 +389,8 @@ access_violation: return secfalse; } +#endif // USE_SD_CARD + // --------------------------------------------------------------------- void unit_properties_get__verified(unit_properties_t *props) { @@ -403,6 +408,8 @@ access_violation: // --------------------------------------------------------------------- +#ifdef USE_OPTIGA + optiga_sign_result __wur optiga_sign__verified( uint8_t index, const uint8_t *digest, size_t digest_size, uint8_t *signature, size_t max_sig_size, size_t *sig_size) { @@ -479,6 +486,8 @@ access_violation: return false; } +#endif // USE_OPTIGA + // --------------------------------------------------------------------- void storage_init__verified(PIN_UI_WAIT_CALLBACK callback, const uint8_t *salt, diff --git a/core/embed/trezorhal/stm32f4/syscall_verifiers.h b/core/embed/sys/syscall/stm32/syscall_verifiers.h similarity index 94% rename from core/embed/trezorhal/stm32f4/syscall_verifiers.h rename to core/embed/sys/syscall/stm32/syscall_verifiers.h index 4e7c959291..2cb4d323dd 100644 --- a/core/embed/trezorhal/stm32f4/syscall_verifiers.h +++ b/core/embed/sys/syscall/stm32/syscall_verifiers.h @@ -23,7 +23,7 @@ #ifdef SYSCALL_DISPATCH // --------------------------------------------------------------------- -#include "systask.h" +#include void system_exit__verified(int exit_code); @@ -35,12 +35,12 @@ void system_exit_fatal__verified(const char *message, size_t message_len, const char *file, size_t file_len, int line); // --------------------------------------------------------------------- -#include "bootutils.h" +#include void reboot_and_upgrade__verified(const uint8_t hash[32]); // --------------------------------------------------------------------- -#include "display.h" +#include #ifdef FRAMEBUFFER bool display_get_frame_buffer__verified(display_fb_info_t *fb); @@ -51,7 +51,7 @@ void display_fill__verified(const gfx_bitblt_t *bb); void display_copy_rgb565__verified(const gfx_bitblt_t *bb); // --------------------------------------------------------------------- -#include "usb_hid.h" +#include int usb_hid_read__verified(uint8_t iface_num, uint8_t *buf, uint32_t len); @@ -64,7 +64,7 @@ int usb_hid_write_blocking__verified(uint8_t iface_num, const uint8_t *buf, uint32_t len, int timeout); // --------------------------------------------------------------------- -#include "usb_vcp.h" +#include int usb_vcp_read__verified(uint8_t iface_num, uint8_t *buf, uint32_t len); @@ -77,7 +77,7 @@ int usb_vcp_write_blocking__verified(uint8_t iface_num, const uint8_t *buf, uint32_t len, int timeout); // --------------------------------------------------------------------- -#include "usb_webusb.h" +#include int usb_webusb_read__verified(uint8_t iface_num, uint8_t *buf, uint32_t len); @@ -90,7 +90,10 @@ int usb_webusb_write_blocking__verified(uint8_t iface_num, const uint8_t *buf, uint32_t len, int timeout); // --------------------------------------------------------------------- -#include "sdcard.h" + +#ifdef USE_SD_CARD + +#include secbool __wur sdcard_read_blocks__verified(uint32_t *dest, uint32_t block_num, uint32_t num_blocks); @@ -99,13 +102,17 @@ secbool __wur sdcard_write_blocks__verified(const uint32_t *src, uint32_t block_num, uint32_t num_blocks); +#endif // USE_SD_CARD + // --------------------------------------------------------------------- -#include "unit_properties.h" +#include void unit_properties_get__verified(unit_properties_t *props); // --------------------------------------------------------------------- -#include "optiga.h" +#ifdef USE_OPTIGA + +#include optiga_sign_result __wur optiga_sign__verified( uint8_t index, const uint8_t *digest, size_t digest_size, @@ -120,6 +127,8 @@ bool __wur optiga_read_sec__verified(uint8_t *sec); bool __wur optiga_random_buffer__verified(uint8_t *dest, size_t size); +#endif // USE_OPTIGA + // --------------------------------------------------------------------- #include "storage.h" @@ -150,7 +159,7 @@ secbool storage_set__verified(const uint16_t key, const void *val, secbool storage_next_counter__verified(const uint16_t key, uint32_t *count); // --------------------------------------------------------------------- -#include "translations.h" +#include bool translations_write__verified(const uint8_t *data, uint32_t offset, uint32_t len); @@ -158,12 +167,12 @@ bool translations_write__verified(const uint8_t *data, uint32_t offset, const uint8_t *translations_read__verified(uint32_t *len, uint32_t offset); // --------------------------------------------------------------------- -#include "entropy.h" +#include void entropy_get__verified(uint8_t *buf); // --------------------------------------------------------------------- -#include "fwutils.h" +#include secbool firmware_calc_hash__verified(const uint8_t *challenge, size_t challenge_len, uint8_t *hash, diff --git a/core/embed/firmware/systemview.h b/core/embed/sys/systemview/inc/sys/systemview.h similarity index 88% rename from core/embed/firmware/systemview.h rename to core/embed/sys/systemview/inc/sys/systemview.h index e4e3b5ee14..b6a3ad34c5 100644 --- a/core/embed/firmware/systemview.h +++ b/core/embed/sys/systemview/inc/sys/systemview.h @@ -21,15 +21,8 @@ #ifndef CORE_SYSTEMVIEW_H #define CORE_SYSTEMVIEW_H -#ifdef SYSTEM_VIEW - #include "SEGGER_SYSVIEW.h" void enable_systemview(void); -#else -#define SEGGER_SYSVIEW_RecordEnterISR() -#define SEGGER_SYSVIEW_RecordExitISR() -#endif - #endif // CORE_SYSTEMVIEW_H diff --git a/core/embed/segger/Config/SEGGER_RTT_Conf.h b/core/embed/sys/systemview/stm32/config/SEGGER_RTT_Conf.h similarity index 100% rename from core/embed/segger/Config/SEGGER_RTT_Conf.h rename to core/embed/sys/systemview/stm32/config/SEGGER_RTT_Conf.h diff --git a/core/embed/segger/Config/SEGGER_SYSVIEW_Conf.h b/core/embed/sys/systemview/stm32/config/SEGGER_SYSVIEW_Conf.h similarity index 100% rename from core/embed/segger/Config/SEGGER_SYSVIEW_Conf.h rename to core/embed/sys/systemview/stm32/config/SEGGER_SYSVIEW_Conf.h diff --git a/core/embed/segger/Config/SEGGER_SYSVIEW_Config_NoOS.c b/core/embed/sys/systemview/stm32/config/SEGGER_SYSVIEW_Config_NoOS.c similarity index 100% rename from core/embed/segger/Config/SEGGER_SYSVIEW_Config_NoOS.c rename to core/embed/sys/systemview/stm32/config/SEGGER_SYSVIEW_Config_NoOS.c diff --git a/core/embed/segger/Config/Global.h b/core/embed/sys/systemview/stm32/segger/Global.h similarity index 100% rename from core/embed/segger/Config/Global.h rename to core/embed/sys/systemview/stm32/segger/Global.h diff --git a/core/embed/segger/SEGGER/SEGGER.h b/core/embed/sys/systemview/stm32/segger/SEGGER.h similarity index 100% rename from core/embed/segger/SEGGER/SEGGER.h rename to core/embed/sys/systemview/stm32/segger/SEGGER.h diff --git a/core/embed/segger/SEGGER/SEGGER_RTT.c b/core/embed/sys/systemview/stm32/segger/SEGGER_RTT.c similarity index 100% rename from core/embed/segger/SEGGER/SEGGER_RTT.c rename to core/embed/sys/systemview/stm32/segger/SEGGER_RTT.c diff --git a/core/embed/segger/SEGGER/SEGGER_RTT.h b/core/embed/sys/systemview/stm32/segger/SEGGER_RTT.h similarity index 100% rename from core/embed/segger/SEGGER/SEGGER_RTT.h rename to core/embed/sys/systemview/stm32/segger/SEGGER_RTT.h diff --git a/core/embed/segger/SEGGER/SEGGER_RTT_ASM_ARMv7M.S b/core/embed/sys/systemview/stm32/segger/SEGGER_RTT_ASM_ARMv7M.S similarity index 100% rename from core/embed/segger/SEGGER/SEGGER_RTT_ASM_ARMv7M.S rename to core/embed/sys/systemview/stm32/segger/SEGGER_RTT_ASM_ARMv7M.S diff --git a/core/embed/segger/SEGGER/SEGGER_RTT_printf.c b/core/embed/sys/systemview/stm32/segger/SEGGER_RTT_printf.c similarity index 100% rename from core/embed/segger/SEGGER/SEGGER_RTT_printf.c rename to core/embed/sys/systemview/stm32/segger/SEGGER_RTT_printf.c diff --git a/core/embed/segger/SEGGER/SEGGER_SYSVIEW.c b/core/embed/sys/systemview/stm32/segger/SEGGER_SYSVIEW.c similarity index 100% rename from core/embed/segger/SEGGER/SEGGER_SYSVIEW.c rename to core/embed/sys/systemview/stm32/segger/SEGGER_SYSVIEW.c diff --git a/core/embed/segger/SEGGER/SEGGER_SYSVIEW.h b/core/embed/sys/systemview/stm32/segger/SEGGER_SYSVIEW.h similarity index 100% rename from core/embed/segger/SEGGER/SEGGER_SYSVIEW.h rename to core/embed/sys/systemview/stm32/segger/SEGGER_SYSVIEW.h diff --git a/core/embed/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h b/core/embed/sys/systemview/stm32/segger/SEGGER_SYSVIEW_ConfDefaults.h similarity index 100% rename from core/embed/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h rename to core/embed/sys/systemview/stm32/segger/SEGGER_SYSVIEW_ConfDefaults.h diff --git a/core/embed/segger/SEGGER/SEGGER_SYSVIEW_Int.h b/core/embed/sys/systemview/stm32/segger/SEGGER_SYSVIEW_Int.h similarity index 100% rename from core/embed/segger/SEGGER/SEGGER_SYSVIEW_Int.h rename to core/embed/sys/systemview/stm32/segger/SEGGER_SYSVIEW_Int.h diff --git a/core/embed/segger/SEGGER/Syscalls/SEGGER_RTT_Syscalls_GCC.c b/core/embed/sys/systemview/stm32/segger/Syscalls/SEGGER_RTT_Syscalls_GCC.c similarity index 100% rename from core/embed/segger/SEGGER/Syscalls/SEGGER_RTT_Syscalls_GCC.c rename to core/embed/sys/systemview/stm32/segger/Syscalls/SEGGER_RTT_Syscalls_GCC.c diff --git a/core/embed/firmware/systemview.c b/core/embed/sys/systemview/systemview.c similarity index 98% rename from core/embed/firmware/systemview.c rename to core/embed/sys/systemview/systemview.c index ca171d6569..9c931bceae 100644 --- a/core/embed/firmware/systemview.c +++ b/core/embed/sys/systemview/systemview.c @@ -21,8 +21,8 @@ #include +#include #include "mpconfigport.h" -#include "systemview.h" #include "SEGGER_SYSVIEW.h" #include "SEGGER_SYSVIEW_Conf.h" diff --git a/core/embed/trezorhal/tamper.h b/core/embed/sys/tamper/inc/sys/tamper.h similarity index 100% rename from core/embed/trezorhal/tamper.h rename to core/embed/sys/tamper/inc/sys/tamper.h diff --git a/core/embed/trezorhal/stm32u5/tamper.c b/core/embed/sys/tamper/stm32u5/tamper.c similarity index 99% rename from core/embed/trezorhal/stm32u5/tamper.c rename to core/embed/sys/tamper/stm32u5/tamper.c index ec02ef09f2..880eecb646 100644 --- a/core/embed/trezorhal/stm32u5/tamper.c +++ b/core/embed/sys/tamper/stm32u5/tamper.c @@ -20,9 +20,9 @@ #include #include -#include -#include -#include +#include +#include +#include #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/applet.h b/core/embed/sys/task/inc/sys/applet.h similarity index 99% rename from core/embed/trezorhal/applet.h rename to core/embed/sys/task/inc/sys/applet.h index a7fc04f887..7f924d8010 100644 --- a/core/embed/trezorhal/applet.h +++ b/core/embed/sys/task/inc/sys/applet.h @@ -24,7 +24,7 @@ #ifdef SYSCALL_DISPATCH -#include "systask.h" +#include // Applet entry point typedef void (*applet_startup_t)(const char* args, uint32_t random); diff --git a/core/embed/trezorhal/systask.h b/core/embed/sys/task/inc/sys/systask.h similarity index 99% rename from core/embed/trezorhal/systask.h rename to core/embed/sys/task/inc/sys/systask.h index b830fa4da8..ef0f39eeb8 100644 --- a/core/embed/trezorhal/systask.h +++ b/core/embed/sys/task/inc/sys/systask.h @@ -22,7 +22,7 @@ #include -#include "mpu.h" +#include // Termination reason for the task typedef enum { diff --git a/core/embed/trezorhal/system.h b/core/embed/sys/task/inc/sys/system.h similarity index 99% rename from core/embed/trezorhal/system.h rename to core/embed/sys/task/inc/sys/system.h index 5c952c1bff..a758bacd95 100644 --- a/core/embed/trezorhal/system.h +++ b/core/embed/sys/task/inc/sys/system.h @@ -20,7 +20,7 @@ #ifndef TREZORHAL_SYSTEM_H #define TREZORHAL_SYSTEM_H -#include +#include #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/stm32f4/applet.c b/core/embed/sys/task/stm32/applet.c similarity index 94% rename from core/embed/trezorhal/stm32f4/applet.c rename to core/embed/sys/task/stm32/applet.c index 8945e8a993..47f7621c06 100644 --- a/core/embed/trezorhal/stm32f4/applet.c +++ b/core/embed/sys/task/stm32/applet.c @@ -19,12 +19,15 @@ #include -#include "applet.h" -#include "display.h" -#include "mpu.h" -#include "rng.h" -#include "systask.h" -#include "trustzone.h" +#include +#include +#include +#include +#include + +#ifdef USE_TRUSTZONE +#include +#endif #ifdef SYSCALL_DISPATCH diff --git a/core/embed/trezorhal/stm32f4/systask.c b/core/embed/sys/task/stm32/systask.c similarity index 98% rename from core/embed/trezorhal/stm32f4/systask.c rename to core/embed/sys/task/stm32/systask.c index 720ce6eada..a6bb7a0bf8 100644 --- a/core/embed/trezorhal/stm32f4/systask.c +++ b/core/embed/sys/task/stm32/systask.c @@ -20,13 +20,12 @@ #include #include -#include "bootutils.h" -#include "irq.h" -#include "mpu.h" -#include "syscall.h" -#include "systask.h" -#include "system.h" -#include "systemview.h" +#include +#include +#include +#include +#include +#include #ifdef KERNEL_MODE @@ -345,7 +344,7 @@ __attribute((no_stack_protector, used)) static uint32_t scheduler_pendsv( uint32_t sp, uint32_t sp_lim, uint32_t exc_return) { systask_scheduler_t* scheduler = &g_systask_scheduler; - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); // Save the current task context systask_t* prev_task = scheduler->active_task; @@ -375,7 +374,7 @@ __attribute((no_stack_protector, used)) static uint32_t scheduler_pendsv( // Setup the MPU for the new task mpu_reconfig(next_task->mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + IRQ_LOG_EXIT(); return (uint32_t)next_task; } @@ -472,7 +471,7 @@ __attribute__((naked, no_stack_protector)) void PendSV_Handler(void) { __attribute__((no_stack_protector, used)) static uint32_t svc_handler( uint32_t* stack, uint32_t* msp, uint32_t exc_return, uint32_t r4, uint32_t r5, uint32_t r6) { - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); uint8_t svc_number = ((uint8_t*)stack[6])[-2]; @@ -505,7 +504,9 @@ __attribute__((no_stack_protector, used)) static uint32_t svc_handler( } mpu_restore(mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + + IRQ_LOG_EXIT(); + return exc_return; } diff --git a/core/embed/trezorhal/stm32f4/system.c b/core/embed/sys/task/stm32/system.c similarity index 97% rename from core/embed/trezorhal/stm32f4/system.c rename to core/embed/sys/task/stm32/system.c index 1d44175dbd..9c860e0e6a 100644 --- a/core/embed/trezorhal/stm32f4/system.c +++ b/core/embed/sys/task/stm32/system.c @@ -20,15 +20,19 @@ #include #include -#include "bootutils.h" -#include "mpu.h" -#include "systask.h" -#include "system.h" -#include "systick.h" -#include "systimer.h" +#include +#include +#include +#include +#include +#include + +#ifdef USE_SDRAM +#include +#endif #if defined(TREZOR_MODEL_T) && (!defined(BOARDLOADER)) -#include "startup_init.h" +#include "../stm32f4/startup_init.h" #endif #ifndef HardFault_IRQn @@ -42,6 +46,9 @@ void system_init(systask_error_handler_t error_handler) { // Early boardloader versions on Model T initialized the CPU clock to 168MHz. // We need to set it to the STM32F429's maximum - 180MHz. set_core_clock(CLOCK_180_MHZ); +#endif +#ifdef USE_SDRAM + sdram_init(); #endif mpu_init(); mpu_reconfig(MPU_MODE_DEFAULT); diff --git a/core/embed/trezorhal/unix/system.c b/core/embed/sys/task/unix/system.c similarity index 97% rename from core/embed/trezorhal/unix/system.c rename to core/embed/sys/task/unix/system.c index eab9d53b82..a7df50e917 100644 --- a/core/embed/trezorhal/unix/system.c +++ b/core/embed/sys/task/unix/system.c @@ -21,10 +21,10 @@ #include -#include "bootutils.h" -#include "system.h" -#include "systick.h" -#include "systimer.h" +#include +#include +#include +#include systask_error_handler_t g_error_handler = NULL; diff --git a/core/embed/trezorhal/systick.h b/core/embed/sys/time/inc/sys/systick.h similarity index 100% rename from core/embed/trezorhal/systick.h rename to core/embed/sys/time/inc/sys/systick.h diff --git a/core/embed/trezorhal/systimer.h b/core/embed/sys/time/inc/sys/systimer.h similarity index 100% rename from core/embed/trezorhal/systimer.h rename to core/embed/sys/time/inc/sys/systimer.h diff --git a/core/embed/trezorhal/stm32f4/systick.c b/core/embed/sys/time/stm32/systick.c similarity index 97% rename from core/embed/trezorhal/stm32f4/systick.c rename to core/embed/sys/time/stm32/systick.c index 790949fbab..8ef897dd97 100644 --- a/core/embed/trezorhal/stm32f4/systick.c +++ b/core/embed/sys/time/stm32/systick.c @@ -19,13 +19,11 @@ #include -#include "irq.h" -#include "mpu.h" -#include "systemview.h" - -#include "systick.h" +#include +#include +#include +#include #include "systick_internal.h" -#include "systimer.h" #ifdef KERNEL_MODE @@ -158,7 +156,8 @@ uint64_t systick_us(void) { } void SysTick_Handler(void) { - SEGGER_SYSVIEW_RecordEnterISR(); + IRQ_LOG_ENTER(); + mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); systick_driver_t* drv = &g_systick_driver; @@ -181,7 +180,8 @@ void SysTick_Handler(void) { } mpu_restore(mpu_mode); - SEGGER_SYSVIEW_RecordExitISR(); + + IRQ_LOG_EXIT(); } #endif // KERNEL_MODE diff --git a/core/embed/trezorhal/stm32f4/systick_internal.h b/core/embed/sys/time/stm32/systick_internal.h similarity index 92% rename from core/embed/trezorhal/stm32f4/systick_internal.h rename to core/embed/sys/time/stm32/systick_internal.h index 1b98fe196e..f79cb6b61d 100644 --- a/core/embed/trezorhal/stm32f4/systick_internal.h +++ b/core/embed/sys/time/stm32/systick_internal.h @@ -3,7 +3,7 @@ #include -#include "systick.h" +#include // Internal function called from interrupt context. // Handles expired timers and invoked their callbacks. diff --git a/core/embed/trezorhal/stm32f4/systimer.c b/core/embed/sys/time/stm32/systimer.c similarity index 99% rename from core/embed/trezorhal/stm32f4/systimer.c rename to core/embed/sys/time/stm32/systimer.c index f1215e6b76..d5a2e32b30 100644 --- a/core/embed/trezorhal/stm32f4/systimer.c +++ b/core/embed/sys/time/stm32/systimer.c @@ -19,9 +19,9 @@ #include -#include "irq.h" +#include +#include #include "systick_internal.h" -#include "systimer.h" #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/unix/systick.c b/core/embed/sys/time/unix/systick.c similarity index 99% rename from core/embed/trezorhal/unix/systick.c rename to core/embed/sys/time/unix/systick.c index 923ea435b6..678f005a16 100644 --- a/core/embed/trezorhal/unix/systick.c +++ b/core/embed/sys/time/unix/systick.c @@ -22,7 +22,7 @@ #include #include -#include "systick.h" +#include // Systick driver state typedef struct { diff --git a/core/embed/trezorhal/unix/systimer.c b/core/embed/sys/time/unix/systimer.c similarity index 98% rename from core/embed/trezorhal/unix/systimer.c rename to core/embed/sys/time/unix/systimer.c index 6f56cc0327..614dca03da 100644 --- a/core/embed/trezorhal/unix/systimer.c +++ b/core/embed/sys/time/unix/systimer.c @@ -19,7 +19,7 @@ #include -#include "systimer.h" +#include // systimer driver state typedef struct { diff --git a/core/embed/trezorhal/trustzone.h b/core/embed/sys/trustzone/inc/sys/trustzone.h similarity index 100% rename from core/embed/trezorhal/trustzone.h rename to core/embed/sys/trustzone/inc/sys/trustzone.h diff --git a/core/embed/trezorhal/stm32u5/trustzone.c b/core/embed/sys/trustzone/stm32u5/trustzone.c similarity index 99% rename from core/embed/trezorhal/stm32u5/trustzone.c rename to core/embed/sys/trustzone/stm32u5/trustzone.c index ba766eb247..ac7747efb7 100644 --- a/core/embed/trezorhal/stm32u5/trustzone.c +++ b/core/embed/sys/trustzone/stm32u5/trustzone.c @@ -21,10 +21,10 @@ #include #include -#include "image.h" -#include "irq.h" -#include "sizedefs.h" -#include "trustzone.h" +#include +#include +#include +#include #define SAU_INIT_CTRL_ENABLE 1 #define SAU_INIT_CTRL_ALLNS 0 diff --git a/core/embed/trezorhal/stm32f4/systemview.h b/core/embed/trezorhal/stm32f4/systemview.h deleted file mode 120000 index fda5c909e7..0000000000 --- a/core/embed/trezorhal/stm32f4/systemview.h +++ /dev/null @@ -1 +0,0 @@ -../../firmware/systemview.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32f4/xdisplay/ug-2828/display_driver.c b/core/embed/trezorhal/stm32f4/xdisplay/ug-2828/display_driver.c deleted file mode 100644 index d90c003052..0000000000 --- a/core/embed/trezorhal/stm32f4/xdisplay/ug-2828/display_driver.c +++ /dev/null @@ -1,454 +0,0 @@ -/* - * 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 . - */ - -#include -#include - -#include "display.h" -#include "mpu.h" - -#if (DISPLAY_RESX != 128) || (DISPLAY_RESY != 128) -#error "Incompatible display resolution" -#endif - -// This file implements display driver for monochromatic display V-2864KSWEG01 -// with 128x128 resolution connected to CPU via SPI interface. -// -// This type of displayed was used on some preliminary dev kits for T3T1 (Trezor -// TS3) - -#define FRAME_BUFFER_SIZE (DISPLAY_RESX * DISPLAY_RESY) - -__attribute__((section(".fb1"))) uint8_t g_framebuf[FRAME_BUFFER_SIZE]; - -// Display driver context. -typedef struct { - // Set if the driver is initialized - bool initialized; - // Frame buffer (8-bit Mono) - uint8_t *framebuf; - // Current display orientation (0 or 180) - int orientation_angle; - // Current backlight level ranging from 0 to 255 - int backlight_level; -} display_driver_t; - -// Display driver instance -static display_driver_t g_display_driver = { - .initialized = false, -}; - -// Macros to access display parallel interface - -// FSMC/FMC Bank 1 - NOR/PSRAM 1 -#define DISPLAY_MEMORY_BASE 0x60000000 -#define DISPLAY_MEMORY_PIN 16 - -#define CMD_ADDR *((__IO uint8_t *)((uint32_t)(DISPLAY_MEMORY_BASE))) -#define DATA_ADDR \ - (*((__IO uint8_t *)((uint32_t)(DISPLAY_MEMORY_BASE | \ - (1 << DISPLAY_MEMORY_PIN))))) - -#define ISSUE_CMD_BYTE(X) \ - do { \ - (CMD_ADDR) = (X); \ - } while (0) -#define ISSUE_DATA_BYTE(X) \ - do { \ - (DATA_ADDR) = (X); \ - } while (0) - -// --------------------------------------------------------------------------- -// Display controller registers -// --------------------------------------------------------------------------- - -#define OLED_SETCONTRAST 0x81 -#define OLED_DISPLAYALLON_RESUME 0xA4 -#define OLED_DISPLAYALLON 0xA5 -#define OLED_NORMALDISPLAY 0xA6 -#define OLED_INVERTDISPLAY 0xA7 -#define OLED_DISPLAYOFF 0xAE -#define OLED_DISPLAYON 0xAF -#define OLED_SETDISPLAYOFFSET 0xD3 -#define OLED_SETCOMPINS 0xDA -#define OLED_SETVCOMDETECT 0xDB -#define OLED_SETDISPLAYCLOCKDIV 0xD5 -#define OLED_SETPRECHARGE 0xD9 -#define OLED_SETMULTIPLEX 0xA8 -#define OLED_SETLOWCOLUMN 0x00 -#define OLED_SETHIGHCOLUMN 0x10 -#define OLED_SETSTARTLINE 0x40 -#define OLED_MEMORYMODE 0x20 -#define OLED_COMSCANINC 0xC0 -#define OLED_COMSCANDEC 0xC8 -#define OLED_SEGREMAP 0xA0 -#define OLED_CHARGEPUMP 0x8D - -// Dipslay specific initialization sequence -static const uint8_t ug_2828tswig01_init_seq[] = { - OLED_DISPLAYOFF, - // Divide ratio 0, Oscillator Frequency +0% - OLED_SETDISPLAYCLOCKDIV, 0x50, - // Set Memory Addressing Mode - page addressing mode - 0x20, - // Set Contrast Control Register - OLED_SETCONTRAST, 0x8F, - // Set DC-DC Setting: (Double Bytes Command) - 0xAD, 0x8A, - // Set Segment Re-map - OLED_SEGREMAP | 0x01, - // Set COM Output Scan Direction - OLED_COMSCANDEC, - // Set Display Start Line:(Double Bytes Command) - 0xDC, 0x00, - // Set Display Offset:(Double Bytes Command) - OLED_SETDISPLAYOFFSET, 0x00, - // Set Discharge / Pre-Charge Period (Double Bytes Command) - OLED_SETPRECHARGE, 0x22, - // Set VCOM Deselect Level - OLED_SETVCOMDETECT, 0x35, - // Set Multiplex Ratio - OLED_SETMULTIPLEX, 0x7F, - // Set Page - 0xB0, - // Reset column - OLED_SETLOWCOLUMN | 0, OLED_SETHIGHCOLUMN | 0, - - // Set Entire Display Off - // to be clear, this command turns off the function - // which turns entire display on, but it does not clear - // the data in display RAM - OLED_DISPLAYALLON_RESUME, - // Set Normal Display - OLED_NORMALDISPLAY}; - -static void __attribute__((unused)) display_sleep(void) { - // Display OFF - ISSUE_CMD_BYTE(OLED_DISPLAYOFF); - HAL_Delay(5); - // Vpp disable - HAL_GPIO_WritePin(GPIOD, GPIO_PIN_8, GPIO_PIN_RESET); -} - -static void display_resume(void) { - // Vpp enable - HAL_GPIO_WritePin(GPIOD, GPIO_PIN_8, GPIO_PIN_SET); - // 100 ms mandatory wait - HAL_Delay(100); - // Display ON - ISSUE_CMD_BYTE(OLED_DISPLAYON); -} - -// Sets the display cursor to the specific row and column -static void display_set_page_and_col(uint8_t page, uint8_t col) { - if (page < (DISPLAY_RESY / 8)) { - ISSUE_CMD_BYTE(0xB0 | (page & 0xF)); - - if (col < DISPLAY_RESX) { - ISSUE_CMD_BYTE(OLED_SETHIGHCOLUMN | ((col & 0x70) >> 4)); - ISSUE_CMD_BYTE(OLED_SETLOWCOLUMN | (col & 0x0F)); - } else { - // Reset column to start - ISSUE_CMD_BYTE(OLED_SETHIGHCOLUMN); - ISSUE_CMD_BYTE(OLED_SETLOWCOLUMN); - } - } -} - -#define COLLECT_ROW_BYTE(src) \ - (0 | (*(src + (0 * DISPLAY_RESX)) >= 128 ? 128 : 0) | \ - (*(src + (1 * DISPLAY_RESX)) >= 128 ? 64 : 0) | \ - (*(src + (2 * DISPLAY_RESX)) >= 128 ? 32 : 0) | \ - (*(src + (3 * DISPLAY_RESX)) >= 128 ? 16 : 0) | \ - (*(src + (4 * DISPLAY_RESX)) >= 128 ? 8 : 0) | \ - (*(src + (5 * DISPLAY_RESX)) >= 128 ? 4 : 0) | \ - (*(src + (6 * DISPLAY_RESX)) >= 128 ? 2 : 0) | \ - (*(src + (7 * DISPLAY_RESX)) >= 128 ? 1 : 0)) - -// Copies the framebuffer to the display via SPI interface -static void display_sync_with_fb(void) { - display_driver_t *drv = &g_display_driver; - - if (!drv->initialized) { - return NULL; - } - - for (int y = 0; y < DISPLAY_RESY / 8; y++) { - display_set_page_and_col(y, 0); - uint8_t *src = &drv->framebuf[y * DISPLAY_RESX * 8]; - for (int x = 0; x < DISPLAY_RESX; x++) { - ISSUE_DATA_BYTE(COLLECT_ROW_BYTE(src)); - src++; - } - } -} - -static void display_init_controller(void) { - // LCD_RST/PC14 - HAL_GPIO_WritePin(GPIOC, GPIO_PIN_14, GPIO_PIN_RESET); - // wait 10 milliseconds. only needs to be low for 10 microseconds. - // my dev display module ties display reset and touch panel reset together. - // keeping this low for max(display_reset_time, ctpm_reset_time) aids - // development and does not hurt. - HAL_Delay(10); - - // LCD_RST/PC14 - HAL_GPIO_WritePin(GPIOC, GPIO_PIN_14, GPIO_PIN_SET); - // max wait time for hardware reset is 120 milliseconds - // (experienced display flakiness using only 5ms wait before sending commands) - HAL_Delay(120); - - // Apply initialization sequence specific to this display controller/panel - for (int i = 0; i < sizeof(ug_2828tswig01_init_seq); i++) { - ISSUE_CMD_BYTE(ug_2828tswig01_init_seq[i]); - } - - // Resume the suspended display - display_resume(); - // Clear display internal framebuffer - display_sync_with_fb(); -} - -static void display_init_interface(void) { - // init peripherals - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOD_CLK_ENABLE(); - __HAL_RCC_GPIOE_CLK_ENABLE(); - __HAL_RCC_FMC_CLK_ENABLE(); - - GPIO_InitTypeDef GPIO_InitStructure = {0}; - - // LCD_RST/PC14 - GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStructure.Pull = GPIO_NOPULL; - GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStructure.Alternate = 0; - GPIO_InitStructure.Pin = GPIO_PIN_14; - // default to keeping display in reset - HAL_GPIO_WritePin(GPIOC, GPIO_PIN_14, GPIO_PIN_RESET); - HAL_GPIO_Init(GPIOC, &GPIO_InitStructure); - - // VPP Enable - GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStructure.Pull = GPIO_PULLDOWN; - GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStructure.Alternate = 0; - GPIO_InitStructure.Pin = GPIO_PIN_8; - HAL_GPIO_WritePin(GPIOD, GPIO_PIN_8, GPIO_PIN_RESET); - HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); - - GPIO_InitStructure.Mode = GPIO_MODE_AF_PP; - GPIO_InitStructure.Pull = GPIO_NOPULL; - GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStructure.Alternate = GPIO_AF12_FMC; - // LCD_CS/PD7 LCD_RS/PD11 LCD_RD/PD4 LCD_WR/PD5 - GPIO_InitStructure.Pin = GPIO_PIN_7 | GPIO_PIN_11 | GPIO_PIN_4 | GPIO_PIN_5; - HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); - // LCD_D0/PD14 LCD_D1/PD15 LCD_D2/PD0 LCD_D3/PD1 - GPIO_InitStructure.Pin = GPIO_PIN_14 | GPIO_PIN_15 | GPIO_PIN_0 | GPIO_PIN_1; - HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); - // LCD_D4/PE7 LCD_D5/PE8 LCD_D6/PE9 LCD_D7/PE10 - GPIO_InitStructure.Pin = GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10; - HAL_GPIO_Init(GPIOE, &GPIO_InitStructure); - - // Reference UM1725 "Description of STM32F4 HAL and LL drivers", - // section 64.2.1 "How to use this driver" - SRAM_HandleTypeDef display_sram = {0}; - display_sram.Instance = FMC_NORSRAM_DEVICE; - display_sram.Extended = FMC_NORSRAM_EXTENDED_DEVICE; - display_sram.Init.NSBank = FMC_NORSRAM_BANK1; - display_sram.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE; - display_sram.Init.MemoryType = FMC_MEMORY_TYPE_SRAM; - display_sram.Init.MemoryDataWidth = FMC_NORSRAM_MEM_BUS_WIDTH_8; - display_sram.Init.BurstAccessMode = FMC_BURST_ACCESS_MODE_DISABLE; - display_sram.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW; - display_sram.Init.WrapMode = FMC_WRAP_MODE_DISABLE; - display_sram.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS; - display_sram.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE; - display_sram.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE; - display_sram.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE; - display_sram.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_DISABLE; - display_sram.Init.WriteBurst = FMC_WRITE_BURST_DISABLE; - display_sram.Init.ContinuousClock = FMC_CONTINUOUS_CLOCK_SYNC_ONLY; - display_sram.Init.PageSize = FMC_PAGE_SIZE_NONE; - - // reference RM0090 section 37.5 Table 259, 37.5.4, Mode 1 SRAM, and 37.5.6 - FMC_NORSRAM_TimingTypeDef normal_mode_timing = {0}; - normal_mode_timing.AddressSetupTime = 10; - normal_mode_timing.AddressHoldTime = 10; - normal_mode_timing.DataSetupTime = 10; - normal_mode_timing.BusTurnAroundDuration = 0; - normal_mode_timing.CLKDivision = 2; - normal_mode_timing.DataLatency = 2; - normal_mode_timing.AccessMode = FMC_ACCESS_MODE_A; - - HAL_SRAM_Init(&display_sram, &normal_mode_timing, NULL); -} - -void display_init(display_content_mode_t mode) { - display_driver_t *drv = &g_display_driver; - - if (drv->initialized) { - return; - } - - memset(drv, 0, sizeof(display_driver_t)); - drv->framebuf = g_framebuf; - - if (mode == DISPLAY_RESET_CONTENT) { - // Initialize GPIO & FSMC controller - display_init_interface(); - // Initialize display controller - display_init_controller(); - } - - drv->initialized = true; -} - -void display_deinit(display_content_mode_t mode) { - display_driver_t *drv = &g_display_driver; - - mpu_set_unpriv_fb(NULL, 0); - - drv->initialized = false; -} - -int display_set_backlight(int level) { - display_driver_t *drv = &g_display_driver; - - if (!drv->initialized) { - return 0; - } - - if (level != drv->backlight_level) { - if (level >= 0 && level <= 255) { - drv->backlight_level = level; - // Set Contrast Control Register: (Double Bytes Command) - ISSUE_CMD_BYTE(OLED_SETCONTRAST); - ISSUE_CMD_BYTE(level & 0xFF); - } - } - - return drv->backlight_level; -} - -int display_get_backlight(void) { - display_driver_t *drv = &g_display_driver; - - if (!drv->initialized) { - return 0; - } - - return drv->backlight_level; -} - -int display_set_orientation(int angle) { - display_driver_t *drv = &g_display_driver; - - if (!drv->initialized) { - return 0; - } - - if (angle != drv->orientation_angle) { - if (angle == 0 || angle == 180) { - drv->orientation_angle = angle; - if (angle == 0) { - // Set Segment Re-map: (A0H - A1H) - ISSUE_CMD_BYTE(OLED_SEGREMAP | 0x01); - // Set COM Output Scan Direction - ISSUE_CMD_BYTE(OLED_COMSCANDEC); - } else { - // Set Segment Re-map: (A0H - A1H) - ISSUE_CMD_BYTE(OLED_SEGREMAP | 0x00); - // Set COM Output Scan Direction - ISSUE_CMD_BYTE(OLED_COMSCANINC); - } - } - } - - return drv->orientation_angle; -} - -int display_get_orientation(void) { - display_driver_t *drv = &g_display_driver; - - if (!drv->initialized) { - return 0; - } - - return drv->orientation_angle; -} - -bool display_get_frame_buffer(display_fb_info_t *fb) { - display_driver_t *drv = &g_display_driver; - - if (!drv->initialized) { - fb->ptr = NULL; - fb->stride = 0; - return false; - } else { - fb->ptr = &drv->framebuf[0]; - fb->stride = DISPLAY_RESX; - // Enable access to the frame buffer from the unprivileged code - mpu_set_unpriv_fb(fb->ptr, FRAME_BUFFER_SIZE); - return true; - } -} - -void display_refresh(void) { - display_driver_t *drv = &g_display_driver; - - if (!drv->initialized) { - return NULL; - } - - // Disable access to the frame buffer from the unprivileged code - mpu_set_unpriv_fb(NULL, 0); - - // Copy the frame buffer to the display - display_sync_with_fb(); -} - -void display_fill(const gfx_bitblt_t *bb) { - display_driver_t *drv = &g_display_driver; - - if (!drv->initialized) { - return NULL; - } - - gfx_bitblt_t bb_new = *bb; - bb_new.dst_row = &drv->framebuf[DISPLAY_RESX * bb_new.dst_y]; - bb_new.dst_stride = DISPLAY_RESX; - - mono8_fill(&bb_new); -} - -void display_copy_mono1p(const gfx_bitblt_t *bb) { - display_driver_t *drv = &g_display_driver; - - if (!drv->initialized) { - return NULL; - } - - gfx_bitblt_t bb_new = *bb; - bb_new.dst_row = &drv->framebuf[DISPLAY_RESX * bb_new.dst_y]; - bb_new.dst_stride = DISPLAY_RESX; - - mono8_copy_mono1p(&bb_new); -} diff --git a/core/embed/trezorhal/stm32u5/applet.c b/core/embed/trezorhal/stm32u5/applet.c deleted file mode 120000 index 0cdabf36aa..0000000000 --- a/core/embed/trezorhal/stm32u5/applet.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/applet.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/backlight_pwm.c b/core/embed/trezorhal/stm32u5/backlight_pwm.c deleted file mode 120000 index ca21f1a602..0000000000 --- a/core/embed/trezorhal/stm32u5/backlight_pwm.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/backlight_pwm.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/backlight_pwm.h b/core/embed/trezorhal/stm32u5/backlight_pwm.h deleted file mode 120000 index 37053b491d..0000000000 --- a/core/embed/trezorhal/stm32u5/backlight_pwm.h +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/backlight_pwm.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/board_capabilities.c b/core/embed/trezorhal/stm32u5/board_capabilities.c deleted file mode 120000 index da6d3b1a3d..0000000000 --- a/core/embed/trezorhal/stm32u5/board_capabilities.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/board_capabilities.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/bootutils.c b/core/embed/trezorhal/stm32u5/bootutils.c deleted file mode 120000 index cdb656edf3..0000000000 --- a/core/embed/trezorhal/stm32u5/bootutils.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/bootutils.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/button.c b/core/embed/trezorhal/stm32u5/button.c deleted file mode 120000 index 9c6b0a7704..0000000000 --- a/core/embed/trezorhal/stm32u5/button.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/button.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/dma2d_bitblt.c b/core/embed/trezorhal/stm32u5/dma2d_bitblt.c deleted file mode 120000 index faeb9cc40b..0000000000 --- a/core/embed/trezorhal/stm32u5/dma2d_bitblt.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/dma2d_bitblt.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/fwutils.c b/core/embed/trezorhal/stm32u5/fwutils.c deleted file mode 120000 index 8968a5a024..0000000000 --- a/core/embed/trezorhal/stm32u5/fwutils.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/fwutils.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/irq.h b/core/embed/trezorhal/stm32u5/irq.h deleted file mode 120000 index f2c8e555e6..0000000000 --- a/core/embed/trezorhal/stm32u5/irq.h +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/irq.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/layout_helpers.h b/core/embed/trezorhal/stm32u5/layout_helpers.h deleted file mode 120000 index fc9960bef7..0000000000 --- a/core/embed/trezorhal/stm32u5/layout_helpers.h +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/layout_helpers.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/pvd.c b/core/embed/trezorhal/stm32u5/pvd.c deleted file mode 120000 index e94aab5b3e..0000000000 --- a/core/embed/trezorhal/stm32u5/pvd.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/pvd.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/random_delays.c b/core/embed/trezorhal/stm32u5/random_delays.c deleted file mode 120000 index eb47d77293..0000000000 --- a/core/embed/trezorhal/stm32u5/random_delays.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/random_delays.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/rng.c b/core/embed/trezorhal/stm32u5/rng.c deleted file mode 120000 index f16159d787..0000000000 --- a/core/embed/trezorhal/stm32u5/rng.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/rng.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/sbu.c b/core/embed/trezorhal/stm32u5/sbu.c deleted file mode 120000 index 54c434947d..0000000000 --- a/core/embed/trezorhal/stm32u5/sbu.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/sbu.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/syscall.c b/core/embed/trezorhal/stm32u5/syscall.c deleted file mode 120000 index 4995488e2a..0000000000 --- a/core/embed/trezorhal/stm32u5/syscall.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/syscall.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/syscall.h b/core/embed/trezorhal/stm32u5/syscall.h deleted file mode 120000 index 8563747ddf..0000000000 --- a/core/embed/trezorhal/stm32u5/syscall.h +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/syscall.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/syscall_dispatch.c b/core/embed/trezorhal/stm32u5/syscall_dispatch.c deleted file mode 120000 index f7542fb99e..0000000000 --- a/core/embed/trezorhal/stm32u5/syscall_dispatch.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/syscall_dispatch.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/syscall_numbers.h b/core/embed/trezorhal/stm32u5/syscall_numbers.h deleted file mode 120000 index f2e572e964..0000000000 --- a/core/embed/trezorhal/stm32u5/syscall_numbers.h +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/syscall_numbers.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/syscall_probe.c b/core/embed/trezorhal/stm32u5/syscall_probe.c deleted file mode 120000 index b9351466af..0000000000 --- a/core/embed/trezorhal/stm32u5/syscall_probe.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/syscall_probe.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/syscall_probe.h b/core/embed/trezorhal/stm32u5/syscall_probe.h deleted file mode 120000 index 92b93e98c2..0000000000 --- a/core/embed/trezorhal/stm32u5/syscall_probe.h +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/syscall_probe.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/syscall_stubs.c b/core/embed/trezorhal/stm32u5/syscall_stubs.c deleted file mode 120000 index 877f2904f0..0000000000 --- a/core/embed/trezorhal/stm32u5/syscall_stubs.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/syscall_stubs.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/syscall_verifiers.c b/core/embed/trezorhal/stm32u5/syscall_verifiers.c deleted file mode 120000 index 22b83e8c93..0000000000 --- a/core/embed/trezorhal/stm32u5/syscall_verifiers.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/syscall_verifiers.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/syscall_verifiers.h b/core/embed/trezorhal/stm32u5/syscall_verifiers.h deleted file mode 120000 index bd32627b4e..0000000000 --- a/core/embed/trezorhal/stm32u5/syscall_verifiers.h +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/syscall_verifiers.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/systask.c b/core/embed/trezorhal/stm32u5/systask.c deleted file mode 120000 index 7b6c139ae3..0000000000 --- a/core/embed/trezorhal/stm32u5/systask.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/systask.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/system.c b/core/embed/trezorhal/stm32u5/system.c deleted file mode 120000 index 36a84d685c..0000000000 --- a/core/embed/trezorhal/stm32u5/system.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/system.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/systemview.h b/core/embed/trezorhal/stm32u5/systemview.h deleted file mode 120000 index fda5c909e7..0000000000 --- a/core/embed/trezorhal/stm32u5/systemview.h +++ /dev/null @@ -1 +0,0 @@ -../../firmware/systemview.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/systick.c b/core/embed/trezorhal/stm32u5/systick.c deleted file mode 120000 index 1a5e42f109..0000000000 --- a/core/embed/trezorhal/stm32u5/systick.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/systick.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/systick_internal.h b/core/embed/trezorhal/stm32u5/systick_internal.h deleted file mode 120000 index 2060732867..0000000000 --- a/core/embed/trezorhal/stm32u5/systick_internal.h +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/systick_internal.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/systimer.c b/core/embed/trezorhal/stm32u5/systimer.c deleted file mode 120000 index 035d4ff20f..0000000000 --- a/core/embed/trezorhal/stm32u5/systimer.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/systimer.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/time_estimate.c b/core/embed/trezorhal/stm32u5/time_estimate.c deleted file mode 120000 index 9c2a9b118e..0000000000 --- a/core/embed/trezorhal/stm32u5/time_estimate.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/time_estimate.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/touch/ft6x36.c b/core/embed/trezorhal/stm32u5/touch/ft6x36.c deleted file mode 120000 index 68b33fbb6a..0000000000 --- a/core/embed/trezorhal/stm32u5/touch/ft6x36.c +++ /dev/null @@ -1 +0,0 @@ -../../stm32f4/touch/ft6x36.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/touch/ft6x36.h b/core/embed/trezorhal/stm32u5/touch/ft6x36.h deleted file mode 120000 index 2c609d19bf..0000000000 --- a/core/embed/trezorhal/stm32u5/touch/ft6x36.h +++ /dev/null @@ -1 +0,0 @@ -../../stm32f4/touch/ft6x36.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/touch/panels b/core/embed/trezorhal/stm32u5/touch/panels deleted file mode 120000 index 1923ae8946..0000000000 --- a/core/embed/trezorhal/stm32u5/touch/panels +++ /dev/null @@ -1 +0,0 @@ -../../stm32f4/touch/panels/ \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/touch/sitronix.h b/core/embed/trezorhal/stm32u5/touch/sitronix.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/core/embed/trezorhal/stm32u5/unit_properties.c b/core/embed/trezorhal/stm32u5/unit_properties.c deleted file mode 120000 index d1874a0bc4..0000000000 --- a/core/embed/trezorhal/stm32u5/unit_properties.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/unit_properties.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/usb b/core/embed/trezorhal/stm32u5/usb deleted file mode 120000 index cbd91c097f..0000000000 --- a/core/embed/trezorhal/stm32u5/usb +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/usb \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/xdisplay/st-7789 b/core/embed/trezorhal/stm32u5/xdisplay/st-7789 deleted file mode 120000 index e524c4e49a..0000000000 --- a/core/embed/trezorhal/stm32u5/xdisplay/st-7789 +++ /dev/null @@ -1 +0,0 @@ -../../stm32f4/xdisplay/st-7789 \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/xdisplay/vg-2864 b/core/embed/trezorhal/stm32u5/xdisplay/vg-2864 deleted file mode 120000 index 5f1987533d..0000000000 --- a/core/embed/trezorhal/stm32u5/xdisplay/vg-2864 +++ /dev/null @@ -1 +0,0 @@ -../../stm32f4/xdisplay/vg-2864 \ No newline at end of file diff --git a/core/embed/trezorhal/unix/fwutils.c b/core/embed/trezorhal/unix/fwutils.c deleted file mode 120000 index 8968a5a024..0000000000 --- a/core/embed/trezorhal/unix/fwutils.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/fwutils.c \ No newline at end of file diff --git a/core/embed/extmod/modtrezorconfig/modtrezorconfig.c b/core/embed/upymod/modtrezorconfig/modtrezorconfig.c similarity index 99% rename from core/embed/extmod/modtrezorconfig/modtrezorconfig.c rename to core/embed/upymod/modtrezorconfig/modtrezorconfig.c index c535b4c7ab..f683bd627d 100644 --- a/core/embed/extmod/modtrezorconfig/modtrezorconfig.c +++ b/core/embed/upymod/modtrezorconfig/modtrezorconfig.c @@ -25,9 +25,9 @@ #if MICROPY_PY_TREZORCONFIG -#include "embed/extmod/trezorobj.h" +#include "embed/upymod/trezorobj.h" -#include "entropy.h" +#include #include "memzero.h" #include "storage.h" diff --git a/core/embed/extmod/modtrezorconfig/norcow_config.h b/core/embed/upymod/modtrezorconfig/norcow_config.h similarity index 97% rename from core/embed/extmod/modtrezorconfig/norcow_config.h rename to core/embed/upymod/modtrezorconfig/norcow_config.h index e0bae4f4b7..5cb12bdc14 100644 --- a/core/embed/extmod/modtrezorconfig/norcow_config.h +++ b/core/embed/upymod/modtrezorconfig/norcow_config.h @@ -23,7 +23,7 @@ #include #include -#include "flash.h" +#include #define NORCOW_HEADER_LEN 0 #define NORCOW_SECTOR_COUNT 2 diff --git a/core/embed/extmod/modtrezorcrypto/crc.c b/core/embed/upymod/modtrezorcrypto/crc.c similarity index 100% rename from core/embed/extmod/modtrezorcrypto/crc.c rename to core/embed/upymod/modtrezorcrypto/crc.c diff --git a/core/embed/extmod/modtrezorcrypto/crc.h b/core/embed/upymod/modtrezorcrypto/crc.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/crc.h rename to core/embed/upymod/modtrezorcrypto/crc.h diff --git a/core/embed/extmod/modtrezorcrypto/hdnode.h b/core/embed/upymod/modtrezorcrypto/hdnode.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/hdnode.h rename to core/embed/upymod/modtrezorcrypto/hdnode.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-aes.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-aes.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-aes.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-aes.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-aesgcm.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-aesgcm.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-aesgcm.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-aesgcm.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bech32.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-bech32.h similarity index 98% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bech32.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-bech32.h index 16819b914d..051c7864b4 100644 --- a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bech32.h +++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-bech32.h @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include "embed/extmod/trezorobj.h" +#include "embed/upymod/trezorobj.h" #include "py/objstr.h" #include "segwit_addr.h" diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bip32.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-bip32.h similarity index 99% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bip32.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-bip32.h index ed0794b597..34579663b3 100644 --- a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bip32.h +++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-bip32.h @@ -19,7 +19,7 @@ #include "py/objstr.h" -#include "embed/extmod/trezorobj.h" +#include "embed/upymod/trezorobj.h" #include "hdnode.h" #include "bip32.h" diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bip340.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-bip340.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bip340.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-bip340.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bip39.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-bip39.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bip39.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-bip39.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-blake256.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake256.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-blake256.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake256.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-blake2b.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake2b.h similarity index 99% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-blake2b.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake2b.h index 2b1f4b2f46..21c5783ce5 100644 --- a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-blake2b.h +++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake2b.h @@ -19,7 +19,7 @@ #include "py/objstr.h" -#include "embed/extmod/trezorobj.h" +#include "embed/upymod/trezorobj.h" #include "blake2b.h" #include "memzero.h" diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-blake2s.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake2s.h similarity index 99% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-blake2s.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake2s.h index 3e1b28870d..bbedaf1821 100644 --- a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-blake2s.h +++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake2s.h @@ -19,7 +19,7 @@ #include "py/objstr.h" -#include "embed/extmod/trezorobj.h" +#include "embed/upymod/trezorobj.h" #include "blake2s.h" #include "memzero.h" diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-cardano.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-cardano.h similarity index 99% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-cardano.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-cardano.h index 04caede4aa..af341dfb27 100644 --- a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-cardano.h +++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-cardano.h @@ -21,7 +21,7 @@ #include "py/objstr.h" -#include "embed/extmod/trezorobj.h" +#include "embed/upymod/trezorobj.h" #include "hdnode.h" #include "bip39.h" diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-chacha20poly1305.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-chacha20poly1305.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-chacha20poly1305.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-chacha20poly1305.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-crc.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-crc.h similarity index 98% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-crc.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-crc.h index ab0042eef3..467aef7a66 100644 --- a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-crc.h +++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-crc.h @@ -19,7 +19,7 @@ #include "py/objstr.h" -#include "embed/extmod/trezorobj.h" +#include "embed/upymod/trezorobj.h" #include "crc.h" diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-curve25519.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-curve25519.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-curve25519.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-curve25519.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-ed25519.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-ed25519.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-ed25519.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-ed25519.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-elligator2.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-elligator2.h similarity index 98% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-elligator2.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-elligator2.h index 8bbfd7910d..85e9385d43 100644 --- a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-elligator2.h +++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-elligator2.h @@ -19,7 +19,7 @@ #include "py/objstr.h" -#include "embed/extmod/trezorobj.h" +#include "embed/upymod/trezorobj.h" #include "elligator2.h" diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-groestl.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-groestl.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-groestl.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-groestl.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-hmac.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-hmac.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-hmac.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-hmac.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-monero.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-monero.h similarity index 99% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-monero.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-monero.h index a28d1bd523..0c7686522d 100644 --- a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-monero.h +++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-monero.h @@ -21,7 +21,7 @@ #include "py/objint.h" #include "py/objstr.h" -#include "embed/extmod/trezorobj.h" +#include "embed/upymod/trezorobj.h" #include "bignum.h" #include "memzero.h" diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-nem.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-nem.h similarity index 98% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-nem.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-nem.h index 5658954d2a..e1cdebc2b2 100644 --- a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-nem.h +++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-nem.h @@ -19,7 +19,7 @@ #include "py/objstr.h" -#include "embed/extmod/trezorobj.h" +#include "embed/upymod/trezorobj.h" #include "nem.h" diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-nist256p1.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-nist256p1.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-nist256p1.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-nist256p1.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-optiga.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-optiga.h similarity index 98% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-optiga.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-optiga.h index 040de99622..bc7a8b373a 100644 --- a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-optiga.h +++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-optiga.h @@ -21,8 +21,8 @@ #include "py/objstr.h" -#include "optiga.h" -#include "optiga_commands.h" +#include +#include /// package: trezorcrypto.optiga diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-random.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-random.h similarity index 98% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-random.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-random.h index e85f05e6ae..0a013848c8 100644 --- a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-random.h +++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-random.h @@ -19,12 +19,12 @@ #include "py/objstr.h" -#include "embed/extmod/trezorobj.h" +#include "embed/upymod/trezorobj.h" #include "rand.h" #if USE_OPTIGA -#include "optiga.h" +#include #endif /// package: trezorcrypto.random diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-ripemd160.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-ripemd160.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-ripemd160.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-ripemd160.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-secp256k1.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-secp256k1.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-secp256k1.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-secp256k1.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha1.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha1.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha1.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha1.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha256.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha256.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha256.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha256.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha3-256.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha3-256.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha3-256.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha3-256.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha3-512.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha3-512.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha3-512.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha3-512.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha512.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha512.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha512.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha512.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-shamir.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-shamir.h similarity index 98% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-shamir.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-shamir.h index 09d4b3f746..9e21adaa0f 100644 --- a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-shamir.h +++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-shamir.h @@ -19,7 +19,7 @@ #include "py/obj.h" -#include "embed/extmod/trezorobj.h" +#include "embed/upymod/trezorobj.h" #include "shamir.h" diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-slip39.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-slip39.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-slip39.h rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto-slip39.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto.c b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto.c similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto.c rename to core/embed/upymod/modtrezorcrypto/modtrezorcrypto.c diff --git a/core/embed/extmod/modtrezorcrypto/rand.c b/core/embed/upymod/modtrezorcrypto/rand.c similarity index 97% rename from core/embed/extmod/modtrezorcrypto/rand.c rename to core/embed/upymod/modtrezorcrypto/rand.c index c93f3d8ef4..adc44c746c 100644 --- a/core/embed/extmod/modtrezorcrypto/rand.c +++ b/core/embed/upymod/modtrezorcrypto/rand.c @@ -18,6 +18,6 @@ */ #include "rand.h" -#include "rng.h" +#include uint32_t random32(void) { return rng_get(); } diff --git a/core/embed/extmod/modtrezorio/diskio.h b/core/embed/upymod/modtrezorio/diskio.h similarity index 100% rename from core/embed/extmod/modtrezorio/diskio.h rename to core/embed/upymod/modtrezorio/diskio.h diff --git a/core/embed/extmod/modtrezorio/ff.c b/core/embed/upymod/modtrezorio/ff.c similarity index 100% rename from core/embed/extmod/modtrezorio/ff.c rename to core/embed/upymod/modtrezorio/ff.c diff --git a/core/embed/extmod/modtrezorio/ff.h b/core/embed/upymod/modtrezorio/ff.h similarity index 100% rename from core/embed/extmod/modtrezorio/ff.h rename to core/embed/upymod/modtrezorio/ff.h diff --git a/core/embed/extmod/modtrezorio/ff_unifdef.sh b/core/embed/upymod/modtrezorio/ff_unifdef.sh similarity index 100% rename from core/embed/extmod/modtrezorio/ff_unifdef.sh rename to core/embed/upymod/modtrezorio/ff_unifdef.sh diff --git a/core/embed/extmod/modtrezorio/ffconf.h b/core/embed/upymod/modtrezorio/ffconf.h similarity index 100% rename from core/embed/extmod/modtrezorio/ffconf.h rename to core/embed/upymod/modtrezorio/ffconf.h diff --git a/core/embed/extmod/modtrezorio/ffunicode.c b/core/embed/upymod/modtrezorio/ffunicode.c similarity index 100% rename from core/embed/extmod/modtrezorio/ffunicode.c rename to core/embed/upymod/modtrezorio/ffunicode.c diff --git a/core/embed/extmod/modtrezorio/modtrezorio-fatfs.h b/core/embed/upymod/modtrezorio/modtrezorio-fatfs.h similarity index 99% rename from core/embed/extmod/modtrezorio/modtrezorio-fatfs.h rename to core/embed/upymod/modtrezorio/modtrezorio-fatfs.h index a515e41982..cbc3fb875b 100644 --- a/core/embed/extmod/modtrezorio/modtrezorio-fatfs.h +++ b/core/embed/upymod/modtrezorio/modtrezorio-fatfs.h @@ -17,14 +17,14 @@ * along with this program. If not, see . */ -#include "embed/extmod/trezorobj.h" +#include "embed/upymod/trezorobj.h" #include "py/mperrno.h" #include "py/objstr.h" // clang-format off #include "ff.h" #include "diskio.h" -#include "sdcard.h" +#include // clang-format on /// package: trezorio.fatfs diff --git a/core/embed/extmod/modtrezorio/modtrezorio-haptic.h b/core/embed/upymod/modtrezorio/modtrezorio-haptic.h similarity index 98% rename from core/embed/extmod/modtrezorio/modtrezorio-haptic.h rename to core/embed/upymod/modtrezorio/modtrezorio-haptic.h index 9462b82614..3e332f4eca 100644 --- a/core/embed/extmod/modtrezorio/modtrezorio-haptic.h +++ b/core/embed/upymod/modtrezorio/modtrezorio-haptic.h @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include "haptic.h" +#include /// package: trezorio.haptic diff --git a/core/embed/extmod/modtrezorio/modtrezorio-hid.h b/core/embed/upymod/modtrezorio/modtrezorio-hid.h similarity index 99% rename from core/embed/extmod/modtrezorio/modtrezorio-hid.h rename to core/embed/upymod/modtrezorio/modtrezorio-hid.h index c5dd5195d3..bcf141d776 100644 --- a/core/embed/extmod/modtrezorio/modtrezorio-hid.h +++ b/core/embed/upymod/modtrezorio/modtrezorio-hid.h @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include "embed/extmod/trezorobj.h" +#include "embed/upymod/trezorobj.h" /// package: trezorio.__init__ diff --git a/core/embed/extmod/modtrezorio/modtrezorio-poll.h b/core/embed/upymod/modtrezorio/modtrezorio-poll.h similarity index 98% rename from core/embed/extmod/modtrezorio/modtrezorio-poll.h rename to core/embed/upymod/modtrezorio/modtrezorio-poll.h index a538dcc3c5..2d97e491e7 100644 --- a/core/embed/extmod/modtrezorio/modtrezorio-poll.h +++ b/core/embed/upymod/modtrezorio/modtrezorio-poll.h @@ -20,11 +20,14 @@ #include #include -#include "button.h" -#include "display.h" -#include "systick.h" +#include +#include -#include "embed/extmod/trezorobj.h" +#ifdef USE_BUTTON +#include +#endif + +#include "embed/upymod/trezorobj.h" #ifdef TREZOR_EMULATOR #include "SDL.h" diff --git a/core/embed/extmod/modtrezorio/modtrezorio-sdcard.h b/core/embed/upymod/modtrezorio/modtrezorio-sdcard.h similarity index 98% rename from core/embed/extmod/modtrezorio/modtrezorio-sdcard.h rename to core/embed/upymod/modtrezorio/modtrezorio-sdcard.h index 1750f58542..9ce480036a 100644 --- a/core/embed/extmod/modtrezorio/modtrezorio-sdcard.h +++ b/core/embed/upymod/modtrezorio/modtrezorio-sdcard.h @@ -17,10 +17,10 @@ * along with this program. If not, see . */ -#include "embed/extmod/trezorobj.h" +#include "embed/upymod/trezorobj.h" #include "py/mperrno.h" -#include "sdcard.h" +#include /// package: trezorio.sdcard diff --git a/core/embed/extmod/modtrezorio/modtrezorio-usb.h b/core/embed/upymod/modtrezorio/modtrezorio-usb.h similarity index 100% rename from core/embed/extmod/modtrezorio/modtrezorio-usb.h rename to core/embed/upymod/modtrezorio/modtrezorio-usb.h diff --git a/core/embed/extmod/modtrezorio/modtrezorio-vcp.h b/core/embed/upymod/modtrezorio/modtrezorio-vcp.h similarity index 100% rename from core/embed/extmod/modtrezorio/modtrezorio-vcp.h rename to core/embed/upymod/modtrezorio/modtrezorio-vcp.h diff --git a/core/embed/extmod/modtrezorio/modtrezorio-webusb.h b/core/embed/upymod/modtrezorio/modtrezorio-webusb.h similarity index 100% rename from core/embed/extmod/modtrezorio/modtrezorio-webusb.h rename to core/embed/upymod/modtrezorio/modtrezorio-webusb.h diff --git a/core/embed/extmod/modtrezorio/modtrezorio.c b/core/embed/upymod/modtrezorio/modtrezorio.c similarity index 97% rename from core/embed/extmod/modtrezorio/modtrezorio.c rename to core/embed/upymod/modtrezorio/modtrezorio.c index 75a5501c5e..80bd6abd92 100644 --- a/core/embed/extmod/modtrezorio/modtrezorio.c +++ b/core/embed/upymod/modtrezorio/modtrezorio.c @@ -27,9 +27,15 @@ #if MICROPY_PY_TREZORIO -#include "button.h" -#include "touch.h" -#include "usb.h" +#ifdef USE_BUTTON +#include +#endif + +#ifdef USE_TOUCH +#include +#endif + +#include // Whether USB data pins were connected on last check (USB configured) bool usb_connected_previously = true; diff --git a/core/embed/extmod/modtrezorui/modtrezorui-display.h b/core/embed/upymod/modtrezorui/modtrezorui-display.h similarity index 98% rename from core/embed/extmod/modtrezorui/modtrezorui-display.h rename to core/embed/upymod/modtrezorui/modtrezorui-display.h index d6fce1dd16..d5494a9329 100644 --- a/core/embed/extmod/modtrezorui/modtrezorui-display.h +++ b/core/embed/upymod/modtrezorui/modtrezorui-display.h @@ -19,9 +19,9 @@ #include -#include "display.h" -#include "fonts/fonts.h" -#include "gfx_draw.h" +#include +#include +#include /// class Display: /// """ diff --git a/core/embed/extmod/modtrezorui/modtrezorui.c b/core/embed/upymod/modtrezorui/modtrezorui.c similarity index 97% rename from core/embed/extmod/modtrezorui/modtrezorui.c rename to core/embed/upymod/modtrezorui/modtrezorui.c index e6a42cccac..5037281d5a 100644 --- a/core/embed/extmod/modtrezorui/modtrezorui.c +++ b/core/embed/upymod/modtrezorui/modtrezorui.c @@ -23,7 +23,7 @@ #if MICROPY_PY_TREZORUI -#include "embed/extmod/trezorobj.h" +#include "embed/upymod/trezorobj.h" #include "modtrezorui-display.h" STATIC const mp_rom_map_elem_t mp_module_trezorui_globals_table[] = { diff --git a/core/embed/extmod/modtrezorutils/modtrezorutils-meminfo.h b/core/embed/upymod/modtrezorutils/modtrezorutils-meminfo.h similarity index 99% rename from core/embed/extmod/modtrezorutils/modtrezorutils-meminfo.h rename to core/embed/upymod/modtrezorutils/modtrezorutils-meminfo.h index 55fdfd3770..da2b543bf2 100644 --- a/core/embed/extmod/modtrezorutils/modtrezorutils-meminfo.h +++ b/core/embed/upymod/modtrezorutils/modtrezorutils-meminfo.h @@ -34,9 +34,9 @@ #include "py/objstr.h" #include "py/objtype.h" -#include "embed/extmod/trezorobj.h" +#include #include "embed/rust/librust.h" -#include "embed/trezorhal/usb.h" +#include "embed/upymod/trezorobj.h" #define WORDS_PER_BLOCK ((MICROPY_BYTES_PER_GC_BLOCK) / MP_BYTES_PER_OBJ_WORD) #define BYTES_PER_BLOCK (MICROPY_BYTES_PER_GC_BLOCK) diff --git a/core/embed/extmod/modtrezorutils/modtrezorutils.c b/core/embed/upymod/modtrezorutils/modtrezorutils.c similarity index 98% rename from core/embed/extmod/modtrezorutils/modtrezorutils.c rename to core/embed/upymod/modtrezorutils/modtrezorutils.c index 5a864093c9..e60bd425dc 100644 --- a/core/embed/extmod/modtrezorutils/modtrezorutils.c +++ b/core/embed/upymod/modtrezorutils/modtrezorutils.c @@ -23,22 +23,22 @@ #include "py/objstr.h" #include "py/runtime.h" -#include "image.h" +#include #include "version.h" #if MICROPY_PY_TREZORUTILS -#include "embed/extmod/modtrezorutils/modtrezorutils-meminfo.h" -#include "embed/extmod/trezorobj.h" +#include "embed/upymod/modtrezorutils/modtrezorutils-meminfo.h" +#include "embed/upymod/trezorobj.h" +#include +#include +#include +#include #include "blake2s.h" -#include "bootutils.h" -#include "fwutils.h" -#include "unit_properties.h" -#include "usb.h" #if USE_OPTIGA && !defined(TREZOR_EMULATOR) -#include "secret.h" +#include #endif static void ui_progress(void *context, uint32_t current, uint32_t total) { diff --git a/core/embed/extmod/modutime.c b/core/embed/upymod/modutime.c similarity index 100% rename from core/embed/extmod/modutime.c rename to core/embed/upymod/modutime.c diff --git a/core/embed/extmod/rustmods.c b/core/embed/upymod/rustmods.c similarity index 100% rename from core/embed/extmod/rustmods.c rename to core/embed/upymod/rustmods.c diff --git a/core/embed/extmod/trezorobj.c b/core/embed/upymod/trezorobj.c similarity index 100% rename from core/embed/extmod/trezorobj.c rename to core/embed/upymod/trezorobj.c diff --git a/core/embed/extmod/trezorobj.h b/core/embed/upymod/trezorobj.h similarity index 100% rename from core/embed/extmod/trezorobj.h rename to core/embed/upymod/trezorobj.h diff --git a/core/embed/lib/bl_check.c b/core/embed/util/bl_check/bl_check.c similarity index 98% rename from core/embed/lib/bl_check.c rename to core/embed/util/bl_check/bl_check.c index 3a62f6f8b7..3acca64369 100644 --- a/core/embed/lib/bl_check.c +++ b/core/embed/util/bl_check/bl_check.c @@ -20,12 +20,12 @@ #include #include +#include +#include +#include +#include #include "blake2s.h" -#include "board_capabilities.h" -#include "flash.h" -#include "image.h" #include "memzero.h" -#include "mpu.h" #include "uzlib.h" // symbols from bootloader.bin => bootloader.o diff --git a/core/embed/lib/bl_check.h b/core/embed/util/bl_check/inc/util/bl_check.h similarity index 100% rename from core/embed/lib/bl_check.h rename to core/embed/util/bl_check/inc/util/bl_check.h diff --git a/core/embed/trezorhal/board_capabilities.h b/core/embed/util/board_capabilities/inc/util/board_capabilities.h similarity index 100% rename from core/embed/trezorhal/board_capabilities.h rename to core/embed/util/board_capabilities/inc/util/board_capabilities.h diff --git a/core/embed/trezorhal/stm32f4/board_capabilities.c b/core/embed/util/board_capabilities/stm32/board_capabilities.c similarity index 97% rename from core/embed/trezorhal/stm32f4/board_capabilities.c rename to core/embed/util/board_capabilities/stm32/board_capabilities.c index 509d7618c8..bb7d03955b 100644 --- a/core/embed/trezorhal/stm32f4/board_capabilities.c +++ b/core/embed/util/board_capabilities/stm32/board_capabilities.c @@ -20,8 +20,8 @@ #include #include -#include "board_capabilities.h" -#include "mpu.h" +#include +#include #ifdef KERNEL_MODE diff --git a/core/embed/lib/flash_utils.c b/core/embed/util/flash/flash_utils.c similarity index 98% rename from core/embed/lib/flash_utils.c rename to core/embed/util/flash/flash_utils.c index 4e3c4bf346..c518589fff 100644 --- a/core/embed/lib/flash_utils.c +++ b/core/embed/util/flash/flash_utils.c @@ -20,9 +20,9 @@ #include #include +#include +#include #include "flash_area.h" -#include "flash_utils.h" -#include "mpu.h" typedef struct { const flash_area_t* area; diff --git a/core/embed/util/flash/inc/flash.h b/core/embed/util/flash/inc/flash.h new file mode 100644 index 0000000000..542e18aff6 --- /dev/null +++ b/core/embed/util/flash/inc/flash.h @@ -0,0 +1,25 @@ +/* + * 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 . + */ + +// This header is included in storage module +// +// Do not include this header or add dependencies to it unless required by +// storage. + +#include "util/flash.h" diff --git a/core/embed/trezorhal/flash.h b/core/embed/util/flash/inc/util/flash.h similarity index 100% rename from core/embed/trezorhal/flash.h rename to core/embed/util/flash/inc/util/flash.h diff --git a/core/embed/trezorhal/layout.h b/core/embed/util/flash/inc/util/flash_layout.h similarity index 100% rename from core/embed/trezorhal/layout.h rename to core/embed/util/flash/inc/util/flash_layout.h diff --git a/core/embed/trezorhal/flash_otp.h b/core/embed/util/flash/inc/util/flash_otp.h similarity index 100% rename from core/embed/trezorhal/flash_otp.h rename to core/embed/util/flash/inc/util/flash_otp.h diff --git a/core/embed/lib/flash_utils.h b/core/embed/util/flash/inc/util/flash_utils.h similarity index 100% rename from core/embed/lib/flash_utils.h rename to core/embed/util/flash/inc/util/flash_utils.h diff --git a/core/embed/trezorhal/stm32f4/layout_helpers.h b/core/embed/util/flash/layout_helpers.h similarity index 100% rename from core/embed/trezorhal/stm32f4/layout_helpers.h rename to core/embed/util/flash/layout_helpers.h diff --git a/core/embed/trezorhal/stm32f4/flash.c b/core/embed/util/flash/stm32f4/flash.c similarity index 99% rename from core/embed/trezorhal/stm32f4/flash.c rename to core/embed/util/flash/stm32f4/flash.c index 42e78d62da..f9598cec06 100644 --- a/core/embed/trezorhal/stm32f4/flash.c +++ b/core/embed/util/flash/stm32f4/flash.c @@ -20,7 +20,7 @@ #include #include -#include "flash.h" +#include #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/stm32f4/layout.c b/core/embed/util/flash/stm32f4/flash_layout.c similarity index 96% rename from core/embed/trezorhal/stm32f4/layout.c rename to core/embed/util/flash/stm32f4/flash_layout.c index 75f6bb3084..664082674f 100644 --- a/core/embed/trezorhal/stm32f4/layout.c +++ b/core/embed/util/flash/stm32f4/flash_layout.c @@ -20,8 +20,9 @@ #include #include -#include "flash.h" -#include "layout_helpers.h" +#include + +#include "../layout_helpers.h" // Convert sector number to address // diff --git a/core/embed/trezorhal/stm32f4/flash_otp.c b/core/embed/util/flash/stm32f4/flash_otp.c similarity index 97% rename from core/embed/trezorhal/stm32f4/flash_otp.c rename to core/embed/util/flash/stm32f4/flash_otp.c index 10226edb42..60990b44b3 100644 --- a/core/embed/trezorhal/stm32f4/flash_otp.c +++ b/core/embed/util/flash/stm32f4/flash_otp.c @@ -20,9 +20,9 @@ #include #include -#include "flash.h" -#include "flash_otp.h" -#include "mpu.h" +#include +#include +#include #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/stm32u5/flash.c b/core/embed/util/flash/stm32u5/flash.c similarity index 99% rename from core/embed/trezorhal/stm32u5/flash.c rename to core/embed/util/flash/stm32u5/flash.c index 6461fb8cb3..da2f2ae4c4 100644 --- a/core/embed/trezorhal/stm32u5/flash.c +++ b/core/embed/util/flash/stm32u5/flash.c @@ -21,7 +21,7 @@ #include #include -#include "flash.h" +#include #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/stm32u5/layout.c b/core/embed/util/flash/stm32u5/flash_layout.c similarity index 96% rename from core/embed/trezorhal/stm32u5/layout.c rename to core/embed/util/flash/stm32u5/flash_layout.c index b7527157e6..577d92b51f 100644 --- a/core/embed/trezorhal/stm32u5/layout.c +++ b/core/embed/util/flash/stm32u5/flash_layout.c @@ -20,8 +20,9 @@ #include #include -#include "flash.h" -#include "layout_helpers.h" +#include + +#include "../layout_helpers.h" // Convert sector number to address // diff --git a/core/embed/trezorhal/stm32u5/flash_otp.c b/core/embed/util/flash/stm32u5/flash_otp.c similarity index 97% rename from core/embed/trezorhal/stm32u5/flash_otp.c rename to core/embed/util/flash/stm32u5/flash_otp.c index 0f94ecd931..2489edfbe2 100644 --- a/core/embed/trezorhal/stm32u5/flash_otp.c +++ b/core/embed/util/flash/stm32u5/flash_otp.c @@ -20,9 +20,9 @@ #include #include -#include "flash.h" -#include "flash_otp.h" -#include "mpu.h" +#include +#include +#include #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/unix/flash.c b/core/embed/util/flash/unix/flash.c similarity index 99% rename from core/embed/trezorhal/unix/flash.c rename to core/embed/util/flash/unix/flash.c index 399e249135..6e402280c8 100644 --- a/core/embed/trezorhal/unix/flash.c +++ b/core/embed/util/flash/unix/flash.c @@ -27,7 +27,7 @@ #include #include -#include "flash.h" +#include #include "profile.h" #ifndef FLASH_FILE diff --git a/core/embed/trezorhal/unix/flash_otp.c b/core/embed/util/flash/unix/flash_otp.c similarity index 98% rename from core/embed/trezorhal/unix/flash_otp.c rename to core/embed/util/flash/unix/flash_otp.c index 8e92639459..3eecc0ea54 100644 --- a/core/embed/trezorhal/unix/flash_otp.c +++ b/core/embed/util/flash/unix/flash_otp.c @@ -19,7 +19,7 @@ #include -#include "../flash_otp.h" +#include #define OTP_BLOCK_SIZE 32 #define FLASH_SECTOR_OTP (FLASH_SECTOR_COUNT) diff --git a/core/embed/trezorhal/stm32f4/fwutils.c b/core/embed/util/fwutils/fwutils.c similarity index 97% rename from core/embed/trezorhal/stm32f4/fwutils.c rename to core/embed/util/fwutils/fwutils.c index cd5fd055e4..0c9c60166a 100644 --- a/core/embed/trezorhal/stm32f4/fwutils.c +++ b/core/embed/util/fwutils/fwutils.c @@ -21,11 +21,11 @@ #include #include +#include +#include +#include #include "blake2s.h" -#include "flash.h" #include "flash_area.h" -#include "fwutils.h" -#include "image.h" #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/fwutils.h b/core/embed/util/fwutils/inc/util/fwutils.h similarity index 100% rename from core/embed/trezorhal/fwutils.h rename to core/embed/util/fwutils/inc/util/fwutils.h diff --git a/core/embed/lib/image.c b/core/embed/util/image/image.c similarity index 99% rename from core/embed/lib/image.c rename to core/embed/util/image/image.c index c2fd7bf863..df20fd4824 100644 --- a/core/embed/lib/image.c +++ b/core/embed/util/image/image.c @@ -22,8 +22,8 @@ #include "ed25519-donna/ed25519.h" -#include "flash.h" -#include "image.h" +#include +#include _Static_assert(VENDOR_HEADER_MAX_SIZE + IMAGE_HEADER_SIZE <= IMAGE_CHUNK_SIZE, "The size of the firmware headers must be less than or equal to " diff --git a/core/embed/lib/image.h b/core/embed/util/image/inc/util/image.h similarity index 99% rename from core/embed/lib/image.h rename to core/embed/util/image/inc/util/image.h index a2d02dd105..7ed0b400f7 100644 --- a/core/embed/lib/image.h +++ b/core/embed/util/image/inc/util/image.h @@ -23,8 +23,9 @@ #include #include +#include #include "blake2s.h" -#include "flash.h" + #include "image_hash_conf.h" #define VENDOR_HEADER_MAX_SIZE (64 * 1024) diff --git a/core/embed/lib/image_hash_conf.h b/core/embed/util/image/inc/util/image_hash_conf.h similarity index 97% rename from core/embed/lib/image_hash_conf.h rename to core/embed/util/image/inc/util/image_hash_conf.h index e7acaa3564..3b509d2cf5 100644 --- a/core/embed/lib/image_hash_conf.h +++ b/core/embed/util/image/inc/util/image_hash_conf.h @@ -8,7 +8,7 @@ #include "sha2.h" #define IMAGE_HASH_DIGEST_LENGTH SHA256_DIGEST_LENGTH #if defined(USE_HASH_PROCESSOR) && defined(KERNEL_MODE) -#include "hash_processor.h" +#include #define IMAGE_HASH_CTX hash_sha256_context_t #define IMAGE_HASH_INIT(ctx) hash_processor_sha256_init(ctx) #define IMAGE_HASH_UPDATE(ctx, data, len) \ diff --git a/core/embed/trezorhal/option_bytes.h b/core/embed/util/option_bytes/inc/util/option_bytes.h similarity index 100% rename from core/embed/trezorhal/option_bytes.h rename to core/embed/util/option_bytes/inc/util/option_bytes.h diff --git a/core/embed/trezorhal/stm32f4/option_bytes.c b/core/embed/util/option_bytes/stm32f4/option_bytes.c similarity index 98% rename from core/embed/trezorhal/stm32f4/option_bytes.c rename to core/embed/util/option_bytes/stm32f4/option_bytes.c index 03707c25fb..f3327dc71c 100644 --- a/core/embed/trezorhal/stm32f4/option_bytes.c +++ b/core/embed/util/option_bytes/stm32f4/option_bytes.c @@ -19,9 +19,9 @@ #include -#include "flash_otp.h" -#include "mpu.h" -#include "option_bytes.h" +#include +#include +#include #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/stm32u5/option_bytes.c b/core/embed/util/option_bytes/stm32u5/option_bytes.c similarity index 99% rename from core/embed/trezorhal/stm32u5/option_bytes.c rename to core/embed/util/option_bytes/stm32u5/option_bytes.c index 38fae4c05a..a797a77dfe 100644 --- a/core/embed/trezorhal/stm32u5/option_bytes.c +++ b/core/embed/util/option_bytes/stm32u5/option_bytes.c @@ -23,8 +23,8 @@ #ifdef KERNEL_MODE -#include "flash.h" -#include "option_bytes.h" +#include +#include #pragma GCC optimize( \ "no-stack-protector") // applies to all functions in this file diff --git a/core/embed/lib/rsod.h b/core/embed/util/rsod/inc/util/rsod.h similarity index 98% rename from core/embed/lib/rsod.h rename to core/embed/util/rsod/inc/util/rsod.h index 86f302d861..9cd858bba9 100644 --- a/core/embed/lib/rsod.h +++ b/core/embed/util/rsod/inc/util/rsod.h @@ -20,7 +20,7 @@ #ifndef LIB_RSOD_H #define LIB_RSOD_H -#include "systask.h" +#include // Shows RSOD (Red Screen of Death) using terminal. void rsod_terminal(const systask_postmortem_t* pminfo); diff --git a/core/embed/lib/rsod.c b/core/embed/util/rsod/rsod.c similarity index 96% rename from core/embed/lib/rsod.c rename to core/embed/util/rsod/rsod.c index 87be6aea73..e802933416 100644 --- a/core/embed/lib/rsod.c +++ b/core/embed/util/rsod/rsod.c @@ -17,12 +17,12 @@ * along with this program. If not, see . */ -#include "rsod.h" -#include "bootutils.h" -#include "display.h" -#include "mini_printf.h" -#include "system.h" -#include "terminal.h" +#include +#include +#include +#include +#include +#include #define RSOD_DEFAULT_TITLE "INTERNAL ERROR"; #define RSOD_DEFAULT_MESSAGE "UNSPECIFIED"; diff --git a/core/embed/lib/translations.h b/core/embed/util/translations/inc/util/translations.h similarity index 100% rename from core/embed/lib/translations.h rename to core/embed/util/translations/inc/util/translations.h diff --git a/core/embed/lib/translations.c b/core/embed/util/translations/translations.c similarity index 94% rename from core/embed/lib/translations.c rename to core/embed/util/translations/translations.c index e9dcbb6c01..f272405482 100644 --- a/core/embed/lib/translations.c +++ b/core/embed/util/translations/translations.c @@ -1,9 +1,9 @@ #include #include -#include "flash.h" -#include "mpu.h" -#include "translations.h" +#include +#include +#include #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/unit_properties.h b/core/embed/util/unit_properties/inc/util/unit_properties.h similarity index 100% rename from core/embed/trezorhal/unit_properties.h rename to core/embed/util/unit_properties/inc/util/unit_properties.h diff --git a/core/embed/trezorhal/stm32f4/unit_properties.c b/core/embed/util/unit_properties/stm32/unit_properties.c similarity index 98% rename from core/embed/trezorhal/stm32f4/unit_properties.c rename to core/embed/util/unit_properties/stm32/unit_properties.c index 940c26a8e7..527c48ce6b 100644 --- a/core/embed/trezorhal/stm32f4/unit_properties.c +++ b/core/embed/util/unit_properties/stm32/unit_properties.c @@ -21,8 +21,8 @@ #include #include -#include "flash_otp.h" -#include "unit_properties.h" +#include +#include #ifdef KERNEL_MODE diff --git a/core/embed/trezorhal/unix/unit_properties.c b/core/embed/util/unit_properties/unix/unit_properties.c similarity index 97% rename from core/embed/trezorhal/unix/unit_properties.c rename to core/embed/util/unit_properties/unix/unit_properties.c index a90291ff9d..c2de25732e 100644 --- a/core/embed/trezorhal/unix/unit_properties.c +++ b/core/embed/util/unit_properties/unix/unit_properties.c @@ -20,8 +20,8 @@ #include #include -#include "flash_otp.h" -#include "unit_properties.h" +#include +#include // Unit properties driver structure typedef struct { diff --git a/core/mocks/generated/trezorconfig.pyi b/core/mocks/generated/trezorconfig.pyi index 14d59a7a15..48393ae935 100644 --- a/core/mocks/generated/trezorconfig.pyi +++ b/core/mocks/generated/trezorconfig.pyi @@ -1,7 +1,7 @@ from typing import * -# extmod/modtrezorconfig/modtrezorconfig.c +# upymod/modtrezorconfig/modtrezorconfig.c def init( ui_wait_callback: Callable[[int, int, StorageMessage], bool] | None = None @@ -12,7 +12,7 @@ def init( """ -# extmod/modtrezorconfig/modtrezorconfig.c +# upymod/modtrezorconfig/modtrezorconfig.c def unlock(pin: str, ext_salt: bytes | None) -> bool: """ Attempts to unlock the storage with the given PIN and external salt. @@ -20,7 +20,7 @@ def unlock(pin: str, ext_salt: bytes | None) -> bool: """ -# extmod/modtrezorconfig/modtrezorconfig.c +# upymod/modtrezorconfig/modtrezorconfig.c def check_pin(pin: str, ext_salt: bytes | None) -> bool: """ Check the given PIN with the given external salt. @@ -28,35 +28,35 @@ def check_pin(pin: str, ext_salt: bytes | None) -> bool: """ -# extmod/modtrezorconfig/modtrezorconfig.c +# upymod/modtrezorconfig/modtrezorconfig.c def lock() -> None: """ Locks the storage. """ -# extmod/modtrezorconfig/modtrezorconfig.c +# upymod/modtrezorconfig/modtrezorconfig.c def is_unlocked() -> bool: """ Returns True if storage is unlocked, False otherwise. """ -# extmod/modtrezorconfig/modtrezorconfig.c +# upymod/modtrezorconfig/modtrezorconfig.c def has_pin() -> bool: """ Returns True if storage has a configured PIN, False otherwise. """ -# extmod/modtrezorconfig/modtrezorconfig.c +# upymod/modtrezorconfig/modtrezorconfig.c def get_pin_rem() -> int: """ Returns the number of remaining PIN entry attempts. """ -# extmod/modtrezorconfig/modtrezorconfig.c +# upymod/modtrezorconfig/modtrezorconfig.c def change_pin( oldpin: str, newpin: str, @@ -68,21 +68,21 @@ def change_pin( """ -# extmod/modtrezorconfig/modtrezorconfig.c +# upymod/modtrezorconfig/modtrezorconfig.c def ensure_not_wipe_code(pin: str) -> None: """ Wipes the device if the entered PIN is the wipe code. """ -# extmod/modtrezorconfig/modtrezorconfig.c +# upymod/modtrezorconfig/modtrezorconfig.c def has_wipe_code() -> bool: """ Returns True if storage has a configured wipe code, False otherwise. """ -# extmod/modtrezorconfig/modtrezorconfig.c +# upymod/modtrezorconfig/modtrezorconfig.c def change_wipe_code( pin: str, ext_salt: bytes | None, @@ -93,7 +93,7 @@ def change_wipe_code( """ -# extmod/modtrezorconfig/modtrezorconfig.c +# upymod/modtrezorconfig/modtrezorconfig.c def get(app: int, key: int, public: bool = False) -> bytes | None: """ Gets the value of the given key for the given app (or None if not set). @@ -102,14 +102,14 @@ def get(app: int, key: int, public: bool = False) -> bytes | None: """ -# extmod/modtrezorconfig/modtrezorconfig.c +# upymod/modtrezorconfig/modtrezorconfig.c def set(app: int, key: int, value: bytes, public: bool = False) -> None: """ Sets a value of given key for given app. """ -# extmod/modtrezorconfig/modtrezorconfig.c +# upymod/modtrezorconfig/modtrezorconfig.c def delete( app: int, key: int, public: bool = False, writable_locked: bool = False ) -> bool: @@ -118,7 +118,7 @@ def delete( """ -# extmod/modtrezorconfig/modtrezorconfig.c +# upymod/modtrezorconfig/modtrezorconfig.c def set_counter( app: int, key: int, count: int, writable_locked: bool = False ) -> None: @@ -127,7 +127,7 @@ def set_counter( """ -# extmod/modtrezorconfig/modtrezorconfig.c +# upymod/modtrezorconfig/modtrezorconfig.c def next_counter( app: int, key: int, writable_locked: bool = False, ) -> int: @@ -137,7 +137,7 @@ def next_counter( """ -# extmod/modtrezorconfig/modtrezorconfig.c +# upymod/modtrezorconfig/modtrezorconfig.c def wipe() -> None: """ Erases the whole config. Use with caution! @@ -145,7 +145,7 @@ def wipe() -> None: from enum import IntEnum -# extmod/modtrezorconfig/modtrezorconfig.c +# upymod/modtrezorconfig/modtrezorconfig.c class StorageMessage(IntEnum): NO_MSG = 0 VERIFYING_PIN_MSG = 1 diff --git a/core/mocks/generated/trezorcrypto/__init__.pyi b/core/mocks/generated/trezorcrypto/__init__.pyi index 7792fbe085..4d9ef558ba 100644 --- a/core/mocks/generated/trezorcrypto/__init__.pyi +++ b/core/mocks/generated/trezorcrypto/__init__.pyi @@ -1,7 +1,7 @@ from typing import * -# extmod/modtrezorcrypto/modtrezorcrypto-aes.h +# upymod/modtrezorcrypto/modtrezorcrypto-aes.h class aes: """ AES context. @@ -33,7 +33,7 @@ class aes: """ -# extmod/modtrezorcrypto/modtrezorcrypto-aesgcm.h +# upymod/modtrezorcrypto/modtrezorcrypto-aesgcm.h class aesgcm: """ AES-GCM context. @@ -82,7 +82,7 @@ class aesgcm: """ -# extmod/modtrezorcrypto/modtrezorcrypto-blake256.h +# upymod/modtrezorcrypto/modtrezorcrypto-blake256.h class blake256: """ Blake256 context. @@ -106,7 +106,7 @@ class blake256: """ -# extmod/modtrezorcrypto/modtrezorcrypto-blake2b.h +# upymod/modtrezorcrypto/modtrezorcrypto-blake2b.h class blake2b: """ Blake2b context. @@ -136,7 +136,7 @@ class blake2b: """ -# extmod/modtrezorcrypto/modtrezorcrypto-blake2s.h +# upymod/modtrezorcrypto/modtrezorcrypto-blake2s.h class blake2s: """ Blake2s context. @@ -166,7 +166,7 @@ class blake2s: """ -# extmod/modtrezorcrypto/modtrezorcrypto-chacha20poly1305.h +# upymod/modtrezorcrypto/modtrezorcrypto-chacha20poly1305.h class chacha20poly1305: """ ChaCha20Poly1305 context. @@ -203,7 +203,7 @@ class chacha20poly1305: """ -# extmod/modtrezorcrypto/modtrezorcrypto-groestl.h +# upymod/modtrezorcrypto/modtrezorcrypto-groestl.h class groestl512: """ GROESTL512 context. @@ -227,7 +227,7 @@ class groestl512: """ -# extmod/modtrezorcrypto/modtrezorcrypto-hmac.h +# upymod/modtrezorcrypto/modtrezorcrypto-hmac.h class hmac: """ HMAC context. @@ -256,7 +256,7 @@ class hmac: """ -# extmod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h +# upymod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h class pbkdf2: """ PBKDF2 context. @@ -287,7 +287,7 @@ class pbkdf2: """ -# extmod/modtrezorcrypto/modtrezorcrypto-ripemd160.h +# upymod/modtrezorcrypto/modtrezorcrypto-ripemd160.h class ripemd160: """ RIPEMD160 context. @@ -311,7 +311,7 @@ class ripemd160: """ -# extmod/modtrezorcrypto/modtrezorcrypto-sha1.h +# upymod/modtrezorcrypto/modtrezorcrypto-sha1.h class sha1: """ SHA1 context. @@ -335,7 +335,7 @@ class sha1: """ -# extmod/modtrezorcrypto/modtrezorcrypto-sha256.h +# upymod/modtrezorcrypto/modtrezorcrypto-sha256.h class sha256: """ SHA256 context. @@ -359,7 +359,7 @@ class sha256: """ -# extmod/modtrezorcrypto/modtrezorcrypto-sha3-256.h +# upymod/modtrezorcrypto/modtrezorcrypto-sha3-256.h class sha3_256: """ SHA3_256 context. @@ -392,7 +392,7 @@ class sha3_256: """ -# extmod/modtrezorcrypto/modtrezorcrypto-sha3-512.h +# upymod/modtrezorcrypto/modtrezorcrypto-sha3-512.h class sha3_512: """ SHA3_512 context. @@ -425,7 +425,7 @@ class sha3_512: """ -# extmod/modtrezorcrypto/modtrezorcrypto-sha512.h +# upymod/modtrezorcrypto/modtrezorcrypto-sha512.h class sha512: """ SHA512 context. diff --git a/core/mocks/generated/trezorcrypto/bech32.pyi b/core/mocks/generated/trezorcrypto/bech32.pyi index 3303846974..c47a7b3893 100644 --- a/core/mocks/generated/trezorcrypto/bech32.pyi +++ b/core/mocks/generated/trezorcrypto/bech32.pyi @@ -1,7 +1,7 @@ from typing import * -# extmod/modtrezorcrypto/modtrezorcrypto-bech32.h +# upymod/modtrezorcrypto/modtrezorcrypto-bech32.h def decode( bech: str, max_bech_len: int = 90, diff --git a/core/mocks/generated/trezorcrypto/bip32.pyi b/core/mocks/generated/trezorcrypto/bip32.pyi index e2a8cbde9e..be8b08e233 100644 --- a/core/mocks/generated/trezorcrypto/bip32.pyi +++ b/core/mocks/generated/trezorcrypto/bip32.pyi @@ -1,7 +1,7 @@ from typing import * -# extmod/modtrezorcrypto/modtrezorcrypto-bip32.h +# upymod/modtrezorcrypto/modtrezorcrypto-bip32.h class HDNode: """ BIP0032 HD node structure. @@ -104,7 +104,7 @@ class HDNode: """ -# extmod/modtrezorcrypto/modtrezorcrypto-bip32.h +# upymod/modtrezorcrypto/modtrezorcrypto-bip32.h def from_seed(seed: bytes, curve_name: str) -> HDNode: """ Construct a BIP0032 HD node from a BIP0039 seed value. diff --git a/core/mocks/generated/trezorcrypto/bip340.pyi b/core/mocks/generated/trezorcrypto/bip340.pyi index 855cb20029..1039c9d7cf 100644 --- a/core/mocks/generated/trezorcrypto/bip340.pyi +++ b/core/mocks/generated/trezorcrypto/bip340.pyi @@ -1,21 +1,21 @@ from typing import * -# extmod/modtrezorcrypto/modtrezorcrypto-bip340.h +# upymod/modtrezorcrypto/modtrezorcrypto-bip340.h def generate_secret() -> bytes: """ Generate secret key. """ -# extmod/modtrezorcrypto/modtrezorcrypto-bip340.h +# upymod/modtrezorcrypto/modtrezorcrypto-bip340.h def publickey(secret_key: bytes) -> bytes: """ Computes public key from secret key. """ -# extmod/modtrezorcrypto/modtrezorcrypto-bip340.h +# upymod/modtrezorcrypto/modtrezorcrypto-bip340.h def sign( secret_key: bytes, digest: bytes, @@ -25,7 +25,7 @@ def sign( """ -# extmod/modtrezorcrypto/modtrezorcrypto-bip340.h +# upymod/modtrezorcrypto/modtrezorcrypto-bip340.h def verify_publickey(public_key: bytes) -> bool: """ Verifies whether the public key is valid. @@ -33,7 +33,7 @@ def verify_publickey(public_key: bytes) -> bool: """ -# extmod/modtrezorcrypto/modtrezorcrypto-bip340.h +# upymod/modtrezorcrypto/modtrezorcrypto-bip340.h def verify(public_key: bytes, signature: bytes, digest: bytes) -> bool: """ Uses public key to verify the signature of the digest. @@ -41,7 +41,7 @@ def verify(public_key: bytes, signature: bytes, digest: bytes) -> bool: """ -# extmod/modtrezorcrypto/modtrezorcrypto-bip340.h +# upymod/modtrezorcrypto/modtrezorcrypto-bip340.h def tweak_public_key( public_key: bytes, root_hash: bytes | None = None, @@ -51,7 +51,7 @@ def tweak_public_key( """ -# extmod/modtrezorcrypto/modtrezorcrypto-bip340.h +# upymod/modtrezorcrypto/modtrezorcrypto-bip340.h def tweak_secret_key( secret_key: bytes, root_hash: bytes | None = None, diff --git a/core/mocks/generated/trezorcrypto/bip39.pyi b/core/mocks/generated/trezorcrypto/bip39.pyi index 2bc41eaca9..16955bfde2 100644 --- a/core/mocks/generated/trezorcrypto/bip39.pyi +++ b/core/mocks/generated/trezorcrypto/bip39.pyi @@ -1,28 +1,28 @@ from typing import * -# extmod/modtrezorcrypto/modtrezorcrypto-bip39.h +# upymod/modtrezorcrypto/modtrezorcrypto-bip39.h def generate(strength: int) -> str: """ Generate a mnemonic of given strength (128, 160, 192, 224 and 256 bits). """ -# extmod/modtrezorcrypto/modtrezorcrypto-bip39.h +# upymod/modtrezorcrypto/modtrezorcrypto-bip39.h def from_data(data: bytes) -> str: """ Generate a mnemonic from given data (of 16, 20, 24, 28 and 32 bytes). """ -# extmod/modtrezorcrypto/modtrezorcrypto-bip39.h +# upymod/modtrezorcrypto/modtrezorcrypto-bip39.h def check(mnemonic: str) -> bool: """ Check whether given mnemonic is valid. """ -# extmod/modtrezorcrypto/modtrezorcrypto-bip39.h +# upymod/modtrezorcrypto/modtrezorcrypto-bip39.h def seed( mnemonic: str, passphrase: str, diff --git a/core/mocks/generated/trezorcrypto/cardano.pyi b/core/mocks/generated/trezorcrypto/cardano.pyi index f5b839b9e9..3633b2581e 100644 --- a/core/mocks/generated/trezorcrypto/cardano.pyi +++ b/core/mocks/generated/trezorcrypto/cardano.pyi @@ -2,7 +2,7 @@ from typing import * from trezorcrypto.bip32 import HDNode -# extmod/modtrezorcrypto/modtrezorcrypto-cardano.h +# upymod/modtrezorcrypto/modtrezorcrypto-cardano.h def derive_icarus( mnemonic: str, passphrase: str, @@ -17,21 +17,21 @@ def derive_icarus( """ -# extmod/modtrezorcrypto/modtrezorcrypto-cardano.h +# upymod/modtrezorcrypto/modtrezorcrypto-cardano.h def from_secret(secret: bytes) -> HDNode: """ Creates a Cardano HD node from a master secret. """ -# extmod/modtrezorcrypto/modtrezorcrypto-cardano.h +# upymod/modtrezorcrypto/modtrezorcrypto-cardano.h def from_seed_slip23(seed: bytes) -> HDNode: """ Creates a Cardano HD node from a seed via SLIP-23 derivation. """ -# extmod/modtrezorcrypto/modtrezorcrypto-cardano.h +# upymod/modtrezorcrypto/modtrezorcrypto-cardano.h def from_seed_ledger(seed: bytes) -> HDNode: """ Creates a Cardano HD node from a seed via Ledger derivation. diff --git a/core/mocks/generated/trezorcrypto/crc.pyi b/core/mocks/generated/trezorcrypto/crc.pyi index c9d7c05aff..9a319f79ac 100644 --- a/core/mocks/generated/trezorcrypto/crc.pyi +++ b/core/mocks/generated/trezorcrypto/crc.pyi @@ -1,7 +1,7 @@ from typing import * -# extmod/modtrezorcrypto/modtrezorcrypto-crc.h +# upymod/modtrezorcrypto/modtrezorcrypto-crc.h def crc32(data: bytes, crc: int = 0) -> int: """ Computes a CRC32 checksum of `data`. diff --git a/core/mocks/generated/trezorcrypto/curve25519.pyi b/core/mocks/generated/trezorcrypto/curve25519.pyi index 1e7b4559f7..e5ac78ebf8 100644 --- a/core/mocks/generated/trezorcrypto/curve25519.pyi +++ b/core/mocks/generated/trezorcrypto/curve25519.pyi @@ -1,21 +1,21 @@ from typing import * -# extmod/modtrezorcrypto/modtrezorcrypto-curve25519.h +# upymod/modtrezorcrypto/modtrezorcrypto-curve25519.h def generate_secret() -> bytes: """ Generate secret key. """ -# extmod/modtrezorcrypto/modtrezorcrypto-curve25519.h +# upymod/modtrezorcrypto/modtrezorcrypto-curve25519.h def publickey(secret_key: bytes) -> bytes: """ Computes public key from secret key. """ -# extmod/modtrezorcrypto/modtrezorcrypto-curve25519.h +# upymod/modtrezorcrypto/modtrezorcrypto-curve25519.h def multiply(secret_key: bytes, public_key: bytes) -> bytes: """ Multiplies point defined by public_key with scalar defined by diff --git a/core/mocks/generated/trezorcrypto/ed25519.pyi b/core/mocks/generated/trezorcrypto/ed25519.pyi index 735c4dce3b..07da52b358 100644 --- a/core/mocks/generated/trezorcrypto/ed25519.pyi +++ b/core/mocks/generated/trezorcrypto/ed25519.pyi @@ -1,28 +1,28 @@ from typing import * -# extmod/modtrezorcrypto/modtrezorcrypto-ed25519.h +# upymod/modtrezorcrypto/modtrezorcrypto-ed25519.h def generate_secret() -> bytes: """ Generate secret key. """ -# extmod/modtrezorcrypto/modtrezorcrypto-ed25519.h +# upymod/modtrezorcrypto/modtrezorcrypto-ed25519.h def publickey(secret_key: bytes) -> bytes: """ Computes public key from secret key. """ -# extmod/modtrezorcrypto/modtrezorcrypto-ed25519.h +# upymod/modtrezorcrypto/modtrezorcrypto-ed25519.h def sign(secret_key: bytes, message: bytes, hasher: str = "") -> bytes: """ Uses secret key to produce the signature of message. """ -# extmod/modtrezorcrypto/modtrezorcrypto-ed25519.h +# upymod/modtrezorcrypto/modtrezorcrypto-ed25519.h def sign_ext( secret_scalar: bytes, secret_extension: bytes, message: bytes ) -> bytes: @@ -31,7 +31,7 @@ def sign_ext( """ -# extmod/modtrezorcrypto/modtrezorcrypto-ed25519.h +# upymod/modtrezorcrypto/modtrezorcrypto-ed25519.h def verify(public_key: bytes, signature: bytes, message: bytes) -> bool: """ Uses public key to verify the signature of the message. @@ -39,28 +39,28 @@ def verify(public_key: bytes, signature: bytes, message: bytes) -> bool: """ -# extmod/modtrezorcrypto/modtrezorcrypto-ed25519.h +# upymod/modtrezorcrypto/modtrezorcrypto-ed25519.h def cosi_combine_publickeys(public_keys: list[bytes]) -> bytes: """ Combines a list of public keys used in COSI cosigning scheme. """ -# extmod/modtrezorcrypto/modtrezorcrypto-ed25519.h +# upymod/modtrezorcrypto/modtrezorcrypto-ed25519.h def cosi_combine_signatures(R: bytes, signatures: list[bytes]) -> bytes: """ Combines a list of signatures used in COSI cosigning scheme. """ -# extmod/modtrezorcrypto/modtrezorcrypto-ed25519.h +# upymod/modtrezorcrypto/modtrezorcrypto-ed25519.h def cosi_commit() -> tuple[bytes, bytes]: """ Generate a nonce and commitment for the CoSi cosigning scheme. """ -# extmod/modtrezorcrypto/modtrezorcrypto-ed25519.h +# upymod/modtrezorcrypto/modtrezorcrypto-ed25519.h def cosi_sign( secret_key: bytes, message: bytes, diff --git a/core/mocks/generated/trezorcrypto/elligator2.pyi b/core/mocks/generated/trezorcrypto/elligator2.pyi index c1e1bae8da..c924067891 100644 --- a/core/mocks/generated/trezorcrypto/elligator2.pyi +++ b/core/mocks/generated/trezorcrypto/elligator2.pyi @@ -1,7 +1,7 @@ from typing import * -# extmod/modtrezorcrypto/modtrezorcrypto-elligator2.h +# upymod/modtrezorcrypto/modtrezorcrypto-elligator2.h def map_to_curve25519(input: bytes) -> bytes: """ Maps a 32-byte input to a curve25519 point. diff --git a/core/mocks/generated/trezorcrypto/monero.pyi b/core/mocks/generated/trezorcrypto/monero.pyi index a4da402f2b..e38926d165 100644 --- a/core/mocks/generated/trezorcrypto/monero.pyi +++ b/core/mocks/generated/trezorcrypto/monero.pyi @@ -1,7 +1,7 @@ from typing import * -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h class Point: """ EC point on ED25519 @@ -12,7 +12,7 @@ class Point: """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h class Scalar: """ EC scalar on SC25519 @@ -23,7 +23,7 @@ class Scalar: """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h class Hasher: """ XMR hasher @@ -46,7 +46,7 @@ class Hasher: """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def sc_copy( dst: Scalar | None, val: int | bytes | Scalar ) -> Scalar: @@ -55,49 +55,49 @@ def sc_copy( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def sc_check(val: Scalar) -> None: """ Throws exception if scalar is invalid """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def sc_iszero(val: Scalar) -> bool: """ Returns False if the scalar is zero """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def sc_eq(a: Scalar, b: Scalar) -> int: """ Compares scalars, returns 1 on the same value """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def sc_add_into(r: Scalar | None, a: Scalar, b: Scalar) -> Scalar: """ Scalar addition """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def sc_sub_into(r: Scalar | None, a: Scalar, b: Scalar) -> Scalar: """ Scalar subtraction """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def sc_mul_into(r: Scalar | None, a: Scalar, b: Scalar) -> Scalar: """ Scalar multiplication """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def sc_mulsub_into( r: Scalar | None, a: Scalar, b: Scalar, c: Scalar ) -> Scalar: @@ -106,7 +106,7 @@ def sc_mulsub_into( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def sc_muladd_into( r: Scalar | None, a: Scalar, b: Scalar, c: Scalar ) -> Scalar: @@ -115,14 +115,14 @@ def sc_muladd_into( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def sc_inv_into(r: Scalar | None, a: Scalar) -> Scalar: """ Scalar modular inversion """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def encodeint_into( r: bytes | None, a: Scalar, offset: int | None = 0 ) -> bytes: @@ -131,7 +131,7 @@ def encodeint_into( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def decodeint_into( r: Scalar | None, a: bytes, offset: int = 0 ) -> Scalar: @@ -140,7 +140,7 @@ def decodeint_into( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def decodeint_into_noreduce( r: Scalar | None, a: bytes, offset: int = 0 ) -> Scalar: @@ -149,56 +149,56 @@ def decodeint_into_noreduce( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def identity_into(r: Point | None = None) -> Point: """ Sets neutral point """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def xmr_H(r: Point | None = None) -> Point: """ Sets H point """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def ge25519_check(r: Point) -> None: """ Checks point, throws if not on curve """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def point_eq(a: Point, b: Point) -> bool: """ Compares EC points """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def point_add_into(r: Point | None, a: Point, b: Point) -> Point: """ Adds EC points """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def point_sub_into(r: Point | None, a: Point, b: Point) -> Point: """ Subtracts EC points """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def ge25519_mul8(r: Point | None, p: Point) -> Point: """ EC point * 8 """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def ge25519_double_scalarmult_vartime_into( r: Point | None, p1: Point, s1: Scalar, s2: Scalar ) -> Point: @@ -207,7 +207,7 @@ def ge25519_double_scalarmult_vartime_into( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def scalarmult_base_into( r: Point | None, s: Scalar | int ) -> Point: @@ -216,7 +216,7 @@ def scalarmult_base_into( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def scalarmult_into( r: Point | None, p: Point, s: Scalar | int ) -> Point: @@ -225,14 +225,14 @@ def scalarmult_into( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def encodepoint_into(r: bytes | None, p: Point, offset: int = 0) -> bytes: """ Point compression """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def decodepoint_into( r: Point | None, buff: bytes, offset: int = 0 ) -> Point: @@ -241,14 +241,14 @@ def decodepoint_into( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def xmr_base58_addr_encode_check(tag: int, buff: bytes) -> str: """ Monero block base 58 encoding """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def xmr_base58_addr_decode_check(buff: bytes) -> tuple[bytes, int]: """ Monero block base 58 decoding, returning (decoded, tag) or raising on @@ -256,14 +256,14 @@ def xmr_base58_addr_decode_check(buff: bytes) -> tuple[bytes, int]: """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def random_scalar(r: Scalar | None = None) -> Scalar: """ Generates a random scalar """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def fast_hash_into( r: bytes | None, buff: bytes, @@ -275,7 +275,7 @@ def fast_hash_into( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def hash_to_point_into( r: Point | None, buff: bytes, @@ -287,7 +287,7 @@ def hash_to_point_into( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def hash_to_scalar_into( r: Scalar | None, buff: bytes, @@ -299,7 +299,7 @@ def hash_to_scalar_into( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def xmr_derivation_to_scalar( r: Scalar | None, p: Point, output_index: int ) -> Scalar: @@ -308,7 +308,7 @@ def xmr_derivation_to_scalar( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def xmr_generate_key_derivation( r: Point | None, A: Point, b: Scalar ) -> Point: @@ -317,7 +317,7 @@ def xmr_generate_key_derivation( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def xmr_derive_private_key( r: Scalar | None, deriv: Point, idx: int, base: Scalar ) -> Scalar: @@ -326,7 +326,7 @@ def xmr_derive_private_key( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def xmr_derive_public_key( r: Point | None, deriv: Point, idx: int, base: Point ) -> Point: @@ -335,7 +335,7 @@ def xmr_derive_public_key( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def add_keys2_into( r: Point | None, a: Scalar, b: Scalar, B: Point ) -> Point: @@ -344,7 +344,7 @@ def add_keys2_into( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def add_keys3_into( r: Point | None, a: Scalar, A: Point, b: Scalar, B: Point ) -> Point: @@ -353,7 +353,7 @@ def add_keys3_into( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def xmr_get_subaddress_secret_key( r: Scalar | None, major: int, minor: int, m: Scalar ) -> Scalar: @@ -362,14 +362,14 @@ def xmr_get_subaddress_secret_key( """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def gen_commitment_into(r: Point | None, a: Scalar, amount: int) -> Point: """ aG + amount * H """ -# extmod/modtrezorcrypto/modtrezorcrypto-monero.h +# upymod/modtrezorcrypto/modtrezorcrypto-monero.h def ct_equals(a: bytes, b: bytes) -> bool: """ Constant time buffer comparison diff --git a/core/mocks/generated/trezorcrypto/nem.pyi b/core/mocks/generated/trezorcrypto/nem.pyi index 142279536c..896bae2444 100644 --- a/core/mocks/generated/trezorcrypto/nem.pyi +++ b/core/mocks/generated/trezorcrypto/nem.pyi @@ -1,14 +1,14 @@ from typing import * -# extmod/modtrezorcrypto/modtrezorcrypto-nem.h +# upymod/modtrezorcrypto/modtrezorcrypto-nem.h def validate_address(address: str, network: int) -> bool: """ Validate a NEM address """ -# extmod/modtrezorcrypto/modtrezorcrypto-nem.h +# upymod/modtrezorcrypto/modtrezorcrypto-nem.h def compute_address(public_key: bytes, network: int) -> str: """ Compute a NEM address from a public key diff --git a/core/mocks/generated/trezorcrypto/nist256p1.pyi b/core/mocks/generated/trezorcrypto/nist256p1.pyi index 996a4c41f3..204d03c908 100644 --- a/core/mocks/generated/trezorcrypto/nist256p1.pyi +++ b/core/mocks/generated/trezorcrypto/nist256p1.pyi @@ -1,21 +1,21 @@ from typing import * -# extmod/modtrezorcrypto/modtrezorcrypto-nist256p1.h +# upymod/modtrezorcrypto/modtrezorcrypto-nist256p1.h def generate_secret() -> bytes: """ Generate secret key. """ -# extmod/modtrezorcrypto/modtrezorcrypto-nist256p1.h +# upymod/modtrezorcrypto/modtrezorcrypto-nist256p1.h def publickey(secret_key: bytes, compressed: bool = True) -> bytes: """ Computes public key from secret key. """ -# extmod/modtrezorcrypto/modtrezorcrypto-nist256p1.h +# upymod/modtrezorcrypto/modtrezorcrypto-nist256p1.h def sign( secret_key: bytes, digest: bytes, compressed: bool = True ) -> bytes: @@ -24,7 +24,7 @@ def sign( """ -# extmod/modtrezorcrypto/modtrezorcrypto-nist256p1.h +# upymod/modtrezorcrypto/modtrezorcrypto-nist256p1.h def verify(public_key: bytes, signature: bytes, digest: bytes) -> bool: """ Uses public key to verify the signature of the digest. @@ -32,7 +32,7 @@ def verify(public_key: bytes, signature: bytes, digest: bytes) -> bool: """ -# extmod/modtrezorcrypto/modtrezorcrypto-nist256p1.h +# upymod/modtrezorcrypto/modtrezorcrypto-nist256p1.h def verify_recover(signature: bytes, digest: bytes) -> bytes: """ Uses signature of the digest to verify the digest and recover the public @@ -40,7 +40,7 @@ def verify_recover(signature: bytes, digest: bytes) -> bytes: """ -# extmod/modtrezorcrypto/modtrezorcrypto-nist256p1.h +# upymod/modtrezorcrypto/modtrezorcrypto-nist256p1.h def multiply(secret_key: bytes, public_key: bytes) -> bytes: """ Multiplies point defined by public_key with scalar defined by diff --git a/core/mocks/generated/trezorcrypto/optiga.pyi b/core/mocks/generated/trezorcrypto/optiga.pyi index af5a36b7a1..dac03ebc22 100644 --- a/core/mocks/generated/trezorcrypto/optiga.pyi +++ b/core/mocks/generated/trezorcrypto/optiga.pyi @@ -1,26 +1,26 @@ from typing import * -# extmod/modtrezorcrypto/modtrezorcrypto-optiga.h +# upymod/modtrezorcrypto/modtrezorcrypto-optiga.h class OptigaError(Exception): """Error returned by the Optiga chip.""" -# extmod/modtrezorcrypto/modtrezorcrypto-optiga.h +# upymod/modtrezorcrypto/modtrezorcrypto-optiga.h class SigningInaccessible(OptigaError): """The signing key is inaccessible. Typically, this will happen after the bootloader has been unlocked. """ -# extmod/modtrezorcrypto/modtrezorcrypto-optiga.h +# upymod/modtrezorcrypto/modtrezorcrypto-optiga.h def get_certificate(cert_index: int) -> bytes: """ Return the certificate stored at the given index. """ -# extmod/modtrezorcrypto/modtrezorcrypto-optiga.h +# upymod/modtrezorcrypto/modtrezorcrypto-optiga.h def sign( key_index: int, digest: bytes, @@ -31,14 +31,14 @@ def sign( """ -# extmod/modtrezorcrypto/modtrezorcrypto-optiga.h +# upymod/modtrezorcrypto/modtrezorcrypto-optiga.h def get_sec() -> int | None: """ Returns the value of Optiga's security event counter. """ -# extmod/modtrezorcrypto/modtrezorcrypto-optiga.h +# upymod/modtrezorcrypto/modtrezorcrypto-optiga.h def set_sec_max() -> None: """ Set Optiga's security event counter to maximum. diff --git a/core/mocks/generated/trezorcrypto/random.pyi b/core/mocks/generated/trezorcrypto/random.pyi index bd32605801..b13e5a5495 100644 --- a/core/mocks/generated/trezorcrypto/random.pyi +++ b/core/mocks/generated/trezorcrypto/random.pyi @@ -1,7 +1,7 @@ from typing import * -# extmod/modtrezorcrypto/modtrezorcrypto-random.h +# upymod/modtrezorcrypto/modtrezorcrypto-random.h def uniform(n: int) -> int: """ Compute uniform random number from interval 0 ... n - 1. @@ -9,7 +9,7 @@ def uniform(n: int) -> int: import builtins -# extmod/modtrezorcrypto/modtrezorcrypto-random.h +# upymod/modtrezorcrypto/modtrezorcrypto-random.h def bytes(len: int, strong: bool = False) -> builtins.bytes: """ Generate random bytes sequence of length len. If `strong` is set then @@ -17,14 +17,14 @@ def bytes(len: int, strong: bool = False) -> builtins.bytes: """ -# extmod/modtrezorcrypto/modtrezorcrypto-random.h +# upymod/modtrezorcrypto/modtrezorcrypto-random.h def shuffle(data: list) -> None: """ Shuffles items of given list (in-place). """ -# extmod/modtrezorcrypto/modtrezorcrypto-random.h +# upymod/modtrezorcrypto/modtrezorcrypto-random.h def reseed(value: int) -> None: """ Re-seed the RNG with given value. diff --git a/core/mocks/generated/trezorcrypto/secp256k1.pyi b/core/mocks/generated/trezorcrypto/secp256k1.pyi index c562b625f2..6c9b6167a7 100644 --- a/core/mocks/generated/trezorcrypto/secp256k1.pyi +++ b/core/mocks/generated/trezorcrypto/secp256k1.pyi @@ -1,14 +1,14 @@ from typing import * -# extmod/modtrezorcrypto/modtrezorcrypto-secp256k1.h +# upymod/modtrezorcrypto/modtrezorcrypto-secp256k1.h def generate_secret() -> bytes: """ Generate secret key. """ -# extmod/modtrezorcrypto/modtrezorcrypto-secp256k1.h +# upymod/modtrezorcrypto/modtrezorcrypto-secp256k1.h def publickey(secret_key: bytes, compressed: bool = True) -> bytes: """ Computes public key from secret key. @@ -17,7 +17,7 @@ CANONICAL_SIG_ETHEREUM: int = 1 CANONICAL_SIG_EOS: int = 2 -# extmod/modtrezorcrypto/modtrezorcrypto-secp256k1.h +# upymod/modtrezorcrypto/modtrezorcrypto-secp256k1.h def sign( secret_key: bytes, digest: bytes, @@ -29,7 +29,7 @@ def sign( """ -# extmod/modtrezorcrypto/modtrezorcrypto-secp256k1.h +# upymod/modtrezorcrypto/modtrezorcrypto-secp256k1.h def verify(public_key: bytes, signature: bytes, digest: bytes) -> bool: """ Uses public key to verify the signature of the digest. @@ -37,7 +37,7 @@ def verify(public_key: bytes, signature: bytes, digest: bytes) -> bool: """ -# extmod/modtrezorcrypto/modtrezorcrypto-secp256k1.h +# upymod/modtrezorcrypto/modtrezorcrypto-secp256k1.h def verify_recover(signature: bytes, digest: bytes) -> bytes: """ Uses signature of the digest to verify the digest and recover the public @@ -45,7 +45,7 @@ def verify_recover(signature: bytes, digest: bytes) -> bytes: """ -# extmod/modtrezorcrypto/modtrezorcrypto-secp256k1.h +# upymod/modtrezorcrypto/modtrezorcrypto-secp256k1.h def multiply(secret_key: bytes, public_key: bytes) -> bytes: """ Multiplies point defined by public_key with scalar defined by diff --git a/core/mocks/generated/trezorcrypto/shamir.pyi b/core/mocks/generated/trezorcrypto/shamir.pyi index 883c84354d..7dedbdd283 100644 --- a/core/mocks/generated/trezorcrypto/shamir.pyi +++ b/core/mocks/generated/trezorcrypto/shamir.pyi @@ -1,7 +1,7 @@ from typing import * -# extmod/modtrezorcrypto/modtrezorcrypto-shamir.h +# upymod/modtrezorcrypto/modtrezorcrypto-shamir.h def interpolate(shares: list[tuple[int, bytes]], x: int) -> bytes: """ Returns f(x) given the Shamir shares (x_1, f(x_1)), ... , (x_k, f(x_k)). diff --git a/core/mocks/generated/trezorcrypto/slip39.pyi b/core/mocks/generated/trezorcrypto/slip39.pyi index 4dedc34282..32d11ec414 100644 --- a/core/mocks/generated/trezorcrypto/slip39.pyi +++ b/core/mocks/generated/trezorcrypto/slip39.pyi @@ -1,7 +1,7 @@ from typing import * -# extmod/modtrezorcrypto/modtrezorcrypto-slip39.h +# upymod/modtrezorcrypto/modtrezorcrypto-slip39.h def word_index(word: str) -> int: """ Finds index of given word. @@ -9,7 +9,7 @@ def word_index(word: str) -> int: """ -# extmod/modtrezorcrypto/modtrezorcrypto-slip39.h +# upymod/modtrezorcrypto/modtrezorcrypto-slip39.h def get_word(index: int) -> str: """ Returns word on position 'index'. diff --git a/core/mocks/generated/trezorio/__init__.pyi b/core/mocks/generated/trezorio/__init__.pyi index d60c9f2efb..efb11e08e9 100644 --- a/core/mocks/generated/trezorio/__init__.pyi +++ b/core/mocks/generated/trezorio/__init__.pyi @@ -1,7 +1,7 @@ from typing import * -# extmod/modtrezorio/modtrezorio-hid.h +# upymod/modtrezorio/modtrezorio-hid.h class HID: """ USB HID interface configuration. @@ -38,7 +38,7 @@ class HID: """ -# extmod/modtrezorio/modtrezorio-poll.h +# upymod/modtrezorio/modtrezorio-poll.h def poll(ifaces: Iterable[int], list_ref: list, timeout_ms: int) -> bool: """ Wait until one of `ifaces` is ready to read or write (using masks @@ -56,7 +56,7 @@ def poll(ifaces: Iterable[int], list_ref: list, timeout_ms: int) -> bool: """ -# extmod/modtrezorio/modtrezorio-usb.h +# upymod/modtrezorio/modtrezorio-usb.h class USB: """ USB device configuration. @@ -95,7 +95,7 @@ class USB: """ -# extmod/modtrezorio/modtrezorio-vcp.h +# upymod/modtrezorio/modtrezorio-vcp.h class VCP: """ USB VCP interface configuration. @@ -119,7 +119,7 @@ class VCP: """ -# extmod/modtrezorio/modtrezorio-webusb.h +# upymod/modtrezorio/modtrezorio-webusb.h class WebUSB: """ USB WebUSB interface configuration. diff --git a/core/mocks/generated/trezorio/fatfs.pyi b/core/mocks/generated/trezorio/fatfs.pyi index b150191074..a5685ec385 100644 --- a/core/mocks/generated/trezorio/fatfs.pyi +++ b/core/mocks/generated/trezorio/fatfs.pyi @@ -23,22 +23,22 @@ FR_INVALID_PARAMETER: int # (19) Given parameter is invalid FR_NO_SPACE: int # (64) No space left on device -# extmod/modtrezorio/modtrezorio-fatfs.h +# upymod/modtrezorio/modtrezorio-fatfs.h class FatFSError(OSError): pass -# extmod/modtrezorio/modtrezorio-fatfs.h +# upymod/modtrezorio/modtrezorio-fatfs.h class NotMounted(FatFSError): pass -# extmod/modtrezorio/modtrezorio-fatfs.h +# upymod/modtrezorio/modtrezorio-fatfs.h class NoFilesystem(FatFSError): pass -# extmod/modtrezorio/modtrezorio-fatfs.h +# upymod/modtrezorio/modtrezorio-fatfs.h class FatFSFile: """ Class encapsulating file @@ -90,7 +90,7 @@ class FatFSFile: """ -# extmod/modtrezorio/modtrezorio-fatfs.h +# upymod/modtrezorio/modtrezorio-fatfs.h class FatFSDir(Iterator[tuple[int, str, str]]): """ Class encapsulating directory @@ -102,77 +102,77 @@ class FatFSDir(Iterator[tuple[int, str, str]]): """ -# extmod/modtrezorio/modtrezorio-fatfs.h +# upymod/modtrezorio/modtrezorio-fatfs.h def open(path: str, flags: str) -> FatFSFile: """ Open or create a file """ -# extmod/modtrezorio/modtrezorio-fatfs.h +# upymod/modtrezorio/modtrezorio-fatfs.h def listdir(path: str) -> FatFSDir: """ List a directory (return generator) """ -# extmod/modtrezorio/modtrezorio-fatfs.h +# upymod/modtrezorio/modtrezorio-fatfs.h def mkdir(path: str, exist_ok: bool=False) -> None: """ Create a sub directory """ -# extmod/modtrezorio/modtrezorio-fatfs.h +# upymod/modtrezorio/modtrezorio-fatfs.h def unlink(path: str) -> None: """ Delete an existing file or directory """ -# extmod/modtrezorio/modtrezorio-fatfs.h +# upymod/modtrezorio/modtrezorio-fatfs.h def stat(path: str) -> tuple[int, str, str]: """ Get file status """ -# extmod/modtrezorio/modtrezorio-fatfs.h +# upymod/modtrezorio/modtrezorio-fatfs.h def rename(oldpath: str, newpath: str) -> None: """ Rename/Move a file or directory """ -# extmod/modtrezorio/modtrezorio-fatfs.h +# upymod/modtrezorio/modtrezorio-fatfs.h def mount() -> None: """ Mount the SD card filesystem. """ -# extmod/modtrezorio/modtrezorio-fatfs.h +# upymod/modtrezorio/modtrezorio-fatfs.h def unmount() -> None: """ Unmount the SD card filesystem. """ -# extmod/modtrezorio/modtrezorio-fatfs.h +# upymod/modtrezorio/modtrezorio-fatfs.h def is_mounted() -> bool: """ Check if the filesystem is mounted. """ -# extmod/modtrezorio/modtrezorio-fatfs.h +# upymod/modtrezorio/modtrezorio-fatfs.h def mkfs(callback: Callable[[int], None] | None = None) -> None: """ Create a FAT volume on the SD card, """ -# extmod/modtrezorio/modtrezorio-fatfs.h +# upymod/modtrezorio/modtrezorio-fatfs.h def setlabel(label: str) -> None: """ Set volume label diff --git a/core/mocks/generated/trezorio/haptic.pyi b/core/mocks/generated/trezorio/haptic.pyi index 8820ebfa6f..dd9c8b3b98 100644 --- a/core/mocks/generated/trezorio/haptic.pyi +++ b/core/mocks/generated/trezorio/haptic.pyi @@ -1,7 +1,7 @@ from typing import * -# extmod/modtrezorio/modtrezorio-haptic.h +# upymod/modtrezorio/modtrezorio-haptic.h def haptic_set_enabled(enable: bool) -> None: """ Enable/Disable the haptic feedback. diff --git a/core/mocks/generated/trezorio/sdcard.pyi b/core/mocks/generated/trezorio/sdcard.pyi index b6765a7c5b..fb42622c0f 100644 --- a/core/mocks/generated/trezorio/sdcard.pyi +++ b/core/mocks/generated/trezorio/sdcard.pyi @@ -2,14 +2,14 @@ from typing import * BLOCK_SIZE: int # size of SD card block -# extmod/modtrezorio/modtrezorio-sdcard.h +# upymod/modtrezorio/modtrezorio-sdcard.h def is_present() -> bool: """ Returns True if SD card is detected, False otherwise. """ -# extmod/modtrezorio/modtrezorio-sdcard.h +# upymod/modtrezorio/modtrezorio-sdcard.h def power_on() -> None: """ Power on the SD card interface. @@ -18,21 +18,21 @@ def power_on() -> None: """ -# extmod/modtrezorio/modtrezorio-sdcard.h +# upymod/modtrezorio/modtrezorio-sdcard.h def power_off() -> None: """ Power off the SD card interface. """ -# extmod/modtrezorio/modtrezorio-sdcard.h +# upymod/modtrezorio/modtrezorio-sdcard.h def capacity() -> int: """ Returns capacity of the SD card in bytes, or zero if not present. """ -# extmod/modtrezorio/modtrezorio-sdcard.h +# upymod/modtrezorio/modtrezorio-sdcard.h def read(block_num: int, buf: bytearray) -> None: """ Reads blocks starting with block_num from the SD card into buf. @@ -41,7 +41,7 @@ def read(block_num: int, buf: bytearray) -> None: """ -# extmod/modtrezorio/modtrezorio-sdcard.h +# upymod/modtrezorio/modtrezorio-sdcard.h def write(block_num: int, buf: bytes) -> None: """ Writes blocks starting with block_num from buf to the SD card. diff --git a/core/mocks/generated/trezorui.pyi b/core/mocks/generated/trezorui.pyi index b34f62bbb9..ed57058ae8 100644 --- a/core/mocks/generated/trezorui.pyi +++ b/core/mocks/generated/trezorui.pyi @@ -1,7 +1,7 @@ from typing import * -# extmod/modtrezorui/modtrezorui-display.h +# upymod/modtrezorui/modtrezorui-display.h class Display: """ Provide access to device display. diff --git a/core/mocks/generated/trezorutils.pyi b/core/mocks/generated/trezorutils.pyi index d28a5866ce..c8b55c2b9b 100644 --- a/core/mocks/generated/trezorutils.pyi +++ b/core/mocks/generated/trezorutils.pyi @@ -1,7 +1,7 @@ from typing import * -# extmod/modtrezorutils/modtrezorutils-meminfo.h +# upymod/modtrezorutils/modtrezorutils-meminfo.h def meminfo(filename: str) -> None: """Dumps map of micropython GC arena to a file. The JSON file can be decoded by analyze.py @@ -9,7 +9,7 @@ def meminfo(filename: str) -> None: """ -# extmod/modtrezorutils/modtrezorutils.c +# upymod/modtrezorutils/modtrezorutils.c def consteq(sec: bytes, pub: bytes) -> bool: """ Compares the private information in `sec` with public, user-provided @@ -19,7 +19,7 @@ def consteq(sec: bytes, pub: bytes) -> bool: """ -# extmod/modtrezorutils/modtrezorutils.c +# upymod/modtrezorutils/modtrezorutils.c def memcpy( dst: bytearray | memoryview, dst_ofs: int, @@ -35,14 +35,14 @@ def memcpy( """ -# extmod/modtrezorutils/modtrezorutils.c +# upymod/modtrezorutils/modtrezorutils.c def halt(msg: str | None = None) -> None: """ Halts execution. """ -# extmod/modtrezorutils/modtrezorutils.c +# upymod/modtrezorutils/modtrezorutils.c def firmware_hash( challenge: bytes | None = None, callback: Callable[[int, int], None] | None = None, @@ -53,42 +53,42 @@ def firmware_hash( """ -# extmod/modtrezorutils/modtrezorutils.c +# upymod/modtrezorutils/modtrezorutils.c def firmware_vendor() -> str: """ Returns the firmware vendor string from the vendor header. """ -# extmod/modtrezorutils/modtrezorutils.c +# upymod/modtrezorutils/modtrezorutils.c def unit_color() -> int | None: """ Returns the color of the unit. """ -# extmod/modtrezorutils/modtrezorutils.c +# upymod/modtrezorutils/modtrezorutils.c def unit_btconly() -> bool | None: """ Returns True if the unit is BTConly. """ -# extmod/modtrezorutils/modtrezorutils.c +# upymod/modtrezorutils/modtrezorutils.c def unit_packaging() -> int | None: """ Returns the packaging version of the unit. """ -# extmod/modtrezorutils/modtrezorutils.c +# upymod/modtrezorutils/modtrezorutils.c def sd_hotswap_enabled() -> bool: """ Returns True if SD card hot swapping is enabled """ -# extmod/modtrezorutils/modtrezorutils.c +# upymod/modtrezorutils/modtrezorutils.c def reboot_to_bootloader( boot_command : int = 0, boot_args : bytes | None = None, @@ -99,7 +99,7 @@ def reboot_to_bootloader( VersionTuple = Tuple[int, int, int, int] -# extmod/modtrezorutils/modtrezorutils.c +# upymod/modtrezorutils/modtrezorutils.c class FirmwareHeaderInfo(NamedTuple): version: VersionTuple vendor: str @@ -107,12 +107,12 @@ class FirmwareHeaderInfo(NamedTuple): hash: bytes -# extmod/modtrezorutils/modtrezorutils.c +# upymod/modtrezorutils/modtrezorutils.c def check_firmware_header(header : bytes) -> FirmwareHeaderInfo: """Parses incoming firmware header and returns information about it.""" -# extmod/modtrezorutils/modtrezorutils.c +# upymod/modtrezorutils/modtrezorutils.c def bootloader_locked() -> bool | None: """ Returns True/False if the the bootloader is locked/unlocked and None if diff --git a/core/site_scons/models/D001/discovery.py b/core/site_scons/models/D001/discovery.py index 97ef8a53b2..1006999cf9 100644 --- a/core/site_scons/models/D001/discovery.py +++ b/core/site_scons/models/D001/discovery.py @@ -34,12 +34,13 @@ def configure( defines += [f"HW_REVISION={hw_revision}"] sources += [ - "embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/display_driver.c", - "embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/display_ltdc.c", - "embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/ili9341_spi.c", + "embed/io/display/stm32f429i-disc1/display_driver.c", + "embed/io/display/stm32f429i-disc1/display_ltdc.c", + "embed/io/display/stm32f429i-disc1/ili9341_spi.c", ] + paths += ["embed/io/display/inc"] - sources += ["embed/trezorhal/stm32u5/dma2d_bitblt.c"] + sources += ["embed/gfx/bitblt/stm32/dma2d_bitblt.c"] sources += [ "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma2d.c" @@ -56,29 +57,33 @@ def configure( features_available.append("framebuffer") features_available.append("display_rgb565") - sources += ["embed/trezorhal/stm32f4/sdram.c"] + sources += ["embed/sys/sdram/stm32f429i-disc1/sdram_bsp.c"] + paths += ["embed/sys/sdram/inc"] defines += ["USE_SDRAM=1"] if "input" in features_wanted: - sources += ["embed/trezorhal/stm32f4/i2c_bus.c"] - sources += ["embed/trezorhal/stm32f4/touch/stmpe811.c"] + sources += ["embed/io/i2c_bus/stm32f4/i2c_bus.c"] + sources += ["embed/io/touch/stmpe811/stmpe811.c"] + paths += ["embed/io/i2c_bus/inc"] + paths += ["embed/io/touch/inc"] features_available.append("touch") defines += ["USE_TOUCH=1"] defines += ["USE_I2C=1"] if "usb" in features_wanted: sources += [ - "embed/trezorhal/stm32f4/usb/usb_class_hid.c", - "embed/trezorhal/stm32f4/usb/usb_class_vcp.c", - "embed/trezorhal/stm32f4/usb/usb_class_webusb.c", - "embed/trezorhal/stm32f4/usb/usb.c", - "embed/trezorhal/stm32f4/usb/usbd_conf.c", - "embed/trezorhal/stm32f4/usb/usbd_core.c", - "embed/trezorhal/stm32f4/usb/usbd_ctlreq.c", - "embed/trezorhal/stm32f4/usb/usbd_ioreq.c", + "embed/io/usb/stm32/usb_class_hid.c", + "embed/io/usb/stm32/usb_class_vcp.c", + "embed/io/usb/stm32/usb_class_webusb.c", + "embed/io/usb/stm32/usb.c", + "embed/io/usb/stm32/usbd_conf.c", + "embed/io/usb/stm32/usbd_core.c", + "embed/io/usb/stm32/usbd_ctlreq.c", + "embed/io/usb/stm32/usbd_ioreq.c", "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c", ] features_available.append("usb") + paths += ["embed/io/usb/inc"] defines += ["USE_PVD=1"] diff --git a/core/site_scons/models/D002/discovery2.py b/core/site_scons/models/D002/discovery2.py index 30465e406a..0cadedaeff 100644 --- a/core/site_scons/models/D002/discovery2.py +++ b/core/site_scons/models/D002/discovery2.py @@ -17,7 +17,7 @@ def configure( hw_revision = 0 mcu = "STM32U5G9xx" - linker_script = """embed/trezorhal/stm32u5/linker/u5g/{target}.ld""" + linker_script = """embed/sys/linker/stm32u5g/{target}.ld""" stm32u5_common_files(env, defines, sources, paths) @@ -41,31 +41,35 @@ def configure( ] sources += [ - "embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_driver.c", - "embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_fb.c", - "embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_ltdc_dsi.c", + "embed/io/display/stm32u5a9j-dk/display_driver.c", + "embed/io/display/stm32u5a9j-dk/display_fb.c", + "embed/io/display/stm32u5a9j-dk/display_ltdc_dsi.c", ] + paths += ["embed/io/display/inc"] if "input" in features_wanted: - sources += ["embed/trezorhal/stm32u5/i2c_bus.c"] - sources += ["embed/trezorhal/stm32u5/touch/sitronix.c"] + sources += ["embed/io/i2c_bus/stm32u5/i2c_bus.c"] + sources += ["embed/io/touch/sitronix/sitronix.c"] + paths += ["embed/io/i2c_bus/inc"] + paths += ["embed/io/touch/inc"] features_available.append("touch") defines += ["USE_TOUCH=1"] defines += ["USE_I2C=1"] if "usb" in features_wanted: sources += [ - "embed/trezorhal/stm32u5/usb/usb_class_hid.c", - "embed/trezorhal/stm32u5/usb/usb_class_vcp.c", - "embed/trezorhal/stm32u5/usb/usb_class_webusb.c", - "embed/trezorhal/stm32u5/usb/usb.c", - "embed/trezorhal/stm32u5/usb/usbd_conf.c", - "embed/trezorhal/stm32u5/usb/usbd_core.c", - "embed/trezorhal/stm32u5/usb/usbd_ctlreq.c", - "embed/trezorhal/stm32u5/usb/usbd_ioreq.c", + "embed/io/usb/stm32/usb_class_hid.c", + "embed/io/usb/stm32/usb_class_vcp.c", + "embed/io/usb/stm32/usb_class_webusb.c", + "embed/io/usb/stm32/usb.c", + "embed/io/usb/stm32/usbd_conf.c", + "embed/io/usb/stm32/usbd_core.c", + "embed/io/usb/stm32/usbd_ctlreq.c", + "embed/io/usb/stm32/usbd_ioreq.c", "vendor/stm32u5xx_hal_driver/Src/stm32u5xx_ll_usb.c", ] features_available.append("usb") + paths += ["embed/io/usb/inc"] defines += [ "USE_DMA2D", @@ -73,7 +77,7 @@ def configure( "USE_RGB_COLORS", ] - sources += ["embed/trezorhal/stm32u5/dma2d_bitblt.c"] + sources += ["embed/gfx/bitblt/stm32/dma2d_bitblt.c"] features_available.append("dma2d") features_available.append("ui_color_32bit") diff --git a/core/site_scons/models/T2B1/emulator.py b/core/site_scons/models/T2B1/emulator.py index ec32ce2ccb..fc05aa8342 100644 --- a/core/site_scons/models/T2B1/emulator.py +++ b/core/site_scons/models/T2B1/emulator.py @@ -30,20 +30,23 @@ def configure( defines += ["FLASH_BLOCK_WORDS=1"] if "sbu" in features_wanted: - sources += ["embed/trezorhal/unix/sbu.c"] + sources += ["embed/io/sbu/unix/sbu.c"] + paths += ["embed/io/sbu/inc"] defines += ["USE_SBU=1"] if "optiga" in features_wanted: - sources += ["embed/trezorhal/unix/optiga_hal.c"] - sources += ["embed/trezorhal/unix/optiga.c"] + sources += ["embed/sec/optiga/unix/optiga_hal.c"] + sources += ["embed/sec/optiga/unix/optiga.c"] + paths += ["embed/sec/optiga/inc"] features_available.append("optiga") defines += ["USE_OPTIGA=1"] if "input" in features_wanted: - sources += ["embed/trezorhal/unix/button.c"] + sources += ["embed/io/button/unix/button.c"] + paths += ["embed/io/button/inc"] features_available.append("button") defines += ["USE_BUTTON=1"] - sources += ["embed/trezorhal/stm32f4/layout.c"] + sources += ["embed/util/flash/stm32f4/flash_layout.c"] return features_available diff --git a/core/site_scons/models/T2B1/trezor_r_v10.py b/core/site_scons/models/T2B1/trezor_r_v10.py index 18db28c2d3..7219716e44 100644 --- a/core/site_scons/models/T2B1/trezor_r_v10.py +++ b/core/site_scons/models/T2B1/trezor_r_v10.py @@ -37,46 +37,53 @@ def configure( defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_REVISION={hw_revision}"] - sources += ["embed/trezorhal/stm32f4/xdisplay/vg-2864/display_driver.c"] + sources += ["embed/io/display/vg-2864/display_driver.c"] + paths += ["embed/io/display/inc"] if "input" in features_wanted: - sources += ["embed/trezorhal/stm32f4/button.c"] + sources += ["embed/io/button/stm32/button.c"] + paths += ["embed/io/button/inc"] features_available.append("button") defines += ["USE_BUTTON=1"] if "sbu" in features_wanted: - sources += ["embed/trezorhal/stm32f4/sbu.c"] + sources += ["embed/io/sbu/stm32/sbu.c"] + paths += ["embed/io/sbu/inc"] features_available.append("sbu") defines += ["USE_SBU=1"] if "consumption_mask" in features_wanted: - sources += ["embed/trezorhal/stm32f4/consumption_mask.c"] + sources += ["embed/sec/consumption_mask/stm32f4/consumption_mask.c"] sources += [ "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c" ] + paths += ["embed/sec/consumption_mask/inc"] defines += ["USE_CONSUMPTION_MASK=1"] if "usb" in features_wanted: sources += [ - "embed/trezorhal/stm32f4/usb/usb_class_hid.c", - "embed/trezorhal/stm32f4/usb/usb_class_vcp.c", - "embed/trezorhal/stm32f4/usb/usb_class_webusb.c", - "embed/trezorhal/stm32f4/usb/usb.c", - "embed/trezorhal/stm32f4/usb/usbd_conf.c", - "embed/trezorhal/stm32f4/usb/usbd_core.c", - "embed/trezorhal/stm32f4/usb/usbd_ctlreq.c", - "embed/trezorhal/stm32f4/usb/usbd_ioreq.c", + "embed/io/usb/stm32/usb_class_hid.c", + "embed/io/usb/stm32/usb_class_vcp.c", + "embed/io/usb/stm32/usb_class_webusb.c", + "embed/io/usb/stm32/usb.c", + "embed/io/usb/stm32/usbd_conf.c", + "embed/io/usb/stm32/usbd_core.c", + "embed/io/usb/stm32/usbd_ctlreq.c", + "embed/io/usb/stm32/usbd_ioreq.c", "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c", ] features_available.append("usb") + paths += ["embed/io/usb/inc"] if "optiga" in features_wanted: - sources += ["embed/trezorhal/stm32f4/i2c_bus.c"] - sources += ["embed/trezorhal/stm32f4/optiga_hal.c"] - sources += ["embed/trezorhal/optiga/optiga.c"] - sources += ["embed/trezorhal/optiga/optiga_commands.c"] - sources += ["embed/trezorhal/optiga/optiga_transport.c"] + sources += ["embed/io/i2c_bus/stm32f4/i2c_bus.c"] + sources += ["embed/sec/optiga/stm32f4/optiga_hal.c"] + sources += ["embed/sec/optiga/optiga.c"] + sources += ["embed/sec/optiga/optiga_commands.c"] + sources += ["embed/sec/optiga/optiga_transport.c"] sources += ["vendor/trezor-crypto/hash_to_curve.c"] + paths += ["embed/io/i2c_bus/inc"] + paths += ["embed/sec/optiga/inc"] features_available.append("optiga") defines += ["USE_OPTIGA=1"] defines += ["USE_I2C=1"] diff --git a/core/site_scons/models/T2T1/emulator.py b/core/site_scons/models/T2T1/emulator.py index d00a631dea..9bf7b0696d 100644 --- a/core/site_scons/models/T2T1/emulator.py +++ b/core/site_scons/models/T2T1/emulator.py @@ -29,34 +29,30 @@ def configure( defines += ["FLASH_BIT_ACCESS=1"] defines += ["FLASH_BLOCK_WORDS=1"] - if "dma2d" in features_wanted: - features_available.append("dma2d") - sources += [ - "embed/trezorhal/unix/dma2d_bitblt.c", - ] - defines += ["USE_DMA2D"] - if "sd_card" in features_wanted: features_available.append("sd_card") sources += [ - "embed/trezorhal/unix/sdcard.c", - "embed/extmod/modtrezorio/ff.c", - "embed/extmod/modtrezorio/ffunicode.c", + "embed/io/sdcard/unix/sdcard.c", + "embed/upymod/modtrezorio/ff.c", + "embed/upymod/modtrezorio/ffunicode.c", ] + paths += ["embed/io/sdcard/inc"] defines += ["USE_SD_CARD=1"] if "sbu" in features_wanted: - sources += ["embed/trezorhal/unix/sbu.c"] + sources += ["embed/io/sbu/unix/sbu.c"] + paths += ["embed/io/sbu/inc"] defines += ["USE_SBU=1"] if "input" in features_wanted: - sources += ["embed/trezorhal/unix/touch.c"] + sources += ["embed/io/touch/unix/touch.c"] + paths += ["embed/io/touch/inc"] features_available.append("touch") defines += ["USE_TOUCH=1"] features_available.append("backlight") defines += ["USE_BACKLIGHT=1"] - sources += ["embed/trezorhal/stm32f4/layout.c"] + sources += ["embed/util/flash/stm32f4/flash_layout.c"] return features_available diff --git a/core/site_scons/models/T2T1/trezor_t.py b/core/site_scons/models/T2T1/trezor_t.py index 5d8f2c46a3..3f6c5b3bc5 100644 --- a/core/site_scons/models/T2T1/trezor_t.py +++ b/core/site_scons/models/T2T1/trezor_t.py @@ -37,59 +37,65 @@ def configure( defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_REVISION={hw_revision}"] - sources += ["embed/trezorhal/stm32f4/xdisplay/st-7789/display_nofb.c"] - sources += ["embed/trezorhal/stm32f4/xdisplay/st-7789/display_driver.c"] - sources += ["embed/trezorhal/stm32f4/xdisplay/st-7789/display_io.c"] - sources += ["embed/trezorhal/stm32f4/xdisplay/st-7789/display_panel.c"] - sources += ["embed/trezorhal/stm32f4/xdisplay/st-7789/panels/tf15411a.c"] - sources += ["embed/trezorhal/stm32f4/xdisplay/st-7789/panels/154a.c"] - sources += ["embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2411.c"] - sources += ["embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2422.c"] + sources += ["embed/io/display/st-7789/display_nofb.c"] + sources += ["embed/io/display/st-7789/display_driver.c"] + sources += ["embed/io/display/st-7789/display_io.c"] + sources += ["embed/io/display/st-7789/display_panel.c"] + sources += ["embed/io/display/st-7789/panels/tf15411a.c"] + sources += ["embed/io/display/st-7789/panels/154a.c"] + sources += ["embed/io/display/st-7789/panels/lx154a2411.c"] + sources += ["embed/io/display/st-7789/panels/lx154a2422.c"] + paths += ["embed/io/display/inc"] - sources += ["embed/trezorhal/stm32f4/backlight_pwm.c"] + sources += ["embed/io/display/backlight/stm32/backlight_pwm.c"] features_available.append("backlight") defines += ["USE_BACKLIGHT=1"] if "input" in features_wanted: - sources += ["embed/trezorhal/stm32f4/i2c_bus.c"] - sources += ["embed/trezorhal/stm32f4/touch/ft6x36.c"] + sources += ["embed/io/i2c_bus/stm32f4/i2c_bus.c"] + sources += ["embed/io/touch/ft6x36/ft6x36.c"] + paths += ["embed/io/i2c_bus/inc"] + paths += ["embed/io/touch/inc"] features_available.append("touch") defines += ["USE_TOUCH=1"] defines += ["USE_I2C=1"] if "sd_card" in features_wanted: - sources += ["embed/trezorhal/stm32f4/sdcard.c"] - sources += ["embed/extmod/modtrezorio/ff.c"] - sources += ["embed/extmod/modtrezorio/ffunicode.c"] + sources += ["embed/io/sdcard/stm32f4/sdcard.c"] + sources += ["embed/upymod/modtrezorio/ff.c"] + sources += ["embed/upymod/modtrezorio/ffunicode.c"] sources += [ "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c" ] + paths += ["embed/io/sdcard/inc"] features_available.append("sd_card") defines += ["USE_SD_CARD=1"] if "sbu" in features_wanted: - sources += ["embed/trezorhal/stm32f4/sbu.c"] + sources += ["embed/io/sbu/stm32/sbu.c"] + paths += ["embed/io/sbu/inc"] features_available.append("sbu") defines += ["USE_SBU=1"] if "usb" in features_wanted: sources += [ - "embed/trezorhal/stm32f4/usb/usb_class_hid.c", - "embed/trezorhal/stm32f4/usb/usb_class_vcp.c", - "embed/trezorhal/stm32f4/usb/usb_class_webusb.c", - "embed/trezorhal/stm32f4/usb/usb.c", - "embed/trezorhal/stm32f4/usb/usbd_conf.c", - "embed/trezorhal/stm32f4/usb/usbd_core.c", - "embed/trezorhal/stm32f4/usb/usbd_ctlreq.c", - "embed/trezorhal/stm32f4/usb/usbd_ioreq.c", + "embed/io/usb/stm32/usb_class_hid.c", + "embed/io/usb/stm32/usb_class_vcp.c", + "embed/io/usb/stm32/usb_class_webusb.c", + "embed/io/usb/stm32/usb.c", + "embed/io/usb/stm32/usbd_conf.c", + "embed/io/usb/stm32/usbd_core.c", + "embed/io/usb/stm32/usbd_ctlreq.c", + "embed/io/usb/stm32/usbd_ioreq.c", "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c", ] features_available.append("usb") + paths += ["embed/io/usb/inc"] if "dma2d" in features_wanted: defines += ["USE_DMA2D"] - sources += ["embed/trezorhal/stm32u5/dma2d_bitblt.c"] + sources += ["embed/gfx/bitblt/stm32/dma2d_bitblt.c"] sources += [ "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma2d.c" ] diff --git a/core/site_scons/models/T3B1/emulator.py b/core/site_scons/models/T3B1/emulator.py index ae2132c6ee..8e3ff56ee7 100644 --- a/core/site_scons/models/T3B1/emulator.py +++ b/core/site_scons/models/T3B1/emulator.py @@ -30,20 +30,23 @@ def configure( defines += ["FLASH_BLOCK_WORDS=1"] if "sbu" in features_wanted: - sources += ["embed/trezorhal/unix/sbu.c"] + sources += ["embed/io/sbu/unix/sbu.c"] + paths += ["embed/io/sbu/inc"] defines += ["USE_SBU=1"] if "optiga" in features_wanted: - sources += ["embed/trezorhal/unix/optiga_hal.c"] - sources += ["embed/trezorhal/unix/optiga.c"] + sources += ["embed/sec/optiga/unix/optiga_hal.c"] + sources += ["embed/sec/optiga/unix/optiga.c"] + paths += ["embed/sec/optiga/inc"] features_available.append("optiga") defines += ["USE_OPTIGA=1"] if "input" in features_wanted: - sources += ["embed/trezorhal/unix/button.c"] + sources += ["embed/io/button/unix/button.c"] + paths += ["embed/io/button/inc"] features_available.append("button") defines += ["USE_BUTTON=1"] - sources += ["embed/trezorhal/stm32u5/layout.c"] + sources += ["embed/util/flash/stm32u5/flash_layout.c"] return features_available diff --git a/core/site_scons/models/T3B1/trezor_t3b1_revB.py b/core/site_scons/models/T3B1/trezor_t3b1_revB.py index d0c46ec6e2..7665fa5d4c 100644 --- a/core/site_scons/models/T3B1/trezor_t3b1_revB.py +++ b/core/site_scons/models/T3B1/trezor_t3b1_revB.py @@ -21,7 +21,7 @@ def configure( features_available.append("display_mono") mcu = "STM32U585xx" - linker_script = """embed/trezorhal/stm32u5/linker/u58/{target}.ld""" + linker_script = """embed/sys/linker/stm32u58/{target}.ld""" stm32u5_common_files(env, defines, sources, paths) @@ -38,46 +38,53 @@ def configure( defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_REVISION={ord(hw_revision)}"] - sources += ["embed/trezorhal/stm32u5/xdisplay/vg-2864/display_driver.c"] + sources += ["embed/io/display/vg-2864/display_driver.c"] + paths += ["embed/io/display/inc"] if "input" in features_wanted: - sources += ["embed/trezorhal/stm32u5/button.c"] + sources += ["embed/io/button/stm32/button.c"] + paths += ["embed/io/button/inc"] features_available.append("button") defines += ["USE_BUTTON=1"] if "sbu" in features_wanted: - sources += ["embed/trezorhal/stm32u5/sbu.c"] + sources += ["embed/io/sbu/stm32/sbu.c"] + paths += ["embed/io/sbu/inc"] features_available.append("sbu") defines += ["USE_SBU=1"] if "usb" in features_wanted: sources += [ - "embed/trezorhal/stm32u5/usb/usb_class_hid.c", - "embed/trezorhal/stm32u5/usb/usb_class_vcp.c", - "embed/trezorhal/stm32u5/usb/usb_class_webusb.c", - "embed/trezorhal/stm32u5/usb/usb.c", - "embed/trezorhal/stm32u5/usb/usbd_conf.c", - "embed/trezorhal/stm32u5/usb/usbd_core.c", - "embed/trezorhal/stm32u5/usb/usbd_ctlreq.c", - "embed/trezorhal/stm32u5/usb/usbd_ioreq.c", + "embed/io/usb/stm32/usb_class_hid.c", + "embed/io/usb/stm32/usb_class_vcp.c", + "embed/io/usb/stm32/usb_class_webusb.c", + "embed/io/usb/stm32/usb.c", + "embed/io/usb/stm32/usbd_conf.c", + "embed/io/usb/stm32/usbd_core.c", + "embed/io/usb/stm32/usbd_ctlreq.c", + "embed/io/usb/stm32/usbd_ioreq.c", "vendor/stm32u5xx_hal_driver/Src/stm32u5xx_ll_usb.c", ] features_available.append("usb") + paths += ["embed/io/usb/inc"] if "optiga" in features_wanted: - sources += ["embed/trezorhal/stm32u5/i2c_bus.c"] - sources += ["embed/trezorhal/stm32u5/optiga_hal.c"] - sources += ["embed/trezorhal/optiga/optiga.c"] - sources += ["embed/trezorhal/optiga/optiga_commands.c"] - sources += ["embed/trezorhal/optiga/optiga_transport.c"] + sources += ["embed/io/i2c_bus/stm32u5/i2c_bus.c"] + sources += ["embed/sec/optiga/stm32u5/optiga_hal.c"] + sources += ["embed/sec/optiga/optiga.c"] + sources += ["embed/sec/optiga/optiga_commands.c"] + sources += ["embed/sec/optiga/optiga_transport.c"] sources += ["vendor/trezor-crypto/hash_to_curve.c"] + paths += ["embed/io/i2c_bus/inc"] + paths += ["embed/sec/optiga/inc"] features_available.append("optiga") defines += ["USE_OPTIGA=1"] defines += ["USE_I2C=1"] if "consumption_mask" in features_wanted: - sources += ["embed/trezorhal/stm32u5/consumption_mask.c"] + sources += ["embed/sec/consumption_mask/stm32u5/consumption_mask.c"] sources += ["vendor/stm32u5xx_hal_driver/Src/stm32u5xx_hal_tim.c"] + paths += ["embed/sec/consumption_mask/inc"] defines += ["USE_CONSUMPTION_MASK=1"] defines += [ diff --git a/core/site_scons/models/T3T1/emulator.py b/core/site_scons/models/T3T1/emulator.py index 79f6dcdb70..ab733d9cb2 100644 --- a/core/site_scons/models/T3T1/emulator.py +++ b/core/site_scons/models/T3T1/emulator.py @@ -31,40 +31,37 @@ def configure( defines += ["FLASH_BIT_ACCESS=1"] defines += ["FLASH_BLOCK_WORDS=1"] - if "dma2d" in features_wanted: - features_available.append("dma2d") - sources += [ - "embed/trezorhal/unix/dma2d_bitblt.c", - ] - defines += ["USE_DMA2D"] - if "sd_card" in features_wanted: features_available.append("sd_card") sources += [ - "embed/trezorhal/unix/sdcard.c", - "embed/extmod/modtrezorio/ff.c", - "embed/extmod/modtrezorio/ffunicode.c", + "embed/io/sdcard/unix/sdcard.c", + "embed/upymod/modtrezorio/ff.c", + "embed/upymod/modtrezorio/ffunicode.c", ] + paths += ["embed/io/sdcard/inc"] defines += ["USE_SD_CARD=1"] if "sbu" in features_wanted: - sources += ["embed/trezorhal/unix/sbu.c"] + sources += ["embed/io/sbu/unix/sbu.c"] + paths += ["embed/io/sbu/inc"] defines += ["USE_SBU=1"] if "optiga" in features_wanted: - sources += ["embed/trezorhal/unix/optiga_hal.c"] - sources += ["embed/trezorhal/unix/optiga.c"] + sources += ["embed/sec/optiga/unix/optiga_hal.c"] + sources += ["embed/sec/optiga/unix/optiga.c"] + paths += ["embed/sec/optiga/inc"] features_available.append("optiga") defines += ["USE_OPTIGA=1"] if "input" in features_wanted: - sources += ["embed/trezorhal/unix/touch.c"] + sources += ["embed/io/touch/unix/touch.c"] + paths += ["embed/io/touch/inc"] features_available.append("touch") defines += ["USE_TOUCH=1"] features_available.append("backlight") defines += ["USE_BACKLIGHT=1"] - sources += ["embed/trezorhal/stm32u5/layout.c"] + sources += ["embed/util/flash/stm32u5/flash_layout.c"] return features_available diff --git a/core/site_scons/models/T3T1/trezor_t3t1_revE.py b/core/site_scons/models/T3T1/trezor_t3t1_revE.py index 84c0a3b54c..fc22976bcc 100644 --- a/core/site_scons/models/T3T1/trezor_t3t1_revE.py +++ b/core/site_scons/models/T3T1/trezor_t3t1_revE.py @@ -23,7 +23,7 @@ def configure( defines += ["USE_RGB_COLORS=1"] mcu = "STM32U585xx" - linker_script = """embed/trezorhal/stm32u5/linker/u58/{target}.ld""" + linker_script = """embed/sys/linker/stm32u58/{target}.ld""" stm32u5_common_files(env, defines, sources, paths) @@ -40,80 +40,86 @@ def configure( defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_REVISION={hw_revision}"] - sources += ["embed/trezorhal/stm32u5/xdisplay/st-7789/display_fb.c"] - sources += ["embed/trezorhal/stm32u5/xdisplay/st-7789/display_driver.c"] - sources += ["embed/trezorhal/stm32u5/xdisplay/st-7789/display_io.c"] - sources += ["embed/trezorhal/stm32u5/xdisplay/st-7789/display_panel.c"] - sources += [ - "embed/trezorhal/stm32u5/xdisplay/st-7789/panels/lx154a2482.c", - ] + sources += ["embed/io/display/st-7789/display_fb.c"] + sources += ["embed/io/display/st-7789/display_driver.c"] + sources += ["embed/io/display/st-7789/display_io.c"] + sources += ["embed/io/display/st-7789/display_panel.c"] + sources += ["embed/io/display/st-7789/panels/lx154a2482.c"] + paths += ["embed/io/display/inc"] - sources += ["embed/trezorhal/stm32u5/backlight_pwm.c"] + sources += ["embed/io/display/backlight/stm32/backlight_pwm.c"] features_available.append("backlight") defines += ["USE_BACKLIGHT=1"] env_constraints = env.get("CONSTRAINTS") if not (env_constraints and "limited_util_s" in env_constraints): - sources += ["embed/trezorhal/stm32u5/bg_copy.c"] + sources += ["embed/io/display/bg_copy/stm32u5/bg_copy.c"] if "input" in features_wanted: - sources += ["embed/trezorhal/stm32u5/i2c_bus.c"] - sources += ["embed/trezorhal/stm32u5/touch/ft6x36.c"] - sources += ["embed/trezorhal/stm32u5/touch/panels/lx154a2422cpt23.c"] + sources += ["embed/io/i2c_bus/stm32u5/i2c_bus.c"] + sources += ["embed/io/touch/ft6x36/ft6x36.c"] + sources += ["embed/io/touch/ft6x36/panels/lx154a2422cpt23.c"] + paths += ["embed/io/i2c_bus/inc"] + paths += ["embed/io/touch/inc"] features_available.append("touch") defines += ["USE_TOUCH=1"] defines += ["USE_I2C=1"] if "haptic" in features_wanted: sources += [ - "embed/trezorhal/stm32u5/haptic/drv2625/drv2625.c", + "embed/io/haptic/drv2625/drv2625.c", ] sources += [ "vendor/stm32u5xx_hal_driver/Src/stm32u5xx_hal_tim.c", "vendor/stm32u5xx_hal_driver/Src/stm32u5xx_hal_tim_ex.c", ] + paths += ["embed/io/haptic/inc"] features_available.append("haptic") defines += ["USE_HAPTIC=1"] if "sd_card" in features_wanted: - sources += ["embed/trezorhal/stm32u5/sdcard.c"] - sources += ["embed/extmod/modtrezorio/ff.c"] - sources += ["embed/extmod/modtrezorio/ffunicode.c"] + sources += ["embed/io/sdcard/stm32u5/sdcard.c"] + sources += ["embed/upymod/modtrezorio/ff.c"] + sources += ["embed/upymod/modtrezorio/ffunicode.c"] sources += ["vendor/stm32u5xx_hal_driver/Src/stm32u5xx_hal_sd.c"] sources += ["vendor/stm32u5xx_hal_driver/Src/stm32u5xx_ll_sdmmc.c"] + paths += ["embed/io/sdcard/inc"] features_available.append("sd_card") defines += ["USE_SD_CARD=1"] if "sbu" in features_wanted: - sources += ["embed/trezorhal/stm32u5/sbu.c"] + sources += ["embed/io/sbu/stm32/sbu.c"] + paths += ["embed/io/sbu/inc"] features_available.append("sbu") defines += ["USE_SBU=1"] if "usb" in features_wanted: sources += [ - "embed/trezorhal/stm32u5/usb/usb_class_hid.c", - "embed/trezorhal/stm32u5/usb/usb_class_vcp.c", - "embed/trezorhal/stm32u5/usb/usb_class_webusb.c", - "embed/trezorhal/stm32u5/usb/usb.c", - "embed/trezorhal/stm32u5/usb/usbd_conf.c", - "embed/trezorhal/stm32u5/usb/usbd_core.c", - "embed/trezorhal/stm32u5/usb/usbd_ctlreq.c", - "embed/trezorhal/stm32u5/usb/usbd_ioreq.c", + "embed/io/usb/stm32/usb_class_hid.c", + "embed/io/usb/stm32/usb_class_vcp.c", + "embed/io/usb/stm32/usb_class_webusb.c", + "embed/io/usb/stm32/usb.c", + "embed/io/usb/stm32/usbd_conf.c", + "embed/io/usb/stm32/usbd_core.c", + "embed/io/usb/stm32/usbd_ctlreq.c", + "embed/io/usb/stm32/usbd_ioreq.c", "vendor/stm32u5xx_hal_driver/Src/stm32u5xx_ll_usb.c", ] features_available.append("usb") + paths += ["embed/io/usb/inc"] if "dma2d" in features_wanted: defines += ["USE_DMA2D"] - sources += ["embed/trezorhal/stm32u5/dma2d_bitblt.c"] + sources += ["embed/gfx/bitblt/stm32/dma2d_bitblt.c"] features_available.append("dma2d") if "optiga" in features_wanted: - sources += ["embed/trezorhal/stm32u5/optiga_hal.c"] - sources += ["embed/trezorhal/optiga/optiga.c"] - sources += ["embed/trezorhal/optiga/optiga_commands.c"] - sources += ["embed/trezorhal/optiga/optiga_transport.c"] + sources += ["embed/sec/optiga/stm32u5/optiga_hal.c"] + sources += ["embed/sec/optiga/optiga.c"] + sources += ["embed/sec/optiga/optiga_commands.c"] + sources += ["embed/sec/optiga/optiga_transport.c"] sources += ["vendor/trezor-crypto/hash_to_curve.c"] + paths += ["embed/sec/optiga/inc"] features_available.append("optiga") defines += ["USE_OPTIGA=1"] diff --git a/core/site_scons/models/T3W1/emulator.py b/core/site_scons/models/T3W1/emulator.py index 5edbe1a623..3be3a6ed2f 100644 --- a/core/site_scons/models/T3W1/emulator.py +++ b/core/site_scons/models/T3W1/emulator.py @@ -32,31 +32,27 @@ def configure( defines += ["FLASH_BIT_ACCESS=1"] defines += ["FLASH_BLOCK_WORDS=1"] - if "dma2d" in features_wanted: - features_available.append("dma2d") - sources += [ - "embed/trezorhal/unix/dma2d_bitblt.c", - ] - defines += ["USE_DMA2D"] - if "sbu" in features_wanted: - sources += ["embed/trezorhal/unix/sbu.c"] + sources += ["embed/io/sbu/unix/sbu.c"] + paths += ["embed/io/sbu/inc"] defines += ["USE_SBU=1"] if "optiga" in features_wanted: - sources += ["embed/trezorhal/unix/optiga_hal.c"] - sources += ["embed/trezorhal/unix/optiga.c"] + sources += ["embed/sec/optiga/unix/optiga_hal.c"] + sources += ["embed/sec/optiga/unix/optiga.c"] + paths += ["embed/sec/optiga/inc"] features_available.append("optiga") defines += ["USE_OPTIGA=1"] if "input" in features_wanted: - sources += ["embed/trezorhal/unix/touch.c"] + sources += ["embed/io/touch/unix/touch.c"] + paths += ["embed/io/touch/inc"] features_available.append("touch") defines += ["USE_TOUCH=1"] features_available.append("backlight") defines += ["USE_BACKLIGHT=1"] - sources += ["embed/trezorhal/stm32u5/layout.c"] + sources += ["embed/util/flash/stm32u5/flash_layout.c"] return features_available diff --git a/core/site_scons/models/T3W1/trezor_t3w1_revA.py b/core/site_scons/models/T3W1/trezor_t3w1_revA.py index fce173b7a9..3d35ffc592 100644 --- a/core/site_scons/models/T3W1/trezor_t3w1_revA.py +++ b/core/site_scons/models/T3W1/trezor_t3w1_revA.py @@ -17,7 +17,7 @@ def configure( hw_revision = 0 mcu = "STM32U5G9xx" - linker_script = """embed/trezorhal/stm32u5/linker/u5g/{target}.ld""" + linker_script = """embed/sys/linker/stm32u5g/{target}.ld""" stm32u5_common_files(env, defines, sources, paths) @@ -35,18 +35,23 @@ def configure( defines += [f"HW_REVISION={hw_revision}"] sources += [ - "embed/trezorhal/stm32u5/xdisplay/st7785ma/display_driver.c", - "embed/trezorhal/stm32u5/backlight_pwm.c", + "embed/io/display/st7785ma/display_driver.c", + "embed/io/display/backlight/stm32/backlight_pwm.c", ] + paths += ["embed/io/display/inc"] + features_available.append("backlight") defines += ["USE_BACKLIGHT=1"] if "input" in features_wanted: - sources += ["embed/trezorhal/stm32u5/i2c_bus.c"] - sources += ["embed/trezorhal/stm32u5/touch/ft6x36.c"] - sources += ["embed/trezorhal/stm32u5/touch/panels/lhs200kb-if21.c"] + sources += ["embed/io/i2c_bus/stm32u5/i2c_bus.c"] + sources += ["embed/io/touch/ft6x36/ft6x36.c"] + sources += ["embed/io/touch/ft6x36/panels/lhs200kb-if21.c"] + paths += ["embed/io/i2c_bus/inc"] + paths += ["embed/io/touch/inc"] features_available.append("touch") - # sources += ["embed/trezorhal/stm32u5/button.c"] + # sources += ["embed/io/button/stm32/button.c"] + # paths += ["embed/io/button/inc"] # features_available.append("button") defines += ["USE_TOUCH=1"] defines += ["USE_I2C=1"] @@ -70,29 +75,31 @@ def configure( ] if "sbu" in features_wanted: - sources += ["embed/trezorhal/stm32u5/sbu.c"] + sources += ["embed/io/sbu/stm32/sbu.c"] + paths += ["embed/io/sbu/inc"] features_available.append("sbu") defines += ["USE_SBU=1"] if "usb" in features_wanted: sources += [ - "embed/trezorhal/stm32u5/usb/usb_class_hid.c", - "embed/trezorhal/stm32u5/usb/usb_class_vcp.c", - "embed/trezorhal/stm32u5/usb/usb_class_webusb.c", - "embed/trezorhal/stm32u5/usb/usb.c", - "embed/trezorhal/stm32u5/usb/usbd_conf.c", - "embed/trezorhal/stm32u5/usb/usbd_core.c", - "embed/trezorhal/stm32u5/usb/usbd_ctlreq.c", - "embed/trezorhal/stm32u5/usb/usbd_ioreq.c", + "embed/io/usb/stm32/usb_class_hid.c", + "embed/io/usb/stm32/usb_class_vcp.c", + "embed/io/usb/stm32/usb_class_webusb.c", + "embed/io/usb/stm32/usb.c", + "embed/io/usb/stm32/usbd_conf.c", + "embed/io/usb/stm32/usbd_core.c", + "embed/io/usb/stm32/usbd_ctlreq.c", + "embed/io/usb/stm32/usbd_ioreq.c", "vendor/stm32u5xx_hal_driver/Src/stm32u5xx_ll_usb.c", ] features_available.append("usb") + paths += ["embed/io/usb/inc"] defines += [ "USE_DMA2D", "USE_RGB_COLORS", ] - sources += ["embed/trezorhal/stm32u5/dma2d_bitblt.c"] + sources += ["embed/gfx/bitblt/stm32/dma2d_bitblt.c"] features_available.append("dma2d") diff --git a/core/site_scons/models/stm32f4_common.py b/core/site_scons/models/stm32f4_common.py index 400595207f..07a8fe51e4 100644 --- a/core/site_scons/models/stm32f4_common.py +++ b/core/site_scons/models/stm32f4_common.py @@ -10,7 +10,26 @@ def stm32f4_common_files(env, defines, sources, paths): ] paths += [ - "embed/trezorhal/stm32f4", + "embed/sec/entropy/inc", + "embed/sec/monoctr/inc", + "embed/sec/random_delays/inc", + "embed/sec/rng/inc", + "embed/sec/secure_aes/inc", + "embed/sec/time_estimate/inc", + "embed/sys/bsp/stm32f4", + "embed/sys/irq/inc", + "embed/sys/mpu/inc", + "embed/sys/pvd/inc", + "embed/sec/secret/inc", + "embed/sys/startup/inc", + "embed/sys/syscall/inc", + "embed/sys/task/inc", + "embed/sys/time/inc", + "embed/util/board_capabilities/inc", + "embed/util/flash/inc", + "embed/util/fwutils/inc", + "embed/util/option_bytes/inc", + "embed/util/unit_properties/inc", "vendor/micropython/lib/cmsis/inc", "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Inc", "vendor/micropython/lib/stm32lib/CMSIS/STM32F4xx/Include", @@ -40,35 +59,35 @@ def stm32f4_common_files(env, defines, sources, paths): ] sources += [ - "embed/trezorhal/stm32f4/applet.c", - "embed/trezorhal/stm32f4/board_capabilities.c", - "embed/trezorhal/stm32f4/bootutils.c", - "embed/trezorhal/stm32f4/entropy.c", - "embed/trezorhal/stm32f4/flash.c", - "embed/trezorhal/stm32f4/flash_otp.c", - "embed/trezorhal/stm32f4/fwutils.c", - "embed/trezorhal/stm32f4/layout.c", - "embed/trezorhal/stm32f4/monoctr.c", - "embed/trezorhal/stm32f4/mpu.c", - "embed/trezorhal/stm32f4/option_bytes.c", - "embed/trezorhal/stm32f4/pvd.c", - "embed/trezorhal/stm32f4/random_delays.c", - "embed/trezorhal/stm32f4/reset_flags.c", - "embed/trezorhal/stm32f4/rng.c", - "embed/trezorhal/stm32f4/secret.c", - "embed/trezorhal/stm32f4/startup_init.c", - "embed/trezorhal/stm32f4/syscall.c", - "embed/trezorhal/stm32f4/syscall_dispatch.c", - "embed/trezorhal/stm32f4/syscall_probe.c", - "embed/trezorhal/stm32f4/syscall_stubs.c", - "embed/trezorhal/stm32f4/syscall_verifiers.c", - "embed/trezorhal/stm32f4/system.c", - "embed/trezorhal/stm32f4/systask.c", - "embed/trezorhal/stm32f4/systick.c", - "embed/trezorhal/stm32f4/systimer.c", - "embed/trezorhal/stm32f4/time_estimate.c", - "embed/trezorhal/stm32f4/unit_properties.c", - "embed/trezorhal/stm32f4/vectortable.S", + "embed/sec/entropy/stm32f4/entropy.c", + "embed/sec/monoctr/stm32f4/monoctr.c", + "embed/sec/random_delays/stm32/random_delays.c", + "embed/sec/rng/stm32/rng.c", + "embed/sec/secret/stm32f4/secret.c", + "embed/sec/time_estimate/stm32/time_estimate.c", + "embed/sys/mpu/stm32f4/mpu.c", + "embed/sys/pvd/stm32/pvd.c", + "embed/sys/startup/stm32/bootutils.c", + "embed/sys/startup/stm32f4/reset_flags.c", + "embed/sys/startup/stm32f4/startup_init.c", + "embed/sys/startup/stm32f4/vectortable.S", + "embed/sys/syscall/stm32/syscall.c", + "embed/sys/syscall/stm32/syscall_dispatch.c", + "embed/sys/syscall/stm32/syscall_probe.c", + "embed/sys/syscall/stm32/syscall_stubs.c", + "embed/sys/syscall/stm32/syscall_verifiers.c", + "embed/sys/task/stm32/applet.c", + "embed/sys/task/stm32/systask.c", + "embed/sys/task/stm32/system.c", + "embed/sys/time/stm32/systick.c", + "embed/sys/time/stm32/systimer.c", + "embed/util/board_capabilities/stm32/board_capabilities.c", + "embed/util/flash/stm32f4/flash.c", + "embed/util/flash/stm32f4/flash_layout.c", + "embed/util/flash/stm32f4/flash_otp.c", + "embed/util/fwutils/fwutils.c", + "embed/util/option_bytes/stm32f4/option_bytes.c", + "embed/util/unit_properties/stm32/unit_properties.c", ] # boardloader needs separate assembler for some function unencumbered by various FW+bootloader hacks @@ -76,12 +95,12 @@ def stm32f4_common_files(env, defines, sources, paths): env_constraints = env.get("CONSTRAINTS") if env_constraints and "limited_util_s" in env_constraints: sources += [ - "embed/trezorhal/stm32f4/limited_util.S", + "embed/sys/startup/stm32f4/limited_util.S", ] else: sources += [ - "embed/trezorhal/stm32f4/util.S", + "embed/sys/startup/stm32f4/util.S", ] env.get("ENV")["SUFFIX"] = "stm32f4" - env.get("ENV")["LINKER_SCRIPT"] = """embed/trezorhal/stm32f4/linker/{target}.ld""" + env.get("ENV")["LINKER_SCRIPT"] = """embed/sys/linker/stm32f4/{target}.ld""" diff --git a/core/site_scons/models/stm32u5_common.py b/core/site_scons/models/stm32u5_common.py index 85a9484914..a7f83d1e05 100644 --- a/core/site_scons/models/stm32u5_common.py +++ b/core/site_scons/models/stm32u5_common.py @@ -10,7 +10,29 @@ def stm32u5_common_files(env, defines, sources, paths): ] paths += [ - "embed/trezorhal/stm32u5", + "embed/sec/entropy/inc", + "embed/sec/hash_processor/inc", + "embed/sec/monoctr/inc", + "embed/sec/random_delays/inc", + "embed/sec/rng/inc", + "embed/sec/secret/inc", + "embed/sec/secure_aes/inc", + "embed/sec/time_estimate/inc", + "embed/sys/irq/inc", + "embed/sys/bsp/stm32u5", + "embed/sys/mpu/inc", + "embed/sys/pvd/inc", + "embed/sys/startup/inc", + "embed/sys/syscall/inc", + "embed/sys/tamper/inc", + "embed/sys/task/inc", + "embed/sys/time/inc", + "embed/sys/trustzone/inc", + "embed/util/board_capabilities/inc", + "embed/util/flash/inc", + "embed/util/fwutils/inc", + "embed/util/option_bytes/inc", + "embed/util/unit_properties/inc", "vendor/stm32u5xx_hal_driver/Inc", "vendor/cmsis_device_u5/Include", "vendor/cmsis_5/CMSIS/Core/Include", @@ -50,39 +72,39 @@ def stm32u5_common_files(env, defines, sources, paths): ] sources += [ - "embed/trezorhal/stm32u5/applet.c", - "embed/trezorhal/stm32u5/board_capabilities.c", - "embed/trezorhal/stm32u5/bootutils.c", - "embed/trezorhal/stm32u5/entropy.c", - "embed/trezorhal/stm32u5/flash.c", - "embed/trezorhal/stm32u5/flash_otp.c", - "embed/trezorhal/stm32u5/fwutils.c", - "embed/trezorhal/stm32u5/layout.c", - "embed/trezorhal/stm32u5/hash_processor.c", - "embed/trezorhal/stm32u5/monoctr.c", - "embed/trezorhal/stm32u5/mpu.c", - "embed/trezorhal/stm32u5/option_bytes.c", - "embed/trezorhal/stm32u5/pvd.c", - "embed/trezorhal/stm32u5/random_delays.c", - "embed/trezorhal/stm32u5/reset_flags.c", - "embed/trezorhal/stm32u5/rng.c", - "embed/trezorhal/stm32u5/secret.c", - "embed/trezorhal/stm32u5/secure_aes.c", - "embed/trezorhal/stm32u5/startup_init.c", - "embed/trezorhal/stm32u5/syscall.c", - "embed/trezorhal/stm32u5/syscall_dispatch.c", - "embed/trezorhal/stm32u5/syscall_probe.c", - "embed/trezorhal/stm32u5/syscall_stubs.c", - "embed/trezorhal/stm32u5/syscall_verifiers.c", - "embed/trezorhal/stm32u5/system.c", - "embed/trezorhal/stm32u5/systask.c", - "embed/trezorhal/stm32u5/systick.c", - "embed/trezorhal/stm32u5/systimer.c", - "embed/trezorhal/stm32u5/tamper.c", - "embed/trezorhal/stm32u5/time_estimate.c", - "embed/trezorhal/stm32u5/trustzone.c", - "embed/trezorhal/stm32u5/unit_properties.c", - "embed/trezorhal/stm32u5/vectortable.S", + "embed/sec/entropy/stm32u5/entropy.c", + "embed/sec/hash_processor/stm32u5/hash_processor.c", + "embed/sec/monoctr/stm32u5/monoctr.c", + "embed/sec/random_delays/stm32/random_delays.c", + "embed/sec/rng/stm32/rng.c", + "embed/sec/secret/stm32u5/secret.c", + "embed/sec/secure_aes/stm32u5/secure_aes.c", + "embed/sec/time_estimate/stm32/time_estimate.c", + "embed/sys/mpu/stm32u5/mpu.c", + "embed/sys/pvd/stm32/pvd.c", + "embed/sys/startup/stm32/bootutils.c", + "embed/sys/startup/stm32u5/reset_flags.c", + "embed/sys/startup/stm32u5/startup_init.c", + "embed/sys/startup/stm32u5/vectortable.S", + "embed/sys/syscall/stm32/syscall.c", + "embed/sys/syscall/stm32/syscall_dispatch.c", + "embed/sys/syscall/stm32/syscall_probe.c", + "embed/sys/syscall/stm32/syscall_stubs.c", + "embed/sys/syscall/stm32/syscall_verifiers.c", + "embed/sys/tamper/stm32u5/tamper.c", + "embed/sys/task/stm32/applet.c", + "embed/sys/task/stm32/systask.c", + "embed/sys/task/stm32/system.c", + "embed/sys/time/stm32/systick.c", + "embed/sys/time/stm32/systimer.c", + "embed/sys/trustzone/stm32u5/trustzone.c", + "embed/util/board_capabilities/stm32/board_capabilities.c", + "embed/util/flash/stm32u5/flash.c", + "embed/util/flash/stm32u5/flash_layout.c", + "embed/util/flash/stm32u5/flash_otp.c", + "embed/util/fwutils/fwutils.c", + "embed/util/option_bytes/stm32u5/option_bytes.c", + "embed/util/unit_properties/stm32/unit_properties.c", ] # boardloader needs separate assembler for some function unencumbered by various FW+bootloader hacks @@ -90,11 +112,11 @@ def stm32u5_common_files(env, defines, sources, paths): env_constraints = env.get("CONSTRAINTS") if env_constraints and "limited_util_s" in env_constraints: sources += [ - "embed/trezorhal/stm32u5/limited_util.S", + "embed/sys/startup/stm32u5/limited_util.S", ] else: sources += [ - "embed/trezorhal/stm32u5/util.S", + "embed/sys/startup/stm32u5/util.S", ] env.get("ENV")["SUFFIX"] = "stm32u5" diff --git a/core/site_scons/ui/common.py b/core/site_scons/ui/common.py index c13b67c1ef..83f0dc96ea 100644 --- a/core/site_scons/ui/common.py +++ b/core/site_scons/ui/common.py @@ -10,6 +10,6 @@ def add_font( "TREZOR_FONT_" + font_name + "_ENABLE=" + font, "TREZOR_FONT_" + font_name + '_INCLUDE=\\"' + font_filename + '.h\\"', ] - sourcefile = "embed/lib/fonts/" + font_filename + ".c" + sourcefile = "embed/gfx/fonts/" + font_filename + ".c" if sourcefile not in sources: sources.append(sourcefile) diff --git a/core/src/apps/monero/README.md b/core/src/apps/monero/README.md index 8ad510db1c..5c4237c651 100644 --- a/core/src/apps/monero/README.md +++ b/core/src/apps/monero/README.md @@ -265,7 +265,7 @@ level operations are implemented, such as MLSAG. #### Crypto API -API bridging [trezor-crypto] and [trezor-core]: `embed/extmod/modtrezorcrypto/modtrezorcrypto-monero.h` +API bridging [trezor-crypto] and [trezor-core]: `embed/upymod/modtrezorcrypto/modtrezorcrypto-monero.h` It encapsulates Ed25519 points and scalars in corresponding Python classes which have memory-wiping destructor. API provides basic functions for work with scalars and points and Monero specific functions. diff --git a/core/tools/build_mocks b/core/tools/build_mocks index f5dbdf4c52..82dd1b968e 100755 --- a/core/tools/build_mocks +++ b/core/tools/build_mocks @@ -7,7 +7,7 @@ import tempfile from pathlib import Path CORE_DIR = Path(__file__).resolve().parent.parent -EXTMOD_PATH = CORE_DIR / "embed" / "extmod" +EXTMOD_PATH = CORE_DIR / "embed" / "upymod" RUSTMOD_PATH = CORE_DIR / "embed" / "rust" / "src" MOCKS_PATH = CORE_DIR / "mocks" / "generated" diff --git a/core/tools/codegen/gen_font.py b/core/tools/codegen/gen_font.py index bd86912d83..6cad9d1c8f 100755 --- a/core/tools/codegen/gen_font.py +++ b/core/tools/codegen/gen_font.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# script used to generate core/embed/lib/fonts/font_*_*.c +# script used to generate core/embed/gfx/fonts/font_*_*.c from __future__ import annotations @@ -24,8 +24,8 @@ def _normalize(s: str) -> str: HERE = Path(__file__).parent CORE_ROOT = HERE.parent.parent FONTS_DIR = HERE / "fonts" -OUT_DIR = HERE / ".." / ".." / "embed" / "lib" / "fonts" -C_FONTS_DEST = CORE_ROOT / "embed" / "lib" / "fonts" +OUT_DIR = HERE / ".." / ".." / "embed" / "drv" / "gfx" / "fonts" +C_FONTS_DEST = CORE_ROOT / "embed" / "drv" / "gfx" / "fonts" JSON_FONTS_DEST = CORE_ROOT / "translations" / "fonts" MIN_GLYPH = ord(" ") diff --git a/core/tools/codegen/gen_loader.py b/core/tools/codegen/gen_loader.py index 57e36cc01e..44225fc64a 100755 --- a/core/tools/codegen/gen_loader.py +++ b/core/tools/codegen/gen_loader.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# script used to generate /embed/extmod/modtrezorui/loader_X.h +# script used to generate /embed/upymod/modtrezorui/loader_X.h import math diff --git a/core/tools/size/checker.py b/core/tools/size/checker.py index f16de12b9c..09a6613666 100755 --- a/core/tools/size/checker.py +++ b/core/tools/size/checker.py @@ -20,7 +20,7 @@ if len(sys.argv) > 1: else: BIN_TO_ANALYZE = CORE_DIR / "build/firmware/firmware.elf" # type: ignore -# Comes from `core/embed/firmware/memory_T.ld` +# Comes from `core/embed/projects/firmware/memory_T.ld` FLASH_SIZE_KB = 768 FLASH_2_SIZE_KB = 896 diff --git a/core/tools/size/groups.py b/core/tools/size/groups.py index 22cd01c699..1fa427fd0a 100755 --- a/core/tools/size/groups.py +++ b/core/tools/size/groups.py @@ -27,7 +27,7 @@ def _categories_func(row: DataRow) -> str | None: CATEGORIES: dict[str, Callable[[DataRow], bool]] = { "UI": lambda row: ( row.source_definition.startswith( - ("src/trezor/ui/", "embed/extmod/modtrezorui/") + ("src/trezor/ui/", "embed/upymod/modtrezorui/") ) ), "Crypto": lambda row: ( @@ -35,7 +35,7 @@ def _categories_func(row: DataRow) -> str | None: ( "vendor/trezor-crypto/", "src/trezor/crypto/", - "embed/extmod/modtrezorcrypto/", + "embed/upymod/modtrezorcrypto/", ) ) ), @@ -80,22 +80,26 @@ def _categories_func(row: DataRow) -> str | None: ), "Other apps": lambda row: row.source_definition.startswith("src/apps/"), "Rest of src/": lambda row: row.source_definition.startswith("src/"), - "Fonts": lambda row: row.source_definition.startswith("embed/lib/fonts/"), + "Fonts": lambda row: row.source_definition.startswith("embed/gfx/fonts/"), "Embed firmware": lambda row: row.source_definition.startswith( - "embed/firmware/" + "embed/projects/firmware/" + ), + "Trezorhal": lambda row: row.source_definition.startswith( + ("embed/io/", "embed/sys/", "embed/sec/", "embed/util/") ), - "Trezorhal": lambda row: row.source_definition.startswith("embed/trezorhal/"), "Trezorio": lambda row: row.source_definition.startswith( - "embed/extmod/modtrezorio/" + "embed/upymod/modtrezorio/" ), "Trezorconfig": lambda row: row.source_definition.startswith( - "embed/extmod/modtrezorconfig/" + "embed/upymod/modtrezorconfig/" ), "Trezorutils": lambda row: row.source_definition.startswith( - "embed/extmod/modtrezorutils/" + "embed/upymod/modtrezorutils/" + ), + "Embed upymod": lambda row: row.source_definition.startswith("embed/upymod/"), + "Embed lib": lambda row: row.source_definition.startswith( + ("embed/rtl/", "embed/gfx/") ), - "Embed extmod": lambda row: row.source_definition.startswith("embed/extmod/"), - "Embed lib": lambda row: row.source_definition.startswith("embed/lib/"), "Rust": lambda row: ( row.language == "Rust" or row.source_definition.startswith(("embed/rust/", "/cargo/registry")) diff --git a/core/tools/snippets/change_icon_format.py b/core/tools/snippets/change_icon_format.py index 529e866992..0058ed4cc2 100644 --- a/core/tools/snippets/change_icon_format.py +++ b/core/tools/snippets/change_icon_format.py @@ -140,10 +140,10 @@ def reformat_toif_icons(p: str | Path) -> None: def change_icon_format(): # bootloader icons - reformat_c_icons(CORE_DIR / "embed/bootloader") + reformat_c_icons(CORE_DIR / "embed/projects/bootloader") # bootloader_ci icons - reformat_c_icons(CORE_DIR / "embed/bootloader_ci") + reformat_c_icons(CORE_DIR / "embed/projects/bootloader_ci") # rust icons reformat_toif_icons(CORE_DIR / "embed/rust/src/ui/model_tr/res") diff --git a/core/translations/cli.py b/core/translations/cli.py index f59c038259..734a68cec5 100755 --- a/core/translations/cli.py +++ b/core/translations/cli.py @@ -28,7 +28,7 @@ PUBLIC_KEYS_PROD = [ ) ] -VERSION_H = HERE.parent / "embed" / "firmware" / "version.h" +VERSION_H = HERE.parent / "embed" / "projects" / "firmware" / "version.h" SIGNATURES_JSON = HERE / "signatures.json" diff --git a/docs/core/embed_debug/index.md b/docs/core/embed_debug/index.md index b3674763b7..1091ccf691 100644 --- a/docs/core/embed_debug/index.md +++ b/docs/core/embed_debug/index.md @@ -128,7 +128,7 @@ First, clone the repo and build both emulator and embedded code: Now rename `Makefile` under `core` to something else, like `Makefile.orig`. Open the `core` directory as new project in CLion. -Open any .c file, e.g. `embed/firmware/main.c`. +Open any .c file, e.g. `embed/projects/firmware/main.c`. At this point since CLion does not see `Makefile` or `CMakeLists.txt`, it will [suggest creating CMakeLists for you based on existing files](https://www.jetbrains.com/help/clion/creating-new-project-from-scratch.html#example). diff --git a/docs/core/index.md b/docs/core/index.md index bbea796915..55ad67be48 100644 --- a/docs/core/index.md +++ b/docs/core/index.md @@ -6,7 +6,7 @@ Trezor Core is part of the trezor-firmware monorepo to be found on [GitHub](http Trezor Core uses [MicroPython](https://github.com/micropython/micropython), it is a Python implementation for embedded systems, which allows us to have an application layer in Python, which makes the code significantly more readable and sustainable. This is what you find in the `src` folder. -Not everything is in Python though, we need to use C occasionally, usually for performance reasons. That is what `embed/extmod` is for. It extends MicroPython's modules with a number of our owns and serves as a bridge between C and Python codebase. Related to that, `mocks` contain Python mocks of those functions to improve readability and IDE functioning. +Not everything is in Python though, we need to use C occasionally, usually for performance reasons. That is what `embed/upymod` is for. It extends MicroPython's modules with a number of our owns and serves as a bridge between C and Python codebase. Related to that, `mocks` contain Python mocks of those functions to improve readability and IDE functioning. Where appropriate, we also use Rust. For example, all UI components and animations are implemented in `embed/rust`. Similarly to C bindings, you can find Python mocks for the Rust functions in `mocks` directory. Developing new features in Rust is preferred in the future. diff --git a/docs/misc/changelog.md b/docs/misc/changelog.md index 2a35513e56..c9dc10b02d 100644 --- a/docs/misc/changelog.md +++ b/docs/misc/changelog.md @@ -7,9 +7,9 @@ at the time a new version is released. There are currently 8 such changelogs for different components of the repository: * **[`core/CHANGELOG.md`](https://github.com/trezor/trezor-firmware/blob/master/core/CHANGELOG.md)** for Trezor T firmware -* **[`core/embed/boardloader/CHANGELOG.md`](https://github.com/trezor/trezor-firmware/blob/master/core/embed/boardloader/CHANGELOG.md)** for Trezor T boardloader -* **[`core/embed/bootloader/CHANGELOG.md`](https://github.com/trezor/trezor-firmware/blob/master/core/embed/bootloader/CHANGELOG.md)** for Trezor T bootloader -* **[`core/embed/bootloader_ci/CHANGELOG.md`](https://github.com/trezor/trezor-firmware/blob/master/core/embed/bootloader_ci/CHANGELOG.md)** for Trezor T CI bootloader +* **[`core/embed/projects/boardloader/CHANGELOG.md`](https://github.com/trezor/trezor-firmware/blob/master/core/embed/projects/boardloader/CHANGELOG.md)** for Trezor T boardloader +* **[`core/embed/projects/bootloader/CHANGELOG.md`](https://github.com/trezor/trezor-firmware/blob/master/core/embed/projects/bootloader/CHANGELOG.md)** for Trezor T bootloader +* **[`core/embed/projects/bootloader_ci/CHANGELOG.md`](https://github.com/trezor/trezor-firmware/blob/master/core/embed/projects/bootloader_ci/CHANGELOG.md)** for Trezor T CI bootloader * **[`legacy/firmware/CHANGELOG.md`](https://github.com/trezor/trezor-firmware/blob/master/legacy/firmware/CHANGELOG.md)** for Trezor 1 firmware * **[`legacy/bootloader/CHANGELOG.md`](https://github.com/trezor/trezor-firmware/blob/master/legacy/bootloader/CHANGELOG.md)** for Trezor 1 bootloader * **[`legacy/intermediate_fw/CHANGELOG.md`](https://github.com/trezor/trezor-firmware/blob/master/legacy/intermediate_fw/CHANGELOG.md)** for Trezor 1 intermediate firmware diff --git a/docs/misc/generated-files.md b/docs/misc/generated-files.md index adfc7c8153..2e2c802279 100644 --- a/docs/misc/generated-files.md +++ b/docs/misc/generated-files.md @@ -15,7 +15,7 @@ the result. The following is a (possibly incomplete) list of files regenerated by `make gen`: * `core/mocks/generated`: mock Python stubs for C modules (`modtrezor*`). Generated from - special comments in `embed/extmod/modtrezor*`. + special comments in `embed/upymod/modtrezor*`. * `networks.py`, `tokens.py`, `coininfo.py` and `nem_mosaics.py` in their respective subdirectories of `core/src/apps`. In general, any file matching `*.py.mako` has a corresponding `*.py` file generated from the Mako template. These files are based on diff --git a/tools/bump-version.py b/tools/bump-version.py index f045dc76aa..2d15701a4d 100755 --- a/tools/bump-version.py +++ b/tools/bump-version.py @@ -73,7 +73,7 @@ def cli(project, version): ) elif parts[-1] == "core": bump_header( - project / "embed" / "firmware" / "version.h", + project / "embed" / "projects" / "firmware" / "version.h", VERSION_MAJOR=major, VERSION_MINOR=minor, VERSION_PATCH=patch, diff --git a/tools/style.c.exclude b/tools/style.c.exclude index adeb5ca608..6487231786 100644 --- a/tools/style.c.exclude +++ b/tools/style.c.exclude @@ -1,4 +1,4 @@ -^\./core/embed/bootloader/protob/ +^\./core/embed/projects/bootloader/protob/ ^\./crypto/aes/ ^\./crypto/chacha20poly1305/ ^\./crypto/ed25519-donna/ @@ -9,4 +9,4 @@ ^\./crypto/sha2 ^\./crypto/sha3 ^\./legacy/vendor -^\./core/embed/segger +^\./core/embed/sys/systemview/stm32