Failed to override svcHook.


For my first post, I'd like to submit a problem I'm turning around for days :cry:
I tried to override the svcHook function is order to set a SVC handler.
And it doesn't seem to work (i.e. the program stops, due to the alias of svcHook).

However, overriding other weak symbols (TC3_Handler, etc) works fine. So why just this one ?

I've changed the halt function which aliases svcHook to make it doing nothing, and in this case, my program ... do not stop anymore. Hence, it seems that the svcHook of the "standard library" is always the called one.

Guys from FreeRTOS or ChibiOS succeeded ! I've spent hours reading the code (trying to understand :wink: but I do not see the (good :wink: ) difference.

For the test, I compile using the Arduino editor, not a Makefile.
Below is my simple code.

Thank you for any idea.

-- F

volatile bool led_status = LOW ;

void svcHook () { led_status = ! led_status ; digitalWrite (13, led_status) ; }

void setup ()
pinMode (13, OUTPUT) ;
digitalWrite (13, LOW) ;
NVIC_EnableIRQ (SVCall_IRQn) ;

void test_supervisor () { asm volatile ("SVC #0\n\t" ::slight_smile: ; }

void loop () { test_supervisor () ; }

Could this be the order things are linked?

Could this be the order things are linked?

Possible... But so, why doesn't it also happen for other weak symbols like TCx_Handler etc ?

Even stranger... I compiled with a Makefile and performed an objdump.

It seems (?) that SVC_Handler branches on ... pendSVHook, and not on svcHook :astonished:

Am I crazy ? Or did I misused objdump ?

Of course, I tried to override pendSVHook, but it's not better.

I finally found !!! :slight_smile:

The overriding function had to be in an extern "C" { } statement !

It seems now to be working.

The remaining question: why not for other one (again TCx_Handler, etc) ? :astonished: