Coder Social home page Coder Social logo

o-gent / arduinocore-mbed Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arduino/arduinocore-mbed

0.0 0.0 0.0 770.56 MB

Shell 0.03% JavaScript 0.05% C++ 10.33% Python 0.01% C 89.45% Go 0.02% Assembly 0.02% Logos 0.06% Processing 0.01% CSS 0.01% Makefile 0.01% HTML 0.01% CMake 0.01% Batchfile 0.01%

arduinocore-mbed's Introduction

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

Note:

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

mkdir -p $sketchbook/hardware/arduino-git
cd $sketchbook/hardware/arduino-git
git clone [email protected]:arduino/ArduinoCore-mbed mbed

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

git clone [email protected]:arduino/ArduinoCore-API

Update the api symlink

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. This script is compatible only with Linux. If you are using macOS, use the https://github.com/arduino/ArduinoCore-mbed/blob/master/mbed-os-to-arduino-macos script.

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.

arduinocore-mbed's People

Contributors

facchinm avatar sebromero avatar pennam avatar giulcioffi avatar leonardocavagnis avatar adamgreen avatar manchoz avatar aentinger avatar iabdalkader avatar polldo avatar per1234 avatar umbynos avatar cvejlbo avatar rocketct avatar jandrassy avatar cmaglie avatar alrvid avatar maxpayne86 avatar alessandromrc avatar aliphys avatar hpssjellis avatar pnndra avatar kisvegabor avatar dcuartielles avatar trik avatar sandeepmistry avatar d-a-v avatar marqdevx avatar simonfj20 avatar tttapa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.