Skip to content

Commit 3ffb9b4

Browse files
committed
MIMXRT1050: Fix ENET issues
This is a fix for Issue 10239. The change includes 1. Invalidate receive buffers 2. Align the receive buffer lengths Signed-off-by: Mahesh Mahadevan <[email protected]>
1 parent d8dc981 commit 3ffb9b4

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

features/netsocket/emac-drivers/TARGET_NXP_EMAC/TARGET_IMX/imx_emac.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
#include "mbed_shared_queues.h"
4444

4545
#include "fsl_phy.h"
46+
#if defined(FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL) && FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL
47+
#include "fsl_cache.h"
48+
#endif /* FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL */
4649

4750
#include "imx_emac_config.h"
4851
#include "imx_emac.h"
@@ -189,7 +192,8 @@ bool Kinetis_EMAC::low_level_init_successful()
189192

190193
/* Create buffers for each receive BD */
191194
for (i = 0; i < ENET_RX_RING_LEN; i++) {
192-
rx_buff[i] = memory_manager->alloc_heap(ENET_ETH_MAX_FLEN, ENET_BUFF_ALIGNMENT);
195+
rx_buff[i] = memory_manager->alloc_heap(ENET_ALIGN(ENET_ETH_MAX_FLEN, ENET_BUFF_ALIGNMENT),
196+
ENET_BUFF_ALIGNMENT);
193197
if (NULL == rx_buff[i])
194198
return false;
195199

@@ -278,8 +282,14 @@ emac_mem_buf_t *Kinetis_EMAC::low_level_input(int idx)
278282
p = rx_buff[idx];
279283
memory_manager->set_len(p, length);
280284

285+
#if defined(FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL) && FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL
286+
/* Add the cache invalidate maintain. */
287+
DCACHE_InvalidateByRange((uint32_t)bdPtr->buffer, g_handle.rxBuffSizeAlign[0]);
288+
#endif /* FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL */
289+
281290
/* Attempt to queue new buffer */
282-
temp_rxbuf = memory_manager->alloc_heap(ENET_ETH_MAX_FLEN, ENET_BUFF_ALIGNMENT);
291+
temp_rxbuf = memory_manager->alloc_heap(ENET_ALIGN(ENET_ETH_MAX_FLEN, ENET_BUFF_ALIGNMENT),
292+
ENET_BUFF_ALIGNMENT);
283293
if (NULL == temp_rxbuf) {
284294
/* Re-queue the same buffer */
285295
update_read_buffer(NULL);

targets/targets.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,6 +1917,7 @@
19171917
"SKIP_SYSCLK_INIT",
19181918
"FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE",
19191919
"SDRAM_IS_SHAREABLE",
1920+
"FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL=1",
19201921
"MBED_MPU_CUSTOM"
19211922
],
19221923
"inherits": ["Target"],

0 commit comments

Comments
 (0)