Skip to content

Commit

Permalink
add alpine setup to guide
Browse files Browse the repository at this point in the history
  • Loading branch information
DorianRudolph committed Jan 23, 2022
1 parent 181201f commit 85fa0db
Showing 1 changed file with 160 additions and 1 deletion.
161 changes: 160 additions & 1 deletion guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,163 @@ rkdeveloptool reboot

Note that there is a bug in rkdeveloptool that prohibits us from dumping partitions of size larger than 2G.
So we cannot successfully dump userdata, but that is not so important because android can recreate that on its own.
Do make sure that the dumped partitions contain actual data and not just 0xCC to ensure that there
Do make sure that the dumped partitions contain actual data and not just 0xCC.

## Android root

### Enable ADB

https://forum.pine64.org/showthread.php?tid=15598

- Application icon (4 squares) in the top
- Application management
- Application message
- 3 Dots -> Show System
- Search for "Settings" and open

Enable ADB the standard way.
This didn't work immediately for me, so I also set the "Default USB configuration" to PTP, after which I had to reenable ADB.
Then I got the permission prompt.

### Magisk

We use [Magisk](https://github.com/topjohnwu/Magisk) following the [tutorial](https://topjohnwu.github.io/Magisk/install.html#patching-images).

I had issues with Magisk, discussed in this [issue](https://github.com/topjohnwu/Magisk/issues/5125) (many thanks to canyie for fixing this so quickly).
The canary build of Magisk, should work now, but I also backed up the version I used ([backup](static/magisk_c85b2a0.apk)).

```
adb push boot.img /sdcard/boot.img # d60f4054edb91259fb4471eb5f0ba53803b9a7e2300c3647e11f7b71aa95a003
adb install magisk_c85b2a0.apk
# install magisk to boot.img
adb pull /sdcard/Download/magisk_patched-23011_dhTkI.img boot_magisk.img
rkdeveloptool write-partition boot boot_magisk.img
rkdeveloptool reboot
```

Now you should have a working root. Try running `su` in `adb shell`.

## Build mainline kernel

Clone kernel:
```sh
git clone -b rk355x-ebc-dev https://github.com/smaeul/linux/tree/rk356x-ebc-dev
# or
git clone https://gitlab.com/pgwipeout/linux-next.git
curl https://gitlab.com/pgwipeout/quartz64_ci/-/raw/main/quartz64_defconfig?inline=false -o linux-next/arch/arm64/configs/pinenote_defconfig
```
I'm using pgwipeout's kernel for now

### VCOM

Each Eink panel has a calibration offset VCOM.
The factory uboot sets the kernel parameter `ebc_pmic.vcom=960`, which you can find out with `cat /proc/cmdline` on android.
For my device, VCOM is 960mV, but this value is (supposedly) unique for each device.
This value should be entered into `regulator-min-microvolt` and `regulator-max-microvolt` in the `rk3556-pinenote.dts`.
Alternatively, you can also remove the `regulator-min-microvolt` and `regulator-max-microvolt`, which we do here.

```diff
--- a/arch/arm64/boot/dts/rockchip/rk3566-pinenote.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3566-pinenote.dts
@@ -653,8 +653,8 @@ v3p3: v3p3 {

vcom: vcom {
regulator-name = "vcom";
- regulator-min-microvolt = <1450000>;
- regulator-max-microvolt = <1450000>;
+ /* regulator-min-microvolt = <960000>;
+ regulator-max-microvolt = <960000>; */
};

vdrive: vdrive {
```

### Compile the kernel

Add F2FS to `pinenote_defconfig` such that we can work with the userdata partition.
```
CONFIG_F2FS_FS=y
CONFIG_F2FS_STAT_FS=y
CONFIG_F2FS_FS_XATTR=y
CONFIG_F2FS_FS_POSIX_ACL=y
CONFIG_F2FS_FS_SECURITY=y
CONFIG_F2FS_FS_ENCRYPTION=y
```

Download toolchain (next to the kernel directory):
```sh
wget https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu.tar.xz{,.asc}
md5sum -c gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu.tar.xz.asc
tar xfv gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu.tar.xz
```

Build (save as shell script for rebuilds):

```sh
export CROSS_COMPILE="$PWD/../gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-"
export ARCH=arm64

make clean

make pinenote_defconfig
make -j $(nproc) all

rm -rf pack
mkdir pack
make INSTALL_MOD_PATH=pack modules_install
make INSTALL_PATH=pack dtbs_install

rm -rf ../kout
mkdir ../kout
cp arch/arm64/boot/Image ../kout
cp pack/dtbs/*/rockchip/rk3566-pinenote.dtb ../kout
rsync -av pack/lib/modules ../kout --exclude='*/source' --exclude='*/build'

cd ../kout/modules
tar cf ../modules.tar *
cd ..
rm -r modules
```

### Export firmware


```sh
adb shell
su

cd /vendor/etc/firmware
tar -c -j -f /sdcard/firmware.tar.bz2 *
dd if=/dev/block/mmcblk2p3 of=/sdcard/waveform.bin bs=1k count=2048
sha1sum /sdcard/firmware.tar.bz2 /sdcard/waveform.bin
# waveform.bin matches waveform partition
exit

adb pull /sdcard/waveform.bin
adb pull /sdcard/firmware.tar.bz2
```
Backup: (waveform.bin)[static/waveform.bin], (firmware.tar.bz2)[static/firmware.tar.bz2]

## Boot Alpine

Setup alpine root in `/cache`:
```sh
# alpine rootfs
wget https://dl-cdn.alpinelinux.org/alpine/v3.15/releases/aarch64/alpine-minirootfs-3.15.0-aarch64.tar.gz
adb push alpine-minirootfs-3.15.0-aarch64.tar.gz /sdcard

# kernel and modules
cd kout
adb push * /sdcard

adb shell
su

cp rk3566-pinenote.dtb Image /cache
tar -zxf alpine-minirootfs-3.15.0-aarch64.tar.gz -C /cache
echo "nameserver $(getprop net.dns1)" > /cache/etc/resolv.conf

# chroot to install additional tools (wake the pinenote to connect to wifi)
env -i PATH=/usr/bin:/bin:/usr/sbin:/sbin chroot /cache
apk add --no-cache parted e2fsprogs
```

0 comments on commit 85fa0db

Please sign in to comment.