mimxrt/boards: Update the deploy instructions for the UF2 bootloader.

Signed-off-by: robert-hh <robert@hammelrath.com>
This commit is contained in:
robert-hh 2024-10-07 08:45:54 +02:00 committed by Damien George
parent 2a80d5c68b
commit 9eb9451d83
4 changed files with 122 additions and 168 deletions

View file

@ -1,141 +1,11 @@
## 1. Deploy the MicroPython firmware to the Metro M7 board. ## 1. Deploy the MicroPython firmware to the Metro M7 board.
### 1.1 Deploy the firmware using the serial bootloader. The Metro M7 board comes pre-installed with a UF2 bootloader. It can
be started by pushing reset twice. Then the bootloader drive will
appear. If that does not happen or the bootloader was lost, you can
reinstall the bootloader using the instructions by Adafruit
here: https://learn.adafruit.com/adafruit-metro-m7-microsd/installing-the-bootloader
For initial deployment of the firmware a few preparation steps are required, which Once the bootloader is installed and started, you can install MicroPython
have to be done once. by copying the .uf2 version of the firmware file to the bootloader
drive. When the firmware is installed, the drive will disappear.
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.

View file

@ -1,39 +1,43 @@
For initial deployment of the firmware a few preparation steps are required, which The Olimex RT1011 board is delivered without firmware. The best option to
install MicroPython is installing a UF2 bootstrap loader first, which then can be
used to install and update MicroPython. The bootloader has to be installed
only once.
For initial deployment of the bootloader a few preparation steps are required, which
have to be done once. have to be done once.
1. Get the files ufconv.py and uf2families.json from the micropython/tools directory, 1. Get the NXP program sdphost for your operating system, e.g. from
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. https://github.com/adafruit/tinyuf2/tree/master/ports/mimxrt10xx/sdphost.
You can also get them from the NXP web sites. 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 2. Get the UF2 boot-loader package https://github.com/adafruit/tinyuf2/releases/tag/0.21.0/tinyuf2-imxrt1010_evk-0.20.1.zip and extract the files `tinyuf2-imxrt1010_evk-0.21.0.bin`
and extract the file tinyuf2-imxrt1010_evk-0.9.0.bin. . You may as well go for a newer release.
Now you have all files at hand that you will need for updating. 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. 1. Get the firmware file you want to upload with the .uf2 extension from the MicroPython download page.
2. Push and hold the "Boot" button, then press "Reset", and release both buttons. 2. Push and hold the "Boot" button, then press "Reset", and release both buttons.
3. Run the commands: 3. Run the commands:
``` ```
sudo ./sdphost -u 0x1fc9,0x0145 -- write-file 0x20206400 tinyuf2-imxrt1010_evk-0.9.0.bin sudo ./sdphost -u 0x1fc9,0x0145 -- write-file 0x20206400 tinyuf2-imxrt1010_evk-0.21.0.bin
sudo ./sdphost -u 0x1fc9,0x0145 -- jump-address 0x20207000 sudo ./sdphost -u 0x1fc9,0x0145 -- jump-address 0x20207000
``` ```
Wait until a drive icon appears on the computer (or mount it explicitly), and then run: Wait until a drive icon appears on the computer (or mount it explicitly). Then the UF2 bootloader
``` is permanently installed.
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.
4. Once the upload is finished, push Reset again.
Using sudo is Linux specific. You may not need it at all, if the access rights are set properly, 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. and you will not need it for Windows.
Once the generic boot-loader is available, this procedure is only required for the first 4. Once the upload of the bootloader is finished, push Reset twice.
firmware load or in case the flash is corrupted and the existing firmware is not functioning
any more. The bootloader should start and show a drive icon. Copy the .uf2 version of MicroPython
to this drive to install or update MicroPython.
Once the UF2 bootloader is installed, only step 4 is required to deploy MicroPython. If
MicroPython is already installed, the bootloader can as well be invoked by calling
`machine.bootloader()`.
If at any time the flash content is corrupted you can always start over from the beginning.

View file

@ -1,6 +1,52 @@
Firmware upload to the Seed ARCH MIX board can be done using the J-Link interface The Seeed Arch Mix board is delivered without firmware. The best option to
For that, follow the instructions given by Seed in their Wiki at install MicroPython is installing a UF2 bootstrap loader first, which then can be
https://wiki.seeedstudio.com/Arch_Mix/#flashing-arduino-bootloader-to-arch-mix. used to install and update MicroPython. The bootloader has to be installed
You will need a J-Link debug probe and software. What has been tested was the only once.
Segger JLlink edu or Segger JLink edu mini. As matching loader tool you can use
Segger JFlashLite. The target address for loading is 0x60000000. For initial deployment of the bootloader a few preparation steps are required, which
have to be done once.
1. 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.
2. Get the UF2 boot-loader package https://github.com/adafruit/tinyuf2/releases/tag/0.20.1/tinyuf2-imxrt1050_evkb-0.21.0.zip and extract the files `tinyuf2-imxrt1050_evkb-0.21.0.bin`.
You may as well go for a newer release.
Now you have all files at hand that you will need for updating.
1. Get the firmware file you want to upload with the .uf2 extension from the MicroPython download page.
2. At the Seeed Arch Mix board, connect the RX pin (J3-19) with 3.3V, and change the DIP switches
3 an 4 at SW1 from 1-0 to 0-1.
3. Push Reset.
4. Run the commands:
```
sudo ./sdphost -u 0x1fc9,0x0130 -- write-file 0x1000 tinyuf2-imxrt1050_evkb-0.21.0.bin
sudo ./sdphost -u 0x1fc9,0x0130 -- jump-address 0x2000
```
Wait until a drive icon appears on the computer (or mount it explicitly). When using the above
mentioned bootloader, it has the label `RT1050BOOT`. Then the UF2 bootloader
is permanently installed.
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.
5. At the Seeed Arch Mix board, disconnect the RX pin (J3-19) with 3.3V, and change the DIP switches
3 an 4 at SW1 back to 1-0.
6. Once the upload of the bootloader is finished or when it is already installed, push Reset twice.
The bootloader should start and show a drive icon. Do not push too fast. The i.MX RT MCU
have no dedicated Reset Pin and are reset through power cycling, which may be slow.
Copy the .uf2 version of MicroPython to this drive to install or update MicroPython.
If after steps 1-4 the bootloader drive is already shown, you do not have to reset again.
Once the UF2 bootloader is installed, only step 6 is required to deploy MicroPython. If
MicroPython is already installed, the bootloader can as well be invoked by calling
`machine.bootloader()` or switching the USB baud rate at the PC to 1200 baud and back.
If at any time the flash content is corrupted you can always start over from the beginning.

View file

@ -1,11 +1,45 @@
Firmware can be loaded to the MIMXRT development boards in various ways. The most convenient ## Firmware installation options
one is using the built-in support MCU. When a PC is connected to the debug USB port, a drive
icon will appear. Firmware can be uploaded to the board by copying it to this drive. The copy There are two ways to load the MicroPython firmware to the device:
and flashing will take a few moments. At the end of the upload, the drive icon will disappear
and reappear again. Then the reset button has to be pushed, which starts the MicroPython firmware. 1. Load the MicroPython firmware directly to the device. The MicroPython
firmware files for that method have the extension .bin or .hex and are available
at the MicroPython download site.
2. Install a resident UF2 bootstrap loader to the device first and use that later for loading
MicroPython. The MicroPython firmware files for that method have the extension .uf2
and are available at the MicroPython download site. The UF2 bootstrap loader can be obtained
from the site https://github.com/adafruit/tinyuf2. Open the recent release page and
get the version of the bootloader for your board. If there is no specific bootloader
for a specific board, get versions for the respective imxrt10xx-evk board. The file
with the .bin or .hex extension is the one to be installed first.
## Direct loading of MicroPython or installation of the UF2 bootloader
The MicroPython firmware or the UF2 bootstrap loader can be loaded to the MIMXRT development
boards in various ways. The most convenient one is using the built-in support MCU. When a PC
is connected to the debug USB port, a drive icon will appear. Firmware can be uploaded to
the board by copying it to this drive. The copy and flashing will take a few moments.
At the end of the upload, the drive icon will disappear and reappear again. Then the reset
button has to be pushed, which starts the MicroPython firmware.
Depending on the power jumper settings, both the debug USB and OTG USB port have to be powered Depending on the power jumper settings, both the debug USB and OTG USB port have to be powered
during firmware upload. during firmware upload.
You may as well load the firmware using the JLink port or openSDA interface with the appropriate tools. You may as well load the firmware using the JLink port or openSDA interface with the appropriate tools.
For more options, consult the user guide of the board. For more options, consult the user guide of the board.
## Installing the MicroPython firmware using the UF2 bootloader
When using the UF2 bootloader, the OTG USB port will be used.
Once the UF2 bootloader is installed, it has to be started to upload MicroPython.The
methods to start the bootloader are:
- Push reset twice.
- Call machine.bootloader() e.g. from REPL.
- Switch the USB port shortly to 1200 baud and back. That requires MicroPython to be
installed.
If there is no valid Firmware on the device, the bootloader will start automatically.
Once it's started, a drive ICON will appear. The MicroPython firmware file with .uf2
extension must then be copied to that drive. When the file is copied and MicroPython
is installed, the drive disappears and MicroPython starts.