Skip to content

Verified TBYB flag works as intended#293

Merged
devYaoYH merged 8 commits intomainfrom
yiheng/ota-mvp-tbyb
Mar 1, 2026
Merged

Verified TBYB flag works as intended#293
devYaoYH merged 8 commits intomainfrom
yiheng/ota-mvp-tbyb

Conversation

@devYaoYH
Copy link
Copy Markdown
Contributor

build and flashing sequence:

Load the partition table

picotool load ota_mvp/pt.uf2 -f
picotool reboot

First build the 'main' version of the code that will call reboot into the second partition

bazel build //ota_mvp:ota --config=pico
picotool load bazel-bin/ota_mvp/ota.uf2 -p 0 -f

Then build the new version of the code that will have Try-Before-You-Buy (TBYB) flag set

bazel build //ota_mvp:ota --config=ota-blink
picotool load bazel-bin/ota_mvp/ota.uf2 -p 1 -f

Now you can reboot which will start the code executing in partition 0 for ~6s (with led turned on constantly)

picotool reboot

At the end of ~6s it will call rom_reboot into partition 1 (with led blinking) for around 17s (watchdog timer). Since we never call explicit_buy, this software watchdog timer will reboot us back into partition 0!

@devYaoYH devYaoYH requested a review from QuackWifHat February 28, 2026 22:10
Copy link
Copy Markdown
Contributor

@QuackWifHat QuackWifHat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

quack and others added 2 commits February 28, 2026 15:35
…the TBYB version from getting rebotted every 16 seconds
@devYaoYH
Copy link
Copy Markdown
Contributor Author

devYaoYH commented Mar 1, 2026

Thanks for the fix to write partition bytes! I've verified that the writing actually works \o/ @QuackWifHat

Comment thread ota_mvp/main.c
// <--- the following doesn't work at all --->
// // Read vector table from partition 1 using NON-CACHED XIP
// uint32_t *vector_table = (uint32_t *)0x1C042000;
uint32_t target_offset = 0x42000;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@QuackWifHat This is a static memory offset to the partition 1 starting address? So assuming we change the partition table, it would no longer work?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment below, we can also extract this using a combination of rom_get_partition_table_info and rom_get_b_partition calls.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that is correct, it would stop working if we change the partition table. It would be better to move this to a more dynamic call, like rom_get_partition_table_info, I will try allocating some cycles to get on this soon.

@devYaoYH
Copy link
Copy Markdown
Contributor Author

devYaoYH commented Mar 1, 2026

We could also potentially extract the b_partition address offset dynamically:

[13:02:19.675] Partition Table Information:
[13:02:19.678] ----------------------------
[13:02:19.681] Has partition table: Yes
[13:02:19.684] Number of partitions: 3
[13:02:19.686] Partition 0:
[13:02:19.688]   Location: 0x00002000 (8 KB from flash start)
[13:02:19.692]   Size: 256 KB
[13:02:19.694] Partition 1:
[13:02:19.696]   Location: 0x00042000 (264 KB from flash start)
[13:02:19.701]   Size: 256 KB
[13:02:19.702] Partition 2:
[13:02:19.704]   Location: 0x00082000 (520 KB from flash start)
[13:02:19.709]   Size: 15860 KB
[13:02:19.711] === End of Partition Table ===
[13:02:19.714] Raw partition table data dump:
[13:02:19.717]   [0] 0x00000011
[13:02:19.719]   [1] 0x00000103
[13:02:19.721]   [2] 0xffffe000
[13:02:19.723]   [3] 0xfc008000
[13:02:19.725]   [4] 0xfc082002
[13:02:19.727]   [5] 0xfc021001
[13:02:19.729]   [6] 0xfc102042
[13:02:19.731]   [7] 0xfc021003
[13:02:19.733]   [8] 0xfdffc082
[13:02:19.735]   [9] 0xfc011001
[13:02:19.737] Boot info word from sys_info: 0x000000ff
[13:02:19.741] Get recent boot diagnostic from sys_info: 00000000
[13:02:19.746] B partition index of A/B partitioning scheme: 1
[13:02:19.751] Extracted B partition location from partition table: 0x00042000

Not an issue if we never commit to a newer version with explicity_buy, but might become an issue when we do.

@devYaoYH devYaoYH merged commit f9d0ab4 into main Mar 1, 2026
9 checks passed
@devYaoYH devYaoYH mentioned this pull request Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants