cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 LwiP using DTCM-SRAM. Is it possible?

Asantos
Senior

Hi,

I would like to use DTCM-RAM (0x20000000 to 0x2001FFFF) as system memory, and AXI-SRAM only for buffers. Is there a way to modify the ethernetif.c to have LwIP working in the DTCM-RAM?

5 REPLIES 5
TDK
Guru

There are a few ways to do this. One is to modify your linker file to put all RAM storage into DCTM. The other would be to specify on a per-variable basis where to put things with a attribute on a per-variable basis.

uint8_t buffer[1024] __attribute__ ((section ("in_dtcm")));

Then add a section to your linker to put data here.

Not sure if the ethernet DMA has access to DCTM, which may be an issue if you're using that section to store data.

If you feel a post has answered your question, please click "Accept as Solution".

>>Not sure if the ethernet DMA has access to DCTM, which may be an issue if you're using that section to store data.

Would definitely check the plumbing in the Bus Matrix diagram(s), the H7 is a lot more convoluted design, and memories have been purposefully separated to limit contention and coherency issues.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Asantos
Senior

The problem with the H7 is just that the DMA does not have access to DTCM. It is a big drawback. So you have to modify the liker script to put the system memory in the AXI-SRAM area. (0x24000000 to 0x2407FFFF).

I need a tip on how to modify ethernetif.c to copy ethernet packets to a buffer on AXI-SRAM, and keep the system memory in the DTCM-SRAM, as default for a Lwip project generated by the STM32CubeMX.

Piranha
Chief II

On H7 and Ethernet/lwIP with a HAL/Cube bloatware the buffers are not your problem. You can move them anywhere you want, but that non-working bloatware will not magically start working. Basically the ethernetif.c, stm32h7xx_hal_eth.c and other ST's monkey made code needs to be replaced.

https://community.st.com/s/question/0D50X0000C6eNNSSQ2/bug-fixes-stm32h7-ethernet

https://community.st.com/s/question/0D50X0000BOtfhnSQB/how-to-make-ethernet-and-lwip-working-on-stm32

alister
Lead

The ethernetif.c in https://community.st.com/s/question/0D50X0000C6eNNSSQ2/bug-fixes-stm32h7-ethernet shows how to move the lwIP heap and PBUF_RAM for tx buffers is allocated from there.