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
This example uses a python script running on a host machine to _push_ new operating software image to a specified Pico 2 W running this `ota_update` example image. The incoming image is programmed into Pico 2 W flash memory.
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 operating software image to a Pico 2 W running the `ota_update` example image. The incoming image is received via the LwIP IP stack and programmed into Pico 2 W flash memory.
4
6
5
7
On successful completion of the flash programming, the Pico 2 W will be rebooted and the updated operating image will be selected and executed by the RP2350 bootrom. This process can be repeated as required.
6
8
7
9
## More detail
8
10
9
-
The Pico 2 W operates as a server which listens on TCP port 4242. The incoming octet stream, pushed by the host, is expected to be a sequence of UF2 blocks which are programmed into Pico 2 W flash using the APIs provided by the RP2350 bootrom. In addition to programming, the received data is 'hashed' using the RP2350 SHA256 hardware, and the hash sent back to host to allow integrity checking.
11
+
The Pico 2 W listens on TCP port 4242. The incoming octet stream, pushed by the host, is expected to be a sequence of UF2 blocks which are programmed into Pico 2 W flash using the APIs provided by the RP2350 bootrom. In addition to programming, the received data is 'hashed' using the RP2350 SHA256 hardware, and the hash sent back to host to allow integrity checking.
10
12
11
-
The flash must be appropriately partitioned for this example to work; most obviously *two*` IMAGE_DEF` partitions are required, one for the running software and the other which is updated by the example software.
13
+
The flash must be appropriately partitioned for this example to work. Two ` IMAGE_DEF` partitions are required, one for the currently running software and the other which is updated by the `ota_update` example.
12
14
13
-
Note: This example _also_ demonstrates storage of the CYW43 Wi-fi firmware object using additional flash partition(s) although this firmware is not updated by this example.
15
+
Note: This example _also_ demonstrates how the CYW43 Wi-fi firmware can be stored in a separate flash partition(s) which is not updated by the `ota_update`example. This reduces the size of the update that's downloaded.
14
16
15
17
For more information flash partitioning and boot image selection please see section 5 of [RP2350 datasheet](https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf)
16
18
@@ -20,7 +22,7 @@ For more information flash partitioning and boot image selection please see sect
20
22
21
23
Before the example can be run, the Flash on the Pico 2 W must be appropriately partitioned.
22
24
23
-
Flash partitioning only needs doing only once for this example but, as written below, will completely remove any previous flash contents.
25
+
Flash partitioning only needs to be done once for this example but, as written below, will completely remove any previous flash contents.
24
26
25
27
The required partition data can be loaded by creating a UF2 from the partition table JSON in this folder:
26
28
@@ -33,19 +35,44 @@ picotool load pt.uf2
33
35
picotool reboot -u
34
36
```
35
37
36
-
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 and executing the main program (`picow_ota_update.uf2`) - either by dragging and dropping them in order, or using `picotool`:
38
+
> [!NOTE]
39
+
> `reboot -u` reboots back to bootsel mode so we can send more commands to the device
40
+
41
+
Once the partition table is loaded, you then need to load the Wi-Fi firmware UF2 (`picow_ota_update_firmware.uf2`) followed by loading and executing the main program (`picow_ota_update.uf2`) - either by dragging and dropping them in order, or using `picotool`:
37
42
```
38
-
picotool load picow_ota_update_wifi_firmware.uf2
43
+
picotool load picow_ota_update_firmware.uf2
39
44
picotool load -x picow_ota_update.uf2
40
45
```
41
46
47
+
NOTE]
48
+
> `load -x` attempts to execute the uf2 after the load
49
+
42
50
### Operation
43
51
44
-
Once running, you can use [python_ota_update.py](python_ota_update.py) to upload new UF2s from the host to it using it's IP address. For example:
52
+
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
53
+
54
+
```
55
+
Boot partition was 0
56
+
Starting server at 192.168.0.103 on port 4242
57
+
```
58
+
59
+
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 it's IP address. For example:
This will update the Pico 2 W at `192.168.0.103` with the specified image.
48
64
49
-
Will update the Pico 2 W at `192.168.0.103` with the specified image.
65
+
```
66
+
Code Target partition is fc6d21b6 fc061003
67
+
Start 1b6000, End 36a000, Size 1b4000
68
+
Done - rebooting for a flash update boot 0
69
+
Chosen CYW43 firmware in partition 2
70
+
Boot partition was 1
71
+
Someone updated into me
72
+
Flash update base was 101b6000
73
+
Update info 1
74
+
Update info now 4
75
+
Starting server at 10.3.195.246 on port 4242
76
+
```
50
77
51
-
Note: This example will send debug output text on the default UART 0, `GPIO 0`.
78
+
The update is downloaded into the free boot partition that's not currently in use, before rebooting the Pico 2 W to take the new software into use. After the restart the boot partition should have changed.
0 commit comments