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 and MicroBlaze-V processor or Arm Cortext-A9, Cortex-R5F, Cortex-R52,
Cortex-A53, Cortex-A72, and Cortex-A78 processors. You can find the header files
corresponding to these C standard functions in the
<installation
directory>/Xilinx/<release
number>/gnu/<processor>/<platform>/<toolchain>/<processor-lib>/usr/include
folder where:<installation directory>/Xilinx/<release number>is the Vitis Unified Software Development Environment installation path- <processor> is either Arm, MicroBlaze, or MicroBlaze-V
- <platform> is either Windows (nt) 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 riscv64-unknown-elf Programs accessing standard C
library functions must be compiled as follows:- For MicroBlaze processors
mb-gcc <C files> - For MicroBlaze-V
processor
riscv64-unknown-elf-gcc <C files> - For Arm Cortex-A9, Cortex-A53, and Cortex-A72 (32-bit mode) processors
arm-none-eabi-gcc <C files> - For Arm Cortex-A53, Cortex-A72, and Cortex-A78 (64-bit mode) processors
aarch64-none-elf-gcc <C files> - For Cortex-R5F and Cortex-R52 processor
armr5-none-eabi-gcc <C files>
Memory Management Functions
The MicroBlaze, MicroBlaze-V, Arm Cortex-A9, Cortex-A53, Cortex-A72, Cortex-A78,
Cortex-R52, 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.