Skip to content

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.

Comment on lines 58 to 63
#if MICROPY_PY_BLUETOOTH
#include "extmod/modbluetooth.h"
#include "mpbthciport.h"
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if MICROPY_PY_BLUETOOTH
#include "extmod/modbluetooth.h"
#include "mpbthciport.h"
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs to be removed.

Comment on lines +116 to +107
#if MICROPY_PY_BLUETOOTH
mp_bluetooth_hci_init();
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if MICROPY_PY_BLUETOOTH
mp_bluetooth_hci_init();
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this still needs to be moved back up outside the soft reset loop, where it used to be.

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

@github-actions
Copy link

github-actions bot commented Nov 13, 2023

Code size report:

Reference:  lib/micropython-lib: Update submodule to latest. [2bd337e]
Comparison: mimxrt/wlan_pinout and mimxrt/Makefile: Implement review comments. [merge of 7d4177f]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt: +366112 +97.135% TEENSY40[incl +344(data) +44088(bss)]
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

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

@codecov
Copy link

codecov bot commented Nov 13, 2023

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.38%. Comparing base (2bd337e) to head (7d4177f).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #12937   +/-   ##
=======================================
  Coverage   98.38%   98.38%           
=======================================
  Files         171      171           
  Lines       22300    22300           
=======================================
  Hits        21939    21939           
  Misses        361      361           

☔ 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 and others added 16 commits December 8, 2025 16:33
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>
And remove the MP_WEAK modifiers from that file, as suggested in the
review.

Signed-off-by: robert-hh <robert@hammelrath.com>
Mostly removing duplicate or obsolete settings.

Signed-off-by: robert-hh <robert@hammelrath.com>
Allowing to disable WiFi and BLE by the value of
MICROPY_PY_NETWORK_ESP_HOSTED in a board's  mpconfigboard.mk.

Remove duplicate lines from Makefile.

Signed-off-by: robert-hh <robert@hammelrath.com>
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
docs/mimxrt/wlan_pinout.rst: Refer to NINA_FW version 2.0
ports/mimxrt/Makefile: Move config lines back to where they were.

side change: Fix two comments at Teensy mpconfigboard.h and change
the initial baudrate for MIMXRT1050_EVK.

Signed-off-by: robert-hh <robert@hammelrath.com>
@robert-hh
Copy link
Contributor Author

Micropython esp-hosted works with the v1.0.0.0.0 driver. The module used for esphosted has to provide at least 4MB flash. Therefore it does not work with the uBlox NINA-W102 modules with 2MB flash per se. The esp-hosted configuration is for a 4MB flash, including a second firmware partition for OTA. That would not fit into 2MB.
I made a version with a single partition and for 2MB flash, which starts up and connects to the AP. Tested on a SAMD51. The connection is NOT stable, but that may be due to other problems. esp_hosted seems to consume a lot of execution time, so REPL is somewhat stuttering.

@iabdalkader
Copy link
Contributor

Micropython esp-hosted works with the v1.0.0.0.0 driver

Good to know! Thanks @robert-hh

@robert-hh
Copy link
Contributor Author

robert-hh commented Dec 9, 2025

@iabdalkader There is a startup problem with esp_hosted V1.0.0.0: After calling wlan.connect(), sometimes wlan.isconnected() never returns True. But the interface is working. I can "Ping" the board and can run iperf3 with both TCP and UDP connections. I do not see this behavior with V0.0.5. This is related to the esp_hosted firmware and happens with different ports.

Edit: The same happens if a static IP is set before calling wlan.conenct() with every port, even for esp_hosted v0.0.5. wlan.isconnected() never returns True, but the device IS connected.

@robert-hh
Copy link
Contributor Author

@iabdalkader @dpgeorge After testing with esp_hosted v1.0.0.0 for a few days, I consider it as not ready for use, at least in the configuration I have determined. Besides the start-up problem noted above, it works reliably only with fast MCU's like Teensy 4.x, with slower ones and smaller RAM it locks up quite often, almost all the time when trying TCP transfer. UDP works mostly. So there is a problem in the interaction between esp module and MCU.
V0.0.5 works reliably on the tested ports, namely RP2, MIMXRT and SAMD. For the latter I have a branch, but will due to it's code size most likely not raise a PR for it.

@iabdalkader
Copy link
Contributor

Not 100% sure, but it might have something to do with the changes ESP made to the ABI/protocol after v0.0.5. We could probably support both firmwares via a config option. I'll see if we can allocate some time for this.

@robert-hh
Copy link
Contributor Author

@iabdalkader Thanks. Attached are the sdkconfig files which I used for V1.x. The SPI Pin config is for Airlift boards. But that is easy changeable.
sdkconfig_V1_000.zip

@robert-hh robert-hh marked this pull request as draft December 15, 2025 07:31
@robert-hh
Copy link
Contributor Author

robert-hh commented Dec 16, 2025

@dpgeorge I'm closing this PR. After a bit of consideration, it looks more like a source of continuous irritation than a benefit. There is no board or an add-on, where it would work off-the-shelf. In any case, the WiFi module has to be updated first, which is not a very simple step. And for both the NINA and the esp_hosted firmware the firmware versions are old. Newer firmware versions are either not available or do not work properly. So we have two components - Micropython and the Wifi module firmware - which must be kept in sync, and that will probably fail sooner that later.

@iabdalkader It may still be interesting to tell, why the v1.0.0.0 version of esp_hosted behaves strange. There are a few boards which use esp_hosted of-the-shelf, and for these it may be interesting to have an upgrade path.

@robert-hh robert-hh closed this Dec 16, 2025
@dpgeorge
Copy link
Member

@robert-hh thanks for your persistence with this and your executive decision to stop working on it.

I agree that it's pretty hard to maintain drivers (both the host and controller drivers) for a WiFi coprocessor. The required bandwidth and low latency of WiFi, along with the complexity of the protocol, makes it pretty tricky to line up all the pieces. If it were a major feature for a commercial board (eg pyboard) then we could spend time on it. But having it as an optional bonus feature for mimxrt, no one has the time for that right now.

Eventually things might improve. Eg the ESP32-P4 needs the esp_hosted firmware, and a way to upgrade it, so we might have to revisit the upgrade process at the very least.

[Side note: this is why I like the cyw43xx, because its patch firmware is relatively small and stable, is included on the host side and downloaded each time it's powered on. That makes it much easier to use and more reliable.]

@robert-hh
Copy link
Contributor Author

The esp_hosted firmware is currently used by two MP boards, the ESP32_P4 and the Arduino Nano 33 BLE. For that reason I left PR micropython/micropython-lib#642 open. There is OTA support for updating the esp_hosted firmware, but I did not try that.

B.t.w.: My P4 board complains that the esp_hosted firmware needs an upgrade, but works otherwise.

@iabdalkader
Copy link
Contributor

@iabdalkader It may still be interesting to tell, why the v1.0.0.0 version of esp_hosted behaves strange. There are a few boards which use esp_hosted of-the-shelf, and for these it may be interesting to have an upgrade path.

I will get around to working on this, maybe a few days next week. It's a work thing so will be on work hours.

@robert-hh
Copy link
Contributor Author

robert-hh commented Dec 20, 2025

I just found a different way to get a start point, which may be more recent and seems more straightforward.

  1. set up esp-idf v5.5.1 and run export.sh
  2. go to a directory of you choice and run:
idf.py create-project-from-example "espressif/esp_hosted^2.7.0:slave"
cd slave
idf.py set-target esp32  # or any other ESP32 device of your choice
idf.py menuconfig  # configure the interface, which is all now in example-configuration
idf.py build

I did not check yet whether it is all one needs, but it looks more consistent.
Edit: Already building using that path seems to be a rough ride.

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.

5 participants