Need help with PIO for SPI ROM chip reads

December 23, 2023, 22:10

matteius

Background -- I recently discovered https://github.com/stacksmashing/pico-serprog and since I have a ton of picos and no rom programmers I thought I'd give it ago, except flashrom doesn't detect it as a programmer. Then I discovered the fork https://codeberg.org/libreboot/pico-serprog except that it doesn't implement all commands. So today I forked it: https://github.com/opensensor/pico-serprog and implemented remaining commands. I think started refactoring the primary rom read command S_CMD_O_SPIOP -- seems to be the problem is related to flashrom reading the entire 16 MB rom I can read from the chip as long as I read a subset that can fit into pico memory and send it one go -- as soon as I chunk the payload the communications with flashrom break. I've started trying to implement pio spi in a branch, but I am kind of confused. It compiles, but no data is received for the large chunks, meaning the new pio code I added isn't quite right: https://github.com/opensensor/pico-serprog/pull/1/files

matteius

Here is what I have tried the last hours since making this post -- its communicating, kind of, but not getting the right bytes back I feel. https://github.com/opensensor/pico-serprog/pull/2

matteius

Well I never got pio to work right with it yet, but I think I found an alternative solution -- there were some missing serprog commands not implemented, and two of them said the maximum buffer size the device could support. Even with that I couldn't get a large buffer like 512 to work, so I restricted it to 8 and it seems to be reading the rom chip, and takes a really long time. Like up to 10 minutes

matteius

But working is a big win for me