linuxboot / heads-wiki

Documentation for the Heads firmware project
83 stars 43 forks source link

Add in place programmer's flashing "best practices" and refer to ch341a rev 1.6+ #120

Open tlaurion opened 1 year ago

tlaurion commented 1 year ago

There is a lot of information out there on ch341a programmer giving too much voltage (5v vs 3.3v). Users reports of having bricked their laptops (SPI chip to motherboards resistors).

One of those example is a recent exchange on slack/matrix accessible at: https://matrix.to/#/!pAlHOfxQNPXOgFGTmo:matrix.org/$kcFoywTcHgKLIbRP3iJ1bgJ8vRUGZsZcCGvvJsCszgw?via=matrix.org&via=nitro.chat&via=talk.puri.sm

xx20/xx30 chips and motherboard resistors are really resilient and cheap ch341a providing 5v never caused any issue, but this may vary for other SPI chips/motherboard when doing in place programming (with a PAMONA clip connected to the chip on the motherboard.)

General guidelines, depending on motherboard is:

  1. Make sure that CMOS, AC Adapter and battery is deconnected.
  2. Make sure to connect the clip on CHIP prior of powering up the programmer (I never followed that even with black programmer and bricked 2 laptops to date because I didn't respect point 1 above.
  3. Other guides suggest to modify ch341 programmer to make sure voltage provided is 3.3v (https://www.chucknemeth.com/laptop/lenovo-x230/flash-lenovo-x230-coreboot being one of them)
  4. Other guides suggest unsoldering/resoldering the SPI for extra caution (never did that)
  5. More expensive programmer (LC Technologies ch341a programmers) were suggested (good general advice)

I would invite people into discussing facts here to be used to create additional flashing best practice page to the wiki.

tlaurion commented 1 year ago

The general guideline is to make sure that the wiring is conform to chip SPI datasheet (this is a standard generally used by a chip family. Here for xx20/xx30 and SOIC8 chips), making sure that orientation of the chip is good is mandatory. On SPI chips, there is a "dot" which inform the eye that that pin is pin 1:

1- CS / CS# 2- SO1-SIO1 / MISO 3- WP# / N/C 4- GND 5- SI-SIO0 / MOSI 6- SCLK / CLK 7- HOLD# / N/C 8- VCC

For example, those two guides inversed the picture with similar pin names:

tlaurion commented 10 months ago

All of this should just replace ch341a by ch341a rev 1.6+ based boards which has output voltage selector (5v, 3.3v, 2.5v, 1.8v).

The ch341a v1.6/v1.7 is easily distinguishable from past versions by the voltage switch and additional components put on board, green color of board and smaller size compared to black one: signal-2024-01-15-102301 Green arrow shows easily distinguishable component not present on 1.1/1.2... 1.5 boards revisions.

One can see the differences between old (black, non versioned ch341a) and green clearly stating v1.7: signal-2024-01-15-104825

When flipping v 1.6+ board upside down, one can see on the board the voltage selection switch slots: signal-2024-01-15-102253

Example of readily available kits including proper pictures for visual identification of 1.6 board containing a voltage selector and the same components being easily distinguishable prior of buying:

https://shop.3mdeb.com/shop/modules/ch341a-flash-bios-usb-programmer-kit-soic8-sop8/

Floahazz 1 Metal Ch341A Programmer V1.7 1.8V Level Shift W25Q64Fw W25Q128Fw Gd25Lq64 Parts https://a.co/d/5hr2I5x

tlaurion commented 7 months ago

1- CS / CS# 2- SO1-SIO1 / MISO 3- WP# / N/C 4- GND 5- SI-SIO0 / MOSI 6- SCLK / CLK 7- HOLD# / N/C 8- VCC

Attacking the w530 today. Clip that came with kit doesn't fit constrained place, needed to rewire my pamona clip with wires that came with my raspberries across the years. They are 10 colors coded, that will help me and probably others replicating.

SPI Chip Pomona Clip Adapter Board CH341A Programmer
Pin 1 (dot) Pin 1 (red dot) VCC (red) 25XX (red stripe)
Pin 2 Pin 2 GND (black) GND (black)
Pin 3 Pin 3 CS (yellow) CS (yellow)
Pin 4 Pin 4 CLK (orange) CLK (orange)
Pin 5 Pin 5 DO (blue) DO (blue)
Pin 6 Pin 6 DI (purple) DI (purple)
Pin 7 Pin 7 (brown) VCC or GND (brown) NC
Pin 8 Pin 8 (white) VCC or GND (white) NC

Then. 1- Connect sopi6/8-dip8 daughter board on ziff connector, making sure the adapter is connected into the closest holes to you when looking at the adapt from the usb connector signal-2023-12-18-181636 signal-2023-12-18-181715 2- Then do the wiring pattern above. Looks like that when done: signal-2023-12-18-181130 signal-2023-12-18-181429

Will definitely glue all those together with Epoxy they slide way too easily, but that works! Got my 8mb backup from w530. Now going to make external flashing image that can be flashed only on that exposed 8mb chip which is https://github.com/linuxboot/heads/issues/1189 to the flash whole maximized image internally.

tlaurion commented 7 months ago

W530 board owners tagged under https://github.com/linuxboot/heads/issues/692

w530 (xx30): @eganonoa @zifxify @weyounsix (dGPU: w530-k2000m) @jnscmns (dGPU K1000M) @computer-user123 (w530 / & w530 k2000 : prefers iGPU) :

What have you done on stock bios for TPM to function correctly to setup TPM DUK? Can't seem to figure it out https://github.com/n4ru/1vyrain/issues/37#issuecomment-1866575025

tlaurion commented 6 months ago

Nevermind TPM error of past message! That was https://github.com/linuxboot/heads/issues/1565.

tlaurion commented 1 month ago

That question popped again under Matrix channel https://matrix.to/#/!pAlHOfxQNPXOgFGTmo:matrix.org/$Y5a44cDMjH-CO96sfpn7ZCHeHkBDrsBjPEatp3mbcLE?via=matrix.org&via=nitro.chat&via=envs.net

tlaurion commented 1 month ago

Concerns raised again at https://matrix.to/#/!pAlHOfxQNPXOgFGTmo:matrix.org/$n56mqz2A0ZCWP1HrqVBkRL1IGKOfqJmsGqTvI8kNP-g?via=matrix.org&via=nitro.chat&via=envs.net

tlaurion commented 4 weeks ago

To be honest, I think this thread and concerns from end users are mixing two different use cases:

Unbricking / initial flashing/non-development related dev cycles / initial external flashing was made from well testers and platform I well tested

There I actually no need here to anything better/faster /safer then a ch341a even at 5v for most older platforms (thinkpads) if all external power sources are disconnected.

dev cycles / debugging /porting of new platforms / multiple flashing a day is needed / newcomers to coreboot and external flashing / insecure end users

There are way better options then ch341a, different prices ranges, different features across reprogrammers, including some development helper kits (Tigard best of line here) that also provide logic analyser), permits to turn programmer into a coreboot usb debugging helper (through serial over usb) which is possible through beaglebone black and Tigard. So the reason this is not yet in docs is because, depending of goals and needs, there are multiple tools out there.

perplexity.ai discussion (made public) : https://www.perplexity.ai/search/Of-all-in-nfyU4c8tQp2.2GONIONnyA

Extract of markdown table:

Programmer Cost Theoretical Speed (16MB) Voltage Selection Flashrom Support Additional Use for Debugging
DediProg SF600Plus-G2 $500-$600 16 seconds Multiple Not mentioned No
DediProg SF100 $200-$300 22 seconds Multiple Not mentioned No
CH341A $5-$15 480 seconds (8 minutes) 3.3V (mod needed) Yes No
Raspberry Pi $35-$80 16 seconds 3.3V (additional hardware needed for other voltages) Yes No
BeagleBone Black $60-$90 16 seconds 3.3V, some pins 1.8V Yes Yes
REVELPROG-IS $150-$200 16 seconds Not specified Not mentioned No
Tigard $69-$89 16 seconds 1.8V, 3.3V, 5.0V, external target voltage Yes Yes
tlaurion commented 3 weeks ago

Will buy a Tigard and test across platforms I own. For some reason,s people don't want to commust ordered one ent on github and stay stubborn having sporadic and non permanent/searchable notes given on Heads matrix channel. Point against Tigard at https://matrix.to/#/!pAlHOfxQNPXOgFGTmo:matrix.org/$WDHLHatL2aVLFCxTK3EX9PUAo8t18yx-eufPSCHdQPk?via=matrix.org&via=nitro.chat&via=envs.net

EDIT: if Tigard testing is good:


Then revise promotion of ch341a v1.6+ to tigard/beaglebone black.

Just ordered a Tigard from https://www.crowdsupply.com/securinghw/tigard for 67$USD (to ship to Canada, prices will vary), which is not bad and a nice project giving money to someone that devotes himself changing things for the better here

tlaurion commented 2 weeks ago

Ideally, we would be able to propose a refreshed version for the beaglebone black screwdriver so that bricking could give input from testers through EHCI debugging logs, based and improved upon https://www.coreboot.org/BeagleBone_Black_-_screwdriver

Or a cheaper alternative, providing both flashrom and usb EHCI debug support, ideally permitting to grab the logs, take micro ssd card/launch command on host and be able to upload those logs in a bug report.

tlaurion commented 6 days ago

Just experienced a n41 bad rom flash from https://github.com/linuxboot/heads/pull/1723/commits/b05fbf6d9f1b88e01ba8fe46dcaa8036c16db8f0

Points:

Tigard, while faster with default settings, was constantly failing on flashrom verify step, and didn't seem to even check if what was attempted to be written was actually written while verify failed at different addresses.

Flashing with ch341a, while slower, successfully unbricked my nv41 with master rom.

Some pictures.... Scary setup. No I'm not zen enough to stay immobile for more then 8 minutes at a time with frustrating failing attempts.

Edit: flashrom loop command added from history: retry until successful. No power source connected (no ac, no battery, no cmos).