7 years, 10 months ago.

mbed-os working on mbed-CLI, but not mbed-classic

I've spent a while on this and read around without luck so hope someone can help.

I've downloaded and setup my mbed-cli as per: https://www.youtube.com/watch?v=cM0dFoTuU14 (minor deviation is I have installed 2016q3 first and 2016q2 second (2016q2 without 'Add path to environment variable' or 'Add registry information').

I've successfully imported and compiled mbed-os-example-blinky as per this great blog post: http://grbd.github.io/posts/2016/11/06/using-the-mbed-cli/

I'm trying to work with mbed classic projects and no success. I always get he same Linker issue. I have created my own projects using mbed-CLI (<<code>>new mbed-classic-program --mbedlib<</code>>), exported code and tried mbed_blinky from: https://developer.mbed.org/users/mbed_demo/code/mbed_blinky as per: https://www.youtube.com/watch?v=PI1Kq9RSN_Y

In all cases I get many issues around the Linker including <<code>>undefined reference to `__wrap_exit'<</code>>

I have tried this with 2016q3 and 2016q2 (by using: mbed config GCC_ARM_PATH "C:\Program Files (x86)\GNU Tools ARM Embedded\5.4 2016q2\bin"). Any ideas what is wrong? Below is a full cmd session showing the issue. The mbed build looks to be the same as in the youtube video (Unpacking library build "f9eeca106725" in "C:\SOURCE\retry\mbed_blinky\mbed").

Is anyone successfully working with mbed-classic under mbed-CLI?

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\Users\Chris>cd ..

C:\Users>cd ..

C:\>cd SOURCE

C:\SOURCE>mkdir retry

C:\SOURCE>cd retry

C:\SOURCE\retry>mbed import https://developer.mbed.org/users/mbed_demo/code/mbed_blinky/
[mbed] Importing program "mbed_blinky" from "https://developer.mbed.org/users/mbed_demo/code/mbed_blinky" at latest revision in the current branch
[mbed] Adding library "mbed" from "http://mbed.org/users/mbed_official/code/mbed/builds" at rev #f9eeca106725
[mbed] Downloading library build "f9eeca106725" (might take a minute)
[mbed] Unpacking library build "f9eeca106725" in "C:\SOURCE\retry\mbed_blinky\mbed"
[mbed] Couldn't find build tools in your program. Downloading the mbed 2.0 SDK tools...

C:\SOURCE\retry>cd mbed_blinky

C:\SOURCE\retry\mbed_blinky>mbed toolchain GCC_ARM
[mbed] GCC_ARM now set as default toolchain in program "mbed_blinky"

C:\SOURCE\retry\mbed_blinky>mbed target K64F
[mbed] K64F now set as default target in program "mbed_blinky"

C:\SOURCE\retry\mbed_blinky>mbed compile
Building project mbed_blinky (K64F, GCC_ARM)
Scan: .
Scan: mbed
Scan: env
Compile [100.0%]: main.cpp
Link: mbed_blinky
c:/program files (x86)/gnu tools arm embedded/5.4 2016q3/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7e-m/softfp/crt0.o: In function `_start':
(.text+0x4e): undefined reference to `__wrap_exit'
./mbed/f9eeca106725/TARGET_K64F/TOOLCHAIN_GCC_ARM\libmbed.a(error.o): In function `error':
error.c:(.text.error+0x14): undefined reference to `__wrap_exit'
c:/program files (x86)/gnu tools arm embedded/5.4 2016q3/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7e-m/softfp\libc.a(lib_a-mprec.o): In function `_Balloc':
mprec.c:(.text._Balloc+0x22): undefined reference to `__wrap__calloc_r'
mprec.c:(.text._Balloc+0x3e): undefined reference to `__wrap__calloc_r'
collect2.exe: error: ld returned 1 exit status
[ERROR] c:/program files (x86)/gnu tools arm embedded/5.4 2016q3/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7e-m/softfp/crt0.o: In function `_start':
(.text+0x4e): undefined reference to `__wrap_exit'
./mbed/f9eeca106725/TARGET_K64F/TOOLCHAIN_GCC_ARM\libmbed.a(error.o): In function `error':
error.c:(.text.error+0x14): undefined reference to `__wrap_exit'
c:/program files (x86)/gnu tools arm embedded/5.4 2016q3/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7e-m/softfp\libc.a(lib_a-mprec.o): In function `_Balloc':
mprec.c:(.text._Balloc+0x22): undefined reference to `__wrap__calloc_r'
mprec.c:(.text._Balloc+0x3e): undefined reference to `__wrap__calloc_r'
collect2.exe: error: ld returned 1 exit status

[mbed] ERROR: "python" returned error code 1.
[mbed] ERROR: Command "python -u C:\SOURCE\retry\mbed_blinky\.temp\tools\make.py -t GCC_ARM -m K64F --source . --build .\BUILD\K64F\GCC_ARM" in "C:\SOURCE\retry\mbed_blinky"
---

C:\SOURCE\retry\mbed_blinky>mbed config --list
[mbed] Global config:
No global configuration is set

[mbed] Local config (C:\SOURCE\retry\mbed_blinky):
TOOLCHAIN=GCC_ARM
TARGET=K64F

C:\SOURCE\retry\mbed_blinky>mbed config GCC_ARM_PATH "C:\Program Files (x86)\GNU Tools ARM Embedded\5.4 2016q2\bin"
[mbed] C:\Program Files (x86)\GNU Tools ARM Embedded\5.4 2016q2\bin now set as default GCC_ARM_PATH in program "mbed_blinky"

C:\SOURCE\retry\mbed_blinky>mbed config --list
[mbed] Global config:
No global configuration is set

[mbed] Local config (C:\SOURCE\retry\mbed_blinky):
GCC_ARM_PATH=C:\Program Files (x86)\GNU Tools ARM Embedded\5.4 2016q2\bin
TOOLCHAIN=GCC_ARM
TARGET=K64F

C:\SOURCE\retry\mbed_blinky>mbed compile
Building project mbed_blinky (K64F, GCC_ARM)
Scan: .
Scan: mbed
Scan: env
Link: mbed_blinky
c:/program files (x86)/gnu tools arm embedded/5.4 2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7e-m/softfp/crt0.o: In function `_start':
(.text+0x4e): undefined reference to `__wrap_exit'
./mbed/f9eeca106725/TARGET_K64F/TOOLCHAIN_GCC_ARM\libmbed.a(error.o): In function `error':
error.c:(.text.error+0x14): undefined reference to `__wrap_exit'
c:/program files (x86)/gnu tools arm embedded/5.4 2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7e-m/softfp\libc.a(lib_a-mprec.o): In function `_Balloc':
mprec.c:(.text._Balloc+0x22): undefined reference to `__wrap__calloc_r'
mprec.c:(.text._Balloc+0x3e): undefined reference to `__wrap__calloc_r'
collect2.exe: error: ld returned 1 exit status
[ERROR] c:/program files (x86)/gnu tools arm embedded/5.4 2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7e-m/softfp/crt0.o: In function `_start':
(.text+0x4e): undefined reference to `__wrap_exit'
./mbed/f9eeca106725/TARGET_K64F/TOOLCHAIN_GCC_ARM\libmbed.a(error.o): In function `error':
error.c:(.text.error+0x14): undefined reference to `__wrap_exit'
c:/program files (x86)/gnu tools arm embedded/5.4 2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7e-m/softfp\libc.a(lib_a-mprec.o): In function `_Balloc':
mprec.c:(.text._Balloc+0x22): undefined reference to `__wrap__calloc_r'
mprec.c:(.text._Balloc+0x3e): undefined reference to `__wrap__calloc_r'
collect2.exe: error: ld returned 1 exit status

[mbed] ERROR: "python" returned error code 1.
[mbed] ERROR: Command "python -u C:\SOURCE\retry\mbed_blinky\.temp\tools\make.py -t GCC_ARM -m K64F --source . --build .\BUILD\K64F\GCC_ARM" in "C:\SOURCE\retry\mbed_blinky"
---

C:\SOURCE\retry\mbed_blinky>

1 Answer

7 years, 10 months ago.

Hey Chris,

This was a bug in mbed-sdk-tools. The bug was that the tools would not recognize the mbed 2 revisions after a particular number, and treat them as mbed-os. I have updated these tools to include the most recent versions of mbed 2 libraries. You should be able to replace the tools with the new version and have no problems

TL;DR: delete the ".temp" directory and "mbed deploy" and try again. It should work this time

-Jimmy

Accepted Answer

The problem seems to be NOT solved. Compilation success with mbed-os-example-blinky, but fails with mbed_blinky! I tried with gcc-arm-none-eabi-5_4-2016q2 and gcc-arm-none-eabi-5_4-2016q3.

root@antoDeb8:/home/anto/Projects/mbed/mbed_blinky# mbed config list [mbed] Global config: GCC_ARM_PATH=/home/anto/Projects/mbed/gcc-arm-none-eabi-5_4-2016q2/bin

[mbed] Local config (/home/anto/Projects/mbed/mbed_blinky): TARGET=K64F root@antoDeb8:/home/anto/Projects/mbed# root@antoDeb8:/home/anto/Projects/mbed# mbed compile [mbed] Auto-installing missing Python modules... Building project mbed_blinky (K64F, GCC_ARM) Scan: . Scan: mbed Scan: env Compile [100.0%]: main.cpp Link: mbed_blinky /home/anto/Projects/mbed/gcc-arm-none-eabi-5_4-2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7e-m/softfp/crt0.o: In function `_start': (.text+0x4e): undefined reference to `wrap_exit' ./mbed/f9eeca106725/TARGET_K64F/TOOLCHAIN_GCC_ARM/libmbed.a(error.o): In function `error': error.c:(.text.error+0x14): undefined reference to `wrap_exit' /home/anto/Projects/mbed/gcc-arm-none-eabi-5_4-2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7e-m/softfp/libc.a(lib_a-mprec.o): In function `_Balloc': mprec.c:(.text._Balloc+0x22): undefined reference to `wrapcalloc_r' mprec.c:(.text._Balloc+0x3e): undefined reference to `wrapcalloc_r' collect2: error: ld returned 1 exit status [ERROR] /home/anto/Projects/mbed/gcc-arm-none-eabi-5_4-2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7e-m/softfp/crt0.o: In function `_start': (.text+0x4e): undefined reference to `wrap_exit' ./mbed/f9eeca106725/TARGET_K64F/TOOLCHAIN_GCC_ARM/libmbed.a(error.o): In function `error': error.c:(.text.error+0x14): undefined reference to `wrap_exit' /home/anto/Projects/mbed/gcc-arm-none-eabi-5_4-2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7e-m/softfp/libc.a(lib_a-mprec.o): In function `_Balloc': mprec.c:(.text._Balloc+0x22): undefined reference to `wrapcalloc_r' mprec.c:(.text._Balloc+0x3e): undefined reference to `wrapcalloc_r' collect2: error: ld returned 1 exit status

