* [ptxdist] [PATCH 1/2] Add host-parted @ 2012-03-26 12:01 Bernhard Walle 2012-03-26 12:01 ` [ptxdist] [PATCH 2/2] Allow creation of bootable SD card for OMAP CPUs Bernhard Walle 2012-03-27 14:22 ` [ptxdist] [PATCH 1/2] Add host-parted Michael Olbrich 0 siblings, 2 replies; 12+ messages in thread From: Bernhard Walle @ 2012-03-26 12:01 UTC (permalink / raw) To: ptxdist; +Cc: Bernhard Walle Signed-off-by: Bernhard Walle <walle@corscience.de> --- platforms/hosttools.in | 1 + rules/host-parted.in | 8 ++++++++ rules/host-parted.make | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 rules/host-parted.in create mode 100644 rules/host-parted.make diff --git a/platforms/hosttools.in b/platforms/hosttools.in index e9ce0fc..10d05e8 100644 --- a/platforms/hosttools.in +++ b/platforms/hosttools.in @@ -18,6 +18,7 @@ source "rules/host-mkelfImage.in" source "rules/host-mtd-utils.in" source "rules/host-mtools.in" source "rules/host-openssl.in" +source "rules/host-parted.in" source "rules/host-squashfs-tools.in" source "rules/host-u-boot-tools.in" source "rules/host-util-linux-ng.in" diff --git a/rules/host-parted.in b/rules/host-parted.in new file mode 100644 index 0000000..d150ffd --- /dev/null +++ b/rules/host-parted.in @@ -0,0 +1,8 @@ +## SECTION=hosttools_noprompt + +config HOST_PARTED + bool + default ALLYES + help + The well-known parted program + diff --git a/rules/host-parted.make b/rules/host-parted.make new file mode 100644 index 0000000..9655f5d --- /dev/null +++ b/rules/host-parted.make @@ -0,0 +1,38 @@ +# -*-makefile-*- +# +# Copyright (C) 2006 by Robert Schwebel +# 2009 by Marc Kleine-Budde <mkl@pengutronix.de> +# +# See CREDITS for details about who has contributed to this project. +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +# +# We provide this package +# +HOST_PACKAGES-$(PTXCONF_HOST_PARTED) += host-parted + +# +# Paths and names +# +HOST_PARTED = $(PARTED) +HOST_PARTED_DIR = $(HOST_BUILDDIR)/$(HOST_PARTED) + +# ---------------------------------------------------------------------------- +# Prepare +# ---------------------------------------------------------------------------- + +HOST_PARTED_ENV := $(HOST_ENV) + +# +# autoconf +# +HOST_PARTED_AUTOCONF := $(HOST_AUTOCONF) \ + --disable-device-mapper \ + --disable-Werror + +HOST_PARTED_INSTALL_OPT := install + +# vim: syntax=make -- 1.7.9.4 -- ptxdist mailing list ptxdist@pengutronix.de ^ permalink raw reply [flat|nested] 12+ messages in thread
* [ptxdist] [PATCH 2/2] Allow creation of bootable SD card for OMAP CPUs 2012-03-26 12:01 [ptxdist] [PATCH 1/2] Add host-parted Bernhard Walle @ 2012-03-26 12:01 ` Bernhard Walle 2012-04-10 11:32 ` Andreas Bießmann 2012-04-10 12:01 ` Andreas Bießmann 2012-03-27 14:22 ` [ptxdist] [PATCH 1/2] Add host-parted Michael Olbrich 1 sibling, 2 replies; 12+ messages in thread From: Bernhard Walle @ 2012-03-26 12:01 UTC (permalink / raw) To: ptxdist; +Cc: Bernhard Walle With the new option IMAGE_OMAPSD it's possible to create an image for OMAP-bootable SD cards. Tested with a devkit8000 and a virtual beagle board (qemu). See the comment in platforms/image_omapsd.in for more information. Signed-off-by: Bernhard Walle <walle@corscience.de> --- platforms/image_omapsd.in | 48 +++++++++++++ rules/post/image_omapsd.make | 32 +++++++++ scripts/genomapsdimg | 160 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 240 insertions(+) create mode 100644 platforms/image_omapsd.in create mode 100644 rules/post/image_omapsd.make create mode 100755 scripts/genomapsdimg diff --git a/platforms/image_omapsd.in b/platforms/image_omapsd.in new file mode 100644 index 0000000..ef6c5e4 --- /dev/null +++ b/platforms/image_omapsd.in @@ -0,0 +1,48 @@ +## SECTION=image + +menuconfig IMAGE_OMAPSD + bool + select IMAGE_VFAT_TOOLS + select HOST_PARTED + select IMAGE_EXT2 + depends on ARCH_ARM + prompt "Generate OMAP bootable SD card" + help + Creates an bootable SD card for OMAP CPUs, for example for the beagle board. + The resulting image is called "omap_sd.img". You can copy it with "dd" + on a raw SD card, without partitioning. + + The SD card contains two file systems: + 1) A FAT file system that contains MLO, a bootloader and a Linux kernel + (plus additional files like an initramfs). + 2) The root file system as ext3 file system. + + OMAP has special requirements regarding the geometry of partition table, + and the location of MLO, that's why a fixed image makes more sense here + than copying the files manually. + +if IMAGE_OMAPSD + +config IMAGE_OMAPSD_BOOTLOADER + string + default "u-boot.img" + prompt "Bootloader file" + help + The name of the bootloader that should be copied to the SD card. If you use + u-boot SPL, then "u-boot.img" is the right choice here. If you still use + x-loader, then "u-boot.bin" should be copied. Also barebox can be used + with its MLO. The file must reside in the images directory of the platform. + +config IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES + string + default "" + prompt "Additional files for the boot partition" + help + A (whitespace separated) list of additional files can be specified here. + The files get copied in the boot partition (1st FAT partition). They must + be in the images/ directory of the platform that is built. One example is + a uRamdisk that gets loaded by the bootloader. + +endif + +# vim: set sw=8 ts=8 noet ft=kconfig: diff --git a/rules/post/image_omapsd.make b/rules/post/image_omapsd.make new file mode 100644 index 0000000..3741106 --- /dev/null +++ b/rules/post/image_omapsd.make @@ -0,0 +1,32 @@ +# -*-makefile-*- +# +# Copyright (C) 2012 by the ptxdist project <ptxdist@pengutronix.de> +# +# See CREDITS for details about who has contributed to this project. +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +SEL_ROOTFS-$(PTXCONF_IMAGE_OMAPSD) += $(IMAGEDIR)/omap_sd.img + +# preprend the $(IMAGEDIR) if PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES is not +# empty +ifneq ($(PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES),"") +PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES_FULL := \ + $(addprefix $(IMAGEDIR)/, $(PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES)) +endif + +$(IMAGEDIR)/omap_sd.img: $(IMAGEDIR)/root.ext2 + @ln -sf $(IMAGEDIR)/linuximage $(IMAGEDIR)/uImage + @echo "Creating bootable SD card for OMAP"; \ + PATH=$(PTXCONF_SYSROOT_HOST)/bin:$$PATH $(PTXDIST_TOPDIR)/scripts/genomapsdimg \ + -m $(IMAGEDIR)/MLO \ + -b $(IMAGEDIR)/u-boot.img \ + -k $(IMAGEDIR)/uImage \ + -f $(IMAGEDIR)/root.ext2 \ + -a "$(PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES_FULL)" \ + -o $@ + @echo "done." + +# vim: syntax=make diff --git a/scripts/genomapsdimg b/scripts/genomapsdimg new file mode 100755 index 0000000..9c87e45 --- /dev/null +++ b/scripts/genomapsdimg @@ -0,0 +1,160 @@ +#!/bin/bash + +# Creates a OMAP bootable SD card. +# The image has a PC-style partition table with two partitions: +# +# 1) a FAT partition with MLO, bootloader and a Linux kernel +# 2) a ext3 partition with the root file system. +# +# That's a bit tricky because the OMAP needs a special partition table +# (therefore, genpart cannot be used). +# +# Parts of the script have been copied from 'debian-cd' (post-boot-armel). + +# exit on error +set -e + +usage() { +cat <<-EOF + +Usage: `basename "$0"` OPTIONS + + -h this help + -m <mlo> path to the MLO file (SPL) + -b <bootloader> path to the bootloader + -k <kernel> path to the linux kernel + -a <file> additional file that should be included in the FAT partition + (e.g. a FTD or an initramfs). Multiple files can be specified + using whitespace separation. Don't forget to quote. + -f <filesystem> the (ext3) file system image for the second partition + -o <output> the output file that should be written + +EOF +} + +file_length() +{ + stat -c %s "$1" +} + +create_partitions() +{ + local boot_size="$((72 * 1024 * 1024))" # 72 MB for the partition + local image_size="$(file_length "${FILESYSTEM}")" + local img_size_blocks="$(((${boot_size} + ${image_size} + 512 - 1) / 512))" + + dd if=/dev/zero of="${OUTPUT}" bs=512 count=0 seek="${img_size_blocks}" >/dev/null 2>&1 + + local trg_size="$(file_length "${OUTPUT}")" + local cylinders=$(echo ${trg_size}/255/63/512 | bc) + + { + echo ,9,0x0C,* + echo ,,,- + } | sfdisk -D -H 255 -S 63 -C ${cylinders} "${OUTPUT}" >/dev/null 2>&1 +} + +check_input() +{ + if ! [ -r "${MLO}" ] ; then + echo "MLO '${MLO}' does not exist." + usage + exit 1 + fi + + if ! [ -r "${BOOTLOADER}" ] ; then + echo "Bootloader '${BOOTLOADER}' does not exist." + usage + exit 1 + fi + + if ! [ -r "${KERNEL}" ] ; then + echo "Kernel '${KERNEL}' does not exist." + usage + exit 1 + fi + + if ! [ -r "${FILESYSTEM}" ] ; then + echo "File system image '${FILESYSTEM}' does not exist." + usage + exit 1 + fi +} + +create_filesystem() +{ + local vatstart=$(parted "${OUTPUT}" unit B print 2>/dev/null|grep "^ 1"|awk '{print $2}') + local vatsize=$(LANG=C fdisk -l "${OUTPUT}" 2>/dev/null|grep W95 |awk '{print $5}') + + mkdosfs -F 32 -C "${OUTPUT_FAT}" "${vatsize}" >/dev/null 2>&1 +} + +copy_files() +{ + export MTOOLS_SKIP_CHECK=1 + + # it's important to copy the MLO first + mcopy -i "${OUTPUT_FAT}" "${MLO}" ::MLO + mcopy -i "${OUTPUT_FAT}" "${BOOTLOADER}" "::$(basename "${BOOTLOADER}")" + mcopy -i "${OUTPUT_FAT}" "${KERNEL}" "::$(basename "${KERNEL}")" + + # copy additional files (like FTD or an initramfs) + if [ -n "$ADDITIONAL_FILES" ] ; then + for file in ${ADDITIONAL_FILES} ; do + local targetname=$(basename "${file}") + mcopy -i "${OUTPUT_FAT}" "${file}" "::${targetname}" + done + fi +} + +create_image() +{ + # now put the whole vfat into the first partition + local vatstart=$(parted "${OUTPUT}" unit B print 2>/dev/null | grep "^ 1" | awk '{print $2}') + + dd conv=notrunc bs="${vatstart%B}" if="${OUTPUT_FAT}" of="${OUTPUT}" seek=1 >/dev/null 2>&1 + rm "${OUTPUT_FAT}" + + # put ext3 content into the second partition + local ext3start=$(parted "${OUTPUT}" unit B print 2>/dev/null | grep "^ 2" | awk '{print $2}') + dd conv=notrunc bs="${ext3start%B}" if="${FILESYSTEM}" of="${OUTPUT}" seek=1 >/dev/null 2>&1 +} + + +# command line parsing + +while getopts hm:b:k:a:f:o: name ; do + case $name in + m) MLO="${OPTARG}" + ;; + b) BOOTLOADER="${OPTARG}" + ;; + k) KERNEL="${OPTARG}" + ;; + a) ADDITIONAL_FILES="${OPTARG}" + ;; + f) FILESYSTEM="${OPTARG}" + ;; + o) OUTPUT="${OPTARG}" + ;; + h) usage + exit 0 + ;; + *) usage + exit 1 + ;; + esac +done + +OUTPUT_FAT="${OUTPUT}.vfat" +[ -r "${OUTPUT_FAT}" ] && rm "${OUTPUT_FAT}" + +check_input +create_partitions +create_filesystem +copy_files +create_image + +echo "${OUTPUT} ready" + +# vim: set sw=4 ts=4 noet: -- 1.7.9.4 -- ptxdist mailing list ptxdist@pengutronix.de ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [ptxdist] [PATCH 2/2] Allow creation of bootable SD card for OMAP CPUs 2012-03-26 12:01 ` [ptxdist] [PATCH 2/2] Allow creation of bootable SD card for OMAP CPUs Bernhard Walle @ 2012-04-10 11:32 ` Andreas Bießmann 2012-04-10 12:49 ` Bernhard Walle 2012-04-10 12:01 ` Andreas Bießmann 1 sibling, 1 reply; 12+ messages in thread From: Andreas Bießmann @ 2012-04-10 11:32 UTC (permalink / raw) To: ptxdist; +Cc: Bernhard Walle, Bernhard Walle On 26.03.2012 14:01, Bernhard Walle wrote: > With the new option IMAGE_OMAPSD it's possible to create an image for > OMAP-bootable SD cards. Tested with a devkit8000 and a virtual beagle > board (qemu). > > See the comment in platforms/image_omapsd.in for more information. > > Signed-off-by: Bernhard Walle <walle@corscience.de> > --- > platforms/image_omapsd.in | 48 +++++++++++++ > rules/post/image_omapsd.make | 32 +++++++++ > scripts/genomapsdimg | 160 ++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 240 insertions(+) > create mode 100644 platforms/image_omapsd.in > create mode 100644 rules/post/image_omapsd.make > create mode 100755 scripts/genomapsdimg > > diff --git a/platforms/image_omapsd.in b/platforms/image_omapsd.in > new file mode 100644 > index 0000000..ef6c5e4 > --- /dev/null > +++ b/platforms/image_omapsd.in > @@ -0,0 +1,48 @@ > +## SECTION=image > + > +menuconfig IMAGE_OMAPSD > + bool > + select IMAGE_VFAT_TOOLS > + select HOST_PARTED > + select IMAGE_EXT2 > + depends on ARCH_ARM > + prompt "Generate OMAP bootable SD card" > + help > + Creates an bootable SD card for OMAP CPUs, for example for the beagle board. > + The resulting image is called "omap_sd.img". You can copy it with "dd" > + on a raw SD card, without partitioning. > + > + The SD card contains two file systems: > + 1) A FAT file system that contains MLO, a bootloader and a Linux kernel > + (plus additional files like an initramfs). > + 2) The root file system as ext3 file system. can we make the second ext3 filesystem optional? Anyway, it could be done in a second step. Would be great to get this tool into 2012.05! > + > + OMAP has special requirements regarding the geometry of partition table, > + and the location of MLO, that's why a fixed image makes more sense here > + than copying the files manually. > + > +if IMAGE_OMAPSD > + > +config IMAGE_OMAPSD_BOOTLOADER > + string > + default "u-boot.img" > + prompt "Bootloader file" > + help > + The name of the bootloader that should be copied to the SD card. If you use > + u-boot SPL, then "u-boot.img" is the right choice here. If you still use > + x-loader, then "u-boot.bin" should be copied. Also barebox can be used > + with its MLO. The file must reside in the images directory of the platform. > + > +config IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES > + string > + default "" > + prompt "Additional files for the boot partition" > + help > + A (whitespace separated) list of additional files can be specified here. > + The files get copied in the boot partition (1st FAT partition). They must > + be in the images/ directory of the platform that is built. One example is > + a uRamdisk that gets loaded by the bootloader. > + > +endif > + > +# vim: set sw=8 ts=8 noet ft=kconfig: > diff --git a/rules/post/image_omapsd.make b/rules/post/image_omapsd.make > new file mode 100644 > index 0000000..3741106 > --- /dev/null > +++ b/rules/post/image_omapsd.make > @@ -0,0 +1,32 @@ > +# -*-makefile-*- > +# > +# Copyright (C) 2012 by the ptxdist project <ptxdist@pengutronix.de> your copyright? > +# > +# See CREDITS for details about who has contributed to this project. > +# > +# For further information about the PTXdist project and license conditions > +# see the README file. > +# > + > +SEL_ROOTFS-$(PTXCONF_IMAGE_OMAPSD) += $(IMAGEDIR)/omap_sd.img > + > +# preprend the $(IMAGEDIR) if PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES is not > +# empty > +ifneq ($(PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES),"") > +PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES_FULL := \ > + $(addprefix $(IMAGEDIR)/, $(PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES)) > +endif > + > +$(IMAGEDIR)/omap_sd.img: $(IMAGEDIR)/root.ext2 > + @ln -sf $(IMAGEDIR)/linuximage $(IMAGEDIR)/uImage alternatively provide a Kconfig option for renaming $(IMAGEDIR)/linuximage? > + @echo "Creating bootable SD card for OMAP"; \ > + PATH=$(PTXCONF_SYSROOT_HOST)/bin:$$PATH $(PTXDIST_TOPDIR)/scripts/genomapsdimg \ > + -m $(IMAGEDIR)/MLO \ > + -b $(IMAGEDIR)/u-boot.img \ use IMAGE_OMAPSD_BOOTLOADER variable here! > + -k $(IMAGEDIR)/uImage \ > + -f $(IMAGEDIR)/root.ext2 \ > + -a "$(PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES_FULL)" \ > + -o $@ cleanup $(IMAGEDIR)/uImage? > + @echo "done." > + > +# vim: syntax=make > diff --git a/scripts/genomapsdimg b/scripts/genomapsdimg > new file mode 100755 > index 0000000..9c87e45 > --- /dev/null > +++ b/scripts/genomapsdimg > @@ -0,0 +1,160 @@ > +#!/bin/bash copyright? > + > +# Creates a OMAP bootable SD card. > +# The image has a PC-style partition table with two partitions: > +# > +# 1) a FAT partition with MLO, bootloader and a Linux kernel > +# 2) a ext3 partition with the root file system. > +# > +# That's a bit tricky because the OMAP needs a special partition table > +# (therefore, genpart cannot be used). > +# > +# Parts of the script have been copied from 'debian-cd' (post-boot-armel). > + > +# exit on error > +set -e > + > +usage() { > +cat <<-EOF > + > +Usage: `basename "$0"` OPTIONS > + > + -h this help > + -m <mlo> path to the MLO file (SPL) > + -b <bootloader> path to the bootloader > + -k <kernel> path to the linux kernel > + -a <file> additional file that should be included in the FAT partition > + (e.g. a FTD or an initramfs). Multiple files can be specified > + using whitespace separation. Don't forget to quote. > + -f <filesystem> the (ext3) file system image for the second partition > + -o <output> the output file that should be written > + > +EOF > +} > + > +file_length() > +{ > + stat -c %s "$1" > +} > + > +create_partitions() > +{ > + local boot_size="$((72 * 1024 * 1024))" # 72 MB for the partition > + local image_size="$(file_length "${FILESYSTEM}")" > + local img_size_blocks="$(((${boot_size} + ${image_size} + 512 - 1) / 512))" > + > + dd if=/dev/zero of="${OUTPUT}" bs=512 count=0 seek="${img_size_blocks}" >/dev/null 2>&1 > + > + local trg_size="$(file_length "${OUTPUT}")" > + local cylinders=$(echo ${trg_size}/255/63/512 | bc) > + > + { > + echo ,9,0x0C,* > + echo ,,,- > + } | sfdisk -D -H 255 -S 63 -C ${cylinders} "${OUTPUT}" >/dev/null 2>&1 catch possible error (in some tests I didn't had sfdisk in $PATH; took some time to find this out ;). > +} > + > +check_input() > +{ > + if ! [ -r "${MLO}" ] ; then > + echo "MLO '${MLO}' does not exist." > + usage > + exit 1 > + fi > + > + if ! [ -r "${BOOTLOADER}" ] ; then > + echo "Bootloader '${BOOTLOADER}' does not exist." > + usage > + exit 1 > + fi > + > + if ! [ -r "${KERNEL}" ] ; then > + echo "Kernel '${KERNEL}' does not exist." > + usage > + exit 1 > + fi > + > + if ! [ -r "${FILESYSTEM}" ] ; then > + echo "File system image '${FILESYSTEM}' does not exist." > + usage > + exit 1 > + fi > +} > + > +create_filesystem() > +{ > + local vatstart=$(parted "${OUTPUT}" unit B print 2>/dev/null|grep "^ 1"|awk '{print $2}') > + local vatsize=$(LANG=C fdisk -l "${OUTPUT}" 2>/dev/null|grep W95 |awk '{print $5}') > + > + mkdosfs -F 32 -C "${OUTPUT_FAT}" "${vatsize}" >/dev/null 2>&1 catch error on tool missing? > +} > + > +copy_files() > +{ > + export MTOOLS_SKIP_CHECK=1 > + > + # it's important to copy the MLO first > + mcopy -i "${OUTPUT_FAT}" "${MLO}" ::MLO > + mcopy -i "${OUTPUT_FAT}" "${BOOTLOADER}" "::$(basename "${BOOTLOADER}")" > + mcopy -i "${OUTPUT_FAT}" "${KERNEL}" "::$(basename "${KERNEL}")" > + > + # copy additional files (like FTD or an initramfs) > + if [ -n "$ADDITIONAL_FILES" ] ; then > + for file in ${ADDITIONAL_FILES} ; do > + local targetname=$(basename "${file}") > + mcopy -i "${OUTPUT_FAT}" "${file}" "::${targetname}" > + done > + fi > +} > + > +create_image() > +{ > + # now put the whole vfat into the first partition > + local vatstart=$(parted "${OUTPUT}" unit B print 2>/dev/null | grep "^ 1" | awk '{print $2}') > + > + dd conv=notrunc bs="${vatstart%B}" if="${OUTPUT_FAT}" of="${OUTPUT}" seek=1 >/dev/null 2>&1 > + rm "${OUTPUT_FAT}" > + > + # put ext3 content into the second partition > + local ext3start=$(parted "${OUTPUT}" unit B print 2>/dev/null | grep "^ 2" | awk '{print $2}') > + dd conv=notrunc bs="${ext3start%B}" if="${FILESYSTEM}" of="${OUTPUT}" seek=1 >/dev/null 2>&1 > +} > + > + > +# command line parsing > + > +while getopts hm:b:k:a:f:o: name ; do > + case $name in > + m) MLO="${OPTARG}" > + ;; > + b) BOOTLOADER="${OPTARG}" > + ;; > + k) KERNEL="${OPTARG}" > + ;; > + a) ADDITIONAL_FILES="${OPTARG}" > + ;; > + f) FILESYSTEM="${OPTARG}" > + ;; > + o) OUTPUT="${OPTARG}" > + ;; > + h) usage > + exit 0 > + ;; > + *) usage > + exit 1 > + ;; > + esac > +done > + > +OUTPUT_FAT="${OUTPUT}.vfat" > +[ -r "${OUTPUT_FAT}" ] && rm "${OUTPUT_FAT}" > + > +check_input > +create_partitions > +create_filesystem > +copy_files > +create_image > + > +echo "${OUTPUT} ready" > + > +# vim: set sw=4 ts=4 noet: best regards Andreas Bießmann -- ptxdist mailing list ptxdist@pengutronix.de ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [ptxdist] [PATCH 2/2] Allow creation of bootable SD card for OMAP CPUs 2012-04-10 11:32 ` Andreas Bießmann @ 2012-04-10 12:49 ` Bernhard Walle 0 siblings, 0 replies; 12+ messages in thread From: Bernhard Walle @ 2012-04-10 12:49 UTC (permalink / raw) To: Andreas Bießmann; +Cc: ptxdist Hi, * Andreas Bießmann <biessmann@corscience.de> [2012-04-10 13:32]: > > can we make the second ext3 filesystem optional? > Anyway, it could be done in a second step. Would be great to get this > tool into 2012.05! I would like to get that mainline first and add additional features, if needed, later. > > +# -*-makefile-*- > > +# > > +# Copyright (C) 2012 by the ptxdist project <ptxdist@pengutronix.de> > > your copyright? Honestly, I don't care. But I changed it now to be consistent. > > +# > > +# See CREDITS for details about who has contributed to this project. > > +# > > +# For further information about the PTXdist project and license conditions > > +# see the README file. > > +# > > + > > +SEL_ROOTFS-$(PTXCONF_IMAGE_OMAPSD) += $(IMAGEDIR)/omap_sd.img > > + > > +# preprend the $(IMAGEDIR) if PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES is not > > +# empty > > +ifneq ($(PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES),"") > > +PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES_FULL := \ > > + $(addprefix $(IMAGEDIR)/, $(PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES)) > > +endif > > + > > +$(IMAGEDIR)/omap_sd.img: $(IMAGEDIR)/root.ext2 > > + @ln -sf $(IMAGEDIR)/linuximage $(IMAGEDIR)/uImage > > alternatively provide a Kconfig option for renaming $(IMAGEDIR)/linuximage? I fear that breaks too much. > > + @echo "Creating bootable SD card for OMAP"; \ > > + PATH=$(PTXCONF_SYSROOT_HOST)/bin:$$PATH $(PTXDIST_TOPDIR)/scripts/genomapsdimg \ > > + -m $(IMAGEDIR)/MLO \ > > + -b $(IMAGEDIR)/u-boot.img \ > > use IMAGE_OMAPSD_BOOTLOADER variable here! Indeed. > > + -k $(IMAGEDIR)/uImage \ > > + -f $(IMAGEDIR)/root.ext2 \ > > + -a "$(PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES_FULL)" \ > > + -o $@ > > cleanup $(IMAGEDIR)/uImage? Done. > > index 0000000..9c87e45 > > --- /dev/null > > +++ b/scripts/genomapsdimg > > @@ -0,0 +1,160 @@ > > +#!/bin/bash > > copyright? Added. > catch possible error (in some tests I didn't had sfdisk in $PATH; took > some time to find this out ;). The script was not designed to get executed standalone. But well, I removed the 'set -e' and added some error messages. Please check. > > +create_filesystem() > > +{ > > + local vatstart=$(parted "${OUTPUT}" unit B print 2>/dev/null|grep "^ 1"|awk '{print $2}') > > + local vatsize=$(LANG=C fdisk -l "${OUTPUT}" 2>/dev/null|grep W95 |awk '{print $5}') > > + > > + mkdosfs -F 32 -C "${OUTPUT_FAT}" "${vatsize}" >/dev/null 2>&1 > > catch error on tool missing? It is not missing, it would have no effect because I added 'set -e'. The script aborts and has no chance to output an error. But as I mentioned above, I removed 'set -e' and added an error message here and at some more places. Regards, Bernhard -- ptxdist mailing list ptxdist@pengutronix.de ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [ptxdist] [PATCH 2/2] Allow creation of bootable SD card for OMAP CPUs 2012-03-26 12:01 ` [ptxdist] [PATCH 2/2] Allow creation of bootable SD card for OMAP CPUs Bernhard Walle 2012-04-10 11:32 ` Andreas Bießmann @ 2012-04-10 12:01 ` Andreas Bießmann 2012-04-10 12:54 ` Bernhard Walle 1 sibling, 1 reply; 12+ messages in thread From: Andreas Bießmann @ 2012-04-10 12:01 UTC (permalink / raw) To: ptxdist; +Cc: Bernhard Walle, Bernhard Walle Hi, On 26.03.2012 14:01, Bernhard Walle wrote: > With the new option IMAGE_OMAPSD it's possible to create an image for > OMAP-bootable SD cards. Tested with a devkit8000 and a virtual beagle > board (qemu). > > See the comment in platforms/image_omapsd.in for more information. > > Signed-off-by: Bernhard Walle <walle@corscience.de> > --- > platforms/image_omapsd.in | 48 +++++++++++++ > rules/post/image_omapsd.make | 32 +++++++++ > scripts/genomapsdimg | 160 ++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 240 insertions(+) > create mode 100644 platforms/image_omapsd.in > create mode 100644 rules/post/image_omapsd.make > create mode 100755 scripts/genomapsdimg > <snip> > diff --git a/scripts/genomapsdimg b/scripts/genomapsdimg > new file mode 100755 > index 0000000..9c87e45 > --- /dev/null > +++ b/scripts/genomapsdimg > @@ -0,0 +1,160 @@ > +#!/bin/bash > + > +# Creates a OMAP bootable SD card. > +# The image has a PC-style partition table with two partitions: > +# > +# 1) a FAT partition with MLO, bootloader and a Linux kernel > +# 2) a ext3 partition with the root file system. > +# > +# That's a bit tricky because the OMAP needs a special partition table > +# (therefore, genpart cannot be used). > +# > +# Parts of the script have been copied from 'debian-cd' (post-boot-armel). > + > +# exit on error > +set -e > + > +usage() { > +cat <<-EOF > + > +Usage: `basename "$0"` OPTIONS > + > + -h this help > + -m <mlo> path to the MLO file (SPL) > + -b <bootloader> path to the bootloader > + -k <kernel> path to the linux kernel > + -a <file> additional file that should be included in the FAT partition > + (e.g. a FTD or an initramfs). Multiple files can be specified > + using whitespace separation. Don't forget to quote. > + -f <filesystem> the (ext3) file system image for the second partition > + -o <output> the output file that should be written > + > +EOF > +} > + > +file_length() > +{ > + stat -c %s "$1" > +} > + > +create_partitions() > +{ > + local boot_size="$((72 * 1024 * 1024))" # 72 MB for the partition > + local image_size="$(file_length "${FILESYSTEM}")" > + local img_size_blocks="$(((${boot_size} + ${image_size} + 512 - 1) / 512))" > + > + dd if=/dev/zero of="${OUTPUT}" bs=512 count=0 seek="${img_size_blocks}" >/dev/null 2>&1 > + > + local trg_size="$(file_length "${OUTPUT}")" > + local cylinders=$(echo ${trg_size}/255/63/512 | bc) avoid bc here, drop trg_size: local cylinders=$(( $(file_length "${OUTPUT}")/255/63/512 )) rest looks good to me beside already mentioned error handling for used tools (provide proper messages). best regards Andreas Bießmann -- ptxdist mailing list ptxdist@pengutronix.de ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [ptxdist] [PATCH 2/2] Allow creation of bootable SD card for OMAP CPUs 2012-04-10 12:01 ` Andreas Bießmann @ 2012-04-10 12:54 ` Bernhard Walle 2012-04-10 15:03 ` [ptxdist] [PATCH v2 1/2] Add host-parted Bernhard Walle 2012-04-10 15:26 ` [ptxdist] [PATCH v3 1/2] Add host-parted Bernhard Walle 0 siblings, 2 replies; 12+ messages in thread From: Bernhard Walle @ 2012-04-10 12:54 UTC (permalink / raw) To: Andreas Bießmann; +Cc: ptxdist * Andreas Bießmann <biessmann@corscience.de> [2012-04-10 14:01]: > > + > > + dd if=/dev/zero of="${OUTPUT}" bs=512 count=0 seek="${img_size_blocks}" >/dev/null 2>&1 > > + > > + local trg_size="$(file_length "${OUTPUT}")" > > + local cylinders=$(echo ${trg_size}/255/63/512 | bc) > > avoid bc here, drop trg_size: > > local cylinders=$(( $(file_length "${OUTPUT}")/255/63/512 )) Using builtin $(()) instead of bc is good but I like to keep trg_size. Regards, Bernhard -- ptxdist mailing list ptxdist@pengutronix.de ^ permalink raw reply [flat|nested] 12+ messages in thread
* [ptxdist] [PATCH v2 1/2] Add host-parted 2012-04-10 12:54 ` Bernhard Walle @ 2012-04-10 15:03 ` Bernhard Walle 2012-04-10 15:03 ` [ptxdist] [PATCH v2 2/2] Allow creation of bootable SD card for OMAP CPUs Bernhard Walle 2012-04-10 15:26 ` [ptxdist] [PATCH v3 1/2] Add host-parted Bernhard Walle 1 sibling, 1 reply; 12+ messages in thread From: Bernhard Walle @ 2012-04-10 15:03 UTC (permalink / raw) To: ptxdist; +Cc: Bernhard Walle Signed-off-by: Bernhard Walle <walle@corscience.de> --- platforms/hosttools.in | 1 + rules/host-parted.in | 8 ++++++++ rules/host-parted.make | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 rules/host-parted.in create mode 100644 rules/host-parted.make diff --git a/platforms/hosttools.in b/platforms/hosttools.in index e9ce0fc..10d05e8 100644 --- a/platforms/hosttools.in +++ b/platforms/hosttools.in @@ -18,6 +18,7 @@ source "rules/host-mkelfImage.in" source "rules/host-mtd-utils.in" source "rules/host-mtools.in" source "rules/host-openssl.in" +source "rules/host-parted.in" source "rules/host-squashfs-tools.in" source "rules/host-u-boot-tools.in" source "rules/host-util-linux-ng.in" diff --git a/rules/host-parted.in b/rules/host-parted.in new file mode 100644 index 0000000..d150ffd --- /dev/null +++ b/rules/host-parted.in @@ -0,0 +1,8 @@ +## SECTION=hosttools_noprompt + +config HOST_PARTED + bool + default ALLYES + help + The well-known parted program + diff --git a/rules/host-parted.make b/rules/host-parted.make new file mode 100644 index 0000000..9655f5d --- /dev/null +++ b/rules/host-parted.make @@ -0,0 +1,38 @@ +# -*-makefile-*- +# +# Copyright (C) 2006 by Robert Schwebel +# 2009 by Marc Kleine-Budde <mkl@pengutronix.de> +# +# See CREDITS for details about who has contributed to this project. +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +# +# We provide this package +# +HOST_PACKAGES-$(PTXCONF_HOST_PARTED) += host-parted + +# +# Paths and names +# +HOST_PARTED = $(PARTED) +HOST_PARTED_DIR = $(HOST_BUILDDIR)/$(HOST_PARTED) + +# ---------------------------------------------------------------------------- +# Prepare +# ---------------------------------------------------------------------------- + +HOST_PARTED_ENV := $(HOST_ENV) + +# +# autoconf +# +HOST_PARTED_AUTOCONF := $(HOST_AUTOCONF) \ + --disable-device-mapper \ + --disable-Werror + +HOST_PARTED_INSTALL_OPT := install + +# vim: syntax=make -- 1.7.10 -- ptxdist mailing list ptxdist@pengutronix.de ^ permalink raw reply [flat|nested] 12+ messages in thread
* [ptxdist] [PATCH v2 2/2] Allow creation of bootable SD card for OMAP CPUs 2012-04-10 15:03 ` [ptxdist] [PATCH v2 1/2] Add host-parted Bernhard Walle @ 2012-04-10 15:03 ` Bernhard Walle 2012-04-10 15:25 ` Bernhard Walle 0 siblings, 1 reply; 12+ messages in thread From: Bernhard Walle @ 2012-04-10 15:03 UTC (permalink / raw) To: ptxdist; +Cc: Bernhard Walle With the new option IMAGE_OMAPSD it's possible to create an image for OMAP-bootable SD cards. Tested with a devkit8000 and a virtual beagle board (qemu). See the comment in platforms/image_omapsd.in for more information. Signed-off-by: Bernhard Walle <walle@corscience.de> --- platforms/image_omapsd.in | 48 +++++++++++ rules/host-parted.in | 3 - rules/host-parted.make | 20 +---- rules/post/image_omapsd.make | 33 ++++++++ scripts/genomapsdimg | 188 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 272 insertions(+), 20 deletions(-) create mode 100644 platforms/image_omapsd.in create mode 100644 rules/post/image_omapsd.make create mode 100755 scripts/genomapsdimg diff --git a/platforms/image_omapsd.in b/platforms/image_omapsd.in new file mode 100644 index 0000000..ef6c5e4 --- /dev/null +++ b/platforms/image_omapsd.in @@ -0,0 +1,48 @@ +## SECTION=image + +menuconfig IMAGE_OMAPSD + bool + select IMAGE_VFAT_TOOLS + select HOST_PARTED + select IMAGE_EXT2 + depends on ARCH_ARM + prompt "Generate OMAP bootable SD card" + help + Creates an bootable SD card for OMAP CPUs, for example for the beagle board. + The resulting image is called "omap_sd.img". You can copy it with "dd" + on a raw SD card, without partitioning. + + The SD card contains two file systems: + 1) A FAT file system that contains MLO, a bootloader and a Linux kernel + (plus additional files like an initramfs). + 2) The root file system as ext3 file system. + + OMAP has special requirements regarding the geometry of partition table, + and the location of MLO, that's why a fixed image makes more sense here + than copying the files manually. + +if IMAGE_OMAPSD + +config IMAGE_OMAPSD_BOOTLOADER + string + default "u-boot.img" + prompt "Bootloader file" + help + The name of the bootloader that should be copied to the SD card. If you use + u-boot SPL, then "u-boot.img" is the right choice here. If you still use + x-loader, then "u-boot.bin" should be copied. Also barebox can be used + with its MLO. The file must reside in the images directory of the platform. + +config IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES + string + default "" + prompt "Additional files for the boot partition" + help + A (whitespace separated) list of additional files can be specified here. + The files get copied in the boot partition (1st FAT partition). They must + be in the images/ directory of the platform that is built. One example is + a uRamdisk that gets loaded by the bootloader. + +endif + +# vim: set sw=8 ts=8 noet ft=kconfig: diff --git a/rules/host-parted.in b/rules/host-parted.in index d150ffd..0702dea 100644 --- a/rules/host-parted.in +++ b/rules/host-parted.in @@ -3,6 +3,3 @@ config HOST_PARTED bool default ALLYES - help - The well-known parted program - diff --git a/rules/host-parted.make b/rules/host-parted.make index 9655f5d..a73c6a5 100644 --- a/rules/host-parted.make +++ b/rules/host-parted.make @@ -1,7 +1,6 @@ # -*-makefile-*- # -# Copyright (C) 2006 by Robert Schwebel -# 2009 by Marc Kleine-Budde <mkl@pengutronix.de> +# Copyright (C) 2012 by Bernhard Walle <walle@corscience.de> # # See CREDITS for details about who has contributed to this project. # @@ -15,24 +14,11 @@ HOST_PACKAGES-$(PTXCONF_HOST_PARTED) += host-parted # -# Paths and names -# -HOST_PARTED = $(PARTED) -HOST_PARTED_DIR = $(HOST_BUILDDIR)/$(HOST_PARTED) - -# ---------------------------------------------------------------------------- -# Prepare -# ---------------------------------------------------------------------------- - -HOST_PARTED_ENV := $(HOST_ENV) - -# # autoconf # -HOST_PARTED_AUTOCONF := $(HOST_AUTOCONF) \ +HOST_PARTED_CONF_TOOL := autoconf +HOST_PARTED_CONF_OPT := $(HOST_AUTOCONF) \ --disable-device-mapper \ --disable-Werror -HOST_PARTED_INSTALL_OPT := install - # vim: syntax=make diff --git a/rules/post/image_omapsd.make b/rules/post/image_omapsd.make new file mode 100644 index 0000000..5131b40 --- /dev/null +++ b/rules/post/image_omapsd.make @@ -0,0 +1,33 @@ +# -*-makefile-*- +# +# Copyright (C) 2012 by Bernhard Walle <walle@corscience.de> +# +# See CREDITS for details about who has contributed to this project. +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +SEL_ROOTFS-$(PTXCONF_IMAGE_OMAPSD) += $(IMAGEDIR)/omap_sd.img + +# preprend the $(IMAGEDIR) if PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES is not +# empty +ifneq ($(PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES),"") +PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES_FULL := \ + $(addprefix $(IMAGEDIR)/, $(PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES)) +endif + +$(IMAGEDIR)/omap_sd.img: $(IMAGEDIR)/root.ext2 + @ln -sf $(IMAGEDIR)/linuximage $(IMAGEDIR)/uImage + @echo "Creating bootable SD card for OMAP"; \ + PATH=$(PTXCONF_SYSROOT_HOST)/bin:$$PATH $(PTXDIST_TOPDIR)/scripts/genomapsdimg \ + -m $(IMAGEDIR)/MLO \ + -b $(IMAGEDIR)/$(PTXCONF_IMAGE_OMAPSD_BOOTLOADER) \ + -k $(IMAGEDIR)/uImage \ + -f $(IMAGEDIR)/root.ext2 \ + -a "$(PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES_FULL)" \ + -o $@ + @echo "done." + @rm -f $(IMAGEDIR)/uImage + +# vim: syntax=make diff --git a/scripts/genomapsdimg b/scripts/genomapsdimg new file mode 100755 index 0000000..cd48fd5 --- /dev/null +++ b/scripts/genomapsdimg @@ -0,0 +1,188 @@ +#!/bin/bash +# +# Copyright (C) 2011 by Bernhard Walle <walle@corscience.de> +# +# Creates a OMAP bootable SD card. +# The image has a PC-style partition table with two partitions: +# +# 1) a FAT partition with MLO, bootloader and a Linux kernel +# 2) a ext3 partition with the root file system. +# +# That's a bit tricky because the OMAP needs a special partition table +# (therefore, genpart cannot be used). +# +# Parts of the script have been copied from 'debian-cd' (post-boot-armel). + +usage() { +cat <<-EOF + +Usage: `basename "$0"` OPTIONS + + -h this help + -m <mlo> path to the MLO file (SPL) + -b <bootloader> path to the bootloader + -k <kernel> path to the linux kernel + -a <file> additional file that should be included in the FAT partition + (e.g. a FTD or an initramfs). Multiple files can be specified + using whitespace separation. Don't forget to quote. + -f <filesystem> the (ext3) file system image for the second partition + -o <output> the output file that should be written + +EOF +} + +error() +{ + echo >&2 "$@" + exit 1 +} + +file_length() +{ + stat -c %s "$1" +} + +create_partitions() +{ + local boot_size="$((72 * 1024 * 1024))" # 72 MB for the partition + local image_size="$(file_length "${FILESYSTEM}")" + local img_size_blocks="$(((${boot_size} + ${image_size} + 512 - 1) / 512))" + + dd if=/dev/zero of="${OUTPUT}" bs=512 count=0 seek="${img_size_blocks}" >/dev/null 2>&1 + if [ $? -ne 0 ] ; then + error "Unable to create '${OUTPUT}' with 'dd'" + fi + + local trg_size="$(file_length "${OUTPUT}")" + local cylinders=$(( ${trg_size}/255/63/512 )) + + { + echo ,9,0x0C,* + echo ,,,- + } | sfdisk -D -H 255 -S 63 -C ${cylinders} "${OUTPUT}" >/dev/null 2>&1 + + if [ $? -ne 0 ] ; then + error "Unable to execute sfdisk" + fi +} + +check_input() +{ + if ! [ -r "${MLO}" ] ; then + echo "MLO '${MLO}' does not exist." + usage + exit 1 + fi + + if ! [ -r "${BOOTLOADER}" ] ; then + echo "Bootloader '${BOOTLOADER}' does not exist." + usage + exit 1 + fi + + if ! [ -r "${KERNEL}" ] ; then + echo "Kernel '${KERNEL}' does not exist." + usage + exit 1 + fi + + if ! [ -r "${FILESYSTEM}" ] ; then + echo "File system image '${FILESYSTEM}' does not exist." + usage + exit 1 + fi + + if [ -z "${OUTPUT}" ] ; then + echo "You have to specify an output file with -o." + usage + exit 1 + fi +} + +create_filesystem() +{ + local vatstart=$(parted "${OUTPUT}" unit B print 2>/dev/null|grep "^ 1"|awk '{print $2}') + local vatsize=$(LANG=C fdisk -l "${OUTPUT}" 2>/dev/null|grep W95 |awk '{print $5}') + + if ! mkdosfs -F 32 -C "${OUTPUT_FAT}" "${vatsize}" >/dev/null 2>&1 ; then + error "Unable to create '${OUTPUT_FAT}' via 'mkdosfs'" + fi +} + +copy_files() +{ + export MTOOLS_SKIP_CHECK=1 + + # it's important to copy the MLO first + mcopy -i "${OUTPUT_FAT}" "${MLO}" ::MLO + mcopy -i "${OUTPUT_FAT}" "${BOOTLOADER}" "::$(basename "${BOOTLOADER}")" + mcopy -i "${OUTPUT_FAT}" "${KERNEL}" "::$(basename "${KERNEL}")" + + # copy additional files (like FTD or an initramfs) + if [ -n "$ADDITIONAL_FILES" ] ; then + for file in ${ADDITIONAL_FILES} ; do + local targetname=$(basename "${file}") + if ! mcopy -i "${OUTPUT_FAT}" "${file}" "::${targetname}" ; then + error "Unable to copy '${file}' to '${OUTPUT_FAT}'" + fi + done + fi +} + +create_image() +{ + # now put the whole vfat into the first partition + local vatstart=$(parted "${OUTPUT}" unit B print 2>/dev/null | grep "^ 1" | awk '{print $2}') + + dd conv=notrunc bs="${vatstart%B}" if="${OUTPUT_FAT}" of="${OUTPUT}" seek=1 >/dev/null 2>&1 + if [ $? -ne 0 ] ; then + error "Unable to append '${OUTPUT_FAT}' to '${OUTPUT}'" + fi + rm "${OUTPUT_FAT}" + + # put ext3 content into the second partition + local ext3start=$(parted "${OUTPUT}" unit B print 2>/dev/null | grep "^ 2" | awk '{print $2}') + dd conv=notrunc bs="${ext3start%B}" if="${FILESYSTEM}" of="${OUTPUT}" seek=1 >/dev/null 2>&1 + if [ $? -ne 0 ] ; then + error "Unable to append '${FILESYSTEM}' to '${OUTPUT}'" + fi +} + + +# command line parsing + +while getopts hm:b:k:a:f:o: name ; do + case $name in + m) MLO="${OPTARG}" + ;; + b) BOOTLOADER="${OPTARG}" + ;; + k) KERNEL="${OPTARG}" + ;; + a) ADDITIONAL_FILES="${OPTARG}" + ;; + f) FILESYSTEM="${OPTARG}" + ;; + o) OUTPUT="${OPTARG}" + ;; + h) usage + exit 0 + ;; + *) usage + exit 1 + ;; + esac +done + +OUTPUT_FAT="${OUTPUT}.vfat" +[ -r "${OUTPUT_FAT}" ] && rm "${OUTPUT_FAT}" + +check_input +create_partitions +create_filesystem +copy_files +create_image + +echo "${OUTPUT} ready" + +# vim: set sw=4 ts=4 noet: -- 1.7.10 -- ptxdist mailing list ptxdist@pengutronix.de ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [ptxdist] [PATCH v2 2/2] Allow creation of bootable SD card for OMAP CPUs 2012-04-10 15:03 ` [ptxdist] [PATCH v2 2/2] Allow creation of bootable SD card for OMAP CPUs Bernhard Walle @ 2012-04-10 15:25 ` Bernhard Walle 0 siblings, 0 replies; 12+ messages in thread From: Bernhard Walle @ 2012-04-10 15:25 UTC (permalink / raw) To: ptxdist * Bernhard Walle <bernhard@bwalle.de> [2012-04-10 17:03]: > @@ -3,6 +3,3 @@ > config HOST_PARTED > bool > default ALLYES > - help > - The well-known parted program > - > diff --git a/rules/host-parted.make b/rules/host-parted.make > index 9655f5d..a73c6a5 100644 > --- a/rules/host-parted.make > +++ b/rules/host-parted.make > @@ -1,7 +1,6 @@ > # -*-makefile-*- > # > -# Copyright (C) 2006 by Robert Schwebel > -# 2009 by Marc Kleine-Budde <mkl@pengutronix.de> > +# Copyright (C) 2012 by Bernhard Walle <walle@corscience.de> > # That's not what I wanted. Wait for v3. Regards, Bernhard -- ptxdist mailing list ptxdist@pengutronix.de ^ permalink raw reply [flat|nested] 12+ messages in thread
* [ptxdist] [PATCH v3 1/2] Add host-parted 2012-04-10 12:54 ` Bernhard Walle 2012-04-10 15:03 ` [ptxdist] [PATCH v2 1/2] Add host-parted Bernhard Walle @ 2012-04-10 15:26 ` Bernhard Walle 2012-04-10 15:26 ` [ptxdist] [PATCH v3 2/2] Allow creation of bootable SD card for OMAP CPUs Bernhard Walle 1 sibling, 1 reply; 12+ messages in thread From: Bernhard Walle @ 2012-04-10 15:26 UTC (permalink / raw) To: ptxdist; +Cc: Bernhard Walle Signed-off-by: Bernhard Walle <walle@corscience.de> --- platforms/hosttools.in | 1 + rules/host-parted.in | 5 +++++ rules/host-parted.make | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 rules/host-parted.in create mode 100644 rules/host-parted.make diff --git a/platforms/hosttools.in b/platforms/hosttools.in index e9ce0fc..10d05e8 100644 --- a/platforms/hosttools.in +++ b/platforms/hosttools.in @@ -18,6 +18,7 @@ source "rules/host-mkelfImage.in" source "rules/host-mtd-utils.in" source "rules/host-mtools.in" source "rules/host-openssl.in" +source "rules/host-parted.in" source "rules/host-squashfs-tools.in" source "rules/host-u-boot-tools.in" source "rules/host-util-linux-ng.in" diff --git a/rules/host-parted.in b/rules/host-parted.in new file mode 100644 index 0000000..0702dea --- /dev/null +++ b/rules/host-parted.in @@ -0,0 +1,5 @@ +## SECTION=hosttools_noprompt + +config HOST_PARTED + bool + default ALLYES diff --git a/rules/host-parted.make b/rules/host-parted.make new file mode 100644 index 0000000..a73c6a5 --- /dev/null +++ b/rules/host-parted.make @@ -0,0 +1,24 @@ +# -*-makefile-*- +# +# Copyright (C) 2012 by Bernhard Walle <walle@corscience.de> +# +# See CREDITS for details about who has contributed to this project. +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +# +# We provide this package +# +HOST_PACKAGES-$(PTXCONF_HOST_PARTED) += host-parted + +# +# autoconf +# +HOST_PARTED_CONF_TOOL := autoconf +HOST_PARTED_CONF_OPT := $(HOST_AUTOCONF) \ + --disable-device-mapper \ + --disable-Werror + +# vim: syntax=make -- 1.7.10 -- ptxdist mailing list ptxdist@pengutronix.de ^ permalink raw reply [flat|nested] 12+ messages in thread
* [ptxdist] [PATCH v3 2/2] Allow creation of bootable SD card for OMAP CPUs 2012-04-10 15:26 ` [ptxdist] [PATCH v3 1/2] Add host-parted Bernhard Walle @ 2012-04-10 15:26 ` Bernhard Walle 0 siblings, 0 replies; 12+ messages in thread From: Bernhard Walle @ 2012-04-10 15:26 UTC (permalink / raw) To: ptxdist; +Cc: Bernhard Walle With the new option IMAGE_OMAPSD it's possible to create an image for OMAP-bootable SD cards. Tested with a devkit8000 and a virtual beagle board (qemu). See the comment in platforms/image_omapsd.in for more information. Signed-off-by: Bernhard Walle <walle@corscience.de> --- platforms/image_omapsd.in | 48 +++++++++++ rules/post/image_omapsd.make | 33 ++++++++ scripts/genomapsdimg | 188 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 269 insertions(+) create mode 100644 platforms/image_omapsd.in create mode 100644 rules/post/image_omapsd.make create mode 100755 scripts/genomapsdimg diff --git a/platforms/image_omapsd.in b/platforms/image_omapsd.in new file mode 100644 index 0000000..ef6c5e4 --- /dev/null +++ b/platforms/image_omapsd.in @@ -0,0 +1,48 @@ +## SECTION=image + +menuconfig IMAGE_OMAPSD + bool + select IMAGE_VFAT_TOOLS + select HOST_PARTED + select IMAGE_EXT2 + depends on ARCH_ARM + prompt "Generate OMAP bootable SD card" + help + Creates an bootable SD card for OMAP CPUs, for example for the beagle board. + The resulting image is called "omap_sd.img". You can copy it with "dd" + on a raw SD card, without partitioning. + + The SD card contains two file systems: + 1) A FAT file system that contains MLO, a bootloader and a Linux kernel + (plus additional files like an initramfs). + 2) The root file system as ext3 file system. + + OMAP has special requirements regarding the geometry of partition table, + and the location of MLO, that's why a fixed image makes more sense here + than copying the files manually. + +if IMAGE_OMAPSD + +config IMAGE_OMAPSD_BOOTLOADER + string + default "u-boot.img" + prompt "Bootloader file" + help + The name of the bootloader that should be copied to the SD card. If you use + u-boot SPL, then "u-boot.img" is the right choice here. If you still use + x-loader, then "u-boot.bin" should be copied. Also barebox can be used + with its MLO. The file must reside in the images directory of the platform. + +config IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES + string + default "" + prompt "Additional files for the boot partition" + help + A (whitespace separated) list of additional files can be specified here. + The files get copied in the boot partition (1st FAT partition). They must + be in the images/ directory of the platform that is built. One example is + a uRamdisk that gets loaded by the bootloader. + +endif + +# vim: set sw=8 ts=8 noet ft=kconfig: diff --git a/rules/post/image_omapsd.make b/rules/post/image_omapsd.make new file mode 100644 index 0000000..5131b40 --- /dev/null +++ b/rules/post/image_omapsd.make @@ -0,0 +1,33 @@ +# -*-makefile-*- +# +# Copyright (C) 2012 by Bernhard Walle <walle@corscience.de> +# +# See CREDITS for details about who has contributed to this project. +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +SEL_ROOTFS-$(PTXCONF_IMAGE_OMAPSD) += $(IMAGEDIR)/omap_sd.img + +# preprend the $(IMAGEDIR) if PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES is not +# empty +ifneq ($(PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES),"") +PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES_FULL := \ + $(addprefix $(IMAGEDIR)/, $(PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES)) +endif + +$(IMAGEDIR)/omap_sd.img: $(IMAGEDIR)/root.ext2 + @ln -sf $(IMAGEDIR)/linuximage $(IMAGEDIR)/uImage + @echo "Creating bootable SD card for OMAP"; \ + PATH=$(PTXCONF_SYSROOT_HOST)/bin:$$PATH $(PTXDIST_TOPDIR)/scripts/genomapsdimg \ + -m $(IMAGEDIR)/MLO \ + -b $(IMAGEDIR)/$(PTXCONF_IMAGE_OMAPSD_BOOTLOADER) \ + -k $(IMAGEDIR)/uImage \ + -f $(IMAGEDIR)/root.ext2 \ + -a "$(PTXCONF_IMAGE_OMAPSD_ADDITIONAL_BOOT_FILES_FULL)" \ + -o $@ + @echo "done." + @rm -f $(IMAGEDIR)/uImage + +# vim: syntax=make diff --git a/scripts/genomapsdimg b/scripts/genomapsdimg new file mode 100755 index 0000000..cd48fd5 --- /dev/null +++ b/scripts/genomapsdimg @@ -0,0 +1,188 @@ +#!/bin/bash +# +# Copyright (C) 2011 by Bernhard Walle <walle@corscience.de> +# +# Creates a OMAP bootable SD card. +# The image has a PC-style partition table with two partitions: +# +# 1) a FAT partition with MLO, bootloader and a Linux kernel +# 2) a ext3 partition with the root file system. +# +# That's a bit tricky because the OMAP needs a special partition table +# (therefore, genpart cannot be used). +# +# Parts of the script have been copied from 'debian-cd' (post-boot-armel). + +usage() { +cat <<-EOF + +Usage: `basename "$0"` OPTIONS + + -h this help + -m <mlo> path to the MLO file (SPL) + -b <bootloader> path to the bootloader + -k <kernel> path to the linux kernel + -a <file> additional file that should be included in the FAT partition + (e.g. a FTD or an initramfs). Multiple files can be specified + using whitespace separation. Don't forget to quote. + -f <filesystem> the (ext3) file system image for the second partition + -o <output> the output file that should be written + +EOF +} + +error() +{ + echo >&2 "$@" + exit 1 +} + +file_length() +{ + stat -c %s "$1" +} + +create_partitions() +{ + local boot_size="$((72 * 1024 * 1024))" # 72 MB for the partition + local image_size="$(file_length "${FILESYSTEM}")" + local img_size_blocks="$(((${boot_size} + ${image_size} + 512 - 1) / 512))" + + dd if=/dev/zero of="${OUTPUT}" bs=512 count=0 seek="${img_size_blocks}" >/dev/null 2>&1 + if [ $? -ne 0 ] ; then + error "Unable to create '${OUTPUT}' with 'dd'" + fi + + local trg_size="$(file_length "${OUTPUT}")" + local cylinders=$(( ${trg_size}/255/63/512 )) + + { + echo ,9,0x0C,* + echo ,,,- + } | sfdisk -D -H 255 -S 63 -C ${cylinders} "${OUTPUT}" >/dev/null 2>&1 + + if [ $? -ne 0 ] ; then + error "Unable to execute sfdisk" + fi +} + +check_input() +{ + if ! [ -r "${MLO}" ] ; then + echo "MLO '${MLO}' does not exist." + usage + exit 1 + fi + + if ! [ -r "${BOOTLOADER}" ] ; then + echo "Bootloader '${BOOTLOADER}' does not exist." + usage + exit 1 + fi + + if ! [ -r "${KERNEL}" ] ; then + echo "Kernel '${KERNEL}' does not exist." + usage + exit 1 + fi + + if ! [ -r "${FILESYSTEM}" ] ; then + echo "File system image '${FILESYSTEM}' does not exist." + usage + exit 1 + fi + + if [ -z "${OUTPUT}" ] ; then + echo "You have to specify an output file with -o." + usage + exit 1 + fi +} + +create_filesystem() +{ + local vatstart=$(parted "${OUTPUT}" unit B print 2>/dev/null|grep "^ 1"|awk '{print $2}') + local vatsize=$(LANG=C fdisk -l "${OUTPUT}" 2>/dev/null|grep W95 |awk '{print $5}') + + if ! mkdosfs -F 32 -C "${OUTPUT_FAT}" "${vatsize}" >/dev/null 2>&1 ; then + error "Unable to create '${OUTPUT_FAT}' via 'mkdosfs'" + fi +} + +copy_files() +{ + export MTOOLS_SKIP_CHECK=1 + + # it's important to copy the MLO first + mcopy -i "${OUTPUT_FAT}" "${MLO}" ::MLO + mcopy -i "${OUTPUT_FAT}" "${BOOTLOADER}" "::$(basename "${BOOTLOADER}")" + mcopy -i "${OUTPUT_FAT}" "${KERNEL}" "::$(basename "${KERNEL}")" + + # copy additional files (like FTD or an initramfs) + if [ -n "$ADDITIONAL_FILES" ] ; then + for file in ${ADDITIONAL_FILES} ; do + local targetname=$(basename "${file}") + if ! mcopy -i "${OUTPUT_FAT}" "${file}" "::${targetname}" ; then + error "Unable to copy '${file}' to '${OUTPUT_FAT}'" + fi + done + fi +} + +create_image() +{ + # now put the whole vfat into the first partition + local vatstart=$(parted "${OUTPUT}" unit B print 2>/dev/null | grep "^ 1" | awk '{print $2}') + + dd conv=notrunc bs="${vatstart%B}" if="${OUTPUT_FAT}" of="${OUTPUT}" seek=1 >/dev/null 2>&1 + if [ $? -ne 0 ] ; then + error "Unable to append '${OUTPUT_FAT}' to '${OUTPUT}'" + fi + rm "${OUTPUT_FAT}" + + # put ext3 content into the second partition + local ext3start=$(parted "${OUTPUT}" unit B print 2>/dev/null | grep "^ 2" | awk '{print $2}') + dd conv=notrunc bs="${ext3start%B}" if="${FILESYSTEM}" of="${OUTPUT}" seek=1 >/dev/null 2>&1 + if [ $? -ne 0 ] ; then + error "Unable to append '${FILESYSTEM}' to '${OUTPUT}'" + fi +} + + +# command line parsing + +while getopts hm:b:k:a:f:o: name ; do + case $name in + m) MLO="${OPTARG}" + ;; + b) BOOTLOADER="${OPTARG}" + ;; + k) KERNEL="${OPTARG}" + ;; + a) ADDITIONAL_FILES="${OPTARG}" + ;; + f) FILESYSTEM="${OPTARG}" + ;; + o) OUTPUT="${OPTARG}" + ;; + h) usage + exit 0 + ;; + *) usage + exit 1 + ;; + esac +done + +OUTPUT_FAT="${OUTPUT}.vfat" +[ -r "${OUTPUT_FAT}" ] && rm "${OUTPUT_FAT}" + +check_input +create_partitions +create_filesystem +copy_files +create_image + +echo "${OUTPUT} ready" + +# vim: set sw=4 ts=4 noet: -- 1.7.10 -- ptxdist mailing list ptxdist@pengutronix.de ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [ptxdist] [PATCH 1/2] Add host-parted 2012-03-26 12:01 [ptxdist] [PATCH 1/2] Add host-parted Bernhard Walle 2012-03-26 12:01 ` [ptxdist] [PATCH 2/2] Allow creation of bootable SD card for OMAP CPUs Bernhard Walle @ 2012-03-27 14:22 ` Michael Olbrich 1 sibling, 0 replies; 12+ messages in thread From: Michael Olbrich @ 2012-03-27 14:22 UTC (permalink / raw) To: ptxdist On Mon, Mar 26, 2012 at 02:01:13PM +0200, Bernhard Walle wrote: > Signed-off-by: Bernhard Walle <walle@corscience.de> > --- > platforms/hosttools.in | 1 + > rules/host-parted.in | 8 ++++++++ > rules/host-parted.make | 38 ++++++++++++++++++++++++++++++++++++++ > 3 files changed, 47 insertions(+) > create mode 100644 rules/host-parted.in > create mode 100644 rules/host-parted.make > > diff --git a/platforms/hosttools.in b/platforms/hosttools.in > index e9ce0fc..10d05e8 100644 > --- a/platforms/hosttools.in > +++ b/platforms/hosttools.in > @@ -18,6 +18,7 @@ source "rules/host-mkelfImage.in" > source "rules/host-mtd-utils.in" > source "rules/host-mtools.in" > source "rules/host-openssl.in" > +source "rules/host-parted.in" > source "rules/host-squashfs-tools.in" > source "rules/host-u-boot-tools.in" > source "rules/host-util-linux-ng.in" > diff --git a/rules/host-parted.in b/rules/host-parted.in > new file mode 100644 > index 0000000..d150ffd > --- /dev/null > +++ b/rules/host-parted.in > @@ -0,0 +1,8 @@ > +## SECTION=hosttools_noprompt > + > +config HOST_PARTED > + bool > + default ALLYES > + help > + The well-known parted program no need for help in noprompt options > + > diff --git a/rules/host-parted.make b/rules/host-parted.make > new file mode 100644 > index 0000000..9655f5d > --- /dev/null > +++ b/rules/host-parted.make > @@ -0,0 +1,38 @@ > +# -*-makefile-*- > +# > +# Copyright (C) 2006 by Robert Schwebel > +# 2009 by Marc Kleine-Budde <mkl@pengutronix.de> Shouldn't this be your copyright? > +# > +# See CREDITS for details about who has contributed to this project. > +# > +# For further information about the PTXdist project and license conditions > +# see the README file. > +# > + > +# > +# We provide this package > +# > +HOST_PACKAGES-$(PTXCONF_HOST_PARTED) += host-parted > + > +# > +# Paths and names > +# > +HOST_PARTED = $(PARTED) > +HOST_PARTED_DIR = $(HOST_BUILDDIR)/$(HOST_PARTED) remove > + > +# ---------------------------------------------------------------------------- > +# Prepare > +# ---------------------------------------------------------------------------- > + > +HOST_PARTED_ENV := $(HOST_ENV) remove > + > +# > +# autoconf > +# > +HOST_PARTED_AUTOCONF := $(HOST_AUTOCONF) \ > + --disable-device-mapper \ > + --disable-Werror I'd like to see CONF_TOOL/CONF_OPT in new packages. Take a look at e.g. rules/host-ncurses.make to see what's necessary. > + > +HOST_PARTED_INSTALL_OPT := install Isn't that the default anyways? > + > +# vim: syntax=make > -- > 1.7.9.4 > > > -- > ptxdist mailing list > ptxdist@pengutronix.de > -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | -- ptxdist mailing list ptxdist@pengutronix.de ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2012-04-10 15:30 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-03-26 12:01 [ptxdist] [PATCH 1/2] Add host-parted Bernhard Walle 2012-03-26 12:01 ` [ptxdist] [PATCH 2/2] Allow creation of bootable SD card for OMAP CPUs Bernhard Walle 2012-04-10 11:32 ` Andreas Bießmann 2012-04-10 12:49 ` Bernhard Walle 2012-04-10 12:01 ` Andreas Bießmann 2012-04-10 12:54 ` Bernhard Walle 2012-04-10 15:03 ` [ptxdist] [PATCH v2 1/2] Add host-parted Bernhard Walle 2012-04-10 15:03 ` [ptxdist] [PATCH v2 2/2] Allow creation of bootable SD card for OMAP CPUs Bernhard Walle 2012-04-10 15:25 ` Bernhard Walle 2012-04-10 15:26 ` [ptxdist] [PATCH v3 1/2] Add host-parted Bernhard Walle 2012-04-10 15:26 ` [ptxdist] [PATCH v3 2/2] Allow creation of bootable SD card for OMAP CPUs Bernhard Walle 2012-03-27 14:22 ` [ptxdist] [PATCH 1/2] Add host-parted Michael Olbrich
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox