Locating the variable to particular segment of RAM

cancel
Showing results for 
Search instead for 
Did you mean: 

Locating the variable to particular segment of RAM

770 Views
Contributor III

Hi,

I am facing some problems in locating the variable to particular segment of RAM.

Application code is

__attribute__((section(".bl_std_faiRecdata_RAM"))) StdFailurRecord_t gStdFailureRecord;

__attribute__((section(".bl_std_faiRecdata_RAM"))) int abc;

__attribute__((section(".bl_std_faiRecdata_RAM"))) int *ptr;

as per the linker file , the above variable's has to locate to the " .bl_std_faiRecdata_RAM " section".

variables are mapped to the particular section address in map file, but variables are located to the m_data2 segment (while debugging).

please find the attached ld file and map file snap shot.

kindly help me in this.

Regards,

Ambarish

12 Replies

4 Views
Contributor III

Hi,

Thank you Stan and Jiri for your reply.

I found the problem , if I run the project with debug build configuration, then it is mapped to the  "bl_std_faiRecdata_RAM"  segment.

if I run the project with debug_RAM  build configuration, then it is mapped to the  some other segment(taking the other linker file as input linker file for the project i.e ram.ld file).

but  if I run project as debug configuration, it is not yet all jump to main, it is goes to default ISR(in console it is showing

Initializing.

Target has been RESET and is active.

Interrupt command received. Halting execution."

/* Init .data and .bss sections */

ldr r0,=init_data_bss

blx r0

cpsie i /* Unmask interrupts */

bl main

here is the code of startup code, I have put the break point at the blx ro,  it will directly jump to default isr.

it is not yet all come to main.

kindly help me in this.

Regards,

Ambarish

0 Kudos

4 Views
NXP Employee
NXP Employee

Hi,

can you please share map file? In your linker file is missing .text section where executable code is normally stored. I'm not sure if you also modified auto generated startup.c (Project_root->SDK->Platform->Devices). If the init_data_bss() function in startup.c  is not moved to custom code section - it is possible that from assembly (startup_S32K144.S) is the init_data_bss function address unknown. You can also check the r0 value before blx r0  instruction in startup_S32K144.S. 

Jiri

0 Kudos

4 Views
Contributor III

Hi,

PFA of mapfile. text in the linker file is changed to   m_blc_code_area.

Regards,

Ambarish

0 Kudos

4 Views
NXP Employee
NXP Employee

Hi, 

there is no .text section defined - and you probably didn't move to custom section all functions (including functions from generated code). On debug console there should be some warning - something like missing .text section . 

Easy fix is add .text section into your blc_code_area like this: 

.blc_code_area :
{
. = ALIGN(4);
*(.blc_code_area) /* .text sections (code) */
*(.blc_code_area*) /* .text* sections (code) */

*(.text) 
*(.text*)
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} > m_blc_code_area

Otherwise you need to add front of all functions (including bss_data_init)

__atribute__((section("blc_code_area"))) ...

Jiri

0 Kudos

4 Views
Contributor III

Hi,

I have tried with the above changes, still same problem facing.

0 Kudos

4 Views
NXP Employee
NXP Employee

Um - can you check the r0 value one step after ldr r0,=init_data_bss instruction? You can see the value in debug perspective and Registers tab.

Jiri

0 Kudos

4 Views
Contributor III

Hi,

the value of ro is 1245(decimal) before ldr r0,=init_data_bss instruction, after this instruction execution,r0 is 1289(decimal).

it directly jumps to default isr.

Regards,

Ambarish

0 Kudos

4 Views
NXP Employee
NXP Employee

Can you please share your project (you can send it directly jiri.kral@nxp.com) or at least your elf file? Without more info I can't find out what's wrong. 

Basically - the next step  (blx r0) is jump into init_data_bss function implemented in startup.c file. If the address 1289 (0x0509) is not address of init_data_bss function - program ends in exception (the jump to self loop). 

Jiri

0 Kudos

4 Views
Contributor III

Hi,

thank you for your support and time.

I found the problem in the linker file.

its working fine.

Regards,

Ambarish B H

4 Views
NXP Employee
NXP Employee

Hi Ambarish, 

Good to hear - I find out that program ends in exception on address 0x0548 on 

str.w   r2, [r1,r3 lsl #2]

where

r2=0x20007000 - beginning of stack

r1=0x1128 - this address is unallocated - beginning of unoccupied m_blc_code_area section. 

r3=0x0000

So - there was probably missing another section in linker file. 

Jiri

0 Kudos

4 Views
NXP Employee
NXP Employee

Hi,

according to the screenshot and .ld file - the variables seems to be placed correctly.

Could you please post here the debugger screenshot (e.g. including disassembly) when accessing one of these variables to show it is located in m_data_2 memory block.

Stan

0 Kudos

4 Views
NXP Employee
NXP Employee

Hi Ambarish,

is your project build as a Flash target? 

Jiri

0 Kudos