ChibiOS OpenOCD support

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
Post Reply
mabl
Posts: 417
Joined: Tue Dec 21, 2010 10:19 am
Been thanked: 1 time

Re: ChibiOS OpenOCD support

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS OpenOCD support

Post 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
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS OpenOCD support

Post 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
mabl
Posts: 417
Joined: Tue Dec 21, 2010 10:19 am
Been thanked: 1 time

Re: ChibiOS OpenOCD support

Post 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?
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: ChibiOS OpenOCD support

Post 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
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS OpenOCD support

Post 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
mabl
Posts: 417
Joined: Tue Dec 21, 2010 10:19 am
Been thanked: 1 time

Re: ChibiOS OpenOCD support

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS OpenOCD support

Post 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
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: ChibiOS OpenOCD support

Post 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
mabl
Posts: 417
Joined: Tue Dec 21, 2010 10:19 am
Been thanked: 1 time

Re: ChibiOS OpenOCD support

Post 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?
Post Reply