picotool load file.bin -o 0x11000000 always fails with second flash chip present and configured

Open Beginner friendly
#360 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp
Domain
cli, embedded-iot

Research direction

Start at the load_guts function and inspect the flash-size validation around the reported comparison. Reproduce picotool load file.bin -o 0x11000000 with a configured second flash chip, then verify the command succeeds without regressing the flash-size error for an out-of-range offset.

Written by the indexing model from the issue text.

Description

Failure:

ERROR: File size 0x100 starting at 0x1000000 is too big to fit in flash size 0x200000

Appears to be due to a bug in #121 where an offset is compared against an address. Offending line and proposed fix which I've tested.

@@ -5277,7 +5278,7 @@ bool load_guts(picoboot::connection con, iostream_memory_access &file_access) {
         uint32_t size_guess = guess_flash_size(raw_access);
         if (size_guess > 0) {
             // Skip check when targeting PSRAM, which is anything above 0x11000000
-            if (flash_start_offset < FLASH_END_RP2040 && (flash_start_offset + flash_data_size) > size_guess) {
+            if (flash_start_offset < (FLASH_END_RP2040 - FLASH_START) && (flash_start_offset + flash_data_size) > size_guess) {
                 if (flash_start_offset) {
                     fail(ERROR_NOT_POSSIBLE, "File size 0x%x starting at 0x%x is too big to fit in flash size 0x%x", flash_data_size, flash_start_offset, size_guess);
                 } else {
Dominant language
C++
Stars
999
Forks
189
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from raspberrypi/picotool

All issues in raspberrypi/picotool

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.