Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not guess flash more than 16MB correctly #193

Open
zx-wowuying opened this issue Jan 5, 2025 · 1 comment
Open

Can not guess flash more than 16MB correctly #193

zx-wowuying opened this issue Jan 5, 2025 · 1 comment

Comments

@zx-wowuying
Copy link

zx-wowuying commented Jan 5, 2025

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.

@will-v-pi
Copy link
Contributor

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.

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

No branches or pull requests

2 participants