Offline GCC compiler works with mbed libraries!

16 Mar 2016

@Chris H

Hello Chris,

Have you made any progress? I am unable to advise you based on your question above. Please look through my blog page:

http://www.rescuerobot.org/drupal/?q=content/best-free-offline-ide-mbedorg-projects

You will see that my explanation of gcc4mbed-master and installing eclipse is quite complete. With the NUCLEO-F446RE I had no trouble completing the setup of gcc4mbed-master and installing eclipse. Check every step and contact me on my site.

Regards,

Kevin.

04 May 2016

A new version of GCC4MBED is available on github at https://github.com/adamgreen/gcc4mbed#quick-start

New features include:

10 May 2016

Hey Community,

I am trying to compile my RTOS project offline with the newest GCC4MBED.

Target: K64F

Build-option: make all deploy GCC4MBED_TYPE=Release

The building process has been finished without errors.

Could someone provide the current Online-Compiler for improve the Makefile Flags? My offline compiled version crashes everytime, when SD-card is used ( writing with fprintf(..)) The online version works well... ;)

I have attached my current makefile.

Thanks for your support :) /media/uploads/aquaduct/k64f-device.mk

21 Jun 2016

Hi Tobi

Were you successful here:

https://developer.mbed.org/questions/68943/Export-to-KDS-Problem-with-RTOS-for-Plat/

Is the SD card library compatible with RTOS?

Regards,

Kevin

28 Jun 2016

Yes of course :)

Problem SOLVED :) With the help of this topic: https://developer.mbed.org/forum/mbed/topic/3290/

Increased stack size for SDcard thread to 2.25 * DEFAULT_STACK_SIZE

27 Jul 2016

Has anyone used this for the new nrf51 dev kit that has 32k ram . It appears at the moment that the NRF51822 target is assuming 16k ram like the older BLE mbed board

12 Sep 2016

I tried to install gcc4mbed on Windows 10, but after running win_install.cmd, it hangs while "Performing a clean build of the gcc4mbed samples...". Please help.

Sorry, it worked eventually, just took a very long time.

/media/uploads/smartsystemdesign/win_install.log

06 Nov 2016

Whenever I execute "arm-none-eabi-gdb -version" I get the following error message:

"arm-none-eabi-gdb: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory"

Execution of "ldd $(which arm-none-eabi-gdb)" returns:

linux-gate.so.1 => (0xf7742000) libdl.so.2 => /lib/libdl.so.2 (0xf7728000) libncurses.so.5 => not found libm.so.6 => /lib/libm.so.6 (0xf76e6000) libc.so.6 => /lib/libc.so.6 (0xf7529000) /lib/ld-linux.so.2 (0xf7743000)>>

Any Idea on what I have to do in order to eliminate the "not found" library error?

"file /usr/lib64/libncurses.so.5" returns

