Skip to content

Commit 39d31d9

Browse files
boricjsambuc
authored andcommitted
ARM: Remove dependency on mtools
Instead of formatting the image, and then using the mtools to copy on it the boot partition files, we use makefs to directly generate the partition. Change-Id: I468e3100842177f3f55edbfdb910941bafa576ba
1 parent b67d2ae commit 39d31d9

File tree

1 file changed

+52
-83
lines changed

1 file changed

+52
-83
lines changed

releasetools/arm_sdimage.sh

+52-83
Original file line numberDiff line numberDiff line change
@@ -64,32 +64,8 @@ then
6464
exit 1
6565
fi
6666

67-
case $(uname -s) in
68-
Darwin)
69-
MKFS_VFAT_CMD=newfs_msdos
70-
MKFS_VFAT_OPTS="-h 64 -u 32 -S 512 -s ${FAT_SIZE} -o 0"
71-
;;
72-
FreeBSD)
73-
MKFS_VFAT_CMD=newfs_msdos
74-
MKFS_VFAT_OPTS=
75-
;;
76-
*)
77-
MKFS_VFAT_CMD=mkfs.vfat
78-
MKFS_VFAT_OPTS=
79-
;;
80-
esac
81-
8267
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:${PATH}
8368

84-
for needed in mcopy dd ${MKFS_VFAT_CMD} git
85-
do
86-
if ! which $needed 2>&1 > /dev/null
87-
then
88-
echo "**Skipping image creation: missing tool '$needed'"
89-
exit 1
90-
fi
91-
done
92-
9369
# we create a disk image of about 2 gig's
9470
# for alignment reasons, prefer sizes which are multiples of 4096 bytes
9571
: ${IMG_SIZE=$(( 2*(2**30) ))}
@@ -130,67 +106,9 @@ echo "Creating specification files..."
130106
create_input_spec
131107
create_protos "usr home"
132108

133-
#
134-
# Create the FAT partition, which contains the bootloader files, kernel and modules
135-
#
136-
dd if=/dev/zero of=${WORK_DIR}/fat.img bs=512 count=1 seek=$(($FAT_SIZE -1)) 2>/dev/null
137-
138-
#
139-
# Format the fat partition and put the bootloaders
140-
# uEnv and the kernel command line in the FAT partition
141-
#
142-
${MKFS_VFAT_CMD} ${MKFS_VFAT_OPTS} ${WORK_DIR}/fat.img
143-
144-
#
145109
# Download the stage 1 bootloader and u-boot
146110
#
147111
${RELEASETOOLSDIR}/fetch_u-boot.sh -o ${RELEASETOOLSDIR}/u-boot -n $U_BOOT_GIT_VERSION
148-
cp ${RELEASETOOLSDIR}/u-boot/${U_BOOT_BIN_DIR}/MLO ${WORK_DIR}/
149-
cp ${RELEASETOOLSDIR}/u-boot/${U_BOOT_BIN_DIR}/u-boot.img ${WORK_DIR}/
150-
151-
#
152-
# Create a uEnv.txt file
153-
# -n default to network boot
154-
# -p add a prefix to the network booted files (e.g. xm/"
155-
# -c set console e.g. tty02 or tty00
156-
# -v set verbosity e.g. 0 to 3
157-
#${RELEASETOOLSDIR}/gen_uEnv.txt.sh -c ${CONSOLE} -n -p bb/ > ${WORK_DIR}/uEnv.txt
158-
${RELEASETOOLSDIR}/gen_uEnv.txt.sh -c ${CONSOLE} > ${WORK_DIR}/uEnv.txt
159-
160-
echo "Copying configuration kernel and boot modules"
161-
mcopy -bsp -i ${WORK_DIR}/fat.img ${WORK_DIR}/$MLO ::MLO
162-
mcopy -bsp -i ${WORK_DIR}/fat.img ${WORK_DIR}/$UBOOT ::u-boot.img
163-
mcopy -bsp -i ${WORK_DIR}/fat.img ${WORK_DIR}/uEnv.txt ::uEnv.txt
164-
165-
#
166-
# Do some last processing of the kernel and servers and then put them on the FAT
167-
# partition.
168-
#
169-
${CROSS_PREFIX}objcopy ${OBJ}/minix/kernel/kernel -O binary ${OBJ}/kernel.bin
170-
mcopy -bsp -i ${WORK_DIR}/fat.img ${OBJ}/kernel.bin ::kernel.bin
171-
172-
for f in servers/vm/vm servers/rs/rs servers/pm/pm servers/sched/sched \
173-
servers/vfs/vfs servers/ds/ds servers/mib/mib fs/pfs/pfs fs/mfs/mfs \
174-
../sbin/init/init
175-
do
176-
fn=`basename $f`.elf
177-
cp ${OBJ}/minix/${f} ${OBJ}/${fn}
178-
${CROSS_PREFIX}strip -s ${OBJ}/${fn}
179-
mcopy -bsp -i ${WORK_DIR}/fat.img ${OBJ}/${fn} ::${fn}
180-
done
181-
182-
for f in tty/tty/tty storage/memory/memory
183-
do
184-
fn=`basename $f`.elf
185-
cp ${OBJ}/minix/drivers/${f} ${OBJ}/${fn}
186-
${CROSS_PREFIX}strip -s ${OBJ}/${fn}
187-
mcopy -bsp -i ${WORK_DIR}/fat.img ${OBJ}/${fn} ::${fn}
188-
done
189-
190-
#
191-
# For tftp booting
192-
#
193-
cp ${WORK_DIR}/uEnv.txt ${OBJ}/
194112

