bmlib - a bare metal library
Library of stuff often needed in bare metal projects.
It is more or less a small fraction (say 1%) of libc functionality in a tiny tiny package.
Who should use this?
This is probably only useful to people working on 32 or 64-bit embedded systems.
What does it provide?
It currently includes the following functions
- from stdio.h: printf, snprintf and vprintf
- from string.h: memcpy, memset, strlen, strcpy, strncpy, strcmp, strncmp, strchr, strtok and strrok_r
- from elsewhere: divu10 (to avoid libgcc dependency of __eabi_div )
You can include/exclude groups of functions by editing bmconfig.h
Build a library using the existing Makefile and define your architecture and configuration via variables.
To cross-compile for Raspberry Pi 2 (32-bit ARMv7):
make CROSS_COMPILE=arm-none-eabi- UFLAGS="-mcpu=cortex-a7" CONFIG=...
To cross-compile for Raspberry Pi 3 (64-bit ARMv8):
make CROSS_COMPILE=aarch64-linux-gnu- UFLAGS="-mcpu=cortex-a53 -march=armv8-a -mgeneral-regs-only" CONFIG=...
- UFLAGS is added to gcc CFLAGS.
- CONFIG should point to the folder holding bmconfig.h. The default value is src/config
- If you use printf() you need to provide your own int putchar(int c)
The footprint of the full library is shown below for various architectures:
- AMD x64: 1379 + 15 bytes (text + data/bss)
- ARM v7: 1304 + 11
- ARM v8: 1704 + 15
You can reduce footprint further by excluding some functions in bmconfig.h.