How to get Debian working


I don’t have my Hikey 960 with me so I can’t check that every step is right, but these are the notes I made to get Debian working with Hynix UFS. You need to have a serial interface connected to the Hikey.

Thanks to Bas Vermeulen on this thread: How to enable Opencl support on hikey960? for the kernel and useful hints.

The steps are:

  1. Build patched kernel
  2. Convert rootfs from android sparse image to standard image and mount
  3. Copy new kernel into rootfs
  4. Convert back to sparse image and flash
  5. Boot and modify boot command to point to new kernel

Below assumes you have a directory structure of
./images downloaded disk images from Linaro
./linux where the kernel is cloned
./hynix_patch where the patch is cloned

# Get the patch
git clone

# Get a build environment
sudo apt install build-essential gcc-aarch64-linux-gnu

# Get the kernel
    git clone
    cd linux/
    git checkout daedalean

# Apply the patch
git apply ../hynix_patch/hynix.patch

# Build the kernel    
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu daedalean_defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu Image modules

# Install all the stuff somewhere 
mkdir -p /tmp/tmp_install/boot
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- INSTALL_MOD_PATH=/tmp/tmp_install INSTALL_MOD_STRIP=1 modules_install
cp arch/arm64/boot/Image /tmp/tmp_install/boot/Image

# Turn rootfs image from sparse into normal
cd ../images 
simg2img debian-hikey960-public.rootfs.img debian-hikey960-public.rootfs.raw.img

# Mount it and copy the new kernel in with a new name
mkdir tmp
sudo mount debian-hikey960-public.rootfs.raw.img tmp
sudo cp /tmp/tmp_install/boot/Image tmp/boot/Image_new
sudo umount tmp

# Repack as a sparse image and flash
img2simg  debian-hikey960-public.rootfs.raw.img repacked_debian.img
sudo fastboot flash system repacked_debian.img

# Reboot Hikey960
sudo fastboot reboot

# In the UEFI menu, navigate to edit menu item, change name of kernel, ctrl-x to save and reboot

There may be mistakes above but it should be roughly right… Probably the patch will work on the standard kernel but I haven’t tried it.

EDITED to fix typo in last instruction

Can't boot into linux after flash it through official guide
Debian fails to boot
Problems with linaro-stretch-developer-hikey-20180828-19

Hi. Thanks for sharing this guide. I can’t find the UEFI menu. Could you please explain more about the last step?


On your serial terminal during booting press ESC quickly enough and you get the UEFI menu:

Select Boot Manager->Grub and you get the Grub menu:

Select ‘e’ within 10 seconds and you get the editor:

You need to change the command to point to the kernel image you copied into the rootfs. This doesn’t change the command permanently, I think you need to use the grub tools to do that.


Hi, @siteks!
Thanks for your patience! But my Grub menu is different from yours.

I’m wondering whether we are using the same prm_table.img and such. I’m using images from the offical guide Then I take the steps in I tried the rootfs image from and from, but both ends up with the Grub menu above and I can’t find the command you shared. Could you share your flash images and flash steps?


SSH into hikey960

Ok, I was using @bvermeul rootfs image and kernel because it is built for Hikey960 rather than the old Hikey board and has support for OpenCL and more peripherals. But I just tried with the Linaro image:

