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
Semihosting with newlib freeze
Moderators: RoccoMarco, barthess
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Semihosting with newlib freeze
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
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
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?
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?
- Attachments
-
- ch.zip
- map file
- (25.1 KiB) Downloaded 206 times
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Semihosting with newlib freeze
This is how that function works:
http://stackoverflow.com/questions/1526 ... init-array
In you case the initialization arrays are empty, functions in the array are called by the startup file:
What is the function to be called that isn't called exactly?
http://stackoverflow.com/questions/1526 ... init-array
In 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
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.
std.isra()
call stack was
std.isra()
__sinit()
_puts_r()
puts()
main()
I have no clue what is missing here.
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Semihosting with newlib freeze
You could look at the source code. Newlib is open source.
Also consider stack overflows, that trace is pretty deep.
Giovanni
Also consider stack overflows, that trace is pretty deep.
Giovanni
- DeusExMachina
- Posts: 223
- Joined: Tue Apr 03, 2012 5:08 am
- Location: South Korea
- Has thanked: 3 times
- Been thanked: 3 times
Re: Semihosting with newlib freeze
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.
- DeusExMachina
- Posts: 223
- Joined: Tue Apr 03, 2012 5:08 am
- Location: South Korea
- Has thanked: 3 times
- Been thanked: 3 times
Re: Semihosting with newlib freeze
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.
- DeusExMachina
- Posts: 223
- Joined: Tue Apr 03, 2012 5:08 am
- Location: South Korea
- Has thanked: 3 times
- Been thanked: 3 times
Re: Semihosting with newlib freeze
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!
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Semihosting with newlib freeze
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
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
Who is online
Users browsing this forum: No registered users and 49 guests