Good morning
I have an ugly issue with the compiler.
I want to define the configuration words in the source code. That's what I do
static __attribute__ ((section (".FlashConfig"))) const cfm_t _cfm =
{
.backkey[ 0 ] = 0x01,
.backkey[ 1 ] = 0x02,
.backkey[ 2 ] = 0x03,
......
The fields are expanded..
If in the startup file .s I use the original declaration
.section .FlashConfig, "a"
.long 0xFFFFFFFF
.long 0xFFFFFFFF
.long 0xFFFFFFFF
.long 0xFFFF7DFE
The linking process advices the FlashConfig section is too small to guest both data .That's what I expect.
Bit if I comment the assembly declaration, the C declared data _cfm disappears. Simply it does not exist in the map file.
I don't find a reason why.
Suggestions??
Thank You
Pietro
Solved! Go to Solution.
Hi Pietro
For GCC:
const KINETIS_FLASH_CONFIGURATION __attribute__((section(".f_config"))) __flash_config
= {
KINETIS_FLASH_CONFIGURATION_BACKDOOR_KEY,
KINETIS_FLASH_CONFIGURATION_PROGRAM_PROTECTION,
KINETIS_FLASH_CONFIGURATION_SECURITY,
KINETIS_FLASH_CONFIGURATION_NONVOL_OPTION,
KINETIS_FLASH_CONFIGURATION_EEPROM_PROT,
KINETIS_FLASH_CONFIGURATION_DATAFLASH_PROT
};
In linker script
.f_config ALIGN(__Fconfig_segment_start__ , 4) :
{
__flash_config = .;
KEEP(*(.f_config .f_config.*))
}
You NEED the KEEP so that the linker doesn't optimise the data away since it doesn't find it being accessed by any code.
Regards
Mark
uTasker developer and supporter (+5'000 hours experience on +60 Kinetis derivatives in +80 product developments)
Kinetis: http://www.utasker.com/kinetis.html
Hei Mark
The implementation gives the result to have the structure in the map file.
Like this
.FlashConfig 0x00000400 0x10
0x00000400 . = ALIGN (0x4)
0x00000400 _cfm = .
*(.FlashConfig .FlashConfig.*)
.FlashConfig 0x00000400 0x10 ./Sources/chip_cfg.o
0x00000410 . = ALIGN (0x4)
But when I try to program the memory dump of the address 0x400 is not reflecting the content of the _cfm..
What can it be?
Thank You
Pietro
Hi Pietro
If you see the sector in the map file I would expect it to be in your binary too.
Look at the binary file (or srec) content with a binary editor - maybe it is there but being filled with unexpected data - such as 0xff (?).
Regards
Mark
uTasker developer and supporter (+5'000 hours experience on +60 Kinetis derivatives in +80 product developments)
Kinetis: http://www.utasker.com/kinetis.html
Hei Mark
Thank You for following. Now I have the data in the flash. I have another problem in the bit field interpretation.
But for now I can live with what I have, I need to concentrate on another issue.
I created another thread, Flash writes with breakpoints NOT without. If You can give a look it would be helpful.
Thank You
Pietro
Hello Pietro
These may help with some field interpretations.
typedef struct _PACK stKINETIS_FLASH_CONFIGURATION // loaded from FLASH 0x00000400 at reset
{
unsigned char ucBackdoorComparisonKey[8];
unsigned long ulProgramFlashProtection;
unsigned char ucFlashSecurity;
unsigned char ucNonvolatileOption;
unsigned char ucEEPROM_protection;
unsigned char ucDataFlashProtection;
} KINETIS_FLASH_CONFIGURATION;
const KINETIS_FLASH_CONFIGURATION __attribute__((section(".f_config"))) __flash_config
= {
{BACKDOOR_KEY_0, BACKDOOR_KEY_1, BACKDOOR_KEY_2, BACKDOOR_KEY_3, BACKDOOR_KEY_4, BACKDOOR_KEY_5, BACKDOOR_KEY_6, BACKDOOR_KEY_7},
(0xffffffff), // PROT[31:24]:PROT[23:16]:PROT[15:8]:PROT[7:0] - no protection when all are '1'
KINETIS_FLASH_CONFIGURATION_SECURITY,
KINETIS_FLASH_CONFIGURATION_NONVOL_OPTION,
KINETIS_FLASH_CONFIGURATION_EEPROM_PROT,
KINETIS_FLASH_CONFIGURATION_DATAFLASH_PROT
};
Regards
Mark
uTasker developer and supporter (+5'000 hours experience on +60 Kinetis derivatives in +80 product developments)
Kinetis: http://www.utasker.com/kinetis.html
Thank You
I will enjoy this suggestion when the bootloader will work. Now the crashing of the flash writing is booking me fully.
Thank You
Pietro
Hi Pietro
For GCC:
const KINETIS_FLASH_CONFIGURATION __attribute__((section(".f_config"))) __flash_config
= {
KINETIS_FLASH_CONFIGURATION_BACKDOOR_KEY,
KINETIS_FLASH_CONFIGURATION_PROGRAM_PROTECTION,
KINETIS_FLASH_CONFIGURATION_SECURITY,
KINETIS_FLASH_CONFIGURATION_NONVOL_OPTION,
KINETIS_FLASH_CONFIGURATION_EEPROM_PROT,
KINETIS_FLASH_CONFIGURATION_DATAFLASH_PROT
};
In linker script
.f_config ALIGN(__Fconfig_segment_start__ , 4) :
{
__flash_config = .;
KEEP(*(.f_config .f_config.*))
}
You NEED the KEEP so that the linker doesn't optimise the data away since it doesn't find it being accessed by any code.
Regards
Mark
uTasker developer and supporter (+5'000 hours experience on +60 Kinetis derivatives in +80 product developments)
Kinetis: http://www.utasker.com/kinetis.html