|
1 | 1 | ## 1. Deploy the MicroPython firmware to the Metro M7 board.
|
2 | 2 |
|
3 |
| -### 1.1 Deploy the firmware using the serial bootloader. |
4 |
| - |
5 |
| -For initial deployment of the firmware a few preparation steps are required, which |
6 |
| -have to be done once. |
7 |
| - |
8 |
| -1. Get the files ufconv.py and uf2families.json from the micropython/tools directory, |
9 |
| -e.g. at https://github.com/micropython/micropython/tree/master/tools. |
10 |
| - |
11 |
| -2. Get the NXP program sdphost for your operating system, e.g. from |
12 |
| -https://github.com/adafruit/tinyuf2/tree/master/ports/mimxrt10xx/sdphost. |
13 |
| -You can also get them from the NXP web sites. |
14 |
| - |
15 |
| -3. Get the UF2 boot-loader package https://github.com/adafruit/tinyuf2/releases/download/0.9.0/tinyuf2-imxrt1010_evk-0.9.0.zip |
16 |
| -and extract the file tinyuf2-imxrt1010_evk-0.9.0.bin. |
17 |
| - |
18 |
| -Now you have all files at hand that you will need for updating. |
19 |
| - |
20 |
| -1. Get the firmware you want to upload from the MicroPython download page. |
21 |
| - |
22 |
| -2. Set the two BOOTSEL DIP switches to the 1/0 position, which is the opposite position of the normal use mode. |
23 |
| - |
24 |
| -3. Push the reset button. |
25 |
| - |
26 |
| -4. Run the commands: |
27 |
| - |
28 |
| -``` |
29 |
| -sudo ./sdphost -u 0x1fc9,0x0145 -- write-file 0x20206400 tinyuf2-imxrt1010_evk-0.9.0.bin |
30 |
| -sudo ./sdphost -u 0x1fc9,0x0145 -- jump-address 0x20207000 |
31 |
| -``` |
32 |
| -Wait until a drive icon appears on the computer (or mount it explicitly), and then run: |
33 |
| -``` |
34 |
| -python3 uf2conv.py <firmware_xx.yy.zz.hex> --base 0x60000400 -f 0x4fb2d5bd |
35 |
| -``` |
36 |
| -You can put all of that in a script. Just add a short wait before the 3rd command to let the drive connect. |
37 |
| - |
38 |
| -5. Once the upload is finished, set the BOOTSEL DIP switches back to the 0/1 position and push reset. |
39 |
| - |
40 |
| -Using sudo is Linux specific. You may not need it at all, if the access rights are set properly, |
41 |
| -and you will not need it for Windows. |
42 |
| - |
43 |
| -### 1.2 Deploy the firmware using a JTAG adapter. |
44 |
| - |
45 |
| -With a JTAG adapter the firmware can be easily installed. Appropriate tools are Segger JFlash Lite and |
46 |
| -the Segger Edu Mini adapter. Just use the firmware.hex file for loading, which will be loaded at the |
47 |
| -proper address. |
48 |
| - |
49 |
| - |
50 |
| -## 2. Deploy the WiFi firmware. |
51 |
| - |
52 |
| -The NINA firmware in the NINA module has to be updated for use with MicroPython. That can be done |
53 |
| -using MicroPython and two small Python scripts. |
54 |
| - |
55 |
| -The firmware binaries are available at |
56 |
| -https://github.com/micropython/micropython-lib/tree/master/micropython/espflash |
57 |
| -or https://github.com/robert-hh/Shared-Stuff. For the Metro M7 board, the |
58 |
| -NINA_FW_v1.5.0_Airlift.bin file is needed. |
59 |
| - |
60 |
| -For firmware upload, the following connections to the WiFi module are required: |
61 |
| - |
62 |
| -- Pin Reset (as above) |
63 |
| -- Pin GPIO0 |
64 |
| -- UART RX |
65 |
| -- UART TX |
66 |
| - |
67 |
| -The GPIO pins and UART device id varies between boards. At the Adafruit Metro M7 board, |
68 |
| -the UART is UART(1), and the Pin names for reset and GPIO0 are ESP_RESET and ESP_GPIO0. |
69 |
| -The firmware can be uploaded, using the espflash.py module, a short script |
70 |
| -using espflash.py and mpremote. espflash.py is available at |
71 |
| -https://github.com/micropython/micropython-lib/tree/master/micropython/espflash. |
72 |
| -This place also holds the example script. |
73 |
| - |
74 |
| -``` |
75 |
| -import espflash |
76 |
| -from machine import Pin |
77 |
| -from machine import UART |
78 |
| -import sys |
79 |
| -sys.path.append("/flash") |
80 |
| -
|
81 |
| -reset = Pin("ESP_RESET", Pin.OUT) |
82 |
| -gpio0 = Pin("ESP_GPIO0", Pin.OUT) |
83 |
| -uart = UART(0, 115200, timeout=350) |
84 |
| -
|
85 |
| -md5sum = b"b0b9ab23da820a469e597c41364acb3a" |
86 |
| -path = "/remote/NINA_FW_v1.5.0_Airlift.bin" |
87 |
| -
|
88 |
| -esp = espflash.ESPFlash(reset, gpio0, uart) |
89 |
| -# Enter bootloader download mode, at 115200 |
90 |
| -esp.bootloader() |
91 |
| -# Can now change to higher/lower baud rate |
92 |
| -esp.set_baudrate(921600) |
93 |
| -# Must call this first before any flash functions. |
94 |
| -esp.flash_attach() |
95 |
| -# Read flash size |
96 |
| -size = esp.flash_read_size() |
97 |
| -# Configure flash parameters. |
98 |
| -esp.flash_config(size) |
99 |
| -# Write firmware image from internal storage. |
100 |
| -esp.flash_write_file(path) |
101 |
| -# Compares file and flash MD5 checksum. |
102 |
| -esp.flash_verify_file(path, md5sum) |
103 |
| -# Resets the ESP32 chip. |
104 |
| -esp.reboot() |
105 |
| -``` |
106 |
| - |
107 |
| -The script shows the set-up for the Metro M7 board. |
108 |
| -The md5sum is the one of the WiFi firmware. It may change and |
109 |
| -can be recalculated using e.g. the Linux `md5sum` command. It is used to |
110 |
| -verify the firmware upload. To upload the firmware, place the firmware |
111 |
| -and the above script (let's call it ninaflash.py) into the same directory |
112 |
| -on your PC, and run the command: |
113 |
| -``` |
114 |
| -mpremote connect <port> mount . run ninaflash.py |
115 |
| -``` |
116 |
| -After a while, the upload will start. A typical start sequence looks like: |
117 |
| -``` |
118 |
| -Local directory . is mounted at /remote |
119 |
| -Failed to read response to command 8. |
120 |
| -Failed to read response to command 8. |
121 |
| -Changing baudrate => 921600 |
122 |
| -Flash attached |
123 |
| -Flash size 2.0 MBytes |
124 |
| -Flash write size: 1310720 total_blocks: 320 block size: 4096 |
125 |
| -Writing sequence number 0/320... |
126 |
| -Writing sequence number 1/320... |
127 |
| -Writing sequence number 2/320... |
128 |
| -Writing sequence number 3/320... |
129 |
| -Writing sequence number 4/320... |
130 |
| -.... |
131 |
| -.... |
132 |
| -Writing sequence number 317/320... |
133 |
| -Writing sequence number 318/320... |
134 |
| -Writing sequence number 319/320... |
135 |
| -Flash write finished |
136 |
| -Flash verify: File MD5 b'b0b9ab23da820a469e597c41364acb3a' |
137 |
| -Flash verify: Flash MD5 b'b0b9ab23da820a469e597c41364acb3a' |
138 |
| -Firmware verified. |
139 |
| -``` |
140 |
| -The initial messages `Failed to read response to command 8.` |
141 |
| -can be ignored. |
| 3 | +The Metro M7 board comes pre-installed with a UF2 bootloader. It can |
| 4 | +be started by pushing reset twice. Then the bootloader drive will |
| 5 | +appear. If that does not happen or the bootloader was lost, you can |
| 6 | +reinstall the bootloader using the instructions by Adafruit |
| 7 | +here: https://learn.adafruit.com/adafruit-metro-m7-microsd/installing-the-bootloader |
| 8 | + |
| 9 | +Once the bootloader is installed and started, you can install MicroPython |
| 10 | +by copying the .uf2 version of the firmware file to the bootloader |
| 11 | +drive. When the firmware is installed, the drive will disappear. |
0 commit comments