/usr/lib64/libncurses.so.5: symbolic link to `libncurses.so.5.9'

"file /usr/lib64/libncurses.so.5.9" returns

/usr/lib64/libncurses.so.5.9: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=17bbe791547fb4e59b7a4209a4b82469bb349ec3, stripped

PS: I am running centos7

06 Nov 2016

Solved Above Issue by using

yum provides '*/libncurses.so.5

to identify the 32 Bit package and afterwards installed it through

yum install ncurses-libs-5.9-13.20130511.el7.i686

11 Nov 2016

Indexer cannot find "Serial"

/media/uploads/rgeissen/bildschirmfoto_2016-11-11_um_20.00.05.png

Unfortunately the Indexer marks my reference to the Serial class "Serial pc(USBTX, USBRX)" as invalid (Type Serial cannot be resolved), even though mbed.h includes Serial.h (see attached picture) ... any idea on how to get rid of this annoying behaviour?

I have added two include directories to PATHS & SYMBOLS:

.../gcc4mbed/external/mbed-os

.../gcc4mbed/external/mbed-os/targets/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_MCU_K64F/TARGET_FRDM

12 Nov 2016

Even though I succeeded with compiling most of my programs I am now getting the following compile error with a more complex program:

Description	Resource	Path	Location	Type
'HW_GPIO_PCOR_WR' was not declared in this scope	FS_AZURE_IOTHUB_CLIENT_WORKING		line 193	C/C++ Problem
'HW_GPIO_PDDR_RD' was not declared in this scope	FS_AZURE_IOTHUB_CLIENT_WORKING		line 123	C/C++ Problem
make: *** [K64F/main.o] Fehler 1	FS_AZURE_IOTHUB_CLIENT_WORKING		 	C/C++ Problem

Any Idea on how to get rid of this compile error?

... needless to say that this program runs with the online compiler ... and ... also with the offline compiler using the standard Makefile provided by the online compiler export.

13 Nov 2016

-- I SOLVED BELOW ONE THROUGH CHANGING DEVICE.H (as it is the source for conditional compiling based on device) -

Rainer Geissendoerfer wrote:

Indexer cannot find "Serial"

/media/uploads/rgeissen/bildschirmfoto_2016-11-11_um_20.00.05.png

Unfortunately the Indexer marks my reference to the Serial class "Serial pc(USBTX, USBRX)" as invalid (Type Serial cannot be resolved), even though mbed.h includes Serial.h (see attached picture) ... any idea on how to get rid of this annoying behaviour?

I have added two include directories to PATHS & SYMBOLS:

.../gcc4mbed/external/mbed-os

.../gcc4mbed/external/mbed-os/targets/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_MCU_K64F/TARGET_FRDM

13 Nov 2016

Wanting to ask Kevin Gordon a question ... :-)

If you're around Kevin, you say in your excellent blog post above '..openstm32.org, is limited to ST platforms and has problems accepting imports of mbed.org projects.'

So I was wanting to know what kind of problems you've encountered and whether this was recent?

The reason is that so far I've found importing mbed projects, even complex ones, very quick and straightforward (even the source and library paths are now configured automatically). Indeed some programmes that haven't worked doing an mbed compilation and download to the target, have worked fine with an import and OpenSTM32 GCC compile. The significant problem right now (mid Nov 2016) is that programmes compiled on-line using the latest, re-structured version of mbed-dev source, won't export at all to any IDE!

Perhaps what's needed is a way of using mbed libraries without having to compile on-line and export at all.

Best wishes, Ron

13 Nov 2016

Solved below one by changing the compiler to an older version

Rainer Geissendoerfer wrote:

Even though I succeeded with compiling most of my programs I am now getting the following compile error with a more complex program:

Description	Resource	Path	Location	Type
'HW_GPIO_PCOR_WR' was not declared in this scope	FS_AZURE_IOTHUB_CLIENT_WORKING		line 193	C/C++ Problem
'HW_GPIO_PDDR_RD' was not declared in this scope	FS_AZURE_IOTHUB_CLIENT_WORKING		line 123	C/C++ Problem
make: *** [K64F/main.o] Fehler 1	FS_AZURE_IOTHUB_CLIENT_WORKING		 	C/C++ Problem

Any Idea on how to get rid of this compile error?

... needless to say that this program runs with the online compiler ... and ... also with the offline compiler using the standard Makefile provided by the online compiler export.

08 Dec 2016

Hello Fellows,

Newbie here, be patient with me ;-).

I spent few hours for the last 4 days on and off trying to find a solution before posting here. It seems you guys have this working since earlier this year with GCC4mbed.

Is GCC4meb required for us to be able to use eclipse compiling mbed code if we already have set and environment using eclipse to cross compiler to ARM? i.e., KDS 3.x (Kinetis Development Studio)

That is, if we have KDS working including debugging, why can't we use the mbed IDE export project to KDS, then import in KDS and do a build it all?

I was under impression that this was the cool advertised part of the export from the mbed IDE... The sources would come along with the project and one could build it all in the particular off-line environment.

Of course, I am writing this note to you because the export/import/build is failing for me with the simple mbed Blinky on K64F platform. I can post exactly the errors to you here. But so I don't look too silly, first I decided to ask if this was supposed to be plug and play process in December 2016 (vs. earlier in the year requiring gcc4meb) or I should install some pre-compiled mbed OS libraries in the KDS environment first and or gcc4mbed is required.

PlatformIO import/compile worked compiling mbed exampled. But having the pay* to use the debugging functionality wont work for us.

  • My ultimate goal is to use the mbed IDE then KDS with kids ranging from middle school to high school using Windows and Mac. So the export / import in an easy installed development environment such as KDS can be very handy.

Thank you! -Jack

11 Dec 2016

Here is the error I get With a simple HelloWorld code:

" ../main.cpp:3:23: error: call to 'mbed::Serial::Serial(PinName, PinName, const char*, int)' uses the default argument for parameter 4, which is not yet defined Serial pc(USBTX, USBRX); tx, rx "

Code:

  1. include "mbed.h"

Serial pc(USBTX, USBRX); tx, rx int i=0; int main() { while(i<=10){ pc.printf("Hello World!\n"); i++; } }

I am pretty sure it is because KDS is not getting the mbed libraries. I don't know how to do that. I export the mbed project from the mbed online IDE to a KDS format. Then import in in KDS. Could not be that easy huh... I hoped the source for mbed was being exported with the project and KDS would build it all.

I know other people had work done on GCC4mbed earlier. Do we still need to do that kind of work to export / import mdeb to KDS?

Thanks, -Jack

If you check my notebook, you will also find information about LPC_DEPLOY environment variables and how they can be applied. "Make adjustments" to copy the binary result to the device automatically.

19 Dec 2016

Hi guys.

Tinkering with GCC4mbed and trying to get debugging working with ST 32L476G Discovery board (DISCO_L476VG). I've managed to setup the makefiles and target configurations so that the build & programming work both command line and in eclipse. Serial communication seems to be ok as the terminal output works ok from the board.

However I cannot get the debugger to work:

Quote:

<terminated>GlassLCD Debug [C/C++ Remote Application] arm-none-eabi-gdb (7.10.1.20151217) GNU gdb (GNU Tools for ARM Embedded Processors) 7.10.1.20151217-cvs Copyright (C) 2015 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "host=i686-linux-gnu target=arm-none-eabi". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word". Ignoring packet error, continuing... warning: unrecognized item "timeout" in "qSupported" response Ignoring packet error, continuing... Ignoring packet error, continuing..."

I've followed the instructions from this tutorial: https://developer.mbed.org/cookbook/eclipse-for-building-and-debugging

I've also gone through all the mbed4gcc instructions from Adam from this thread and this repository: https://github.com/adamgreen/gcc4mbed#quick-start

Any ideas? Should the onboard debugger work out-of-box with gdb?

19 Dec 2016

Ok, my previous post isn't even visible yet, but just to re-cap stuff I needed to make debugger work:

prequisite: mbed4gcc setup like described in coockbook: https://developer.mbed.org/cookbook/eclipse-for-building-and-debugging

System building OK in eclipse.

1. Install seggert firmware to my dev board: https://www.segger.com/jlink-st-link.html

2. Setup j-link for eclipse. http://gnuarmeclipse.github.io/debug/jlink/

3 days of work and 4 different instruction sets merged into one blob.

I received an error message such as: ../../external/mbed/PinNames.h:18:14: error: use enum 'PinName' without previous announcement.

08 Feb 2017

I did the steps but there are errors, like: Function 'wait' could not be resolved main.cpp /default-ide line 13 Semantic Error

and this warning was appeared : Invalid project path: Include path not found (C:\mbed-dev\external\mbed Directory:: C::\mbed-dev\external\mbed\LPC1768). default-ide pathentry Path Entry Problem

what I can do ? .... I used stm NUCLEO-f746zg

08 Feb 2017

Ibrahim,
It might have something to do with the "::" (double colon) in the path?
Azq

20 Feb 2017

Hi , I'm new beginning for this site recommend I thank you for everything.

04 Mar 2017

Many thanks for this work. Outstanding!

One thing I see in this is a patched arm-none-eabi-gdb that seems to be the key to being able to debug. I'm curious what that patch was - can you provide any insight?

BTW, what I am trying to do is use the latest GNU Arm Embedded Toolchain in Launchpad (https://launchpad.net/gcc-arm-embedded). With this toolchain, I've been able to build and deploy non-debug images to my NXP LPC1768 just fine.

When I build a debug version using the launchpad toolchain and then use arm-none-eabi-gdb from that same toolchain, however, the debugger hangs (arm-none-eabi-gdb --interpreter mi2 --nx followed by tar remote /dev/tty.usbmodem1442).

Keeping all other things equal (using the launchpad toolchain to build a debug version) if I use the patched arm-none-eabi-gdb from GCC4MBED, I can debug just fine.

So, I'm curious what secret sauce has been put in the GCC4MED arm-none-eabi-gdb.

Many thanks again for all of the hard work putting GCC4MED together.

05 Mar 2017

I do see the following in https://github.com/adamgreen/mri/blob/master/notes/mri-faq.creole:

Quote:

"If you are running GDB on OS X, then you need to make sure that you are using the custom build of arm-none-eabi-gdb which is installed by GCC4MBED's mac_install script. I have made modifications to this build of GDB to make it work better with the USB virtual serial ports on OS X."

So, getting closer to an answer, but I'm curious what the changes are.

09 Mar 2017

Never mind - I think I was running into this bug: https://bugs.launchpad.net/gcc-arm-embedded/+bug/1655778. When I installed gcc-arm-none-eabi-6-2017-q1-update-mac.tar.bz2 from 23-Feb-2017, my gdb issues went away.

01 May 2017

Willie Walker wrote:

One thing I see in this is a patched arm-none-eabi-gdb that seems to be the key to being able to debug. I'm curious what that patch was - can you provide any insight?

Sorry, I haven't been getting any e-mail notifications for posts in this thread for over a year. I just stumbled back in here today.

I don't think the patch I made to that version of GDB probably had anything to do with your issue...it seems like it was just the fact that it was an older version of GDB that made it work for you. However, the change I made in that version of GDB was to make the serial port I/O usage non-blocking so that GDB could connect to the mbed-LPC1768 running my MRI debug monitor. Before it would hang waiting for the carrier to be detected (think modem).

diff --git a/src/gdb/gdb/ser-unix.c b/src/gdb/gdb/ser-unix.c
index b9e55f0911..a0567d52b4 100644
--- a/src/gdb/gdb/ser-unix.c
+++ b/src/gdb/gdb/ser-unix.c
@@ -108,7 +108,7 @@ void _initialize_ser_hardwire (void);
 static int
 hardwire_open (struct serial *scb, const char *name)
 {
-  scb->fd = gdb_open_cloexec (name, O_RDWR, 0);
+  scb->fd = gdb_open_cloexec (name, O_RDWR | O_NONBLOCK, 0);
   if (scb->fd < 0)
     return -1;
 
@@ -151,6 +151,9 @@ set_tty_state (struct serial *scb, struct hardwire_ttystate *state)
 #ifdef HAVE_TERMIOS
   if (tcsetattr (scb->fd, TCSANOW, &state->termios) < 0)
     return -1;
+  
+  /* Give USB based serial port one frame to handle baud request. */
+  usleep(2000);
 
   return 0;
 #endif
@@ -705,7 +708,7 @@ rate_to_code (int rate)
 
   for (i = 0; baudtab[i].rate != -1; i++)
     {
-      /* test for perfect macth.  */
+      /* test for perfect match.  */
       if (rate == baudtab[i].rate)
         return baudtab[i].code;
       else
01 May 2017

Hey everyone!

This is quite a long and detailed thread. I want to pop in and say that there are two supported ways to compile your code offline with the GCC:

1) You can use the export function that is integrated into the online compiler - https://docs.mbed.com/docs/mbed-os-handbook/en/latest/dev_tools/third_party/. In this case, you might export to a GNU ARM Embedded makefile.

2) You can use our command line tool, mbed CLI, to compile your code, manage dependencies, and use the export functionality of (1) offline.

Additionally, you can use pyOCD to debug your code with a GDB client.

03 May 2017

Absolute newbie here.

I ran the build script following the instructions at gcc4mbed#quick-start

I followed the instructions in the eclipse.creole notes. With the exception that the URL for the Eclipse IDE is different now.

When I get to the step to select the toolchain, none of those options show up. So I select GCC ARM.

I try to set up the FileTest. When finished, the clean and build steps do not do anything - they just print the all done message.

Any idea what I'm doing wrong?

Thanks!

18 May 2017

A new version of GCC4MBED is available on GitHub at https://github.com/adamgreen/gcc4mbed#quick-start

New features include:

  • Upgraded GNU tools to GCC ARM Embedded 6-2017-q1-update.
  • Upgraded mbed SDK from revision 119 to revision 142.
  • With the upgrade to mbed SDK revision 142, the multithreaded mbed-os version 5 is now the default version of mbed used:
    • If you want the smaller single-threaded mbed 2 version of the library then add MBED_OS_ENABLE := 0 to your project's Makefile.
  • GCC4MBED_TYPE now supports these following types to match the mbed build system:
    • Debug with optimization disabled. CPU sleep not used from RTOS and asserts are enabled. Best debugging experience but largest code size.
    • Develop with -Os, space saving optimizations enabled. CPU sleep not used from RTOS and asserts are enabled.
    • Release with -Os, space saving optimizations enabled. CPU sleep is used from RTOS and asserts are disabled by setting the NDEBUG macro.
  • The GCC4MBED_TYPE alone never enables the MRI debug monitor anymore. You must now set the MRI_ENABLE variable to value of 1 to enable it.
  • The mbed build system now force includes a mbed_config.h into every source file compiled. GCC4MBED has the MBED_CONFIG_H variable to allow the user to specify the config file to use. It defaults to src/mbed_config.h
  • The build/ folder now contains *-device.mk makefiles for every target that has been marked in targets.json as supporting the GCC_ARM toolchain.
    • You can run make help for any of the samples to see a list of all currently supported devices.
    • I have only tested building the targets which indicate that they are part of mbed's version 2 or 5 releases in targets.json.
    • While I make sure that the samples build for most of the targets, I only deploy and run on the following set:
      • LPC1768
      • KL25Z
      • K64F
      • NRF51_DK
    • Please feel free to open GitHub issues to let me and the community know if you hit any issues for a target that should be supported with the GCC_ARM toolchain so that we can investigate.
    • See device notes for more information about the expanded target support.
  • Sample updates:
    • Some were deleted:
      • USBHost samples since none of the USB libraries are officially supported in the latest mbed tree (they are in the features/unsupported folder). I did use the unsupported USBDevice library as a user library in the USBMouse sample though.
      • rtos_basic since even HelloWorld now uses the RTOS.
    • Updated Blink sample to get it as small as possible:
      • Set MBED_OS_ENABLE to 0 since it doesn't need any RTOS functionality.
      • Provides an implementation of _exit() since the mbed version flushes the stdout/stderr streams and uses mbed APIs to blink LEDs. This pulls in a bunch of stream, UART, timer, and GPIO mbed code.
    • Updated SdPerf to use the SD card driver compatible with the new driver model of the mbed-os. The SDBlockDevice implementation comes from https://github.com/ARMmbed/sd-driver where before it was shipped as part of the mbed SDK.
    • Updated TCPSocket_HelloWorld to use the new mbed-os networking APIs.
  • I updated the documentation and added a few new documents as well: