This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

static link in object file

hi,
i would like to write a bootloader placed
in lower part of flash.

the bootloader uses some tcpnet functions
to upload from the network the application.

the application will be copied in higher
part of the flash and executed independently.

i want both the bootloader and the applcation
to use their local copies of tcpnet and not to share them.

how do i instruct the linker to place any
call to tcpnet in separate areas?

regards, marco.

  • You buuild as two separate targets - each target with it's own memory map, i.e. you don't let the two targets see the whole flash, but just a subset of the flash sectors.

  • if i understand correctly, you suggest to use two
    different targets, compile and link them separately.

    ok, good way. how do you suggest to do it?

    one way i can think of is to have two different projects bootloader.uv2 and application.uv2 each one containing the desired target and its memory space.

    however, i need to load into flash the bootloader.hex and application.hex separately.

    does anybody know any other method whcih uses a single project and hence a single .hex file?

    i have used the scatter file to place the *.o files in different ares of flash (see example), what i need to understand is how to add into the *.o files all the code coming from libraries without using a jump to the code of the library. i suppose that there is some #pragma instruction for the linker, but i cannot find it.

    
    
    ; *************************************************************
    ; *** user-generated Scatter-Loading Description File       ***
    ; *************************************************************
    
    LR_IROM1   0x00100000 0x00020000  { ; 128k flash, 32k ram
    
      ER_IROM1 0x00108000 0x000008000 { ; load application.o at 32k
       application.o (RESET, +First)
       * (+RO)
      }
    
      ER_IROM2 0x00100000 0x00008000 { ; load bootloader at 0k
       bootloader.o (RESET, +First)
       * (+RO)
      }
    
      RW_IRAM1 0x00200000 0x00008000  {  ; RW data: 32k
       * (+RW +ZI)
      }
    
    }
    
    
    
    
    
    /* ---------------------------------------------------------------- bootloader.[c, h] contains: - some code ...
    $Id: $ $Log: $ ---------------------------------------------------------------- */
    // this file uses tcpnet functions which, by means of // #pragma TOBEUNDERSTOOD, are places inside the bootloader.o // object file.
    #pragma TOBEUNDERSTOOD
    #include <RTL.h>
    U8 tcp_soc; U8 soc_state; BOOL wait_ack;
    void bootloader (void) { init_TcpNet (); tcp_soc = tcp_get_socket (TCP_TYPE_CLIENT, 0, 120, tcp_callback); soc_state = 0;
    // etc. etc.
    }
    /* ---- end of file ---- */

  • add a project target using the "components, environment and books" menu, "project target" tab. then you can add any files you need to a specific target.

  • If you build two targets, you will get two hex files.

    Easiest way is to open the hex file for the boot-loader and remove the last line. Then concatenate the application hex after the boot-loader hex.

    Now, you'll have a single hex file containing both the boot loader and the application.

    And since you used two separate targets (with non-intersecting memory blocks) your combined hex file will not contain any intersections. In short: You will know that the boot loader will not share any variables or functions with your application.

    People quite often try to do everything in a single build and just try to get the scatter file to move the boot loader part into one address range and the rest into another. But if you build as a single target, then the compiler will link in common code or variables - such as help code for division, stack overflow checking or similar.