Skip to content

Commit d467f4b

Browse files
More ota_update readme changes (#688)
1 parent 9b4c332 commit d467f4b

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

pico_w/wifi/ota_update/README.md

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ picotool load -x picow_ota_update.uf2
4949
> **NOTE**
5050
> 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
5151
52+
The device should now have the following firmware layout.
53+
54+
| Partition | Purpose |
55+
| ----------|-------- |
56+
| 0 | Partition A for the application firmware |
57+
| 1 | Partition B for the application firmware |
58+
| 2 | Partition A for the wifi firmware |
59+
| 3 | Partition B for the wifi firmware |
60+
5261
## Operation
5362

5463
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
@@ -65,16 +74,29 @@ python ./python_ota_update.py 192.168.0.103 picow_ota_update.uf2
6574
This will update the Pico 2 W at `192.168.0.103` with the specified image.
6675

6776
```
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
7277
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
7878
```
7979

8080
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
81+
82+
## Try before you Buy
83+
84+
The `picow_ota_update.uf2` application is marked with the "Try Before You Buy" (TBYB) attribute by specifying `PICO_CRT0_IMAGE_TYPE_TBYB=1` in its compile definitions.
85+
86+
This means that if a newly downloaded image partition is not explicitly "bought" by calling the `rom_explicit_buy` function within 16.7 seconds, the device will reboot and revert to the previously used partition. This gives some protection against a bad OTA update being applied. See section 5.1.17 of [RP2350 datasheet](https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf) for more details about Try Before You Buy.
87+
88+
### Wifi Firmware
89+
90+
This example also demonstrates how TBYB can be applied to other partitions - in this case the Wifi firmware. In debug builds you should see debug output which shows the partition that's currently being used for the wifi firmware.
91+
92+
The example uses the `pico_use_wifi_firmware_partition` keyword to make the Wifi firmware appear in its own partition rather than embedded in the application as is usually the case.
93+
94+
```
95+
Chosen CYW43 firmware in partition 2
96+
```
97+
98+
Two UF2 files are generated for the wifi firmware, `picow_ota_update_wifi_firmware.uf2` and `picow_ota_update_wifi_firmware_tbyb.uf2`. These images are the same except only the latter image has the TBYB attribute set.
99+
100+
You can update the current Wifi partition with these UF2 files using [python_ota_update.py](python_ota_update.py).
101+
102+
If you use `picow_ota_update_wifi_firmware_tbyb.uf2` for the update then if something goes wrong before the partition is explicitly "bought" by calling the `rom_explicit_buy` function, then the device will switch back to the previous working Wifi firmware partition after a reboot. This does not happen if you use `picow_ota_update_wifi_firmware.uf2` for the update. In this way the TBYB attribute gives you some protection against an OTA update applying bad Wifi firmware.

0 commit comments

Comments
 (0)