User:Tildeguy/Hi6250 Notes
HiSilicon Kirin 650/655/658/659 (Hi6250)
Bootloader unlocking
We will use PotatoNV to unlock the device. Disassemble the phone and locate the testpoint. Run PotatoNV as described below, and short the testpoint to GND while the device is booting.
$ git clone https://github.com/tildeknown/PotatoNV --recursive
$ cd PotatoNV
$ pip install -r requirements.txt
$ python main.py -b hisi65x_a # short the testpoint
$ fastboot oem unlock 0123456789ABCDEF
Partitions
- Never write to the userdata partition (unless your device allows it).
- The boot image is split into the kernel and the ramdisk, and each one is flashed as an Android boot image.
Second-stage bootloader
UniLoader
Status: merged agassi2 support
U-Boot
Status: not ported. https://github.com/tildeknown/u-boot
Mainlining
Status: boots, shows postmarketos logo with stub/aoctrl clocks enabled
Y - mainlined
P - written, untested/broken
N - not mainlined
| Component | Driver | Status | Notes |
|---|---|---|---|
| Dual timer | arm,sp804 | Y | |
| Timer | arm,armv8-timer | Y | |
| PMU | arm,cortex-a53-pmu | Y | |
| GIC | arm,cortex-a9-gic | Y | |
| CPU | arm,cortex-a53 | Y | needs more testing (opp?) |
| GPIO | arm,pl061 | P | |
| Pinctrl | pinconf-single | P | hi6250-pinctrl.dtsi |
| I2C | snps,designware-i2c | P | |
| Aoctrl clock | hisilicon,hi6250-aoctrl | P | clk-hi6250.c |
| Pmuctrl clock | hisilicon,hi6250-pmuctrl | P | clk-hi6250.c |
| Sysctrl clock | hisilicon,hi6250-sysctrl | P | clk-hi6250.c |
| Crgctrl clock | hisilicon,hi6250-crgctrl | P | clk-hi6250.c |
| Stub clock | hisilicon,hi6250-stub-clk | Y | clk-hi6250-stub.c |
| Pctrl clock | syscon | N | empty |
| Iomcu clock | syscon | P | empty |
| Mailbox | hisilicon,hi3660-mbox | Y | |
| Crg reset | hisilicon,hi3660-reset | P | |
| Iomcu reset | hisilicon,hi3660-reset | P | |
| Sys reset | hisilicon,hi3660-reset | P | |
| PMIC | hisilicon,hi655x-pmic | P | |
| GPU | arm,mali-t830 | P | |
| USB | hisilicon,hi3660-usb3-otg-bc | P | |
| USB Charger | richtek,rt9466 | N | i2c4, agassi2-specific |
| Charger | huawei,bq2560x_charger | N | i2c4, agassi2-specific |
| UART | arm,pl011 | P | |
| DMA | hisilicon,k3-dma-1.0 | P | |
| Iomcu DMA | hisilicon,k3-dma-1.0 | P | |
| DMA Controller | hisilicon,hisi-pcm-asp-dma-1.0 | N | maybe useless |
| EMMC 5.0 | arasan,sdhci | N | i won't work on it |
| SD (DWMMC1) | hisilicon,hi3660-dw-mshc | P | |
| Wi-Fi (DWMMC2) | hisilicon,hi3660-dw-mshc | P | |
| Framebuffer | simple-framebuffer | P | 0x5d000000 (logo-buffer) |
| Iomcu SMMU (ION) | hisi,hisi-smmu / arm,smmu-v3 | N | some important thing |
Testing
| WARNING: Danger! Danger! Backup all your partitions using dd in TWRP or rooted android before even trying to flash something!!! Write everything yourself, I'm just giving examples! |
| WARNING: I am not responsible for frying yo device |
This guide is mostly based on testing on the Huawei Agassi2, so you'll need to adapt it for your device.
Create new ports for the device
Make mainline kernel and device aports. Not downstream ones, how pmbootstrap offers.
$ pmbootstrap init
Here is my port for a reference
Build the kernel
Build Hi6250 kernel with envkernel (not just make) since we need the kernel aport to get ramdisk.
$ git clone https://github.com/hi6250-mainline/linux
$ cd linux-hi6250
$ envkernel # . pmbootstrap/helpers/envkernel.sh
$ export ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
$ make hi6250_defconfig
$ make
$ pmbootstrap build --force --envkernel linux-huawei-agassi2
$ deactivate
$ pmbootstrap install
$ cd ..
Build uniLoader
Copy kernel blobs and build uniLoader.
You should adapt the config (configs/agassi2_defconfig) and board (board/huawei/board-agassi2.c) for your device. Upstreaming is always appreciated.
$ git clone https://github.com/ivoszbg/uniLoader
$ cd uniLoader
$ cp ../linux-hi6250/.output/arch/arm64/boot/Image blob
$ cp ../linux-hi6250/.output/arch/arm64/boot/dts/hisilicon/hi6250-huawei-agassi2.dtb blob/dtb
$ cp /tmp/postmarketOS-export/initramfs blob/ramdisk
$ export ARCH=aarch64 CROSS_COMPILE=aarch64-linux-gnu-
$ make agassi2_defconfig
$ make
Make boot images
Bootimg parameters for Agassi2
You can get such parameters using unpack_bootimg command.
$ pmbootstrap export
$ curl -O https://raw.githubusercontent.com/tildeknown/mkbootimg/refs/heads/main/mkbootimg.py; chmod +x mkbootimg.py
$ ./mkbootimg.py --kernel uniLoader.gz --ramdisk /dev/null --os_version 8.0.0 --os_patch_level 2020-08 --pagesize 0x00000800 --base 0x00000000 --kernel_offset 0x00480000 --ramdisk_offset 0x08000000 --second_offset 0x01300000 --tags_offset 0x07e00000 --board '' --cmdline 'loglevel=4 coherent_pool=512K page_tracker=on slub_min_objects=12 unmovable_isolate1=2:192M,3:224M,4:256M printktimer=0xfff0a000,0x534,0x538 androidboot.selinux=enforcing buildvariant=user' -o /tmp/kernel-boot.img
$ ./mkbootimg.py --kernel /dev/null --ramdisk /tmp/postmarketOS-export/initramfs --os_version 8.0.0 --os_patch_level 2020-10 --pagesize 0x00000800 --base 0x00000000 --kernel_offset 0x10008000 --ramdisk_offset 0x11000000 --second_offset 0x10f00000 --tags_offset 0x10000100 --board '' --cmdline buildvariant=user -o /tmp/ramdisk-boot.img
Flash uniLoader + ramdisk
Simply flash the images
$ fastboot flash kernel /tmp/kernel-boot.img
$ fastboot flash ramdisk /tmp/ramdisk-boot.img
$ fastboot reboot