picotool
picotool copied to clipboard
Can not guess flash more than 16MB correctly
I designed a development board with two 16M flash chips and correctly configured the opt parameters, but picotool can only recognize 16M of space.I found an issue in the source code of guess_flash_size
// Read at decreasing power-of-two addresses until we don't see the boot pages again
const int min_size = 16 * PAGE_SIZE;
const int max_size = 8 * 1024 * 1024;
int size;
for (size = max_size; size >= min_size; size >>= 1) {
auto new_pages = access.read_vector<uint8_t>(FLASH_START + size, 2 * PAGE_SIZE);
if (!std::equal(first_two_pages.begin(), first_two_pages.end(), new_pages.begin())) break;
}
return size * 2;
Then I change the max_size to 16x1024x1024,All the picotool functions,such as info /load/save .. can run correctly.
Considering future scalability, there should be a better configuration option to address this issue.
This won't work correctly if you had, for example, an 16M and an 8M flash chip connected, or an 8M flash and an 8M PSRAM chip connected - this fuction can only correctly guess the flash size for a single chip select window.
You'll have to load files separately into CS0 and CS1 windows, which was fixed with #121 - this should make it possible to use picotool save --range 0x11000000 0x12000000 cs1.bin to save the data from the second flash chip, and picotool load --offset 0x11000000 cs1.bin to load files into the second flash chip.