Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/port/stm32/stm32_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,14 @@ struct eth_desc {
#if defined(STM32H7) || defined(STM32N6)
#define ETH_SECTION __attribute__((section(".eth_buffers")))
#elif defined(STM32H5)
/* H5 places ETH descriptors and buffers in the regular .bss region.
* Both TZEN=0 (TrustZone disabled) and TZEN=1 (NS app under wolfBoot)
* link RAM into a single NS-accessible region; no separate ETHMEM
* alias is needed since the CPU and ETH DMA both run in NS world and
* share the same NS view of physical SRAM. */
#define ETH_SECTION
/* H5 pins ETH descriptors and buffers into the .eth_buffers section.
* Under TZEN=1, wolfBoot keeps SRAM3 non-secure but PRIVILEGED and
* cedes SRAM2 as non-secure + UNPRIVILEGED. The H5 ETH DMA master is
* unprivileged, so its descriptors/buffers must live in SRAM2; the
* linker script places .eth_buffers at the base of NS RAM (SRAM2 at
* 0x20040000). The same macro is used for TZEN=0, which has no
* privilege constraint but maps .eth_buffers the same way. */
#define ETH_SECTION __attribute__((section(".eth_buffers")))
#endif

/* DMA descriptor / buffer addresses are taken as-is. NS pointers map
Expand Down
11 changes: 11 additions & 0 deletions src/port/stm32h563/target.ld
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ SECTIONS
__fini_array_end = .;
} > FLASH

/* ETH DMA arena. TrustZone is disabled here so there is no privilege
* constraint, but stm32_eth.c emits descriptors/buffers into the
* named .eth_buffers section for all STM32H5 builds, so give it an
* explicit home in RAM. */
.eth_buffers (NOLOAD) :
{
. = ALIGN(32);
KEEP(*(.eth_buffers))
. = ALIGN(32);
} > RAM

.data :
{
. = ALIGN(4);
Expand Down
20 changes: 18 additions & 2 deletions src/port/stm32h563/target_tzen.ld
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
* RAM: wolfBoot (patched hal_gtzc_init / hal_tz_sau_init) keeps SRAM1
* secure for its own use and cedes SRAM2 + SRAM3 to NS:
* NS RAM: 0x20040000 .. 0x2009FFFF (384 KB, SRAM2 + SRAM3)
* SRAM2 (0x20040000, 64 KB) is non-secure + UNPRIVILEGED; SRAM3
* (0x20050000, 320 KB) is non-secure + PRIVILEGED. The .eth_buffers
* section is placed first so the ETH DMA descriptors/buffers land in
* SRAM2: the H5 ETH DMA master is unprivileged and can only reach the
* unprivileged window. The privileged NS CPU uses the rest of RAM.
*
* The NS app runs in Non-Secure world; plain LDR/STR carry HNONSEC=1,
* matching the H5 product-default NS attribution for the ETH peripheral
* and DMA. ETH descriptors and buffers live in the same NS RAM region
* as everything else -- no separate ETHMEM alias is needed.
* and DMA.
*/

MEMORY
Expand Down Expand Up @@ -78,6 +82,18 @@ SECTIONS
__fini_array_end = .;
} > FLASH

/* ETH DMA arena: placed first in RAM (RAM ORIGIN = 0x20040000 =
* SRAM2 base) so descriptors/buffers stay in the unprivileged SRAM2
* window reachable by the unprivileged ETH DMA master. NOLOAD: no
* FLASH load image, so LOADADDR(.data) below is unaffected. */
.eth_buffers (NOLOAD) :
{
. = ALIGN(32);
KEEP(*(.eth_buffers))
. = ALIGN(32);
} > RAM
ASSERT(. <= 0x20050000, ".eth_buffers must fit within SRAM2 (0x20040000-0x2004FFFF)")

.data :
{
. = ALIGN(4);
Expand Down
Loading