diff mbox

[1/3] configs: atmel: add sama5d2 xplained sd card image generation

Message ID 1459497706-1663-1-git-send-email-ludovic.desroches@atmel.com
State Superseded
Headers show

Commit Message

ludovic.desroches@atmel.com April 1, 2016, 8:01 a.m. UTC
Use genimage to generate a sd card with a fat partition (at91bootstrap,
u-boot, kernel, dtbs) and an ext4 partition (rootfs).

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 board/atmel/sama5d2_xplained_mmc/genimage.cfg  | 33 ++++++++++++++++++++++++++
 board/atmel/sama5d2_xplained_mmc/post-image.sh | 16 +++++++++++++
 configs/atmel_sama5d2_xplained_mmc_defconfig   |  4 ++++
 3 files changed, 53 insertions(+)
 create mode 100644 board/atmel/sama5d2_xplained_mmc/genimage.cfg
 create mode 100755 board/atmel/sama5d2_xplained_mmc/post-image.sh

Comments

Thomas Petazzoni April 2, 2016, 3:35 p.m. UTC | #1
Hello,

On Fri, 1 Apr 2016 10:01:44 +0200, Ludovic Desroches wrote:
> Use genimage to generate a sd card with a fat partition (at91bootstrap,
> u-boot, kernel, dtbs) and an ext4 partition (rootfs).
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>

Thanks for working on this!


> diff --git a/board/atmel/sama5d2_xplained_mmc/post-image.sh b/board/atmel/sama5d2_xplained_mmc/post-image.sh
> new file mode 100755
> index 0000000..c82b189
> --- /dev/null
> +++ b/board/atmel/sama5d2_xplained_mmc/post-image.sh
> @@ -0,0 +1,16 @@
> +#!/bin/sh
> +
> +BOARD_DIR="$(dirname $0)"
> +GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg"
> +GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
> +
> +rm -rf "${GENIMAGE_TMP}"
> +
> +genimage                               \
> +	--rootpath "${TARGET_DIR}"     \
> +	--tmppath "${GENIMAGE_TMP}"    \
> +	--inputpath "${BINARIES_DIR}"  \
> +	--outputpath "${BINARIES_DIR}" \
> +	--config "${GENIMAGE_CFG}"
> +
> +exit $?

This last line is not needed.

We really need at some point to provide a generic mechanism for
genimage, because this script is duplicated all over the place. But
that's a separate issue, we can definitely accept your patch without
doing this refactoring.


> +BR2_PACKAGE_HOST_GENIMAGE=y

You need to add:

BR2_PACKAGE_HOST_DOSFSTOOLS=y
BR2_PACKAGE_HOST_MTOOLS=y

Which are used to generate the FAT filesystem. You may not have noticed
if you have those tools installed on your machine, but they are needed.

Last but not least, could you add a patch at the end of the series that
updates the documentation in board/atmel/readme.txt to simplify the SD
card installation details? Indeed we no longer need to tell the user to
create the partitions, copy the files manually and so on.

Thanks a lot!

Thomas
ludovic.desroches@atmel.com April 4, 2016, 6:20 a.m. UTC | #2
On Sat, Apr 02, 2016 at 05:35:25PM +0200, Thomas Petazzoni wrote:
> Hello,
> 
> On Fri, 1 Apr 2016 10:01:44 +0200, Ludovic Desroches wrote:
> > Use genimage to generate a sd card with a fat partition (at91bootstrap,
> > u-boot, kernel, dtbs) and an ext4 partition (rootfs).
> > 
> > Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Thanks for working on this!
> 
> 
> > diff --git a/board/atmel/sama5d2_xplained_mmc/post-image.sh b/board/atmel/sama5d2_xplained_mmc/post-image.sh
> > new file mode 100755
> > index 0000000..c82b189
> > --- /dev/null
> > +++ b/board/atmel/sama5d2_xplained_mmc/post-image.sh
> > @@ -0,0 +1,16 @@
> > +#!/bin/sh
> > +
> > +BOARD_DIR="$(dirname $0)"
> > +GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg"
> > +GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
> > +
> > +rm -rf "${GENIMAGE_TMP}"
> > +
> > +genimage                               \
> > +	--rootpath "${TARGET_DIR}"     \
> > +	--tmppath "${GENIMAGE_TMP}"    \
> > +	--inputpath "${BINARIES_DIR}"  \
> > +	--outputpath "${BINARIES_DIR}" \
> > +	--config "${GENIMAGE_CFG}"
> > +
> > +exit $?
> 
> This last line is not needed.
> 

Ok.

