surface-pro-x icon indicating copy to clipboard operation
surface-pro-x copied to clipboard

Windows Dev Kit 2023 Boot Work

Open nickdepinet opened this issue 2 years ago • 138 comments

Discussion started in Issue #7, splitting to it's own issue for tracking:

I've recently gotten ahold of a windows dev kit 2023, which appears to be a surface pro 9 (5g) / sq3 in a box, and I'm attempting to boot linux on it with these patches.

Progress so far -

Booting base Ubuntu 22.04.1 LTS arm image - Hangs at: Booting a command list

Synchronous Exception at 0x0000000C1B17927C Building a "default" profile image with the image tool - Hangs at: Loading initramfs... Booting into Surface kernel... EFI stub: Booting Linux Kernel... EFI stub: Using DTB from configuration table EFI stub: Exiting boot services... Barring better suggestions, I'm going to try to extract the firmware with the script from aarch64-firmware and stuff it into the arch image above and see where that gets booting


  1. could possibly be fixed by https://github.com/linux-surface/grub/commit/55b95a388414a3d850e24fd2ae8fac100ffd9319. So you could try to use e.g. the pre-built grub from https://github.com/linux-surface/grub-image-aarch64/releases/tag/fedora-37-2 with your Ubuntu kernel. Alternatively, just use the image from 2) which contains the patched grub, but remove the devicetree option from the boot entry. That should get you booting in ACPI mode.

  2. is way before any firmware gets loaded, so I doubt that that will make any difference. Can you make sure that efi=novamap is set (press e in the grub menu to edit)? Also, this is booting with the SPX DT, and I'm not sure if that's a good idea. So as I've said above, you can remove the devicetree option in the grub config and it should hopefully get you a bit further.

You can also experiment with earlycon=efifb.

In the long run, you'll probably want to have a look at the DT of the sc8280xp (that is 8cx Gen 3; it's also used in the Thinkpad X13s) and use that as a base. Also, you might want to join the oftc/#aarch64-laptops IRC. There are a lot more experienced people who also might have some ideas.

Originally posted by @qzed in https://github.com/linux-surface/surface-pro-x/issues/7#issuecomment-1306998491

nickdepinet avatar Nov 09 '22 01:11 nickdepinet

Booting the image from number 2 above with the devicetree line removed gets into a boot loop. Adding earlycon=efifb console=efifb boot_delay=200 to the boot parameters gets us to see that we're reaching the following lines before instantly rebooting:

earlycon_bootlog

there are a bunch of BAR and firmware errors further up the log as well that may be worth investigating

nickdepinet avatar Nov 09 '22 01:11 nickdepinet

swapping in sc8280xp-lenovo-thinkpad-x13s.dtb as the devicetree on boot gets to same line & rebootloop behavior as above

nickdepinet avatar Nov 09 '22 03:11 nickdepinet

So at this point you'll probably really want to head over to oftc/#aarch64-laptops :) They'll know much more about what might be going wrong here.

Also if you're starting off with the thinkpad DTS you might need to remove/disable a couple of parts. AFAIK sudden restarts are generally happening when you access something you shouldn't (yet) access, like powered-off MMIO, invalid memory, ...

