Understand the embedded C library, BSP structure and the two driver levels used by a Vitis application.
The BSP connects a software domain to exported hardware. It supplies drivers, libraries, and startup services for the selected processor.
Identify dependencies
A Vitis platform associates an XSA with one or more domains. Each domain selects processor, operating system, and BSP. In standalone, the application uses those services directly without Linux.
Element
Purpose
Generated headers
Hardware addresses, identifiers and parameters
Drivers
Access to PS and PL peripherals
Libraries
Standard C, files, network and system services
Startup code
Vector table, initialization and exception handling
The C library, generally Newlib-based in this flow, provides memcpy, printf, and allocation. OS-dependent services need adaptation. Check the library actually selected by the toolchain.
xparameters.h contains addresses, identifiers, interrupts, and some frequencies. Names depend on instances and generation flow. After hardware changes, update XSA, platform, and BSP before rebuilding.
Newer flows may use base addresses instead of historical device IDs. Read actual BSP signatures rather than retaining an incompatible API.
It suits short sequences when addresses, offsets, and access order are known. Level 1 keeps an instance and checks initialization:
XGpio gpio;int gpio_init(void){ int status = XGpio_Initialize(&gpio, XPAR_FPT_LED_BANK_DEVICE_ID); if (status != XST_SUCCESS) { return XST_FAILURE; } XGpio_SetDataDirection(&gpio, 1, 0x0U); return XST_SUCCESS;}
The structure supports multiple instances and callbacks. Check every return value; a missing configuration must not lead to later invalid access.
Add only needed libraries
XilFFS supplies FAT for SD/eMMC; lwIP supplies networking. Flash and other services add code and buffers. Choose according to available memory, execution model, and requirements.
Define application lifetime
init_platform() and cleanup_platform() execute operations defined in platform.c. They may handle caches or standard UART depending on the target. They do not replace application peripheral setup or teardown.
int main(void){ int status; init_platform(); status = gpio_init(); if (status != XST_SUCCESS) { xil_printf("GPIO initialization failed\r\n"); cleanup_platform(); return XST_FAILURE; } XGpio_DiscreteWrite(&gpio, 1, 0x55U); cleanup_platform(); return XST_SUCCESS;}
This main completes the preceding declarations and gpio_init function; BSP headers and platform.h are also required. It checks failure before proceeding and cleans up on both return paths. An infinite application loop has a different lifetime.