Skip to content

Commit 03a23a2

Browse files
authored
Merge pull request #13 from lool/rb1-instructions
Add alpha instructions to craft a RB1 image
2 parents ca980ea + d712fe2 commit 03a23a2

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
@@ -105,6 +105,152 @@ To enter EDL mode:
105105

106106
NB: It's also possible to run qdl from the host while the baord is not connected, and starting the board directly in EDL mode.
107107

108+
### RB1 instructions (alpha)
109+
110+
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.
111+
112+
#### Build disk-sdcard.img with debos
113+
As above, build a SD card image as it's using a 512 sector size, like eMMC on the RB1:
114+
```bash
115+
debos \
116+
--fakemachine-backend qemu \
117+
--memory 1GiB \
118+
--scratchsize 4GiB \
119+
-t xfcedesktop:true \
120+
debos-recipes/qualcomm-linux-debian-rootfs.yaml
121+
debos \
122+
--fakemachine-backend qemu \
123+
--memory 1GiB \
124+
--scratchsize 4GiB \
125+
-t dtb:qcom/qrb2210-rb1.dtb \
126+
-t imagetype:sdcard \
127+
debos-recipes/qualcomm-linux-debian-image.yaml
128+
```
129+
130+
#### Build U-Boot with RB1 support
131+
132+
U-Boot will be chainloaded from the first Android boot partition.
133+
134+
1. install build-dependencies to build U-Boot and to generate Android boot images
135+
```bash
136+
sudo apt install git build-essential crossbuild-essential-arm64 flex bison libssl-dev gnutls-dev mkbootimg
137+
```
138+
139+
1. get the qcom-mainline branch from Sumit Garg's U-Boot repository ([upstream submission](https://patchwork.ozlabs.org/project/uboot/list/?series=451544))
140+
```bash
141+
git clone -b qcom-mainline https://github.com/b49020/u-boot/
142+
```
143+
144+
1. build U-Boot and pack it into an Android boot image with the RB1 DTB
145+
```bash
146+
make qcom_defconfig
147+
make -j`nproc` DEVICE_TREE=qcom/qrb2210-rb1
148+
gzip u-boot-nodtb.bin
149+
cat u-boot-nodtb.bin.gz dts/upstream/src/arm64/qcom/qrb2210-rb1.dtb >u-boot-nodtb.bin.gz-dtb
150+
mkbootimg --base 0x80000000 --pagesize 4096 --kernel u-boot-nodtb.bin.gz-dtb --cmdline "root=/dev/notreal" --ramdisk u-boot.bin --output rb1-boot.img
151+
```
152+
153+
#### Build an upstream Linux kernel to workaround boot issues
154+
155+
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]/))
156+
157+
1. install build-dependencies, get latest kernel (or a stable one)
158+
```bash
159+
sudo apt install git flex bison bc libelf-dev libssl-dev
160+
git clone --depth=1 https://github.com/torvalds/linux
161+
make defconfig
162+
make deb-pkg -j$(nproc)
163+
```
164+
165+
1. on an arm64 capable machine, chroot into the disk image's root filesystem, mount the ESP and install the kernel
166+
```bash
167+
# this mounts the image and starts a shell in the chroot
168+
host% sudo scripts/disk-image-edit.sh disk-sdcard.img 512
169+
chroot#
170+
171+
# in another shell on the host, copy the kernel .deb to /mnt/root
172+
host% chroot sudo cp linux-image-6.13.0_6.13.0-1_arm64.deb /mnt/root/
173+
174+
# from within the chroot, mount ESP and install the kernel
175+
chroot# mount /boot/efi
176+
chroot# dpkg -i /root/linux-image-6.13.0_6.13.0-1_arm64.deb
177+
# uncompress the kernel as systemd-boot doesn’t handle these
178+
chroot# zcat /boot/efi/*/6.13*/linux >/tmp/linux
179+
chroot# mv /tmp/linux /boot/efi/*/6.13*/linux
180+
# update systemd entry to point at uncompressed kernel
181+
vi /boot/efi/…
182+
chroot# umount /boot/efi
183+
184+
# leave chroot and unmount image
185+
chroot# exit
186+
```
187+
188+
#### Extract the root and ESP partitions from the disk image
189+
190+
This will create disk-sdcard.img1 and disk-sdcard.img2:
191+
```bash
192+
fdisk -l disk-sdcard.img | sed -n '1,/^Device/ d; p' |
193+
while read name start end sectors rest; do
194+
dd if=disk-sdcard.img of="${name}" bs=512 skip="${start}" count="${sectors}"
195+
done
196+
```
197+
198+
#### Prepare a flashable image
199+
200+
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/)
201+
202+
1. edit rawprogram0.xml and change the filename for the following partitions to these values to match files generated earlier:
203+
204+
|label|filename|
205+
|---|---|
206+
|`boot_a`|`u-boot-abootimg.img`|
207+
|`esp`|`disk-sdcard.img1`|
208+
|`rootfs`|`disk-sdcard.img2`|
209+
210+
#### Flash the image
211+
212+
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:
213+
214+
Linux (tweak the name of the device):
215+
```bash
216+
screen /dev/ttyUSB* 115200
217+
```
218+
macOS (tweak the name of the device):
219+
```bash
220+
screen /dev/cu.usbserial-* 115200
221+
```
222+
223+
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.
224+
225+
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.
226+
227+
Connect a cable from the flashing host to the USB type-C port on the board.
228+
229+
Unpack the pre-built tarball and run:
230+
```bash
231+
qdl --storage emmc prog_firehose_ddr.elf rawprogram*.xml patch*.xml
232+
```
233+
234+
You should see:
235+
```
236+
Waiting for EDL device
237+
waiting for programmer...
238+
flashed "xbl_a" successfully
239+
[...]
240+
partition 0 is now bootable
241+
```
242+
243+
And the board should boot to a LightDM greeter on HDMI. Login to the serial console or Xfce session with user / password debian / debian.
244+
245+
The USB ports and Ethernet should work after flipping the 6th switch on the `DIP_SW_1` bank next to the eMMC to `OFF`.
246+
247+
#### Installing “qbootctl” to reset the reboot counter on boot
248+
249+
In the installed Debian system, install “qbootctl” to make the current Android boot image as a successful:
250+
```bash
251+
sudo apt install qbootctl
252+
```
253+
108254
## Development
109255

110256
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)