Skip to content

Commit d712fe2

Browse files
committed
Add alpha instructions to craft a RB1 image
This is very manual and error-prone, and will be trimmed down as various components are fixed. Signed-off-by: Loïc Minier <[email protected]>
1 parent aafb0bb commit d712fe2

File tree

2 files changed

+189
-0
lines changed

2 files changed

+189
-0
lines changed

README.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,152 @@ The RB3 Gen2 board boots from UFS by default. To flash a disk image to the UFS s
8282
```
8383
The `prog_firehose_ddr.elf` payload is part of the the Yocto Qualcomm Linux image download.
8484

85+
### RB1 instructions (alpha)
86+
87+
The RB1 board boots from eMMC by default and uses an Android style boot architecture. Read-on to flash a disk image to the eMMC storage of the RB1 board and emulate an UEFI boot architecture.
88+
89+
#### Build disk-sdcard.img with debos
90+
As above, build a SD card image as it's using a 512 sector size, like eMMC on the RB1:
91+
```bash
92+
debos \
93+
--fakemachine-backend qemu \
94+
--memory 1GiB \
95+
--scratchsize 4GiB \
96+
-t xfcedesktop:true \
97+
debos-recipes/qualcomm-linux-debian-rootfs.yaml
98+
debos \
99+
--fakemachine-backend qemu \
100+
--memory 1GiB \
101+
--scratchsize 4GiB \
102+
-t dtb:qcom/qrb2210-rb1.dtb \
103+
-t imagetype:sdcard \
104+
debos-recipes/qualcomm-linux-debian-image.yaml
105+
```
106+
107+
#### Build U-Boot with RB1 support
108+
109+
U-Boot will be chainloaded from the first Android boot partition.
110+
111+
1. install build-dependencies to build U-Boot and to generate Android boot images
112+
```bash
113+
sudo apt install git build-essential crossbuild-essential-arm64 flex bison libssl-dev gnutls-dev mkbootimg
114+
```
115+
116+
1. get the qcom-mainline branch from Sumit Garg's U-Boot repository ([upstream submission](https://patchwork.ozlabs.org/project/uboot/list/?series=451544))
117+
```bash
118+
git clone -b qcom-mainline https://github.com/b49020/u-boot/
119+
```
120+
121+
1. build U-Boot and pack it into an Android boot image with the RB1 DTB
122+
```bash
123+
make qcom_defconfig
124+
make -j`nproc` DEVICE_TREE=qcom/qrb2210-rb1
125+
gzip u-boot-nodtb.bin
126+
cat u-boot-nodtb.bin.gz dts/upstream/src/arm64/qcom/qrb2210-rb1.dtb >u-boot-nodtb.bin.gz-dtb
127+
mkbootimg --base 0x80000000 --pagesize 4096 --kernel u-boot-nodtb.bin.gz-dtb --cmdline "root=/dev/notreal" --ramdisk u-boot.bin --output rb1-boot.img
128+
```
129+
130+
#### Build an upstream Linux kernel to workaround boot issues
131+
132+
Linux 6.14 or later will just work, but 6.13 kernels need `CONFIG_CLK_QCM2290_GPUCC=m` ([upstream submission](https://lore.kernel.org/linux-arm-msm/[email protected]/))
133+
134+
1. install build-dependencies, get latest kernel (or a stable one)
135+
```bash
136+
sudo apt install git flex bison bc libelf-dev libssl-dev
137+
git clone --depth=1 https://github.com/torvalds/linux
138+
make defconfig
139+
make deb-pkg -j$(nproc)
140+
```
141+
142+
1. on an arm64 capable machine, chroot into the disk image's root filesystem, mount the ESP and install the kernel
143+
```bash
144+
# this mounts the image and starts a shell in the chroot
145+
host% sudo scripts/disk-image-edit.sh disk-sdcard.img 512
146+
chroot#
147+
148+
# in another shell on the host, copy the kernel .deb to /mnt/root
149+
host% chroot sudo cp linux-image-6.13.0_6.13.0-1_arm64.deb /mnt/root/
150+
151+
# from within the chroot, mount ESP and install the kernel
152+
chroot# mount /boot/efi
153+
chroot# dpkg -i /root/linux-image-6.13.0_6.13.0-1_arm64.deb
154+
# uncompress the kernel as systemd-boot doesn’t handle these
155+
chroot# zcat /boot/efi/*/6.13*/linux >/tmp/linux
156+
chroot# mv /tmp/linux /boot/efi/*/6.13*/linux
157+
# update systemd entry to point at uncompressed kernel
158+
vi /boot/efi/…
159+
chroot# umount /boot/efi
160+
161+
# leave chroot and unmount image
162+
chroot# exit
163+
```
164+
165+
#### Extract the root and ESP partitions from the disk image
166+
167+
This will create disk-sdcard.img1 and disk-sdcard.img2:
168+
```bash
169+
fdisk -l disk-sdcard.img | sed -n '1,/^Device/ d; p' |
170+
while read name start end sectors rest; do
171+
dd if=disk-sdcard.img of="${name}" bs=512 skip="${start}" count="${sectors}"
172+
done
173+
```
174+
175+
#### Prepare a flashable image
176+
177+
1. download and unpack the [Linux eMMC RB1 recovery image version 23.12 from Linaro](https://releases.linaro.org/96boards/rb1/linaro/rescue/23.12/)
178+
179+
1. edit rawprogram0.xml and change the filename for the following partitions to these values to match files generated earlier:
180+
181+
|label|filename|
182+
|---|---|
183+
|`boot_a`|`u-boot-abootimg.img`|
184+
|`esp`|`disk-sdcard.img1`|
185+
|`rootfs`|`disk-sdcard.img2`|
186+
187+
#### Flash the image
188+
189+
You probably want to connect to the serial port during the whole process, to follow what’s happening on the target. Plug the type-B USB cable to your host and access the serial console with 115200 8N1, e.g. with screen:
190+
191+
Linux (tweak the name of the device):
192+
```bash
193+
screen /dev/ttyUSB* 115200
194+
```
195+
macOS (tweak the name of the device):
196+
```bash
197+
screen /dev/cu.usbserial-* 115200
198+
```
199+
200+
Make sure that the 6th switch on the `DIP_SW_1` bank next to the eMMC is `ON` as to use the USB type-C port for flashing.
201+
202+
Put the board in "emergency download" mode (EDL) by removing any cable from the USB type-C port, and pressing the `F_DL` button while turning the power on.
203+
204+
Connect a cable from the flashing host to the USB type-C port on the board.
205+
206+
Unpack the pre-built tarball and run:
207+
```bash
208+
qdl --storage emmc prog_firehose_ddr.elf rawprogram*.xml patch*.xml
209+
```
210+
211+
You should see:
212+
```
213+
Waiting for EDL device
214+
waiting for programmer...
215+
flashed "xbl_a" successfully
216+
[...]
217+
partition 0 is now bootable
218+
```
219+
220+
And the board should boot to a LightDM greeter on HDMI. Login to the serial console or Xfce session with user / password debian / debian.
221+
222+
The USB ports and Ethernet should work after flipping the 6th switch on the `DIP_SW_1` bank next to the eMMC to `OFF`.
223+
224+
#### Installing “qbootctl” to reset the reboot counter on boot
225+
226+
In the installed Debian system, install “qbootctl” to make the current Android boot image as a successful:
227+
```bash
228+
sudo apt install qbootctl
229+
```
230+
85231
## Development
86232

87233
Want to join in the development? Changes welcome! See [CONTRIBUTING.md file](CONTRIBUTING.md) for step by step instructions.

scripts/disk-image-edit.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
4+
# Input disk image and sector size
5+
DISK_IMG="$1"
6+
SECTOR_SIZE="$2"
7+
8+
# Setup loop device with specified sector size
9+
LOOP_DEV=$(losetup -f --show -P --sector-size "$SECTOR_SIZE" "$DISK_IMG")
10+
11+
# Mount the second partition
12+
mkdir -p /mnt
13+
mount "${LOOP_DEV}p2" /mnt
14+
15+
# Bind mount necessary directories
16+
mount --bind /dev /mnt/dev
17+
mount --bind /dev/pts /mnt/dev/pts
18+
mount --bind /proc /mnt/proc
19+
mount --bind /sys /mnt/sys
20+
21+
# Dangerous
22+
#mount --bind /tmp /mnt/tmp
23+
24+
# DNS from host
25+
touch /mnt/etc/resolv.conf
26+
mount --bind /etc/resolv.conf /mnt/etc/resolv.conf
27+
28+
# Chroot into /mnt and run a shell
29+
chroot /mnt /bin/bash
30+
31+
# Cleanup after exiting the chroot shell
32+
umount /mnt/etc/resolv.conf
33+
#umount /mnt/tmp
34+
umount /mnt/dev/pts
35+
umount /mnt/dev
36+
umount /mnt/proc
37+
umount /mnt/sys
38+
umount /mnt
39+
40+
# Detach the loop device
41+
losetup -d "$LOOP_DEV"
42+
43+
echo "Cleanup completed."

0 commit comments

Comments
 (0)