I'm writing an embedded program, divided in two parts: bootloader and app. (I'm using STM32, eclipse) I'm usign a display, so I wrote some function and 3 different fonts. The idea is to use a sector of the microcontroller and share it. The font area is defined with Ld script like
.mySegment start_of_FONT_segm : {KEEP(*(.Courier_New_Bold_20_Section))}
.mySegment1 0x8011298 : {KEEP(*(.Terminal6x8_Section))}
and use an array to write in
const unsigned char __attribute__((section (".Terminal6x8_Section"))) Terminal6x8[] = {
0x00,
0x00,
...
But how to read it from another program (in this case, the Aplication?) I tried with
unsigned char *Terminal6x8 = (volatile unsigned char*)0x08011298;
but the compiler put the 'Terminal6x8' into RAM. I'll be glad to share some functions also, but don't know how to declare in ld and C sintax too.
Any suggestions?
CodePudding user response:
Indeed the pointer *Terminal6x8 is put into RAM. If you want the pointer stored in flash, declare it const.
Although, the data pointed to by *Terminal6x8 is stored in flash at address 0x08011298 as you want. No matter where the pointer is stored.
CodePudding user response:
unsigned char *Terminal6x8 = (volatile unsigned char*)0x08011298;
Is bad in many means.
- Uses fixed address which is not very good
- Declares the data as
volatile
which makes no sense in this context - Data is not declared as constant.
If you want to pointer to be also placed in the FLASH memory
const unsigned char * const Terminal6x8 = (const unsigned char * const) 0x08011298;
I'll be glad to share some functions also
How to do it properly?
You need to declare a vector table (pointer table) containing the pointers to data and functions you want to share.