Skip to content

Commit 33b5b28

Browse files
committed
Modernize readme
1 parent 163b825 commit 33b5b28

File tree

1 file changed

+50
-17
lines changed

1 file changed

+50
-17
lines changed

README.md

+50-17
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,63 @@ fork/exec /bin/arm-none-eabi-g++: no such file or directory
3737
```
3838
To install ARM build tools, use the `Boards Manager` option in the Arduino IDE to add the `Arduino mbed-enabled Boards` package.
3939

40+
## mbed-os-to-arduino script
4041

41-
## Adding an mbed target
42+
The backbone of the packaging process is 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.
4243

43-
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 the `BOARDNAME` and `ARDUINOCORE` env variables.
44-
Actions marked as TODO must be executed manually.
44+
It can be used for a variety of tasks including:
45+
46+
**Recompiling libmbed with source level debug support**
47+
48+
```
49+
cd $sketchbook/hardware/arduino-git/mbed
50+
./mbed-os-to-arduino -a -g PORTENTA_H7_M7:PORTENTA_H7_M7
51+
```
52+
53+
In this case `-a` applies all the patches from `patches` folder into a mainline `mbed-os` tree, and `-g` restores the debug info.
54+
55+
**Selecting a different optimization profile**
56+
57+
```
58+
cd $sketchbook/hardware/arduino-git/mbed
59+
PROFILE=release ./mbed-os-to-arduino -a NANO_RP2040_CONNECT:NANO_RP2040_CONNECT
60+
```
61+
62+
The `PROFILE` environment variable tunes the compilation profiles (defaults to `DEVELOP`). Other available profiles are `DEBUG` and `RELEASE`.
63+
64+
**Selecting a different mbed-os tree**
4565

46-
**Minimum Example**:
4766
```
4867
cd $sketchbook/hardware/arduino-git/mbed
49-
./mbed-os-to-arduino -r /home/alex/projects/arduino/cores/mbed-os-h747 PORTENTA_H7_M7:PORTENTA_H7_M7
68+
./mbed-os-to-arduino -r /path/to/my/mbed-os-fork NICLA_VISION:NICLA_VISION
5069
```
5170

52-
### How to build a debug version of the Arduino mbed libraries
53-
* Modify `mbed-os-to-arduino `
54-
```diff
55-
mbed_compile () {
56-
- PROFILE_FLAG=""
57-
if [ x"$PROFILE" != x ]; then
58-
PROFILE_FLAG=--profile="$ARDUINOVARIANT"/conf/profile/$PROFILE.json
59-
export PROFILE=-${PROFILE^^}
60-
+ else
61-
+ export PROFILE="-DEBUG"
62-
+ PROFILE_FLAG="--profile=debug"
63-
fi
71+
`-r` flag allows using a custom `mbed-os` fork in place of the mainline one; useful during new target development.
72+
73+
**Adding a new target (variant)**
74+
75+
Adding a target is a mostly automatic procedure.
76+
77+
For boards already supported by `mbed-os` , the bare minimum is
78+
79+
```
80+
cd $sketchbook/hardware/arduino-git/mbed
81+
mkdir -p variants/$ALREADY_SUPPORTED_BOARD_NAME/{libs,conf}
82+
./mbed-os-to-arduino $ALREADY_SUPPORTED_BOARD_NAME:$ALREADY_SUPPORTED_BOARD_NAME
83+
# for example, to create a core for LPC546XX
84+
# mkdir -p variants/LPC546XX/{libs,conf}
85+
# ./mbed-os-to-arduino LPC546XX:LPC546XX
86+
```
87+
88+
This will produce almost all the files needed. To complete the port, add the board specifications to `boards.txt` (giving it an unique name) and provide `pins_arduino.h` and `variants.cpp` in `variants/$ALREADY_SUPPORTED_BOARD_NAME` folder.
89+
Feel free to take inspirations from the existing variants :)
90+
91+
For boards not supported by mainline `mbed-os`, the same applies but you should provide the path of your `mbed-os` fork
92+
93+
```
94+
cd $sketchbook/hardware/arduino-git/mbed
95+
mkdir -p variants/$BRAND_NEW_BOARD_NAME/{libs,conf}
96+
./mbed-os-to-arduino -r /path/to/mbed-os/fork/that/supports/new/board $BRAND_NEW_BOARD_NAME:$BRAND_NEW_BOARD_NAME
6497
```
6598

6699
## Using this core as an mbed library

0 commit comments

Comments
 (0)