>From inspection of the master branch, it looks like this issue has already 
>been addressed and only exists in v0.10.0. In the current master I can see 
>that semihosting has (again) been completely refactored/restructured since 
>0.10.0.  In semihosting_common() the SEMIHOSTING_SYS_EXIT op handler  now 
>includes some careful logic to ensure the target is resumed only when it is 
>configured to do so (nice!).  So I guess you can close this unless you are 
>stil patching release v0.10.0?  Anyway the patch is above if anyone needs it.


---

** [tickets:#218] arm semihosting: target resumes after application exit**

**Status:** new
**Milestone:** 0.9.0
**Created:** Thu Jan 03, 2019 05:40 PM UTC by Joseph McLaughlin
**Last Updated:** Thu Jan 03, 2019 05:40 PM UTC
**Owner:** nobody


In release 0.10.0 when running the target in semihosted mode it was found that 
a `wait_halt <ms>` command is not  honored after the target app has run to 
completion.  By "run to completion" I mean that  a  semihosting op of 0x18 
`angel_SWIreason_ReportException` has been requested by the target.  The 
following command works as expected in v0.9.0 but "hangs" in v0.10.0 until the 
`wait_halt` timer expires: 

`openocd -f openocd.cfg -c "program hello_world" -c 'arm semihosting enable' -c 
'reset run' -c 'wait_halt 60000' -c 'shutdown'`

...assuming `hello_world` is a semihosted app that exits gracefully well before 
the timer expiry. 

It was found that this "hang" is likely due to the target being resumed in 
`arm_semihosting()` after the `angel_SWIreason_ReportException` is processed.  
It looks like some subtle logic may have been inadvertently removed between 
v0.9.0 and v0.10.0. that prevented the target from resuming in this case.

This patch fixes the "hang", but not sure if it's an appropriate  fix:
```
$ diff -u original/src/target/arm_semihosting.c patched/src/target
--- original/src/target/arm_semihosting.c       2016-12-25 09:12:55.000000000 
-0500
+++ patched/src/target/arm_semihosting.c        2019-01-03 11:13:09.000000000 
-0500
@@ -772,6 +772,10 @@
                        LOG_ERROR("Failed semihosting operation");
                        return 0;
                }
+
+               // Early out if handling an exit request / exception report
+               if (arm->semihosting_op == 0x18)
+                       return 1;
        }
```




---

Sent from sourceforge.net because [email protected] is 
subscribed to https://sourceforge.net/p/openocd/tickets/

To unsubscribe from further messages, a project admin can change settings at 
https://sourceforge.net/p/openocd/admin/tickets/options.  Or, if this is a 
mailing list, you can unsubscribe from the mailing list.
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to