Boot Hikey970 with f2fs userdata partition using Android 9 and above with system-on-root feature

Hello,

I am using the following branch to build the images for hikey970.

https://android.googlesource.com/platform/manifest/+/master

In order to comply with the system-on-root feature, I modified the following line in build_kernel.sh script:

${MKBOOTTOOL_DIR}/mkbootimg --kernel ${HIKEY970_KERNEL}/Image-dtb --ramdisk ${RAMDISK} --cmdline "androidboot.hardware=hikey970 firmware_class.path=/system/etc/firmware loglevel=15 buildvariant=userdebug androidboot.selinux=permissive clk_ignore_unused=true" --base 0x0 --tags_offset 0x07A00000 --kernel_offset 0x00080000 --ramdisk_offset 0x07c00000 --os_version 7.0 --os_patch_level 2016-08-05 --output ${PRODUCT_OUT}/boot.img

by

${MKBOOTTOOL_DIR}/mkbootimg.py --kernel ${HIKEY970_KERNEL}/Image-dtb --ramdisk ${RAMDISK} --cmdline "androidboot.hardware=hikey970 firmware_class.path=/system/etc/firmware loglevel=15 buildvariant=userdebug androidboot.selinux=permissive clk_ignore_unused=true root=/dev/sdd12 rootwait skip_initramfs init=/init" --base 0x0 --tags_offset 0x07A00000 --kernel_offset 0x00080000 --ramdisk_offset 0x07c00000 --os_version 9.0 --os_patch_level 2016-08-05 --output ${PRODUCT_OUT}/boot.img

Ref:

In order to boot the userdata partition using f2fs, I carried out the following steps:

1. Enabled the f2fs configs in the kernel

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_CHECK_FS=y
CONFIG_F2FS_FS_ENCRYPTION=y
CONFIG_F2FS_IO_TRACE=y
CONFIG_F2FS_FAULT_INJECTION=y

2. Modified the default fstab to the following

# Android fstab file.
#<src>                                                  <mnt_point>         <type>    <mnt_flags and options>                               <fs_mgr_flags>
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK

#/dev/block/platform/soc/ff3b0000.ufs/by-name/system_a    /system    ext4    ro                                                                   wait
/dev/block/sdd12    /system    ext4    ro                                                                   wait
#/dev/block/platform/soc/ff3b0000.ufs/by-name/cache       /cache     ext4    discard,noauto_da_alloc,data=ordered,user_xattr,discard,barrier=1    wait
/dev/block/sdd5     /cache     ext4    discard,noauto_da_alloc,data=ordered,user_xattr,discard,barrier=1    wait
#/dev/block/platform/soc/ff3b0000.ufs/by-name/userdata    /data      ext4    discard,noauto_da_alloc,data=ordered,user_xattr,discard,barrier=1    wait
/dev/block/sdd15    /data      f2fs    discard,noatime,nosuid,nodev    wait,check,fileencryption=software,quota
/dev/block/sdd15    /data      ext4    discard,noauto_da_alloc,data=ordered,user_xattr,discard,barrier=1    wait
/devices/platform/soc/ff37f000.dwmmc1/mmc_host/mmc*      auto       auto    defaults    voldmanaged=sdcard1:auto,encryptable=userdata
/devices/platform/soc/soc:hisi_dwc3/ff100000.dwc3/xhci-hcd.*.auto/usb*               auto               auto      defaults  voldmanaged=usbdisk:auto,encryptable=userdata
hikey970:/ # 

3. Built the AOSP using the following command

make -j$(nproc) BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE=f2fs TARGET_USERIMAGES_USE_F2FS=true

It is observed that after booting, the /data partition is not mounted:

nand@nand:/mnt/storage2/ArunJTS/ticket_5055/pie-dr1/out/target/product/hikey970$ adb shell
hikey970:/ $ df -h
Filesystem       Size  Used Avail Use% Mounted on
/dev/root        4.5G  1.2G  3.2G  29% /
tmpfs            2.8G  356K  2.8G   1% /dev
tmpfs            2.8G     0  2.8G   0% /mnt
tmpfs            2.8G     0  2.8G   0% /apex
/dev/block/sdd5  232M  176K  224M   1% /cache
/dev/block/loop0 856K  840K     0 100% /apex/com.android.tzdata@31000010
/dev/block/loop1 4.4M  4.4M     0 100% /apex/com.android.conscrypt@1
/dev/block/loop2 2.7M  2.7M     0 100% /apex/com.android.resolv@1
/dev/block/loop3  76M   74M  912K  99% /apex/com.android.runtime@1

The /dev/block/sdd15 does show up however attempts to manually mount it also fail:

