Skip to content

Commit a3ab585

Browse files
authored
Merge pull request #15 from ElectronicCats/fixcorerror
fix core EC
2 parents 9942264 + 396f1e0 commit a3ab585

File tree

4,927 files changed

+40487
-2097043
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,927 files changed

+40487
-2097043
lines changed

.gitignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 80 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,116 @@
1-
# Electronic Cats Arduino Core for mbed enabled devices
1+
# Arduino Core for mbed enabled devices
22

33
The repository contains the Arduino APIs and IDE integration files targeting a generic mbed-enabled board
44

5-
## Features Electronic Cats version Vs Arduino Original version
5+
## FAQ
6+
### Source-Code Level Debugging
7+
**Question**: "I want to debug my ArduinoCore-mbed based sketch using traditional debugging tools, i.e. gdb via SWD interface. However, the debugger is unable to locate the sources for all files, particular the mbed-os files."
68

7-
- Support for [Adafruit Bootloader UF2](https://github.com/ElectronicCats/Adafruit_nRF52_Bootloader) only MBR Bootloader (Unsupport SoftDevice)
8-
- Upload firmware via [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil)
9+
**Answer**: This is due to the fact that we pre-compile the mbed-os code into a static library `libmbed.a`. Information on how to recompile `libmbed.a` for source code debugging can be found [here](#recompiling-libmbed-with-source-level-debug-support). The [Arduino Documentation](https://docs.arduino.cc/) also contains articles explaining how to debug via [Segger J-Link](https://docs.arduino.cc/tutorials/portenta-breakout/breakout-jlink-setup) and [Lauterbach TRACE32](https://docs.arduino.cc/tutorials/portenta-h7/lauterbach-debugger).
910

10-
## Nice features from Arduino
11+
## Installation
1112

12-
- Based in Arduino mbedOS
13-
- Support library [ArduinoBLE](https://github.com/arduino-libraries/ArduinoBLE)
14-
- Support Library Arduino Tensorflow Lite
13+
### Clone the repository in `$sketchbook/hardware/arduino-git`
1514

16-
## Easy Install
15+
```bash
16+
mkdir -p $sketchbook/hardware/arduino-git
17+
cd $sketchbook/hardware/arduino-git
18+
git clone git@github.com:arduino/ArduinoCore-mbed mbed
19+
```
20+
21+
### Clone https://github.com/arduino/ArduinoCore-API into a directory of your choice.
1722

18-
To add board support for our products, start Arduino and open the Preferences window (**File** > **Preferences**). Now copy and paste the following URL into the 'Additional Boards Manager URLs' input field:
23+
```bash
24+
git clone git@github.com:arduino/ArduinoCore-API
25+
```
1926

20-
https://electroniccats.github.io/Arduino_Boards_Index/package_electroniccats_index.json
27+
### Update the `api` symlink
2128

29+
Create a symlink to `ArduinoCore-API/api` in `$sketchbook/hardware/arduino-git/mbed/cores/arduino`.
2230

23-
- If there is already an URL from another manufacturer in that field, click the button at the right end of the field. This will open an editing window allowing you to paste the above URL onto a new line.
31+
### Test things out
2432

25-
- Press the "OK" button.
26-
- Open the "boards manager" that is in tools --> Board --> board manager.
27-
- Now write "Electronic Cats" (without quotes) in the search bar.
28-
- Click in install, jus wait to finish to install and only close the window.
33+
Open the Arduino IDE.
2934

35+
You should now see three new targets under the `MBED boards` label.
3036

31-
## Manual Installation
37+
*This procedure does not automatically install the required ARM compiler toolchain.*
3238

33-
Clone the repository in `$sketchbook/hardware/arduino`
39+
If the toolchain is missing, you'll see errors like this when you try to build for an mbed-os enabled board.:
3440

35-
```bash
36-
mkdir -p $sketchbook/hardware/arduino
37-
cd $sketchbook/hardware/arduino
38-
git clone git@github.com:arduino/ArduinoCore-mbed mbed
3941
```
42+
fork/exec /bin/arm-none-eabi-g++: no such file or directory
43+
```
44+
To install ARM build tools, use the `Boards Manager` option in the Arduino IDE to add the `Arduino mbed-enabled Boards` package.
4045

41-
Then clone https://github.com/arduino/ArduinoCore-API in a directory at your choice. Checkout `namespace_arduino` branch.
46+
## mbed-os-to-arduino script
4247

43-
```bash
44-
git clone git@github.com:arduino/ArduinoCore-API -b namespace_arduino
48+
The backbone of the packaging process is the https://github.com/arduino/ArduinoCore-mbed/blob/master/mbed-os-to-arduino script. It basically compiles a blank Mbed OS project for any supported target board, recovering the files that will be needed at compile time and copying them to the right location.
49+
50+
It can be used for a variety of tasks including:
51+
52+
### Recompiling libmbed with source level debug support
53+
54+
```
55+
cd $sketchbook/hardware/arduino-git/mbed
56+
./mbed-os-to-arduino -a -g PORTENTA_H7_M7:PORTENTA_H7_M7
4557
```
4658

47-
Remove the symlink to `api` you can find in `$sketchbook/hardware/arduino/mbed/cores/arduino` and replace it with a symlink to `ArduinoCore-API/api`
59+
In this case `-a` applies all the patches from `patches` folder into a mainline `mbed-os` tree, and `-g` restores the debug info.
4860

49-
Open Arduino IDE; you should now see three new targets under `MBED boards` label
61+
### Selecting a different optimization profile
5062

51-
## Supported boards
63+
```
64+
cd $sketchbook/hardware/arduino-git/mbed
65+
PROFILE=release ./mbed-os-to-arduino -a NANO_RP2040_CONNECT:NANO_RP2040_CONNECT
66+
```
5267

53-
* [BastBLE low cost development board](https://www.electroniccats.com)
54-
* [Arduino Nano 33 BLE ](https://store.arduino.cc/usa/nano-33-ble-sense)
68+
The `PROFILE` environment variable tunes the compilation profiles (defaults to `DEVELOP`). Other available profiles are `DEBUG` and `RELEASE`.
5569

56-
## Adding an mbed target
70+
### Selecting a different Mbed OS tree
5771

58-
Adding a target is a mostly automatic procedure that involves running https://github.com/arduino/ArduinoCore-mbed/blob/master/mbed-os-to-arduino after setting `BOARDNAME` and `ARDUINOCORE` env variables.
59-
Actions marked as TODO must be executed manually.
72+
```
73+
cd $sketchbook/hardware/arduino-git/mbed
74+
./mbed-os-to-arduino -r /path/to/my/mbed-os-fork NICLA_VISION:NICLA_VISION
75+
```
76+
77+
`-r` flag allows using a custom `mbed-os` fork in place of the mainline one; useful during new target development.
78+
79+
### Adding a new target ([core variant](https://arduino.github.io/arduino-cli/latest/platform-specification/#core-variants))
6080

61-
**Minimum Example**: `./mbed-os-to-arduino -r /home/alex/projects/arduino/cores/mbed-os-h747 ENVIE_M7:ENVIE_M7`
81+
Adding a target is a mostly automatic procedure.
6282

63-
### How to build a debug version of the Arduino mbed libraries
64-
* Modify `mbed-os-to-arduino `
65-
```diff
66-
mbed_compile () {
67-
- PROFILE_FLAG=""
68-
if [ x"$PROFILE" != x ]; then
69-
PROFILE_FLAG=--profile="$ARDUINOVARIANT"/conf/profile/$PROFILE.json
70-
export PROFILE=-${PROFILE^^}
71-
+ else
72-
+ export PROFILE="-DEBUG"
73-
+ PROFILE_FLAG="--profile=debug"
74-
fi
83+
For boards already supported by Mbed OS, the bare minimum is:
84+
85+
```
86+
cd $sketchbook/hardware/arduino-git/mbed
87+
mkdir -p variants/$ALREADY_SUPPORTED_BOARD_NAME/{libs,conf}
88+
./mbed-os-to-arduino $ALREADY_SUPPORTED_BOARD_NAME:$ALREADY_SUPPORTED_BOARD_NAME
89+
# for example, to create a core for LPC546XX
90+
# mkdir -p variants/LPC546XX/{libs,conf}
91+
# ./mbed-os-to-arduino LPC546XX:LPC546XX
7592
```
7693

94+
This will produce almost all the files needed. To complete the port, add the board specifications to [`boards.txt`](https://arduino.github.io/arduino-cli/latest/platform-specification/#boardstxt) (giving it a unique ID) and provide `pins_arduino.h` and `variants.cpp` in `variants/$ALREADY_SUPPORTED_BOARD_NAME` folder.
95+
Feel free to take inspirations from the existing variants :)
96+
97+
For boards not supported by mainline Mbed OS, the same applies but you should provide the path of your Mbed OS fork
98+
99+
```
100+
cd $sketchbook/hardware/arduino-git/mbed
101+
mkdir -p variants/$BRAND_NEW_BOARD_NAME/{libs,conf}
102+
./mbed-os-to-arduino -r /path/to/mbed-os/fork/that/supports/new/board $BRAND_NEW_BOARD_NAME:$BRAND_NEW_BOARD_NAME
103+
```
104+
105+
### Customizing Mbed OS build without modifying the code
106+
107+
Most Mbed OS defines can be tuned using a project file called `mbed_app.json` . In case you need to tune a build you can add that file to your variant's `conf` folder. One example is https://github.com/arduino/ArduinoCore-mbed/blob/master/variants/PORTENTA_H7_M7/conf/mbed_app.json .
108+
Providing an invalid json or replacing a non-existing property will make the build fail silently, so it's always better to validate that file with a standard Mbed OS project.
109+
110+
77111
## Using this core as an mbed library
78112

79113
You can use this core as a standard mbed library; all APIs are under `arduino` namespace (so they must be called like `arduino::digitalWrite()` )
80114

81115
The opposite is working as well; from any sketch you can call mbed APIs by prepending `mbed::` namespace.
82116

83-

0 commit comments

Comments
 (0)