195113
# Clean image
196114
if [ -f ${IMG} ] # IMG might be a block device
@@ -222,12 +140,63 @@ HOME_START=$((${USR_START} + ${_USR_SIZE}))
222140
echo " * HOME"
223141
_HOME_SIZE=$(${CROSS_TOOLS}/nbmkfs.mfs -d ${HOMESIZEARG} -I $((${HOME_START}*512)) ${IMG} ${WORK_DIR}/proto.home)
224142
_HOME_SIZE=$(($_HOME_SIZE / 512))
143+
echo " * BOOT"
144+
rm -rf ${ROOT_DIR}/*
145+
cp ${RELEASETOOLSDIR}/u-boot/${U_BOOT_BIN_DIR}/MLO ${ROOT_DIR}/
146+
cp ${RELEASETOOLSDIR}/u-boot/${U_BOOT_BIN_DIR}/u-boot.img ${ROOT_DIR}/
147+
148+
# Create a uEnv.txt file
149+
# -n default to network boot
150+
# -p add a prefix to the network booted files (e.g. xm/"
151+
# -c set console e.g. tty02 or tty00
152+
# -v set verbosity e.g. 0 to 3
153+
#${RELEASETOOLSDIR}/gen_uEnv.txt.sh -c ${CONSOLE} -n -p bb/ > ${WORK_DIR}/uEnv.txt
154+
${RELEASETOOLSDIR}/gen_uEnv.txt.sh -c ${CONSOLE} > ${ROOT_DIR}/uEnv.txt
155+
156+
# Do some last processing of the kernel and servers and then put them on the FAT
157+
# partition.
158+
${CROSS_PREFIX}objcopy ${OBJ}/minix/kernel/kernel -O binary ${ROOT_DIR}/kernel.bin
159+
160+
for f in servers/vm/vm servers/rs/rs servers/pm/pm servers/sched/sched \
161+
servers/vfs/vfs servers/ds/ds servers/mib/mib fs/pfs/pfs fs/mfs/mfs \
162+
../sbin/init/init drivers/tty/tty/tty drivers/storage/memory/memory
163+
do
164+
fn=`basename $f`.elf
165+
cp ${OBJ}/minix/${f} ${ROOT_DIR}/${fn}
166+
${CROSS_PREFIX}strip -s ${ROOT_DIR}/${fn}
167+
done
168+
cat >${WORK_DIR}/boot.mtree <<EOF
169+
. type=dir
170+
./MLO type=file
171+
./u-boot.img type=file
172+
./uEnv.txt type=file
173+
./kernel.bin type=file
174+
./ds.elf type=file
175+
./rs.elf type=file
176+
./pm.elf type=file
177+
./sched.elf type=file
178+
./vfs.elf type=file
179+
./memory.elf type=file
180+
./tty.elf type=file
181+
./mib.elf type=file
182+
./vm.elf type=file
183+
./pfs.elf type=file
184+
./mfs.elf type=file
185+
./init.elf type=file
186+
EOF
187+
188+
#
189+
# Create the FAT partition, which contains the bootloader files, kernel and modules
190+
#
191+
${CROSS_TOOLS}/nbmakefs -t msdos -s ${FAT_SIZE}b -o F=16,c=1 \
192+
-F ${WORK_DIR}/boot.mtree ${WORK_DIR}/fat.img ${ROOT_DIR}
225193

226194
#
227195
# Write the partition table using the natively compiled
228196
# minix partition utility
229197
#
230-
${CROSS_TOOLS}/nbpartition -f -m ${IMG} ${FAT_START} "c:${FAT_SIZE}*" 81:${_ROOT_SIZE} 81:${_USR_SIZE} 81:${_HOME_SIZE}
198+
${CROSS_TOOLS}/nbpartition -f -m ${IMG} ${FAT_START} \
199+
"c:${FAT_SIZE}*" 81:${_ROOT_SIZE} 81:${_USR_SIZE} 81:${_HOME_SIZE}
231200

232201
#
233202
# Merge the partitions into a single image.

0 commit comments

Comments
 (0)