[mbed] ERROR: "python" returned error code 1. [mbed] ERROR: Command "python -u /home/anto/Projects/mbed/mbed_blinky/.temp/tools/make.py -t GCC_ARM -m K64F source . build ./BUILD/K64F/GCC_ARM" in "/home/anto/Projects/mbed/mbed_blinky" -

posted by Antonello Lombardinilo 24 Feb 2017

First, we use gcc_arm_embedded 4.9.3, but that's not related to your problem. As I cannot reproduce this error on my machine, I would like to know a bit more information.

The procedure I followed is (Linux, GCC ARM Embedde v 4.9.3):

1. `$ mbed import http://mbed.org/teams/mbed/code/mbed_blinky/`

2. `$ cd mbed_blinky`

3.`$ mbed compile -t gcc_arm -m k64f`

``` Building project mbed_blinky (K64F, GCC_ARM) Scan: . Scan: mbed Scan: env Compile [100.0%]: main.cpp Link: mbed_blinky Elf2Bin: mbed_blinky +---+-+-+--+

Module.text.data.bss

+---+-+-+--+

Fill7342083
Misc375792492749
Subtotals3765224962832

+---+-+-+--+ Allocated Heap: 65536 bytes Allocated Stack: unknown Total Static RAM memory (data + bss): 5328 bytes Total RAM memory (data + bss + heap + stack): 70864 bytes Total Flash memory (text + data + misc): 41188 bytes

Image: ./BUILD/k64f/gcc_arm/mbed_blinky.bin ```

How does this compare to your process? Which OS are you running this on?

posted by the other jimmy 24 Feb 2017

I run the whole procedure again, and the problem has apparently disappeared!

My OS is Debian Jessy.

1 - '$ mbed import http://mbed.org/teams/mbed/code/mbed_blinky/'

2 - '$ cd mbed_blinky/'

3 - '$ mbed config target EFM32GG_STK3700'

4 - '$ mbed toolchain GCC_ARM'

5 - '$ mbed config --list'

6 - '$ mbed compile'

| Module    | .text | .data | .bss |

+-----------+-------+-------+------+
| Fill      |    79 |   220 |    9 |
| Misc      | 31729 |  2500 |  627 |
| Subtotals | 31808 |  2720 |  636 |
+-----------+-------+-------+------+
Allocated Heap: 3072 bytes
Allocated Stack: unknown
Total Static RAM memory (data + bss): 3356 bytes
Total RAM memory (data + bss + heap + stack): 6428 bytes
Total Flash memory (text + data + misc): 34528 bytes

Image: ./BUILD/EFM32GG_STK3700/GCC_ARM/mbed_blinky.bin

I noticed that the library build downloaded is the ad3be0349dc5, which it is different from the previous one that I used The problem is now import project to Simplicity Studio V3 (import->Simplicity Studio -> MCU Project) after the command

