Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update support for rp2040 #14

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e2da071
Update drivers
sabas1080 Jul 16, 2022
f8fad9c
Update Libraries
sabas1080 Jul 16, 2022
e941c0d
add patches
sabas1080 Jul 16, 2022
9e74e91
add variant rp2040
sabas1080 Jul 16, 2022
4544b8d
Update variant nano33ble
sabas1080 Jul 16, 2022
cbc1e9e
update nano33ble
sabas1080 Jul 16, 2022
16673cf
update files
sabas1080 Jul 16, 2022
04ccab2
Update Core
sabas1080 Jul 16, 2022
c97fcbe
Update Arduino API
sabas1080 Jul 16, 2022
1a6812a
update compile flags
sabas1080 Jul 16, 2022
b40244d
Update uploaders
sabas1080 Jul 16, 2022
39cfde9
Update BASTBLE
sabas1080 Jul 16, 2022
9496321
Nano33BLE more
sabas1080 Jul 16, 2022
979bd15
Fix variant BASTBLE
sabas1080 Jul 16, 2022
4f024ed
Fix variant FRONTIER
sabas1080 Jul 16, 2022
098dd11
Fix Variant RAK4631
sabas1080 Jul 16, 2022
80eeddd
Fix Variant RAK5010
sabas1080 Jul 16, 2022
e5a331e
Fix digital pins RAK4631
sabas1080 Jul 16, 2022
2c012cc
fix board.txt for NRF
sabas1080 Jul 16, 2022
df11700
Welcome HunterCat NFC 2040
sabas1080 Jul 16, 2022
3b376d7
Welcome BomberCat!!
sabas1080 Jul 16, 2022
7cc67af
patch for NRF52840 temporal
sabas1080 Jul 17, 2022
5766a12
fix define bombercat board.txt
sabas1080 Jul 17, 2022
6c2c3c3
Add CATWAN Usb Stick rp2040
sabas1080 Jul 17, 2022
16c7c38
remove nina pins for variant without NINA
sabas1080 Jul 17, 2022
9942264
Update flash size
sabas1080 Jul 19, 2022
396f1e0
fix core EC
sabas1080 Jul 29, 2022
a3ab585
Merge pull request #15 from ElectronicCats/fixcorerror
sabas1080 Aug 29, 2022
437bc47
Update analog pins bombercat
sabas1080 Aug 29, 2022
4bde882
Add CatWAN USB Stick 2040
sabas1080 Aug 29, 2022
7bba147
add board.txt usb stick rp2040
sabas1080 Aug 29, 2022
6b6faf8
memory size bombercat
sabas1080 Aug 29, 2022
4a54f3f
Add HunterCat NFC RP2040
sabas1080 Aug 29, 2022
9f1d11d
fix board txt
sabas1080 Aug 29, 2022
30b3c32
update compile examples
sabas1080 Aug 29, 2022
1f8bbab
update example CI PDM
sabas1080 Aug 29, 2022
e321c1b
update examples compile
sabas1080 Aug 29, 2022
5d3476d
add new examples
sabas1080 Aug 29, 2022
246bea8
Update HunterCat NFC
sabas1080 Aug 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
31 changes: 17 additions & 14 deletions .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,37 @@ jobs:

matrix:
board:
- fqbn: electroniccats:mbed:bastble
- fqbn: electroniccats:mbed:bast_frontier
- fqbn: electroniccats:mbed:rak_wistrio5010
- fqbn: electroniccats:mbed:wisblock_rak4631
- fqbn: electroniccats:mbed:bombercat
- fqbn: electroniccats:mbed:huntercatnfc_2040
- fqbn: electroniccats:mbed:catwan_usb_stick_2040

# compile only the examples compatible with each board
include:
- board:
fqbn: electroniccats:mbed:bastble
additional-sketch-paths: '"libraries/PDM" "libraries/ThreadDebug"'
fqbn: electroniccats:mbed:bombercat
additional-sketch-paths: |
- libraries/USBHID
- ~/Arduino/libraries/WiFiNINA
- board:
fqbn: electroniccats:mbed:bast_frontier
additional-sketch-paths: '"libraries/PDM" "libraries/ThreadDebug"'
fqbn: electroniccats:mbed:huntercatnfc_2040
additional-sketch-paths: |
- libraries/USBHID
- board:
fqbn: electroniccats:mbed:rak_wistrio5010
additional-sketch-paths: '"libraries/ThreadDebug"'
- board:
fqbn: electroniccats:mbed:wisblock_rak4631
additional-sketch-paths: '"libraries/ThreadDebug"'
fqbn: electroniccats:mbed:catwan_usb_stick_2040
additional-sketch-paths: |
- libraries/USBHID

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Compile examples
uses: arduino/compile-sketches@main
uses: arduino/compile-sketches@v1
with:
fqbn: ${{ matrix.board.fqbn }}
libraries: |
- name: WiFiNINA
${{ matrix.additional-libraries }}
platforms: |
# Use Board Manager to install the latest release of Arduino mbed Boards to get the toolchain
- source-url: "https://electroniccats.github.io/Arduino_Boards_Index/package_electroniccats_index.json"
Expand Down
4 changes: 0 additions & 4 deletions .gitignore

This file was deleted.

9 changes: 4 additions & 5 deletions .mbedignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ cores/arduino/mbed/*
cores/arduino/api/Stream.h
cores/arduino/api/deprecated/Stream.h
cores/arduino/main.cpp
variants/*mbed_config.h
variants/E*
variants/M*
libraries/micro*
libraries/WiFi*
libraries/openamp*
cores/arduino/USB/*
variants/*
libraries/*
127 changes: 80 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,83 +1,116 @@
# Electronic Cats Arduino Core for mbed enabled devices
# Arduino Core for mbed enabled devices

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

## Features Electronic Cats version Vs Arduino Original version
## 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."

- Support for [Adafruit Bootloader UF2](https://github.com/ElectronicCats/Adafruit_nRF52_Bootloader) only MBR Bootloader (Unsupport SoftDevice)
- Upload firmware via [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil)
**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).

## Nice features from Arduino
## Installation

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

## Easy Install
```bash
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.

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:
```bash
git clone [email protected]:arduino/ArduinoCore-API
```

https://electroniccats.github.io/Arduino_Boards_Index/package_electroniccats_index.json
### Update the `api` symlink

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

- 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.
### Test things out

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

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

## Manual Installation
*This procedure does not automatically install the required ARM compiler toolchain.*

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

```bash
mkdir -p $sketchbook/hardware/arduino
cd $sketchbook/hardware/arduino
git clone [email protected]:arduino/ArduinoCore-mbed mbed
```
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.

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

```bash
git clone [email protected]:arduino/ArduinoCore-API -b namespace_arduino
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
```

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`
In this case `-a` applies all the patches from `patches` folder into a mainline `mbed-os` tree, and `-g` restores the debug info.

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

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

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

## Adding an mbed target
### Selecting a different Mbed OS tree

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.
Actions marked as TODO must be executed manually.
```
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](https://arduino.github.io/arduino-cli/latest/platform-specification/#core-variants))

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

### How to build a debug version of the Arduino mbed libraries
* Modify `mbed-os-to-arduino `
```diff
mbed_compile () {
- PROFILE_FLAG=""
if [ x"$PROFILE" != x ]; then
PROFILE_FLAG=--profile="$ARDUINOVARIANT"/conf/profile/$PROFILE.json
export PROFILE=-${PROFILE^^}
+ else
+ export PROFILE="-DEBUG"
+ PROFILE_FLAG="--profile=debug"
fi
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`](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.
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.


Loading