mbed-cli: Mbed compile -m detect picks incorrect target

mbed compile -m detect -t gcc_arm with a SEED_TINY_BLE plugged in will compile for the ARCH_BLE.

Original comment below


I am a beginner with mbed and mbed-cli, and I have a problem which I need help for. If I selected a wrong place to ask this question, please forgive me and point me to the right place. I thought this might be related to mbed_cli, but also it might be related to arm gcc compiler.

Description: I have created simple LED blink example with the online mbed compiler and compiled for Seeed Tiny BLE target and after compiling everything is as expected and LED blinks.

Then I wanted to compile same code with mbed-cli to get the offline capability.

  1. I have exported code from the online compiler and selected GCC (ARM Embedded) toolchain. Then I have executed following commands with given output:
$ mbed compile -m ARCH_BLE -t GCC_ARM
[mbed] ERROR: The mbed tools were not found in "/home/user/MBED/mbed_blinky_26022018". 
[mbed] ERROR: Run `mbed deploy` to install dependencies and tools. 
---
$ mbed deploy
[mbed] WARNING: Program "mbed_blinky_26022018" in "/home/user/MBED/mbed_blinky_26022018" does not use source control management.
[mbed] WARNING: To fix this you should use "mbed new ." in the root of your program.
---
[mbed] Updating library "mbed" to rev #7130f322cb7e
[mbed] Downloading library build "7130f322cb7e" (might take a minute)
[mbed] Couldn't find build tools in your program. Downloading the mbed 2.0 SDK tools...
[mbed] Updating the mbed 2.0 SDK tools... 
$ mbed compile -m ARCH_BLE -t GCC_ARM
Building project mbed_blinky_26022018 (ARCH_BLE, GCC_ARM)
Scan: .
Scan: mbed
Scan: env
Compile [100.0%]: main.cpp
[Fatal Error] platform.h@29,10: device.h: No such file or directory
[ERROR] In file included from ./mbed/mbed.h:55:0,
                 from ./main.cpp:1:
./mbed/platform/platform.h:29:10: fatal error: device.h: No such file or directory
 #include "device.h"
          ^~~~~~~~~~
compilation terminated.

[mbed] ERROR: "/usr/bin/python" returned error code 1.
[mbed] ERROR: Command "/usr/bin/python -u /home/user/MBED/mbed_blinky_26022018/.temp/tools/make.py -t GCC_ARM -m ARCH_BLE --source . --build ./BUILD/ARCH_BLE/GCC_ARM" in "/home/user/MBED/mbed_blinky_26022018"
---

I do not know how to solve this error, so I have tried other approach to import project from URL with following commands and outputs:

$ mbed import http://os.mbed.com/teams/mbed/code/mbed_blinky/
[mbed] Importing program "mbed_blinky" from "https://os.mbed.com/teams/mbed/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 #7130f322cb7e
[mbed] Downloading library build "7130f322cb7e" (might take a minute)
[mbed] Unpacking library build "7130f322cb7e" in "/home/user/MBED/mbed_blinky/mbed"
[mbed] Couldn't find build tools in your program. Downloading the mbed 2.0 SDK tools...
$ mbed compile -m ARCH_BLE -t GCC_ARM
Building project mbed_blinky (ARCH_BLE, GCC_ARM)
Scan: .
Scan: env
Scan: mbed
Compile [100.0%]: main.cpp
Link: mbed_blinky
Elf2Bin: mbed_blinky
+-------------------+-------+-------+------+
| Module            | .text | .data | .bss |
+-------------------+-------+-------+------+
| BUILD/ARCH_BLE    |   220 |     4 |   24 |
| [fill]            |    18 |     0 |   15 |
| [lib]/c_nano.a    |  2337 |   100 |   12 |
| [lib]/gcc.a       |  1640 |     0 |    0 |
| [lib]/mbed.a      |  1113 |     0 |   29 |
| [lib]/misc        |   220 |     8 |   28 |
| mbed/7130f322cb7e |  2963 |    12 |  208 |
| Subtotals         |  8511 |   124 |  316 |
+-------------------+-------+-------+------+
Total Static RAM memory (data + bss): 440 bytes
Total Flash memory (text + data): 8635 bytes

Image: ./BUILD/ARCH_BLE/GCC_ARM/mbed_blinky.hex

Hex file is successfully created and I have copied it to the mbed drive and the code is programmed to the target, but LED does not blink. I have even tried to create a new project and just copy main.cpp but the result is the same. For example with a command: $ mbed new mbed-classic-program --mbedlib At the end, the outcome is the same, LED does not blink.

If I create OS mbed project following output is given:

$ mbed compile -m ARCH_BLE -t GCC_ARM
Building project mbed-os-example-blinky (ARCH_BLE, GCC_ARM)
Scan: .
Scan: mbed
Scan: env
Scan: FEATURE_BLE

Could not compile for ARCH_BLE: Target does not support mbed OS 5

So I assumed this is not an option for Seeed Tiny BLE board.

After comparing hex file generated by online compiler and the one generated localy, I have observed that they are different. I guess since they are compiled with different compiler and linked with different linker, this could cause the difference. Also, that difference is localized only to the end of file (last 10% of that file).

All the required tools were installed on Ubuntu 17.10:

python 2.7.14
pip 9.0.1
git 2.14.1
hg 4.3.1
arm-none-eabi-gcc 7.2.1 (20170904, revision 255204 - added to the system PATH)
srec_cat 1.58.D001

Can somebody help with this issue I have? At least some pointers would be helpful? I am sorry in advance if I missed some topic or issue where this was already discussed, but after googling for a while I could not find the solution to this problem.

Goran Kecman

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (12 by maintainers)

Most upvoted comments

@gorankecman I’ll mark this as a bug and edit the top post to call out the detect problem as a bug.