- 7 '$ mbed export -i simplicityv3'
- 8 '$ ls'
posted by Antonello Lombardinilo 01 Mar 2017

Update!

I repeated all the steps necessary on OS Win7x64. I again the problem undefined reference to '_wrap_calloc_r' In this case the library build downloaded is the f9eeca106725

How can I force a different version from f9eeca106725?

C:\Users\Antonello\Documents\Projects\mbed-cli>mbed --version
1.0.0

C:\Users\Antonello\Documents\Projects\mbed-cli>mbed import https://developer.mbed.org/users/mbed_demo/code/mbed_blinky/
[mbed] Importing program "mbed_blinky" from "https://developer.mbed.org/users/mbed_demo/code/mbed_blinky" at latest revision in the current branch
[mbed] Adding library "mbed" from "http://mbed.org/users/mbed_official/code/mbed/builds" at rev #f9eeca106725
[mbed] Downloading library build "f9eeca106725" (might take a minute)
[mbed] Unpacking library build "f9eeca106725" in "C:\Users\Antonello\Documents\Projects\mbed-cli\mbed_blinky\mbed"
[mbed] Couldn't find build tools in your program. Downloading the mbed 2.0 SDK tools...
[mbed] Auto-installing missing Python modules...

C:\Users\Antonello\Documents\Projects\mbed-cli>mbed detect
[mbed] WARNING: The mbed tools were not found in "C:\Users\Antonello\Documents\Projects\mbed-cli".
[mbed] WARNING: Limited information will be shown about connected mbed targets/boards
---
[mbed] Detected "EFM32GG_STK3700" connected to "M:" and using com port "COM23"

C:\Users\Antonello\Documents\Projects\mbed-cli>cd mbed_blinky

C:\Users\Antonello\Documents\Projects\mbed-cli\mbed_blinky>mbed detect

[mbed] Detected EFM32GG_STK3700, port COM23, mounted M:
[mbed] Supported toolchains for EFM32GG_STK3700
+-----------------+-----------+-----------+-----------+-----------+-----------+
| Target          | mbed OS 2 | mbed OS 5 |    ARM    |  GCC_ARM  |    IAR    |
+-----------------+-----------+-----------+-----------+-----------+-----------+
| EFM32GG_STK3700 | Supported | Supported | Supported | Supported | Supported |
+-----------------+-----------+-----------+-----------+-----------+-----------+
Supported targets: 1
Supported toolchains: 3

C:\Users\Antonello\Documents\Projects\mbed-cli\mbed_blinky>mbed toolchain GCC_ARM
[mbed] GCC_ARM now set as default toolchain in program "mbed_blinky"

C:\Users\Antonello\Documents\Projects\mbed-cli\mbed_blinky>mbed target EFM32GG_STK3700
[mbed] EFM32GG_STK3700 now set as default target in program "mbed_blinky"

