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

Allow Mbed CE to be built as an Arduino core #206

Merged
merged 6 commits into from
Jan 13, 2024

Conversation

multiplemonomials
Copy link
Collaborator

@multiplemonomials multiplemonomials commented Jan 12, 2024

Summary of changes

This PR works together with the new https://github.com/mbed-ce/ArduinoCore-mbed-ce repository. Using this PR plus that repo, one can compile an Arduino IDE compatible core for Mbed CE! All you gotta do is drop the core folder in the $HOME/Documents/Arduino/hardware/mbed-ce folder, and bam! The Arduino IDE can then compile for supported boards (currently Nano 33 BLE and RPi Pico) using Mbed CE as a backend.

Many of the patches needed for these targets already existed in Mbed from earlier efforts to keep the Arduino targets in sync, but some more still had to be added. I tried to not go completely bonkers adding changes, and just go for the minimum needed to make it compile and work.

Changes include:

  • Move mbed-target-config.h to a subfolder of CMAKE_BINARY_DIR. This makes it easier to include without picking up all of Mbed OS!
  • Merge Arduino patch which allows loading TLS certificates from the filesystem for a TLS socket. This is, I believe, more efficient than reading the file into RAM because it accesses the file directly.
  • Add mbedtls.entropy-nv-seed which allows MBEDTLS_ENTROPY_NV_SEED to be enabled using target_overrides (instead of being forced to enable it globally using macros)
  • Merge Arduino patch to change I2CSlave::read() return value.
  • Don't download greentea client if greentea testing isn't actually enabled. Why wasn't it like this before? 🤷‍♂️
  • Include mbed-target-config.h from mbed.h. This means that code external to mbed, which includes mbed.h, no longer has to have the -include mbed-target-config.h flag set up, which is convenient.
  • Fix SDBlockDevice compile error introduced by async SPI change
  • Fix adc.c missing from RPi Pico source file list, meaning that any attempt to use the ADC would cause a linker error
  • Add hardware_pio and hardware_dma libraries for RPi Pico
  • Update RPi Pico SDK importer to use regex matching. This means it won't erroneously rename functions like adc_gpio_init(). (because before it was just replacing any instance of gpio_init). The import is slower now but only I have to deal with that...
  • ARDUINO_NANO33BLE_SWD now inherits from ARDUINO_NANO33BLE (so that the correct target label is applied even in SWD mode).
  • mbed-target-config.h now contains an include guard.
  • The Mbed toolchain file now sets C11 and C++17 as the default language standards.

Impact of changes

Migration actions required

  • I2CSlave::read() now returns the number of bytes actually read. This is pretty much required in order to know how many bytes were actually sent by the master -- I don't know why it wasn't like this before!! Honestly I would be surprised if anybody was actually using this API given how broken it was.

Documentation

See ArduinoCore-mbed-ce repo.


Pull request type

[] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[X] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[X] Tests / results supplied as part of this PR

I've build and run several examples, and they work!


Reviewers


@multiplemonomials multiplemonomials merged commit 699437e into master Jan 13, 2024
9 checks passed
@multiplemonomials multiplemonomials deleted the dev/arduino-core-support branch January 13, 2024 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants