#40 semihosted (syscall.c,handler) not to issue any bkpt when core not debuged

Next Release
closed-fixed
None
5
2014-12-23
2014-02-25
diabolo38
No

semi hosting use AngelSwi (bkpt) declare in swi.h to interact with the host semi hosting
When the core is not being debug these cause an hard fault exception and program to crash when not debugged
Hopefully We can test for presence of debugger and not issue the swi instead return -1 failure.

The easy debugger test is chip dependent (we can't include core_cm4.h) prior the chip specific file to have access to few core register we need.

So final fix impact the actual shared/common file among various all template/chips

we can modify swi.h it will impact all over usage that could be fine already
we can modify only syscall have a local DoSwi using one in swi.h after test
we can add new include file in chip src dir say "machine.h" or alike
that enable all not machine dependent file to work without change by including it
over alternative ?

For the default startup not to crash , a new HardFault_Handler is needed
we can modify one existing in CMSIS or add a new file on all template
with semi hosting based on

i'm attaching the stm32f4xx files i have changed now here for purpose of review and discussion.

1 Attachments

Discussion

  • Liviu Ionescu (ilg)

    thank your for you suggestion. I'll analyse it these days.

    at first glance, I did not see you comments documenting the changes in swi.h and syscalls.c, I need to run some diffs.

    as strategy, I'll first add the Hard_Fault handler to prevent applications using the actual librdimon to crash.

    then I'll add the librdimon crt0 to the project, and once I have control to all calls, I'll change the semihosting call to skip the bkpt if debugging is not enabled.

     
  • Liviu Ionescu (ilg)

    • status: open --> open-accepted
    • assigned_to: Liviu Ionescu (ilg)
     
  • diabolo38

    diabolo38 - 2014-02-25

    Up to you how to change swi.h/syscall.c

    Sorry i could have sent git patch even if not so friendly

    Attached patch for what i did for one stm4 template,
    i'm sure new machine.h is a at good places
    when i create a project i see stm32f4xx in "project/include" not "project/src" ?
    also i don't know how to test these change localy ?

    In the pacth swi.h not change syscall.c is + new machine.h file
    so that syscall.c and hardfault.c can remain same across all chips

     
  • Liviu Ionescu (ilg)

    I'm currently rewriting all templates for adding new features, so I'll be quite busy for the next 2-3 days; please accept my apologies for not processing your files sooner.

    anyway, once all details fixed, the semihosting patch will be applied to all templates.

     
  • Liviu Ionescu (ilg)

    hi! I have a beta version of the new templates available for testing:

    https://sourceforge.net/p/gnuarmeclipse/beta-versions/2/

    currently I applied the patch when calling the semihosting for trace_write(). I'll also consider the patch for the exception handler, but some more work is needed to integrate it.

     
  • Liviu Ionescu (ilg)

    • status: open-accepted --> closed-fixed
     
  • Liviu Ionescu (ilg)

    fixed on 2.2.1-201404120702

    however, the debugger registers are not available on Cortex-M0/M0+, so this patch applies only to armv7m cores

     
  • Liviu Ionescu (ilg)

    I finally took the time to implement the real fix for this problem, i.e. processing semihosting calls in the HardFault_Handler. the solution is based on your suggestion, but it is slightly more elaborated.

    the latest beta, is available from updates-test.

    I would appreciate your comments/suggestions.

     
  • diabolo38

    diabolo38 - 2014-12-23

    look more elaborated and likely more exhaustive and correct that what i did
    most important It works :D
    I did not tried to force an hard fault see it react correctly.

    Note i had issue installing from updates-test on the 2 Kepler i have
    on 1st (SR2) it would have un-install the stm32 template so i stopped
    on 2nd it failed during install (missing bundle...)

    I finally installed on a luna (fresh never installeld plugins) that i'm not using

     
  • Liviu Ionescu (ilg)

    I did not tried to force an hard fault see it react correctly.

    it prints the stack frame and some other registers on the trace device.

    issue installing from updates-test

    yes, I know, SourceForge mirrors are not always up-to-date :-(

     
  • Liviu Ionescu (ilg)

    I forgot to tell, in case you want to single step through the added code, you can define OS_DEBUG_SEMIHOSTING_FAULTS and this will replace the BKPT with an illegal instruction, that will trigger UsageFault exceptions, which can be debugged without problems.

    in this case be sure you do not select the trace device to use semihosting too, since this is not possible; use ITM instead.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks