10 years, 3 months ago.

[BUG] Exporting to ARM GCC does not work (need update in tutorial and missing files)

Use Case: Exporting my Hello World to build it on my host machine with ARM GCC.

Environment: - Linux host machine - Mbed LPC1768 (Note: I have only a single plateform) - GNU Tools for ARM Embedded Processors: I used the one advertised on this page: https://launchpad.net/gcc-arm-embedded/4.7/4.7-2012-q4-major

Test Case 1) Export my hello world form the web UI - Right click on MyHelloWorld > Export Program Export Toolchain: GCC (ARM Embedded)

2) Unzip the tarball in /tmp

/tmp/MyHelloWorld$ ls -R
.:
main.cpp  Makefile  mbed  mbed.bld

./mbed:
AnalogIn.h   BusOut.h      DigitalIn.h     Ethernet.h         I2C.h              mbed.h             PortInOut.h  rtc_time.h          SPISlave.h    Timer.h
AnalogOut.h  CAN.h         DigitalInOut.h  FileHandle.h       I2CSlave.h         PeripheralNames.h  PortNames.h  Serial.h            Stream.h      wait_api.h
Base.h       can_helper.h  DigitalOut.h    FileLike.h         InterruptIn.h      PinNames.h         PortOut.h    SerialHalfDuplex.h  Ticker.h
BusIn.h      cmsis.h       DirHandle.h     FileSystemLike.h   LocalFileSystem.h  platform.h         PwmOut.h     SPI.h               Timeout.h
BusInOut.h   cmsis_nvic.h  error.h         FunctionPointer.h  LPC1768            PortIn.h           rpc.h        SPIHalfDuplex.h     TimerEvent.h

./mbed/LPC1768:
cmsis_nvic.o  core_cm3.h  core_cm3.o  LPC17xx.h  stackheap.o  startup_LPC17xx.o  system_LPC17xx.h  system_LPC17xx.o