nand@nand:/mnt/storage2/ArunJTS/ticket_5055/pie-dr1/out/target/product/hikey970$ adb root
nand@nand:/mnt/storage2/ArunJTS/ticket_5055/pie-dr1/out/target/product/hikey970$ adb shell
hikey970:/ # su
hikey970:/ # df -h
Filesystem       Size  Used Avail Use% Mounted on
/dev/root        4.5G  1.2G  3.2G  29% /
tmpfs            2.8G  356K  2.8G   1% /dev
tmpfs            2.8G     0  2.8G   0% /mnt
tmpfs            2.8G     0  2.8G   0% /apex
/dev/block/sdd5  232M  176K  232M   1% /cache
/dev/block/loop0 856K  840K   16K  99% /apex/com.android.tzdata@31000010
/dev/block/loop1 4.4M  4.4M  8.0K 100% /apex/com.android.conscrypt@1
/dev/block/loop2 2.7M  2.7M   12K 100% /apex/com.android.resolv@1
/dev/block/loop3  76M   74M  2.4M  97% /apex/com.android.runtime@1
hikey970:/ # su
hikey970:/ # mount -t f2fs /dev/block/sdd                                      
sdd    sdd10  sdd12  sdd14  sdd2   sdd4   sdd6   sdd8
sdd1   sdd11  sdd13  sdd15  sdd3   sdd5   sdd7   sdd9
hikey970:/ # mount -t f2fs /dev/block/sdd15 data/                              
mount: '/dev/block/sdd15'->'data/': No such device
1|hikey970:/ # mount -t f2fs /dev/block/sdd15 /data                            
mount: '/dev/block/sdd15'->'/data': No such device
1|hikey970:/ # su
hikey970:/ # mount -t f2fs /dev/block/sdd15 /data/                             
mount: '/dev/block/sdd15'->'/data/': No such device
1|hikey970:/ # 

The changes made to fstab.hikey970 are reflected on the on-board fstab.hikey970 file:

hikey970:/ # cat fstab.hikey970                                              

# Android fstab file.
#<src>                                                  <mnt_point>         <type>    <mnt_flags and options>                               <fs_mgr_flags>
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK

#/dev/block/platform/soc/ff3b0000.ufs/by-name/system_a    /system    ext4    ro                                                                   wait
/dev/block/sdd12    /system    ext4    ro                                                                   wait
#/dev/block/platform/soc/ff3b0000.ufs/by-name/cache       /cache     ext4    discard,noauto_da_alloc,data=ordered,user_xattr,discard,barrier=1    wait
/dev/block/sdd5     /cache     ext4    discard,noauto_da_alloc,data=ordered,user_xattr,discard,barrier=1    wait
#/dev/block/platform/soc/ff3b0000.ufs/by-name/userdata    /data      ext4    discard,noauto_da_alloc,data=ordered,user_xattr,discard,barrier=1    wait
/dev/block/sdd15    /data      f2fs    discard,noatime,nosuid,nodev    wait,check,fileencryption=software,quota
/dev/block/sdd15    /data      ext4    discard,noauto_da_alloc,data=ordered,user_xattr,discard,barrier=1    wait
/devices/platform/soc/ff37f000.dwmmc1/mmc_host/mmc*      auto       auto    defaults    voldmanaged=sdcard1:auto,encryptable=userdata
/devices/platform/soc/soc:hisi_dwc3/ff100000.dwc3/xhci-hcd.*.auto/usb*               auto               auto      defaults  voldmanaged=usbdisk:auto,encryptable=userdata
hikey970:/ # 

Why does the f2fs partition not mount ?

Thank you for your time,

Regards,
Nishad

Hello Nishad,

I have encountered the same issue but with ext4 fs. So, not sure this will solve your issue with f2fs but it worth trying :slight_smile:

To allow the userdata to be mounted, I did the following:

  • reboot in fastboot mode: adb reboot bootloader
  • fastboot format userdata
  • fastboot reboot

Best regards,

According this topic How can I create partition table for Hikey970
It looks like regenerating the partition table solves the issue also.

BR,

Hello Charly-D

Thanks very much for the pointers.

On trying to format the userdata partition, I found that the userdata partition does get mounted, but it gets mounted as an ext4 file system.

After trying to generate the ptable, similar error is seen. The data partition does not get mounted.

Thanks again,
Nishad

Hi,

The issue has been resolved. I had missed to comment the

#make hikey970_defconfig && \

in the build_kernel.sh script which is why the F2FS configs which I had enabled weren’t actually enabled in the config.

The board now successfully boots with f2fs data partition with the above procedure.

Thanks and regards,
Nishad

Hi Nishad,

Good news! Thank you for the update.

BR,