printf not working when relocating stack to CCMRAM

Asked by Adrian Gin

I have a simple printf program which uses the RDImon specs and implements the fputc function.

printf and calls to a puts function result in a hardfault when the MSP is initialised to the CCMRAM. Code works fine when estack points to the main RAM location. For some reason there is an attempt in _puts_r to write to an invalid memory address of: 0x10010001 which results in the hard fault.

CCMRAM on the STM32F429 is enabled by default, and const strings are located in the rodata section in the flash.

printf( "Hello World!\n" );

/* Highest address of the user mode stack, choose either main RAM or CCM RAM */
_estack = 0x20030000; /* end of 192K RAM (using main RAM) */
//_estack = 0x10010000; /* use CCM RAM (64K) */

/* Specify the memory areas */
MEMORY
{
  FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
  RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K
  MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
  CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
  BKPSRAM (rw) : ORIGIN = 0x40024000, LENGTH = 4K
}

Any ideas appreciated.

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
Adrian Gin
Solved:
Last query:
Last reply:
Revision history for this message
Tejas Belagod (belagod-tejas) said :
#1
Revision history for this message
Adrian Gin (adrian-gin) said :
#2

Thanks Tejas,

The CCMRAM seems to be working fine. Stack variables are being pushed and popped from the highest CCMRAM location.

However the printf hard faults when the estack is set to the highest CCMRAM location.

Works fine when estack is set back to RAM.

 *(COMMON) section is placed in the BSS which is placed in RAM.

 .data.impure_data and .data._impure_ptr are placed in the DATA RAM section.

I've also done a Hex and Map compare and the only difference is the Stack pointer init value at the Base address 0x08000000.

One hardfaults at the first printf, the other doesn't. At this stage, all interrupts are disabled.

Revision history for this message
Adrian Gin (adrian-gin) said :
#3

I have found the issue:

An end symbol needs to be placed in the correct location for the sbrk function to work. Putting this symbol in the correct area, CCMRAM or RAM will fix this issue.

PROVIDE ( end = . );