Cross-compiling picobsd

Jacques Fourie jacques.fourie at gmail.com
Thu Mar 12 08:29:33 PDT 2009


Hi,

I've made some very crude modifications to picobsd that allowed me to
cross-compile images for my gumstix platform. In case this helps
anyone, I'll post the diffs here. I found it very helpful to have a
kernel.gz.tramp with an embedded MFS that I could boot from.

Jacques
-------------- next part --------------
--- a/release/picobsd/build/Makefile.conf
+++ b/release/picobsd/build/Makefile.conf
@@ -21,7 +21,8 @@ MODULES?=-DNO_MODULES	# do not build them as a default
 # If config were smart enough, we could place the config
 # file in some other place than ${SRC}/sys/i386/conf, but
 # at the moment (Oct.2001) this is not possible yet.
-CONF=${SRC}/sys/i386/conf
+#CONF=${SRC}/sys/i386/conf
+CONF=${SRC}/sys/${TARGET_ARCH}/conf
 #CONF=${BUILDDIR}/conf         # XXX does not work yet
 CONFFILE=PICOBSD-${name}
 
@@ -39,10 +40,19 @@ ${BUILDDIR}/kernel: ${KERNFILE}
 ${KERNFILE}: ${COMPILE} do_a_make_in_the_kernel_directory_anyways
 
 do_a_make_in_the_kernel_directory_anyways:
+	unset TARGET_CPUTYPE
+	unset TARGET_BIG_ENDIAN
 	(cd ${COMPILE}; ${BINMAKE} KERNEL=kernel ${MODULES} )
 
+trampoline:
+	unset TARGET_CPUTYPE
+	unset TARGET_BIG_ENDIAN
+	(cd ${COMPILE}; ${BINMAKE} KERNEL=kernel ${MODULES} trampoline )
+
 ${COMPILE}: ${CONF}/${CONFFILE}
-	(cd ${CONF}; ${CONFIG} -d ${COMPILE} ${CONFFILE}; \
+	unset TARGET_CPUTYPE
+	unset TARGET_BIG_ENDIAN
+	(cd ${CONF}; PATH=${TMPPATH} ${CONFIG} -d ${COMPILE} ${CONFFILE}; \
 	cd ${COMPILE}; ${BINMAKE} KERNEL=kernel ${MODULES} depend )
 
 ${CONF}/${CONFFILE}: PICOBSD
--- /dev/null
+++ b/release/picobsd/build/build.sh
@@ -0,0 +1 @@
+./picobsd --target_arch arm --target_cputype xscale --src /home/jacques/gumstix -n -v gumstix 
diff --git a/release/picobsd/build/picobsd b/release/picobsd/build/picobsd
index a3b3cf5..14235ff 100755
--- a/release/picobsd/build/picobsd
+++ b/release/picobsd/build/picobsd
@@ -21,6 +21,7 @@
 #   Makefile.conf	Makefile used to build the kernel
 #   config		shell variables, sourced here.
 #   mfs.mtree		mtree config file
+#
 #   floppy.tree/	files which go on the floppy
 #   mfs_tree/		files which go onto the mfs
 #
@@ -28,13 +29,10 @@
 #   PICOBSD		kernel config file
 #   config		shell variables, sourced here.
 #   crunch.conf		crunchgen configuration
-#   mfs.mtree		overrides ${PICO_TREE}/mfs.mtree
 #   floppy.tree.exclude	files from floppy.tree/ which we do not need here.
-#   floppy.tree/	local additions to ${PICO_TREE}/mfs_free
+#   floppy.tree/	local additions to the floppy.tree
 #   floppy.tree.${site}/ same as above, site specific.
 #   mfs_tree/		local additions to the mfs_free
-#   buildtree.mk	optional makefile to build an extension for floppy tree
-#			(generated in buildtree/ )
 
 #
 #--- The main entry point is at the end.
@@ -100,7 +98,7 @@ set_defaults() {
     EDITOR=${EDITOR:-vi}
     fd_size=${fd_size:-1440}
 
-    o_use_loader="yes"		# use /boot/loader
+    o_target_arch="i386"
     o_all_in_mfs="yes"		# put all files in mfs so you can boot and run
 				# the image via diskless boot.
     o_clean=""			# do not clean
@@ -109,7 +107,7 @@ set_defaults() {
     o_tarv=""			# tar verbose flag, "" or "v"
     o_init_src=""		# non "" if we need to init libs and includes.
     o_makeopts=${MAKEOPTS:--s}	# make options, be silent by default
-    o_no_devfs=yes		# we do not want devfs
+    o_no_devfs=""		# we do not want devfs
     o_do_modules=""		# do not build modules
 
     SRC="/usr/src"		# default location for sources
@@ -130,7 +128,6 @@ set_defaults() {
     				# mountpoint used to build memory filesystems
     c_fs=fs.PICOBSD		# filename used for the memory filesystem
     c_img=picobsd.bin		# filename used for the picobsd image
-    generate_iso="NO"		# don't generate the iso image
 
     # select the right memory disk name
     case `uname -r` in
@@ -150,7 +147,6 @@ set_defaults() {
     trap fail 15
 }
 
-# use the new build infrastructure
 create_includes_and_libraries2() {
     local no
     log "create_includes_and_libraries2() for ${SRC}"
@@ -163,7 +159,7 @@ create_includes_and_libraries2() {
     export MAKEOBJDIRPREFIX
     ( cd ${SRC};
     # make -DNOCLEAN -DNOPROFILE -DNOGAMES -DNOLIBC_R -DPICOBSD buildworld
-    make _+_= $no toolchain _includes _libraries
+    make _+_= $no toolchain
     )
 }
 
@@ -212,7 +208,7 @@ create_includes_and_libraries() {
 
 # set_type <type> looks in user or system directories for the floppy type
 # specified as first argument, and sets variables according to the config.
-# file. Also sets MY_TREE and BUILDDIR and SITE
+# file. Sets THETYPE, SITE, name, MY_TREE and BUILDDIR
 
 set_type() {
     local a i
@@ -260,13 +256,6 @@ set_msgs() {		# OK
 \t3.  Site-info: ${SITE}\n\t4.  Full-path: ${MY_TREE}\n"
 }
 
-# build the iso image
-build_iso_image() {
-    log "build_iso_image()"
-    clear
-    set_msgs
-    printf "${MSG}---> Build the iso image not ready yet\n\n"
-}
 
 # Main build procedure.
 build_image() {
@@ -292,14 +281,18 @@ build_image() {
     if [ ${OSVERSION} -ge 500035 ] ; then
 	export MAKEOBJDIRPREFIX=${l_objtree}
 	eval "export BINMAKE=\"`cd ${SRC}; make -f Makefile -V BINMAKE`\""
+	eval "export TMPPATH=\"`cd ${SRC}; make -f Makefile.inc1 -V TMPPATH`\""
 	eval export `cd ${SRC}; ${BINMAKE} -f Makefile.inc1 -V WMAKEENV`
     fi
+    echo ${PATH}
     # create build directory and subtree
     mkdir -p ${BUILDDIR}/crunch
     # remove any old stuff
     rm -f ${BUILDDIR}/kernel.gz ${BUILDDIR}/${c_fs}
     # invoke commands to build a kernel
     do_kernel
+
+    export TARGET_CPUTYPE		
     # fill a subdirectory with things that go into the floppy
     # (mostly /etc and similar stuff)
     populate_floppy_fs
@@ -319,6 +312,10 @@ build_package() {
     echo "##############################################" >>build.status
     for z in bridge dial router net isp ; do
 	set_type ${z}
+        if [ "${name}" = "" ] ; then
+	    echo "*** TYPE=${z} not found" >>build.status
+	    continue
+	fi
 	echo "---------------------------------------------">>build.status
 	echo "Building TYPE=${z}, SIZE=${MFS_SIZE}" >>build.status
 	msg="(ok)"	# error message
@@ -435,9 +432,14 @@ this as small as possible. " 10 70 2> ${c_reply} \
 do_install() {
     log "do_install()"
 
+    if [ "${o_target_arch}" = "arm" ] ; then
+	echo "Bootable ARM trampoline is in
+	${BUILDDIR}/PICOBSD-${name}/kernel.gz.tramp"
+    fi
+
     if [ "${o_interactive}" = "NO" ] ; then
 	echo "+++ Build completed +++"
-	cat .build.reply || true
+#cat .build.reply || true
 	return
     fi
     dialog --title "Build ${THETYPE} completed" --inputbox \
@@ -474,6 +476,13 @@ do_kernel() {		# OK
 	fail $? missing_kernel
 }
 
+rebuild_trampoline() {
+    log "rebuild_trampoline() Re-building kernel trampoline \"$name\" in $MY_TREE"
+    (cd $MY_TREE; export name SRC BUILDDIR # used in this makefile ;
+    	${BINMAKE} -v -f ${PICO_TREE}/build/Makefile.conf trampoline ) || \
+	fail $? missing_kernel
+}
+
 # Populate the variable part of the floppy filesystem. Must be done before
 # the MFS because its content might need to be copied there as well.
 #
@@ -492,10 +501,10 @@ populate_floppy_fs() {		# OK
     dst=${BUILDDIR}/floppy.tree
     log "pwd=`pwd` Populating floppy filesystem..."
 
-    rm -rf ${dst} || true	# clean relics from old compilations.
-    mkdir ${dst}		# create a clean tree
+    # clean relics from old compilations.
+    rm -rf ${dst} || true
+    mkdir ${dst}
 
-    # compute exclude list for generic tree
     excl=${MY_TREE}/floppy.tree.exclude
     if [ -f ${excl} ] ; then
 	log "Files excluded from generic tree: `echo;cat ${excl}`"
@@ -503,26 +512,29 @@ populate_floppy_fs() {		# OK
     else
 	excl=""
     fi
-    # copy from the floppy trees into the destination
-    for FLOPPY_TREE in ${PICO_TREE}/floppy.tree ${MY_TREE}/floppy.tree \
-		${MY_TREE}/floppy.tree.${SITE} ; do
-	if [ -d ${FLOPPY_TREE} ] ; then
-	    (cd ${FLOPPY_TREE} ; tar -cf - --exclude CVS \
-		    --exclude .svn ${excl} . ) | \
+    (cd ${PICO_TREE}/floppy.tree ; tar -cf - --exclude CVS --exclude .svn \
+    		${excl} . ) | \
 		(cd ${dst} ; tar x${o_tarv}f - )
-	    log "Copied from ${FLOPPY_TREE}"
-	fi
-	excl="" # reset the exclude list.
-    done
-
-    # add local manipulation
-    if [ -f ${MY_TREE}/buildtree.mk ] ; then
-	log "building local floppy tree"
-	${BINMAKE} -C ${dst} -f ${MY_TREE}/buildtree.mk floppy.tree
+    log "Copied from generic floppy-tree `echo; ls -laR ${dst}`"
+
+    srcdir=${MY_TREE}/floppy.tree
+    if [ -d ${srcdir} ] ; then
+	log "update with type-specific files:"
+	(cd ${srcdir} ; tar -cf - --exclude CVS --exclude .svn . ) | \
+	    (cd ${dst} ; tar x${o_tarv}f - )
+	log "Copied from type floppy-tree `echo; ls -laR ${dst}`"
+    else
+	log "No type-specific floppy-tree"
     fi
- 
-    # compress the files in etc/, just in case
-    # XXX this should be done in the makefile.
+    if [ -d ${srcdir}.${SITE} ] ; then
+	log "Update with site-specific (${SITE}) files:"
+	(cd ${srcdir}.${SITE} ; tar -cf - --exclude CVS --exclude .svn . ) | \
+	    (cd ${dst} ; tar x${o_tarv}f - )
+	log "Copied from site floppy-tree `echo; ls -laR ${dst}`"
+    else
+	log "No site-specific floppy-tree"
+    fi
+
     # gzip returns an error if it fails to compress some file
     (cd $dst ; gzip -9 etc/*
 	    log "Compressed files in etc/ `echo; ls -l etc`"
@@ -537,12 +549,13 @@ populate_floppy_fs() {		# OK
 # Finally, if required, make a copy of the floppy.tree onto /fd
 
 populate_mfs_tree() {
-    local a dst MFS_TREE
+    local a dst
 
     log "populate_mfs_tree()"
     dst=${BUILDDIR}/mfs.tree
-    rm -rf ${dst} || true	# clean relics from old compilations.
-    mkdir ${dst}		# create a fresh tree
+    # clean relics from old compilations.
+    rm -rf ${dst} || true
+    mkdir ${dst}
 
     log "pwd=`pwd`, Populating MFS tree..."
 
@@ -559,7 +572,7 @@ populate_mfs_tree() {
     ln -s /dev/null ${dst}/var/run/log
     ln -s /etc/termcap ${dst}/usr/share/misc/termcap
 
-    ### now build the crunched binaries ###
+
     (
     cd ${BUILDDIR}/crunch
     log "Making and installing crunch1 from `pwd` src ${SRC}..."
@@ -603,18 +616,12 @@ populate_mfs_tree() {
 	fi
     done
 
-    if [ -f ${MY_TREE}/buildtree.mk ] ; then
-	log "building local floppy tree"
-	${BINMAKE} -C ${dst} -f ${MY_TREE}/buildtree.mk mfs.tree
-    fi
-
     if [ "${o_all_in_mfs}" = "yes" ]; then
 	log "Copy generic floppy_tree into MFS..."
-	# ignore failure in case the floppy is empty
+	# this may fail in case the floppy is empty
 	cp -Rp ${BUILDDIR}/floppy.tree/* ${dst}/fd || true
     fi
 
-    # 4.x compatibility - create device nodes
     if [ "${o_no_devfs}" != "" ] ; then
 	# create device entries using MAKEDEV
 	(cd ${dst}/dev
@@ -633,21 +640,19 @@ populate_mfs_tree() {
 	log "importing ${import_files} into mfs"
 	# We do it in a chroot environment on the target so
 	# symlinks are followed correctly.
-	# Make sure we have a statically linked tar there.
-	mkdir -p ${dst}/rescue
-	cp /rescue/tar ${dst}/rescue
+	cp `which tar` ${dst}/my_copy_of_tar
 	(cd ${l_usrtree}/.. ; tar cf - ${import_files} ) | \
-	    (chroot ${dst} /rescue/tar xPf - )
-	rm -rf ${dst}/rescue
+	    (chroot ${dst} /my_copy_of_tar xf - )
+	rm ${dst}/my_copy_of_tar
     fi
 
     (cd ${BUILDDIR}
 	# override the owner
 	echo "/set uid=0 gid=0" > mtree.out
-	mtree -ic -p ${dst} -k "" >> mtree.out
+	mtree -c -p ${dst} -k "" >> mtree.out
 	log "mtre.out at ${BUILDDIR}/mtree.out"
 	makefs -t ffs -o bsize=4096 -o fsize=512 \
-		-s ${MFS_SIZE}k -f 1000 -F mtree.out ${c_fs} ${dst}
+		-s ${MFS_SIZE}k -f 100 -F mtree.out ${c_fs} ${dst}
 	ls -l ${c_fs} )
     log "done mfs image"
 }
@@ -723,107 +728,107 @@ fill_floppy_image() {
 	blocks=1476
     fi
 
-    log "Labeling floppy image"
-    b2=${BUILDDIR}/boot2 # modified boot2
-    cp -f ${c_boot2} ${b2}
-    chmod 0644 ${b2}
+    if [ "${o_target_arch}" != "arm" ]; then
+	    log "Labeling floppy image"
+	    log "patch ${c_boot2} to boot /kernel right away"
+	    b2=${BUILDDIR}/boot2 # modified boot2
+	    cp -f ${c_boot2} ${b2}
+	    chmod 0644 ${b2}
 
-    if [ ${o_use_loader} = "no" ] ; then
-	log "patch ${c_boot2} to boot /kernel right away"
-	set `strings -at d ${b2} | grep "/boot/loader"`
-	echo -e "/kernel\0\0\0\0\0" | \
+	    set `strings -at d ${b2} | grep "/boot/loader"`
+	    echo -e "/kernel\0\0\0\0\0" | \
 	    dd of=${b2} obs=$1 oseek=1 conv=notrunc 2>/dev/null
+	    chmod 0444 ${b2}
     fi
-    chmod 0444 ${b2}
 
     dst=${BUILDDIR}/image.tree
     rm -rf ${dst}
     mkdir -p ${dst}
-    (
-    cd ${BUILDDIR}
-    set 0 0 # reset variables
-    # $1 takes the offset of the MFS filesystem
-    set `strings -at d kernel | grep "MFS Filesystem goes here"`
-    mfs_start=$1
-    set 0 0 # reset variables
-    set `strings -at d kernel | grep "MFS Filesystem had better"`
-    mfs_end=$1
-    mfs_size="$((${mfs_end} - ${mfs_start}))"
-    set -- `ls -l ${c_fs}`; imgsize="$5"
-    if [ ${mfs_start} -gt 0 -a ${mfs_size} -ge ${imgsize} ] ; then
-	mfs_ofs=$((${mfs_start} + 8192))
-	log "Preload kernel with file ${c_fs} at ${mfs_ofs}"
-	logverbose "`ls -l ${c_fs}` to fit in ${mfs_size}"
-	dd if=${c_fs} ibs=8192 iseek=1 of=kernel obs=${mfs_ofs} \
-	    oseek=1 conv=notrunc # 2> /dev/null
-    else
-    	log "not loading mfs, size ${mfs_size} img ${imgsize}"
-    fi
-    log "Compress with kgzip and copy to floppy image"
-    if [ ${o_use_loader} = "no" ] ; then
-	kgzip -o kernel.gz kernel
-	cp -p kernel.gz ${dst}/kernel || fail $? no_space "copying kernel"
+    mykern=${BUILDDIR}/PICOBSD-${name}/kernel.debug
+    if [ "${o_target_arch}" = "arm" ] ; then
+	    (
+    	    cd ${BUILDDIR}
+	    set 0 0 # reset variables
+	    # $1 takes the offset of the MFS filesystem
+	    set `strings -at d ${mykern} | grep "MFS Filesystem goes here"`
+	    mfs_start=$1
+	    set 0 0 # reset variables
+	    set `strings -at d ${mykern} | grep "MFS Filesystem had better"`
+	    mfs_end=$1
+	    mfs_size="$((${mfs_end} - ${mfs_start}))"
+	    set -- `ls -l ${c_fs}`; imgsize="$5"
+	    if [ ${mfs_start} -gt 0 -a ${mfs_size} -ge ${imgsize} ] ; then
+		log "Preload kernel with file ${c_fs} at ${mfs_start}"
+		mfs_ofs=$((${mfs_start} + 8192))
+		dd if=${c_fs} ibs=8192 iseek=1 of=${mykern} obs=${mfs_ofs} \
+		    oseek=1 conv=notrunc 2> /dev/null
+	    else
+		log "not loading mfs, size ${mfs_size} img ${imgsize}"
+	    fi
+	    )
+	    rebuild_trampoline
     else
-        gzip kernel
-	mkdir -p  ${dst}/boot/kernel
-	echo "hint.acpi.0.disabled=\"1\"" > ${dst}/boot/loader.conf
-	echo "console=\"comconsole\"" >> ${dst}/boot/loader.conf
-	cp -p /boot/loader ${dst}/boot/loader || fail $? no_space "copying bootloader"
-	cp -p kernel.gz ${dst}/boot/kernel/kernel.gz || fail $? no_space "copying kernel"
-    fi
-
-    # now transfer the floppy tree. If it is already in mfs, dont bother.
-    if [ "${o_all_in_mfs}" != "yes" ] ; then
-	log "Now transfer floppy tree if not already in MFS image"
-	cp -Rp floppy.tree/* ${dst} || \
-		fail $? no_space "copying floppy tree"
-    fi
-    )
-
-    # add local manipulation to the image
-    if [ -f ${MY_TREE}/buildtree.mk ] ; then
-	${BINMAKE} -C ${dst} -f ${MY_TREE}/buildtree.mk image.tree
-    fi
-
-    log "image used `du -s ${dst}` of ${blocks}k"
-    (cd ${BUILDDIR}
-    makefs -t ffs -o bsize=4096 -o fsize=512 \
-	-s ${blocks}k -f 50 ${c_img} ${dst}
-    # ${l_label} -f `pwd`/${c_img}
-    ${l_label} -w -f `pwd`/${c_img} auto # write in a label
-    # copy partition c: into a: with some sed magic
-    ${l_label} -f `pwd`/${c_img} | sed -e '/  c:/{p;s/c:/a:/;}' | \
-	${l_label} -R -f `pwd`/${c_img} /dev/stdin
-    ${l_label} -f `pwd`/${c_img}
-
-    ls -l ${c_img}
-    ${l_label} -f `pwd`/${c_img}
-    logverbose "after disklabel"
-    )
-
-    echo "BUILDDIR ${BUILDDIR}"
-    if [ "${generate_iso}" = "YES" ]; then
-	echo "generate_iso ${generate_iso}"
-	#build_iso_image()
-	exit 1
+	    (
+	    cd ${BUILDDIR}
+	    set 0 0 # reset variables
+	    # $1 takes the offset of the MFS filesystem
+	    set `strings -at d kernel | grep "MFS Filesystem goes here"`
+	    mfs_start=$1
+	    set 0 0 # reset variables
+	    set `strings -at d kernel | grep "MFS Filesystem had better"`
+	    mfs_end=$1
+	    mfs_size="$((${mfs_end} - ${mfs_start}))"
+	    set -- `ls -l ${c_fs}`; imgsize="$5"
+	    if [ ${mfs_start} -gt 0 -a ${mfs_size} -ge ${imgsize} ] ; then
+		mfs_ofs=$((${mfs_start} + 8192))
+		log "Preload kernel with file ${c_fs} at ${mfs_ofs}"
+		dd if=${c_fs} ibs=8192 iseek=1 of=kernel obs=${mfs_ofs} \
+		    oseek=1 conv=notrunc 2> /dev/null
+	    else
+		log "not loading mfs, size ${mfs_size} img ${imgsize}"
+	    fi
+	    log "Compress with kgzip and copy to floppy image"
+	    kgzip -o kernel.gz kernel
+	    cp -p kernel.gz ${dst}/kernel || fail $? no_space "copying kernel"
+
+	    log "Now transfer floppy tree if not already in MFS image"
+	    # now transfer the floppy tree. If it is already in mfs, dont bother.
+	    if [ "${o_all_in_mfs}" != "yes" ] ; then
+		cp -Rp floppy.tree/* ${dst} || \
+			fail $? no_space "copying floppy tree"
+	    fi
+	    )
+    fi		    
+
+    if [ "${o_target_arch}" != "arm" ] ; then
+	    (cd ${BUILDDIR}
+	    makefs -t ffs -o bsize=4096 -o fsize=512 \
+		-s ${blocks}k -f 50 ${c_img} ${dst}
+	    # ${l_label} -f `pwd`/${c_img}
+	    ${l_label} -w -f `pwd`/${c_img} auto # write in a label
+	    # copy partition c: into a: with some sed magic
+	    ${l_label} -f `pwd`/${c_img} | sed -e '/  c:/{p;s/c:/a:/;}' | \
+		${l_label} -R -f `pwd`/${c_img} /dev/stdin
+	    ${l_label} -f `pwd`/${c_img}
+	    ls -l ${c_img}
+		logverbose "after disklabel"
+		 )
+	    # dump the primary and secondary boot
+	    # XXX primary is 512 bytes
+	    dd if=${c_boot1} of=${BUILDDIR}/${c_img} conv=notrunc 2>/dev/null
+	    # XXX secondary starts after the 0x114 = dec 276 bytes of the label
+	    # so we skip 276 from the source, and 276+512=788 from dst
+	    # the old style blocks used 512 and 1024 respectively
+
+	    dd if=${b2} iseek=1 ibs=276 2> /dev/null | \
+		dd of=${BUILDDIR}/${c_img} oseek=1 obs=788 conv=notrunc 2>/dev/null
+	    logverbose "done floppy image"
     fi
-
-    # dump the primary and secondary boot
-    # XXX primary is 512 bytes
-    dd if=${c_boot1} of=${BUILDDIR}/${c_img} conv=notrunc 2>/dev/null
-    # XXX secondary starts after the 0x114 = dec 276 bytes of the label
-    # so we skip 276 from the source, and 276+512=788 from dst
-    # the old style blocks used 512 and 1024 respectively
-
-    dd if=${b2} iseek=1 ibs=276 2> /dev/null | \
-	dd of=${BUILDDIR}/${c_img} oseek=1 obs=788 conv=notrunc 2>/dev/null
-    logverbose "done floppy image"
     # XXX (log "Fixing permissions"; cd ${dst}; chown -R root *)
     rm -rf ${BUILDDIR}/floppy.tree || true # cleanup
     # df -ik ${dst} | colrm 70 > .build.reply
     rm -rf ${dst}
-    rm ${BUILDDIR}/${c_fs}
-    # rm ${BUILDDIR}/kernel.gz
+    rm -f ${BUILDDIR}/kernel.gz ${BUILDDIR}/${c_fs}
 }
 
 # This function creates variables which depend on the source tree in use:
@@ -866,8 +871,19 @@ set_build_parameters() {
 # arguments.
 
 set_defaults
-while [ true ]; do
+args=""
+while [ x"$1" != x ]; do
     case $1 in
+    --target_arch)
+    	o_target_arch=$2
+    	TARGET_ARCH=$2
+	export TARGET_ARCH
+	shift
+	;;
+    --target_cputype)
+	TARGET_CPUTYPE=$2
+    	shift
+	;;	
     --src)	# set the source path instead of /usr/src
 	SRC=`(cd $2; pwd)`
 	shift
@@ -881,17 +897,12 @@ while [ true ]; do
 	shift
 	;;
 
-    --no_loader)	# omit /boot/loader, just rely on boot2
-			# (it may have problems with kernels > 4MB)
-	o_use_loader="no"
-	;;
-
     --all_in_mfs)
 	o_all_in_mfs="yes"
 	;;
 
     --no_all_in_mfs)
-	o_all_in_mfs="no"
+	o_all_in_mfs=""
 	;;
 
     --modules)	# also build kernel modules
@@ -911,24 +922,21 @@ while [ true ]; do
 	o_tarv="v"			# tar verbose flag
 	o_makeopts="-d l" # be verbose
 	;;
-
-    --iso) # generate iso image
-	generate_iso="YES"
-	;;
-
     *)
-	break
+	args="$args $1"			# accumulate args
 	;;
 
     esac
     shift
 done
 set_build_parameters	# things that depend on ${SRC}
-set_type $1 $2		# type and site, respectively
 
 # If $1="package", it creates a neat set of floppies
+set -- ${args}
 [ "$1" = "package" ] && build_package
 
+set_type $args		# type and site, respectively
+
 [ "${o_interactive}" != "NO" ] && main_dialog
 
 if [ "${o_clean}" = "YES" ] ; then
--- /dev/null
+++ b/release/picobsd/build/readme.arm
@@ -0,0 +1,14 @@
+Building PICOBSD ARM images
+---------------------------
+<srcdir> is the directory where the FreeBSD source tree lives.
+
+Create suitable cross-compiling environment:
+--------------------------------------------
+cd <srcdir>
+make TARGET_ARCH=arm TARGET_CPUTYPE=xscale buildworld
+mkdir -p ../usr
+ln -s /usr/obj/ ../usr/obj-pico
+
+Build PICOBSD
+-------------
+./picobsd --target_arch arm --target_cputype xscale --src <srcdir> -n -v gumstix 


More information about the freebsd-arm mailing list