build/arm: add arm-based image generation code
This doesn't fully work yet, the +POST_INSTALL of core and possibly plugins does not like the cross-build env yet.
This commit is contained in:
parent
edf3a1277f
commit
66f5ef1d6e
1
LICENSE
1
LICENSE
|
@ -1,4 +1,5 @@
|
|||
Copyright (c) 2014-2017 Franco Fichtner <franco@opnsense.org>
|
||||
Copyright (c) 2015 The FreeBSD Foundation
|
||||
Copyright (c) 2004-2011 Scott Ullrich <sullrich@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
|
|
4
Makefile
4
Makefile
|
@ -23,7 +23,7 @@
|
|||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
STEPS= base boot chroot clean core distfiles dvd info \
|
||||
STEPS= arm base boot chroot clean core distfiles dvd info \
|
||||
kernel nano plugins ports prefetch print rebase \
|
||||
release rename serial sign skim test update verify \
|
||||
vga vm xtools
|
||||
|
@ -101,7 +101,7 @@ core: plugins
|
|||
packages test: core
|
||||
dvd nano serial vga vm: packages kernel
|
||||
sets: distfiles packages kernel
|
||||
images: dvd nano serial vga vm
|
||||
images: dvd nano serial vga vm # arm
|
||||
release: dvd nano serial vga
|
||||
|
||||
# Expand target arguments for the script append:
|
||||
|
|
31
README.md
31
README.md
|
@ -124,30 +124,36 @@ Release sets can be built using:
|
|||
Cross-building for other architecures
|
||||
-------------------------------------
|
||||
|
||||
This feature is currently experimental. It requires
|
||||
to install a qemu package for user mode emulation:
|
||||
This feature is currently experimental and tailored
|
||||
for use with the Raspberry Pi 2. It requires installation
|
||||
of the qemu package for user mode emulation:
|
||||
|
||||
# pkg install qemu-user-static
|
||||
|
||||
It will also require a matching u-boot package, e.g.:
|
||||
|
||||
# pkg install u-boot-rpi2
|
||||
|
||||
A viable cross-build target is the Raspberry Pi 2 using
|
||||
the following options:
|
||||
A cross-build on the operating system sources is
|
||||
executed by specifying the target architecture and
|
||||
custom kernel:
|
||||
|
||||
# make base kernel ARCH=arm:armv6 KERNEL=SMP-RPI2
|
||||
|
||||
In order to speed up building of using an emulated build,
|
||||
the xtools set can be built:
|
||||
In order to speed up building of using an emulated
|
||||
packages build, the xtools set can be created like so:
|
||||
|
||||
# make xtools ARCH=arm:armv6
|
||||
|
||||
The xtools set is used during the packages build similar to
|
||||
the distfiles set.
|
||||
The xtools set is then used during the packages build
|
||||
similar to the distfiles set.
|
||||
|
||||
# make packages ARCH=arm:armv6
|
||||
|
||||
The image will also require a matching u-boot package:
|
||||
|
||||
# pkg install u-boot-rpi2
|
||||
|
||||
The final image is built using:
|
||||
|
||||
# make arm-<size> ARCH=arm:armv6
|
||||
|
||||
About other scripts and tweaks
|
||||
==============================
|
||||
|
||||
|
@ -277,6 +283,7 @@ via the clean script:
|
|||
|
||||
Available clean options are:
|
||||
|
||||
* arm: remove arm image
|
||||
* base: remove base set
|
||||
* distfiles: remove distfiles set
|
||||
* dvd: remove dvd image
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Copyright (c) 2017 Franco Fichtner <franco@opnsense.org>
|
||||
# Copyright (c) 2015 The FreeBSD Foundation
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
set -e
|
||||
|
||||
SELF=arm
|
||||
|
||||
. ./common.sh
|
||||
|
||||
if [ ${PRODUCT_ARCH} != armv6 ]; then
|
||||
echo ">>> Cannot build arm image with arch ${PRODUCT_ARCH}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
check_image ${SELF} ${@}
|
||||
|
||||
ARMSIZE="3G"
|
||||
|
||||
if [ -n "${1}" ]; then
|
||||
ARMSIZE=${1}
|
||||
fi
|
||||
|
||||
ARMIMG="${IMAGESDIR}/${PRODUCT_RELEASE}-arm-${PRODUCT_ARCH}.img"
|
||||
ARMLABEL="${PRODUCT_NAME}"
|
||||
|
||||
sh ./clean.sh ${SELF}
|
||||
|
||||
setup_stage ${STAGEDIR} mnt
|
||||
|
||||
truncate -s ${ARMSIZE} ${ARMIMG}
|
||||
|
||||
DEV=$(mdconfig -a -t vnode -f ${ARMIMG} -x 63 -y 255)
|
||||
|
||||
gpart create -s MBR ${DEV}
|
||||
gpart add -t '!12' -a 63 -s 50m ${DEV}
|
||||
gpart set -a active -i 1 ${DEV}
|
||||
newfs_msdos -L msdosboot -F 16 /dev/${DEV}s1
|
||||
gpart add -t freebsd ${DEV}
|
||||
gpart create -s bsd ${DEV}s2
|
||||
gpart add -t freebsd-ufs -a 64k /dev/${DEV}s2
|
||||
newfs -U -L ${ARMLABEL} /dev/${DEV}s2a
|
||||
mount /dev/${DEV}s2a ${STAGEDIR}/mnt
|
||||
|
||||
setup_base ${STAGEDIR}/mnt
|
||||
setup_kernel ${STAGEDIR}/mnt
|
||||
# xtools poison the installation, but...
|
||||
setup_xtools ${STAGEDIR}/mnt
|
||||
setup_packages ${STAGEDIR}/mnt
|
||||
setup_extras ${STAGEDIR} ${SELF}/mnt
|
||||
setup_entropy ${STAGEDIR}/mnt
|
||||
# ... rewriting the base will fix that
|
||||
setup_base ${STAGEDIR}/mnt
|
||||
|
||||
cat > ${STAGEDIR}/mnt/etc/fstab << EOF
|
||||
# Device Mountpoint FStype Options Dump Pass#
|
||||
/dev/ufs/${ARMLABEL} / ufs rw 1 1
|
||||
/dev/msdosfs/MSDOSBOOT /boot/msdos msdosfs rw,noatime 0 0
|
||||
EOF
|
||||
|
||||
mkdir -p ${STAGEDIR}/mnt/boot/msdos
|
||||
cp -rp ${STAGEDIR}/mnt/boot ${STAGEDIR}/boot
|
||||
|
||||
umount ${STAGEDIR}/mnt
|
||||
mount_msdosfs /dev/${DEV}s1 ${STAGEDIR}/mnt
|
||||
|
||||
UBOOT_DIR="/usr/local/share/u-boot/u-boot-rpi2"
|
||||
UBOOT_FILES="bootcode.bin config.txt fixup.dat fixup_cd.dat \
|
||||
fixup_x.dat start.elf start_cd.elf start_x.elf u-boot.bin"
|
||||
|
||||
for _UF in ${UBOOT_FILES}; do
|
||||
cp -p ${UBOOT_DIR}/${_UF} ${STAGEDIR}/mnt
|
||||
done
|
||||
|
||||
cp -p ${STAGEDIR}/boot/ubldr ${STAGEDIR}/mnt/ubldr
|
||||
cp -p ${STAGEDIR}/boot/ubldr.bin ${STAGEDIR}/mnt/ubldr.bin
|
||||
cp -p ${STAGEDIR}/boot/dtb/rpi2.dtb ${STAGEDIR}/mnt/rpi2.dtb
|
||||
|
||||
umount ${STAGEDIR}/mnt
|
||||
|
||||
mdconfig -d -u ${DEV}
|
|
@ -33,6 +33,10 @@ SELF=clean
|
|||
|
||||
for ARG in ${@}; do
|
||||
case ${ARG} in
|
||||
arm)
|
||||
echo ">>> Removing arm image"
|
||||
rm -f ${IMAGESDIR}/*-${PRODUCT_FLAVOUR}-arm-${PRODUCT_ARCH}.img
|
||||
;;
|
||||
base)
|
||||
echo ">>> Removing base set"
|
||||
rm -f ${SETSDIR}/base-*-${PRODUCT_ARCH}.*
|
||||
|
|
|
@ -355,25 +355,34 @@ setup_copy()
|
|||
cp -r ${2} ${1}${2}
|
||||
}
|
||||
|
||||
setup_xtools()
|
||||
{
|
||||
if [ ${PRODUCT_HOST} = ${PRODUCT_ARCH} ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
echo ">>> Setting up xtools in ${1}"
|
||||
|
||||
# additional emulation layer so that chroot
|
||||
# looks like a native environment later on
|
||||
mkdir -p ${1}/usr/local/bin
|
||||
cp /usr/local/bin/qemu-${PRODUCT_TARGET}-static ${1}/usr/local/bin
|
||||
/usr/local/etc/rc.d/qemu_user_static onerestart
|
||||
|
||||
# copy the native toolchain for extra speed
|
||||
XTOOLS_SET=$(find ${SETSDIR} -name "xtools-*-${PRODUCT_ARCH}.txz")
|
||||
if [ -n "${XTOOLS_SET}" ]; then
|
||||
tar -C ${1} -xpf ${XTOOLS_SET}
|
||||
fi
|
||||
}
|
||||
|
||||
setup_chroot()
|
||||
{
|
||||
# historic glue
|
||||
setup_xtools ${1}
|
||||
|
||||
echo ">>> Setting up chroot in ${1}"
|
||||
|
||||
if [ ${PRODUCT_HOST} != ${PRODUCT_ARCH} ]; then
|
||||
# additional emulation layer so that chroot
|
||||
# looks like a native environment later on
|
||||
mkdir -p ${1}/usr/local/bin
|
||||
cp /usr/local/bin/qemu-${PRODUCT_TARGET}-static \
|
||||
${1}/usr/local/bin
|
||||
/usr/local/etc/rc.d/qemu_user_static onerestart
|
||||
|
||||
# copy the native toolchain for extra speed
|
||||
XTOOLS_SET=$(find ${SETSDIR} -name "xtools-*-${PRODUCT_ARCH}.txz")
|
||||
if [ -n "${XTOOLS_SET}" ]; then
|
||||
tar -C ${1} -xpf ${XTOOLS_SET}
|
||||
fi
|
||||
fi
|
||||
|
||||
cp /etc/resolv.conf ${1}/etc
|
||||
mount -t devfs devfs ${1}/dev
|
||||
chroot ${1} /bin/sh /etc/rc.d/ldconfig start
|
||||
|
@ -402,6 +411,9 @@ setup_base()
|
|||
{
|
||||
echo ">>> Setting up world in ${1}"
|
||||
|
||||
# manually undo xtools additions
|
||||
rm -f ${1}/usr/bin/qemu-*-static ${1}/etc/rc.conf.local
|
||||
|
||||
tar -C ${1} -xpf ${SETSDIR}/base-*-${PRODUCT_ARCH}.txz
|
||||
|
||||
# /home is needed for LiveCD images, and since it
|
||||
|
|
|
@ -33,6 +33,11 @@ SELF=rename
|
|||
|
||||
for ARG in ${@}; do
|
||||
case ${ARG} in
|
||||
arm)
|
||||
echo ">>> Renaming arm image: ${VERSION}"
|
||||
mv ${IMAGESDIR}/*-${PRODUCT_FLAVOUR}-arm-${PRODUCT_ARCH}.img \
|
||||
${IMAGESDIR}/${PRODUCT_NAME}-${VERSION}-${PRODUCT_FLAVOUR}-arm-${PRODUCT_ARCH}.iso
|
||||
;;
|
||||
base)
|
||||
setup_stage ${STAGEDIR}
|
||||
echo ">>> Repacking base set..."
|
||||
|
|
|
@ -10,6 +10,11 @@ kern.cam.boot_delay="10000"
|
|||
EOF
|
||||
}
|
||||
|
||||
arm_hook()
|
||||
{
|
||||
loader_conf_fixup ${1}
|
||||
}
|
||||
|
||||
dvd_hook()
|
||||
{
|
||||
loader_conf_fixup ${1}
|
||||
|
|
|
@ -10,6 +10,11 @@ kern.cam.boot_delay="10000"
|
|||
EOF
|
||||
}
|
||||
|
||||
arm_hook()
|
||||
{
|
||||
loader_conf_fixup ${1}
|
||||
}
|
||||
|
||||
dvd_hook()
|
||||
{
|
||||
loader_conf_fixup ${1}
|
||||
|
|
Loading…
Reference in New Issue