3) Ensure the cross compiler is in the PATH (or edit GCC_BIN in 'Makefile') and Build!

  1. First errors (same as in this topic https://mbed.org/forum/mbed/topic/2336/):
./mbed/PinNames.h:18:14: error: use of enum 'PinName' without previous declaration
./mbed/PinNames.h:18:29: error: invalid type in declaration before ';' token
./mbed/PinNames.h:19:6: error: using typedef-name 'PinName' after 'enum'
  1. Second error (same error as the one reported in the comment: http://mbed.org/questions/845/When-will-export-to-KL25Z-GCC-ARM-Embedd/): (...my toolchain path...)/arm-none-eabi/bin/ld: cannot open linker script file None: No such file or directory

I can see in the Makefile:

LINKER_SCRIPT = None

If I compare with this page: https://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded then I can also see it misses the mbed.lib.

Note: I have cloned the github repository and done a 'python project.py -m LPC1768 -p 0 -i gcc_arm'. I can confirm I can correctly build the generated archive.

Hello,

I can confirm the 2nd error, tested on KL25Z. Compared to the makefile from mbed exporters, library paths is not filled neither. 3 variables are not set in the online compiler's exporters - library, library paths, and linker script.

Thanks for reporting!

Regards,
0xc0170

posted by Martin Kojtal 09 Jan 2014

3 Answers

Olivier M
poster
10 years, 3 months ago.

I confirm updating mbed.lib fixes the issue. it would be nice to get an error message when exporting the project fails.

10 years, 3 months ago.

Hello,

It looks like the project that you're trying to export uses an old version of the mbed library. Could you try to update the mbed library inside your project to the latest version and see if that fixes the issue?

Thanks,
Bogdan

10 years, 3 months ago.

Hi Bogdan,

I am also facing similar issue with FRDM-KL25Z board.

I have imported the Servo Hello world program and updated the mbed library. Then i compiled and tested the binary from mbed. I can see servo motor spinning. I verified the PWM output on PTB0 pin using oscilloscope.Everything looks good.

Issue 1 : Now i Exported my servo hello world (updated the pin for KL25Z) from the web UI - Right click on MyHelloWorld > Export Program Export Toolchain: GCC (ARM Embedded).

Then i launched the gmake and created the binary file.

But when i test it on the board, i do not see PWM signal on the PTB0 pin and also servo motor does not spin. what is the reason ?

And also size of binary file with gcc is 10 times larger than the mbed binary file. How to reduce the binary file size ?

Issue 2: After exporting the FRDM-RGBLED (updated the mbed lib) to gcc arm tool chain. I get an linked error saying ld file is not found. When i verified the makefile, i found that LD file is mentioned as None. And i do not see mbed library is added to make file.

We are struggling with this issue from past one week. Please help.

Thanks, Jagadeesh

Hi Jagadeesh,

Regarding issue 2 above, I just did this:

1. import FRDM-RGBLED from http://mbed.org/users/mbed_official/code/FRDM_RGBLED/
2. update the mbed library inside the project to the latest version
3. export to GCC (ARM embedded)
4. unzip the file from step 3 on a directory on my disk and execute 'make' in that directory

That works and I get my FRDM-RGBLED binary file, so I don't know what's the issue on your side. Could you please publish your project and share it?

Thanks, Bogdan

posted by Bogdan Marinescu 09 Jan 2014

Hi Bogdan,

Issues with FRDM-RGBLED: Issue1: Looks like i have imported the FRDM-RGBLED from one of the mbed user. I have not ried with mbed_official. Now i have tried as you said, i get the binary file. But when i flash the image onto target, i do not see that LED is blinking. Please check and let me know. Issue2 : The binary file size is 36kb. Where as mbed generated binary file size is 13kb. I see that binary file size is 3 times more than the mbed generated file. What are the reasons for increase in size with gcc ? Let us know how to reduce the size of binary file with gcc.

Issue3 : Servo Motor Hello world Program As i explained in my previous post, i have used the mbed official servo motor hello world program. I am able to generate the binary file with gcc. But the servo motor does not run. However, the binary file generated with mbed compiler successfully runs the servo motor. Let me know why this happend ?

My observation from issue1 and issue2, PWM module may not be initialized properly.

posted by Jags K 09 Jan 2014

Hi Jagadeesh,

as written on this page https://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded. Different compilers might generate different binaries that exposes defects in the code: "Whilst we support exporting your project and the libraries to an alternate toolchain, we cannot guarantee the same consistency as using the mbed Online Compiler. We will do our best to maintain the exported libraries, project file and makefiles, but please understand we can not cover all cases, combinations or provide support for use of these alternate tools themselves! "

What you should do is ensured there is no warning messages in the code produced by GCC.

Switch also to the latest ARM Embedded GCC toolchain (4.8-2013-q4-major): https://launchpad.net/gcc-arm-embedded.

Olivier

posted by Olivier M 09 Jan 2014

Hi Oliver, Bogdan,

Thanks for your reply. I completely understand your point.

I have done some more testing today.

The FRDM-RGBLED demo program which uses PWM works fine using gnc gcc compiler after i update the main.cpp as below. I just added a dummy serial object at the top of main function. And this program worked only with Serial dummy object. Are any flags or definitions are missing while exporting from mbed for gcc ? Any ideas are appreciated and helpful for me .

NOTE : I exported the program to Keil and generated binary works well on the target without any modification to the program.

  1. include "mbed.h" PwmOut r (LED_RED); PwmOut g (LED_GREEN); PwmOut b (LED_BLUE); Serial s(USBTX, USBRX);

int main() { r.period(0.001); g.period(0.001); b.period(0.001); while (true) { for (float i = 0.0; i < 1.0 ; i += 0.001) { float p = 3 * i; r = 1.0 - ((p < 1.0) ? 1.0 - p : (p > 2.0) ? p - 2.0 : 0.0); g = 1.0 - ((p < 1.0) ? p : (p > 2.0) ? 0.0 : 2.0 - p); b = 1.0 - ((p < 1.0) ? 0.0 : (p > 2.0) ? 3.0 - p : p - 1.0); wait (0.0025); } } }

posted by Jags K 10 Jan 2014

Jags, I tried to build my simple test application with the latest GCC. And I can see there is no much difference in size:

  • gcc-arm-none-eabi-4_7-2012q4

- MyHelloWorld.bin: 35,556 Byte

- MyHelloWorld.elf: 139,008 Byte

  • gcc-arm-none-eabi-4_8-2013q4

- MyHelloWorld.bin: 35,468 Byte

- MyHelloWorld.elf: 139,629 Byte

posted by Olivier M 12 Jan 2014

Hi Jagadeesh,

Thanks for reporting this issue. The problem you describe in your previous post was traced to an issue in the KL25Z initialization code and fixed. The fix will be part of the next official mbed SDK build, which will be released in 2 weeks or less. You can try the fix even now, but you'll need to use the mbed-src library, not mbed.

Thanks,
Bogdan

posted by Bogdan Marinescu 15 Jan 2014

Hi Bogdan,

Thanks for correcting it. I am about to reply to this post. I found the issue in PWM intialization and corrected and tested locally, it worked. Then i see your changes to mbed-src library. I have taken your changes and tried on the target, now the demo is working fine.

Still one question is puzzling me. Why demo works fine with binary files generated from mbed or keil compiler before your correction to initalization code ? My guess is that libmbed.ar library file is build with different revision source files that the libmbed.a library for KL25z. Is that true ? If not , can you please provide me the reason for working with mbed or keil ?

posted by Jags K 15 Jan 2014

Hi Jagadeesh,

When I changed the initiazation code I had a short look at that, because I wondered indeed the same. I didn't look to indepth at it, but the serial port was initialized even though I didn't have any Serial object or printf in the online compiler: So I assume the online compiler and keil always initialize stdio (which calls the init function of that serial connection), even though it isn't used in the code.

Erik

posted by Erik - 16 Jan 2014

Hi Bogdan,

Does the latest official mbed SDK (version 76) has your fix to the bug reported in this post ?

Please let me know. I would like to try with latest library.

Jagadeesh.

posted by Jags K 31 Jan 2014