You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expand the ota_update readme; there's a lot of ground covered here. (#685)
* Expand the `ota_update` readme; there's a lot of ground covered here.
* Some updates (#686)
Still need to include something about Wifi "firmware" updates?
* Further improve readme.
* Fix it's
* Some fixes
* Update README.md
* Update README.md again
---------
Co-authored-by: Peter Harper <[email protected]>
Co-authored-by: Peter Harper <[email protected]>
Co-authored-by: Graham Sanderson <[email protected]>
This example requires a partition table in flash. This can be loaded by creating a UF2 from the partition table JSON in this folder:
1
+
# Overview
2
+
3
+
This example demonstrates how to implement an Over-The-Air (OTA) software update mechanism using facilities provided by the RP2350 bootrom.
4
+
5
+
A python script runs on a host machine to _push_ a new (UF2 format) application image to a Pico 2 W running the `ota_update` example application. The incoming application image is received via the LwIP IP stack and programmed into Pico 2 W flash memory.
6
+
7
+
Two flash partitions ("A"/"B") are used for application images so that the application can be running from one, while the new application image is being written to the other. The RP2350 bootrom provides support for determining the location in flash memory of the partition to use for the new version of the application.
8
+
9
+
On successful completion of the flash programming, the Pico 2 W is rebooted and the updated applicating image is selected and executed by the RP2350 bootrom. This process can be repeated as required.
10
+
11
+
## More detail
12
+
13
+
The Pico 2 W listens on TCP port 4242. The host [python_ota_update.py](python_ota_update.py) script transmits the update image in a series of fixed sized chunks. Each chunk contains an integer number of UF2 image blocks. If the update image UF2 block count is not an exact sub-multiple of the number of chunks the script will pad the last chunk as required.
14
+
15
+
On receipt of pushed chunks, the ota_update image will program the UF2 block stream into flash. In addition to programming, each chunk is 'hashed', using SHA256, and the calculated hash transmitted to the host as an acknowledgement of the received chunk. The host script compares the local and remotely computed hashes and if data corruption has occurred the update will halt.
16
+
17
+
The flash must be appropriately partitioned for this example to work. Two partitions are required, one for the currently running software and the other to be updated with incoming data.
18
+
19
+
Note: This example _also_ demonstrates how the CYW43 Wi-fi firmware can be stored in a separate flash partition(s). This means the Pico 2 W application can be updated separately which reduces the size of the update download, but also requires four partitions.
20
+
21
+
For more information flash partitioning and boot image selection please see section 5 of [RP2350 datasheet](https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf)
22
+
23
+
# How to
24
+
25
+
## Flash partitioning
26
+
27
+
Before the example can be run, the Flash on the Pico 2 W must be appropriately partitioned.
28
+
29
+
The required partition data can be loaded by creating a UF2 from the supplied partition table JSON in this folder:
30
+
2
31
```
3
32
picotool partition create main.json pt.uf2
4
33
```
@@ -8,13 +37,44 @@ picotool load pt.uf2
8
37
picotool reboot -u
9
38
```
10
39
11
-
Once the partition table is loaded, you first need to load the Wi-Fi firmware UF2 (`picow_ota_update_wifi_firmware.uf2`) followed by loading & executing the main program (`picow_ota_update.uf2`) - either by dragging and dropping them in order, or using `picotool`:
40
+
> **NOTE**
41
+
> `reboot -u` reboots the device (as is required to install the partition table) then returns to BOOTSEL mode so we can send more commands to the device.
42
+
43
+
With the partition table loaded, you then need to load the Wi-Fi firmware UF2 (`picow_ota_update_wifi_firmware.uf2`) and load and execute the main program (`picow_ota_update.uf2`) - either by dragging and dropping them in order, or using `picotool`:
12
44
```
13
45
picotool load picow_ota_update_wifi_firmware.uf2
14
46
picotool load -x picow_ota_update.uf2
15
47
```
16
48
17
-
Once running, you can use [python_ota_update.py](python_ota_update.py) to upload new UF2s to it using it's IP address:
49
+
> **NOTE**
50
+
> The first `load` writes the Wifi Firmware into one of the partitions set aside for that. The second `load -x` loads the main application code into one of the main partitions, then resets the chip to start execution
51
+
52
+
## Operation
53
+
54
+
This example will send debug output text on the default UART. On startup it displays the current boot partition (from where the firmware is running) and IP address of the Pico 2 W
Once running, you can use [python_ota_update.py](python_ota_update.py) to upload new UF2s from the host to the Pico 2 W using its IP address. For example:
This will update the Pico 2 W at `192.168.0.103` with the specified image.
66
+
67
+
```
68
+
Code Target partition is fc6d21b6 fc061003
69
+
Start 1b6000, End 36a000, Size 1b4000
70
+
Done - rebooting for a flash update boot 0
71
+
Chosen CYW43 firmware in partition 2
72
+
Boot partition was 1
73
+
Someone updated into me
74
+
Flash update base was 101b6000
75
+
Update info 1
76
+
Update info now 4
77
+
Starting server at 192.168.0.103 on port 4242
78
+
```
79
+
80
+
The update is downloaded into the main partition that's not currently in use, before rebooting the Pico 2 W to run the new version of the software. This choice of software is made by the RP2350 bootrom based on the version number of the software
0 commit comments