diff --git a/ports/stm32/eth.c b/ports/stm32/eth.c index cece15d457..81faca5cb4 100644 --- a/ports/stm32/eth.c +++ b/ports/stm32/eth.c @@ -133,12 +133,14 @@ typedef struct _eth_dma_t { eth_dma_tx_descr_t tx_descr[TX_BUF_NUM]; uint8_t rx_buf[RX_BUF_NUM * RX_BUF_SIZE] __attribute__((aligned(8))); uint8_t tx_buf[TX_BUF_NUM * TX_BUF_SIZE] __attribute__((aligned(8))); + #if !defined(STM32H5) && !defined(STM32N6) // Make sure the size of this struct is 16k, for the MPU. uint8_t padding[16 * 1024 - sizeof(eth_dma_rx_descr_t) * RX_BUF_NUM - sizeof(eth_dma_tx_descr_t) * TX_BUF_NUM - RX_BUF_NUM * RX_BUF_SIZE - TX_BUF_NUM * TX_BUF_SIZE]; + #endif } eth_dma_t; typedef struct _eth_t { @@ -220,8 +222,6 @@ uint32_t eth_phy_read(uint32_t phy_addr, uint32_t reg) { } int eth_init(eth_t *self, int mac_idx, uint32_t phy_addr, int phy_type) { - MP_STATIC_ASSERT(sizeof(eth_dma_t) == 16 * 1024); - mp_hal_get_mac(mac_idx, &self->netif.hwaddr[0]); self->netif.hwaddr_len = 6; self->phy_addr = phy_addr; @@ -295,8 +295,9 @@ static int eth_mac_init(eth_t *self) { // Configure MPU uint32_t irq_state = mpu_config_start(); #if defined(STM32H5) || defined(STM32N6) - mpu_config_region(MPU_REGION_ETH, (uint32_t)ð_dma, MPU_CONFIG_ETH(16 * 1024)); + mpu_config_region(MPU_REGION_ETH, (uint32_t)ð_dma, MPU_CONFIG_ETH(sizeof(eth_dma_t))); #else + MP_STATIC_ASSERT(sizeof(eth_dma_t) == 16 * 1024); mpu_config_region(MPU_REGION_ETH, (uint32_t)ð_dma, MPU_CONFIG_ETH(MPU_REGION_SIZE_16KB)); #endif mpu_config_end(irq_state);