LWIP + ADC in baremetal stm32h735
Hello everyone,
I'm currently working on a project where I need to transmit ADC data over UDP to a server. I've previously had it working, but after re-generating code Hard-faults or Memory faults would start to appear.
CubeIDE : 1.19
Firmware: FW_H7 V1.12.1
void MemManage_Handler(void)
{
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
uint32_t *sp = (uint32_t *)__get_MSP();
uint32_t stacked_pc = sp[6];
}
While debugging sp would get the value:
Details:0x240000bc <memp_memory_RX_POOL_base+32>
Also I get a Hardfault:
0x240031bc <memp_memory_RX_POOL_base+12576>
I do cache invalidation on my main code to be able to update the data that will be sent through UDP.
while (1){
MX_LWIP_Process();
if (adc_full_ready) {
adc_full_ready = 0;
SCB_InvalidateDCache_by_Addr((uint32_t*)adc_data, adc_input_buffer_size * sizeof(uint16_t));
udpClient_send_adc(adc_data, adc_input_buffer_size);
} //I also have an if for half data, as the callback of the adc sets the adc_full_ready flag to 1
}
which of course led me to modify the flash registry and define the section of the pool buffer which I didn't in the past (But it was working before)
However it doesn't work and I really don't know what else to debug, especially since I haven't done bigger changes to the code, the length of the sample is of 1024 of uint16 and I declare it like this:
//in my .h
extern volatile uint16_t adc_data[adc_input_buffer_size];
//in my .c
ALIGN_32BYTES(volatile uint16_t adc_data[adc_input_buffer_size]);
.lwip_sec (NOLOAD) : {
. = ABSOLUTE(0x30000000);
*(.RxDecripSection)
. = ABSOLUTE(0x30000100);
*(.TxDecripSection)
/* . = ABSOLUTE(0x30000200);
*(.Rx_PoolSection) */ Now is commented because I was rolling back changes
} >RAM_D2Also on ethernetif.c
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
#pragma location = 0x30000200
extern u8_t memp_memory_RX_POOL_base[];
#elif defined ( __CC_ARM ) /* MDK ARM Compiler */
__attribute__((section(".Rx_PoolSection"))) extern u8_t memp_memory_RX_POOL_base[];
#elif defined ( __GNUC__ ) /* GNU */
__attribute__((section(".Rx_PoolSection"))) extern u8_t memp_memory_RX_POOL_base[];
#endif
My ethernet configuration:

My LWIP configuration:

Any leads or comments would be greatly appreciated, as I'm new to the stm32 and to memory management of microcontrollers.
I started this project reading this tutorial:
https://community.st.com/t5/stm32-mcus/how-to-create-a-project-for-stm32h7-with-ethernet-and-lwip-stack/ta-p/49308
Thanks for your help.