# From scratch
cd images
gzip -d boot-linaro-stretch-developer-hikey-20180828-19.img.gz
gzip -d rootfs-linaro-stretch-developer-hikey-20180828-19.img.gz
sudo fastboot flash ptable prm_ptable.img
sudo fastboot flash fastboot l-loader.bin
sudo fastboot flash fip fip.bin
sudo fastboot reboot-bootloader
sudo fastboot erase boot
sudo fastboot erase system
sudo fastboot erase userdata
sudo fastboot flash boot boot-linaro-stretch-developer-hikey-20180828-19.img
sudo fastboot flash system rootfs-linaro-stretch-developer-hikey-20180828-19.img
sudo fastboot reboot
# This fails with these errors on the UFS:
[    4.069111] ufshcd-hisi ff3b0000.ufs: ufshcd_query_flag: Sending flag query for idn 3 failed, err = -11
[    5.605085] ufshcd-hisi ff3b0000.ufs: ufshcd_query_flag: Sending flag query for idn 3 failed, err = -11
[    5.614488] ufshcd-hisi ff3b0000.ufs: ufshcd_query_flag_retry: query attribute, opcode 5, idn 3, failed with error -11 after 3 retires
[    7.141116] ufshcd-hisi ff3b0000.ufs: __ufshcd_query_descriptor: opcode 0x01 for idn 8 failed, index 0, err = -11
[    8.677098] ufshcd-hisi ff3b0000.ufs: __ufshcd_query_descriptor: opcode 0x01 for idn 8 failed, index 0, err = -11
[   10.213118] ufshcd-hisi ff3b0000.ufs: __ufshcd_query_descriptor: opcode 0x01 for idn 8 failed, index 0, err = -11
[   10.223392] ufshcd-hisi ff3b0000.ufs: ufshcd_read_desc_param: Failed reading descriptor. desc_id 8, desc_index 0, param_offset 0, ret -11
[   10.235748] ufshcd-hisi ff3b0000.ufs: ufshcd_init_icc_levels: Failed reading power descriptor.len = 98 ret = -11

# Copy in patched kernel
simg2img rootfs-linaro-stretch-developer-hikey-20180828-19.img rootfs-linaro-stretch-developer-hikey-20180828-19.raw.img
mkdir -p tmp
sudo mount rootfs-linaro-stretch-developer-hikey-20180828-19.raw.img tmp
# The patched kernel:
sudo cp ../kernels/Image tmp/boot/
sudo umount tmp
img2simg rootfs-linaro-stretch-developer-hikey-20180828-19.raw.img rootfs-linaro-stretch-developer-hikey-20180828-19.repacked.img
sudo fastboot erase system
sudo fastboot flash system rootfs-linaro-stretch-developer-hikey-20180828-19.repacked.img
sudo fastboot reboot

Navigate to UEFI GRUB menu, then scroll down:

Change the line starting ‘linux’

Then ctrl-x and it should now boot successfully. In the boot log there are no errors on the UFS:

        [    0.614455] ufshcd-hi3660 ff3b0000.ufs: ufshcd_print_pwr_info:[RX, TX]: gear=[1, 1], lane[1, 1], pwr[SLOWAUTO_MODE, SLOWAUTO_MODE], rate = 0
        [    0.742376] ufs final power mode: gear = 1, lane = 2, pwr = 5, rate = 1
        [    0.742379] ufshcd-hi3660 ff3b0000.ufs: set TX_EQUALIZER 3.5db
        [    0.742392] ufs flash device must set VS_DebugSaveConfigTime 0x10
        [    0.744652] ufshcd-hi3660 ff3b0000.ufs: check TX_EQUALIZER DB value lane0 = 0x1
        [    0.744661] ufshcd-hi3660 ff3b0000.ufs: TX_EQUALIZER DB value lane1 = 0x1
        [    0.744665] ufshcd-hi3660 ff3b0000.ufs: ufshcd_print_pwr_info:[RX, TX]: gear=[1, 1], lane[2, 2], pwr[SLOWAUTO_MODE, SLOWAUTO_MODE], rate = 1
        [    0.745517] ufshcd-hi3660 ff3b0000.ufs: ufshcd_find_max_sup_active_icc_level: Regulator capability was not set, actvIccLevel=0

Sometimes you can get strange results if you don’t erase the system and userdata partitions, now I do that each time to be sure.

Hope this helps!


@siteks I have added the original patch you based yours on into my repository in the daedalean tree.


@bvermeul Great, that’s good to know!


Thanks! @siteks. My borad seems to have some hardware problems. The USB connection breaks down when executing fastboot erase. I’ll try your method again after I fix that.:sweat_smile:



