fix(esp32-qemu-openeth): allocate buffers in internal memory

When the PSRAM is enabled, we should not allocate the TX/RX
buffers there, so we use kmm_calloc here, to make it into IRAM,
so the ethernet controller can read bytes from it.
This commit is contained in:
Marco Casaroli 2024-07-01 14:25:22 +00:00 committed by Xiang Xiao
parent b08d219849
commit f5de966471

View File

@ -38,6 +38,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include <nuttx/irq.h> #include <nuttx/irq.h>
#include <nuttx/kmalloc.h>
#include <nuttx/wqueue.h> #include <nuttx/wqueue.h>
#include <nuttx/net/netconfig.h> #include <nuttx/net/netconfig.h>
#include <nuttx/net/ip.h> #include <nuttx/net/ip.h>
@ -791,7 +792,7 @@ int esp32_openeth_initialize(void)
for (int i = 0; i < RX_BUF_COUNT; i++) for (int i = 0; i < RX_BUF_COUNT; i++)
{ {
priv->rx_buf[i] = calloc(1, DMA_BUF_SIZE); priv->rx_buf[i] = kmm_calloc(1, DMA_BUF_SIZE);
if (!(priv->rx_buf[i])) if (!(priv->rx_buf[i]))
{ {
nerr("ERROR: Failed allocate RX descriptors\n"); nerr("ERROR: Failed allocate RX descriptors\n");
@ -807,7 +808,7 @@ int esp32_openeth_initialize(void)
for (int i = 0; i < TX_BUF_COUNT; i++) for (int i = 0; i < TX_BUF_COUNT; i++)
{ {
priv->tx_buf[i] = calloc(1, DMA_BUF_SIZE); priv->tx_buf[i] = kmm_calloc(1, DMA_BUF_SIZE);
if (!(priv->tx_buf[i])) if (!(priv->tx_buf[i]))
{ {
nerr("ERROR: Failed allocate TX descriptors\n"); nerr("ERROR: Failed allocate TX descriptors\n");