mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
stm32/eth: Don't pad eth_dma_t struct on H5 and N6 MCUs.
It's not necessary (and wastes RAM), the MPU can handle regions of arbitrary size. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user