6 years, 7 months ago.

mbed_interface_reset() with OS5 not resetting the semihost interface

I have been developing with mbed with an LPC1768 for a good few years now and for convenience have developed a serial interface framework for s/w development that uses mbed_interface_reset() to invoke a software controlled reset rather than having to press the reset button - it all works really well.

Problem I have: I am just starting to migrate to OS5 to utilise threading and have ported the bare minimum code to get my basic serial framework (above) working with continued use of mbed_interface_reset() and it no longer works. I have printf debugged and the call to the function returns -1 suggesting the mbed_interface_connected() is NOT connected (Github code snippet below). I am receiving and handshaking serial commands through the Serial(USBTX, USBRX) interface so it's definitely connected in some context at least.

## Github library code snippet

int mbed_interface_reset(void) { if (mbed_interface_connected()) { semihost_reset(); return 0; } else { return -1; } }

If anyone can provide any pointers that would be greatly helpful.

Good question... I've raised a ticket.

posted by Jan Jongboom 27 Sep 2017

According to this response behavior is correct on mbed OS 5.5.6 and mbed OS 5.6... Which version are you on?

posted by Jan Jongboom 29 Sep 2017

2 Answers

6 years, 7 months ago.

I would look into using NVIC_SystemReset() - https://os.mbed.com/questions/4680/reset-command-soft-reset/.

Thank you Sarah, unfortunately this is not the same but that's because my question wasn't so clear...

NVIC_SystemReset() will reset the LPC1768 but that's not what I am after per say. The mbed_interface_reset() (when it works) causes the CMSIS-DAP interface to reload any new bin image into the LPC1768 flash before reset occurs making it possible for me to perform a code upgrade without need to access the reset button for the same.

posted by Jimi Simpson 23 Sep 2017
6 years, 7 months ago.

Also, I was told years ago, when using the mbed RTOS, you should be using RawSerial, not Serial. I have been using RawSerial ever since.

I am certain there have been some improvements since then. There are not overarching problems using Serial and mbed OS 5 (note: this is our latest product, which combines mbed RTOS with the traditional mbed library). Read more about it here - https://www.mbed.com/en/platform/mbed-os/.

posted by Sarah Marsh 22 Sep 2017

I can confirm this wasn't the problem in the context of the question I had, but Kevin this is totally correct.

The Serial class must implement Mutex's which cause assertions to occur at run time in the Serial ISR.

RawSerial definitely overcomes these problems....

posted by Jimi Simpson 25 Sep 2017