The Vitis 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 Cortext-A9, Cortex-R5F, Cortext-A53, and Cortex-A72 processors. You
can find the header files corresponding to these C standard functions in the
<XILINX_SDK>/gnu/<processor>/<platform>/<toolchain>/<processor-lib>/usr/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
aarch64-none
, orgcc-arm-none-eabi
, ormicroblazeeb-xilinx-elf
_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, Cortex-A53/Cortex-A72 (32-bit mode) processors
arm-none-eabi-gcc <C files>
- For Arm Cortex-A53/Cortex-A72 (64-bit mode) processors
aarch64-none-elf-gcc <C files>
- For Cortex-R5F processor
armr5-none-eabi-gcc <C files>
Memory Management Functions
The MicroBlaze processor and Arm Cortex-A9, Cortex-A53, Cortex-A72, and Cortex-R5F) 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
the 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.