linux-surface / surface-uefi-firmware

UEFI firmware updates for surface using fwupd. WIP, be careful.
112 stars 9 forks source link

Latest SurfaceGo firmware throws an error unpacking on Arch? #12

Closed mannp closed 3 years ago

mannp commented 3 years ago

Using the same command as I used previously, it doesn't appear to work on the latest SG firmware...looks like maybe some command line flags have changed..

./repack.sh -m cab -f /home/local/Downloads/SurfaceGo_Win10_18362_21.015.38060_WiFi_0.msi -o out ==> Found Model: SurfaceGo ==> Unpacking driver package ./repack.sh: line 137: cd: out/SurfaceGo/*: No such file or directory basename: missing operand Try 'basename --help' for more information. basename: missing operand Try 'basename --help' for more information. basename: missing operand Try 'basename --help' for more information. cp: missing destination file operand after '/tmp/tmp.rnADxN2GA3/firmware.bin' Try 'cp --help' for more information. cp: missing destination file operand after '/tmp/tmp.rnADxN2GA3/firmware.cat' Try 'cp --help' for more information. cp: missing destination file operand after '/tmp/tmp.rnADxN2GA3/firmware.inf' Try 'cp --help' for more information. sed: can't read /tmp/tmp.rnADxN2GA3/firmware.inf: No such file or directory

jackluo923 commented 3 years ago

don't think this is limited to Surface Go device nor Arch. I received the same error message on Ubuntu 20.04LTS + Surface Pro 4 device.

jackluo923 commented 3 years ago

@mannp There's a problem in the msiextracton line 72 in repack.sh. I was able to get it working inside Windows 10 using msiexec /a <msifilename> /qb TARGETDIR=<out dir>.

mannp commented 3 years ago

@mannp There's a problem in the msiextracton line 72 in repack.sh. I was able to get it working inside Windows 10 using msiexec /a <msifilename> /qb TARGETDIR=<out dir>.

Hi @jackluo923 thanks for the info :) glad you got it working in another way.

I don't have windows at all, so not something I can try easily.

I tried to understand why the 'basename: missing operand' wasn't working but it wasn't obvious to me.

jackluo923 commented 3 years ago

I couldn't figure out what the root cause of the problem (msiextract failing causing the rest of the script to fail, thus outputting basename missing log) either without spending too much time debugging, so I switched to the equivalent Windows operation instead. To extract the MSI package, you can just install KVM, download a Windows 10 ISO (legally through many ways), and run it inside a VM. My hypothesis is that after extracting the package, you should be able to continue w/ the scripts in Arch with slight modification.

I ran the msiexec command for you on my machine for SurfaceGo_18362. You can download it here and use at your own risk within 30 days.

mannp commented 3 years ago

I ran the msiexec command for you on my machine for SurfaceGo_18362. You can download it [here]

Much appreciated, thanks @jackluo923

razlani commented 3 years ago

I'm trying this with the latest Ubuntu/surfacebook2 firmware and executing the repack sh script prints "ERROR: No output directory specified!"

Unfortunately I'm not familiar enough with Linux tools and whilst @jackluo923 seems to have extracted it by other means: I feel this could cause complications when using fwupd

Would be nice if someone more literate could take a look at the script/tool as this blocks the process for SB2 devices (as well as the devices mentioned above) 😒

StollD commented 3 years ago

@razlani Add -o out to your command, like in the README file.

mannp commented 3 years ago

Would be nice if someone more literate could take a look at the script/tool as this blocks the process for SB2 devices (as well as the devices mentioned above) unamused

It is not resolved for me, I was hopeful @StollD may update when they have time, as I said, it was not obvious to me what the issue is, even though it looks like changes in syntax for dependencies, but ones I am not familiar with.

razlani commented 3 years ago

@razlani Add -o out to your command, like in the README file.

This bit works great - now I need to source the old driver pack I need (SurfaceBook2_Win10_18362_20.041.10163.0.msi)...

Any suggestions would be hot :-D

razlani commented 3 years ago

@razlani Add -o out to your command, like in the README file.

This bit works great - now I need to source the old driver pack I need (SurfaceBook2_Win10_18362_20.041.10163.0.msi)...

Any suggestions would be hot :-D

Couldn't do it via wayback machine but simply rolled back from device manager and hoping that will work for my purposes!

jackluo923 commented 3 years ago

@razlani decompressed data of version 18362 can be found here: https://github.com/linux-surface/surface-firmware-old/tree/master/firmware/SurfaceBook_2

ShapeShifter499 commented 3 years ago

It is not resolved for me, I was hopeful @StollD may update when they have time, as I said, it was not obvious to me what the issue is, even though it looks like changes in syntax for dependencies, but ones I am not familiar with.

I have a Surface Go 1 (the 2018 model with 64GB storage) and I'm running Arch Linux. It works fine for me. Have you made sure to run ./prep.sh on the firmware msi file?

I have these scripts installed with this AUR package https://aur.archlinux.org/packages/surface-uefi-firmware-git/ and this is my full output.

[ransu@SurfaceGoHome surface-firmware]$ ls -lsa
total 366819
     4 drwxr-xr-x 2 ransu ransu      3452 Jun 26 05:24 .
     4 drwxr-xr-x 4 ransu ransu      3452 Jun 26 04:56 ..
366812 -rw-r--r-- 1 ransu ransu 375242752 Jun 26 05:24 SurfaceGo_Win10_18362_21.015.38060_WiFi_0.msi
[ransu@SurfaceGoHome surface-firmware]$ surface-firmware-prep SurfaceGo_Win10_18362_21.015.38060_WiFi_0.msi 
 > New filename is SurfaceGo-WiFi_Win10_18362_21.015.38060_WiFi_0.msi
[ransu@SurfaceGoHome surface-firmware]$ ls -lsa
total 366819
     4 drwxr-xr-x 2 ransu ransu      3452 Jun 26 05:24 .
     4 drwxr-xr-x 4 ransu ransu      3452 Jun 26 04:56 ..
366812 -rw-r--r-- 1 ransu ransu 375242752 Jun 26 05:24 SurfaceGo-WiFi_Win10_18362_21.015.38060_WiFi_0.msi
[ransu@SurfaceGoHome surface-firmware]$ surface-firmware-repack -m cab -f SurfaceGo-WiFi_Win10_18362_21.015.38060_WiFi_0.msi -o out
 ==> Found Model: SurfaceGo-WiFi
 ==> Unpacking driver package
 ==> Repacking ME firmware
 ==> Repacking ISH firmware
 ==> Repacking PD firmware
 ==> Repacking UEFI firmware
[ransu@SurfaceGoHome surface-firmware]$ ls -lsa out/
total 11
4 drwxr-xr-x 3 ransu ransu 3452 Jun 26 05:25 .
4 drwxr-xr-x 3 ransu ransu 3452 Jun 26 05:25 ..
4 drwxr-xr-x 6 ransu ransu 3452 Jun 26 05:26 SurfaceGo-WiFi
[ransu@SurfaceGoHome surface-firmware]$ ls -lsa out/SurfaceGo-WiFi/
total 24261
    4 drwxr-xr-x 6 ransu ransu     3452 Jun 26 05:26 .
    4 drwxr-xr-x 3 ransu ransu     3452 Jun 26 05:25 ..
    4 drwxr-xr-x 2 ransu ransu     3452 Jun 26 05:26 ISH
    4 drwxr-xr-x 2 ransu ransu     3452 Jun 26 05:26 ME
    4 drwxr-xr-x 2 ransu ransu     3452 Jun 26 05:26 PD
 3020 -rw-r--r-- 1 ransu ransu  3091708 Jun 26 05:26 SurfaceGo-WiFi_ISH_3.1.0.3524.cab
 3356 -rw-r--r-- 1 ransu ransu  3435724 Jun 26 05:26 SurfaceGo-WiFi_ME_11.8.82.3838.cab
  144 -rw-r--r-- 1 ransu ransu   143794 Jun 26 05:26 SurfaceGo-WiFi_PD_1.0.13.cab
17720 -rw-r--r-- 1 ransu ransu 18123402 Jun 26 05:26 SurfaceGo-WiFi_UEFI_1.0.30.0.cab
    4 drwxr-xr-x 2 ransu ransu     3452 Jun 26 05:26 UEFI
[ransu@SurfaceGoHome surface-firmware]$ 
mannp commented 3 years ago

Thanks @ShapeShifter499 I was using the source pull from github, where as you are correct, using the aur git version, I have converted the files fine with no errors :-/

Trying to flash SurfaceGo-WiFi_ISH_3.1.0.3524.cab gives me an error, something like incorrect flasher version, but again I was able to flash SurfaceGo-WiFi_UEFI_1.0.30.0.cab without an issue.

Updated UEFI, ME then ISH would flash 👍🏻 edit and then PE would flash at the end :)

ShapeShifter499 commented 3 years ago

@mannp is it possible you were missing a dependency? That AUR package should be grabbing from the same code

ShapeShifter499 commented 3 years ago

@mannp oh one more thing, were you able to get SurfaceGo-WiFi_PD_1.0.13.cab to flash? It would just reboot but not show any flash dialogue. fwupdmgr showed that the version stayed the same, not updated.

mannp commented 3 years ago

@mannp is it possible you were missing a dependency? That AUR package should be grabbing from the same code

Not sure about missing a dependency but perhaps a mismatch in supported version at that time on my system -> basename threw the error and perhaps this package has been updated since.

Installing the aur didn't install any new dependencies, so I am not entirely sure, but other @jackluo923 received the same error at the time on Ubuntu, so it didn't appear to be an isolated distro error.

mannp commented 3 years ago

@mannp oh one more thing, were you able to get SurfaceGo-WiFi_PD_1.0.13.cab to flash? It would just reboot but not show any flash dialogue. fwupdmgr showed that the version stayed the same, not updated.

Yes, PE flashed, Updated UEFI, ME, ISH and then PE would flash..... before I had the same issue as you :)

ShapeShifter499 commented 3 years ago

@mannp I could not get PD to flash. It would run through the dialogue, ask to reboot. but on reboot I would not get any flashing utility dialogue like I did when flashing UEFI, ME, and ISH. After reboot fwupdmgr reports the same old version number. I tried this before and after flashing UEFI, ME, and ISH.

I resorted to going back to my USB Windows install to flash the updated firmware. This worked for PD and afterwards fwupdmgr reported the correct newer version number.

The rest of the parts flashed correctly though and reported a newer number afterwards.

mannp commented 3 years ago

@ShapeShifter499 I watched it flash and complete without error.

I checked in the bios and the versions matched the ones on the microsoft firmware page, but not sure where to check the PD element of the update?

ShapeShifter499 commented 3 years ago

@mannp It doesn't seem to show in the BIOS page. But it shows if you try to flash without --allow-older The PD version before update would show 1286 but after I got it to update in Windows it now shows 1287. I only noticed the no dialogue thing because I flashed each part separately and rebooted between each flash.

I'm not sure if Microsoft would screw us over but I wanted to make sure it flashed because it deals with the power and charging for the device if I understand it correctly.

mannp commented 3 years ago

Hi @ShapeShifter499 so I have checked this morning and see below for the PD, which I flashed through arch (I don't have windows installed anywhere)

❯ sudo fwupdmgr install SurfaceGo-WiFi_PD_1.0.13.cab
Decompressing…           [***************************************]
Specified firmware is older than installed '0.0.1287 < 1287'

I think this means I am up to date?

Cheers

ShapeShifter499 commented 3 years ago

@mannp looks exactly the same here. I wonder why it worked for your Surface but not mine. But since it's been updated now I can't exactly diagnose it any further.