From: "Andreas Bießmann" <biessmann@corscience.de>
To: ptxdist@pengutronix.de
Cc: Bernhard Walle <bernhard@bwalle.de>,
Bernhard Walle <walle@corscience.de>
Subject: Re: [ptxdist] [PATCH 2/2] Allow creation of bootable SD card for OMAP CPUs
Date: Tue, 10 Apr 2012 13:32:20 +0200 [thread overview]
Message-ID: <4F841A44.1020807@corscience.de> (raw)
In-Reply-To: <1332763274-17969-2-git-send-email-bernhard@bwalle.de>
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
next prev parent reply other threads:[~2012-04-10 11:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F841A44.1020807@corscience.de \
--to=biessmann@corscience.de \
--cc=bernhard@bwalle.de \
--cc=ptxdist@pengutronix.de \
--cc=walle@corscience.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox