summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--ports/mimxrt/boards/ADAFRUIT_METRO_M7/board.json26
-rw-r--r--ports/mimxrt/boards/ADAFRUIT_METRO_M7/deploy_metro_m7.md141
-rw-r--r--ports/mimxrt/boards/ADAFRUIT_METRO_M7/mpconfigboard.h65
-rw-r--r--ports/mimxrt/boards/ADAFRUIT_METRO_M7/mpconfigboard.mk11
-rw-r--r--ports/mimxrt/boards/ADAFRUIT_METRO_M7/pins.csv31
5 files changed, 274 insertions, 0 deletions
diff --git a/ports/mimxrt/boards/ADAFRUIT_METRO_M7/board.json b/ports/mimxrt/boards/ADAFRUIT_METRO_M7/board.json
new file mode 100644
index 0000000000..c96e9b08fe
--- /dev/null
+++ b/ports/mimxrt/boards/ADAFRUIT_METRO_M7/board.json
@@ -0,0 +1,26 @@
+{
+ "deploy": [
+ "deploy_metro_m7.md"
+ ],
+ "docs": "",
+ "features": [
+ "USB-C",
+ "SPI",
+ "I2C",
+ "UART",
+ "RGB LED",
+ "QSPI Flash",
+ "QWIIC",
+ "JLink",
+ "WiFi",
+ "BLE"
+ ],
+ "images": [
+ "Metro_M7.jpg"
+ ],
+ "mcu": "mimxrt",
+ "product": "Adafruit Metro M7",
+ "thumbnail": "",
+ "url": "https://www.adafruit.com/product/4950",
+ "vendor": "Adafruit"
+}
diff --git a/ports/mimxrt/boards/ADAFRUIT_METRO_M7/deploy_metro_m7.md b/ports/mimxrt/boards/ADAFRUIT_METRO_M7/deploy_metro_m7.md
new file mode 100644
index 0000000000..bc92016b71
--- /dev/null
+++ b/ports/mimxrt/boards/ADAFRUIT_METRO_M7/deploy_metro_m7.md
@@ -0,0 +1,141 @@
+## 1. Deploy the MicroPython firmware to the Metro M7 board.
+
+### 1.1 Deploy the firmware using the serial bootloader.
+
+For initial deployment of the firmware a few preparation steps are required, which
+have to be done once.
+
+1. Get the files ufconv.py and uf2families.json from the micropython/tools directory,
+e.g. at https://github.com/micropython/micropython/tree/master/tools.
+
+2. Get the NXP program sdphost for your operating system, e.g. from
+https://github.com/adafruit/tinyuf2/tree/master/ports/mimxrt10xx/sdphost.
+You can also get them from the NXP web sites.
+
+3. Get the UF2 boot-loader package https://github.com/adafruit/tinyuf2/releases/download/0.9.0/tinyuf2-imxrt1010_evk-0.9.0.zip
+and extract the file tinyuf2-imxrt1010_evk-0.9.0.bin.
+
+Now you have all files at hand that you will need for updating.
+
+1. Get the firmware you want to upload from the MicroPython download page.
+
+2. Set the two BOOTSEL DIP switches to the 1/0 position, which is the opposite position of the normal use mode.
+
+3. Push the reset button.
+
+4. Run the commands:
+
+```
+sudo ./sdphost -u 0x1fc9,0x0145 -- write-file 0x20206400 tinyuf2-imxrt1010_evk-0.9.0.bin
+sudo ./sdphost -u 0x1fc9,0x0145 -- jump-address 0x20207000
+```
+Wait until a drive icon appears on the computer (or mount it explicitly), and then run:
+```
+python3 uf2conv.py <firmware_xx.yy.zz.hex> --base 0x60000400 -f 0x4fb2d5bd
+```
+You can put all of that in a script. Just add a short wait before the 3rd command to let the drive connect.
+
+5. Once the upload is finished, set the BOOTSEL DIP switches back to the 0/1 position and push reset.
+
+Using sudo is Linux specific. You may not need it at all, if the access rights are set properly,
+and you will not need it for Windows.
+
+### 1.2 Deploy the firmware using a JTAG adapter.
+
+With a JTAG adapter the firmware can be easily installed. Appropriate tools are Segger JFlash Lite and
+the Segger Edu Mini adapter. Just use the firmware.hex file for loading, which will be loaded at the
+proper address.
+
+
+## 2. Deploy the WiFi firmware.
+
+The NINA firmware in the NINA module has to be updated for use with MicroPython. That can be done
+using MicroPython and two small Python scripts.
+
+The firmware binaries are available at
+https://github.com/micropython/micropython-lib/tree/master/micropython/espflash
+or https://github.com/robert-hh/Shared-Stuff. For the Metro M7 board, the
+NINA_FW_v1.5.0_Airlift.bin file is needed.
+
+For firmware upload, the following connections to the WiFi module are required:
+
+- Pin Reset (as above)
+- Pin GPIO0
+- UART RX
+- UART TX
+
+The GPIO pins and UART device id varies between boards. At the Adafruit Metro M7 board,
+the UART is UART(1), and the Pin names for reset and GPIO0 are ESP_RESET and ESP_GPIO0.
+The firmware can be uploaded, using the espflash.py module, a short script
+using espflash.py and mpremote. espflash.py is available at
+https://github.com/micropython/micropython-lib/tree/master/micropython/espflash.
+This place also holds the example script.
+
+```
+import espflash
+from machine import Pin
+from machine import UART
+import sys
+sys.path.append("/flash")
+
+reset = Pin("ESP_RESET", Pin.OUT)
+gpio0 = Pin("ESP_GPIO0", Pin.OUT)
+uart = UART(0, 115200, timeout=350)
+
+md5sum = b"b0b9ab23da820a469e597c41364acb3a"
+path = "/remote/NINA_FW_v1.5.0_Airlift.bin"
+
+esp = espflash.ESPFlash(reset, gpio0, uart)
+# Enter bootloader download mode, at 115200
+esp.bootloader()
+# Can now change to higher/lower baud rate
+esp.set_baudrate(921600)
+# Must call this first before any flash functions.
+esp.flash_attach()
+# Read flash size
+size = esp.flash_read_size()
+# Configure flash parameters.
+esp.flash_config(size)
+# Write firmware image from internal storage.
+esp.flash_write_file(path)
+# Compares file and flash MD5 checksum.
+esp.flash_verify_file(path, md5sum)
+# Resets the ESP32 chip.
+esp.reboot()
+```
+
+The script shows the set-up for the Metro M7 board.
+The md5sum is the one of the WiFi firmware. It may change and
+can be recalculated using e.g. the Linux `md5sum` command. It is used to
+verify the firmware upload. To upload the firmware, place the firmware
+and the above script (let's call it ninaflash.py) into the same directory
+on your PC, and run the command:
+```
+mpremote connect <port> mount . run ninaflash.py
+```
+After a while, the upload will start. A typical start sequence looks like:
+```
+Local directory . is mounted at /remote
+Failed to read response to command 8.
+Failed to read response to command 8.
+Changing baudrate => 921600
+Flash attached
+Flash size 2.0 MBytes
+Flash write size: 1310720 total_blocks: 320 block size: 4096
+Writing sequence number 0/320...
+Writing sequence number 1/320...
+Writing sequence number 2/320...
+Writing sequence number 3/320...
+Writing sequence number 4/320...
+....
+....
+Writing sequence number 317/320...
+Writing sequence number 318/320...
+Writing sequence number 319/320...
+Flash write finished
+Flash verify: File MD5 b'b0b9ab23da820a469e597c41364acb3a'
+Flash verify: Flash MD5 b'b0b9ab23da820a469e597c41364acb3a'
+Firmware verified.
+```
+The initial messages `Failed to read response to command 8.`
+can be ignored.
diff --git a/ports/mimxrt/boards/ADAFRUIT_METRO_M7/mpconfigboard.h b/ports/mimxrt/boards/ADAFRUIT_METRO_M7/mpconfigboard.h
new file mode 100644
index 0000000000..ac9cf97058
--- /dev/null
+++ b/ports/mimxrt/boards/ADAFRUIT_METRO_M7/mpconfigboard.h
@@ -0,0 +1,65 @@
+#define MICROPY_HW_BOARD_NAME "Adafruit Metro M7"
+#define MICROPY_HW_MCU_NAME "MIMXRT1011DAE5A"
+
+// i.MX RT1010 EVK has 1 board LED
+#define MICROPY_HW_LED1_PIN (pin_GPIO_03)
+#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
+#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
+
+#define MICROPY_HW_NUM_PIN_IRQS (2 * 32)
+
+// Define mapping logical UART # to hardware UART #
+// LPUART1 on USB_DBG -> 0
+// LPUART1 on D0/D1 -> 1
+// LPUART3 on A0/D4 -> 3
+// LPUART4 on D6/D7 -> 2
+
+#define MICROPY_HW_UART_NUM (sizeof(uart_index_table) / sizeof(uart_index_table)[0])
+#define MICROPY_HW_UART_INDEX { 1, 1, 2, 4 }
+
+#define IOMUX_TABLE_UART \
+ { IOMUXC_GPIO_10_LPUART1_TXD }, { IOMUXC_GPIO_09_LPUART1_RXD }, \
+ { IOMUXC_GPIO_12_LPUART3_TXD }, { IOMUXC_GPIO_11_LPUART3_RXD }, \
+ { 0 }, { 0 }, \
+ { IOMUXC_GPIO_AD_02_LPUART4_TXD }, { IOMUXC_GPIO_AD_01_LPUART4_RXD },
+
+#define MICROPY_HW_SPI_INDEX { 1 }
+
+#define IOMUX_TABLE_SPI \
+ { IOMUXC_GPIO_AD_06_LPSPI1_SCK }, { IOMUXC_GPIO_AD_05_LPSPI1_PCS0 }, \
+ { IOMUXC_GPIO_AD_04_LPSPI1_SDO }, { IOMUXC_GPIO_AD_03_LPSPI1_SDI }, \
+ { IOMUXC_GPIO_AD_02_LPSPI1_PCS1 }
+
+#define DMA_REQ_SRC_RX { 0, kDmaRequestMuxLPSPI1Rx, kDmaRequestMuxLPSPI2Rx }
+#define DMA_REQ_SRC_TX { 0, kDmaRequestMuxLPSPI1Tx, kDmaRequestMuxLPSPI2Tx }
+
+// Define mapping hardware I2C # to logical I2C #
+// SDA/SCL HW-I2C Logical I2C
+// D14/D15 LPI2C1 -> 0
+// D0/D1 LPI2C2 -> 1
+// D6/D7 LPI2C2 -> 1 Alternatively possible GPIO_AD_01, GPIO_AD_02
+
+#define MICROPY_HW_I2C_INDEX { 1, 2 }
+
+#define IOMUX_TABLE_I2C \
+ { IOMUXC_GPIO_02_LPI2C1_SCL }, { IOMUXC_GPIO_01_LPI2C1_SDA }, \
+ { IOMUXC_GPIO_10_LPI2C2_SCL }, { IOMUXC_GPIO_09_LPI2C2_SDA },
+
+// Wifi Deinitions
+#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "mpy-metro-m7"
+
+#define MICROPY_HW_WIFI_SPI_ID (0)
+#define MICROPY_HW_WIFI_SPI_BAUDRATE (8000000)
+
+#define MICROPY_HW_NINA_ACK pin_find(MP_OBJ_NEW_QSTR(MP_QSTR_ESP_BUSY))
+#define MICROPY_HW_NINA_CS pin_find(MP_OBJ_NEW_QSTR(MP_QSTR_ESP_CS))
+#define MICROPY_HW_NINA_RESET pin_find(MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RESET))
+
+// BLE definitions
+#define MICROPY_PY_BLUETOOTH_NINAW10 (1)
+
+#define MICROPY_HW_BLE_UART_ID (1)
+#define MICROPY_HW_BLE_UART_BAUDRATE (115200)
+
+#define MICROPY_HW_NINA_RTS pin_find(MP_OBJ_NEW_QSTR(MP_QSTR_MOSI))
+#define MICROPY_HW_NINA_CTS MICROPY_HW_NINA_ACK
diff --git a/ports/mimxrt/boards/ADAFRUIT_METRO_M7/mpconfigboard.mk b/ports/mimxrt/boards/ADAFRUIT_METRO_M7/mpconfigboard.mk
new file mode 100644
index 0000000000..8617261d54
--- /dev/null
+++ b/ports/mimxrt/boards/ADAFRUIT_METRO_M7/mpconfigboard.mk
@@ -0,0 +1,11 @@
+MCU_SERIES = MIMXRT1011
+MCU_VARIANT = MIMXRT1011DAE5A
+
+MICROPY_FLOAT_IMPL = single
+MICROPY_PY_MACHINE_SDCARD = 0
+MICROPY_HW_FLASH_TYPE ?= qspi_nor_flash
+MICROPY_HW_FLASH_SIZE ?= 0x800000 # 8MB
+
+MICROPY_PY_NETWORK_NINAW10 ?= 1
+MICROPY_PY_USSL ?= 1
+MICROPY_SSL_MBEDTLS ?= 1
diff --git a/ports/mimxrt/boards/ADAFRUIT_METRO_M7/pins.csv b/ports/mimxrt/boards/ADAFRUIT_METRO_M7/pins.csv
new file mode 100644
index 0000000000..65fbd68d50
--- /dev/null
+++ b/ports/mimxrt/boards/ADAFRUIT_METRO_M7/pins.csv
@@ -0,0 +1,31 @@
+D0,GPIO_09
+D1,GPIO_10
+D2,GPIO_13
+D3,GPIO_12
+D4,GPIO_SD_00
+D5,GPIO_SD_01
+D6,GPIO_SD_02
+D7,GPIO_11
+D8,GPIO_08
+D9,GPIO_07
+D10,GPIO_06
+D11,GPIO_05
+D12,GPIO_04
+D13,GPIO_03
+D14,GPIO_01
+D15,GPIO_02
+A0,GPIO_AD_02
+A1,GPIO_AD_01
+A2,GPIO_AD_00
+A3,GPIO_AD_05
+A4,GPIO_AD_10
+A5,GPIO_AD_08
+LED,GPIO_03
+NEOPIXEL,GPIO_00
+ESP_RESET,GPIO_AD_07
+ESP_BUSY,GPIO_AD_11
+ESP_CS,GPIO_AD_14
+ESP_GPIO0,GPIO_SD_05
+SCK,GPIO_AD_06
+MISO,GPIO_AD_03
+MOSI,GPIO_AD_04