diff options
| -rw-r--r-- | ports/nrf/README.md | 1 | ||||
| -rw-r--r-- | ports/nrf/boards/memory.ld | 7 | ||||
| -rw-r--r-- | ports/nrf/boards/nrf52840-mdk-usb-dongle/README.md | 49 | ||||
| -rw-r--r-- | ports/nrf/boards/nrf52840-mdk-usb-dongle/mpconfigboard.h | 71 | ||||
| -rw-r--r-- | ports/nrf/boards/nrf52840-mdk-usb-dongle/mpconfigboard.mk | 7 | ||||
| -rw-r--r-- | ports/nrf/boards/nrf52840-mdk-usb-dongle/nrf52840_open_bootloader.ld | 2 | ||||
| -rw-r--r-- | ports/nrf/boards/nrf52840-mdk-usb-dongle/pins.csv | 17 |
7 files changed, 152 insertions, 2 deletions
diff --git a/ports/nrf/README.md b/ports/nrf/README.md index a02548afe..b08a03456 100644 --- a/ports/nrf/README.md +++ b/ports/nrf/README.md @@ -41,6 +41,7 @@ This is a port of MicroPython to the Nordic Semiconductor nRF series of chips. * [PCA10056](http://www.nordicsemi.com/eng/Products/nRF52840-Preview-DK) * [PCA10059](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-Dongle) * [Particle Xenon](https://docs.particle.io/xenon/) + * [nRF52840 MDK USB Dongle](boards/nrf52840-mdk-usb-dongle/README.md) * nRF9160 * [PCA10090](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF9160-DK) * [Actinius Icarus](https://www.actinius.com/icarus) diff --git a/ports/nrf/boards/memory.ld b/ports/nrf/boards/memory.ld index c95daf3d9..f1f9a2a4c 100644 --- a/ports/nrf/boards/memory.ld +++ b/ports/nrf/boards/memory.ld @@ -1,14 +1,17 @@ /* Flash layout: softdevice | application | filesystem */ /* RAM layout: softdevice RAM | application RAM */ -_sd_size = DEFINED(_sd_size) ? _sd_size : 0; + +_ram_start = DEFINED(_ram_start) ? _ram_start : 0x20000000; +_flash_start = DEFINED(_flash_start) ? _flash_start : 0; +_sd_size = DEFINED(_sd_size) ? _sd_size : _flash_start; _sd_ram = DEFINED(_sd_ram) ? _sd_ram : 0; _fs_size = DEFINED(_fs_size) ? _fs_size : 64K; /* TODO: set to 0 if not using the filesystem */ _app_size = _flash_size - _sd_size - _fs_size; _app_start = _sd_size; _fs_start = _sd_size + _app_size; _fs_end = _fs_start + _fs_size; -_app_ram_start = 0x20000000 + _sd_ram; +_app_ram_start = _ram_start + _sd_ram; _app_ram_size = _ram_size - _sd_ram; _heap_start = _ebss; _heap_end = _ram_end - _stack_size; diff --git a/ports/nrf/boards/nrf52840-mdk-usb-dongle/README.md b/ports/nrf/boards/nrf52840-mdk-usb-dongle/README.md new file mode 100644 index 000000000..c39a800d7 --- /dev/null +++ b/ports/nrf/boards/nrf52840-mdk-usb-dongle/README.md @@ -0,0 +1,49 @@ +nRF52840 MDK USB Dongle +======================= + +The *[nRF52840 MDK USB +Dongle](https://wiki.makerdiary.com/nrf52840-mdk-usb-dongle)* is a small, +low-cost development board in a USB dongle form-factor powered by an nRF52840 +with 1MB flash and 256KB RAM. + +This device is pre-installed with [Open +Bootloader](https://wiki.makerdiary.com/nrf52840-mdk-usb-dongle/programming/), +allowing DFU upgrades over USB using Nordic [nRF +Connect](https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Connect-for-desktop) +or [nrfutil](https://github.com/NordicSemiconductor/pc-nrfutil/). To support +Open Bootloader, the flash and memory layout must be adjusted slightly (details +[here](https://devzone.nordicsemi.com/nordic/short-range-guides/b/getting-started/posts/nrf52840-dongle-programming-tutorial)) +from the typical nRF build; this board definition ensure the appropriate build +configuration is used for MicroPython. + + +Pinout +------ + +The [pinout +diagram](https://wiki.makerdiary.com/nrf52840-mdk-usb-dongle/#pinout-diagram) +provides an overview of the available pins and their capabilities. All pins are +available in MicroPython, using the pin numbers labelled in the diagram +(excluding the leading port number, *P0*). + +The three LEDs are available either through the usual `Pin` mechanism - pins +22-24 - or by `board.LED(n)` where n can be 1, 2 or 3. + + +Build instructions +------------------ + +Follow the standard [nRF Port build instructions](../../README.md); but use +`nrf52840-mdk-usb-dongle` as the value for `BOARD`: + + make BOARD=nrf52840-mdk-usb-dongle + +The build artifacts will be created in `build-nrf52840-mdk-usb-dongle`. Once +built, the easiest way to deploy to the device is to open `firmware.hex` using +*nRF Connect* and select *Write*. Detailed instructions can be found on the +[developer +wiki](https://wiki.makerdiary.com/nrf52840-mdk-usb-dongle/programming/). + +**Note** that the regular method of deployment for the MicroPython nRF port +(using `make deploy`) will *not* operate correctly and will overwrite the +bootloader. diff --git a/ports/nrf/boards/nrf52840-mdk-usb-dongle/mpconfigboard.h b/ports/nrf/boards/nrf52840-mdk-usb-dongle/mpconfigboard.h new file mode 100644 index 000000000..f048c39e0 --- /dev/null +++ b/ports/nrf/boards/nrf52840-mdk-usb-dongle/mpconfigboard.h @@ -0,0 +1,71 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Matt Trentini + * + * 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 "MDK-USB-DONGLE" +#define MICROPY_HW_MCU_NAME "NRF52840" +#define MICROPY_PY_SYS_PLATFORM "nrf52840-MDK-USB-Dongle" + +#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_ENABLE_RNG (1) + +#define MICROPY_HW_USB_CDC (1) + +#define MICROPY_HW_HAS_LED (1) +#define MICROPY_HW_LED_COUNT (3) +#define MICROPY_HW_LED_PULLUP (1) + +#define MICROPY_HW_LED1 (22) // LED1 GREEN +#define MICROPY_HW_LED2 (23) // LED2 RED +#define MICROPY_HW_LED3 (24) // LED3 BLUE + +// UART config +#define MICROPY_HW_UART1_RX (7) +#define MICROPY_HW_UART1_TX (8) +#define MICROPY_HW_UART1_CTS (9) +#define MICROPY_HW_UART1_RTS (10) +#define MICROPY_HW_UART1_HWFC (1) + +// SPI0 config +#define MICROPY_HW_SPI0_NAME "SPI0" + +#define MICROPY_HW_SPI0_SCK (19) +#define MICROPY_HW_SPI0_MOSI (20) +#define MICROPY_HW_SPI0_MISO (21) + +#define MICROPY_HW_PWM0_NAME "PWM0" +#define MICROPY_HW_PWM1_NAME "PWM1" +#define MICROPY_HW_PWM2_NAME "PWM2" +#define MICROPY_HW_PWM3_NAME "PWM3" + +#define HELP_TEXT_BOARD_LED "1,2,3" diff --git a/ports/nrf/boards/nrf52840-mdk-usb-dongle/mpconfigboard.mk b/ports/nrf/boards/nrf52840-mdk-usb-dongle/mpconfigboard.mk new file mode 100644 index 000000000..f98d5c88a --- /dev/null +++ b/ports/nrf/boards/nrf52840-mdk-usb-dongle/mpconfigboard.mk @@ -0,0 +1,7 @@ +MCU_SERIES = m4 +MCU_VARIANT = nrf52 +MCU_SUB_VARIANT = nrf52840 +SOFTDEV_VERSION = 6.1.1 +LD_FILES += boards/nrf52840-mdk-usb-dongle/nrf52840_open_bootloader.ld boards/nrf52840_1M_256k.ld + +NRF_DEFINES += -DNRF52840_XXAA diff --git a/ports/nrf/boards/nrf52840-mdk-usb-dongle/nrf52840_open_bootloader.ld b/ports/nrf/boards/nrf52840-mdk-usb-dongle/nrf52840_open_bootloader.ld new file mode 100644 index 000000000..d6c6e743a --- /dev/null +++ b/ports/nrf/boards/nrf52840-mdk-usb-dongle/nrf52840_open_bootloader.ld @@ -0,0 +1,2 @@ +_ram_start = 0x20000008; +_flash_start = 0x1000; diff --git a/ports/nrf/boards/nrf52840-mdk-usb-dongle/pins.csv b/ports/nrf/boards/nrf52840-mdk-usb-dongle/pins.csv new file mode 100644 index 000000000..571628637 --- /dev/null +++ b/ports/nrf/boards/nrf52840-mdk-usb-dongle/pins.csv @@ -0,0 +1,17 @@ +P2,P2,ADC1_CH0 +P3,P3,ADC1_CH1 +P4,P4,ADC1_CH2 +P5,P5,ADC1_CH3 +P6,P6 +P7,P7 +P8,P8 +P9,P9 +P10,P10 +USER,P18,P18 +P19,P19 +P20,P20 +P21,P21 +LED_G,P22,P22 +LED_R,P23,P23 +LED_B,P24,P24 +P25,P25 |
