7 years ago.

how can I use semihosting with lpcxpresso?

I have a custom LPC1768 based board with firmware that I originally developed using the mbed online compiler. I have since exported the project and am using LPCxpresso to continue development because the project is no longer based on mbed hardware, and because lpcxpresso gives me debug capability. But, I'd like semihosting to work.

The printf calls that worked with mbed hardware no longer produce output, presumably because I don't have the magic mbed processor anymore, or any kind of USB stack in my firmware.

lpcxpresso has a semihosting facility in their example programs. I have done various things to get this closer to working but I finally ran into this:

/Applications/lpcxpresso_6.0.2_151/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/armv7-m/libcr_newlib_semihost.a(syscalls.o): In function `_read': F:\_workspaces\workspaces_clib\newlib_2010_stubs\newlib_stub_semihost\thumb2-v7m/../src/syscalls.c:290: multiple definition of `_read' /Users/sravet/Documents/lpc_xpresso_workspace/illmot_remote/mbed/LPC1768/GCC_CR/libmbed.a(stdio.o):stdio.cpp:(.text._read+0x0): first defined here

same for _write, _lseek, etc.

So it looks like at the bottom of the IO stack both the lpcxpresso libraries and the mbed library are defining the same functions.

Can someone let me know if there is a simple path to getting semihosting to work? Either using the mbed library if possible, or the newlib semihosting? It would be nice to have the output appear in the lpcxpresso gui, like the lpcxpresso examples, but I'm OK with output going to a USB terminal as well. I can't really use UART based output as my project doesn't have the level shifters and probably doesn't have a free UART either.

thanks, steve

2 Answers

7 years ago.

The printf calls are transferred to the mbed interface via UART. The mbed interface is a USB composite device consisting of HID, CDC and MSD. Semihosting was used for the local filesystem and few special functions (mac_address, mbed_reset, etc...)

Have you considered adding the mbed HDK into your custom design?

Steve Ravet
poster
7 years ago.

Hi Sam, thanks for the reply. Unfortunately the PCB is already laid out, manufactured, and stuffed, so it's too late to add the HDK. Although I think it's great that the HDK is available! I really need semihosting to work on this platform. I see a fair number of references to the LPCxpresso environment here at mbed, I was hoping that someone had gotten semihosting working with it.

I wonder if I need to build the mbed library from source instead, and leave out the _write and other functions that collide with the LPC provided functions.

I did lay my board out with a USB connector, so if the USB stack from the HDK were brought over then I should be able to get serial over USB semihosting working directly on the LPC1768. Any chance of the mbed team delivering that?

thanks, steve