cancel
Showing results for 
Search instead for 
Did you mean: 

ARM mbed semihosting fs with stm32

aaron2399
Associate II
Posted on December 15, 2016 at 20:48

One of the unique things about ARM mbed-enabled boards (such as my 32F746GDISCOVERY) is that they have a small storage area that is shows up in Windows or Linux when the board is connected by USB. An executable can be flashed to the board by dropping in onto the USB device.

This storage area is also accessible from the device itself using ARM semi-hosting, with the mbed 'LocalFileSystem' (

https://developer.mbed.org/handbook/LocalFileSystem

 ). I'm using FreeRTOS--not ARM mbed OS--but I want to use this semi-hosting file system for testing purposes.

I have used code from the files 

https://github.com/ARMmbed/mbed-os/blob/master/platform/semihost_api.h

 and 

https://github.com/ARMmbed/mbed-os/blob/master/platform/mbed_semihost_api.c

 to make this happen. It compiles fine and runs fine until it hits the semi-host breakpoint (assembly 'bkpt 0xAB'), as which point it hangs. I assume it is waiting for something else, maybe even the host PC, to fulfill the semi-host request, and maybe it hangs because I haven't set up the board to handle it correctly...? I have read posts that describe how to enable semi-hosting to communicate with GDB, but I'm not sure if/how those apply here.

Am I on a wild goose chase? Does ARM mbed OS do something special to enable its LocalFileSystem that isn't available on other RTOS's? Or does anyone know of a step I could be missing here?

#semihosting #stm32f7 #mbed
2 REPLIES 2
aaron2399
Associate II
Posted on December 15, 2016 at 21:28

I found out that the semi-hosting calls are part of an

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0040d/Bcedijji.html

, which means it should be usable outside of mbed OS, but I don't understand yet how to use it.
TarekB-ST
Associate III
Posted on December 22, 2016 at 18:04

Campbell.Aaron

‌, semihosting is only usable with a debugger.

In fact any semihosting operation will :

  • write some parameters in core registers (R0 : operation command, R1,R2,... : arguments)
  • halts the core by a software breakpoint (0xAB)

after thatthe debugger capture this bkpt and :

  • analyze the command & arguments
  • executes the command
  • put the return value (or error code) in R0
  • and finally resume code execution (step to next instruction)

That's why semihosting is only functional while debugging, and blocks at run-time execution (because of the software bkpt)

Note : not all debuggers support semihosting

Note : to debug some application with semihosting you can use openocd (as example)

Note : writing files into device storage, is not a good idea (because ST-Link Firmware will try to program the created file)

Regards,

Tarek