Go to file
Gary Kim 256f728dfa add api 2022-12-13 01:09:17 -05:00
.github/workflows Add prerequisite library for Nicla GH action 2022-07-15 09:57:13 +02:00
bootloaders Portenta: update bootloaders to v24 2022-09-28 19:05:00 +02:00
cores/arduino add api 2022-12-13 01:09:17 -05:00
drivers Nicla Vision: add windows driver 2022-03-07 11:19:36 +01:00
extras Merge pull request #533 from pennam/remove-unused-imgtool 2022-08-23 14:33:05 +02:00
libraries Merge pull request #572 from pennam/wifi-fw-version 2022-12-12 16:10:27 +01:00
patches Merge pull request #571 from Rocketct/master 2022-12-12 15:51:23 +01:00
variants Recompile variants 2022-12-12 18:01:38 +01:00
.gitignore Add .development files to gitignore 2020-05-18 16:54:00 +02:00
.mbedignore Restore functionality as mbed library 2021-04-14 17:25:49 +02:00
README.md Let's add some cross-links to docs.arduino.cc . 2022-06-09 10:34:53 +02:00
bfg_nano33ble.sh bfg: forget files bigger than 50M 2019-07-31 12:51:26 +02:00
boards.txt Call objcopy.postobjcopy only when needed 2022-07-21 11:51:30 +02:00
edge.variables Add Edge family for packaging 2021-04-06 18:18:31 +02:00
full.variables Add PortentaX8 to full package distribution 2022-05-10 18:18:22 +02:00
mbed-os-to-arduino mbed-os-to-arduino: fix 7aff1a998 for different shells 2022-12-12 17:52:32 +01:00
mbed_lib.json Fix ARDUINO_AS_MBED_LIBRARY usage 2019-07-25 16:47:24 +02:00
nano.variables Add MLC library to packager script 2022-05-11 09:54:44 +02:00
nicla.variables Add MLC library to packager script 2022-05-11 09:54:44 +02:00
package.json add package.json 2022-12-13 01:00:19 -05:00
package.sh Fix Portenta packaging script 2021-09-23 15:20:09 +02:00
package_full.sh Release 3.4.1 2022-10-20 15:07:36 +02:00
platform.txt Call objcopy.postobjcopy only when needed 2022-07-21 11:51:30 +02:00
portenta.variables Add Himax_HM0360 to Portenta bundled libs 2022-09-28 10:36:46 +02:00
post_install.bat Add PortentaH7 bootloader drivers 2020-03-30 11:09:28 +02:00
post_install.sh RP2040: add post_install linux script 2021-03-23 10:28:11 +01:00
programmers.txt Added rules for pluggable discoveries and monitors 2021-10-14 18:05:55 +02:00
rp2040.variables Improve packager script 2021-04-08 11:45:35 +02:00

README.md

Arduino Core for mbed enabled devices

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

FAQ

Source-Code Level Debugging

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."

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. The Arduino Documentation also contains articles explaining how to debug via Segger J-Link and Lauterbach TRACE32.

Installation

Clone the repository in $sketchbook/hardware/arduino-git

mkdir -p $sketchbook/hardware/arduino-git
cd $sketchbook/hardware/arduino-git
git clone git@github.com:arduino/ArduinoCore-mbed mbed

Clone https://github.com/arduino/ArduinoCore-API into a directory of your choice.

git clone git@github.com:arduino/ArduinoCore-API

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

Test things out

Open the Arduino IDE.

You should now see three new targets under the MBED boards label.

This procedure does not automatically install the required ARM compiler toolchain.

If the toolchain is missing, you'll see errors like this when you try to build for an mbed-os enabled board.:

fork/exec /bin/arm-none-eabi-g++: no such file or directory

To install ARM build tools, use the Boards Manager option in the Arduino IDE to add the Arduino mbed-enabled Boards package.

mbed-os-to-arduino script

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.

It can be used for a variety of tasks including:

Recompiling libmbed with source level debug support

cd $sketchbook/hardware/arduino-git/mbed
./mbed-os-to-arduino -a -g PORTENTA_H7_M7:PORTENTA_H7_M7

In this case -a applies all the patches from patches folder into a mainline mbed-os tree, and -g restores the debug info.

Selecting a different optimization profile

cd $sketchbook/hardware/arduino-git/mbed
PROFILE=release ./mbed-os-to-arduino -a NANO_RP2040_CONNECT:NANO_RP2040_CONNECT

The PROFILE environment variable tunes the compilation profiles (defaults to DEVELOP). Other available profiles are DEBUG and RELEASE.

Selecting a different Mbed OS tree

cd $sketchbook/hardware/arduino-git/mbed
./mbed-os-to-arduino -r /path/to/my/mbed-os-fork NICLA_VISION:NICLA_VISION

-r flag allows using a custom mbed-os fork in place of the mainline one; useful during new target development.

Adding a new target (core variant)

Adding a target is a mostly automatic procedure.

For boards already supported by Mbed OS, the bare minimum is:

cd $sketchbook/hardware/arduino-git/mbed
mkdir -p variants/$ALREADY_SUPPORTED_BOARD_NAME/{libs,conf}
./mbed-os-to-arduino $ALREADY_SUPPORTED_BOARD_NAME:$ALREADY_SUPPORTED_BOARD_NAME
# for example, to create a core for LPC546XX
# mkdir -p variants/LPC546XX/{libs,conf}
# ./mbed-os-to-arduino LPC546XX:LPC546XX

This will produce almost all the files needed. To complete the port, add the board specifications to boards.txt (giving it a unique ID) and provide pins_arduino.h and variants.cpp in variants/$ALREADY_SUPPORTED_BOARD_NAME folder. Feel free to take inspirations from the existing variants :)

For boards not supported by mainline Mbed OS, the same applies but you should provide the path of your Mbed OS fork

cd $sketchbook/hardware/arduino-git/mbed
mkdir -p variants/$BRAND_NEW_BOARD_NAME/{libs,conf}
./mbed-os-to-arduino -r /path/to/mbed-os/fork/that/supports/new/board $BRAND_NEW_BOARD_NAME:$BRAND_NEW_BOARD_NAME

Customizing Mbed OS build without modifying the code

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 . 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.

Using this core as an mbed library

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

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