Great, how did you fix it?
Inside your Micropython git clone directory create a new board directory for the custom port named NRF52840:
Code: Select all
cd /micropython/ports/nrf/boards
mkdir NRF52840
containing:
Code: Select all
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Glenn Ruben Bakke
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#define MICROPY_HW_BOARD_NAME "FEATHER-NRF52840"
#define MICROPY_HW_MCU_NAME "NRF52840"
#define MICROPY_PY_SYS_PLATFORM "nrf52840-feather"
#define MICROPY_PY_MACHINE_UART (1)
#define MICROPY_PY_MACHINE_HW_PWM (1)
#define MICROPY_PY_MACHINE_HW_SPI (1)
#define MICROPY_PY_MACHINE_TIMER (1)
#define MICROPY_PY_MACHINE_RTCOUNTER (1)
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_HW_USB_CDC (1) //very important to get USB-Serial to work
#define MICROPY_HW_ENABLE_RNG (1)
#define MICROPY_HW_NEOPIXEL (16)
#define BOARD_HAS_CRYSTAL 1
#if QSPI_FLASH_FILESYSTEM
#define MICROPY_QSPI_DATA0 (17)
#define MICROPY_QSPI_DATA1 (22)
#define MICROPY_QSPI_DATA2 (23)
#define MICROPY_QSPI_DATA3 (21)
#define MICROPY_QSPI_SCK (19)
#define MICROPY_QSPI_CS (20)
#endif
#define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (2)
#define MICROPY_HW_LED_PULLUP (0)
#define MICROPY_HW_LED1 (32+10) // LED1
#define MICROPY_HW_LED2 (32+15) // LED2
// UART config
#define MICROPY_HW_UART1_RX (24)
#define MICROPY_HW_UART1_TX (25)
//#define MICROPY_HW_UART1_CTS (7)
//#define MICROPY_HW_UART1_RTS (5)
#define MICROPY_HW_UART1_HWFC (0)
// SPI0 config
#define MICROPY_HW_SPI0_NAME "SPI0"
#define MICROPY_HW_SPI0_SCK (14)
#define MICROPY_HW_SPI0_MOSI (13)
#define MICROPY_HW_SPI0_MISO (15)
#define MICROPY_HW_PWM0_NAME "PWM0"
#define MICROPY_HW_PWM1_NAME "PWM1"
#define MICROPY_HW_PWM2_NAME "PWM2"
#if 0
#define MICROPY_HW_PWM3_NAME "PWM3"
#endif
#define HELP_TEXT_BOARD_LED "1,2"
Create a mpconfigboard.mk file containing:
Code: Select all
MCU_SERIES = m4
MCU_VARIANT = nrf52
MCU_SUB_VARIANT = nrf52840
SOFTDEV_VERSION = 6.1.1
LD_FILES += boards/nrf52840_1M_256k.ld
NRF_DEFINES += -DNRF52840_XXAA
Pins.csv file containing:
Code: Select all
P0,P0
P1,P1
P2,P2
P3,P3
P4,P4
P5,P5
P6,P6
P7,P7
P8,P8
P9,P9
P10,P10
P11,P11
P12,P12
P13,P13
P14,P14
P15,P15
P16,P16
P17,P17
P18,P18
P19,P19
P20,P20
P21,P21
P22,P22
P23,P23
P24,P24
P25,P25
P26,P26
P27,P27
P28,P28
P29,P29
P30,P30
P31,P31
P32,P32
P33,P33
P34,P34
P35,P35
P36,P36
P37,P37
P38,P38
P39,P39
P40,P40
P41,P41
P42,P42
P43,P43
P44,P44
P45,P45
P46,P46
P47,P47
To build with soft device 140 (as is required for this chip):
Code: Select all
cd /micropython/ports/nrf/
make submodules
make BOARD=NRF52840 sd=s140
A build folder will be created, and therein you will find the firmware.hex and firmware.bin files. Either of these should be converted to a uf2 file, so that it can be dragged and dropped to the Adafruit board. To convert the firmware to a uf2 file, we need to use the uf2conv.py script. (see link previous post for uf2conv.py)
Perform the conversion, not forgetting to set the family flag, -f, to 0XADA52840 and the convert only flag -c
Code: Select all
cd /micropython/ports/nrf/build-NRF52840-s140
python3 /Users/ltmerlin/Desktop/uf2tool.py firmware.hex -c -f 0xADA52840
This should create a flash.uf2 file in the build directory. Connect the Adafruit board via USB to the computer and double press the reset button on the board to go into bootloader mode. The Neopixel should go green and the red LED labelled D3 should breathe. A drive should now be visible called FTHR840BOOT. Drag the flash.uf2 file to this drive. The board should reset itself and micropython should be running.