Page 6 of 18

Re: ChibiOS OpenOCD support

Posted: Wed Oct 03, 2012 6:39 pm
by mabl
Without GC:

Code: Select all

-> % grep ch_debug build/ch.map
                0x0000000020000800                ch_debug
ch_debug                                          build/obj/chregistry.o


With GC:

Code: Select all

-> % grep ch_debug build/ch.map
 .data.ch_debug
ch_debug                                          build/obj/chregistry.o


Isn't it possible to change the linker files?

Re: ChibiOS OpenOCD support

Posted: Wed Oct 03, 2012 6:51 pm
by Giovanni
That would be the easy way to do that, I begin to doubt it is possible by using clean C without use an explicit pointer in some RAM structure.

Giovanni

Re: ChibiOS OpenOCD support

Posted: Wed Oct 03, 2012 8:36 pm
by Giovanni
I found a way to refer it without wasting 4 bytes (a lame trick).

It should be OK now, note that the ch_debug structure changed slightly.

Giovanni

Re: ChibiOS OpenOCD support

Posted: Wed Oct 03, 2012 8:41 pm
by mabl
Hi Giovanni, won't those 4 bytes be wasted by the function call? Or is the GCC to supid to optimize it all away?

Re: ChibiOS OpenOCD support

Posted: Wed Oct 03, 2012 8:42 pm
by Tectu
I tried it out and everything worked out of the box!
Thank you very much for your work, mabl. This will be really useful!

It would be nice if the USE_LINK_GC stuff would be fixed soon :)


~ Tectu

Re: ChibiOS OpenOCD support

Posted: Wed Oct 03, 2012 8:45 pm
by Giovanni
mabl wrote:Hi Giovanni, won't those 4 bytes be wasted by the function call? Or is the GCC to supid to optimize it all away?


It is a macro not a function and it stores the pointer in a thread structure, the pointer points to "main" so the structure is really referred. The p_name field of the main thread points to ch_debug.

Giovanni

Re: ChibiOS OpenOCD support

Posted: Wed Oct 03, 2012 8:59 pm
by mabl
Hi Giovanni,

i've included the changes. Cool trick with "main" :mrgreen: But now you cannot just check if a device runs chibios by reading out the Flash :P and doing a search for CHRT.

EDIT:
Have you thought about backporting the changes to the Stable Branch? There should not be much impact, right?

Re: ChibiOS OpenOCD support

Posted: Wed Oct 03, 2012 9:06 pm
by Giovanni
You can search for "main", zero followed by the size and the various other fields of the structure that are quite recognizable.

The backport can be done, I have to verify if there are other dependencies.

Giovanni

Re: ChibiOS OpenOCD support

Posted: Wed Oct 03, 2012 9:15 pm
by Tectu
I could try it out. I cloned the latest ChibiOS master from github and also the latest OpenOCD master from mabl.
Now it works with USE_LINKER_GC on :)

nice work!


~ Tectu

Re: ChibiOS OpenOCD support

Posted: Fri Oct 05, 2012 11:36 am
by mabl
Giovanni,

the oocd RTOS detection routine depends on detecting symbols unique to the operating system. Currently I only use "rlist" for detection. Are there other symbols I can assume to be always there and not change their name in the future? Like chSysInit and _idle_thread?