Using ROM Lib
Open, Needs TriagePublic

Description

Hi,

I'm trying to make use of the ROMLIB feature, but when we come to the final link we get multiple definition errors:

./build/v1plus/release/lib/libc.a(exit.o): In function `atexit':
/home/neiljones/src/vsi_v1p/TFA-release/lib/libc/exit.c:21: multiple definition of `atexit'
./build/v1plus/release/lib/libwrappers.a(c_atexit.o):(.text+0x0): first defined here
Makefile:759: recipe for target 'build/v1plus/release/bl1/bl1.elf' failed
make: *** [build/v1plus/release/bl1/bl1.elf] Error 1

How is this supposed to work ? Other than marking all the functions we want in the romlib, weak in their respective libs or turning off multiple definitions and being *very* careful about link order I don't see how this is supposed to work ??

Hi,

I don't know what options you tried to build with, but I managed to build with the ROMLIB feature for the FVP platform. I will post everything I did here, hoping it will be of some use to you.
I used the following command to build:

MBEDTLS_DIR=<path_to_mbedtls> make ARM_ROTPK_LOCATION=devel_rsa CROSS_COMPILE=<path_to_cross_compiler(aarch64)> GENERATE_COT=1 PLAT=fvp ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem TRUSTED_BOARD_BOOT=1 USE_ROMLIB=1  DEBUG=1 fiptool all

The cross-compiler I used is GCC 8.3 for AArch64 ELF bare-metal target. You can get it from here:
https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads

You will also need Mbed TLS. The latest stable version (2.16.2) is available here:
https://tls.mbed.org/download

Alternatively, you can clone the repository from github:
https://github.com/ARMmbed/mbedtls
If you choose this, however, you will have to checkout the tag for the latest stable release (for newer versions you might get build errors due to changes in how the source tree is organized):
git checkout mbedtls-2.16.2

The TF-A documentation might also be of some help: https://trustedfirmware-a.readthedocs.io/en/latest/index.html

I hope that this will be of some help to you.