2018-02-26 10:38 AM
I am porting our application from a STM32F779 to a STM32H753 device. Our application looks to run fin if we have the heap located on the DTCM_RAM (the whole 128k is reserved for heap allocation).
If the heap is moved to end of AXI-SRAM (last 128Kb) or SRAM1, our application performs wrong computation.
In all cases, data and bss section are on beginning of AXI-SRAM and stack on SRAM2.
Is there something special about DTCM_RAM that can explain this behavior?
-François
2018-02-26 11:06 AM
>>Is there something special about DTCM_RAM that can explain this behavior?
It is NOT cached, as it is single cycle anyway.
You can DMA into it without causing coherency issues, ie DMA buffers for ETHERNET/SDMMC
If you use other areas of RAM you need to use MMU to set shareability, cacheability and write through properties.
Or use functions to invalidate DCache on areas you have compromised.
2018-02-27 11:29 AM
,
,
Clive,
Thanks to take time to answer to my question. ,
Here couples others details:
(368k)
(368k)
SRAM1
AXI-SRAM (l
ast 128k) ,2018-02-27 11:49 AM
I don't know, try turning the question on its head, what are you doing with the allocated memory?
Do you have some kind of resource leak, or accessing beyond bounds issue? Anything returning a NULL that you aren't catching.
I tend to instrument malloc/free in situations where I use dynamic memory prolifically, it is a good way to see who's creating orphans or releasing the same memory twice. In a pinch I'll build code to walk the allocators linked list. Stack depth might also be something to watch/monitor, stack can dip into statics or locale.
Dynamic allocation in embedded tends to be highly problematic due to long up-time and the potential to leak or fragment.
2018-02-28 09:21 AM
The problem about wrong computation occurs in a FPU intensitive loop. The problem looks to disappear when I add printf in the middle of the loop (when heap is in SRAM2).
Having __DMB() and __DSB() at the same location than printf don't help.
2018-02-28 10:26 AM
printf/scanf are heavy stack users, if RTOS where is it allocating its thread stacks from, and how large.
Review system registers/context at the printf()
2018-03-01 01:14 PM
Are you enabling the clocks ? Maybe this will help.
__HAL_RCC_D2SRAM1_CLK_ENABLE();
__HAL_RCC_D2SRAM2_CLK_ENABLE(); __HAL_RCC_D2SRAM3_CLK_ENABLE();2018-03-02 06:03 AM
>>I do not have code to share as it is sensitive stuff.
I can imagine it is quite complex, but to advance some diagnosis and response.
You'd need to moving beyond 'not working' and pin down more precisely the point and mode of failure, and then share something that replicates that. This will be especially true if you think there is a bug in the silicon. This can be simplified and sanitized code that illustrates the issue quickly and cleanly.
So think of ways you can add sanity checking, and recognizing the failure as soon as possible.
I'd need to re-check the docs on SRAM2, there is one memory that appears in two address ranges.
You should perhaps engage an engineer from the local sales office to look at this and work with you.
2018-03-02 06:21 AM
Ibrahim, that was already done. By the way STM, such initilization must be done within STM32Cube H7. Or at least commented out.
Also, I added
*((__IO uint32_t*)0x51003108) = 0x00000001;
It is the same kind of workaround for SRAM1/2/3 than the workaround for AXI-SRAM regarding bug in silicon (see 2.2.15 from Errata sheet). That will set the switch matrix read capability to 1 for the SRAM1/2/3 (Target 2).
I did more extensive test about memories porganization and here my results
stackheaptest result
SRAM1AXI-SRAMOK
DTCM-RAMAXI-SRAMFail
SRAM4
AXI-SRAM
OKSRAM4
DTCM-RAM
OKSRAM1
DTCM-RAM
OKAXI-SRAM
DTCM-RAM
OKDTCM-RAM
SRAM2FailSRAM1SRAM2Fail
AXI-SRAMSRAM2Fail
SRAM4SRAM2OK
considering
My opinion it is there is another similar silicone bug to 2.2.15 in the STMH7 and/or the workaround is not fixing all the cases.
I do not have code to share as it is sensitive stuff.
2018-03-13 07:41 AM
I was having a similar issue when using SRAM1/2/3 for data, heap and stack my application wouldn't run. The fix was to enable the clocks really early in startup code:
Reset_Handler:
/* Enable SRAM clocks */ ldr r0,=0x580244dc ldr r3,[r0] orr r3, r3, ♯ 3758096384 /* 0xE0000000 */ str r3,[r0]ldr sp, =_estack /* set stack pointer */
......