From c42c268e053f5a2c797e1afc10c348b0a8698a4b Mon Sep 17 00:00:00 2001 From: tychovrahe Date: Mon, 5 Aug 2024 17:13:54 +0200 Subject: [PATCH] fix(core): fix dma2d includes and initialization with respect to new rendering [no changelog] --- core/SConscript.bootloader_emu | 1 - core/embed/boardloader/main.c | 12 ++++++++++++ core/embed/bootloader/main.c | 4 ++++ core/embed/firmware/main.c | 5 +++++ core/embed/trezorhal/dma2d_bitblt.h | 3 +++ core/embed/trezorhal/stm32f4/dma2d_bitblt.c | 2 ++ core/embed/trezorhal/unix/dma2d_bitblt.c | 2 ++ core/site_scons/models/D001/discovery.py | 7 +++++-- core/site_scons/models/D002/discovery2.py | 8 ++++---- core/site_scons/models/T2T1/trezor_t.py | 6 ++++-- core/site_scons/models/T3T1/trezor_t3t1_revE.py | 6 ++++-- core/site_scons/models/T3T1/trezor_t3t1_v4.py | 6 ++++-- 12 files changed, 49 insertions(+), 13 deletions(-) diff --git a/core/SConscript.bootloader_emu b/core/SConscript.bootloader_emu index a9083f8c6a..a71a7aade7 100644 --- a/core/SConscript.bootloader_emu +++ b/core/SConscript.bootloader_emu @@ -158,7 +158,6 @@ SOURCE_TREZORHAL = [ if NEW_RENDERING: SOURCE_TREZORHAL += [ 'embed/trezorhal/unix/display_driver.c', - 'embed/trezorhal/unix/dma2d_bitblt.c', 'embed/trezorhal/xdisplay_legacy.c', ] else: diff --git a/core/embed/boardloader/main.c b/core/embed/boardloader/main.c index 4f7fa1c50c..6f5d3eee3a 100644 --- a/core/embed/boardloader/main.c +++ b/core/embed/boardloader/main.c @@ -44,6 +44,14 @@ #include "hash_processor.h" #endif +#ifdef USE_DMA2D +#ifdef NEW_RENDERING +#include "dma2d_bitblt.h" +#else +#include "dma2d.h" +#endif +#endif + #include "lowlevel.h" #include "model.h" #include "version.h" @@ -281,6 +289,10 @@ int main(void) { hash_processor_init(); #endif +#ifdef USE_DMA2D + dma2d_init(); +#endif + display_init(); display_clear(); display_refresh(); diff --git a/core/embed/bootloader/main.c b/core/embed/bootloader/main.c index cec5b58b7f..fbba58170e 100644 --- a/core/embed/bootloader/main.c +++ b/core/embed/bootloader/main.c @@ -35,8 +35,12 @@ #include "secret.h" #ifdef USE_DMA2D +#ifdef NEW_RENDERING +#include "dma2d_bitblt.h" +#else #include "dma2d.h" #endif +#endif #ifdef USE_I2C #include "i2c.h" #endif diff --git a/core/embed/firmware/main.c b/core/embed/firmware/main.c index 4785fce6dd..fc59514d3c 100644 --- a/core/embed/firmware/main.c +++ b/core/embed/firmware/main.c @@ -60,8 +60,13 @@ #include "consumption_mask.h" #endif #ifdef USE_DMA2D +#ifdef NEW_RENDERING +#include "dma2d_bitblt.h" +#else #include "dma2d.h" #endif +#endif + #ifdef USE_BUTTON #include "button.h" #endif diff --git a/core/embed/trezorhal/dma2d_bitblt.h b/core/embed/trezorhal/dma2d_bitblt.h index 0f3aa26bb1..86c0731167 100644 --- a/core/embed/trezorhal/dma2d_bitblt.h +++ b/core/embed/trezorhal/dma2d_bitblt.h @@ -22,6 +22,9 @@ #include "gfx_bitblt.h" +// Initializes DMA2D peripheral +void dma2d_init(void); + // Waits until any pending DMA2D operation is finished void dma2d_wait(void); diff --git a/core/embed/trezorhal/stm32f4/dma2d_bitblt.c b/core/embed/trezorhal/stm32f4/dma2d_bitblt.c index 2ca307e088..87bc6452f6 100644 --- a/core/embed/trezorhal/stm32f4/dma2d_bitblt.c +++ b/core/embed/trezorhal/stm32f4/dma2d_bitblt.c @@ -40,6 +40,8 @@ static inline bool dma2d_accessible(const void* ptr) { #endif } +void dma2d_init(void) { __HAL_RCC_DMA2D_CLK_ENABLE(); } + void dma2d_wait(void) { while (HAL_DMA2D_PollForTransfer(&dma2d_handle, 10) != HAL_OK) ; diff --git a/core/embed/trezorhal/unix/dma2d_bitblt.c b/core/embed/trezorhal/unix/dma2d_bitblt.c index c2fe9c71a7..f92fae98dc 100644 --- a/core/embed/trezorhal/unix/dma2d_bitblt.c +++ b/core/embed/trezorhal/unix/dma2d_bitblt.c @@ -19,4 +19,6 @@ #include "dma2d_bitblt.h" +void dma2d_init(void) {} + void dma2d_wait(void) {} diff --git a/core/site_scons/models/D001/discovery.py b/core/site_scons/models/D001/discovery.py index 327d6b9c58..b0533b5679 100644 --- a/core/site_scons/models/D001/discovery.py +++ b/core/site_scons/models/D001/discovery.py @@ -48,8 +48,11 @@ def configure( sources += [f"embed/trezorhal/stm32f4/displays/{display}"] sources += ["embed/trezorhal/stm32f4/displays/ili9341_spi.c"] - sources += ["embed/trezorhal/stm32f4/dma2d.c"] - sources += ["embed/trezorhal/stm32f4/dma2d_bitblt.c"] + if "new_rendering" in features_wanted: + sources += ["embed/trezorhal/stm32u5/dma2d_bitblt.c"] + else: + sources += ["embed/trezorhal/stm32u5/dma2d.c"] + sources += [ "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma2d.c" ] diff --git a/core/site_scons/models/D002/discovery2.py b/core/site_scons/models/D002/discovery2.py index 6c73b7efbd..cba3537d1f 100644 --- a/core/site_scons/models/D002/discovery2.py +++ b/core/site_scons/models/D002/discovery2.py @@ -92,10 +92,10 @@ def configure( features_available.append("usb") defines += ["USE_DMA2D", "FRAMEBUFFER", "FRAMEBUFFER32BIT", "UI_COLOR_32BIT"] - sources += [ - "embed/trezorhal/stm32u5/dma2d.c", - "embed/trezorhal/stm32u5/dma2d_bitblt.c", - ] + if "new_rendering" in features_wanted: + sources += ["embed/trezorhal/stm32u5/dma2d_bitblt.c"] + else: + sources += ["embed/trezorhal/stm32u5/dma2d.c"] features_available.append("dma2d") features_available.append("framebuffer") features_available.append("framebuffer32bit") diff --git a/core/site_scons/models/T2T1/trezor_t.py b/core/site_scons/models/T2T1/trezor_t.py index 11550162d7..237db9aa96 100644 --- a/core/site_scons/models/T2T1/trezor_t.py +++ b/core/site_scons/models/T2T1/trezor_t.py @@ -113,8 +113,10 @@ def configure( if "dma2d" in features_wanted: defines += ["USE_DMA2D"] - sources += ["embed/trezorhal/stm32f4/dma2d.c"] - sources += ["embed/trezorhal/stm32f4/dma2d_bitblt.c"] + if "new_rendering" in features_wanted: + sources += ["embed/trezorhal/stm32u5/dma2d_bitblt.c"] + else: + sources += ["embed/trezorhal/stm32u5/dma2d.c"] sources += [ "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma2d.c" ] diff --git a/core/site_scons/models/T3T1/trezor_t3t1_revE.py b/core/site_scons/models/T3T1/trezor_t3t1_revE.py index 644efac595..1c0ca02b55 100644 --- a/core/site_scons/models/T3T1/trezor_t3t1_revE.py +++ b/core/site_scons/models/T3T1/trezor_t3t1_revE.py @@ -114,8 +114,10 @@ def configure( if "dma2d" in features_wanted: defines += ["USE_DMA2D"] - sources += ["embed/trezorhal/stm32u5/dma2d.c"] - sources += ["embed/trezorhal/stm32u5/dma2d_bitblt.c"] + if "new_rendering" in features_wanted: + sources += ["embed/trezorhal/stm32u5/dma2d_bitblt.c"] + else: + sources += ["embed/trezorhal/stm32u5/dma2d.c"] features_available.append("dma2d") if "optiga" in features_wanted: diff --git a/core/site_scons/models/T3T1/trezor_t3t1_v4.py b/core/site_scons/models/T3T1/trezor_t3t1_v4.py index 6b32ca5e2d..ad6b3bfaac 100644 --- a/core/site_scons/models/T3T1/trezor_t3t1_v4.py +++ b/core/site_scons/models/T3T1/trezor_t3t1_v4.py @@ -115,8 +115,10 @@ def configure( if "dma2d" in features_wanted: defines += ["USE_DMA2D"] - sources += ["embed/trezorhal/stm32u5/dma2d.c"] - sources += ["embed/trezorhal/stm32u5/dma2d_bitblt.c"] + if "new_rendering" in features_wanted: + sources += ["embed/trezorhal/stm32u5/dma2d_bitblt.c"] + else: + sources += ["embed/trezorhal/stm32u5/dma2d.c"] features_available.append("dma2d") if "optiga" in features_wanted: