Start to split apart the different image formats that we need to

make. Add support for generating powerpc64 qemu images. We
can generate them, but there's something wrong booting them.
This also simplifies the user config files a bit, and removes
bits no longer true.
This commit is contained in:
Warner Losh 2015-12-07 10:24:40 +00:00
parent 0a85283010
commit 85154c415c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=291930
13 changed files with 185 additions and 154 deletions

View File

@ -25,12 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# This file is heavily derived from both Sam Leffler's Avilia config,
# as well as the BSDRP project's config file. Neither of these have
# an explicit copyright/license statement, but are implicitly BSDL. This
# example has been taken from the FreeNAS project and simplified to meet
# the needs of the example.
#
NANO_ARCH=armv6
NANO_KERNEL=BEAGLEBONE

View File

@ -73,26 +73,6 @@ if [ -z $NANO_NAME ]; then
echo "NANO_NAME not defined. Use foo.cfg instead."
fi
# Slice 1: FAT for ROM loading bootstrap
# Slice 2: Config partition
# Slice 3: FreeBSD partition (sized exactly)
# Slice 4: FreeBSD partition (empty)
# on first boot, we resize slice 3 & 4 to be 1/2 of what's
# left over on the SD card after slice 1 and 2 are taken
# off the top. We also resize the 'a' partion on first boot
# to the size of the partition for the ping/pong upgrade.
if [ -z "$EMBED_OMIT_FAT" ]; then
NANO_SLICE_FAT=s1
NANO_SLICE_CFG=s2
NANO_SLICE_ROOT=s3
NANO_SLICE_ALTROOT=s4
else
NANO_SLICE_CFG=s1
NANO_SLICE_ROOT=s2
NANO_SLICE_ALTROOT=s3
fi
NANO_SLICE_DATA= # Not included
NANO_SLICE_FAT_SIZE=32m
NANO_SLICE_CFG_SIZE=32m
@ -296,71 +276,93 @@ add_port () {
fi
}
create_diskimage ( ) (
local extra
# Creates images for all the formats that use MBR
create_diskimage_mbr ( ) (
pprint 2 "build diskimage ${NANO_NAME}"
pprint 3 "log: ${NANO_OBJ}/_.di"
(
local extra i sz fmt fmtarg bootmbr bootbsd skiparg
set -o xtrace
if [ -n ${NANO_NOPRIV_BUILD} ]; then
extra="-F ${NANO_METALOG}"
fi
[ -z ${NANO_DISKIMAGE_FORMAT} ] || fmtarg="-f ${NANO_DISKIMAGE_FORMAT}"
[ -z ${NANO_DISKIMAGE_FORMAT} ] || fmt=".${NANO_DISKIMAGE_FORMAT}"
bootmbr=${NANO_BOOT_MBR:+-b ${NANO_BOOT_MBR}}
bootbsd=${NANO_BOOT_BSD:+-b ${NANO_BOOT_BSD}}
skiparg=${NANO_MBR_FIRST_SKIP:+-S ${NANO_MBR_FIRST_SKIP}}
for i in s1 s2 s3 s4 empty; do
rm -fr ${NANO_OBJ}/_.${i}*
done
if [ ! -z "${NANO_SLICE_FAT}" ]; then
# Populate the FAT partition
if [-n "${NANO_SLICE_FAT}" ]; then
echo Creating MSDOS partition for kernel
newfs_msdos -C ${NANO_SLICE_FAT_SIZE:-32m} -F 16 -L ${NANO_NAME} \
newfs_msdos -C ${NANO_SLICE_FAT_SIZE} -F 16 -L ${NANO_NAME} \
${NANO_OBJ}/_.${NANO_SLICE_FAT}
# Need to copy files from ${NANO_FATDIR} with mtools, or use
# makefs -t msdos once that's supported
fi
echo Creating main partition
# Populate the / partition, and place it into a slice with a
# bsd label
[ -z ${NANO_NOPRIV_BUILD} ] || extra="-F ${NANO_METALOG}"
sz=${NANO_SLICE_ROOT_SIZE:+-s ${NANO_SLICE_ROOT_SIZE}}
makefs ${extra} -B little $sz -t ffs ${NANO_OBJ}/_.${NANO_SLICE_ROOT}a \
eval "${NANO_MAKEFS_UFS}" ${extra} $sz "${NANO_OBJ}/_.${NANO_SLICE_ROOT}a" \
"${NANO_WORLDDIR}"
mkimg -s bsd ${bootbsd} -p freebsd-ufs:=${NANO_OBJ}/_.${NANO_SLICE_ROOT}a \
-o ${NANO_OBJ}/_.${NANO_SLICE_ROOT}
# Populate the /cfg partition, empty if none given
if [ -z "${NANO_CFGDIR}" ]; then
echo "Faking cfg dir, it's empty"
NANO_CFGDIR=${NANO_OBJ}/_.empty
mkdir ${NANO_CFGDIR}
fi
echo Creating cfg parittion
# XXX -F cfg-mtree
# XXX -F cfg-mtree
eval "${NANO_MAKEFS_UFS}" -s ${NANO_SLICE_CFG_SIZE} \
"${NANO_OBJ}/_.${NANO_SLICE_CFG}" "${NANO_CFGDIR}"
makefs -B little -t ffs -s ${NANO_SLICE_CFG_SIZE:-100m} \
${NANO_OBJ}/_.${NANO_SLICE_CFG} "${NANO_CFGDIR}"
# data slice not supported since we need the part for FAT for
# booting
echo Slicing up the main partition into a full bsd part
bootbsd="-b ${NANO_WORLDDIR}/boot/boot"
mkimg ${bootbsd} -s bsd -p freebsd-ufs:=${NANO_OBJ}/_.${NANO_SLICE_ROOT}a \
-o ${NANO_OBJ}/_.${NANO_SLICE_ROOT}
echo Making the whole shooting match
if [ ! -z $NANO_SLICE_FAT ]; then
# Now shuffle all the slices together into the proper layout
if [ -n "$NANO_SLICE_FAT" ]; then
eval $NANO_SLICE_FAT=fat16b
fi
eval $NANO_SLICE_CFG=freebsd
eval $NANO_SLICE_ROOT=freebsd
[ -z ${NANO_DISKIMAGE_FORMAT} ] || fmtarg="-f ${NANO_DISKIMAGE_FORMAT}"
[ -z ${NANO_DISKIMAGE_FORMAT} ] || fmt=".${NANO_DISKIMAGE_FORMAT}"
bootmbr="-b ${NANO_WORLDDIR}/boot/boot0sio"
# below depends on https://reviews.freebsd.org/D4403 not yet in the tree
# but there's problems: it marks all partitions as active, so you have to
# boot off parittion 3 or 2 by hand if you're playing around with this WIP
if [ ! -z "${NANO_SLICE_FAT}" ]; then
mkimg -a 3 ${fmtarg} ${bootmbr} -s mbr -p ${s1}:=${NANO_OBJ}/_.s1 \
case ${NANO_LAYOUT} in
std-embedded)
mkimg -a 3 ${skiparg} ${fmtarg} ${bootmbr} -s mbr -p ${s1}:=${NANO_OBJ}/_.s1 \
-p ${s2}:=${NANO_OBJ}/_.s2 \
-p ${s3}:=${NANO_OBJ}/_.s3 \
-o ${NANO_OBJ}/_.disk.image.${NANO_NAME}${fmt}
else
;;
std-x86)
# s1 is cfg, s2 is /, not sure how to make that
# boot (marked as active) with mkimg yet
mkimg -a 2 ${fmtarg} ${bootmbr} -s mbr -p ${s1}:=${NANO_OBJ}/_.s1 \
-p ${s2}:=${NANO_OBJ}/_.s2 \
-o ${NANO_OBJ}/_.disk.image.${NANO_NAME}${fmt}
fi
;;
powerpc64-ibm)
# A lie to make the boot loader work, it boots the first BSD partition
# it finds, regardless of the active flag.
s2=fat16b
# boot image is on a special partition, ala std-embedded, but that
# partition isn't FAT with special files, but a copy of the boot
# loader itself.
mkimg ${fmtarg} -s mbr -p ppcboot:=${NANO_WORLDDIR}/boot/boot1.elf \
-p ${s2}:=${NANO_OBJ}/_.s2 \
-p ${s3}:=${NANO_OBJ}/_.s3 \
-o ${NANO_OBJ}/_.disk.image.${NANO_NAME}${fmt}
;;
esac
) > ${NANO_OBJ}/_.di 2>&1
)
@ -372,7 +374,9 @@ die()
# Automatically include the packaging port here so it is always first so it
# builds the port and adds the package so we can add other packages.
#XXX Not sure this works for cross build, so punting for the moment
#XXX Doesn't work for cross build, so punting until I can integreate qemu-static
#XXX or poudere, both of which require priv'd execution. Or qemu-system, which
#XXX is super, super slow.
#add_port ports-mgmt/pkg
#add_port security/sudo
#add_port ftp/curl
@ -384,8 +388,6 @@ if [ -n "$__a" ]; then
umount $__a
fi
NANO_BOOTLOADER="boot/boot0"
if [ "$DEBUG" = 1 ]; then
DEBUG_BUILD="
DEBUG_FLAGS= -g
@ -422,15 +424,6 @@ $var=$val"
fi
done
hack_nsswitch_conf ( )
{
# Remove all references to NIS in the nsswitch.conf file
# Not sure this is still needed, but FreeNAS has it...
sed -i.bak -es/nis/files/g ${NANO_WORLDDIR}/etc/nsswitch.conf
rm -f ${NANO_WORLDDIR}/etc/nsswitch.conf.bak
}
customize_cmd hack_nsswitch_conf
save_build ( )
{
VERSION_FILE=${NANO_WORLDDIR}/etc/version
@ -442,12 +435,6 @@ save_build ( )
}
customize_cmd save_build
remove_patch_divots ( )
{
find ${NANO_WORLDDIR} -name \*.orig -or -name \*.rej -delete
}
customize_cmd remove_patch_divots
shrink_md_fbsize()
{
# We have a lot of little files on our memory disks. Let's decrease
@ -477,3 +464,130 @@ product_custom()
fi
}
late_customize_cmd product_custom
#
# Convenience routines to bring up many settings for standard environments
#
#
# For each architecture, we have a standard set of settings to the extent
# it makes sense. For architectures that don't have a standard environment
# cfg files need to either define a lot of settings, provide their own disk
# imaging, or set which of the variants we support.
#
std_aarch64 ( ) {
}
std_amd64 ( ) {
std_i386
}
std_arm ( ) {
}
std_armeb ( ) {
NANO_ENDIAN=big
}
std_armv6 ( ) {
}
std_i386 ( ) {
# Default values, if not overridden in .cfg file
: ${NANO_KERNEL:=GENERIC}
: ${NANO_DRIVE:=ada0}
: ${NANO_LAYOUT:=std-x86}
: ${NANO_BOOT_MBR:=${NANO_WORLDDIR}/boot/boot0sio}
: ${NANO_BOOT_BSD:=${NANO_WORLDDIR}/boot/boot}
}
std_mips ( ) {
NANO_ENDIAN=big
}
std_mipsel ( ) {
}
std_mips64 ( ) {
NANO_ENDIAN=big
}
std_mips64el ( ) {
}
std_powerpc ( ) {
NANO_ENDIAN=big
}
std_powerpc64 ( ) {
NANO_LAYOUT=powerpc64-ibm
NANO_ENDIAN=big
}
std_sparc64 ( ) {
NANO_ENDIAN=big
}
#
# QEMU settings for the standard environments
#
qemu_env ( ) {
NANO_DISKIMAGE_FORMAT=qcow2
}
# other standard environments will go here
eval std_${NANO_ARCH}
# Slice 1: FAT for ROM loading bootstrap
# Slice 2: Config partition
# Slice 3: FreeBSD partition (sized exactly)
# Slice 4: FreeBSD partition (empty)
# on first boot, we resize slice 3 & 4 to be 1/2 of what's
# left over on the SD card after slice 1 and 2 are taken
# off the top. We also resize the 'a' partion on first boot
# to the size of the partition for the ping/pong upgrade.
# This feature needs support in the rc.d bootup script.
: ${NANO_ENDIAN:=little} # make -V something to figure it out?
: ${NANO_LAYOUT:=std-embedded}
: ${NANO_MAKEFS_UFS:=makefs -t ffs -B ${NANO_ENDIAN}}
: ${NANO_DISK_SCHEME:=mbr} # No others really supported ATM
case ${NANO_LAYOUT} in
std-embedded)
NANO_SLICE_FAT=s1
NANO_SLICE_CFG=s2
NANO_SLICE_ROOT=s3
NANO_SLICE_ALTROOT=s4
;;
std-x86)
NANO_SLICE_CFG=s1
NANO_SLICE_ROOT=s2
NANO_SLICE_ALTROOT=s3
;;
powerpc64-ibm)
NANO_SLICE_PPCBOOT=s1
NANO_SLICE_CFG=s2
NANO_SLICE_ROOT=s3
NANO_SLICE_ALTROOT=s4
;;
powerpc64-apple)
echo Not yet
exit 1
;;
*)
echo Unknown Layout ${NANO_LAYOUT}
exit 1
;;
esac
NANO_SLICE_DATA= # Not included
# Each major disk scheme has its own routine. Generally
# this is for mbr, gpt, etc. These are generally are widely
# shared, but some specialized formats won't be shared.
create_diskimage ( ) (
eval create_diskimage_${NANO_DISK_SCHEME}
)

View File

@ -25,19 +25,10 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# This file is heavily derived from both Sam Leffler's Avilia config,
# as well as the BSDRP project's config file. Neither of these have
# an explicit copyright/license statement, but are implicitly BSDL. This
# example has been taken from the FreeNAS project and simplified to meet
# the needs of the example.
#
NANO_ARCH=amd64
NANO_KERNEL=GENERIC
NANO_DRIVE=ada0
NANO_NAME=qemu-amd64
NANO_DISKIMAGE_FORMAT=qcow2
export EMBED_OMIT_FAT=t
qemu_env
. common # Pull in common definitions, keep last

View File

@ -25,19 +25,10 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# This file is heavily derived from both Sam Leffler's Avilia config,
# as well as the BSDRP project's config file. Neither of these have
# an explicit copyright/license statement, but are implicitly BSDL. This
# example has been taken from the FreeNAS project and simplified to meet
# the needs of the example.
#
NANO_ARCH=i386
NANO_KERNEL=GENERIC
NANO_DRIVE=ada0
NANO_NAME=qemu-i386
NANO_DISKIMAGE_FORMAT=qcow2
export EMBED_OMIT_FAT=t
qemu_env
. common # Pull in common definitions, keep last

View File

@ -25,19 +25,12 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# This file is heavily derived from both Sam Leffler's Avilia config,
# as well as the BSDRP project's config file. Neither of these have
# an explicit copyright/license statement, but are implicitly BSDL. This
# example has been taken from the FreeNAS project and simplified to meet
# the needs of the example.
#
NANO_ARCH=mips
NANO_KERNEL=MALTA
NANO_DRIVE=ada0
NANO_NAME=qemu-mips
NANO_DISKIMAGE_FORMAT=qcow2
export EMBED_OMIT_FAT=t
qemu_env
. common # Pull in common definitions, keep last

