summaryrefslogtreecommitdiff
path: root/ports/nrf
diff options
context:
space:
mode:
authorTG-Techie <TGTechie01@gmail.com>2020-02-28 04:11:54 -0500
committerTG-Techie <TGTechie01@gmail.com>2020-02-28 04:11:54 -0500
commit527eb2444c7d0f82e7a6192f04a93af22f24dee9 (patch)
tree3fa8d444b7961047cb7b6da7a88071b91f3b4e47 /ports/nrf
parent75aea6b1ca3b2d9a14ea195ee3b1e23101b4cc77 (diff)
added TG-Watch02A pins
Diffstat (limited to 'ports/nrf')
-rw-r--r--ports/nrf/boards/TG-Watch02A/README.md201
-rw-r--r--ports/nrf/boards/TG-Watch02A/board.c38
-rw-r--r--ports/nrf/boards/TG-Watch02A/mpconfigboard.h63
-rw-r--r--ports/nrf/boards/TG-Watch02A/mpconfigboard.mk10
-rw-r--r--ports/nrf/boards/TG-Watch02A/pins.c86
5 files changed, 398 insertions, 0 deletions
diff --git a/ports/nrf/boards/TG-Watch02A/README.md b/ports/nrf/boards/TG-Watch02A/README.md
new file mode 100644
index 000000000..8d515010f
--- /dev/null
+++ b/ports/nrf/boards/TG-Watch02A/README.md
@@ -0,0 +1,201 @@
+# Setup
+
+The `feather52840` board is currently based on the `PCA10056` development
+board from Nordic Semiconductors, since commercial modules are not yet
+available for the nRF52840.
+
+The difference between the `pca10056` and `feather52840` board support
+packages is that no bootloader is present on the `pca10056` (a HW debugger
+like a Segger J-Link is required to flash firmware images), whereas the
+`feather52840` package uses a serial bootloader, with a slightly different
+flash layout to account for the bootloader's presence.
+
+Both targets run on the same hardware and assume the same pinouts.
+
+The `feather52840` board support package will be updated at a later date
+to reflect any pin changes in the final Feather form-factor HW.
+
+## Installing CircuitPython submodules
+
+Before you can build, you will need to run the following commands once, which
+will install the submodules that are part of the CircuitPython ecosystem, and
+build the `mpy-cross` tool:
+
+```
+$ cd circuitpython
+$ git submodule update --init
+$ make -C mpy-cross
+```
+
+You then need to download the SD and Nordic SDK files via:
+
+> This script relies on `wget`, which must be available from the command line.
+
+```
+$ cd ports/nrf
+$ ./bluetooth/download_ble_stack.sh
+```
+
+## Installing the Serial Bootloader
+
+The Adafruit nRF52840 Feather uses a serial bootloader that allows you to
+update the core CircuitPython firmware and internal file system contents
+using only a serial connection.
+
+On empty devices, the serial bootloader will need to be flashed once using a
+HW debugger such as a Segger J-Link before the serial updater (`adafruit-nrfutil`) can
+be used.
+
+### Install `nrfjprog`
+
+Before you can install the bootloader, you will first need to install the
+`nrfjprog` tool from Nordic Semiconductors for your operating system. The
+binary files can be downloaded via the following links:
+
+- [nRF5x toolset tar for Linux 32-bit v9.7.2](http://www.nordicsemi.com/eng/nordic/Products/nRF52832/nRF5x-Command-Line-Tools-Linux32/52619)
+- [nRF5x toolset tar for Linux 64-bit v9.7.2](http://www.nordicsemi.com/eng/nordic/Products/nRF52832/nRF5x-Command-Line-Tools-Linux64/51388)
+- [nRF5x toolset tar for OSX v9.7.2](http://www.nordicsemi.com/eng/nordic/Products/nRF52832/nRF5x-Command-Line-Tools-OSX/53406)
+- [nRF5x toolset installer for Windows v9.7.2](http://www.nordicsemi.com/eng/nordic/Products/nRF52832/nRF5x-Command-Line-Tools-Win32/48768)
+
+You will then need to add the `nrfjprog` folder to your system `PATH` variable
+so that it is available from the command line. The exact process for this is
+OS specific, but on a POSIX type system like OS X or Linux, you can
+temporarily add the location to your `PATH` environment variables as follows:
+
+```
+$ export PATH=$PATH:YOURPATHHERE/nRF5x-Command-Line-Tools_9_7_2_OSX/nrfjprog/
+```
+
+You can test this by running the following command:
+
+```
+$ nrfjprog --version
+nrfjprog version: 9.7.2
+JLinkARM.dll version: 6.20f
+```
+
+### Flash the USB CDC Bootloader with 'nrfjprog'
+
+> This operation only needs to be done once, and only on boards that don't
+ already have the serial bootloader installed.
+
+Firstly clone the [Adafruit_nRF52_Bootloader](https://github.com/adafruit/Adafruit_nRF52_Bootloader.git) and enter its directory
+
+```
+$ git clone https://github.com/adafruit/Adafruit_nRF52_Bootloader.git
+$ cd Adafruit_nRF52_Bootloader
+```
+
+Once `nrfjprog` is installed and available in `PATH` you can flash your
+board with the serial bootloader via the following command:
+
+```
+make BOARD=feather_nrf52840_express VERSION=latest flash
+```
+
+This should give you the following (or very similar) output, and you will see
+a DFU blinky pattern on one of the board LEDs:
+
+```
+$ make BOARD=pca10056 VERSION=latest flash
+Flashing: bin/pca10056/6.0.0r0/pca10056_bootloader_s140_6.0.0r0.hex
+nrfjprog --program bin/pca10056/6.0.0r0/pca10056_bootloader_s140_6.0.0r0.hex --chiperase -f nrf52 --reset
+Parsing hex file.
+Erasing user available code and UICR flash areas.
+Applying system reset.
+Checking that the area to write is not protected.
+Programing device.
+Applying system reset.
+Run.
+```
+
+From this point onward, you can now use a simple serial port for firmware
+updates.
+
+Note: You can specify other version that are available in the directory `Adafruit_nRF52_Bootloader/bin/feather_nrf52840_express/` . The `VERSION=latest` will use the latest bootloader available.
+
+### IMPORTANT: Disable Mass Storage on PCA10056 J-Link
+
+The J-Link firmware on the PCA10056 implement USB Mass Storage, but this
+causes a known conflict with reliable USB CDC serial port communication. In
+order to use the serial bootloader, **you must disable MSD support on the
+Segger J-Link**!
+
+To disable mass storage support, run the `JLinkExe` (or equivalent) command,
+and send `MSDDisable`. (You can re-enable MSD support via `MSDEnable`):
+
+```
+$ JLinkExe
+SEGGER J-Link Commander V6.20f (Compiled Oct 13 2017 17:20:01)
+DLL version V6.20f, compiled Oct 13 2017 17:19:52
+
+Connecting to J-Link via USB...O.K.
+Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Jul 24 2017 17:30:12
+Hardware version: V1.00
+S/N: 683947110
+VTref = 3.300V
+
+
+Type "connect" to establish a target connection, '?' for help
+J-Link>MSDDisable
+Probe configured successfully.
+J-Link>exit
+```
+
+## Building and Flashing CircuitPython
+
+### Installing `adafruit-nrfutil`
+
+run follow command to install [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil) from PyPi
+
+```
+$ pip3 install adafruit-nrfutil --user
+```
+
+### Flashing CircuitPython with USB CDC
+
+With the serial bootloader present on your board, you first need to force your
+board into DFU mode by holding down BUTTON1 and RESETTING the board (with
+BUTTON1 still pressed as you come out of reset).
+
+This will give you a **fast blinky DFU pattern** to indicate you are in DFU
+mode.
+
+You can **build and flash** a CircuitPython binary via the following command:
+
+```
+$ make V=1 SD=s140 SERIAL=/dev/tty.usbmodem1411 BOARD=feather52840 all dfu-gen dfu-flash
+```
+
+This should give you the following results:
+
+```
+$make V=1 BOARD=feather52840 SD=s140 SERIAL=/dev/tty.usbmodem1411 dfu-gen dfu-flash
+nrfutil dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application build-feather52840-s140/firmware.hex build-feather52840-s140/dfu-package.zip
+Zip created at build-feather52840-s140/dfu-package.zip
+nrfutil --verbose dfu serial --package build-feather52840-s140/dfu-package.zip -p /dev/ttyACM1 -b 115200 --singlebank
+Upgrading target on /dev/ttyACM1 with DFU package /home/hathach/Dropbox/adafruit/circuitpython/ada_cp/ports/nrf/build-feather52840-s140/dfu-package.zip. Flow control is disabled, Single bank mode
+Starting DFU upgrade of type 4, SoftDevice size: 0, bootloader size: 0, application size: 199840
+Sending DFU start packet
+Sending DFU init packet
+Sending firmware file
+#########################################################################################################################################################################################################################################################################################################################################################################################################
+Activating new firmware
+
+DFU upgrade took 8.50606513023s
+Device programmed.
+```
+
+### Flashing CircuitPython with MSC UF2
+
+uf2 file is generated last by `all` target
+
+```
+$ make V=1 SD=s140 SERIAL=/dev/tty.usbmodem1411 BOARD=feather52840 all
+Create firmware.uf2
+../../tools/uf2/utils/uf2conv.py -f 0xADA52840 -c -o "build-feather52840-s140/firmware.uf2" "build-feather52840-s140/firmware.hex"
+Converting to uf2, output size: 392192, start address: 0x26000
+Wrote 392192 bytes to build-feather52840-s140/firmware.uf2.
+```
+
+Simply drag and drop firmware.uf2 to the MSC, the nrf52840 will blink fast and reset after done.
diff --git a/ports/nrf/boards/TG-Watch02A/board.c b/ports/nrf/boards/TG-Watch02A/board.c
new file mode 100644
index 000000000..4421970ee
--- /dev/null
+++ b/ports/nrf/boards/TG-Watch02A/board.c
@@ -0,0 +1,38 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
+ *
+ * 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.
+ */
+
+#include "boards/board.h"
+
+void board_init(void) {
+}
+
+bool board_requests_safe_mode(void) {
+ return false;
+}
+
+void reset_board(void) {
+
+}
diff --git a/ports/nrf/boards/TG-Watch02A/mpconfigboard.h b/ports/nrf/boards/TG-Watch02A/mpconfigboard.h
new file mode 100644
index 000000000..acb84cba7
--- /dev/null
+++ b/ports/nrf/boards/TG-Watch02A/mpconfigboard.h
@@ -0,0 +1,63 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Glenn Ruben Bakke
+ * Copyright (c) 2018 Dan Halbert for Adafruit Industries
+ *
+ * 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.
+ */
+
+#include "nrfx/hal/nrf_gpio.h"
+
+#define MICROPY_HW_BOARD_NAME "TG-Techie's TG-Watch02A"
+#define MICROPY_HW_MCU_NAME "nRF52840"
+
+#define MICROPY_HW_NEOPIXEL (&pin_P0_16)
+
+#define MICROPY_HW_LED_STATUS (&pin_P1_15)
+
+#if QSPI_FLASH_FILESYSTEM
+#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 17)
+#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 22)
+#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(0, 23)
+#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 21)
+#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(0, 19)
+#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(0, 20)
+#endif
+
+#if SPI_FLASH_FILESYSTEM
+#define SPI_FLASH_MOSI_PIN &pin_P0_17
+#define SPI_FLASH_MISO_PIN &pin_P0_22
+#define SPI_FLASH_SCK_PIN &pin_P0_19
+#define SPI_FLASH_CS_PIN &pin_P0_20
+#endif
+
+#define BOARD_HAS_CRYSTAL 0
+
+#define DEFAULT_I2C_BUS_SCL (&pin_P0_11)
+#define DEFAULT_I2C_BUS_SDA (&pin_P0_12)
+
+#define DEFAULT_SPI_BUS_SCK (&pin_P0_14)
+#define DEFAULT_SPI_BUS_MOSI (&pin_P0_13)
+#define DEFAULT_SPI_BUS_MISO (&pin_P0_15)
+
+#define DEFAULT_UART_BUS_RX (&pin_P0_24)
+#define DEFAULT_UART_BUS_TX (&pin_P0_25)
diff --git a/ports/nrf/boards/TG-Watch02A/mpconfigboard.mk b/ports/nrf/boards/TG-Watch02A/mpconfigboard.mk
new file mode 100644
index 000000000..2c1385cf0
--- /dev/null
+++ b/ports/nrf/boards/TG-Watch02A/mpconfigboard.mk
@@ -0,0 +1,10 @@
+USB_VID = 0x239A
+USB_PID = 0x802A
+USB_PRODUCT = "TG-Watch02A"
+USB_MANUFACTURER = "TG-Tech"
+
+MCU_CHIP = nrf52840
+
+QSPI_FLASH_FILESYSTEM = 1
+EXTERNAL_FLASH_DEVICE_COUNT = 2
+EXTERNAL_FLASH_DEVICES = "GD25Q16C, W25Q128JV_SQ"
diff --git a/ports/nrf/boards/TG-Watch02A/pins.c b/ports/nrf/boards/TG-Watch02A/pins.c
new file mode 100644
index 000000000..cbd20d868
--- /dev/null
+++ b/ports/nrf/boards/TG-Watch02A/pins.c
@@ -0,0 +1,86 @@
+#include "shared-bindings/board/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_04) },
+ { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_05) },
+ { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_30) },
+ { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_28) },
+ { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_02) },
+ { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_03) },
+
+ { MP_ROM_QSTR(MP_QSTR_AREF), MP_ROM_PTR(&pin_P0_31) },
+
+ { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_P0_29) },
+ { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_P0_29) },
+
+ { MP_ROM_QSTR(MP_QSTR_SWITCH), MP_ROM_PTR(&pin_P1_02) },
+
+ { MP_ROM_QSTR(MP_QSTR_NFC1), MP_ROM_PTR(&pin_P0_09) },
+ { MP_ROM_QSTR(MP_QSTR_NFC2), MP_ROM_PTR(&pin_P0_10) },
+
+ { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_P0_10) },
+ { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P1_08) },
+ { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P0_07) },
+ { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P0_26) },
+ { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_P0_27) },
+ { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_P0_06) },
+ { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_P0_08) },
+ { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P1_09) },
+
+ { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_P0_16) },
+
+ { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_14) },
+ { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_13) },
+ { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_15) },
+
+ { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_25) },
+ { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_24) },
+
+ { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_11) },
+ { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_12) },
+
+ { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_P1_15) },
+ { MP_ROM_QSTR(MP_QSTR_RED_LED), MP_ROM_PTR(&pin_P1_15) },
+ { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P1_15) },
+
+ { MP_ROM_QSTR(MP_QSTR_BLUE_LED), MP_ROM_PTR(&pin_P1_10) },
+
+ { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
+ { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
+ { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
+
+ /*TG-Watch02A specific pins*/
+
+ //tft / display pins
+ { MP_ROM_QSTR(MP_QSTR_BACKLIGHT), MP_ROM_PTR(&pin_P0_07) },
+ { MP_ROM_QSTR(MP_QSTR_DISP_PWR), MP_ROM_PTR(&pin_P0_05) },
+ { MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_P1_14) },
+ { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_P1_12) },
+ { MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_P1_01) },
+
+ //cap touch screen
+ { MP_ROM_QSTR(MP_QSTR_CTP_RESET), MP_ROM_PTR(&pin_P1_03) },
+ { MP_ROM_QSTR(MP_QSTR_CTP_INT), MP_ROM_PTR(&pin_P1_05) },
+
+ //power / battery
+ { MP_ROM_QSTR(MP_QSTR_CHRG_STAT), MP_ROM_PTR(&pin_P0_06) },
+ { MP_ROM_QSTR(MP_QSTR_BAT_VDIV), MP_ROM_PTR(&pin_P0_29) },
+ { MP_ROM_QSTR(MP_QSTR_VBUS_PRESENT), MP_ROM_PTR(&pin_P1_04) },
+
+ //sensors / outputs
+ { MP_ROM_QSTR(MP_QSTR_RTC_RESET), MP_ROM_PTR(&pin_P0_26) },
+ { MP_ROM_QSTR(MP_QSTR_RTC_INT), MP_ROM_PTR(&pin_P0_27) },
+
+ { MP_ROM_QSTR(MP_QSTR_ACCEL_INT1), MP_ROM_PTR(&pin_P1_11) },
+ { MP_ROM_QSTR(MP_QSTR_ACCEL_INT2), MP_ROM_PTR(&pin_P1_10) },
+
+ { MP_ROM_QSTR(MP_QSTR_HAPTIC_INT), MP_ROM_PTR(&pin_P1_07) },
+ { MP_ROM_QSTR(MP_QSTR_HAPTIC_ENABLE), MP_ROM_PTR(&pin_P1_06) },
+
+ //smc pins
+ { MP_ROM_QSTR(MP_QSTR_SMC_RESET), MP_ROM_PTR(&pin_P0_08) },
+ { MP_ROM_QSTR(MP_QSTR_BUTTON0), MP_ROM_PTR(&pin_P1_08) },
+ { MP_ROM_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_P1_09) },
+};
+
+MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);