cancel
Showing results for 
Search instead for 
Did you mean: 

Can I store a 4 Bytes of const object into end of flash memory region (for example address 0x17f80).

JBand.1
Associate II

Based on Cosmic compiler document, I am trying to use #pragma to store the const object into flash memory region 0x17f80.

Even I have configured the liker config,

0693W000001cEXsQAM.jpg

Then I have added below code in .c file.

#pragma section const {applflag}

const u32 appl_flag = 0xAA55AA55;

#pragma section const {}

But, I cannot see the value 0xAA55AA55 in the address.

Please find the linker file commands below for your reference.

# Segment ApplFlag:

+seg .applflag -b 0x17f80 -m 0x80 -n .applflag

Please correct me if I did any mistake.

3 REPLIES 3
Philipp Krause
Senior II

On SDCC, this small test program works for me:

#include <stdint.h>

void main(void)

{

}

const uint32_t __at(0xfff0) test = 0x55aa55aa;

AFAIR Cosmic has something similar to SDCC __at.

JBand.1
Associate II

s

Hi Philipp,

Thank you for the information.

If I use "const uint32_t __at(0xfff0) test = 0x55aa55aa", the programm is not compiling at all. By the way, I cannot see any such instruction like "__at()" in cosmic cross compiler document (The document is, "C Cross Compiler User’s Guide for ST Microelectronics STM8" version 4.4).

Here are the details of my dev environment I am using.

Dev tool: STVD development tool

Compiler tool: Cosmic tools

Now, I am following the below method.

From the same document, I have seen a linker section option that can fill a word into memory section and the option is,

0693W000001cOUVQA2.jpg

But, still there a problem in using this. This linker option fills with the value till the end of memory. In this case, from 0x17ffc to 0x17fff with the value 0x55AA55AA.

I need to store in the mid of flash memory using #pragma.