I too have used the instruction to create and install the debian image on a post April 2018 hikey960.

I built a bash script to further automate the process…and it has help!

Below is the help section. when i figure out how I will upload. if I can’t figure it out then I will post a link.

NAME:  version: 0.1
  Hikey960 operating system build, configure and flash utility.

  Single or multiple options are allowed and may appear in any order.
  and do not require a preceeding hyphen(s). Commands may have sub options.

  * install-tools
        Install build tools for kernel compilation and image generation.
  * download-images
        Fetch reference images from the internet and store in ./images.
  * download-blackstar
        Fetch the custom blackstar root fs image from the internet.
  * download-kernelsource
        Fetch the custom kernel source in the Tall guy repository in ./linux
  * build-kernel
        Build the kernel source to generate a custom kernel image
        * SUBOPTION: kernel-config=config
          Specifiy a custom kernel configuration that is saved in 
        * SUBOPTION: make-multicore=N
          Use multiple cpu cores to build the kernel. N = number of cores.
  * install-kernel
        Install the kernel image and support files to ./images.
  * inject-kernel
        Replace the kernel in the downloaded linaro root fs.
        * SUBOPTION: blackstar
          Use the downloaded blackstar root fs instead of linaro root fs.
  * flash-setup
        Use fastboot to upload os install setup files:
        l-loader.bin, fip.bin, prm_table.bin to hikey960 device.
  * flash-reboot
        Use fastboot to reboot the hikey960 device then wait 15
        seconds while rebooting.
  * flash-os
        Use fastboot to install linaro root and boot partitions
        on the hikey960 device.
        * SUBOPTION: blackstar
          Use the downloaded blackstar root fs instead of linaro root fs.

  * Install tools then download reference images
    host# sudo ./ install-tools download-images download-kernelsource

  * Build the kernel image using custom config and 8 cpu cores.
    host# sudo ./ build-kernel kernel-config=myconfig make-multicore=8

  * Install the kernel locally then inject it into the blackstar root fs image.
    host# sudo ./ install-kernel inject-kernel blackstar

  * Install the root fs and boot images to the hikey960 device.
    host# sudo ./ flash-setup flash-reboot flash-os


@siteks I want to make sure and give credit where it is due. I have added your handle and this thread to the header comment. I am happy to add/modify/omit whatever else is needed. Below is what I have in the header.

# author: mark cass - (
# date: November 19, 2018
# from the work of "siteks" found here:
# create root fs image for hikey 960 to support Hynix (post April 2018) based devices.


@mrkcass Nice work with the script, completely happy with your acknowledgment.


Hi, I tried your steps exactly but I am getting the following error when I try to write the system with fastboot.
error: cannot load ‘repackaged_debian.img’

I was able to make it work with the debian by following your guide in here though.

Also, I have the following questions:
Is there a usb support in the Linaro image?
Is the usb supported in the rootfs image provided by bvermeul?


Hi @seckinsimsek, there is a typo in the first instructions. Please try:
sudo fastboot flash system repacked_debian.img

I’m not really sure what works with the Linaro image, but I’m using a USB ethernet adaptor with @bvermeul’s image for networking and to mount an NFS volume and that works fine.


Hi, I finally managed to make it work, thanks for the guides.
@siteks did you need any additional configuration for USB ethernet adaptor?
Furthermore, how can I test if usb ports are working or not?


Hi, I did this to get a USB ethernet adaptor working on @bvermeul’s image, this assumes you have already got a patched kernel. Obviously you don’t need to do all the steps if you’ve already flashed the bootloader etc, but putting them here for completeness.

# Change the Debian image to have:
#   UFS patched kernel
#   Old style interface names
#   Basic ethernet

cd images
gzip -d boot-linaro-stretch-developer-hikey-20180828-19.img.gz
gzip -d debian-hikey960-public.rootfs.img.gz
sudo fastboot flash ptable prm_ptable.img
sudo fastboot flash fastboot l-loader.bin
sudo fastboot flash fip fip.bin
sudo fastboot reboot-bootloader
sudo fastboot erase boot
sudo fastboot erase system
sudo fastboot erase userdata
sudo fastboot flash boot boot-linaro-stretch-developer-hikey-20180828-19.img

# Unpack and mount original image
simg2img debian-hikey960-public.rootfs.img debian-hikey960-public.rootfs.raw.img
mkdir -p tmp
sudo mount debian-hikey960-public.rootfs.raw.img tmp

# Copy in the patched kernel:
sudo cp ../kernels/Image tmp/boot/

# Make basic ethernet setup
cat << EOF |sudo tee -a tmp/etc/network/interfaces
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp

# Change kernel command line for old-style interface names
sudo sed -i 's/rootwait/rootwait net.ifnames=0/' tmp/boot/grub/grub.cfg

# Repack the image
sudo umount tmp
img2simg debian-hikey960-public.rootfs.raw.img debian-hikey960-public.rootfs.repacked.img

# Flash the new image
sudo fastboot flash system debian-hikey960-public.rootfs.repacked.img
sudo fastboot reboot

One thing to be aware of is that having anything plugged into the USB-C connector disables the USB2 connectors. Since I use the USB-C for flashing, its only when that is unplugged that the kernel switches to USB2 and recognises your ethernet adaptor. This bit of the kernel log shows this happening, then the ethernet becoming available:

[   25.752277] [USB3][hisi_dwc3_wake_lock]usb otg wake lock
[   25.757589] [USB3][handle_event]hisi usb_status: OFF -> HOST
[   25.763252] [USB3][event_work]-
[   26.050807] usb 1-1: new high-speed USB device number 2 using xhci-hcd
[   26.242779] hub 1-1:1.0: USB hub found
[   26.246852] hub 1-1:1.0: 5 ports detected
[   26.334834] usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
[   26.370249] hub 2-1:1.0: USB hub found
[   26.374054] hub 2-1:1.0: 5 ports detected
[   26.566550] usb 1-1.1: new high-speed USB device number 3 using xhci-hcd
[   26.802554] usb 1-1.5: new high-speed USB device number 4 using xhci-hcd
[   27.181365] asix 1-1.1:1.0 eth0: register 'asix' at, ASIX AX88772 USB 2.0 Ethernet, 00:50:b6:12:8b:80
[   27.192835] usbcore: registered new interface driver asix
[   27.279285] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[   44.038054] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   44.048300] asix 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xC5E1

root@hikey960:~# ping
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=1.07 ms
64 bytes from icmp_seq=2 ttl=64 time=1.89 ms
64 bytes from icmp_seq=3 ttl=64 time=1.05 ms


thanks a lot, this works for me. might be worth to mention that the login is root , and not linaro as might be expected. Also, HDMI is not working for me, is there any way to fix it? Also , the partitions of sdd are strange, userdata is allocated with 24GB while root only has 2 GB, any idea why/how to fix? many thanks :slight_smile:


Adding some data, in case it will help someone else. After some struggles to remove sdd partition 11-13 and resize part 10 (only possible with parted since GPT backup is corrupted) and using gdisk to repair to the GPT table backup, I was able to allocatr ~32GB to /dev/sdd10 .I can see it is allocated using fdisk -l , however when using df -h , the actual size available is still only 2 GB… not sure how to fix it


Did resize2fs get run at any point in all these changes?


Thanks , I just ran it and it solved the issue. I actually did run it during the process and it failed, so might be important to note , that only after the GPT table is fixed (and all other steps are performed as described above) it should be used. thanks again


Hi, there is an issue I encountered with this version, I cant connect to any internet network, via wifi or usb adapter , the system does not recognize anything but lo.
This is in nmcli , and in ifconfig.
I tried changing the /etc/network/interfaces file as suggested here:
I tried setting values in the interfaces file and disabling the network-manager service and nothing seems to work. maybe there are missing drivers? any idea? thanks