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

Couldn't get this version to work -- have a working fork #10

Open
matteius opened this issue Dec 24, 2023 · 13 comments
Open

Couldn't get this version to work -- have a working fork #10

matteius opened this issue Dec 24, 2023 · 13 comments

Comments

@matteius
Copy link

matteius commented Dec 24, 2023

I tried this one and flashrom couldn't even communicate with the programmer -- I think its pio related (not sure entirely, I later tried in my own implementation the pio but couldn't get it to work either) -- in the version I forked (https://codeberg.org/libreboot/pico-serprog) it could communicate but couldn't read more than a small part of the rom without getting an error. That's when I tried again with pio -- to no avail, but I realized only a subset of the serprog spec is implemented: https://github.com/flashrom/flashrom/blob/main/Documentation/serprog-protocol.txt

So the problem I faced in the second version was actually that neither project implemented the commands that tell flashrom how much buffer the device can handle. Once I implemented these and some other commands, I got it to work. I tried 1024, then 512, and then went to 8 because the higher value buffers got out of sync/didn't work for me. But 8 works great -- its slow, takes about 10-12 minutes to read a 16MB rom chip, and about the same to write, except write is a read + write + read, so about 30-40 minutes for that.

Here is my version in case its helpful to anyone, the main branch is whats working for me and then I have two pio related PRs I could never get to work: https://github.com/opensensor/pico-serprog I would have forked from this branch but my code is closer in line with the libreboot codeberg version.

Example:

Probing for Generic unknown SPI chip (REMS), 0 kB: compare_id: id1 0xa1, id2 0x17
Found Unknown flash chip "SFDP-capable chip" (16384 kB, SPI).
===
This flash part has status UNTESTED for operations: WP
The test status of this chip may have been updated in the latest development
version of flashrom. If you are running the latest development version,
please email a report to flashrom@flashrom.org if any of the above operations
work correctly for you with this flash chip. Please include the flashrom log
file for all operations you tested (see the man page for details), and mention
which mainboard or programmer you tested in the subject line.
Thanks for your help!
Reading flash... read_flash:  region (00000000..0xffffff) is readable, reading range (00000000..0xffffff).
done.
serprog: Output drivers disabled

Note -- the version I have uses a different pin-out than version.

@nezza
Copy link
Contributor

nezza commented Dec 24, 2023

Hi Matteius, thanks a lot!

I only tested with JEDEC compatible flashes, so maybe that's an issue? Can you share the type of flash-chip you're using?

Thanks,
Thomas

@matteius
Copy link
Author

These are 8-pin soc 16MB and 8MB style eeprom chips, for example: https://datasheet.lcsc.com/lcsc/2109132030_FUDAN-MICRO-FM25Q128A-SOB-T-G_C908405.pdf

I haven't done a ton of C programming since college, so I couldn't get PIO example to work (or at least I don't think I am using PIO) but I have to buffer the data into 32 byte chunks, tried 64 and that failed to. I couldn't do it without implementing the commands that tell flashrom what the buffer size is, otherwise when it buffered the stream in memory, flashrom got unexpected byte codes.

I don't have the window open anymore from when I first was working with it, but with my version I can get:

# ./flashrom.exe -p serprog:dev=COM23:2000000 -c "GD25B128B/GD25Q128B" -r gokev300-camera-12242023.bin -VV --force
flashrom 1.4.0-devel (git:v1.2-1386-g5106287e) on Windows 10.0 (x86_64)
flashrom is free software, get the source code at https://flashrom.org

Using clock_gettime for delay loops (clk_id: 1, resolution: 100ns).
flashrom was built with GCC 13.2.0, little endian
Command line (8 args): C:\msys64\home\matte\flashrom\flashrom.exe -p serprog:dev=COM23:2000000 -c GD25B128B/GD25Q128B -r gokev300-camera-12242023.bin -VV --force
Initializing serprog programmer
Baud rate is 2000000.
serprog: connected - attempting to synchronize
.
serprog: Synchronized
serprog: Interface version ok.
serprog: Bus support: parallel=off, LPC=off, FWH=off, SPI=on
serprog: Maximum write-n length is 32
serprog: Maximum read-n length is 32
serprog: Programmer name is "pico-serprog"
serprog: Serial buffer size is 64
Warning: Automatic command availability check failed for cmd 0x07 - won't execute cmd
Warning: NAK to query operation buffer size
serprog: operation buffer size is 300
serprog: Warning: Programmer does not support toggling its output drivers
The following protocols are supported: SPI.
Probing for GigaDevice GD25B128B/GD25Q128B, 16384 kB: compare_id: id1 0xc8, id2 0x4018
Added layout entry 00000000 - 00ffffff named complete flash
Found GigaDevice flash chip "GD25B128B/GD25Q128B" (16384 kB, SPI) on serprog.
Chip status register is 0x00.
Chip status register: Status Register Write Disable (SRWD, SRP, ...) is not set
Chip status register: Block Protect 4 (BP4) is not set
Chip status register: Block Protect 3 (BP3) is not set
Chip status register: Block Protect 2 (BP2) is not set
Chip status register: Block Protect 1 (BP1) is not set
Chip status register: Block Protect 0 (BP0) is not set
Chip status register: Write Enable Latch (WEL) is not set
Chip status register: Write In Progress (WIP/BUSY) is not set
This chip may contain one-time programmable memory. flashrom cannot read
and may never be able to write it, hence it may not be able to completely
clone the contents of this chip (see man page for details).
===
This flash part has status UNTESTED for operations: WP
The test status of this chip may have been updated in the latest development
version of flashrom. If you are running the latest development version,
please email a report to flashrom@flashrom.org if any of the above operations
work correctly for you with this flash chip. Please include the flashrom log
file for all operations you tested (see the man page for details), and mention
which mainboard or programmer you tested in the subject line.
Thanks for your help!
serprog_delay used, but programmer doesn't support delays natively - emulating
Block protection is disabled.
Reading flash... read_flash:  region (00000000..0xffffff) is readable, reading range (00000000..0xffffff).
done.

@matteius
Copy link
Author

matteius commented Jan 4, 2024

@nezza Curious too -- did you use flashrom? Because when I compiled this version I actually couldn't even get flashrom to see the programmer until I found the libreboot fork.

@mikerupp1986
Copy link

Hello, I am running the latest Kali Linux as my OS. I am trying to learn the Pi Pico. I am new to it. I need a direction to compile this and any advice or tutorial would help. I am working on a 2005 Dodge Neon pcm. It's the four plug version and not the stx module. I need to get the VIN and Key code data off the eeprom and flash to donor pcm from a 2003 neon. It's a project. Most everything is expensive with Chrysler and I am beating the odds because it has been done before. Normally I can just open the Skim module and go that route. But Chrysler uses ST95080 8-pin. There are three on this pcm module and a philips eeprom too. This is a nightmare because this pcm has a sticky epoxy rubber that has to be cleaned off the board to access any of the 8-pin eeproms. I'm trying to understand which one has all my data that I need and then flash everything to the donor. Anyway, I need to get my Pi Pico up and running so I can start reverse engineering. My Kali is 2023.4 and Pi Pico is the latest for micro python. I do like the drag and drop programming. I just don't know how to create the "u2f". Note: I am not a programmer by any means. I use what is already created. Any help is greatly appreciated.

@matteius
Copy link
Author

matteius commented Jan 7, 2024

@mikerupp1986 if you send me an email (its in my github profile) I'll forward you a pre-built uf2 of my fork that I have been using.

@mikerupp1986
Copy link

my user handle @gmail

@mikerupp1986
Copy link

@matteius thank you. I will try this out.

@Happylifebored
Copy link

Happylifebored commented Jun 29, 2024

@matteius could i also get that pre-built uf2?
happylifebored@gmail.com

@Happylifebored
Copy link

@matteius pleasee

@matteius
Copy link
Author

Its published in my fork on the releases -- if you'd even look you would have found it.

@Happylifebored
Copy link

i downloaded the pico serprog code from ur directory at https://github.com/opensensor/pico-serprog but didnt see the uf2 file, ig i have to keep looking

@Happylifebored
Copy link

i feel so stupid staring at the forked repository i might order an ch341a 😭😭

@Happylifebored
Copy link

after much staring i found what u meant and should have been obvious for me, tysmm @matteius, sorry if i bothered much im not much of an github user

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

4 participants