I am working on adding code for the Clearfog board, and wanted to use a reserved partition in my setup as a placeholder foru-boot (which is optional, because it may be on SPI flash, or emmc boot0).
So this is what happens after adding disk_reserved_create 1m to clearfog_partition_image
Starting at Sun May 13 15:12:56 UTC 2018
Loading configuration from config.sh
Board: Clearfog
Option: ImageSize 1950mb
Option: Growfs
Option: User freebsd
Source version is: 333575
Building FreeBSD version: 12.0
Image name is:
/opt/work/build/FreeBSD-armv6-12.0-ARMADA38X-333575-Clearfog.img
Building FreeBSD version: 12.0
Object files are at: /opt/work/build/obj/opt/work/src
Found suitable FreeBSD source tree in:
/opt/work/src
Using FreeBSD armv6 world from previous build
Using FreeBSD armv6-ARMADA38X kernel from previous build
Using ubldr from previous build
Creating a 1950MB raw disk image in:
/opt/work/build/FreeBSD-armv6-12.0-ARMADA38X-333575-Clearfog.img
Partitioning the raw disk image with MBR at Sun May 13 15:13:01 UTC 2018
gpart create -s MBR md11
md11 created
Creating reserve partition at Sun May 13 15:13:01 UTC 2018 of size 1m
Creating a 2m FAT partition at Sun May 13 15:13:01 UTC 2018 with start block 63 and label BOOT
active set on md11s2
Default to FAT12 for partition size 2m
Creating an auto-sized UFS partition at Sun May 13 15:13:01 UTC 2018
md11s3 created
/dev/md11s3a: 1855.9MB (3800960 sectors) block size 32768, fragment size 4096
using 4 cylinder groups of 464.00MB, 14848 blks, 59392 inodes.
super-block backups (for fsck_ffs -b #) at:
192, 950464, 1900736, 2851008
tunefs: soft updates set
Using inode 4 in cg 0 for 4194304 byte journal
tunefs: soft updates journaling set
tunefs: NFSv4 ACLs set
Labeling /dev/md11s3a rootfs
Mounting all file systems:
Attempt to mount partition at 1 failed.
Do not know how to mount partitions of type .
This error message is really not meaningful. It turns out that lib/disk.sh:disk_mount gets called without the first argument, MOUNTPOINT.
I traced the invocation to lib/board.sh:board_mount_all
disk_mount `board_mountpoint ${ABSINDEX}` ${ABSINDEX}
Turns out that board_mountpoint does not have a mountpoint for a reserved partition.
Was I expected to set one in my board/Clearfog/setup.sh file? I don't think that would be intuitive.
So as a first hack I changed lib/board.sh:board_mountpoint:
@@ -251,6 +251,8 @@ board_mountpoint ( ) {
MOUNTPOINT_PREFIX=${BOARD_BOOT_MOUNTPOINT_PREFIX}
elif board_is_freebsd_partition ${ABSINDEX}; then
MOUNTPOINT_PREFIX=${BOARD_FREEBSD_MOUNTPOINT_PREFIX}
+ elif [ $TYPE == "RESERVED" ]; then
+ MOUNTPOINT_PREFIX=/dev/null
else
MOUNTPOINT_PREFIX=`eval echo \\$BOARD_${TYPE}_MOUNTPOINT_PREFIX`
fi
The rationale here is that we need a non-empty return value, but it should not ever break anything, worst-case being an error message. So I picked /dev/null/ for now, a folder which cannot exist because a file is there.
This gets me a little further:
Starting at Sun May 13 15:21:25 UTC 2018
Loading configuration from config.sh
Board: Clearfog
Option: ImageSize 1950mb
Option: Growfs
Option: User freebsd
Source version is: 333575
Building FreeBSD version: 12.0
Image name is:
/opt/work/build/FreeBSD-armv6-12.0-ARMADA38X-333575-Clearfog.img
Building FreeBSD version: 12.0
Object files are at: /opt/work/build/obj/opt/work/src
Found suitable FreeBSD source tree in:
/opt/work/src
Using FreeBSD armv6 world from previous build
Using FreeBSD armv6-ARMADA38X kernel from previous build
Using ubldr from previous build
Creating a 1950MB raw disk image in:
/opt/work/build/FreeBSD-armv6-12.0-ARMADA38X-333575-Clearfog.img
Partitioning the raw disk image with MBR at Sun May 13 15:21:30 UTC 2018
gpart create -s MBR md12
md12 created
Creating reserve partition at Sun May 13 15:21:30 UTC 2018 of size 1m
Creating a 2m FAT partition at Sun May 13 15:21:30 UTC 2018 with start block 63 and label BOOT
active set on md12s2
Default to FAT12 for partition size 2m
Creating an auto-sized UFS partition at Sun May 13 15:21:30 UTC 2018
md12s3 created
/dev/md12s3a: 1855.9MB (3800960 sectors) block size 32768, fragment size 4096
using 4 cylinder groups of 464.00MB, 14848 blks, 59392 inodes.
super-block backups (for fsck_ffs -b #) at:
192, 950464, 1900736, 2851008
tunefs: soft updates set
Using inode 4 in cg 0 for 4194304 byte journal
tunefs: soft updates journaling set
tunefs: NFSv4 ACLs set
Labeling /dev/md12s3a rootfs
Mounting all file systems:
Attempt to mount RESERVED partition 1 at /dev/null failed.
Do not know how to mount partitions of type RESERVED.
Okay, so we want to mount a reserved partition, but obviously the filesystem is unknown and may not even exist. This should not be a problem. How about not trying to mount reserved partitions?
I racked it to lib/disk.sh:disk_mount and added this hack:
@@ -460,6 +462,9 @@ disk_mount ( ) {
UFS)
disk_ufs_mount ${MOUNTPOINT} ${RELINDEX}
;;
+ RESERVED)
+ # just don't do anything
+ ;;
*)
echo "Attempt to mount ${TYPE} partition ${RELINDEX} at ${MOUNTPOINT} failed."
echo "Do not know how to mount partitions of type ${TYPE}."
Maybe this case should instead be captured in lib/board.sh:board_mount_all?
I hope all this information helps you to come up with a good way to solve this.
Here is the final log, where things work as expected:
Starting at Sun May 13 15:22:20 UTC 2018
Loading configuration from config.sh
Board: Clearfog
Option: ImageSize 1950mb
Option: Growfs
Option: User freebsd
Source version is: 333575
Building FreeBSD version: 12.0
Image name is:
/opt/work/build/FreeBSD-armv6-12.0-ARMADA38X-333575-Clearfog.img
Building FreeBSD version: 12.0
Object files are at: /opt/work/build/obj/opt/work/src
Found suitable FreeBSD source tree in:
/opt/work/src
Using FreeBSD armv6 world from previous build
Using FreeBSD armv6-ARMADA38X kernel from previous build
Using ubldr from previous build
Creating a 1950MB raw disk image in:
/opt/work/build/FreeBSD-armv6-12.0-ARMADA38X-333575-Clearfog.img
Partitioning the raw disk image with MBR at Sun May 13 15:22:25 UTC 2018
gpart create -s MBR md13
md13 created
Creating reserve partition at Sun May 13 15:22:25 UTC 2018 of size 1m
Creating a 2m FAT partition at Sun May 13 15:22:25 UTC 2018 with start block 63 and label BOOT
active set on md13s2
Default to FAT12 for partition size 2m
Creating an auto-sized UFS partition at Sun May 13 15:22:25 UTC 2018
md13s3 created
/dev/md13s3a: 1855.9MB (3800960 sectors) block size 32768, fragment size 4096
using 4 cylinder groups of 464.00MB, 14848 blks, 59392 inodes.
super-block backups (for fsck_ffs -b #) at:
192, 950464, 1900736, 2851008
tunefs: soft updates set
Using inode 4 in cg 0 for 4194304 byte journal
tunefs: soft updates journaling set
tunefs: NFSv4 ACLs set
Labeling /dev/md13s3a rootfs
Mounting all file systems:
Mounting FAT partition 1 at /opt/work/build/_.mount.boot
Mounting UFS partition 1 at /opt/work/build/_.mount.freebsd
Installing ubldr in /opt/work/build/_.mount.boot
Installing FreeBSD world at Sun May 13 15:22:29 UTC 2018
Destination: /opt/work/build/_.mount.freebsd
Overlaying board-specific files from /opt/work/crochet/board/Clearfog/overlay
2 blocks
Installing FreeBSD kernel at Sun May 13 15:24:11 UTC 2018
Destination: /opt/work/build/_.mount.freebsd
Adding user freebsd with password freebsd
Unmounting /opt/work/build/_.mount.boot
Unmounting /opt/work/build/_.mount.freebsd
Releasing md13
DONE.
Completed disk image is in: /opt/work/build/FreeBSD-armv6-12.0-ARMADA38X-333575-Clearfog.img
Copy to a suitable memory card using a command such as:
dd if=/opt/work/build/FreeBSD-armv6-12.0-ARMADA38X-333575-Clearfog.img of=/dev/da0 bs=1m
(Replace /dev/da0 with the appropriate path for your card reader.)
Finished at Sun May 13 15:24:22 UTC 2018
I am working on adding code for the Clearfog board, and wanted to use a reserved partition in my setup as a placeholder foru-boot (which is optional, because it may be on SPI flash, or emmc boot0).
So this is what happens after adding disk_reserved_create 1m to clearfog_partition_image
This error message is really not meaningful. It turns out that lib/disk.sh:disk_mount gets called without the first argument, MOUNTPOINT. I traced the invocation to lib/board.sh:board_mount_all
disk_mount `board_mountpoint ${ABSINDEX}` ${ABSINDEX}
Turns out that board_mountpoint does not have a mountpoint for a reserved partition. Was I expected to set one in my board/Clearfog/setup.sh file? I don't think that would be intuitive. So as a first hack I changed lib/board.sh:board_mountpoint:
The rationale here is that we need a non-empty return value, but it should not ever break anything, worst-case being an error message. So I picked /dev/null/ for now, a folder which cannot exist because a file is there. This gets me a little further:
Okay, so we want to mount a reserved partition, but obviously the filesystem is unknown and may not even exist. This should not be a problem. How about not trying to mount reserved partitions? I racked it to lib/disk.sh:disk_mount and added this hack:
Maybe this case should instead be captured in lib/board.sh:board_mount_all?
I hope all this information helps you to come up with a good way to solve this.
Here is the final log, where things work as expected: