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.

retargeting libc in a sys/bios application

I'm developing for AM335x using the Processor SDK RTOS AM335x 2.00.00.00 which contains BIO 6.42.02.29.

My task is to port Lua (lua.org) into my CCSv6 project so that I can make use of the Lua interpreter in my embedded application.  However the Lua library uses standard C calls such as fprintf, fopen, etc.  Under SYS/BIOS RTOS ecosystem what is the best way to port these calls to my hardware (UART and MMCSD specifically)?  I see 2 general paths forward:

1. Remove Lua's C standard library dependencies and replace with my own implementations.

2. Provide implementations to the low level glue functions of the C standard library (_read, _write, etc.).

I would prefer option 2 but I don't see how to do this in SYS/BIOS?  SYS/BIOS documentation mentions the SysStd module but this seems to be a wrapper around the C standard library which is the opposite of what I would need.  

  • Hi Brian,
    Which compiler are you using (TI or GGG)? If you are using the TI compiler, there is a way to add a user defined device driver for C IO, using the add_device() function. This is described in the ARM C/C++ Compiler User's Guide.
    Best regards,
    Janet
  • Hi Janet

    Unfortunately, I'm using the GCC(Linaro 4.8.4) compiler.  I noticed that there is a runtime support library option called 'libnosys.a', however I do not see any documentation on it.  In fact I can't find much documentation on any of the runtime support libraries provided in the drop down box in CCSv6 project properties.  My vague understanding is that libc.a is actually newlib and the file functions (fopen, fread, etc) actually operate on the host filesystem over JTAG?  or is that just librdimon.a?  And then there is the *_s.a versions of each library.  So many questions and I'm willing to read any relevant documentation if I could just find it!

    Kind regards,

    Brian

  • Hi Brian,

    Unfortunately we don't have an easy solution for GCC.  It looks like you'll have to implement the _read, _write, etc. functions.

    Best regards,

        Janet

  • Hi Brian,

    Like Janet suggested, you will have to implement your own version of _read, _write, etc. calls. Here's a link to the "syscalls.c" file in newlib repo that is used to build librdimon.a library. You can use this as reference:

    sourceware.org/.../gitweb.cgi

    Once you add your own implementation of the BSP functions, you should remove libnosys/librdimon from your app's link line.

    Regarding documentation, I am not aware of any libnosys/librdimon documentation in the toolchain but there is documentation for libc/libm in the GCC tools installation. Here's the path to it on my machine:

    C:\ti\ccsv6\tools\compiler\gcc-arm-none-eabi-4_8-2014q3\share\doc\gcc-arm-none-eabi\pdf (contains libc.pdf, libm.pdf, etc)

    Best,
    Ashish
  • Adding to my previous post:

    libnosys source files can be found here: sourceware.org/.../gitweb.cgi
  • This is very helpful, Ashish. Thank you. Just to verify: malloc and free are the only standard c library calls that are implemented by SYS/BIOS then?
  • May I suggest that the options provided in the Project-->Properties-->CCS General-->Runtime support library tab are misleading and should be replaced by options such as:

    libc + libnosys
    libc + librdimon
    libg + libnosys
    libg + librdimon
    etc.
  • BrianBrianBrian said:

    Just to verify: malloc and free are the only standard c library calls that are implemented by SYS/BIOS then?

    TI-RTOS kernel (SYS/BIOS) provides its own implementation of malloc, memalign, calloc, free and realloc libc functions. If you use the Seconds module, then we also provide our own implementation of time() function.

    Best,
    Ashish