Xilinx Standard C Libraries - 2021.1 English

Xilinx Standalone Library Documentation OS and Libraries Document Collection (UG643)

Document ID
UG643
Release Date
2021-06-16
Version
2021.1 English

The Unified Software Development Environment libraries and device drivers provide standard C library functions, as well as functions to access peripherals. These libraries are automatically configured based on the Microprocessor Software Specification (MSS) file. These libraries and include files are saved in the current project lib and include directories, respectively. The -I and -L options of mb-gcc are used to add these directories to its library search paths.

Standard C Library (libc.a)

The standard C library, libc.a, contains the standard C functions compiled for the MicroBlaze™ processor or the Arm® Cortex-A9 processor. You can find the header files corresponding to these C standard functions in the <XILINX_SDK>/gnu/<processor>/<platform>/<processor-lib>/include folder, where:

  • <vitis> is the Vitis Unified Software Development Environment installation path
  • <processor> is either Arm or MicroBlaze
  • <platform> is either Solaris (sol), or Windows (nt), or Linux (lin)
  • <processor-lib> is either arm-xilinx-eabi or microblaze-xilinx-elf

The lib.c directories and functions are:

_ansi.h   fastmath.h  machine/   reent.h    stdlib.h  utime.h   _syslist.h  
fcntl.h   malloc.h    regdef.h   string.h   utmp.h    ar.h      float.h   
math.h    setjmp.h    sys/       assert.h   grp.h     paths.h   signal.h
termios.h ctype.h     ieeefp.h   process.h  stdarg.h  time.h    dirent.h
imits.h   pthread.h   stddef.h   nctrl.h    errno.h   locale.h  pwd.h
stdio.h   unistd.h         

Programs accessing standard C library functions must be compiled as follows:

  • For MicroBlaze processors:
    mb-gcc <C files>
  • For Arm Cortex-A9 processors:
    arm-xilinx-eabi-gcc <C files>

The libc library is included automatically. For programs that access libm math functions, specify the lm option. For more information on the C runtime library, see MicroBlaze Processor Reference Guide (UG081).

Xilinx C Library (libxil.a)

The Xilinx C library, libxil.a, contains the following object files for the MicroBlaze processor embedded processor:

  • _exception_handler.o
  • _interrupt_handler.o
  • _program_clean.o
  • _program_init.o

Default exception and interrupt handlers are provided. The libxil.a library is included automatically. Programs accessing Xilinx C library functions must be compiled as follows:

mb-gcc <C files>

Memory Management Functions

The MicroBlaze processor and Arm Cortex-A9 processor C libraries support the standard memory management functions such as malloc(), calloc(), and free(). Dynamic memory allocation provides memory from the program heap. The heap pointer starts at low memory and grows toward high memory. The size of the heap cannot be increased at run time. Therefore an appropriate value must be provided for the heap size at compile time. The malloc() function requires the heap to be at least 128 bytes in size to be able to allocate memory dynamically (even if the dynamic requirement is less than 128 bytes).

Note: The return value of malloc must always be checked to ensure that it could actually allocate the memory requested.