Fix create-recore-config to actually provision the eMMC config - #98
Merged
Conversation
Three bugs, all reported in #85: 1. Formatted a nonexistent partition node - mkfs.ext4 targeted /dev/mmcblk2boot0p1, but the kernel doesn't create child partition nodes for eMMC boot partitions. mount-config and every other reader loop-mount the raw device directly at offset 17408 instead - the filesystem now gets created the same way, via a loop device at that offset, not via fdisk/a partition node that never existed. 2. metadata_csum (default-on in e2fsprogs 1.47) left no room for the dir-leaf checksum once the filesystem picked a 1K block size at this tiny size, so reads failed with "Bad message". Disabled via -O ^metadata_csum,^64bit. 3. The create path wrote through mount-config, which always mounts read-only (it's meant for readers) - the echo > serial_number would fail even with a valid filesystem. The create path now mounts the loop device directly, read-write, instead. Also fixed a related bug in get-recore-serial-number: it called plain umount instead of unmount-config to tear down the transient mount mount-config sets up via systemd-mount. Plain umount unmounts the filesystem but doesn't deregister the transient systemd unit, so a later mount-config call can fail with "Unit mnt-config.mount was already loaded". Live-tested on real hardware: extracted and backed up the board's existing (already-provisioned) config partition first, ran the fixed create-recore-config against the same serial, and confirmed get-recore-revision/get-recore-serial-number both work and the downloaded calibration.json is byte-identical to the original. Closes #85
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three bugs, all reported in #85:
mkfs.ext4targeted/dev/mmcblk2boot0p1, but the kernel doesn't create child partition nodes for eMMC boot partitions.mount-configand every other reader loop-mount the raw device directly at offset 17408 - the filesystem is now created the same way, via a loop device at that offset, not via fdisk/a partition node that never existed.metadata_csum(default-on in e2fsprogs 1.47) left no room for the dir-leaf checksum once the filesystem picked a 1K block size at this tiny size, so reads failed withBad message. Disabled via-O ^metadata_csum,^64bit.mount-config, which always mounts read-only (it's meant for readers). Now mounts the loop device directly, read-write, for the create path only.Also fixed a related bug in
get-recore-serial-number: it called plainumountinstead ofunmount-configto tear down the transient mountmount-configsets up viasystemd-mount. Plainumountunmounts the filesystem but doesn't deregister the transient systemd unit, so a latermount-configcall can fail withUnit mnt-config.mount was already loaded.Testing
make test-bats- all 13 pass (updated the existingget-recore-serial-numbertest to stubunmount-configinstead ofumount, matching the fix).go test ./...- no regressions.create-recore-configagainst the same serial number, and confirmedget-recore-revision/get-recore-serial-numberboth work and the downloadedcalibration.jsonis byte-identical to the original.Closes #85