- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am trying to (statically) allocate a buffer in the upper SRAM block (0x20000000) in order to bring down SRAM contention between the CPU and DMA.
(I have a DMA channel that continuously pumps pixels from a line buffer in SRAM to a Control Register to display them on screen [VGA]).
I want to know how to tell the compiler (actually the linker I guess) at what address this buffer should be located.
In order to avoid overruns of any kind, I want to move the stack and heap to the top of the lower SRAM block.
That way it is all neat and tidy: CPU uses lower SRAM, DMA uses upper SRAM.
This tutorial (that is my inspiration) uses a custom section (.ram2) No bitbanging necessary, or How to Drive a VGA Monitor on a PSoC 5LP w/Verilog - Page 1
Custom Linker option:
-Wl,--section-start=.ram2=0x20000000
uint8 lineBuffer[VGA_X_BYTES] __attribute__ ((aligned(),section(".ram2")));
Problem is that does not compile/link... 😞
Failed to generate [ProjectPath\ProjectName].hex: Flash address outside hex file range
It also does nothing to avoid stack/heap collisions...
[PSoC 5LP - kit]
[PSoC Creater 4.2]
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi ,
If an uninitialized variable uses __attribute__ with section, the variable is treated like an initialized variable. This causes these variables to not end up in the .bss but instead in the data which goes in the flash.
You can check this AN to understand the structure of Linker scripts page#25, section "Modify the linker script file" :
For example if you initialize like this in your code:
Then
You can do the following in the linker script
Solution:
.MB_section 0x20000100 (NOLOAD) :
{
. = ALIGN(4);
} >ram
You can use the NOLOAD type on the section to specify that this section is not supposed to be loaded. Note that this will only reserve that space in the RAM. If the variables need to be initialized that can be done in the main().
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi ,
If an uninitialized variable uses __attribute__ with section, the variable is treated like an initialized variable. This causes these variables to not end up in the .bss but instead in the data which goes in the flash.
You can check this AN to understand the structure of Linker scripts page#25, section "Modify the linker script file" :
For example if you initialize like this in your code:
Then
You can do the following in the linker script
Solution:
.MB_section 0x20000100 (NOLOAD) :
{
. = ALIGN(4);
} >ram
You can use the NOLOAD type on the section to specify that this section is not supposed to be loaded. Note that this will only reserve that space in the RAM. If the variables need to be initialized that can be done in the main().
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I sort of understand what this does - I never took the time to understand linker scripts.
My initial test with just adding the memory section did compile, but did not put the lineBuffer at the correct address. (range).
I can see in my .map file it is now correct after making your suggested adjustments.
.ramhi 0x20000000 0x50
0x20000000 . = ALIGN (0x4)
.ramhi 0x20000000 0x50 .\CortexM3\ARM_GCC_541\Debug\main.o
0x20000000 lineBuffer
Awesome.
Thanks!