Constant at fixed address

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lopo_1264666
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted

I would like to define constant at fixed location for FX3 so that when I analyze the image file, I can read its value at this known address.

From FX3 TRM, system address from 0x40000000 to 0x4007FFFF.

Something like this:

#define ID "0013" @ 0x40004000

How to code this?

0 Likes
1 Solution
YatheeshD_36
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello,

You can initialize a section in the linker file (fx3.ld) in the FX3 SDK as below (path: <installation directory>\1.3\fw_build\fx3_fw), which is a part of the Data Section starting at 0x40030000.

fx3.ld:

pastedImage_0.png

Then define the variable in the created section

pastedImage_2.png

You can assign this variable any value.

It will be placed under the define section at the respective address:

map file:

pastedImage_1.png

Thanks,

Yatheesh

View solution in original post

0 Likes
7 Replies
YatheeshD_36
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello,

You can initialize a section in the linker file (fx3.ld) in the FX3 SDK as below (path: <installation directory>\1.3\fw_build\fx3_fw), which is a part of the Data Section starting at 0x40030000.

fx3.ld:

pastedImage_0.png

Then define the variable in the created section

pastedImage_2.png

You can assign this variable any value.

It will be placed under the define section at the respective address:

map file:

pastedImage_1.png

Thanks,

Yatheesh

0 Likes

Hi,

I modified the linker file and defined a variable in main.c file as

uint32_t __attribute__((section (".mySection"))) buff1 = 0xBB01;

When I checked .map file, I got this but buff1 is not there:

.mySectionBlock

0x40033000 0x0

0x40033000 . = ALIGN (0x4)

*(.mySection)

.data 0x40047000 0xdfc

0x40047000 _data = .

(.data)

.data.glI2cPageSize

0 Likes
lock attach
Attachments are accessible only for community members.

Hello,

Can you please use the attached linker file?

Thanks,

Yatheesh

0 Likes

Your linker file cannot be used for my project. BTW, my project has this memory definition in the linker file.

MEMORY

{

I-TCM : ORIGIN = 0x100 LENGTH = 0x3F00

SYS_MEM : ORIGIN = 0x40003000 LENGTH = 0x44000

DATA : ORIGIN = 0x40047000 LENGTH = 0x8000

}

I did try this but .map file is not OK.

.mySectionBlock 0x40048000 :

{

. = ALIGN(4);

KEEP(*(.mySection))

} > DATA

.mySectionBlock

0x40048000 0x0

0x40048000 . = ALIGN (0x4)

*(.mySection)

.data 0x40047000 0xdfc

0x40047000 _data = .

0 Likes

Hello,

Looks like the variable is not declared properly in the project. That might be the reason the variable is not reflected in the map file.

Please declare the variable in the main   .c  file as a global variable.

uint32_t __attribute__((section (".mySection"))) buff_1 = 0x11223344;

Thanks,

Yatheesh

0 Likes

Hi,

The problem is the same as before.

0 Likes

Hello,

Please share your project here.

Thanks,

Yatheesh

0 Likes