D
D
Denis2017-05-02 16:59:15
Electronics
Denis, 2017-05-02 16:59:15

How to properly use multiple memory sectors on a microcontroller?

Good day.
The question itself arose due to the fact that my program for the stm32f429ZITx microcontroller crashes into HardFault_Handler simply when adding a few additional variables, not from the start, but during work, when calling the emwin and freeRTOS functions.
With memory, this is the case:
Standard microcontroller RAM (address 0x20000000)
CCMRAM microcontroller memory (address 0x10000000)
AND SDRAM connected via FMC and located in the same address space with the rest of the memory that I use to control the display via LTDC. But the SDRAM is much larger than the display needs. (0xD0000000)
I went beyond the boundaries of the main memory a long time ago and ordered the linker to use CCMRAM.
Registered in the scatter file keil 5 like this

Setting up a scatter file

LR_IROM1 0x08000000 0x00200000 { ; load region size_region
ER_IROM1 0x08000000 0x00200000 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
}
RW_IRAM1 0x20000000 0x00030000 { ; RW data
.ANY (+RW +ZI)
}
RW_IRAM2 0x10000000 0x00010000 {
.ANY (+RW +ZI)
}
}

I think that the problem arises at the intersection of using the main RAM and CCMRAM.
For example, a heap/stack starts in RAM memory and ends in CCMRAM, and if the code increments a pointer (say emWin or freeRTOS), then the pointer may fall into an area that goes beyond the boundaries of ram memory. (Although if the memory is allocated in a row, functions such as malloc , then this can happen in the lungs.)
Tell me how to properly configure the memory in such situations?
PS I suspect that it will be necessary to manually prescribe where to place which variables and limit the stack to any one memory.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Hoksmur, 2017-08-15
@Hoksmur

I'm not familiar with kale, but I'll try to help.
*) The stack is definitely not worth doing in one memory. Especially if they are different types of memory. To say for sure, you need to carefully read the descriptions on the MK.
*) Segment code/data via attributes. For gcc, look at examples of how it is done, I think - there will be something close.
*) You can catch HardFault for other reasons as well. See the contents of the stack after the "trap" is triggered and what is above. It's not easy, but other paths either rely on experience or are even more time consuming.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question