William Goodspeed 的又一个博客

Install Debian GNU/Linux on Galaxy Book Go

Published by goodspeed on March 5, 2024 in 默认分类.

20240305_20h22m32s_grim.png

Why English? Because there isn't much Chinese user base on this device. I accidentally destroyed the Windows partition on the internal storage. So I was left no choice but installing a GNU/Linux distro on it. Because the MS Windows shit don't even have an installation media.

What's working:

  • GPU (with minor shattering)
  • USB-A
  • WiFi
  • Bluetooth
  • Keyboard (may stop working a few time, rebooting will fix it) & Touchpad
  • Internal Display (without backlight control, therefore no dpms)

What's not:

  • audio (bt works OK)
  • webcam
  • USB-C
  • Modem
  • Battery Monitoring
  • Lid dectection

Tho its support is far from the great but it's really working. I already decided to daily drive this laptop and I found the most annoying thing is actually the backlight lol Despite of that, It's far more better than MS Windows. On the WIndows 10, once you booted up, Windows would take around 3G of the RAM, which is terrible. With Debian & Sway, it only uses around 800M, not to mention the fact that I'm running firefox to write this article at the same time.

As you already read above, this could make you get rid of Windows. But, meanwhile, it will be pretty difficult to install it back. Okay, with your curiosity (or maybe the hate of MS Windows), let's get in to it.

Preparation

Firstly, you need to backup the firmware you have on Windows. See the documentation on: https://github.com/hexdump0815/imagebuilder/blob/main/systems/snapdragon_7c_woa/doc/required-firmware.md

Okay, now you've backed up your firmware. You can proceed to get a GNU/Linux running.

Then, reboot to BIOS by pressing F2. In BIOS, turn off secure boot. And then reboot while pressing F10, and boot to your USB drive. In the sysetm, you may follow the steps mentioned in 'required-firmware.md'. One way to verify that you got it right that is to see if you get WiFi.

Do a regular `debootstrap' installation.

Don't forget to get hostname, tzdata, locales, passwd and fstab ready!

These packages are also required: qrtr-tools protection-domain-mapper rmtfs tqftpserv.

You should also enable the services they provided (It seemed that apt already enabled them).

Kernel

In my first installation, I need to copy the kernel from that image. (Obviously, you can do that as well) But after that, I built a debian package of the patched kernel which will make it a little easier.

Download the prebuilt linux kernel package: https://cloud.disroot.org/s/3oiApzMEKpy4FMa

 # cp /path/to/the/packages /mnt/root
 #chroot /mnt
 # dpkg -i /mnt/root/*.deb

Also unfornately, the device trees are not included in the package. You need to manually extract them to /mnt/boot.

You also need to copy your firmwares to the target:

 $ cp /lib/firmware/* /mnt/lib/firmware/

Install initramfs-tools. And create the file:

/etc/initramfs-tools/hooks/firmware
---
#!/bin/sh

set -e

PREREQ=""

prereqs()
{
    echo "${PREREQ}"
}

case "${1}" in
    prereqs)
        prereqs
        exit 0
        ;;
esac

. /usr/share/initramfs-tools/hook-functions

mkdir -p ${DESTDIR}/lib/firmware/qcom
cp -a /lib/firmware/qcom/sc7180 ${DESTDIR}/lib/firmware/qcom

Bootloader

Install grub-efi-arm64. Add this on top of the file /etc/grub.d/10_linux.

GRUB_DEVICETREE="sc7180-samsung-galaxy-book-go"

And at around L194, you will see it loads the linux kernel, right after that, add the code below:

  if [ x"$quiet_boot" = x0 ] || [ x"$type" != xsimple ]; then
    message="$(gettext_printf "Loading Devicetree %s ..." ${GRUB_DEVICETREE})"
    sed "s/^/$submenu_indentation/" << EOF
        echo    '$(echo "$message" | grub_quote)'
EOF
  fi
  sed "s/^/$submenu_indentation/" << EOF
        devicetree   ${rel_dirname}/dtb-${version}/${GRUB_DEVICETREE}.dtb
EOF

It will eventually looks like this:

  if [ x"$quiet_boot" = x0 ] || [ x"$type" != xsimple ]; then
    message="$(gettext_printf "Loading Linux %s ..." ${version})"
    sed "s/^/$submenu_indentation/" << EOF
        echo    '$(echo "$message" | grub_quote)'
EOF
  fi
  if test -d /sys/firmware/efi && test -e "${linux}.efi.signed"; then
    sed "s/^/$submenu_indentation/" << EOF
        linux   ${rel_dirname}/${basename}.efi.signed root=${linux_root_device_thisversion} ro ${args}
EOF
  else
    sed "s/^/$submenu_indentation/" << EOF
        linux   ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
EOF
  fi
  if [ x"$quiet_boot" = x0 ] || [ x"$type" != xsimple ]; then
    message="$(gettext_printf "Loading Devicetree %s ..." ${GRUB_DEVICETREE})"
    sed "s/^/$submenu_indentation/" << EOF
        echo    '$(echo "$message" | grub_quote)'
EOF
  fi
  sed "s/^/$submenu_indentation/" << EOF
        devicetree   ${rel_dirname}/dtb-${version}/${GRUB_DEVICETREE}.dtb
EOF

  if test -n "${initrd}" ; then
    # TRANSLATORS: ramdisk isn't identifier. Should be translated.
    if [ x"$quiet_boot" = x0 ] || [ x"$type" != xsimple ]; then
      message="$(gettext_printf "Loading initial ramdisk ...")"
      sed "s/^/$submenu_indentation/" << EOF
        echo    '$(echo "$message" | grub_quote)'
EOF
    fi
    initrd_path=

Tweak the file `/etc/default/grub' a little, part of the file like this:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX="efi=novamap,noruntime clk_ignore_unused pd_ignore_unused console=tty0 noresume deferred_probe_timeout=30"

And finally, you can install GruB:

 # update-initramfs -c
 # grub-install /dev/sda

Since there is no efibootmgr, we need to manually replace the boot file.

(chroot) # cp /boot/efi/EFI/debian/grubaa64.efi /boot/efi/EFI/Boot/bootaa64.efi

Should be working now!

Reboot and pressing F2 to enter BIOS, and make it boot to `UEFI: Hard Drive' by default. Save and reset.

Now, your Debian on Galaxy Book Go should be working.

评论 | 分类: 默认分类

使用 PN532 读取中华人民共和国护照

Published by goodspeed on February 20, 2024 in 默认分类.

本来是打算读身份证的,但发现身份证的读取是专有且受限的。护照有国际统一的标准,所以我对护照下手。

准备工作

护照(或者准确地说,电子护照:E-passport)中的芯片与常见的 M1 卡(一般门禁卡)不同。读取这样的卡片(即智能卡:Smartcard)一般通过 PCSC/CCID 协议与读卡器通讯,并且主要使用「智能卡应用协议数据单元」(ADPU)与智能卡进行通讯。

PN532 读卡器模块很便宜,但是要使用 PN532 必须通过 I2C/SPI/UART(HSU) 发送其用户手册规定的命令。市售的 PN532 模块一般工作在 HSU (High Speed UART) 模式下,并通过上面的 ch341 芯片转成 USB 接口。

所以,我们让 PN532 可以通过 PCSC 协议通讯。这里,需要用到 ifdnfc 程序。主流发行版已经打包 PCSC 库,但不幸的是,没有 ifdnfc,需要自行编译。

- 阅读剩余部分 -

评论 | 分类: 默认分类

最近回复

分类