> We really need at some point to provide a generic mechanism for
> genimage, because this script is duplicated all over the place. But
> that's a separate issue, we can definitely accept your patch without
> doing this refactoring.
> 
> 
> > +BR2_PACKAGE_HOST_GENIMAGE=y
> 
> You need to add:
> 
> BR2_PACKAGE_HOST_DOSFSTOOLS=y
> BR2_PACKAGE_HOST_MTOOLS=y
>
> Which are used to generate the FAT filesystem. You may not have noticed
> if you have those tools installed on your machine, but they are needed.
> 

I'll add these packages.

> Last but not least, could you add a patch at the end of the series that
> updates the documentation in board/atmel/readme.txt to simplify the SD
> card installation details? Indeed we no longer need to tell the user to
> create the partitions, copy the files manually and so on.
> 

I thought it could be useful if the user wanted to generate it by
himself. But you are right why doing it this way if he only has to
change genimage.cfg

Regards

Ludovic
diff mbox

Patch

diff --git a/board/atmel/sama5d2_xplained_mmc/genimage.cfg b/board/atmel/sama5d2_xplained_mmc/genimage.cfg
new file mode 100644
index 0000000..b0ba22d
--- /dev/null
+++ b/board/atmel/sama5d2_xplained_mmc/genimage.cfg
@@ -0,0 +1,33 @@ 
+# Image for SD card boot on Atmel SAMA5D2 Xplained boards
+#
+image boot.vfat {
+	vfat {
+		files = {
+			"zImage",
+			"at91-sama5d2_xplained.dtb",
+			"at91-sama5d2_xplained_pda4.dtb",
+			"at91-sama5d2_xplained_pda7.dtb",
+			"at91-sama5d2_xplained_pda7b.dtb",
+			"boot.bin",
+			"u-boot.bin"
+		}
+	}
+	size = 16M
+}
+
+image sdcard.img {
+	hdimage {
+	}
+
+	partition boot {
+		partition-type = 0xC
+		bootable = "true"
+		image = "boot.vfat"
+	}
+
+	partition rootfs {
+		partition-type = 0x83
+		image = "rootfs.ext4"
+		size = 512M
+	}
+}
diff --git a/board/atmel/sama5d2_xplained_mmc/post-image.sh b/board/atmel/sama5d2_xplained_mmc/post-image.sh
new file mode 100755
index 0000000..c82b189
--- /dev/null
+++ b/board/atmel/sama5d2_xplained_mmc/post-image.sh
@@ -0,0 +1,16 @@ 
+#!/bin/sh
+
+BOARD_DIR="$(dirname $0)"
+GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg"
+GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
+
+rm -rf "${GENIMAGE_TMP}"
+
+genimage                               \
+	--rootpath "${TARGET_DIR}"     \
+	--tmppath "${GENIMAGE_TMP}"    \
+	--inputpath "${BINARIES_DIR}"  \
+	--outputpath "${BINARIES_DIR}" \
+	--config "${GENIMAGE_CFG}"
+
+exit $?
diff --git a/configs/atmel_sama5d2_xplained_mmc_defconfig b/configs/atmel_sama5d2_xplained_mmc_defconfig
index 74fa2b5..445c814 100644
--- a/configs/atmel_sama5d2_xplained_mmc_defconfig
+++ b/configs/atmel_sama5d2_xplained_mmc_defconfig
@@ -5,6 +5,7 @@  BR2_ARM_ENABLE_VFP=y
 BR2_ARM_FPU_VFPV4=y
 BR2_ARM_INSTRUCTIONS_THUMB2=y
 BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_1=y
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/atmel/sama5d2_xplained_mmc/post-image.sh"
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_CUSTOM_GIT=y
 BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/linux4sam/linux-at91.git"
@@ -13,6 +14,8 @@  BR2_LINUX_KERNEL_DEFCONFIG="sama5"
 BR2_LINUX_KERNEL_ZIMAGE=y
 BR2_LINUX_KERNEL_DTS_SUPPORT=y
 BR2_LINUX_KERNEL_INTREE_DTS_NAME="at91-sama5d2_xplained at91-sama5d2_xplained_pda4 at91-sama5d2_xplained_pda7 at91-sama5d2_xplained_pda7b"
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_4=y
 BR2_TARGET_AT91BOOTSTRAP3=y
 BR2_TARGET_AT91BOOTSTRAP3_CUSTOM_GIT=y
 BR2_TARGET_AT91BOOTSTRAP3_CUSTOM_REPO_URL="https://github.com/linux4sam/at91bootstrap.git"
@@ -24,3 +27,4 @@  BR2_TARGET_UBOOT_CUSTOM_GIT=y
 BR2_TARGET_UBOOT_CUSTOM_REPO_URL="https://github.com/linux4sam/u-boot-at91.git"
 BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION="linux4sam_5.2"
 BR2_TARGET_UBOOT_BOARD_DEFCONFIG="sama5d2_xplained_mmc"
+BR2_PACKAGE_HOST_GENIMAGE=y