C:\Users\Antonello\Documents\Projects\mbed-cli\mbed_blinky>mbed compile
Building project mbed_blinky (EFM32GG_STK3700, GCC_ARM)
Scan: .
Scan: mbed
Scan: env
Compile [100.0%]: main.cpp
Link: mbed_blinky
c:/program files (x86)/gnu tools arm embedded/5.4 2016q3/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7-m/crt0.o: In function `_start':
(.text+0x4e): undefined reference to `__wrap_exit'
./mbed/f9eeca106725/TARGET_EFM32GG_STK3700/TOOLCHAIN_GCC_ARM\libmbed.a(error.o): In function `error':
error.c:(.text.error+0x16): undefined reference to `__wrap_exit'
c:/program files (x86)/gnu tools arm embedded/5.4 2016q3/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7-m\libc.a(lib_a-mprec.o): In func
tion `_Balloc':
mprec.c:(.text._Balloc+0x24): undefined reference to `__wrap__calloc_r'
mprec.c:(.text._Balloc+0x40): undefined reference to `__wrap__calloc_r'
collect2.exe: error: ld returned 1 exit status
[ERROR] c:/program files (x86)/gnu tools arm embedded/5.4 2016q3/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7-m/crt0.o: In function `_
start':
(.text+0x4e): undefined reference to `__wrap_exit'
./mbed/f9eeca106725/TARGET_EFM32GG_STK3700/TOOLCHAIN_GCC_ARM\libmbed.a(error.o): In function `error':
error.c:(.text.error+0x16): undefined reference to `__wrap_exit'
c:/program files (x86)/gnu tools arm embedded/5.4 2016q3/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7-m\libc.a(lib_a-mprec.o): In func
tion `_Balloc':
mprec.c:(.text._Balloc+0x24): undefined reference to `__wrap__calloc_r'
mprec.c:(.text._Balloc+0x40): undefined reference to `__wrap__calloc_r'
collect2.exe: error: ld returned 1 exit status

[mbed] ERROR: "python" returned error code 1.
[mbed] ERROR: Command "python -u C:\Users\Antonello\Documents\Projects\mbed-cli\mbed_blinky\.temp\tools\make.py -t GCC_ARM -m EFM32GG_STK3700 --source . --build
 .\BUILD\EFM32GG_STK3700\GCC_ARM" in "C:\Users\Antonello\Documents\Projects\mbed-cli\mbed_blinky"
posted by Antonello Lombardinilo 01 Mar 2017

With version ad3be0349dc5 the compilation is successful !!

C:\Users\Antonello\Documents\Projects\mbed-cli\mbed_blinky>cd mbed

C:\Users\Antonello\Documents\Projects\mbed-cli\mbed_blinky\mbed>mbed update ad3be0349dc5
[mbed] Updating library "mbed" to rev #ad3be0349dc5
[mbed] Downloading library build "ad3be0349dc5" (might take a minute)
[mbed] Unpacking library build "ad3be0349dc5" in "C:\Users\Antonello\Documents\Projects\mbed-cli\mbed_blinky\mbed"
[mbed] Updating reference "mbed" -> "https://mbed.org/users/mbed_official/code/mbed/builds/ad3be0349dc5"

C:\Users\Antonello\Documents\Projects\mbed-cli\mbed_blinky\mbed>cd ..

C:\Users\Antonello\Documents\Projects\mbed-cli\mbed_blinky>mbed compile --clean
Building project mbed_blinky (EFM32GG_STK3700, GCC_ARM)
Scan: .
Scan: mbed
Scan: env
Compile [100.0%]: main.cpp
Link: mbed_blinky
Elf2Bin: mbed_blinky
+-----------+-------+-------+------+
| Module    | .text | .data | .bss |
+-----------+-------+-------+------+
| Fill      |    75 |   220 |    9 |
| Misc      | 31773 |  2500 |  627 |
| Subtotals | 31848 |  2720 |  636 |
+-----------+-------+-------+------+
Allocated Heap: 3072 bytes
Allocated Stack: unknown
Total Static RAM memory (data + bss): 3356 bytes
Total RAM memory (data + bss + heap + stack): 6428 bytes
Total Flash memory (text + data + misc): 34568 bytes

Image: .\BUILD\EFM32GG_STK3700\GCC_ARM\mbed_blinky.bin
posted by Antonello Lombardinilo 01 Mar 2017

f9eeca106725 does not seem to be a revision of mbed. OTOH, I'm glad that updating worked for you!

posted by the other jimmy 01 Mar 2017