Particular stuff that you might want to remove:

  • HID-over-I2C input nodes (https://github.com/torvalds/linux/blob/f141df371335645ce29a87d9683a3f79fba7fd67/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts#L206-L257)
  • Backlight (https://github.com/torvalds/linux/blob/f141df371335645ce29a87d9683a3f79fba7fd67/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts#L19-L43)

maybe more...

qzed avatar Nov 09 '22 11:11 qzed

Stripped a bunch of stuff out of the dts into a new copy and attempted booting with it - same result. oftc/#aarch64-laptops says that the big thing is that I need to add an override for the smmu. Some googling around found this patch that seems relevant to what needs to be done: https://patchwork.kernel.org/project/linux-arm-kernel/patch/[email protected]/#24198673

nickdepinet avatar Nov 10 '22 06:11 nickdepinet

This does indeed appear to be the right path - whitequark logs direct us to similar issue for samsung galaxy book go here: https://github.com/aarch64-laptops/debian-cdimage/issues/21. Created following PR to add wdk2023 acpi to smmu platlist here: https://github.com/linux-surface/kernel/pull/130. Working on getting my local build environment setup for cross-compiling linux kernel for test

nickdepinet avatar Nov 10 '22 08:11 nickdepinet

Ahh, I completely forgot about this being a thing... That explains at least why it boot-looped with ACPI. However, I think the DTS should have the SMMU described properly, so not sure why that fails similarly.

qzed avatar Nov 10 '22 10:11 qzed

No longer boot looping in ACPI mode with a kernel built with the above patch. Now we're getting rcu_preempt stalls: PXL_20221111_060955367 MP.

Booting with a dtb empty except for including the sc8280xp.dtsi still causes bootloop behavior.

I've also attached the acpidump.txt here: https://github.com/linux-surface/acpidumps/issues/24

nickdepinet avatar Nov 11 '22 06:11 nickdepinet

I'd guess some MMIO region or something is being accessed that hasn't been powered up yet... but hard to tell what exactly...

qzed avatar Nov 11 '22 11:11 qzed

@nickdepinet - just out of curiosity: did you make any further progress in getting this device to boot mainline linux?

hexdump0815 avatar Nov 28 '22 18:11 hexdump0815

Any progress? Btw @qzed are you mainlining your fixes ?

xlazom00 avatar Jan 23 '23 09:01 xlazom00

@xlazom00 Hopefully at some point. But that depends on someone upstreaming a device tree for the sc8180x platform. People have been working on that but I don't know the current status.

qzed avatar Jan 23 '23 13:01 qzed

@qzed btw motherboard in dev kit is same as surface pro 9 so do you know if there is some dts for surface pro 9 somewhere ?

xlazom00 avatar Jan 23 '23 14:01 xlazom00

@nickdepinet - just out of curiosity: did you make any further progress in getting this device to boot mainline linux?

I haven't had time to visit this in a while, so no further progress on my end. There's been some interesting qcom improvements in the arm64 upstream tree that may let us get further, but I haven't had a chance to build a new kernel and give it a go

nickdepinet avatar Jan 23 '23 19:01 nickdepinet

@qzed btw motherboard in dev kit is same as surface pro 9 so do you know if there is some dts for surface pro 9 somewhere ?

I'm not aware of any, sorry.

qzed avatar Jan 24 '23 10:01 qzed

@nickdepinet I haven't got time to debug, but that RCU stall issue seems caused by cpuidle support. You can try to disable CONFIG_CPU_IDLE and see if it helps.

shawnguo2 avatar Feb 13 '23 14:02 shawnguo2

Has anyone seen https://github.com/merckhung/linux_ms_dev_kit/commit/195ccc926158b49c33edbccde99685a497032c3b?

Source: https://twitter.com/merckhung/status/1602205575902683136

jwijenbergh avatar Feb 17 '23 19:02 jwijenbergh

That looks like what you'd need to get it booted via a DT. Not sure about the remoteproc firmware paths (from what I've heard they're signed individually for each device, so you might have to copy them from Windows) but those aren't required to get the basics up and running.

qzed avatar Feb 17 '23 19:02 qzed

@qzed can you plz cherrypick that to your 6.2 linux kernel THX

xlazom00 avatar Feb 20 '23 09:02 xlazom00

@xlazom00 I have thought about it, but decided not to do this, sorry. The reason for that is that I can't maintain this. I don't have a dev-kit, so at best I can keep things compiling. The sc8280xp platform is still moving fairly quickly, so it's likely that things will break and I won't be able to fix these things, or even detect any breakage. Due to this, I've decided to focus on the SPX exclusively, which is time-consuming enough at this point.

qzed avatar Feb 20 '23 13:02 qzed

I was able to boot with Johan's Hovald(@jhovold) git https://github.com/jhovold/linux/tree/wip/sc8280xp-v6.2-rc8 and @shawnguo2 patches on top of that https://github.com/shawnguo2/linux/commits/devkit-dt-6.2-rc5 DTB https://github.com/shawnguo2/linux/commit/f3e0834be69a07b627991101c2f098d19e961324

with this clk_ignore_unused efi=novamap earlycon=efifb console=efifb and I pluged in usbc ethernet so I have internet on that

I still have some problems

  1. cpu is reporting 3GHz but in real it is runing on something really low as benchmarks are reporting same results on every frequency
  2. I see kernel and some OS stuff booting on display connected with displayport but then it go dark. I am able to ssh as usb-c ethernet is working

xlazom00 avatar Mar 04 '23 09:03 xlazom00

Greeting! I'm very novice in linux, help me , please instaley and a version as complete as possible for 7c s book go. I found the link with the sd image but I can not download to the end [email protected] Regards!!!

CriXYZ avatar Mar 04 '23 13:03 CriXYZ

@CriXYZ This is not the right place for this question, I don't think anyone here can help you with that device. Maybe people at https://github.com/aarch64-laptops can help you, but installing Linux on those devices is generally not something that I can recommend for a beginner.

qzed avatar Mar 05 '23 00:03 qzed

I was able to boot with Johan's Hovald(@jhovold) git https://github.com/jhovold/linux/tree/wip/sc8280xp-v6.2-rc8 and @shawnguo2 patches on top of that https://github.com/shawnguo2/linux/commits/devkit-dt-6.2-rc5 DTB shawnguo2/linux@f3e0834

with this clk_ignore_unused efi=novamap earlycon=efifb console=efifb and I pluged in usbc ethernet so I have internet on that

I still have some problems

  1. cpu is reporting 3GHz but in real it is runing on something really low as benchmarks are reporting same results on every frequency
  2. I see kernel and some OS stuff booting on display connected with displayport but then it go dark. I am able to ssh as usb-c ethernet is working

@xlazom00 Awsome! Would you mind sharing the image/iso? Would love to test it as well.

rgn avatar Mar 07 '23 08:03 rgn

I was able to boot with Johan's Hovald(@jhovold) git https://github.com/jhovold/linux/tree/wip/sc8280xp-v6.2-rc8 and @shawnguo2 patches on top of that https://github.com/shawnguo2/linux/commits/devkit-dt-6.2-rc5 DTB shawnguo2/linux@f3e0834 with this clk_ignore_unused efi=novamap earlycon=efifb console=efifb and I pluged in usbc ethernet so I have internet on that I still have some problems

  1. cpu is reporting 3GHz but in real it is runing on something really low as benchmarks are reporting same results on every frequency
  2. I see kernel and some OS stuff booting on display connected with displayport but then it go dark. I am able to ssh as usb-c ethernet is working

@xlazom00 Awsome! Would you mind sharing the image/iso? Would love to test it as well.

I second that, but a quick write up on how you did it if you can would be preferred. Thanks

thelumberjhack avatar Mar 07 '23 13:03 thelumberjhack

Is there any progress on this - by any luck?

mjrc avatar Mar 30 '23 15:03 mjrc

Sorry :)

I made this branch of armbian https://github.com/xlazom00/build/tree/qcom-sc8280xp

  1. You will need to build image like this ./compile.sh EXPERT="yes" KERNEL_GIT=shallow BOARD=microsoft-devkit-2023 BRANCH=edge RELEASE=kinetic BUILD_MINIMAL=yes BUILD_DESKTOP=no KERNEL_CONFIGURE=no COMPRESS_OUTPUTIMAGE=sha,img EXTRAWIFI=no WIREGUARD=no PLYMOUTH=no PREFER_DOCKER=no

  2. flash image to sd card or usb dongle with this for example https://www.balena.io/etcher

  3. disable secure UEFI on device and change order to boot from usb first

Kernel will use ACPI to setup hw USB ports working(ethernet port), PCI also(wifi only need blobs from linux firmware) cpufreq driver don't so device will run on some low freq gpu driver don't

armbian will use https://github.com/jhovold/linux/tree/wip/sc8280xp-v6.3-rc4 and ACPI paches from here https://github.com/shawnguo2/linux/commits/wdk2023-acpi-6.2

Thank you for @jhovold and @shawnguo2 work!

Now it will be nice to have device tree version with all drivers in DT version cpufreq is working missing one usb port(one with usb-ethernet) display port dont ....

xlazom00 avatar Mar 30 '23 19:03 xlazom00

Hi so I have booted DevKit 2023 to Ubuntu 23.04 desktop. But I am still using 6.0 kernel. I will try your kernel and see if I am lucky.

IMG_0093

merckhung avatar Apr 03 '23 09:04 merckhung

So, I have switched to Steev’s 6.3-rc4 kernel with your ACPI patches. I feel the system (Ubuntu 23.04) runs smoother and faster than before (higher CPU freq?), but the GPU DRM is not detected, so it’s still software rendered.

I took a look at my X13s dmesg, I believe x13s’ GPU/DRM is detected through DTB (overlay?), instead of ACPI. Thinking about having a hack in the DRM msm_dpu driver.

merckhung avatar Apr 04 '23 05:04 merckhung

@merckhung this one https://github.com/steev/linux/commits/lenovo-x13s-linux-v6.3-rc5 ?

xlazom00 avatar Apr 04 '23 07:04 xlazom00

@merckhung this one https://github.com/steev/linux/commits/lenovo-x13s-linux-v6.3-rc5 ?

IMG_0098

I used rc4 branch, but the GPU is not working yet as it was not detected in the driver probe() function through ACPI. Sound card not working yet as well.

merckhung avatar Apr 04 '23 11:04 merckhung