7 Replies Latest reply on Nov 2, 2020 8:31 PM by YatheeshK_36

    Constant at fixed address

    lopo_1264666

      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?

        • 1. Re: Constant at fixed address
          YatheeshK_36

          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:

           

          Then define the variable in the created section

           

          You can assign this variable any value.

           

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

           

          map file:

           

          Thanks,

          Yatheesh

          • 2. Re: Constant at fixed address
            lopo_1264666

            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

            • 3. Re: Constant at fixed address
              YatheeshK_36

              Hello,

               

              Can you please use the attached linker file?

               

              Thanks,

              Yatheesh

              • 4. Re: Constant at fixed address
                lopo_1264666

                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 = .

                • 5. Re: Constant at fixed address
                  YatheeshK_36

                  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

                  • 6. Re: Constant at fixed address
                    lopo_1264666

                    Hi,

                     

                    The problem is the same as before.

                    • 7. Re: Constant at fixed address
                      YatheeshK_36

                      Hello,

                       

                      Please share your project here.

                       

                      Thanks,

                      Yatheesh