Part 1
요약·해설
SOF Community key가 설정된 Intel Chromebook ADSP에서 custom Zephyr firmware를 실행하기 위해 ChromeOS와 kernel, signing tool을 준비합니다.
Asus Flip CX5 · delbin
Intel CAVS 2.5 · SOF
zephyr.ri
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
194362A083EE4108B6A685B3517865602DDDE8B251E064AA5DCF31253A09019A
.. _zephyr-audio-dsp-development-on-chromebooks:
Zephyr Audio DSP Development on Chromebooks
###########################################
The Audio DSP on Intel Chromebooks is configured to use the SOF
"Community" key for firmware signing, and can therefore accept
arbitrary user-developed firmware like Zephyr applications (of which
SOF is one), including the Zephyr samples and test suite.
Initial TGL Chromebook Setup
****************************
(These instructions were written specifically to the Asus Flip CX5
device code named "delbin". But they should be reasonably applicable
to any recent Intel device.)
Power the device on and connect it to a wireless network. It will
likely want to download a firmware update (mine did). Let this finish
first, to ensure you have two working OS images.
Enable Developer Mode
=====================
Power the device off (menu in lower right, or hold the power button
on the side)
Hold Esc + Refresh (the arrow-in-a-circle "reload" key above "3") and
hit the power key to enter recovery mode. Note: the touchscreen and
pad don't work in recovery mode, use the arrow keys to navigate.
Select "Advanced Options", then "Enable Developer Mode" and confirm
that you really mean it. Select "Boot from Internal Storage" at the
bootloader screen. You will see this screen every time the machine
boots now, telling you that the boot is unverified.
Wait while the device does the required data wipe. My device takes
about 15 minutes to completely write the stateful partition. On
reboot, select "Boot from Internal Storage" again and set it up
(again) with Google account.
Make a Recovery Drive
=====================
You will at some point wreck your device and need a recovery stick.
Install the Chromebook Recovery Utility from the Google Web Store and
make one.
You can actually do this on any machine (and any OS) with Chrome
installed, but it's easiest on the Chromebook because it knows its
device ID (for example "DELBIN-XHVI D4B-H4D-G4G-Q9A-A9P" for the Asus
Tiger Lake board). Note that recovery, when it happens, will not
affect developer mode or firmware settings but it **will wipe out the
root filesystem and /usr/local customizations you have made**. So
plan on a strategy that can tolerate data loss on the device you're
messing with!
Make the root filesystem writable
=================================
For security, ChromeOS signs and cryptographically verifies (using
Linux's dm-verity feature) all access to the read-only root
filesystem. Mucking with the rootfs (for example, to install modules
for a custom kernel) requires that the dm-verity layer be turned off:
First open a terminal with Ctrl-Alt-T. Then at the "crosh> " prompt
issue the "shell" command to get a shell running as the "chronos"
user. Finally (in developer mode) a simple "sudo su -" will get you a
root prompt.
.. code-block:: console
crosh> shell
chronos@localhost / $ sudo su -
localhost ~ #
Now you need to turn of signature verification in the bootloader
(because obviously we'll be breaking whatever signature existed).
Note that signature verification is something done by the ROM
bootloader, not the OS, and this setting is a (developer-mode-only)
directive to that code:
.. code-block:: console
cros# crossystem dev_boot_signed_only=0
(*Note: for clarity, commands in this document entered at the ChromeOS
core shell will be prefixed with a hostname of cros.*)
Next you disable the validation step:
.. code-block:: console
cros# /usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification
**THIS COMMAND WILL FAIL**, give you an error that you are changing
the setting for the entire running system, and suggest an alternative
"--partitions X" argument to use that modifies only the currently used
partition. Run that modified command, then reboot.
After rebooting, you will notice that your chromebook boots with the
raw storage device (e.g. /dev/nvme0n1p5) mounted as root and not the
"dm-0" verity device, and that the rootfs is read-write.
Note: What this command actually does is modify the command line of
the installed kernel image (it saves a backup in
/mnt/stateful_partition/cros_sign_backups) so that it specifies
"root=<guid>" and not "root=dm-0". It does seem to leave the other
verity configuration in place though, it just doesn't try to mount the
resulting (now-invalid!) partition.
Metanote: The astute will note that we're probably going to throw this
kernel out, and that we could probably have just edited the command
line of the new kernel instead of flashing and rebooting into this
modified one. But that's too many balls to juggle at once for me.
Enable ChromeOS SSH
===================
Once you are booted with a writable partition, you can turn on the
built-in ssh server with:
.. code-block:: console
cros# /usr/libexec/debugd/helpers/dev_features_ssh
By default neither the "chronos" user nor root accounts have
passwords, so unless you want to type a ssh key in by hand, you
probably want to set a password for the first login (before you run
ssh-copy-id, of course):
.. code-block:: console
cros# passwd
Now ssh into the chromebook and add your key to
``.ssh/authorized_keys`` as you do for any Linux system.
Install Crouton
***************
The Zephyr integration tools require a proper Linux environment and
won't run on ChromeOS's minimal distro. So we need to install a Linux
personality. **DO NOT** bother installing the "Linux Development
Environment" (Crostini) from the ChromeOS Developer settings. This
personality runs inside a VM, where our tools need access to the real
kernel running on the real hardware. Instead install Crouton
(https://github.com/dnschneid/crouton), which is a community
chroot-based personality that preserves access to the real hardware
sysfs and /dev filesystem. These instructions install the "cli-extra"
package list, there are X11-enabled ones available too if you prefer
to work on the device screen directly. See the project page, etc...
At a root shell, grab the installer and run it (note: /usr/local is
the only writable filesystem without noexec, you must place the binary
there for it to run!):
.. code-block:: console
cros# mkdir -p /usr/local/bin
cros# curl -L https://github.com/dnschneid/crouton/raw/master/installer/crouton \
> /usr/local/bin/crouton
cros# chmod 755 /usr/local/bin/crouton
cros# crouton -r focal -t cli-extra
Start the Crouton chroot environment:
.. code-block:: console
cros# startcli
Now you are typing commands into the Ubuntu environment. Enable
inbound ssh on Crouton, but on a port other than 22 (which is used for
the native ChromeOS ssh server). I'm using 222 here (which is easy to
remember, and not a registered port in /etc/services):
.. code-block:: console
crouton# apt install iptables openssh-server
crouton# echo "Port 222" >> /etc/ssh/sshd_config
crouton# mkdir /run/sshd
crouton# iptables -I INPUT -p tcp --dport 222 -j ACCEPT
crouton# /usr/sbin/sshd
(*As above: note that we have introduced a hostname of "crouton" to
refer to the separate Linux personality.*)
NOTE: the mkdir, iptables and sshd commands need to be run every time
the chroot is restarted. You can put them in /etc/rc.local for
convenience. Crouton doesn't run systemd (because it can't -- it
doesn't own the system!) so Ubuntu services like openssh-server don't
know how to start themselves.
Building and Installing a Custom Kernel
***************************************
On your build host, grab a copy of the ChromeOS kernel tree. The
shipping device is using a 5.4 kernel, but the 5.10 tree works for me
and seems to have been backporting upstream drivers such that its main
hardware is all quite recent (5-6 weeks behind mainline or so). We
place it in the home directory here for simplicity:
.. code-block:: console
dev$ cd $HOME
dev$ git clone https://chromium.googlesource.com/chromiumos/third_party/kernel
dev$ cd kernel
dev$ git checkout chromeos-5.10
(*Once again, we are typing into a different shell. We introduce the
hostname "dev" here to represent the development machine on which you
are building kernels and Zephyr apps. It is possible to do this on the
chromebook directly, but not advisable. Remember the discussion above
about requiring a drive wipe on system recovery!*)
Note: you probably have an existing Linux tree somewhere already. If
you do it's much faster to add this as a remote there and just fetch
the deltas -- ChromeOS tracks upstream closely.
Now you need a .config file. The Chromebook kernel ships with the
"configs" module built which exposes this in the running kernel. You
just have to load the module and read the file.
.. code-block:: console
dev$ cd /path/to/kernel
dev$ ssh root@cros modprobe configs
dev$ ssh root@cros zcat /proc/config.gz > .config
You will need to set some custom configuration variables differently
from ChromeOS defaults (you can edit .config directly, or use
menuconfig, etc...):
+ ``CONFIG_HUGETLBFS=y`` - The Zephyr loader tool requires this
+ ``CONFIG_EXTRA_FIRMWARE_DIR=n`` - This refers to a build directory
in Google's build environment that we will not have.
+ ``CONFIG_SECURITY_LOADPIN=n`` - Pins modules such that they will
only load from one filesystem. Annoying restriction for custom
kernels.
+ ``CONFIG_MODVERSIONS=n`` - Allow modules to be built and installed
from modified "dirty" build trees.
Now build your kernel just as you would any other:
.. code-block:: console
dev$ make olddefconfig # Or otherwise update .config
dev$ make bzImage modules # Probably want -j<whatever> for parallel build
The modules you can copy directly to the (now writable) rootfs on the
device. Note that this filesystem has very limited space (it's
intended to be read only), so the INSTALL_MOD_STRIP=1 is absolutely
required, and you may find you need to regularly prune modules from
older kernels to make space:
.. code-block:: console
dev$ make INSTALL_MOD_PATH=mods INSTALL_MOD_STRIP=1 modules_install
dev$ (cd mods/lib/modules; tar cf - .) | ssh root@cros '(cd /lib/modules; tar xfv -)'
Pack and Install ChromeOS Kernel Image
======================================
The kernel bzImage file itself needs to be signed and packaged into a
ChromeOS vboot package and written directly to the kernel partition.
Thankfully the tools to do this are shipped in Debian/Ubuntu
repositories already:
.. code-block:: console
$ sudo apt install vboot-utils vboot-kernel-utils
Find the current kernel partition on the device. You can get this by
comparing the "kernel_guid" command line parameter (passed by the
bootloader) with the partition table of the boot drive, for example:
.. code-block:: console
dev$ KPART=`ssh root@cros 'fdisk -l -o UUID,Device /dev/nvme0n1 | \
grep -i $(sed "s/.*kern_guid=//" /proc/cmdline \
| sed "s/ .*//") \
| sed "s/.* //"'`
dev$ echo $KPART
/dev/nvme0n1p4
Extract the command line from that image into a local file:
.. code-block:: console
dev$ ssh root@cros vbutil_kernel --verify /dev/$KPART | tail -1 > cmdline.txt
Now you can pack a new kernel image using the vboot tooling. Most of
these arguments are boilerplate and always the same. The keys are
there because the boot requires a valid signature, even though as
configured it won't use it. Note the cannot-actually-be-empty dummy
file passed as a "bootloader", which is a holdover from previous ROM
variants which needed an EFI stub.
.. code-block:: console
dev$ echo dummy > dummy.efi
dev$ vbutil_kernel --pack kernel.img --config cmdline.txt \
--vmlinuz arch/x86_64/boot/bzImage \
--keyblock /usr/share/vboot/devkeys/kernel.keyblock \
--signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
--version 1 --bootloader dummy.efi --arch x86_64
You can verify this image if you like with "vbutil_kernel --verify".
Now just copy up the file and write it to the partition on the device:
.. code-block:: console
$ scp kernel.img root@cros:/tmp
$ ssh root@cros dd if=/tmp/kernel.img of=/dev/nvme0n1p4
Now reboot, and if all goes well you will find yourself running in
your new kernel.
Wifi Firmware Fixup
===================
On the Tiger Lake Chromebook, the /lib/firmware tree is a bit stale
relative to the current 5.10 kernel. The iwlwifi driver requests a
firmware file that doesn't exist, leading to a device with no network.
It's a simple problem, but a catastrophic drawback if uncorrected. It
seems to be sufficient just to link the older version to the new name.
(It would probably be better to copy the proper version from
/lib/firmware from a recent kernel.org checkout.):
.. code-block:: console
cros# cd /lib/firmware
cros# ln -s iwlwifi-QuZ-a0-hr-b0-62.ucode iwlwifi-QuZ-a0-hr-b0-64.ucode
Build and Run a Zephyr Application
**********************************
Finally, with your new kernel booted, you are ready to run Zephyr
code.
Build rimage Signing Tool
=========================
First download and build a copy of the Sound Open Firmware "rimage"
tool (these instructions put it in your home directory for clarity,
but anywhere is acceptable):
.. code-block:: console
dev$ cd $HOME
dev$ git clone https://github.com/thesofproject/rimage
dev$ cd rimage/
dev$ git submodule init
dev$ git submodule update
dev$ cmake .
dev$ make
Copy Integration Scripting to Chromebook
========================================
There is a python scripts needed on the device, to be run inside
the Crouton environment installed above. Copy them:
.. code-block:: console
dev$ scp soc/intel/intel_adsp/tools/cavstool.py user@crouton:
Then start the service in the Crouton environment:
.. code-block:: console
crouton$ sudo ./cavstool.py user@crouton:
Build and Sign Zephyr App
=========================
Zephyr applications build conventionally for this platform, and are
signed with "west flash" with just a few extra arguments. Note that
the key in use for the Tiger Lake DSP is the "3k" key from SOF, not
the original that is used with older hardware. The output artifact is
a "zephyr.ri" file to be copied to the device.
.. code-block:: console
dev$ west build -b intel_adsp/cavs25 samples/hello_world
dev$ west sign --tool-data=~/rimage/config -t ~/rimage/rimage -- \
-k $ZEPHYR_BASE/../modules/audio/sof/keys/otc_private_key_3k.pem
Run it!
=======
The loader script takes the signed rimage file as its argument. Once
it reports success, the application begins running immediately and its
console output (in the SOF shared memory trace buffer) can be read by
the logging script.
.. code-block:: console
dev$ west flash --remote-host crouton
Hello World! intel_adsp
Misc References
***************
Upstream documentation from which these instructions were drawn:
This page has the best reference for the boot process:
https://www.chromium.org/chromium-os/developer-library/reference/device/disk-format
This is great too, with an eye toward booting things other than ChromeOS:
https://www.chromium.org/chromium-os/developer-information-for-chrome-os-devices/custom-firmware
Part 3
한국어 전문 번역
Intel Chromebook의 Zephyr Audio DSP 개발
Intel Chromebook의 Audio DSP는 firmware signing에 SOF Community key를 사용하도록 구성됩니다. 따라서 SOF 자체뿐 아니라 Zephyr sample과 test suite를 포함해 사용자가 개발한 임의의 Zephyr application firmware도 받아들일 수 있습니다.
초기 Tiger Lake Chromebook 설정
장치 전원을 켜고 wireless network에 연결합니다. Firmware update를 내려받으려 한다면 먼저 끝날 때까지 기다려 working OS image 두 개를 확보합니다.
Developer Mode 활성화
- 오른쪽 아래 menu를 사용하거나 측면 power button을 길게 눌러 장치를 끕니다.
- Esc+Refresh(숫자 3 위의 원형 화살표 reload key)를 누른 채 power key를 눌러 recovery mode로 들어갑니다. Recovery mode에서는 touchscreen과 touchpad가 작동하지 않으므로 arrow key로 이동합니다.
- Advanced Options, Enable Developer Mode를 차례로 선택하고 확인합니다. Bootloader 화면에서 Boot from Internal Storage를 선택합니다. 이후 부팅 때마다 boot가 검증되지 않았다는 이 화면이 나타납니다.
- 필수 data wipe가 끝날 때까지 기다립니다. 원문 작성자의 장치는 stateful partition을 완전히 쓰는 데 약 15분이 걸렸습니다.
- Reboot 후 다시 Boot from Internal Storage를 선택하고 Google account로 장치를 다시 설정합니다.
Recovery drive 만들기
작업 중 장치를 망가뜨릴 가능성에 대비해 Google Web Store의 Chromebook Recovery Utility를 설치하고 recovery USB를 만듭니다. Chrome이 설치된 어느 machine·OS에서도 만들 수 있지만 Chromebook 자체는 device ID를 알고 있어 가장 간단합니다. Asus Tiger Lake board의 예시 ID는 DELBIN-XHVI D4B-H4D-G4G-Q9A-A9P입니다.
Root filesystem을 writable로 만들기
ChromeOS는 보안을 위해 Linux dm-verity를 사용해 read-only root filesystem의 모든 access에 signature와 cryptographic verification을 적용합니다. Custom kernel용 module을 설치하는 등 rootfs를 변경하려면 dm-verity layer를 꺼야 합니다.
Ctrl+Alt+T로 terminal을 열고 crosh> prompt에서 shell을 실행해 chronos user shell을 얻습니다. Developer mode에서는 sudo su -로 root prompt를 얻습니다.
crosh> shell
chronos@localhost / $ sudo su -
localhost ~ #
기존 signature를 깨뜨릴 것이므로 bootloader의 signature verification을 끕니다. 이것은 OS가 아니라 ROM bootloader가 수행하는 검증이며, 다음 setting은 developer-mode 전용 directive입니다.
cros# crossystem dev_boot_signed_only=0이 문서에서 hostname cros로 시작하는 prompt는 ChromeOS core shell에 입력하는 명령입니다.
다음으로 validation step을 비활성화합니다.
cros# /usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification
Reboot하면 Chromebook의 root가 dm-0 verity device가 아니라 raw storage device(예: /dev/nvme0n1p5)로 mount되고 rootfs가 read-write 상태가 됩니다.
이 명령은 설치된 kernel image의 command line을 실제로 수정하고 backup을 /mnt/stateful_partition/cros_sign_backups에 저장합니다. Command line이 root=dm-0 대신 root=<guid>를 지정하게 합니다. 다른 verity configuration은 남지만 이제 invalid가 된 결과 partition을 mount하려 하지 않습니다.
곧 이 kernel을 교체할 것이므로 새 kernel command line만 편집할 수도 있지만, 원문은 복잡도를 줄이기 위해 현재 kernel을 먼저 수정하고 reboot하는 순서를 사용합니다.
ChromeOS SSH 활성화
Writable partition으로 boot한 뒤 built-in SSH server를 켭니다.
cros# /usr/libexec/debugd/helpers/dev_features_ssh기본적으로 chronos와 root account에는 password가 없습니다. SSH key를 직접 입력하지 않으려면 첫 login과 ssh-copy-id 실행 전에 password를 설정합니다.
cros# passwd이제 Chromebook에 SSH로 접속하고 일반 Linux system처럼 key를 .ssh/authorized_keys에 추가합니다.
Crouton 설치
Zephyr integration tool은 완전한 Linux environment가 필요해 ChromeOS의 minimal distribution에서 실행되지 않습니다. ChromeOS Developer setting의 Linux Development Environment(Crostini)는 설치하지 마십시오. Crostini는 VM 안에서 실행되지만 이 도구들은 실제 hardware에서 실행되는 실제 kernel에 접근해야 합니다.
대신 real hardware의 sysfs와 /dev access를 유지하는 community chroot personality인 Crouton을 설치합니다. 여기서는 cli-extra package list를 설치하며, 화면에서 직접 작업하려면 X11-enabled target도 사용할 수 있습니다.
Root shell에서 installer를 받아 실행합니다. /usr/local은 noexec가 아닌 유일한 writable filesystem이므로 binary를 반드시 그곳에 둬야 합니다.
cros# mkdir -p /usr/local/bin
cros# curl -L https://github.com/dnschneid/crouton/raw/master/installer/crouton \
> /usr/local/bin/crouton
cros# chmod 755 /usr/local/bin/crouton
cros# crouton -r focal -t cli-extraCrouton chroot environment를 시작합니다.
cros# startcli
이제 Ubuntu environment에서 명령을 입력합니다. Native ChromeOS SSH server가 port 22를 사용하므로 Crouton의 inbound SSH는 다른 port를 사용합니다. 다음 예는 기억하기 쉽고 /etc/services에 등록되지 않은 222를 사용합니다.
crouton# apt install iptables openssh-server
crouton# echo "Port 222" >> /etc/ssh/sshd_config
crouton# mkdir /run/sshd
crouton# iptables -I INPUT -p tcp --dport 222 -j ACCEPT
crouton# /usr/sbin/sshd이후 hostname crouton은 별도의 Linux personality를 뜻합니다. Chroot를 다시 시작할 때마다 mkdir, iptables, sshd 명령을 실행해야 하며 편의를 위해 /etc/rc.local에 넣을 수 있습니다. Crouton은 system을 소유하지 않으므로 systemd를 실행할 수 없고, openssh-server 같은 Ubuntu service도 스스로 시작되지 않습니다.
Custom kernel build와 설치
Build host에서 ChromeOS kernel tree를 받습니다. Shipping device는 5.4 kernel을 사용하지만 원문 작성자는 5.10 tree가 잘 동작했고, upstream driver가 mainline보다 약 5~6주 늦은 정도로 backport되어 주요 hardware도 충분히 최신이라고 설명합니다. 간단히 home directory에 둡니다.
dev$ cd $HOME
dev$ git clone https://chromium.googlesource.com/chromiumos/third_party/kernel
dev$ cd kernel
dev$ git checkout chromeos-5.10Hostname dev는 kernel과 Zephyr application을 build하는 development machine의 shell입니다. Chromebook 자체에서도 가능하지만 system recovery 시 drive wipe가 필요할 수 있어 권장하지 않습니다. 기존 Linux tree가 있다면 ChromeOS repository를 remote로 추가하고 delta만 fetch하는 편이 더 빠릅니다.
실행 중인 Chromebook kernel은 configs module을 포함하므로 이를 load해 .config를 가져옵니다.
dev$ cd /path/to/kernel
dev$ ssh root@cros modprobe configs
dev$ ssh root@cros zcat /proc/config.gz > .configChromeOS default와 다르게 다음 custom configuration variable을 설정합니다. .config를 직접 편집하거나 menuconfig를 사용할 수 있습니다.
CONFIG_HUGETLBFS=y: Zephyr loader tool에 필요합니다.CONFIG_EXTRA_FIRMWARE_DIR=n: 현재 환경에 없는 Google build directory 참조를 끕니다.CONFIG_SECURITY_LOADPIN=n: Module을 한 filesystem에서만 load하게 고정하는 제약을 끕니다.CONFIG_MODVERSIONS=n: 수정된 dirty build tree에서 module을 build·install할 수 있게 합니다.
일반 Linux kernel과 같은 방식으로 build합니다.
dev$ make olddefconfig # Or otherwise update .config
dev$ make bzImage modules # Probably want -j<whatever> for parallel build
Module은 이제 writable인 device rootfs로 직접 복사할 수 있습니다. 이 filesystem은 read-only 용도로 설계되어 공간이 매우 작으므로 INSTALL_MOD_STRIP=1이 반드시 필요하며, 공간 확보를 위해 오래된 kernel module을 주기적으로 제거해야 할 수 있습니다.
dev$ make INSTALL_MOD_PATH=mods INSTALL_MOD_STRIP=1 modules_install
dev$ (cd mods/lib/modules; tar cf - .) | ssh root@cros '(cd /lib/modules; tar xfv -)'
ChromeOS kernel image package와 설치
bzImage를 서명해 ChromeOS vboot package로 묶은 뒤 kernel partition에 직접 써야 합니다. 필요한 도구는 Debian·Ubuntu repository에 있습니다.
$ sudo apt install vboot-utils vboot-kernel-utilsBootloader가 전달한 kernel_guid command-line parameter와 boot drive partition table을 비교해 현재 kernel partition을 찾습니다.
dev$ KPART=`ssh root@cros 'fdisk -l -o UUID,Device /dev/nvme0n1 | \
grep -i $(sed "s/.*kern_guid=//" /proc/cmdline \
| sed "s/ .*//") \
| sed "s/.* //"'`
dev$ echo $KPART
/dev/nvme0n1p4현재 image의 command line을 local file로 추출합니다.
dev$ ssh root@cros vbutil_kernel --verify /dev/$KPART | tail -1 > cmdline.txtVboot tooling으로 새 kernel image를 package합니다. 대부분의 인수는 항상 같은 boilerplate입니다. 현재 설정이 signature를 사용하지 않더라도 boot에는 valid signature가 필요해 key를 제공합니다. 실제로 비울 수 없는 dummy file을 bootloader로 전달하는 것은 EFI stub이 필요했던 이전 ROM variant의 흔적입니다.
dev$ echo dummy > dummy.efi
dev$ vbutil_kernel --pack kernel.img --config cmdline.txt \
--vmlinuz arch/x86_64/boot/bzImage \
--keyblock /usr/share/vboot/devkeys/kernel.keyblock \
--signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
--version 1 --bootloader dummy.efi --arch x86_64원한다면 vbutil_kernel --verify로 image를 검증할 수 있습니다. File을 device로 복사하고 kernel partition에 씁니다.
$ scp kernel.img root@cros:/tmp
$ ssh root@cros dd if=/tmp/kernel.img of=/dev/nvme0n1p4Reboot 후 모든 과정이 성공했다면 새 kernel이 실행됩니다.
Wi-Fi firmware 보정
Tiger Lake Chromebook의 /lib/firmware tree는 현재 5.10 kernel보다 오래되어 iwlwifi driver가 없는 firmware file을 요청하고 network가 사라질 수 있습니다. 간단한 해결책은 이전 version을 새 이름으로 link하는 것입니다. 더 나은 방법은 최신 kernel.org checkout의 /lib/firmware에서 올바른 version을 복사하는 것입니다.
cros# cd /lib/firmware
cros# ln -s iwlwifi-QuZ-a0-hr-b0-62.ucode iwlwifi-QuZ-a0-hr-b0-64.ucode
Zephyr application build와 실행
새 kernel로 boot했다면 Zephyr code를 실행할 준비가 됐습니다.
rimage signing tool build
Sound Open Firmware의 rimage tool을 내려받아 build합니다. 다음 예는 명확성을 위해 home directory를 사용하지만 어느 위치든 괜찮습니다.
dev$ cd $HOME
dev$ git clone https://github.com/thesofproject/rimage
dev$ cd rimage/
dev$ git submodule init
dev$ git submodule update
dev$ cmake .
dev$ make
Integration script를 Chromebook으로 복사
앞에서 설치한 Crouton environment 안에서 실행할 Python script가 필요합니다.
dev$ scp soc/intel/intel_adsp/tools/cavstool.py user@crouton:Crouton environment에서 service를 시작합니다.
crouton$ sudo ./cavstool.py user@crouton:
Zephyr application build와 signing
이 platform에서도 Zephyr application은 일반적인 방식으로 build합니다. 몇 가지 추가 인수와 함께 west sign으로 서명합니다. Tiger Lake DSP는 예전 hardware용 original key가 아니라 SOF의 3k key를 사용합니다. Device로 복사할 output artifact는 zephyr.ri입니다.
dev$ west build -b intel_adsp/cavs25 samples/hello_world
dev$ west sign --tool-data=~/rimage/config -t ~/rimage/rimage -- \
-k $ZEPHYR_BASE/../modules/audio/sof/keys/otc_private_key_3k.pem
실행
Loader script는 signed rimage file을 인수로 받습니다. Success가 보고되면 application이 즉시 실행되고 SOF shared-memory trace buffer의 console output을 logging script가 읽습니다.
dev$ west flash --remote-host crouton
Hello World! intel_adsp
기타 참고 자료
이 절차의 기반이 된 upstream 문서는 다음과 같습니다.
- ChromiumOS Disk Format: boot process에 관한 가장 좋은 참고 자료
- Custom Firmware: ChromeOS 이외의 system boot 관점까지 다루는 자료
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.