Skip to content

create-recore-config fails to provision config on eMMC boot partition #85

Description

@eliasbakken

On a fresh Recore A8, sudo get-recore-serial-number prints nothing (exits 1) because
create-recore-config never creates the ext4 config image, so mount-config has nothing
to mount and set -e aborts before the cat.

Env: Recore A8, kernel 6.12.69-current-sunxi64, e2fsprogs 1.47.2.

Two bugs in create-recore-config

  1. Formats a nonexistent partition node. It runs mkfs.ext4 /dev/${DEV}boot0p1, but
    the kernel doesn't create child partition nodes for eMMC boot partitions —
    /dev/mmcblk2boot0p1 never exists, so mkfs is skipped:

    mke2fs ... The file /dev/mmcblk2boot0p1 does not exist and no size was specified.
    

    mount-config doesn't use a partition node anyway — it loop-mounts the raw device at
    offset=17408. The fs must be created at that offset, not on a ...p1 partition.

  2. metadata_csum breaks reads. Once the fs is created at offset 17408, reads fail:

    cat: serial_number: Bad message
    EXT4-fs: ext4_dirblock_csum_verify: No space for directory leaf checksum
    

    The fs is tiny → 1K block size, and metadata_csum (default-on in e2fsprogs 1.47)
    leaves no room for the dir-leaf checksum at 1K blocks on this kernel.

Also: the create path writes via mount-config, which mounts read-only, so the
echo > serial_number would fail even with a valid fs.

Workaround (works)

  echo 0 | sudo tee /sys/block/mmcblk2boot0/force_ro
  LOOP=$(sudo losetup -f --show -o 17408 /dev/mmcblk2boot0)
  sudo mkfs.ext4 -F -q -O ^metadata_csum,^64bit -E nodiscard "$LOOP"
  sudo mount "$LOOP" /mnt/config
  printf '0481\n' | sudo tee /mnt/config/serial_number
  sudo wget -O /mnt/config/calibration.json \
    https://raw.githubusercontent.com/intelligent-agent/Recore/master/Calibrations/Recore_A8_0481/calibration.json
  sync; sudo umount /mnt/config; sudo losetup -d "$LOOP"
  echo 1 | sudo tee /sys/block/mmcblk2boot0/force_ro

Suggested fix

Create the fs directly at offset 17408 via a loop device (drop fdisk/...boot0p1), pass
-O ^metadata_csum, and use a read-write mount in the create path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions