system76 / firmware-update

System76 Firmware Update Utility
GNU General Public License v3.0
204 stars 15 forks source link

Flashing Open EC firmware fails early with invalid ROM size (bonw14/X170SM-G) #117

Closed magneticflux- closed 1 month ago

magneticflux- commented 1 month ago

Full disclosure: I'm not running anything close to a "genuine" System76 laptop; it's a mess cobbled together from spare Clevo parts, so it's totally fair if you don't offer any support! That being said... from what I can tell, the issue would also occur on official hardware as it's all coming from an official download. With that out of the way, here's the details:

Updating BIOS and EC firmware using system76-firmware-cli (with safety checks patched to force detection of bonw14 and 76ec, I know, I know, it's bad) fails to flash the firmware and prints this error:

# ...
BIOS: Success
file board: Ok("system76/bonw14")
file version: Ok("2021-07-20_93c2809")
ROM size of 33547 is not valid
EC Flash Error: Verify
EC tag: created successfully
System will shut off in 5 seconds

The BIOS update succeeds: I've been using the coreboot BIOS without issue and ACPI device 17761776 exists.

I verified the downloaded firmware bonw14_df60b821b2f5c45288098dba9e084aeb79d491d4133f84b73d298155aba6597e.tar.xz contained ec.rom, which is 33547 bytes.

The check that fails is here: https://github.com/system76/firmware-update/blob/6bf5268b97f2ca788313cb6d63c730465465c41a/src/app/ec.rs#L429-L432 And it appears older versions padded the ROM to fit the flash size, until https://github.com/system76/firmware-update/commit/5fb9563a6060cee49e55888595ca3d6b72165cd8

I could reproduce the previous 0xFF padding behavior manually and continue, but this hiccup was enough to give me pause. I don't need a guarantee it's compatible, but can you confirm there aren't any obvious changes that S76 has made to the EC that could make it incompatible? I wouldn't really expect S76 to go to the trouble of desoldering every IT5570E-128/CX and GD25D10BTIGR that came with the mainboard, but if they do I would be incredibly grateful for a heads-up. If you're curious, this is the spec sheet I'm going off of for compatibility and parts, pages 58 and 103: X170SM SM 20200713.pdf

jackpot51 commented 1 month ago

If this is not our hardware, you will have to figure it out on your own.

magneticflux- commented 1 month ago

Great news, it worked! I figured if it didn't, I'd just grab a CH341A SOIC8 flash programmer and fix it manually in a day or two. I ran my patched system76-firmware-cli which set up the EFI things and downloaded the firmware, and then I ran sudo objcopy -I binary -O binary --gap-fill=0xFF --pad-to=131072 /boot/system76-firmware-update/firmware/ec.rom to pad out the firmware. Then I rebooted, crossed my fingers, and let it install.

Now, the example firmware_id parses everything like normal:

Model: bonw14
Variant: 0
Project: 76ec
Automatic
Automatic transition: 76ec -> 76ec
  Model: bonw14
  Project: 76ec
  Firmware ID: bonw14_df60b821b2f5c45288098dba9e084aeb79d491d4133f84b73d298155aba6597e
Open
Open transition: 76ec -> 76ec
  Model: bonw14
  Project: 76ec
  Firmware ID: bonw14_df60b821b2f5c45288098dba9e084aeb79d491d4133f84b73d298155aba6597e
Proprietary
Proprietary transition: 76ec -> 76ec
  Error: Model 'bonw14' is not supported by proprietary firmware and EC at this time

(I can reverse the patch to return to proprietary)

And the keyboard is properly detected: image