How to get Debian working

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:

Success!!!

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:
  hk960os.sh  version: 0.1
 
DESCRIPTION:
  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.

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 
          ./linux/arch/arm
        * 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.

EXAMPLES:
  * Install tools then download reference images
    host# sudo ./hk960os.sh install-tools download-images download-kernelsource

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

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

  * Install the root fs and boot images to the hikey960 device.
    host# sudo ./hk960os.sh 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 - mechanizedai.com (https://mechanizedai.com)
# date: November 19, 2018
#
#
# from the work of "siteks" found here: https://discuss.96boards.org/t/how-to-get-debian-working/6469/4
#
#
# 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
wget http://snapshots.linaro.org/96boards/reference-platform/components/uefi-staging/latest/hikey960/debug/l-loader.bin
wget http://snapshots.linaro.org/96boards/reference-platform/components/uefi-staging/latest/hikey960/debug/fip.bin
wget http://snapshots.linaro.org/96boards/reference-platform/components/uefi-staging/latest/hikey960/debug/prm_ptable.img
wget http://snapshots.linaro.org/96boards/hikey/linaro/debian/latest/boot-linaro-stretch-developer-hikey-20180828-19.img.gz
wget http://blackstar.xs4all.nl/debian-hikey960-public.rootfs.img.gz
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
EOF

# 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 usb-xhci-hcd.1.auto-1.1, 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 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=1.07 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=1.89 ms
64 bytes from 192.168.0.1: 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: network manager says "device not managed" - Ask Ubuntu
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

Hi,

Are you using the Linaro rootfs image or the proper Debian one from here: http://blackstar.xs4all.nl/debian-hikey960-public.rootfs.img.gz? The Linaro one was built for the old Hikey board, not the Hikey960, so it doesn’t support the Hikey960 peripherals properly, since (I think) the device tree and modules are wrong.

Try the steps in this message: How to get Debian working - #15 by siteks

If that doesn’t work, post the output of dmesg.

Yes , that is probably the reason - thank you. I used the rootfs from linaro, because when using the rootfs from blackstar I get a small root (2GB) and even if I add space by deleting other partitions I am unable to add it to root (SInce root is mapped to / and not to /dev/sdd10 as was the case in linaro’s rootfs)

@Omer_Schleifer @siteks

Sorry for the trouble! I’m in the process of building a debian release image based on 4.19.5 kernel for all hikey boards (Hikey+Hikey960+Hikey970). Below are the supported features of the image:

  1. Hikey - SD/MMC, HDMI, USB, WiFi/BT
  2. Hikey960 - UFS, SD/MMC, USB, WiFi/BT, PCI-E, UFS Fix
  3. HiKey970 - UFS, SD/MMC

Please stay tuned.

Regards,
Mani

Ah yes.

I changed the grub command line to point to /dev/sdd13 and burned to userdata.
Re. the HDMI, the hardware cannot generate correct clocks for many modes, if you force a working mode in the kernel command line you can get it working. I’m not using a monitor, but just tried these new instructions and it does now output to HDMI and display on two monitors I tried.

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

# 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
EOF

# Change kernel command line for old-style interface names and a working HDMI mode
sudo sed -i 's/rootwait/rootwait net.ifnames=0 video=HDMI-A-1:1280x800@60/' tmp/boot/grub/grub.cfg

# Change root partition
sudo sed -i 's/sdd10/sdd13/' 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 erase system
sudo fastboot erase userdata
sudo fastboot flash userdata debian-hikey960-public.rootfs.repacked.img
sudo fastboot reboot

I then resized the file system at the root prompt, strange error first time even with force:

root@hikey960:~# df
Filesystem     1K-blocks   Used Available Use% Mounted on
/dev/root        2064208 913192   1046160  47% /
devtmpfs         1983760      0   1983760   0% /dev
tmpfs            1992528      0   1992528   0% /dev/shm
tmpfs            1992528  29064   1963464   2% /run
tmpfs               5120      0      5120   0% /run/lock
tmpfs            1992528      0   1992528   0% /sys/fs/cgroup
tmpfs             398504      0    398504   0% /run/user/0
root@hikey960:~# lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda       8:0    0    4M  0 disk
sdb       8:16   0    4M  0 disk
sdc       8:32   0    8M  0 disk
└─sdc1    8:33   0    7M  0 part
sdd       8:48   0 29.8G  0 disk
├─sdd1    8:49   0    1M  0 part
├─sdd2    8:50   0   12M  0 part
├─sdd3    8:51   0    6M  0 part
├─sdd4    8:52   0   12M  0 part
├─sdd5    8:53   0  256M  0 part
├─sdd6    8:54   0    1M  0 part
├─sdd7    8:55   0   64M  0 part
├─sdd8    8:56   0   16M  0 part
├─sdd9    8:57   0    2M  0 part
├─sdd10   8:58   0  4.6G  0 part
├─sdd11   8:59   0  784M  0 part
├─sdd12   8:60   0    1M  0 part
└─sdd13   8:61   0 24.1G  0 part /
root@hikey960:~# resize2fs -f /dev/sdd13 24G
resize2fs 1.43.4 (31-Jan-2017)
Filesystem at /dev/sdd13 is mounted on /; on-line re[   64.705471] EXT4-fs (sdd13): resizing filesystem from 524288 to 6291456 blocks
sizing required
old_desc_blocks = 1, ne[   64.718563] EXT4-fs (sdd13): resized filesystem to 6291456
w_desc_blocks = 2
resize2fs: Remote I/O error While checking for on-line resizing support
root@hikey960:~# resize2fs -f /dev/sdd13 24G
resize2fs 1.43.4 (31-Jan-2017)
Filesystem at /dev/sdd13 is mounted on /; on-line resizing[   77.673999] EXT4-fs (sdd13): resizing filesystem from 524288 to 6291456 blocks
 required
old_desc_blocks = 1, new_desc_blocks = 2
[   80.487587] EXT4-fs (sdd13): resized filesystem to 6291456
The filesystem on /dev/sdd13 is now 6291456 (4k) blocks long.

root@hikey960:~# df
Filesystem     1K-blocks   Used Available Use% Mounted on
/dev/root       24770940 915692  22828152   4% /
devtmpfs         1983760      0   1983760   0% /dev
tmpfs            1992528      0   1992528   0% /dev/shm
tmpfs            1992528  29064   1963464   2% /run
tmpfs               5120      0      5120   0% /run/lock
tmpfs            1992528      0   1992528   0% /sys/fs/cgroup
tmpfs             398504      0    398504   0% /run/user/0

thanks so much. I’m trying to run as you suggested, but get an error while flashing rootfs to userdata:

target reported max download size of 134217728 bytes
erasing 'userdata'...
FAILED (remote: Check device console.)
finished. total time: 0.001s

You’ve changed the partition map though, so you’ll need to reflash (I presume) ptable to get the original map back. I suggest:

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

first, before flashing the rootfs to userdata.