Page 1 of 1
Semihosting with newlib freeze
Posted: Tue Jan 26, 2016 3:21 pm
by baoshi
I've been trying semihosting, by changing LD variable in the Makefile to:
LD = $(TRGT)gcc -specs=rdimon.specs
The balance I need to do is just to add
initialise_monitor_handles()
in main() to get printf() working.
However, if I try use newlib at the same time, where
LD = $(TRGT)gcc -specs=nano.specs -specs=rdimon.specs
The program hangs at printf() statement.
It seems a bare-metal build without ChibiOS does not have this problem. I trace a bit and think the lack of __libc_init_array from the startup code probably causes this.
Any help will be appreciated.
Baoshi
Re: Semihosting with newlib freeze
Posted: Tue Jan 26, 2016 3:33 pm
by Giovanni
Hi,
There should be no need for that function call, the startup file handles initialization and finalization functions by itself. Are those initializers correctly caught by rules.ld? you need to look at the map file.
Giovanni
Re: Semihosting with newlib freeze
Posted: Tue Jan 26, 2016 4:17 pm
by baoshi
No, I checked, not existing in map file.
While from a SDK build, I can see
c:/apps/armgcc/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv6-m\libc_nano.a(lib_a-init.o)
c:/apps/armgcc/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv6-m/rdimon-crt0.o (__libc_init_array)
in the map file.
I did something wrongly?
Re: Semihosting with newlib freeze
Posted: Tue Jan 26, 2016 5:21 pm
by Giovanni
This is how that function works:
http://stackoverflow.com/questions/1526 ... init-arrayIn you case the initialization arrays are empty, functions in the array are called by the startup file:
Code: Select all
constructors 0x080000c0 0x0
0x080000c0 __init_array_start = .
*(SORT(.init_array.*))
*(.init_array)
0x080000c0 __init_array_end = .
What is the function to be called that isn't called exactly?
Re: Semihosting with newlib freeze
Posted: Wed Jan 27, 2016 5:10 pm
by baoshi
I dig in a little further and it seems freeze at
std.isra()
call stack was
std.isra()
__sinit()
_puts_r()
puts()
main()
I have no clue what is missing here.
Re: Semihosting with newlib freeze
Posted: Wed Jan 27, 2016 5:15 pm
by Giovanni
You could look at the source code. Newlib is open source.
Also consider stack overflows, that trace is pretty deep.
Giovanni
Re: Semihosting with newlib freeze
Posted: Wed Nov 07, 2018 2:58 am
by DeusExMachina
Have anybody solved this problem with semihosting? I have converted on-board st-link to j-link, added --specs=rdimon.specs to makefile and call initialise_monitor_handles(); on startup. However, printf hangs up and nothing is out on the monitor side.
Re: Semihosting with newlib freeze
Posted: Mon Nov 12, 2018 4:32 am
by DeusExMachina
Chibios definetely has some conflict with newlib, since on bare metal semihosting works fine with openocd and st-link/jlink (I was even able to use gprof for profiling an embedded target). I checked both F072 and F407 bare metal targets which worked with minimal modifications.
Re: Semihosting with newlib freeze
Posted: Tue Nov 13, 2018 12:57 am
by DeusExMachina
Just thought that it would be really cool to have an embedded console output via semihisting debugging interface... No mess with USB2UART adapters or USB drivers... And it works only when debugger is attached! No user interference is possible. It is even possible to open files on PC side and write data down as GPROF does!
Re: Semihosting with newlib freeze
Posted: Tue Nov 13, 2018 7:00 am
by Giovanni
Hi,
ChibiOS does not interact with newlib unless syscalls.c is included. I don't see how it can block something to work in the library.
Giovanni