The Vitis™ Unified Software Development Environment libraries and device drivers provide standard C library functions, as well as functions to access peripherals. The SDK 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 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
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 Cortex A9 processors:
arm-xilinx-eabi-gcc <C files>
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
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 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 runtime. 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.