Skip to content

mimxrt: Provide WiFi and BLE support for MIMXRT boards. #12937

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

robert-hh
Copy link
Contributor

This support uses ESP32 modules with either NINAW10 firmware or esp-hosted firmware. For MIXRT101x devices, the NINAW10 firmware is expected. For MIMXRT102x, MIMXRT105x and MIMXRT106x the esp_hosted firmware has to be used. The esp_hosted firmware is faster and has a more robust BLE support, but the MIMXRT to support it gets too larger for MIMXRT101x devices. This PR includes Pin definitions and enables WiFI and BLE for:

  • ADAFRUIT_METRO_M7_AIRLIFT
  • MIMXRT1010_EVK
  • MIMXRT1015_EVK
  • OLIMEX RT1010py
  • MIMXRT1020_EVK
  • MIMXRT1050_EVK
  • Seeed Arch Mix
  • Teensy 4.0
  • Teensy 4.1

As ESP32 device, e.g. Adafruit Airlift modules, Nina W10 modules or any generic ESP32 breakout can be used. The NINAW10 or esp_hosted firmware has to be installed to that device. Therefore there are dependencies of this device to a few other PR's to micropython-lib, especially micropython/micropython-lib#642 and micropython/micropython-lib#654. The PR micropython/mynewt-nimble#2 prevents a rare lock-up situation in the ble-nimble stack, which occurred during testing with the BLE test suite.

@robert-hh robert-hh force-pushed the mimxrt_wifi_ble branch 3 times, most recently from 235bff0 to 1f69e92 Compare November 12, 2023 16:20
@iabdalkader
Copy link
Contributor

I think you may have some really outdated changes, I didn't look at the whole PR but note that mimxrt already has working WiFi and BLE support using nimble and cyw43, I added it myself some time ago, so some of your changes duplicate things (for example see mp_bluetooth_deinit() in main.c, and port files in Makefile etc..), also nimble.mk includes the paths you added. Like I said it's already working, you just need to add support for new NICs/drivers (Nina/esp_hosted).

@robert-hh
Copy link
Contributor Author

robert-hh commented Nov 13, 2023

Thanks for the hint and maybe it's the case. The history of this PR starts earlier than the inclusion of the cyw43 support. Since you looked at it already, can you be specific about the places were things are duplicated?

Edit: I see the duplicate of deinit. And I used already earlier the mpbthciport.c file introduced with the cyw43 support.
Edit2: I know the there is support for cyw43. Only the existing boards cannot use it. The added support for NINA or esp_hosted based devices allow users to add WiFi/BLE to other boards as well.

@iabdalkader
Copy link
Contributor

Since you looked at it already, can you be specific about the places were things are duplicated?

I left a quick review, anything removed I think is duplicated.

Edit2: I know the there is support for cyw43. Only the existing boards cannot use it. The added support for NINA or esp_hosted based devices allow users to add WiFi/BLE to other boards as well.

I understand, but what I meant is: there's already working support for nimble and LWIP, in that port, which means you only need to add support for Nina/Esp hosted.

@robert-hh
Copy link
Contributor Author

Thanks for the review. I was a little bit overwhelmed by the fact that git managed to merge 3 branches with almost no conflict. But I did not check for duplicated. Still CI reports a build error: [proto_c cannot be found](make: protoc-c: Command not found). Sometimes it works.

@iabdalkader
Copy link
Contributor

Thanks for the review. I was a little bit overwhelmed by the fact that git managed to merge 3 branches

Yes it looked like a bad git merge. Anyway, I can take another look tomorrow.

Still CI reports a build error: [proto_c cannot be found](make: protoc-c: Command not found). Sometimes it works.

You must make submodules with the BOARD set, see ci_renesas_ra_board_build in tools/ci.sh

@robert-hh
Copy link
Contributor Author

robert-hh commented Nov 13, 2023

About Proto-c: It works locally. And when I do the make BOARD=xxx submodules and try to push it, there is no change to push.
Edit: I think I got it. Have to change ci.sh.

Copy link

Code size report:


@iabdalkader
Copy link
Contributor

function ci_mimxrt_build {
    make ${MAKEOPTS} -C mpy-cross
    make ${MAKEOPTS} -C ports/mimxrt BOARD=MIMXRT1020_EVK submodules
    make ${MAKEOPTS} -C ports/mimxrt BOARD=MIMXRT1020_EVK
    make ${MAKEOPTS} -C ports/mimxrt BOARD=TEENSY40 submodules
    make ${MAKEOPTS} -C ports/mimxrt BOARD=TEENSY40
}

I'm not sure why boards are built twice, but I think you need to add submodules to every build.

@iabdalkader
Copy link
Contributor

Oh okay first line checks out the submodules, in that case I'm not sure why it's failing.

@robert-hh
Copy link
Contributor Author

robert-hh commented Nov 13, 2023

Proto-c was not installed. See a few lines up. The error about proto-c is now gone, only I have to clean up the manifest.py files. But maybe not today anymore.

Copy link

codecov bot commented Nov 13, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.54%. Comparing base (0b72962) to head (5f10e49).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #12937   +/-   ##
=======================================
  Coverage   98.54%   98.54%           
=======================================
  Files         169      169           
  Lines       21889    21889           
=======================================
  Hits        21570    21570           
  Misses        319      319           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@robert-hh robert-hh force-pushed the mimxrt_wifi_ble branch 2 times, most recently from de45501 to 516ac48 Compare March 7, 2024 16:35
@robert-hh
Copy link
Contributor Author

Closing in favor of supporting instead PPP. Then the user can go for a communication suitable method.

@robert-hh robert-hh closed this Feb 17, 2025
@andrewleech
Copy link
Contributor

Hi @robert-hh other than the chain of dependencies of this PR is there anything particularly wrong with it?
Are there conflicts with the PPP work?

For context in planning on using this PR at work to add wireless networking to mimxrt platforms, PPP doesn't really help here at all.

I don't have suitable hardware set up though so haven't scheduled testing this yet.

@robert-hh
Copy link
Contributor Author

robert-hh commented Feb 18, 2025

Hi @robert-hh other than the chain of dependencies of this PR is there anything particularly wrong with it?

No. It works fine. And there should be not conflict with PPP, other than lacking PPP would not work on MIMXRT101x boards. If you think it's useful, I can reopen it. Only keeping such a large PR alive and working is quite laborious.

@robert-hh robert-hh reopened this Feb 18, 2025
@robert-hh robert-hh force-pushed the mimxrt_wifi_ble branch 2 times, most recently from 5d41c79 to 36dc348 Compare February 18, 2025 08:52
@dpgeorge
Copy link
Member

Thanks @robert-hh for this piece of work. It is worth merging, I just didn't get a chance to review it. I'll try to do that soon.

@robert-hh
Copy link
Contributor Author

@dpgeorge Thank you for your response. I had a PR for similar support at the SAMD port. I closed it, expecting that with the VFSROM support the flash space would not be sufficient any more. The WiFI only version leaves ~90k free, the WiFi+BLE variant about 5k.

@dpgeorge
Copy link
Member

Let's get this one through first, then we can consider the samd version.

Using the network.WLAN module with Pin settings defined in
mpconfigboard.h.

To allow for port specific WiFi configurations, the functions in
drivers/ninaw10/nina_wifi_bsp.c are declared as MP_WEAK.

Signed-off-by: robert-hh <robert@hammelrath.com>
Change Makefile and mpconfigport.h.
Add a port specific nina_wifi_bsp.c file, which just increases the
poll rate.

The flag for enabling NinaW10 is MICROPY_PY_NETWORK_NINAW10.

Signed-off-by: robert-hh <robert@hammelrath.com>
- MIMXRT1010_EVK
- MIMXRT1015_EVK
- ADAFRUIT Metro M7

For the *_EVK boards the pins are those used by the Adafruit Airlift
shield.

Signed-off-by: robert-hh <robert@hammelrath.com>
RTS must be low for operation.
Allow CS as alias for GPIO1.

Signed-off-by: robert-hh <robert@hammelrath.com>
And reduce the stack size for BLE.

Nibmle uses 13k of static data, increasing the .bss section. Moving the
stack or bss to OCRM is possible, but reduces the Python heap size.

Signed-off-by: robert-hh <robert@hammelrath.com>
For:
MIMXRT1010_EVK
MIMXRT1015_EVK
ADAFRUIT Metro M7
OLIMEX RT1010

Adafruit Metro M7 board:

Add the SD variant of the Adafruit Metro M7 board.
It supports WIFI/BLE as well, but at pins matching the Airlift UNO
breakout.

Olimex 1010 board:

The pins are selected in a way that they are accessible at the UEXT1
connector of the Dev board.

There is no free Pin for GPIO0. So GPIO0 must be connected with a
resistor to a Pin which is not used for FW upload and is used as
output during normal operation, e.g. SPI SCL.
The NINA FW configures GPIO0 as output during normal operation.

Signed-off-by: robert-hh <robert@hammelrath.com>
At first with the board files for MIMXRT1020 only.

MIMXRT1010 and MIMXRT1015 do not build due to insufficient RAM size.

Signed-off-by: robert-hh <robert@hammelrath.com>
- Teensy 4.0
- Teensy 4.1
- MIMXRT1050_EVK
- SEEED Arch Mix

WiFi & BLE work for Teensy 4.x and SEEED Arch Mix with the given wiring.
The Teensy 4.x wiring matches the combination of a Adafruit Feather
Airlift module with Teensy - Feather adapter.
Limited activity for MIMXRT1050, since the SPI wires are not connected.
BLE on MIMXRT1050EVK worked, with CS and MOSI of the airlift shield
hardwired to GND.

Signed-off-by: robert-hh <robert@hammelrath.com>
Instead of waiting a fixed long time for absorbing ESP32 boot messages,
just wait a shorter time for no more data to arrive

Signed-off-by: robert-hh <robert@hammelrath.com>
Inluding instructions for connecting external modules and uploading
the WLAN/BLE firmware.

Signed-off-by: robert-hh <robert@hammelrath.com>
- Makefile, main.c: Remove duplicated code and settings, which were added
  through combining several branches.
- Install the proto-c compiler in ci.sh.
- Move _dcd_data to the start of the .bss segment. This data item has
  to be 2k aligned. Moving it to the start of the segment avoids
  wasting memory.
- Remove the board's manifest.py, now that many boards support
  networking.
- Remove obsolete settings from mpconfigboard.mk files.

Signed-off-by: robert-hh <robert@hammelrath.com>
@dpgeorge dpgeorge added this to the release-1.26.0 milestone Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants