-
Can someone please give me advice/instructions on how to load Micropython onto the Adafruit Feather nRF52840? There are no instructions at https://micropython.org/download/FEATHER52/. I've used urf2conv.py / uf2families.json and the nrf/FEATERH52 micropython v1.23.0 hex to make a uf2-compatible file, firmware.uf2.zip. But when I dragged it onto the UF2 bootloader folder, it failed. The board serial port disappeared, and when I rebooted it, I saw that this method erased the SoftDevice. The UF2 Bootloader version is 0.9.0. I needed to re-load the SoftDevice (S140 6.1.1) using the Arduino IDE onto the board to flash Circuitpython onto it. But I'd like to load it with Micropython instead. I'd appreciate instructions/advice. I'm using a Mac OS 12.6. Thank you, Jay |
Beta Was this translation helpful? Give feedback.
Replies: 18 comments 18 replies
-
Yes the nrf port hasn't had as much development as some others so gaps in docs like this are common. Many of the default builds for nrf generally don't include SD support at all so flash straight over it looks you saw. It can be recompiled for SD at which point the SD can be flashed automatically too: It would certainly be helpful if the uf2 conversion could be done automatically for boards like this that need it by default, that would be a worthwhile addition to the Makefile. |
Beta Was this translation helpful? Give feedback.
-
I had the same/similar problem. See this discussion. |
Beta Was this translation helpful? Give feedback.
-
If the board uses the Adafruit UF2 Bootloader with SoftDevice (S140 6.1.1) and you convert the firmware.hex with urf2conv.py If uf2conv.py does not report 0x26000 linking is not correct. I had a similar problem with a Supermini nrf52840 an solved it by adding |
Beta Was this translation helpful? Give feedback.
-
Thank you for all the suggestions! It is taking me a while to digest them, as I do not have experience in making micropython binary. I have worked primarily with micropython on the ESP32 and relied on the kind micropython builds made by others and their easy loading using esptool. These are my first tentative steps in building micropython using the Mac... Thank you, jkorte-dev! I tried your suggestion - the Adafruit Feather nRF2 express board has a UF2 Bootloader 0.9.0 with SoftDevice S140 6.1.1 - using the indicated uf2conv.py instruction with the FEATHER52-20240602-v1.23.0.hex build. But Terminal reported the resulting uf2 start address at 0x0 and not 0x26000. So the linking is probably not correct as you indicated. By any chance, can I have a zip copy of your firmware.uf2 file just to test whether it can load onto the device? If it does, then I'll do a deep dive into how to build microsoft with the instructions you all mentioned. |
Beta Was this translation helpful? Give feedback.
-
The micropython firmware you tried is for the nRF528320 version of the Feather (Adafruit Feather nRF52). I have overseen that. Here you can find a build for a nrRF52840 board using UF2 Bootloader 0.9.0 with SoftDevice S140: |
Beta Was this translation helpful? Give feedback.
-
Thank you! You are right, its a nRF52840 version of the feather - https://www.adafruit.com/product/4062 . |
Beta Was this translation helpful? Give feedback.
-
I am happy to hear that you had success loading the firmware. The Neopixel Pin on your board is P0.16 which resolves to CPU Pin 16. |
Beta Was this translation helpful? Give feedback.
-
Thank you, jkorte. I can toggle the blue led but I am unable to fire the neopixel or toggle the red led on the Adafruit nRF52840 express. Below is my script and I've attached the pin mappings for the board. Do you have suggestions? Should I more this to a new discussion? J # Test NeoPixel illumination on Adafruit nRF52840 Express Feather
# running v1.24.0-preview.51.g91717a4f9.dirty
from machine import Pin
from neopixel import NeoPixel
import time
# ESP8226-style
# docs.micropython.org/en/latest/esp8266/tutorial/neopixel.html
pixel = NeoPixel(Pin(16, Pin.OUT), 1)
pixel[0] = (255, 0, 0)
pixel.write()
# latest style
# docs.micropython.org/en/latest/library/neopixel.html#output-methods
# bbp is 3 for RGB LEDs
# timing is 1 for 800kHz LEDs
pixel1 = NeoPixel(Pin(16, Pin.OUT), bpp=3, timing=1)
pixel1[0] = (255, 0, 0)
pixel1.write()
# Result: No illumination
# timing is 1 for 400kHz LEDs
pixel2 = NeoPixel(Pin(16, Pin.OUT), 3, 0)
pixel2[0] = (255, 0, 0)
pixel2.write()
# Result: No illumination
# Test Blue LED illumination
# Pin 42 / P1.10
blue_led = Pin(42, Pin.OUT)
blue_led.value(1)
time.sleep(4)
blue_led.value(0)
# Result: blue led illuminates
# Test Red LED illumination
# Pin 47 / P1.15
red_led = Pin(47, Pin.OUT)
red_led.value(1)
time.sleep(4)
red_led.value(0)
# Result: ValueError: not a valid pin identifier |
Beta Was this translation helpful? Give feedback.
-
Hi @jkorte-dev and @JDRBoston, I've been playing around with the Adafruit Feather nRF52840 Express and haven't been able to get it working. In short; as soon as I upload the uf2 file I can no longer see the device (ls /dev). To build the uf2 file I download the bin file (https://micropython.org/download/FEATHER52/) and compile it using If I upload @jkorte-dev pre-compiled file it works well. Do you perhaps know of anything else I can try. Edit: What's interesting @jkorte-dev is when I upload your "micropython-NRF52840-supermini-v1.24.0-preview.uf2" the port is renamed to tty.usbmodem0000000000001 and is detectable and works; however, when I upload "micropython-NRF52840-supermini-s140-v1.24.0-preview.uf2" I am unable to detect the device after uploading the firmware. |
Beta Was this translation helpful? Give feedback.
-
I have checked my repo. The pin definitions have already been extended for the Adafruit Feather nRF52840 Express. https://docs.micropython.org/en/latest/develop/gettingstarted.html#compile-and-build-the-code and than follow the instructions from my README.md https://github.com/jkorte-dev/micropython-board-NRF52840 You do not need run uf2conv.py manually, as it is included in the build process. If you use a Mac please let my know. There are some pit falls. |
Beta Was this translation helpful? Give feedback.
-
OK, then I recommend using xPack GNU Arm Embedded GCC https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/tag/v14.2.1-1.1 the download script for the bluetooth drivers for the nrf port does do not work on Mac because usually Don't forget to read https://github.com/micropython/micropython/blob/master/ports/nrf/README.md |
Beta Was this translation helpful? Give feedback.
-
Thanks @jkorte-dev. One aspect I can't grasp is the pin assignment. I had a look at CircuitPython's Repo(https://github.com/adafruit/circuitpython/tree/main/ports/nordic/boards/feather_nrf52840_express) to see if I can get a better understanding. If I compare their pinouts to the MDBT50Q (SoC on the Adafruit NRF52840 express) footprint it makes sense, however, if I do the same for micropython pins I can't figure out how it's allocated. So my question is; when generating a new build, everything remains the same except for the board files which include the "pins" file and two "mpconfigboard" files? |
Beta Was this translation helpful? Give feedback.
-
@jkorte-dev, make sense thank you. So what I've done is the following; with the help of chatGPT I created a new board with the following files: board.json
mpconfigboard.h
#define MICROPY_PY_MACHINE_UART (1) #define MICROPY_HW_ENABLE_RNG (1) #define MICROPY_HW_HAS_LED (1) #define MICROPY_HW_LED1 (13) // LED1 // UART1 config // SPI0 config #define MICROPY_HW_PWM0_NAME "PWM0" #define HELP_TEXT_BOARD_LED "1,2"` mpconfigboard.mk NRF_DEFINES += -DNRF52840_XXAA MICROPY_VFS_LFS2 = 1` pins.csv and I used the following steps to create the uf2 file: Make .hex and .bin file: Get micropython using git (If you get an error regarding MICROPY_ALLOC_PATH_MAX go to micropython/mpy-cross/mpconfigport.h and change #define MICROPY_ALLOC_PATH_MAX (PATH_MAX) to #define MICROPY_ALLOC_PATH_MAX 256 ) cd ports/nrf Convert .hex to uf2: The firmware.uf2 file is created successfully, however, when I upload the file the device is no longer visible. I then repeated these steps with your SUPERMINI_NRF52840_NIMBLE board which also created the build successfully but also wasn't detectable. Any advice or tips? Thanks in advance once again! |
Beta Was this translation helpful? Give feedback.
-
If you compare the csv file to other ones in the boards directory, you can see that the one above is simply wrong. Most likely the are more errors. Do not follow the erratic words from ChatGPT. Better use other board definitions as template, like the SEEED_XIAO_NRF52, which uses as well the Adafruit bootloader. |
Beta Was this translation helpful? Give feedback.
-
Borrowed from the Cicruitpython pin definitions, a pins.csv file would look like below. But a wrong pins.csv file would not case a non-working firmware.
|
Beta Was this translation helpful? Give feedback.
-
as robert-hh said, I would also start with adjusting pins.csv. Use the SUPERMINI_NRF52840 as a starting point and only change pins.csv. You may also change this won't break anything. I have made quick and dirty board definition for the feather. It compiles but I have no board to test with. You can give it a try and move on with it. If the SUPERMINI_NRF52840 build does not work any more you may check if you have to reinstall your bootloader. https://github.com/jkorte-dev/micropython-board-NRF52840/tree/develop/FEATHER_NRF52840 |
Beta Was this translation helpful? Give feedback.
-
@jkorte-dev and @robert-hh thank you very much for all the corrections and help, I appreciate it. So I've made a bit of progress in terms of generating the final uf2 file. I get it to build, however, the port still doesn't appear. I have reloaded the Bootloader using Arduino and tested Circuitpython which works. @jkorte-dev one thing I did notice is that To compile the SUPERMINI_NRF52840 after a make clean, I do the following in the nrf directory: I then copy the file firmware.uf2 to the device in DFU mode. Is there something I'm doing wrong? |
Beta Was this translation helpful? Give feedback.
-
@Eckaard
|
Beta Was this translation helpful? Give feedback.
Thank you, jkorte-dev - I was able to load your uf2 build onto the nRF52! I was successful after reloading the bootloader using the Arduino IDE. I can now get to REPL via Terminal and Thonny. I appreciate you letting me borrow your code to test this. This is great - now I will learn how to build the hex on the Mac, incorporating your tips, generating the uf2 using your instructions, and see if I can do it myself.