Mounting /usr file system fails after moving it to SD card

By the way, Step 3 of [1] leads to [2]. Is [2] supposed to be equivalent to [3]? I have tried both to no avail.

[1] Linux Host Installation for HiKey960 - 96Boards
[2] https://github.com/96boards-hikey/tools-images-hikey960
[3] Board Recovery for HiKey960 - 96Boards

Sorry, I think here introduced much confusion.

Firstly, [2] points to the legacy booting images which are delivered by Hisilicon propertied images. I checked again in the official AOSP releasing, so far we still use the legacy booting images.

[3] is equivalent to [2], but [3] uses the open sourced booting images (ARM-TF mainline code + UEFI).

Could you confirm one thing for ‘I have tried both to no avail’? Here your target is to recovery board or you have recoveried board successfully, but failed to move some folders into SD card?

If you want to enlarge the space for rootFS and get more sufficient disk size for your work, I suggest you to use the ‘data’ partition to flash the debian rootFS, and in the kernel command line you can specify to mount the ‘data’ partition as the root device. I am not sure this info is useful, maybe it’s irrelevant.

If [3] is preferred over [2], I’d suggest to update Step 3 of [1] to link to [3] instead of [2]. (Only clarify “Now move to the Hikey960 console and press f during UEFI boot.”)

Could you confirm one thing for ‘I have tried both to no avail’? Here your target is to recovery board or you have recoveried board successfully, but failed to move some folders into SD card?

I’ve performed steps in [2] and [3], but this hasn’t helped me to solve the kernel panic issue. (Therefore, I think the board’s firmware was in a good state even before I performed [2] and [3].) To confirm, I see (via USB serial) the GRUB menu, but no matter whether I accept the default or select the recovery mode, the board ends up with a kernel panic after 5 seconds, and hangs. I thought that reflashing either boot or rootfs would help restore the deleted /usr mount point, but the issue is still present… That’s why I tried to erase and even format boot and rootfs, but there’s something I’m missing…

I would expect that overwriting the rootfs should fix the damaged rootfs, so my guess is that rootfs may be in a different location than you are thinking.

Since you have access to grub, why don’t you set up an sdcard with all relevant partitions and boot that? Then you will be able to mount the damaged rootfs and repair it.

I like this idea, but I’m not that experienced with grub, so not sure how to do it. Any links?

I could give you any number of links to grub syntax. You really should hit google for this one, there is no shortage of resources for this.

For example; GRUB 2 bootloader - Full tutorial

1 Like

From the log, you could see the root file system is using /dev/sdd13.

If we review the the ptable [1], the command ‘sudo fastboot flash system rootfs-linaro-stretch-developer-hikey-20190620-32.img’ will flash rootFS into /dev/sdd10, but actually you are using /dev/sdd13 to mount root fs.

[1] https://github.com/96boards-hikey/l-loader/blob/testing/hikey960_v1.2/generate_ptable.sh#L141

@doitright Much appreciated. I probably misinterpreted your advice, as I somehow thought that I would be able to mount /usr from the SD card during the boot time (where I had a copy). Hence my difficulty in finding specific advice on how to edit the GRUB boot command with respect to mounting.

I believe my other board runs entirely from the SD card, so I can indeed try that.

@leo-yan Good catch. I would be curious to know how I managed to arrive at this predicament. But right now I’m simply eager to make the board usable again.

I guess the easiest would be to flash rootFS onto /dev/sdd13. How can I achieve that? Would perhaps the following:

$ sudo fastboot flash userdata rootfs-linaro-stretch-developer-hikey-20190620-32.img

flash rootFS onto /dev/sdd13?

Ideally, I would like to erase everything on the board and run a sequence of recovery/flash commands to put everything in a consistent state again.

The reason I mentioned userdata because I found it here [1]. However, it’s AOSP specific, while I’m trying to install Linux?

[1] https://github.com/96boards-hikey/l-loader/blob/testing/hikey960_v1.2/generate_ptable.sh#L148

If you want to just start over, you could run the uefi-flash-all.sh from AOSP. That would at least reset everything to a clean slate where you can begin again.

If you want to just start over, you could run the uefi-flash-all.sh from AOSP.

Thanks @doitright. I assume that installing Linux immediately after that should work?

I can see flash-all.sh mentioned in Step 5 of [1]. Is it the same? Unfortunately, I cannot find it in [2]?

[1] Linux Host Installation for HiKey960 - 96Boards
[2] https://snapshots.linaro.org/96boards/hikey960/linaro/aosp-master/latest/

I don’t know anything about how the snapshots are organized. The uefi version installs open source bootloaders instead of the blobs.

https://android.googlesource.com/device/linaro/hikey/+/refs/heads/master/installer/hikey960/

Thanks @doitright. I had to modify uefi-flash-all.sh [1] as it uses variables ANDROID_BUILD_TOP and ANDROID_PRODUCT_OUT, and various build products that I don’t have e.g.:

#	fastboot flash boot "${ANDROID_PRODUCT_OUT}"/boot.img
#	fastboot flash system "${ANDROID_PRODUCT_OUT}"/system.img
#	fastboot flash vendor "${ANDROID_PRODUCT_OUT}"/vendor.img
#	fastboot flash cache "${ANDROID_PRODUCT_OUT}"/cache.img
#	fastboot flash userdata "${ANDROID_PRODUCT_OUT}"/userdata.img

Unfortunately, flashing the Linux rootFS after that didn’t work. (I think that system is perhaps different for AOSP and Linux.)

Right now I am just wondering if there is a way to reformat the whole internal flash, and then start with the Linux instructions from scratch.

[1] installer/hikey960/uefi-flash-all.sh - device/linaro/hikey - Git at Google

That’s what I was suggesting that you do. Flash all of AOSP to bring it to a clean working state running Android. You then follow the procedure to I stall debian.

@doitright I must be thick, or something, but how can I get the files under "${ANDROID_PRODUCT_OUT}": boot.img, system.img, vendor.img, cache.img, userdata.img. As I mentioned, trying to flash without them, didn’t work for me.

You really have two options: either build AOSP, or supply the files from some other location, perhaps a snapshot, and edit the script to their path.

OK, I will try to download them from here: https://snapshots.linaro.org/96boards/hikey960/linaro/aosp-master/latest/:

However, cache.img is not there. Maybe an empty file will do?..

Or should I try flash-all.sh which doesn’t need cache.img but also needs dt.img:

Cache can probably be left out. It basically just formats the partition ext4.

1 Like

@doitright This has nearly worked! I mean, I was able to boot the board again. Unfortunately, it wouldn’t work properly with an SD card inserted. But I’ll track that issue separately. Many thanks for your help again!

[1] Hikey 960 UEFI boot hangs when SD card present - #3 by psyhtest