This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/TMS320F28027: Force Linker to add library

Part Number: TMS320F28027
Other Parts Discussed in Thread: MOTORWARE

Tool/software: TI C/C++ Compiler

I am working on a project that uses the FAST_Public library and we are basically out of flash in sections B,C, and D.  I have a bootloader in section A and have quite a bit of space left.  What I would like to do is take the fast_public.lib move it from my application in sections B,C, and D put it in section A.  I have added the library to my bootloader project but it will not link the library in.  Granted it isn't using this library, I just want to add it in so I can snag it from my application.  So I come to the questions, how can this be done?  Can this be done?  

  • I don't fully understand your problem.  But I can shed some light, and make one suggestion that may help.

    The linker brings in an object file from a library only when the main application code calls a function (or, less commonly, uses a data variable) which is defined in that object file.  If no functions in a library are called, nothing in the library is used.  You can force the linker to bring in an object file from a library by use of the option --undef_sym=name_of_function.  Read more about it in the C28x assembly tools manual.

    Thanks and regards,

    -George

  • This suggestion may help, but maybe I wasn't too clear in my description. I have the TI fast_public.lib motor control library that I would like to place in a different sector of flash (the sector that contains my bootloader). This would free enough space that I can continue the project without having to switch chips. The issue is when I add the library to my bootloader project it doesn't actually link the library since I am not using any of the functions in the library. In GCC I could use the --whole-archive flag and it would link the whole library in without my project ever using it. Thats what I am looking for. Is there an option I can use similar to that?

  • Hayden Waddle81 said:
    In GCC I could use the --whole-archive flag and it would link the whole library in

    Unfortunately, the TI linker has no option similar to that.  I know of hack way to do something similar.  It involves using the names utility to auto-generate a linker command file that would have the same effect.  Are you interested?

    Thanks and regards,

    -George

  • Absolutely interested. Whatever info you can give me will help out.
  • The idea is to use the names utility nm2000 to get a list of the global symbols in the library.  Then, with some text processing, turn it into a command file the linker can use.  Read about nm2000 in the C28x assembly tools manual.

    When you run the names utility to see the global symbols, it looks like ...

    % nm2000 -g some.lib
    ARCHIVE:  some.lib
    00000000 U _only_called
    00000000 T _implemented_in_some_lib
    ...
    

    You are only interested in the symbols that are implemented (you might say defined) in the library.  One way to filter for that ...

    % nm2000 -g some.lib | grep ' T '
    00000000 T _implemented_in_some_lib
    00000000 T _another_function
    ...

    Then to turn that into the what the linker needs ...

    % nm2000 -g some.lib | grep ' T ' | perl -ape '"--undef_sym=$F[2]"'
    --undef_sym=_implemented_in_some_lib
    --undef_sym=_another_function
    ...
    

    Capture that in a file ...

    % nm2000 -g some.lib | grep ' T ' | perl -ape '"--undef_sym=$F[2]"' > usyms.cmd

    Add usyms.cmd as another file in the linker invocation.

    The commands grep and perl come from the Unix world.  To explain them here would make this post much longer.  So, I'll let you look those up.  There is probably a way to do the same thing with Windows command line utilities.  But I don't know it.

    Thanks and regards,

    -George

  • I tried this hack but I still get a lot of errors based on the undefined symbols from the library. Any ideas?

  • I need more context.  What is being linked?  The boot loader, or the main application code?  These undefined symbols, where is the definition located?  Is it in a library that is part of the link?

    Thanks and regards,

    -George

  • To advance the issue, please answer the questions in my previous post.

    Thanks and regards,

    -George

  • Sorry George.  I had another project I had to work on before I could get back to this issue.  So I have moved the library over to the Bootloader and have attempted to compile with the new Linker file.  Which looks like this :

    --undef_sym=_CTRL_getGains
    --undef_sym=_CTRL_getIab_filt_pu
    --undef_sym=_CTRL_getIab_in_pu
    --undef_sym=_CTRL_getIdq_in_pu
    --undef_sym=_CTRL_getIdq_ref_pu
    --undef_sym=_CTRL_getMagCurrent_pu
    --undef_sym=_CTRL_getMaximumSpeed_pu
    --undef_sym=_CTRL_getVab_in_pu
    --undef_sym=_CTRL_getVab_out_pu
    --undef_sym=_CTRL_getVdq_out_pu
    --undef_sym=_CTRL_getWaitTimes
    --undef_sym=_CTRL_run
    --undef_sym=_CTRL_setGains
    --undef_sym=_CTRL_setMagCurrent_pu
    --undef_sym=_CTRL_setMaximumSpeed_pu
    --undef_sym=_CTRL_setParams
    --undef_sym=_CTRL_setSpd_ref_krpm
    --undef_sym=_CTRL_setSpd_ref_pu
    --undef_sym=_CTRL_setWaitTimes
    --undef_sym=_CTRL_setup
    --undef_sym=_CTRL_setupClarke_I
    --undef_sym=_CTRL_setupClarke_V
    --undef_sym=_CTRL_updateState
    --undef_sym=_CTRL_getVersion
    --undef_sym=_CTRL_runTraj
    --undef_sym=_CTRL_setEstParams
    --undef_sym=_CTRL_setUserMotorParams
    --undef_sym=_CTRL_setupCtrl
    --undef_sym=_CTRL_setupEstIdleState
    --undef_sym=_CTRL_setupEstOnLineState
    --undef_sym=_CTRL_setupTraj

    Once I compiled I was met with these errors :

    error #10099-D: program will not fit into available memory. load placement with alignment/blocking fails for section "ramfuncs" size 0x2b page 0. Available memory ranges:
    FLASHA size: 0xfbc unused: 0x5 max hole: 0x4
    "../Bootloader.cmd", line 128: error #10099-D: program will not fit into available memory. placement with alignment/blocking fails for section "Fast_Public_Lib" size 0x15ff page 0. Available memory ranges:
    FASTLIB size: 0xfbc unused: 0xfbc max hole: 0xfbc
    "../Bootloader.cmd", line 136: error #10099-D: program will not fit into available memory. placement with alignment/blocking fails for section ".cinit" size 0x31 page 0. Available memory ranges:
    FLASHA size: 0xfbc unused: 0x5 max hole: 0x4

    Plus I have a lot of undefined symbols (those that were referenced outside of the library).  Any ideas?

  • Hayden Waddle81 said:
    error #10099-D: program will not fit into available memory. load placement with alignment/blocking fails for section "ramfuncs" size 0x2b page 0. Available memory ranges:
    FLASHA size: 0xfbc unused: 0x5 max hole: 0x4
    "../Bootloader.cmd", line 128: error #10099-D: program will not fit into available memory. placement with alignment/blocking fails for section "Fast_Public_Lib" size 0x15ff page 0. Available memory ranges:
    FASTLIB size: 0xfbc unused: 0xfbc max hole: 0xfbc
    "../Bootloader.cmd", line 136: error #10099-D: program will not fit into available memory. placement with alignment/blocking fails for section ".cinit" size 0x31 page 0. Available memory ranges:
    FLASHA size: 0xfbc unused: 0x5 max hole: 0x4

    Your program needs more memory than you have.  More on this diagnostic is available in this article.

    Hayden Waddle81 said:
    Plus I have a lot of undefined symbols (those that were referenced outside of the library).  Any ideas?

    I presume these symbols correspond to functions, and not data.  What library, or object files, supplies the code for these functions?

    Thanks and regards,

    -George

  • Understand thats what the errors correspond too but I don't know why.  I should have enough space for the bootloader and this library according to the size from my map file from the application.  These symbols correspond to functions from the TI motorware library.

  • Hayden Waddle81 said:
    These symbols correspond to functions from the TI motorware library.

    I suspect you do not supply this motorware library as an input to this link.  Why?

    Thanks and regards,

    -George

  • Sorry I should be a little more clear. I include the a lot of the motorware modules in my application. The motor control portion of the application relies heavily on them.
  • Unfortunately, I'm still lost on the cause of the undefined symbols.  That linker error diagnostic means your code calls that function, but no object file or library in the link supplies an implementation of that function.  Your choices are to change the code so that call does not occur, or add the missing object file or library to the link.

    As for running out of memory ... This part of the linker has worked the same way for a long time.  It is unlikely to be wrong.

    Thanks and regards,

    -George

  • George, got a quick question for you.  As per our conversation before I narrowed the amount of functions I need to be linked in to 8.  Although If I use the --undef_sym=*function name* in a separate .cmd file the linker ends up linking in the entire library.  Which we have determined is not what I need since I don't have room for that in my bootloader flash.  Is there away around this, as in just linking in those 8 functions from the static library?

  • When you supply the option --undef_sym=function_name, if function_name calls any other functions in that library, then the linker includes those functions too.  There is no way to disable this behavior.  I suspect this is how you end up with some functions that are not listed with --undef_sym.

    Thanks and regards,

    -George