Hi everybody. I'm using M52259DEMOIT and I'm creating a new MQX project. I have CW 7.2 and MQX3.6.
I need to place some variables in the section I create in the .lcf file. In my previous project, with no MQX environment, I did it, but now I'm getting some errors.
I create my section (named static_ram) after BSS in .lcf file (I copied the .lcf in my project folder):
MEMORY{## intflash (RX): ORIGIN = 0x00000000, LENGTH = 0x00080000## sram (RW): ORIGIN = 0x20000000, LENGTH = 0x00010000 vectorrom (RX): ORIGIN = 0x00000000, LENGTH = 0x00000400 cfmprotrom (RX): ORIGIN = 0x00000400, LENGTH = 0x00000020 rom (RX): ORIGIN = 0x00000420, LENGTH = 0x0007FBE0 # Code + Const data ram (RW): ORIGIN = 0x20000000, LENGTH = 0x00010000 # SRAM - RW data # kernel space starts after RAM variables (Location of MQX Kernel data + MQX heap) end_of_kd (RW): ORIGIN = 0x2000FFF0, LENGTH = 0x00000000 # Boot stack reused by MQX Kernel data bstack (RW): ORIGIN = 0x2000FA00, LENGTH = 0x00000200 # Boot stack end_bstack (RW): ORIGIN = 0x2000FBFF, LENGTH = 0x00000000}[...].main_application_bss : { __START_SBSS = .; *(.sbss) *(SCOMMON) __END_SBSS = .; __START_BSS = .; *(.bss) *(COMMON) __END_BSS = .; } >> ram.static_ram : { __START_MYRAM = .; main.c(.my_variables) __END_MYRAM = .; } >> ram[...]
and after making the project I check my .xmap file that contains the new section created:
[...]# .main_application_bss#>20000680 __START_SBSS (linker command file)#>20000680 __END_SBSS (linker command file)#>20000680 __START_BSS (linker command file) 20000680 00000004 .bss menu (main.c) 20000684 00000006 .bss rtc_time (main.c) 2000068C 00000004 .bss port_tc_file (main.c) 20000690 00000004 .bss _mqx_system_stack (mqx_regabi_d.a mqx.o ) 20000694 00000004 .bss driver_bundle (m52259demo_regabi_d.a adc_mcf522xx.o ) 20000698 00000004 .bss adc_channels_used (m52259demo_regabi_d.a adc_mcf522xx.o ) 2000069C 00000004 .bss old_isr_adc1_param (m52259demo_regabi_d.a adc_mcf522xx.o ) 200006A0 00000004 .bss old_isr_adc1 (m52259demo_regabi_d.a adc_mcf522xx.o ) 200006A4 00000004 .bss mcf522xx_adc_ptr (m52259demo_regabi_d.a adc_mcf522xx.o ) 200006A8 00000004 .bss old_isr_timer_param (m52259demo_regabi_d.a adt_pit_mcf522x) 200006AC 00000004 .bss old_isr_timer (m52259demo_regabi_d.a adt_pit_mcf522x) 200006B0 00000008 .bss adt_internal (m52259demo_regabi_d.a adt_pit_mcf522x) 200006B8 00000004 .bss mcf522xx_timer_ptr (m52259demo_regabi_d.a adt_pit_mcf522x) 200006BC 00000004 .bss first_irq (m52259demo_regabi_d.a io_gpio.o ) 200006C0 00000004 .bss mcf5225_eport_ptr (m52259demo_regabi_d.a io_gpio_mcf5225) 200006C4 00000004 .bss mcf5225_gpio_ptr (m52259demo_regabi_d.a io_gpio_mcf5225)#>200006C8 __END_BSS (linker command file)# .static_ram#>200006C8 __START_MYRAM (linker command file)#>200006C8 __END_MYRAM (linker command file)# .kernel_data#>200006D0 ___KERNEL_DATA_START (linker command file)[...]
Now in main.c I define my variable to be stored in that section but I'm in trouble with that. I tried both "__declspec(static_ram)" and "#pragma section static_ram". The first gives the error "Illeal type qualifier(s)" and the seconds gives no error but places my variable in standard bss section.
Where am I wrong?
Thanks in advance,
Marco
The documentation is scarce on this issue.
This is my solution.
#pragma define_section nvram ".nvram" far_absolute RW
#pragma section nvram begin
__declspec(nvram) f_rec ram_file[MAX_FILES];// MAX_FILES * f_rec size
__declspec(nvram) uint_16 ram_table_cs; //ram file table check sum
__declspec(nvram) uint_16 system_init; // system init flag
__declspec(nvram) uint_16 power_up; // power up flag
__declspec(nvram) rnd_flash_file_rec rnd_flash_file; //RND flash program file
__declspec(nvram) log_rec alarm_log[ALARM_LOG_SIZE],
slave_log[SLAVE_LOG_SIZE],
slave_alarm_log[SLAVE_ALARM_LOG_SIZE];
__declspec(nvram) uint_16 main_log_inptr, /* main log */
main_log_outptr,
main_log_ackptr,
num_events_in_main_log, /* 0..max_log_size */
alarm_log_inptr, /* alarm log */
alarm_log_outptr,
alarm_log_ackptr,
slave_log_inptr, /* slave log */
slave_log_outptr,
slave_log_ackptr,
slave_alarm_log_inptr, /* slave alarm log */
slave_alarm_log_outptr,
slave_alarm_log_ackptr;
#pragma section nvram end
Can you post your .lcf?
My lcf is a bit complicated because I am firmware upgrading certain sections and have to maintain an umoving base.
This is the same methodology you are using.
{
mram (RW): ORIGIN = 0x10000000, LENGTH = 0x00800000
## sram (RW): ORIGIN = 0x20000000, LENGTH = 0x00010000
vectorrom (RX): ORIGIN = 0x00000000, LENGTH = 0x00000400
cfmprotrom (RX): ORIGIN = 0x00000400, LENGTH = 0x00000020
rom (RX): ORIGIN = 0x00000420, LENGTH = 0x0002FBE0 # Code + Const data
flashx (RW): ORIGIN = 0x00030000, LENGTH = 0x00050000 # Internal flash
upgrade (RX): ORIGIN = 0x00070000, LENGTH = 0x00010000 # Code + Const data
all (RX)RIGIN = 0x00030000, LENGTH = 0x00050000 #upgradable section
ram (RW): ORIGIN = 0x20000000, LENGTH = 0x00010000 # SRAM - RW data
# kernel space starts after RAM variables (Location of MQX Kernel data + MQX heap)
end_of_kd (RW): ORIGIN = 0x2000FFF0, LENGTH = 0x00000000
# Boot stack reused by MQX Kernel data
bstack (RW): ORIGIN = 0x2000FA00, LENGTH = 0x00000200 # Boot stack
end_bstack (RW): ORIGIN = 0x2000FBFF, LENGTH = 0x00000000
}
KEEP_SECTION { .vectors_rom, .vectors_ram, .cfmconfig }
SECTIONS
{
___INTERNAL_SRAM_BASE = 0x20000000;
___INTERNAL_SRAM_SIZE = 0x00010000;
___INTERNAL_FLASH_BASE = 0x00030000;
___INTERNAL_FLASH_SIZE = 0x00050000;
# ___EXTERNAL_MRAM_BASE = 0x10000000;
# ___EXTERNAL_MRAM_SIZE = 0x00080000;
# ___EXTERNAL_MRAM_ROM_BASE = 0x10000000;
# ___EXTERNAL_MRAM_ROM_SIZE = 0x00060000;
# ___EXTERNAL_MRAM_RAM_BASE = 0x10060000;
# ___EXTERNAL_MRAM_RAM_SIZE = 0x00020000;
___IPSBAR = 0x40000000; # Peripherals/FlexCAN
___VECTOR_TABLE_START = 0x20000000; # Runtime vector table in sram
# MQX link time configurations
___DEFAULT_PROCESSOR_NUMBER = 1;
___DEFAULT_INTERRUPT_STACK_SIZE = 1024;
___KERNEL_DATA_VERIFY_ENABLE = 0; # Test SDRAM read/write
# Flashx configurations
___FLASHX_SECT_SIZE = 0x1000;
.vectors :
{
___VECTOR_TABLE_ROM_START = .; # Runtime vector table in sram
*(.vectors_rom)
. = ALIGN (0x4);
} > vectorrom
.cfmprotect :
{
*(.cfmconfig)
. = ALIGN (0x4);
} > cfmprotrom
.upgrade_application :
{
OBJECT (_get_rc_version, Access.c)
. = ALIGN (0x20);
OBJECT (_process_elevator_access, Access.c)
. = ALIGN (0x20);
OBJECT (_process_reader_data, Access.c)
. = ALIGN (0x20);
OBJECT (_process_mag_reader_data, Access.c)
. = ALIGN (0x20);
OBJECT (_get_ap_state_and_tz, Access.c)
. = ALIGN (0x20);
OBJECT (_set_ap_elevator_outputs, Access.c)
. = ALIGN (0x20);
OBJECT (_process_code_reader_link, Access.c)
. = ALIGN (0x20);
OBJECT (_verify_code, Access.c)
. = ALIGN (0x20);
OBJECT (_check_access_level, Access.c)
. = ALIGN (0x20);
OBJECT (_check_access_level2, Access.c)
. = ALIGN (0x20);
OBJECT (_valid_hi_sec_at_access_p, Access.c)
. = ALIGN (0x20);
OBJECT (_interlock_violation, Access.c)
. = ALIGN (0x20);
OBJECT (_interlock_check, Access.c)
. = ALIGN (0x20);
OBJECT (_update_user_area_usage, Access.c)
. = ALIGN (0x20);
OBJECT (_valid_lock_at_access_p, Access.c)
. = ALIGN (0x20);
Access.c(.text)
Access.c(.rodata)
} > upgrade
.non_volitile_ram :
{
__START_NVRAM = .;
*(.nvram)
__END_NVMRAM = . ;
_START_RAMDISK = .;
*(.ramdisk)
_END_RAMDISK = .;
} > mram
.main_application :
{
*(KERNEL)
*(S_BOOT)
*(IPSUM)
*(.init)
*(.fini)
*(.eini)
*(.ctors)
fp_coldfire.o(.text)
fp_coldfire.o(.rodata)
C_4i_CF_RegABI_MSL.a(.text)
C_4i_CF_RegABI_MSL.a(.rodata)
C_4i_CF_RegABI_Runtime.a(.text)
C_4i_CF_RegABI_Runtime.a(.rodata)
m52259unc_regabi.a(.text)
m52259unc_regabi.a(.rodata)
mqx_regabi.a(.text)
mqx_regabi.a(.rodata)
rtcs_regabi.a(.text)
rtcs_regabi.a(.rodata)
crc.c(.text)
crc.c(.rodata)
unc500_gpio5.c(.text)
unc500_gpio5.c(.rodata)
Flash_Upgrade_Task.c(.rodata)
Flash_Upgrade_Task.c(.text)
*(.dtors)
.= ALIGN(0x4);
*(.rdata)
*(.exception)
. = ALIGN(0x4);
__exception_table_start__ = .;
EXCEPTION
__exception_table_end__ = .;
___sinit__ = .;
STATICINIT
.= ALIGN(0x4);
__COPY_OF_DATA = .;
} > rom
.all_application :
{
ttl.c(.rodata)
ttl.c(.text)
ARC_H.C(.text)
ARC_L21.C(.text)
cgi_unc.c(.text)
COMCOM.C(.text)
httpdsrv_unc.c(.text)
LINK.C(.text)
loncoms.c(.text)
nc500.c(.text)
nc500_socket.c(.text)
NCLOG28.C(.text)
RAMFILE11.C(.text)
reader10.c(.text)
TEST.C(.text)
telnet.c(.text)
tfs_data.c(.text)
unc500a2d.c(.text)
init_capture.c(.text)
init_capture.c(.rodata)
capture.c(.text)
capture.c(.rodata)
*(.text)
*(.rodata)
} > all
.main_application_data : AT(__COPY_OF_DATA)
{
. = ALIGN(0x10000);
___VECTOR_TABLE_RAM_START = .; # Runtime vector table in sram
*(.vectors_ram)
. = ALIGN(512);
__BDT_BASE = .;
*(.usb_bdt)
__BDT_END = .;
. = ALIGN(0x4);
__START_SDATA = .;
*(.sdata)
__END_SDATA = .;
. = ALIGN(0x4);
__SDA_BASE = .;
__SDA_BASE_ = __SDA_BASE;
__START_DATA = .;
C_4i_CF_RegABI_MSL.a(.data)
C_4i_CF_RegABI_Runtime.a(.data)
m52259unc_regabi.a(.data)
mqx_regabi.a(.data)
rtcs_regabi.a(.data)
crc.c(.data)
unc500_gpio5.c(.data)
Flash_Upgrade_Task.c(.data)
*(.data)
__END_DATA = .;
. = ALIGN(0x04);
} > ram
# Locate the ROM copy table into ROM after the initialized data
_romp_at = __COPY_OF_DATA + SIZEOF(.main_application_data);
.romp : AT (_romp_at)
{
__S_romp = _romp_at;
WRITEW(__COPY_OF_DATA); #ROM start address
WRITEW(ADDR(.main_application_data)); #RAM start address
WRITEW(SIZEOF(.main_application_data)); #size
WRITEW(0);
WRITEW(0);
WRITEW(0);
}
_flashx_start = ___INTERNAL_FLASH_BASE;
# flashx working area spans across the whole rest of Flash memory
___FLASHX_START_ADDR = ___INTERNAL_FLASH_BASE;
___FLASHX_END_ADDR = ___INTERNAL_FLASH_BASE + ___INTERNAL_FLASH_SIZE;
.main_application_bss :
{
__START_SBSS = .;
*(.sbss)
*(SCOMMON)
__END_SBSS = .;
__START_BSS = .;
C_4i_CF_RegABI_MSL.a(.bss)
C_4i_CF_RegABI_Runtime.a(.bss)
m52259unc_regabi.a(.bss)
mqx_regabi.a(.bss)
rtcs_regabi.a(.bss)
crc.c(.bss)
unc500_gpio5.c(.bss)
Flash_Upgrade_Task.c(.bss)
*(.bss)
*(COMMON)
__END_BSS = .;
} >> ram
.kernel_data : #AT(ADDR(.main_application_bss) + SIZEOF(.main_application_bss))
{
___KERNEL_DATA_START = ALIGN(0x10);
}
.end_of_kernel_data :
{
___KERNEL_DATA_END = .;
} > end_of_kd
.boot_stack :
{
_stack_end = .;
} > bstack
.end_of_boot_stack :
{
_stack_addr = .;
__SP_INIT = .;
___BOOT_STACK_ADDRESS = .;
} > end_bstack
}