Need help with semihosting

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need help with semihosting

1,281 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by sravet on Mon Sep 02 21:56:25 MST 2013
I have been struggling with semihosting for a while now with no success.  The one example I have that works is adc_semihost, which is written in C.  I need semihosting in C++ but my attempts so far have been failures.  I am using LPCXpresso 5.2.6 on Mac OSX.

I tried creating a new LPCXXpresso C++ project from scratch.  On the second screen, where it looks like I am supposed to pick the microcontroller, the "next" button is never enabled, no matter what controller I pick.  Looks like a GUI problem?  Anyway it seems to be a dead end.

I tried creating a new C++ (as opposed to LPCXpresso C++, what is the difference?) project -> Hello World C++ project.  Seems like this is using Mac OSX GCC tools?  Not sure how that's supposed to work since those are presumably targeting X86.  The code seems to compile OK but when I go to launch it says "Error while launching Debug/hello.  Program file does not exist.  ...../Debug/hello. not found.  This looks like a launch problem because there is a hello.axf in the Debug directory, but it looks like the debugger is trying to find hello. with no extension.

I tried creating a new C++ project -> empty C++ project.  I added main.cpp to the project and put a simple printf into main:
#include <stdio.h>

int main()
{
printf ("hello!\n");
}

That compiles OK but when I go to run it the debugger complains that:
Error while launching Debug/hello.axf
Error in final launch sequence
Failed to execute MI command:
-break-insert -t main
Error message from debugger back end:
Function "main" not defined.

I tried copying adc_semihost into a new project and building it.  That works, and semihosting works.  I renamed main.c to main.cpp (because I need a C++ project) but that didn't work.  It compiled OK but when I tried to run the debugger again complained that main was not defined.

I also tried to bring semihosting into my existing C++ project by copying debug.h, debug.c, and the libraries used by adc_semihost.  I have run into a variety of problems here, I think the closest I got was thoroughly detailed in this post from earlier this year, which didn't get any replies:  http://www.lpcware.com/content/forum/how-do-i-get-debug-printf-to-work

So I need one of two things:
1)  a hello world example that uses printf in a C++ project, that I can use as an example to bring semihosting to my existing project, or
2)  instructions on getting semihosting to work in my existing C++ project

This is a product prototype and I have a deadline coming up, so any help would be greatly appreciated.

thanks,
--steve
0 Kudos
Reply
6 Replies

1,162 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by grad on Sat Sep 21 07:11:07 MST 2013
Yes use EmBlocks.

It supports C++ and Semihosting with output in the gdb debug target window. It supports also the Jlink from segger and there are LPC examples. For the STlink it also supports live data (memory access on running target) but this is not supported by the Segger GDB server.

Tip:

Use the formfeed (\f) in your printf to clear the output window. You can print in this way static lines on the terminal.

http://www.emblocks.org/web
0 Kudos
Reply

1,162 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by sravet on Tue Sep 17 10:00:32 MST 2013
I was completely unaware of the C++ restriction.  Since I started with mbed and moved to lpcxpresso to get debug capability it wouldn't have been a very good choice if I had known about it.  That said, I had very little problem bringing over the mbed library and headers and compiling my project in lpcxpresso.  There are certainly plenty of C++ options scattered around the project preferences.  I'm not sure what "restriction" there actually is regarding C++.  Other than, perhaps, the fact that I can't get semihosting to work.

--steve
0 Kudos
Reply

1,162 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rocketdawg on Mon Sep 16 08:11:08 MST 2013
this is silly.  There is a way to hack it.  So to prevent someone from using C++ is futile.
So why go through the effort?
the main concern is that you have a revenue path, which you do, by charging for code size.
Hopefully NXP will straighten this out and realize it is just Eclipse, GCC, and some helpers, and realize it would be better, if it were all free.

So alternatives, if we are forced to go elsewhere, we go....
http://www.emide.org/   may do C++, have not tried it yet
http://www.emblocks.org/web/  might have debugger issues with LPC, works fine with ST devices
you can run "mbed" on your board.  It is C++.  A little harder to set up since it is not real mbed platform, but it works.

or get eclipse
get gcc
https://launchpad.net/gcc-arm-embedded

0 Kudos
Reply

1,162 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Sun Sep 15 23:50:17 MST 2013
If you look at LPCXpresso project wizards, accessible through Quickstart Panel -> New project -> MCU, you will see that we do not provide functionality to generate C++ projects within LPCXpresso IDE. This restriction has been in place and documented since it was first launch back at the end of 2009.

And I'm afraid that the use of  the "standard" Eclipse New project option to try to bypass this restriction will not work either, and you will run into various problems - as you seem to have found. As "TheFallGuy" has already highlighted, various previous threads have suggested various way around the LPCXpresso C++ restriction, but we can't provide you with any assistance on these.

Regards,
LPCXpresso Support
0 Kudos
Reply

1,162 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by sravet on Sat Sep 14 13:21:19 MST 2013
Well.  I see that now on the code red page.  I wonder how that squares with the fact that the GUI will happily offer to create a C++ project for me.  I guess they wouldn't be embedded development tools if they weren't aggravating to use.

Any more suggestions on getting semihosting to work?

thanks,
--steve
0 Kudos
Reply

1,162 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Mon Sep 02 23:33:11 MST 2013
You know the LPCXpresso does not (officially) support c++, right? If you search the forums you will see various hacks to enable c++...
0 Kudos
Reply