mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 21:36:28 +08:00
arch/xtensa/src/esp32/esp32_spi&spiflash: Free the correct buffer.
Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
This commit is contained in:
committed by
Alan Carvalho de Assis
parent
0182e6e8bb
commit
5ac5655fa4
@@ -870,14 +870,20 @@ static void esp32_spi_dma_exchange(FAR struct esp32_spi_priv_s *priv,
|
|||||||
uint8_t *rp;
|
uint8_t *rp;
|
||||||
uint32_t n;
|
uint32_t n;
|
||||||
uint32_t regval;
|
uint32_t regval;
|
||||||
|
#ifdef CONFIG_XTENSA_USE_SEPERATE_IMEM
|
||||||
|
uint8_t *alloctp;
|
||||||
|
uint8_t *allocrp;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* If the buffer comes from PSRAM, allocate a new one from DRAM */
|
/* If the buffer comes from PSRAM, allocate a new one from DRAM */
|
||||||
|
|
||||||
#ifdef CONFIG_XTENSA_USE_SEPERATE_IMEM
|
#ifdef CONFIG_XTENSA_USE_SEPERATE_IMEM
|
||||||
if (esp32_ptr_extram(txbuffer))
|
if (esp32_ptr_extram(txbuffer))
|
||||||
{
|
{
|
||||||
tp = up_imm_malloc(bytes);
|
alloctp = up_imm_malloc(bytes);
|
||||||
DEBUGASSERT(tp != NULL);
|
DEBUGASSERT(alloctp != NULL);
|
||||||
|
memcpy(alloctp, txbuffer, bytes);
|
||||||
|
tp = alloctp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -888,8 +894,9 @@ static void esp32_spi_dma_exchange(FAR struct esp32_spi_priv_s *priv,
|
|||||||
#ifdef CONFIG_XTENSA_USE_SEPERATE_IMEM
|
#ifdef CONFIG_XTENSA_USE_SEPERATE_IMEM
|
||||||
if (esp32_ptr_extram(rxbuffer))
|
if (esp32_ptr_extram(rxbuffer))
|
||||||
{
|
{
|
||||||
rp = up_imm_malloc(bytes);
|
allocrp = up_imm_malloc(bytes);
|
||||||
DEBUGASSERT(rp != NULL);
|
DEBUGASSERT(allocrp != NULL);
|
||||||
|
rp = allocrp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -959,15 +966,15 @@ static void esp32_spi_dma_exchange(FAR struct esp32_spi_priv_s *priv,
|
|||||||
#ifdef CONFIG_XTENSA_USE_SEPERATE_IMEM
|
#ifdef CONFIG_XTENSA_USE_SEPERATE_IMEM
|
||||||
if (esp32_ptr_extram(rxbuffer))
|
if (esp32_ptr_extram(rxbuffer))
|
||||||
{
|
{
|
||||||
memcpy(rxbuffer, rp, bytes);
|
memcpy(rxbuffer, allocrp, bytes);
|
||||||
up_imm_free(rp);
|
up_imm_free(allocrp);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_XTENSA_USE_SEPERATE_IMEM
|
#ifdef CONFIG_XTENSA_USE_SEPERATE_IMEM
|
||||||
if (esp32_ptr_extram(txbuffer))
|
if (esp32_ptr_extram(txbuffer))
|
||||||
{
|
{
|
||||||
up_imm_free(tp);
|
up_imm_free(alloctp);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1178,6 +1178,8 @@ static ssize_t esp32_write(FAR struct mtd_dev_s *dev, off_t offset,
|
|||||||
{
|
{
|
||||||
return (ssize_t)-ENOMEM;
|
return (ssize_t)-ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memcpy(tmpbuff, buffer, nbytes);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user