View File

@ -25,19 +25,12 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# This file is heavily derived from both Sam Leffler's Avilia config,
# as well as the BSDRP project's config file. Neither of these have
# an explicit copyright/license statement, but are implicitly BSDL. This
# example has been taken from the FreeNAS project and simplified to meet
# the needs of the example.
#
NANO_ARCH=mips
NANO_KERNEL=MALTA64
NANO_DRIVE=ada0
NANO_NAME=qemu-mips64
NANO_DISKIMAGE_FORMAT=qcow2
export EMBED_OMIT_FAT=t
qemu_env
. common # Pull in common definitions, keep last

View File

@ -25,12 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# This file is heavily derived from both Sam Leffler's Avilia config,
# as well as the BSDRP project's config file. Neither of these have
# an explicit copyright/license statement, but are implicitly BSDL. This
# example has been taken from the FreeNAS project and simplified to meet
# the needs of the example.
#
# Open question: do we have one for MAC G4 and one for Book-E?
NANO_ARCH=powerpc
@ -38,7 +32,6 @@ NANO_KERNEL=GENERIC
NANO_DRIVE=ada0
NANO_NAME=qemu-powerpc
NANO_DISKIMAGE_FORMAT=qcow2
export EMBED_OMIT_FAT=t
qemu_env
. common # Pull in common definitions, keep last

View File

@ -25,19 +25,12 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# This file is heavily derived from both Sam Leffler's Avilia config,
# as well as the BSDRP project's config file. Neither of these have
# an explicit copyright/license statement, but are implicitly BSDL. This
# example has been taken from the FreeNAS project and simplified to meet
# the needs of the example.
#
NANO_ARCH=powerpc64
NANO_KERNEL=GENERIC64
NANO_DRIVE=ada0
NANO_NAME=qemu-powerpc64
NANO_DISKIMAGE_FORMAT=qcow2
export EMBED_OMIT_FAT=t
qemu_env
. common # Pull in common definitions, keep last

View File

@ -25,19 +25,12 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# This file is heavily derived from both Sam Leffler's Avilia config,
# as well as the BSDRP project's config file. Neither of these have
# an explicit copyright/license statement, but are implicitly BSDL. This
# example has been taken from the FreeNAS project and simplified to meet
# the needs of the example.
#
NANO_ARCH=sparc64
NANO_KERNEL=GENERIC
NANO_DRIVE=ada0
NANO_NAME=qemu-sparc64
NANO_DISKIMAGE_FORMAT=qcow2
export EMBED_OMIT_FAT=t
qemu_env
. common # Pull in common definitions, keep last

View File

@ -25,12 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# This file is heavily derived from both Sam Leffler's Avilia config,
# as well as the BSDRP project's config file. Neither of these have
# an explicit copyright/license statement, but are implicitly BSDL. This
# example has been taken from the FreeNAS project and simplified to meet
# the needs of the example.
#
NANO_ARCH=armv6
NANO_KERNEL=RPI-B

View File

@ -25,12 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# This file is heavily derived from both Sam Leffler's Avilia config,
# as well as the BSDRP project's config file. Neither of these have
# an explicit copyright/license statement, but are implicitly BSDL. This
# example has been taken from the FreeNAS project and simplified to meet
# the needs of the example.
#
NANO_ARCH=armv6
NANO_KERNEL=RPI2

View File

@ -25,12 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# This file is heavily derived from both Sam Leffler's Avilia config,
# as well as the BSDRP project's config file. Neither of these have
# an explicit copyright/license statement, but are implicitly BSDL. This
# example has been taken from the FreeNAS project and simplified to meet
# the needs of the example.
#
NANO_ARCH=arm
NANO_KERNEL=SAM9260EK

View File

@ -25,12 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# This file is heavily derived from both Sam Leffler's Avilia config,
# as well as the BSDRP project's config file. Neither of these have
# an explicit copyright/license statement, but are implicitly BSDL. This
# example has been taken from the FreeNAS project and simplified to meet
# the needs of the example.
#
NANO_ARCH=arm
NANO_KERNEL=SAM9G20EK