NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
install/55075: distrib/common/bootimage FAT partition support
>Number: 55075
>Category: install
>Synopsis: distrib/common/bootimage FAT partition support
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: install-manager
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sun Mar 15 18:00:00 +0000 2020
>Originator: Izumi Tsutsui
>Release: NetBSD -current
>Organization:
>Environment:
System: NetBSD -current
Architecture: All
Machine: All (especially arc, hpcarm, hpcmips, hpcsh, zaurus etc.)
>Description:
Several ports (arc, hpcarm, hpcmips, hpcsh, zaurus etc.) need to
have FAT (MSDOS) partition in pre-installed liveimages to load
bootstrap loader files from it, but currently distrib/common/bootimage
doesn't support creation of such FAT partition.
(makefs "-t msdos" support was not available at that time)
Currently distrib/utils/embedded also handles images with FAT so
I'm not sure which method should be used, but I think it's still worth
to add FAT partition support in "build.sh live-image" for those ports.
(since files in distrib/utils/embedded are implicitly referred from
src/etc/etc.${MACHINE}/Makefile.inc and it's a bit hard to add
new images for other ports, due to lack of documentation)
>How-To-Repeat:
N/A (change request)
>Fix:
My local changes are attached.
- add FAT partition creation lines to
distrib/common/bootimage/Makefile.bootimage
- parameters for FAT:
- FATMB: FAT partition size
- MBRFAT: MBR partition type
- FATMAKEFSOPTIONS: makefs -t msdos options
- FATFILES: files to be copied into FAT partition
- adjust other partition offsets and sizes
- add FAT partition to TARGET_BLOCKS to concatinate images
- add optional diskproto file with FAT in partition e:
- create FAT as EFI system partition does
- XXX: I wonder if makefs '-B ${TARGET_ENDIANNESS}' is valid for msdosfs
- prepare FAT partition in fdisk (MBR) partition
- add hpcarm and zaurus liveimage files
- zaurus one just works (hpcarm build is ongoing)
---
? distrib/common/bootimage/diskproto.mbrfat.in
? distrib/hpcarm/liveimage
? distrib/zaurus/liveimage
Index: distrib/common/bootimage/Makefile.bootimage
===================================================================
RCS file: /cvsroot/src/distrib/common/bootimage/Makefile.bootimage,v
retrieving revision 1.23
diff -u -p -d -r1.23 Makefile.bootimage
--- distrib/common/bootimage/Makefile.bootimage 21 Nov 2019 22:29:03 -0000 1.23
+++ distrib/common/bootimage/Makefile.bootimage 15 Mar 2020 17:22:21 -0000
@@ -63,6 +63,9 @@
# EFIMB
# EFI partition size in target image in MB
# (default: 128)
+# FATMB
+# FAT partition size in target image in MB
+# (default: empty)
# KERN_SET
# kernel set name which should be extracted into image
# (default: kern-GENERIC)
@@ -123,6 +126,18 @@
# EFIBOOT
# EFI bootloader
# (default: empty)
+# MBRFAT
+# MBR partition type value for FAT
+# (default: 6 ("16-bit FAT, more than 32M"))
+# FATMAKEFSOPTIONS
+# options passed to makefs(8) to create a FAT partition
+# (default: -o fat_type=16)
+# FATFILES
+# list of additional files to be copied into FAT partition,
+# containing one or more tuples of the form:
+# FILE TARGETPATH
+# to put bootstrap binaries for installation image etc.
+# (default: empty)
#
.include <bsd.own.mk> #
@@ -169,11 +184,13 @@ GPTSECTORS= 0
EFIMB?= 128 # 128MB
GPTSECTORS= 2048
.endif
+FATMB?= 0
# XXX: SWAPMB could be zero and expr(1) returns exit status 1 in that case
IMAGESECTORS!= expr ${IMAGEMB} \* 1024 \* 1024 / 512
SWAPSECTORS!= expr ${SWAPMB} \* 1024 \* 1024 / 512 || true
EFISECTORS!= expr ${EFIMB} \* 1024 \* 1024 / 512 || true
+FATSECTORS!= expr ${FATMB} \* 1024 \* 1024 / 512 || true
.if ${USE_MBR} == "no" && ${USE_GPT} == "no"
LABELSECTORS?= 0
@@ -184,7 +201,7 @@ LABELSECTORS?= 2048 # 1MB aligned for mo
.endif
FSSECTORS!= expr ${IMAGESECTORS} - ${SWAPSECTORS} - ${LABELSECTORS} \
- - ${EFISECTORS} - ${GPTSECTORS}
+ - ${EFISECTORS} - ${GPTSECTORS} - ${FATSECTORS}
FSSIZE!= expr ${FSSECTORS} \* 512
# parameters for disklabel and MBR
@@ -196,10 +213,14 @@ MBRHEADS= 255
MBRSECTORS= 63
MBRCYLINDERS!= expr ${IMAGESECTORS} / \( ${MBRHEADS} \* ${MBRSECTORS} \)
MBRNETBSD= 169
+MBRFAT?= 6 # 16-bit FAT, more than 32M
-BSDPARTSECTORS!= expr ${IMAGESECTORS} - ${LABELSECTORS} - ${EFISECTORS} - ${GPTSECTORS}
-FSOFFSET!= expr ${LABELSECTORS} + ${EFISECTORS}
-SWAPOFFSET!= expr ${LABELSECTORS} + ${FSSECTORS} + ${EFISECTORS}
+BSDPARTSECTORS!= expr ${IMAGESECTORS} - ${LABELSECTORS} \
+ - ${EFISECTORS} - ${GPTSECTORS} - ${FATSECTORS}
+FSOFFSET!= expr ${LABELSECTORS} + ${EFISECTORS} + ${FATSECTORS}
+SWAPOFFSET!= expr ${LABELSECTORS} + ${FSSECTORS} \
+ + ${EFISECTORS} + ${FATSECTORS}
+FATOFFSET= ${LABELSECTORS}
# parameters for sunlabel
FSCYLINDERS!= expr ${FSSECTORS} / \( ${HEADS} \* ${SECTORS} \)
@@ -227,6 +248,7 @@ FSTAB_IN?= ${DISTRIBDIR}/common/bootimag
SPEC_IN?= ${DISTRIBDIR}/common/bootimage/spec.in
IMGMAKEFSOPTIONS?= -o bsize=16384,fsize=2048,density=8192
+FATMAKEFSOPTIONS?= -o fat_type=16
WORKDIR?= work
WORKSPEC?= work.spec
@@ -267,6 +289,8 @@ WORKGPT?= work.gpt
WORKLABEL?= work.diskproto
WORKIMG?= work.img
EFIWORKDIR?= work.efidir
+WORKFAT?= work.fat
+WORKFATDIR?= work.fatdir
.if ${USE_GPT} != "no"
${WORKFSTAB}: ${WORKMBR}
@@ -388,6 +412,9 @@ TARGET_BLOCKS+= ${WORKMBRTRUNC}
.if ${USE_GPT} != "no"
TARGET_BLOCKS+= ${WORKEFI}
.endif
+.if ${FATSECTORS} != 0
+TARGET_BLOCKS+= ${WORKFAT}
+.endif
TARGET_BLOCKS+= ${TARGETFS}
.if ${SWAPSECTORS} != 0
TARGET_BLOCKS+= ${WORKSWAP}
@@ -398,6 +425,7 @@ TARGET_BLOCKS+= ${WORKGPT}
CLEANFILES+= ${WORKMBR} ${WORKMBRTRUNC} ${WORKSWAP}
CLEANFILES+= ${WORKEFI} ${WORKGPT}
+CLEANFILES+= ${WORKFAT}
CLEANFILES+= ${WORKLABEL}.tmp ${WORKLABEL}
CLEANFILES+= ${WORKIMG} ${IMGBASE}.img
@@ -423,6 +451,8 @@ ${WORKLABEL}:
-e "s/@@SWAPSECTORS@@/${SWAPSECTORS}/" \
-e "s/@@SWAPOFFSET@@/${SWAPOFFSET}/" \
-e "s/@@BSDPARTSECTORS@@/${BSDPARTSECTORS}/" \
+ -e "s/@@FATSECTORS@@/${FATSECTORS}/" \
+ -e "s/@@FATOFFSET@@/${FATOFFSET}/" \
< ${DISKPROTO_IN} > ${WORKLABEL}.tmp
mv ${WORKLABEL}.tmp ${WORKLABEL}
@@ -439,6 +469,26 @@ ${WORKEFI}: ${TARGETFS}
-t msdos -o F=32,c=1 \
${WORKEFI} ${EFIWORKDIR}
+${WORKFAT}: ${TARGETFS} ${FATFILES}
+ @echo create FAT partition for bootstrap files...
+ @${MKDIR} ${MKDIRPERM} ${WORKFATDIR}
+.if defined(FATFILES)
+ @echo Copying files for FAT partition...
+.for f in ${FATFILES}
+ @if [ ! -f ${f} ]; then \
+ echo "${f} in FATFILES not found, aborting"; \
+ false; \
+ fi
+ ${INSTALL} ${COPY} -m 0644 ${f} ${WORKFATDIR}
+.endfor
+.endif
+ ${RM} -f ${WORKFAT}
+ ${TOOL_MAKEFS} -M ${FATMB}m -m ${FATMB}m \
+ ${MAKEFS_TIMESTAMP} \
+ -t msdos \
+ ${FATMAKEFSOPTIONS} \
+ ${WORKFAT} ${WORKFATDIR}
+
${WORKMBR}:
.if ${USE_GPT} != "no"
@echo creating GPT header and partition entries...
@@ -453,10 +503,24 @@ ${WORKMBR}:
.elif ${USE_MBR} != "no"
@echo creating MBR labels...
${DD} if=/dev/zero of=${WORKMBR} seek=$$((${IMAGESECTORS} - 1)) count=1
+. if ${FATSECTORS} != 0
+ # create BSD partition
+ ${TOOL_FDISK} -f -i -u \
+ -b ${MBRCYLINDERS}/${MBRHEADS}/${MBRSECTORS} \
+ -1 -a -s ${MBRNETBSD}/${FSOFFSET}/${BSDPARTSECTORS} \
+ -F ${WORKMBR}
+ # create FAT partition
+ ${TOOL_FDISK} -f -u \
+ -b ${MBRCYLINDERS}/${MBRHEADS}/${MBRSECTORS} \
+ -0 -s ${MBRFAT}/${FATOFFSET}/${FATSECTORS} \
+ -F ${WORKMBR}
+. else
+ # create BSD partition
${TOOL_FDISK} -f -i -u \
-b ${MBRCYLINDERS}/${MBRHEADS}/${MBRSECTORS} \
-0 -a -s ${MBRNETBSD}/${FSOFFSET}/${BSDPARTSECTORS} \
-F ${WORKMBR}
+. endif
. if empty(MBR_BOOTCODE)
@if [ -f ${WORKDIR}/usr/mdec/${MBR_DEFAULT_BOOTCODE} ]; then \
echo ${TOOL_FDISK} -f \
@@ -520,6 +584,7 @@ clean:
fi # XXX
${RM} -fr ${WORKDIR}
${RM} -fr ${EFIWORKDIR}
+ ${RM} -fr ${WORKFATDIR}
prepare_md_post: .PHONY
image_md_post: .PHONY
Index: distrib/hpcarm/Makefile
===================================================================
RCS file: /cvsroot/src/distrib/hpcarm/Makefile,v
retrieving revision 1.6
diff -u -p -d -r1.6 Makefile
--- distrib/hpcarm/Makefile 19 Sep 2008 17:38:43 -0000 1.6
+++ distrib/hpcarm/Makefile 15 Mar 2020 17:22:21 -0000
@@ -4,9 +4,13 @@
.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
SUBDIR= instkernel stand cdroms
+SUBDIR+= liveimage
TARGETS+= release
iso_image:
${MAKEDIRTARGET} cdroms iso_image
+live_image:
+ ${MAKEDIRTARGET} liveimage live_image
+
.include <bsd.subdir.mk>
Index: distrib/zaurus/Makefile
===================================================================
RCS file: /cvsroot/src/distrib/zaurus/Makefile,v
retrieving revision 1.2
diff -u -p -d -r1.2 Makefile
--- distrib/zaurus/Makefile 29 May 2011 17:19:31 -0000 1.2
+++ distrib/zaurus/Makefile 15 Mar 2020 17:22:22 -0000
@@ -4,9 +4,13 @@
.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
SUBDIR= ramdisk .WAIT instkernel cdroms
+SUBDIR+= liveimage
TARGETS+= release
iso_image:
${MAKEDIRTARGET} cdroms iso_image
+live_image:
+ ${MAKEDIRTARGET} liveimage live_image
+
.include <bsd.subdir.mk>
--- /dev/null 2020-03-16 02:22:59.513742129 +0900
+++ distrib/common/bootimage/diskproto.mbrfat.in 2020-03-16 01:33:44.240196734 +0900
@@ -0,0 +1,26 @@
+# $NetBSD: diskproto.mbr.in,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+type: ESDI
+disk: image
+label:
+flags:
+bytes/sector: 512
+sectors/track: @@SECTORS@@
+tracks/cylinder: @@HEADS@@
+sectors/cylinder: @@SECPERCYLINDERS@@
+cylinders: @@CYLINDERS@@
+total sectors: @@IMAGESECTORS@@
+rpm: 3600
+interleave: 1
+trackskew: 0
+cylinderskew: 0
+headswitch: 0 # microseconds
+track-to-track seek: 0 # microseconds
+drivedata: 0
+
+8 partitions:
+# size offset fstype [fsize bsize cpg/sgs]
+a: @@FSSECTORS@@ @@FSOFFSET@@ 4.2BSD 1024 8192 16
+b: @@SWAPSECTORS@@ @@SWAPOFFSET@@ swap
+c: @@BSDPARTSECTORS@@ @@FSOFFSET@@ unused 0 0
+d: @@IMAGESECTORS@@ 0 unused 0 0
+e: @@FATSECTORS@@ @@FATOFFSET@@ MSDOS
--- /dev/null 2020-03-16 02:23:31.462414624 +0900
+++ distrib/hpcarm/liveimage/Makefile 2020-03-16 01:34:46.951975405 +0900
@@ -0,0 +1,40 @@
+# $NetBSD$
+
+LIVEIMGBASE= NetBSD-${DISTRIBVER}-${MACHINE}-live # gives ${IMGBASE}.img
+
+.include <bsd.own.mk>
+
+LIVEIMAGEMB?= 1920 # for 2GB SD due to Windows Mobile restriction
+SWAPMB?= 64
+FATMB?= 32
+
+USE_MBR= yes
+MBRFAT= 6 # 16-bit FAT, more than 32M
+
+# Omit comp etc. due to size restriction
+KERN_SET= kern-WZERO3
+SETS= base modules etc misc rescue text xbase xetc xfont xserver
+
+# prepare JORNADA720 kernel as an independent name
+prepare_md_post:
+ echo Extracting kern-JORNADA720.${TAR_SUFF} ...
+ ${TOOL_PAX} ${PAX_TIMESTAMP} -rn \
+ --use-compress-program=${COMPRESS_PROGRAM:Q} \
+ -f ${SETS_DIR}/kern-JORNADA720.${TAR_SUFF} .
+ mv netbsd netbsd.JORNADA720
+
+CLEANFILES+= netbsd.JORNADA720
+
+IMGFILE_EXTRA= \
+ ${.OBJDIR}/netbsd.JORNADA720 .
+
+DISKPROTO_IN= ${.CURDIR}/../../common/bootimage/diskproto.mbrfat.in
+FSTAB_IN= ${.CURDIR}/fstab.in
+SPEC_EXTRA= ${.CURDIR}/spec.in
+
+HPCBOOTDIR!= cd ${.CURDIR}/../stand && ${PRINTOBJDIR}
+FATFILES= ${HPCBOOTDIR}/hpcboot.exe
+FATFILES+= ${WORKDIR}/netbsd
+FATFILES+= ${WORKDIR}/netbsd.JORNADA720
+
+.include "${.CURDIR}/../../common/bootimage/Makefile.liveimage"
--- /dev/null 2020-03-16 02:23:31.462414624 +0900
+++ distrib/hpcarm/liveimage/fstab.in 2020-03-15 10:32:24.418280167 +0900
@@ -0,0 +1,7 @@
+ROOT.a / ffs rw 1 1
+ROOT.b none none sw 0 0
+ROOT.e /dos msdos rw 0 0
+ptyfs /dev/pts ptyfs rw 0 0
+kernfs /kern kernfs rw,noauto 0 0
+procfs /proc procfs rw,noauto 0 0
+tmpfs /var/shm tmpfs rw,-m1777,-sram%25 0 0
--- /dev/null 2020-03-16 02:23:31.462414624 +0900
+++ distrib/hpcarm/liveimage/spec.in 2020-03-15 10:32:24.418421198 +0900
@@ -0,0 +1,3 @@
+# $NetBSD$
+./netbsd.JORNADA720 type=file mode=0755 uname=root gname=wheel
+./dos type=dir mode=0755 uname=root gname=wheel
--- /dev/null 2020-03-16 02:24:25.920723538 +0900
+++ distrib/zaurus/liveimage/Makefile 2020-03-16 01:35:44.874270138 +0900
@@ -0,0 +1,39 @@
+# $NetBSD$
+
+LIVEIMGBASE= NetBSD-${DISTRIBVER}-zaurus-live # gives ${IMGBASE}.img
+
+.include <bsd.own.mk>
+
+LIVEIMAGEMB?= 900 # for "1GB" SD due to Zaurus Linux restriction
+SWAPMB?= 64
+FATMB?= 32
+
+USE_MBR= yes
+MBRFAT= 6 # 16-bit FAT, more than 32M
+
+# Omit comp etc. due to size restriction
+KERN_SET= kern-GENERIC
+SETS= base modules etc misc rescue text xbase xetc xfont xserver
+
+# prepare SL-C700 kernel as an independent name
+prepare_md_post:
+ echo Extracting kern-C700.${TAR_SUFF} ...
+ ${TOOL_PAX} ${PAX_TIMESTAMP} -rn \
+ --use-compress-program=${COMPRESS_PROGRAM:Q} \
+ -f ${SETS_DIR}/kern-C700.${TAR_SUFF} .
+ mv netbsd netbsd.c700
+
+CLEANFILES+= netbsd.c700
+
+IMGFILE_EXTRA= \
+ ${.OBJDIR}/netbsd.c700 .
+
+DISKPROTO_IN= ${.CURDIR}/../../common/bootimage/diskproto.mbrfat.in
+FSTAB_IN= ${.CURDIR}/fstab.in
+SPEC_EXTRA= ${.CURDIR}/spec.in
+
+FATFILES= ${WORKDIR}/usr/mdec/zbsdmod.o ${WORKDIR}/usr/mdec/zboot
+FATFILES+= ${WORKDIR}/netbsd
+FATFILES+= ${WORKDIR}/netbsd.c700
+
+.include "${.CURDIR}/../../common/bootimage/Makefile.liveimage"
--- /dev/null 2020-03-16 02:24:29.577178403 +0900
+++ distrib/zaurus/liveimage/fstab.in 2020-03-15 03:53:05.582594568 +0900
@@ -0,0 +1,7 @@
+ROOT.a / ffs rw 1 1
+ROOT.b none none sw 0 0
+ROOT.e /dos msdos rw 0 0
+ptyfs /dev/pts ptyfs rw 0 0
+kernfs /kern kernfs rw,noauto 0 0
+procfs /proc procfs rw,noauto 0 0
+tmpfs /var/shm tmpfs rw,-m1777,-sram%25 0 0
--- /dev/null 2020-03-16 02:24:47.119571207 +0900
+++ distrib/zaurus/liveimage/spec.in 2020-03-15 03:40:22.362575016 +0900
@@ -0,0 +1,3 @@
+# $NetBSD$
+./netbsd.c700 type=file mode=0755 uname=root gname=wheel
+./dos type=dir mode=0755 uname=root gname=wheel
---
See also PR/45153 and PR/45155 for the original implementation
of src/distrib/common/bootimage files.
https://mail-index.NetBSD.org/netbsd-bugs/2011/08/06/msg023639.html
https://mail-index.NetBSD.org/netbsd-bugs/2011/09/23/msg024207.html
https://mail-index.NetBSD.org/netbsd-bugs/2011/12/07/msg025166.html
https://mail-index.NetBSD.org/netbsd-bugs/2011/12/08/msg025178.html
---
Izumi Tsutsui
Home |
Main Index |
Thread Index |
Old Index