summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2013-10-28 14:10:42 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2013-10-28 14:10:42 +0000
commit29950e68ba62c0161f7c7354372b8f0250503d15 (patch)
treed38cab96e8bff21968c1096becc7dab5b38f66f1
parent49b356009bae2f694c9103265b773244aa779ac6 (diff)
Revamp ARMv7 ramdisk and miniroot creation process.
Instead of running mkuboot during install, we call it on during the release build, so that we can also ship bootable images of the generic and the ramdisk kernel. We can now build miniroots for imx, too. The installer also can recognize the SoC and makes decision based on it. Use ext2fs for i.MX6 based devices. Tar the bootloader files to save some space. ok syl@
-rw-r--r--distrib/armv7/miniroot/Makefile2
-rw-r--r--distrib/armv7/miniroot/Makefile.inc27
-rw-r--r--distrib/armv7/miniroot/am335x/Makefile2
-rw-r--r--distrib/armv7/miniroot/beagle/Makefile2
-rw-r--r--distrib/armv7/miniroot/imx/Makefile7
-rw-r--r--distrib/armv7/miniroot/panda/Makefile2
-rw-r--r--distrib/armv7/ramdisk/Makefile8
-rw-r--r--distrib/armv7/ramdisk/install.md97
-rw-r--r--distrib/armv7/ramdisk/list8
-rw-r--r--etc/etc.armv7/Makefile.inc28
-rw-r--r--sys/arch/armv7/conf/RAMDISK-IMX5
11 files changed, 156 insertions, 32 deletions
diff --git a/distrib/armv7/miniroot/Makefile b/distrib/armv7/miniroot/Makefile
index 98abfe080b5..c024f558e46 100644
--- a/distrib/armv7/miniroot/Makefile
+++ b/distrib/armv7/miniroot/Makefile
@@ -1,3 +1,3 @@
-SUBDIR= am335x beagle panda
+SUBDIR= am335x beagle panda imx
.include <bsd.subdir.mk>
diff --git a/distrib/armv7/miniroot/Makefile.inc b/distrib/armv7/miniroot/Makefile.inc
index 018ed3b257f..9e9b141607f 100644
--- a/distrib/armv7/miniroot/Makefile.inc
+++ b/distrib/armv7/miniroot/Makefile.inc
@@ -3,6 +3,7 @@ REV= ${OSrev}
BSD_RD= bsd.rd.OMAP
IMAGE= miniroot-${BOARD}-${REV}.fs
+MKUBOOT?= mkuboot
MOUNT_POINT= /mnt
@@ -17,6 +18,15 @@ PID!= echo $$$$
NBLKS= 36864
+FS?= msdos
+PART_ID?=C
+
+NEWFS_ARGS_msdos=-F 16 -L boot
+NEWFS_ARGS_ext2fs=-v boot
+
+cleandir: clean
+clean:
+ rm -f ${IMAGE}
.ifndef DESTDIR
all ${IMAGE}:
@@ -30,20 +40,27 @@ ${IMAGE}: rd_setup do_files rd_teardown
.endif
do_files:
- echo 'bootcmd=mmc rescan ; setenv loadaddr 0x82800000 ; setenv bootargs sd0i:/bsd.umg ; fatload mmc 0 $${loadaddr} bsd.umg ; bootm $${loadaddr} ;\nuenvcmd=boot' > ${MOUNT_POINT}/uenv.txt
+.if ${PLATFORM} == "OMAP"
cp /usr/mdec/${BOARD}/mlo ${MOUNT_POINT}/mlo
+ echo "bootcmd=mmc rescan ; setenv loadaddr ${LOADADDR} ; setenv bootargs sd0i:/bsd.umg ; fatload mmc 0 \$${loadaddr} bsd.umg ; bootm \$${loadaddr} ;\nuenvcmd=boot" > ${MOUNT_POINT}/uenv.txt
cp /usr/mdec/${BOARD}/u-boot.* ${MOUNT_POINT}/
mkdir ${MOUNT_POINT}/u-boots
cp -r /usr/mdec/{am335x,beagle,panda} ${MOUNT_POINT}/u-boots
- mkuboot -a arm -o linux -e 0x80300000 -l 0x80300000 \
- ${.OBJDIR}/../../ramdisk/bsd.rd.OMAP ${MOUNT_POINT}/bsd.umg
+.endif
+.if ${PLATFORM} == "IMX"
+ echo "; setenv loadaddr ${LOADADDR} ; setenv bootargs sd0i:/bsd.umg ; for dtype in sata mmc ; do for disk in 0 1 ; do \$${dtype} dev \$${disk} ; for fs in fat ext2 ; do if \$${fs}load \$${dtype} \$${disk}:1 \$${loadaddr} bsd.umg ; then bootm \$${loadaddr} ; fi ; done; done; done; echo; echo failed to load bsd.umg" > 6x_bootscript.cmd
+ ${MKUBOOT} -t script -a arm -o linux 6x_bootscript.cmd 6x_bootscript.scr
+ cp 6x_bootscript.scr ${MOUNT_POINT}/6x_bootscript
+
+.endif
+ cp ${.OBJDIR}/../../ramdisk/bsd.rd.${PLATFORM}.umg ${MOUNT_POINT}/bsd.umg
rd_setup:
dd if=/dev/zero of=${IMAGE} bs=512 count=${NBLKS}
vnconfig -c ${VND} ${IMAGE}
fdisk -c 2 -h 255 -s 63 -yi ${VND} >/dev/null
- echo 'u\ne 0\nC\ny\n0\n1\n1\n1\n254\n63\nf 0\nw\nq\n' | fdisk -c 2 -h 255 -s 63 -e ${VND} >/dev/null
- newfs_msdos -F 16 -L boot ${VND_RIDEV} >/dev/null
+ echo "u\ne 0\n${PART_ID}\ny\n0\n1\n1\n1\n254\n63\nf 0\nw\nq\n" | fdisk -c 2 -h 255 -s 63 -e ${VND} >/dev/null
+ newfs_${FS} ${NEWFS_ARGS_${FS}} ${VND_RIDEV} >/dev/null
mount ${VND_IDEV} ${MOUNT_POINT}
rd_teardown:
diff --git a/distrib/armv7/miniroot/am335x/Makefile b/distrib/armv7/miniroot/am335x/Makefile
index 58a8892a8c1..3abba971a24 100644
--- a/distrib/armv7/miniroot/am335x/Makefile
+++ b/distrib/armv7/miniroot/am335x/Makefile
@@ -1,3 +1,5 @@
BOARD= am335x
+PLATFORM=OMAP
+LOADADDR=0x82800000
.include "${.CURDIR}/../Makefile.inc"
diff --git a/distrib/armv7/miniroot/beagle/Makefile b/distrib/armv7/miniroot/beagle/Makefile
index eb3c36bdb58..e4eb94dc34b 100644
--- a/distrib/armv7/miniroot/beagle/Makefile
+++ b/distrib/armv7/miniroot/beagle/Makefile
@@ -1,3 +1,5 @@
BOARD= beagle
+PLATFORM=OMAP
+LOADADDR=0x82800000
.include "${.CURDIR}/../Makefile.inc"
diff --git a/distrib/armv7/miniroot/imx/Makefile b/distrib/armv7/miniroot/imx/Makefile
new file mode 100644
index 00000000000..8984070e9b1
--- /dev/null
+++ b/distrib/armv7/miniroot/imx/Makefile
@@ -0,0 +1,7 @@
+BOARD= imx
+PLATFORM=IMX
+LOADADDR=0x18800000
+FS=ext2fs
+PART_ID=83
+
+.include "${.CURDIR}/../Makefile.inc"
diff --git a/distrib/armv7/miniroot/panda/Makefile b/distrib/armv7/miniroot/panda/Makefile
index a9626bfb717..c8ed3fdd097 100644
--- a/distrib/armv7/miniroot/panda/Makefile
+++ b/distrib/armv7/miniroot/panda/Makefile
@@ -1,3 +1,5 @@
BOARD= panda
+PLATFORM=OMAP
+LOADADDR=0x82800000
.include "${.CURDIR}/../Makefile.inc"
diff --git a/distrib/armv7/ramdisk/Makefile b/distrib/armv7/ramdisk/Makefile
index 6db82d7b96b..206873155de 100644
--- a/distrib/armv7/ramdisk/Makefile
+++ b/distrib/armv7/ramdisk/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.5 2013/10/15 22:46:49 deraadt Exp $
+# $OpenBSD: Makefile,v 1.6 2013/10/28 14:10:41 patrick Exp $
REV= ${OSrev}
@@ -21,6 +21,8 @@ VND_RDEV= /dev/r${VND}a
VND_CRDEV= /dev/r${VND}c
PID!= echo $$$$
+KERNADDR_OMAP=0x80300000
+KERNADDR_IMX=0x10800000
DISKTYPE= rdroot2.5M
NBLKS= 5120
@@ -38,7 +40,7 @@ ALLBSD=
ALLBSDRD=
.for SOC in ${ALLSOC}
ALLBSD+= bsd.${SOC}
-ALLBSDRD+= ${BSD_RD}.${SOC}
+ALLBSDRD+= ${BSD_RD}.${SOC} ${BSD_RD}.${SOC}.umg
all: ${ALLBSDRD}
.endfor
@@ -52,6 +54,8 @@ bsd.${SOC}:
${BSD_RD}.${SOC}: ${CBIN} ${IMAGE} bsd.${SOC} rdsetroot
cp bsd.${SOC} ${BSD_RD}.${SOC}
${.OBJDIR}/rdsetroot ${BSD_RD}.${SOC} ${IMAGE}
+ mkuboot -a arm -o linux -e ${KERNADDR_${SOC}} -l ${KERNADDR_${SOC}} \
+ ${BSD_RD}.${SOC} ${BSD_RD}.${SOC}.umg
.endfor
${IMAGE}: rd_setup do_files rd_teardown
diff --git a/distrib/armv7/ramdisk/install.md b/distrib/armv7/ramdisk/install.md
index b335832f3f3..d163ee2e75c 100644
--- a/distrib/armv7/ramdisk/install.md
+++ b/distrib/armv7/ramdisk/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.1 2013/09/04 20:00:23 patrick Exp $
+# $OpenBSD: install.md,v 1.2 2013/10/28 14:10:41 patrick Exp $
#
#
# Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -32,34 +32,91 @@
# machine dependent section of installation/upgrade script.
#
+# This code runs when the script is initally sourced to set up
+# MDSETS, SANESETS and DEFAULTSETS
+
+dmesg | grep "^omap0 at mainbus0:" >/dev/null
+if [[ $? == 0 ]]; then
+ MDPLAT=OMAP
+ LOADADDR=0x82800000
+fi
+dmesg | grep "^imx0 at mainbus0:" >/dev/null
+if [[ $? == 0 ]]; then
+ MDPLAT=IMX
+ LOADADDR=0x18800000
+fi
+
+MDSETS="bsd.${MDPLAT} bsd.rd.${MDPLAT} bsd.${MDPLAT}.umg bsd.rd.${MDPLAT}.umg"
+SANESETS="bsd.${MDPLAT}"
+DEFAULTSETS=${MDSETS}
+
+NEWFSARGS_msdos="-F 16 -L boot"
+NEWFSARGS_ext2fs="-v boot"
+
md_installboot() {
local _disk=$1
mount /dev/${_disk}i /mnt/mnt
- /mnt/usr/sbin/chroot /mnt /usr/sbin/mkuboot -a arm -o linux \
- -e 0x80300000 -l 0x80300000 /bsd /mnt/bsd.umg
- cp -r /tmp/u-boots/* /mnt/usr/mdec/
+
BEAGLE=$(scan_dmesg '/^omap0 at mainbus0: \(BeagleBoard\).*/s//\1/p')
BEAGLEBONE=$(scan_dmesg '/^omap0 at mainbus0: \(BeagleBone\).*/s//\1/p')
PANDA=$(scan_dmesg '/^omap0 at mainbus0: \(PandaBoard\)/s//\1/p')
- if [[ -n $BEAGLE ]]; then
- cp /mnt/usr/mdec/beagle/{mlo,u-boot.bin} /mnt/mnt/
- elif [[ -n $BEAGLEBONE ]]; then
- cp /mnt/usr/mdec/am335x/{mlo,u-boot.img} /mnt/mnt/
- elif [[ -n $PANDA ]]; then
- cp /mnt/usr/mdec/panda/{mlo,u-boot.bin} /mnt/mnt/
- fi
- cat > /mnt/mnt/uenv.txt<<__EOT
-bootcmd=mmc rescan ; setenv loadaddr 0x82800000 ; setenv bootargs sd0i:/bsd.umg ; fatload mmc 0 \${loadaddr} bsd.umg ; bootm \${loadaddr} ;
+ IMX=$(scan_dmesg '/^imx0 at mainbus0: \(i.MX6.*\)/s//IMX/p')
+
+ if [[ -f /mnt/bsd.${MDPLAT} ]]; then
+ mv /mnt/bsd.${MDPLAT} /mnt/bsd
+ fi
+ if [[ -f /mnt/bsd.${MDPLAT}.umg ]]; then
+ mv /mnt/bsd.${MDPLAT}.umg /mnt/mnt/bsd.umg
+ fi
+ if [[ -f /mnt/bsd.mp.${MDPLAT} ]]; then
+ mv /mnt/bsd.mp.${MDPLAT} /mnt/bsd.mp
+ fi
+ if [[ -f /mnt/bsd.rd.${MDPLAT} ]]; then
+ mv /mnt/bsd.rd.${MDPLAT} /mnt/bsd.rd
+ fi
+ if [[ -f /mnt/bsd.rd.${MDPLAT}.umg ]]; then
+ mv /mnt/bsd.rd.${MDPLAT}.umg /mnt/mnt/bsdrd.umg
+ fi
+
+ # extracted on all machines, so make snap works.
+ tar -C /mnt/ -xf /usr/mdec/u-boots.tgz
+
+ if [[ ${MDPLAT} == "OMAP" ]]; then
+
+ if [[ -n $BEAGLE ]]; then
+ cp /mnt/usr/mdec/beagle/{mlo,u-boot.bin} /mnt/mnt/
+ elif [[ -n $BEAGLEBONE ]]; then
+ cp /mnt/usr/mdec/am335x/{mlo,u-boot.img} /mnt/mnt/
+ elif [[ -n $PANDA ]]; then
+ cp /mnt/usr/mdec/panda/{mlo,u-boot.bin} /mnt/mnt/
+ fi
+ cat > /mnt/mnt/uenv.txt<<__EOT
+bootcmd=mmc rescan ; setenv loadaddr ${LOADADDR}; setenv bootargs sd0i:/bsd.umg ; fatload mmc 0 \${loadaddr} bsd.umg ; bootm \${loadaddr} ;
uenvcmd=boot
__EOT
+ else
+ cat > /tmp/6x_bootscript.scr<<__EOT
+; setenv loadaddr ${LOADADDR} ; setenv bootargs sd0i:/bsd.umg ; for dtype in sata mmc ; do for disk in 0 1 ; do \${dtype} dev \${disk} ; for fs in fat ext2 ; do if \${fs}load \${dtype} \${disk}:1 \${loadaddr} bsd.umg ; then bootm \${loadaddr} ; fi ; done; done; done; echo; echo failed to load bsd.umg
+__EOT
+ mkuboot -t script -a arm -o linux /tmp/6x_bootscript.scr /mnt/mnt/6x_bootscript
+ fi
}
md_prep_fdisk() {
local _disk=$1 _q _d
- mount /dev/sd0i /mnt2
- cp -r /mnt2/u-boots/ /tmp/
- umount /mnt2
+ local bootparttype="C"
+ local bootfstype="msdos"
+ local newfs_args=${NEWFSARGS_msdos}
+
+ # imx needs an ext2fs filesystem
+ IMX=$(scan_dmesg '/^imx0 at mainbus0: \(i.MX6.*\)/s//IMX/p')
+ if [[ -n $IMX ]]; then
+ bootparttype="83"
+ bootfstype="ext2fs"
+ newfs_args=${NEWFSARGS_ext2fs}
+ fi
+
while :; do
_d=whole
if [[ -n $(fdisk $_disk | grep 'Signature: 0xAA55') ]]; then
@@ -70,11 +127,11 @@ md_prep_fdisk() {
ask "Use (W)hole disk$_q or (E)dit the MBR?" "$_d"
case $resp in
w*|W*)
- echo -n "Creating a FAT partition and an OpenBSD partition for rest of $_disk..."
+ echo -n "Creating a ${bootfstype} partition and an OpenBSD partition for rest of $_disk..."
fdisk -e ${_disk} <<__EOT >/dev/null
reinit
e 0
-C
+${bootparttype}
n
64
32768
@@ -89,7 +146,7 @@ quit
__EOT
echo "done."
disklabel $_disk 2>/dev/null | grep -q "^ i:" || disklabel -w -d $_disk
- newfs -t msdos ${_disk}i
+ newfs -t ${bootfstype} ${newfs_args} ${_disk}i
return ;;
e*|E*)
# Manually configure the MBR.
@@ -100,7 +157,7 @@ and one MBR partition on which kernels are located which are loaded
by U-Boot. Neither partition will overlap any other partition.
The OpenBSD MBR partition will have an id of 'A6' and the boot MBR
-partition will have an id of 'C' (MSDOS). The boot partition will be
+partition will have an id of '${bootparttype}' (${bootfstype}). The boot partition will be
at least 16MB and be the first 'MSDOS' partition on the disk.
$(fdisk ${_disk})
diff --git a/distrib/armv7/ramdisk/list b/distrib/armv7/ramdisk/list
index 9f1c084b973..4f6315a4503 100644
--- a/distrib/armv7/ramdisk/list
+++ b/distrib/armv7/ramdisk/list
@@ -1,4 +1,4 @@
-# $OpenBSD: list,v 1.1 2013/09/04 20:00:23 patrick Exp $
+# $OpenBSD: list,v 1.2 2013/10/28 14:10:41 patrick Exp $
SRCDIRS distrib/special
SRCDIRS bin sbin usr.bin usr.sbin
@@ -46,6 +46,7 @@ LINK instbin sbin/mount_msdos
LINK instbin sbin/mount_nfs
LINK instbin sbin/newfs
LINK instbin sbin/newfs_msdos
+LINK instbin sbin/newfs_ext2fs
LINK instbin sbin/ping
LINK instbin sbin/ping6
LINK instbin sbin/reboot sbin/halt
@@ -57,9 +58,13 @@ LINK instbin usr/bin/grep usr/bin/fgrep usr/bin/egrep
LINK instbin usr/bin/gzip usr/bin/gunzip usr/bin/gzcat
LINK instbin usr/bin/less usr/bin/more
LINK instbin usr/bin/sed
+LINK instbin usr/sbin/mkuboot
LINK instbin sbin/sysctl
LINK instbin sbin/bioctl
+# this is the list from distrib/miniroot/makeconf.awk with -lz added.
+LIBS -lstubs -lutil -lotermcap -lm -lz
+
# copy the MAKEDEV script and make some devices
SCRIPT ${DESTDIR}/dev/MAKEDEV dev/MAKEDEV
SPECIAL cd dev; sh MAKEDEV ramdisk
@@ -82,6 +87,7 @@ SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade
SCRIPT ${CURDIR}/../../miniroot/install.sh install
SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub
SPECIAL chmod 755 install upgrade
+SPECIAL tar cvf usr/mdec/u-boots.tgz /usr/mdec/
HASH var/hash
TZ
diff --git a/etc/etc.armv7/Makefile.inc b/etc/etc.armv7/Makefile.inc
index 83440c9589c..92587e02878 100644
--- a/etc/etc.armv7/Makefile.inc
+++ b/etc/etc.armv7/Makefile.inc
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.inc,v 1.2 2013/09/07 23:04:44 patrick Exp $
+# $OpenBSD: Makefile.inc,v 1.3 2013/10/28 14:10:41 patrick Exp $
ALLSOC=IMX OMAP
KERNELS=
@@ -6,9 +6,35 @@ MDEXT=
.for SOC in ${ALLSOC}
KERNELS+= GENERIC-${SOC} bsd.${SOC}
+MDEXT+= bsd.${SOC}.umg
MDEXT+= bsd.rd.${SOC}
+MDEXT+= bsd.rd.${SOC}.umg
.endfor
+KERNADDR_OMAP=0x80300000
+KERNADDR_IMX=0x10800000
+
+.for CONF K in ${KERNELS}
+. if !target($K)
+$K:
+ cd ../sys/arch/${MACHINE}/conf && config ${CONF}
+ cd ../sys/arch/${MACHINE}/compile/${CONF} && \
+ ${MAKE} clean && exec ${MAKE}
+. endif
+ALL_KERNELS += $K
+.endfor
+
+kernels: bootblocks ${ALL_KERNELS}
+.for CONF K in ${KERNELS}
+ cp ../sys/arch/${MACHINE}/compile/${CONF}/bsd ${RELEASEDIR}/$K
+.endfor
+.for SOC in ${ALLSOC}
+ mkuboot -a arm -o linux -e ${KERNADDR_${SOC}} -l ${KERNADDR_${SOC}} \
+ ${RELEASEDIR}/bsd.${SOC} ${RELEASEDIR}/bsd.${SOC}.umg
+.endfor
+
+ALL_KERNELS=
+
bootblocks:
MDEXT+= miniroot-am335x-${OSrev}.fs miniroot-beagle-${OSrev}.fs \
diff --git a/sys/arch/armv7/conf/RAMDISK-IMX b/sys/arch/armv7/conf/RAMDISK-IMX
index 82bc7a0ab8b..742f0d5cfab 100644
--- a/sys/arch/armv7/conf/RAMDISK-IMX
+++ b/sys/arch/armv7/conf/RAMDISK-IMX
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISK-IMX,v 1.3 2013/10/05 23:05:11 patrick Exp $
+# $OpenBSD: RAMDISK-IMX,v 1.4 2013/10/28 14:10:41 patrick Exp $
#
# GENERIC machine description file
#
@@ -31,7 +31,8 @@ options DDB # kernel debugger
options DIAGNOSTIC
option DDB_SAFE_CONSOLE
options FIFO # FIFOs; RECOMMENDED
-#options NFSCLIENT # NFS
+option EXT2FS # Second Extended Filesystem
+#option NFSCLIENT # NFS
makeoptions KERNEL_BASE_PHYS="0x10800000"
makeoptions KERNEL_BASE_VIRT="0xc0800000"