arm-learning-paths icon indicating copy to clipboard operation
arm-learning-paths copied to clipboard

Modify the example to use the UART for printf output

Open joeyemb opened this issue 1 year ago • 2 comments

i've tried this example for FVP based cortex a53 with a c project, but when i created a C++ project for the same FVP and try to use the UART for printf output, i couldn't and a lot of errors kept occur

joeyemb avatar Mar 06 '24 17:03 joeyemb

Hello, I think I replicated the issue.

I changed the example to use the hello world example here: https://www.programiz.com/cpp-programming/examples/print-sentence

At link time I see errors that execution regions exceed limits. These are defined in the scatter file. Changing the size of the region, for example:

ROM_EXEC +0 0x100000 ... RAM_EXEC +0 0x20000

Allows the link to complete.

If this is not your issue, please can you share the errors you are seeing.

RonanSynnottArm avatar Mar 07 '24 01:03 RonanSynnottArm

Hi again, working this through, I think the issue you saw were link errors of the form:

Error: L6200E: Symbol fputc multiply defined (by fputc.o and uart.o). Error: L6200E: Symbol __stdout multiply defined (by stdio_streams.o and uart.o).

These are caused by library objects being linked in for other symbols, which result in symbols being multiply defined.

Adding --verbose to the linker command line shows why this happens, for example:

Loading member stdio_streams.o from c_ou.l. reference : _initio reference : _terminateio definition: __stdin definition: __stdout definition: __stderr definition: __aeabi_stdin definition: __aeabi_stdout definition: __aeabi_stderr

Defining these symbols prevents stdio_stream.o being used.

I've not fully worked through all the symbols that need to be retargeted, but you would need to retarget all such symbols.

I hope the below documentation helps: https://developer.arm.com/documentation/100073/0621/The-Arm-C-and-C---Libraries/Target-dependencies-on-low-level-functions-in-the-C-and-C---libraries

RonanSynnottArm avatar Mar 07 '24 02:03 RonanSynnottArm