@@ -133,12 +133,14 @@ typedef struct _eth_dma_t {
133133 eth_dma_tx_descr_t tx_descr [TX_BUF_NUM ];
134134 uint8_t rx_buf [RX_BUF_NUM * RX_BUF_SIZE ] __attribute__((aligned (8 )));
135135 uint8_t tx_buf [TX_BUF_NUM * TX_BUF_SIZE ] __attribute__((aligned (8 )));
136+ #if !defined(STM32H5 ) && !defined(STM32N6 )
136137 // Make sure the size of this struct is 16k, for the MPU.
137138 uint8_t padding [16 * 1024
138139 - sizeof (eth_dma_rx_descr_t ) * RX_BUF_NUM
139140 - sizeof (eth_dma_tx_descr_t ) * TX_BUF_NUM
140141 - RX_BUF_NUM * RX_BUF_SIZE
141142 - TX_BUF_NUM * TX_BUF_SIZE ];
143+ #endif
142144} eth_dma_t ;
143145
144146typedef struct _eth_t {
@@ -220,8 +222,6 @@ uint32_t eth_phy_read(uint32_t phy_addr, uint32_t reg) {
220222}
221223
222224int eth_init (eth_t * self , int mac_idx , uint32_t phy_addr , int phy_type ) {
223- MP_STATIC_ASSERT (sizeof (eth_dma_t ) == 16 * 1024 );
224-
225225 mp_hal_get_mac (mac_idx , & self -> netif .hwaddr [0 ]);
226226 self -> netif .hwaddr_len = 6 ;
227227 self -> phy_addr = phy_addr ;
@@ -295,8 +295,9 @@ static int eth_mac_init(eth_t *self) {
295295 // Configure MPU
296296 uint32_t irq_state = mpu_config_start ();
297297 #if defined(STM32H5 ) || defined(STM32N6 )
298- mpu_config_region (MPU_REGION_ETH , (uint32_t )& eth_dma , MPU_CONFIG_ETH (16 * 1024 ));
298+ mpu_config_region (MPU_REGION_ETH , (uint32_t )& eth_dma , MPU_CONFIG_ETH (sizeof ( eth_dma_t ) ));
299299 #else
300+ MP_STATIC_ASSERT (sizeof (eth_dma_t ) == 16 * 1024 );
300301 mpu_config_region (MPU_REGION_ETH , (uint32_t )& eth_dma , MPU_CONFIG_ETH (MPU_REGION_SIZE_16KB ));
301302 #endif
302303 mpu_config_end (irq_state );
0 commit comments