Repair boot from SD card on i.MX6 Sabre boards
Hi,
Here is a two-patches series, to repair the boot from SD card on Freescale Sabre boards.
The first patch adapts the SD card creation script to the new versions of sfdisk; a prerequisite to actually preparing an SD card and booting from it.
The second patch switches the defconfigs to building a zImage instead of an uImage, to reflect what u-boot in Freescale releases awaits nowadays.
This was build-tested for all the five touched defconfigs but I did only verify the boot on i.MX6 quad Sabre AI.
Feedbacks and testers welcome!
Best regards,
V.
PATCH 1/2 board/freescale: refresh create-boot-sd.sh
Starting with version 2.26, sfdisk defaults to a unit of 512 B sectors. With those recent versions of sfdisk, the create-boot-sd.sh script ends up creating a boot partition of 240 KB, which is too small to contain a Linux kernel.
Version 2.25 of sfdisk and older defaulted to cylinders; a media-dependant unit, typically much larger than 512 B. With those versions the create-boot-sd.sh creates paritions, large enough to hold a kernel.
We update the create-boot-sd.sh script to use the more readable and more stable named-fields sfdisk format for the partitioning command, and set the boot partition size to 64 MB, which should be enough for everyone.
--- board/freescale/create-boot-sd.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
board/freescale/create-boot-sd.sh +2 -2
@@ -60,8 +60,8 @@ sync # - FAT partition starting at 1MB offset, containing uImage and *.dtb # - ext2/3 partition formatted as ext2 or ext3, containing the root filesystem. sfdisk ${DEV} <<EOF -32,480,b -512,,L +start=1MiB, size=64MiB, type=b +type=83 EOF sync
Signature · 1 line
2.5.3
PATCH 1/2 board/freescale: refresh create-boot-sd.sh
Dear Vincent,
Quoted 4 lines · Vincent Stehl?
Starting with version 2.26, sfdisk defaults to a unit of 512 B sectors. With those recent versions of sfdisk, the
create-boot-sd.shscript ends up creating a boot partition of 240 KB, which is too small to contain a Linux kernel.
Ouch!
Quoted 4 lines
Version 2.25 of sfdisk and older defaulted to cylinders; a media-dependant unit, typically much larger than 512 B. With those versions the
create-boot-sd.shcreates paritions, large enough to hold a
paritions -> partitions, and remove the ',' after it.
Quoted 18 lines
kernel.
We update the
create-boot-sd.shscript to use the more readable and more stable named-fields sfdisk format for the partitioning command, and set the boot partition size to 64 MB, which should be enough for everyone.Signed-off-by Vincent Stehl? <[email protected]>Cc Luca Ceresoli <[email protected]>Cc Gary Bisson <[email protected]>--- board/freescale/create-boot-sd.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)board/freescale/create-boot-sd.sh +0
-0
board/freescale/create-boot-sd.sh sync · line 63
Quoted 6 lines
board/freescale/create-boot-sd.sh +1
-2@@ -60,8 +60,8 @@ sync # - FAT partition starting at 1MB offset, containing uImage and *.dtb # - ext2/3 partition formatted as ext2 or ext3, containing the root filesystem. sfdisk ${DEV} <<EOF -32,480,b -512,,L +start=1MiB, size=64MiB, type=b
Is the "MiB" suffix supported on older sfdisk releases? Ubuntu 14.04 ships sfdisk 2.20.1, and its manpage does not contain "MiB".
If that is not supported, then I guess "--unit M" should work. It's in the manpage, but I haven't tested it yet.
I strongly think we should support the latest Ubuntu LTS, AFAIK it's widely used by embedded Linux developers.
Signature · 1 line
Luca
PATCH 1/2 board/freescale: refresh create-boot-sd.sh
Quoted 46 lines · Luca Ceresoli
Dear Vincent,
Quoted 4 lines · Vincent Stehl?
Starting with version 2.26, sfdisk defaults to a unit of 512 B sectors. With those recent versions of sfdisk, the
create-boot-sd.shscript ends up creating a boot partition of 240 KB, which is too small to contain a Linux kernel.Ouch!
Quoted 4 lines
Version 2.25 of sfdisk and older defaulted to cylinders; a media-dependant unit, typically much larger than 512 B. With those versions the
create-boot-sd.shcreates paritions, large enough to hold aparitions -> partitions, and remove the ',' after it.
Quoted 19 lines
kernel.
We update the
create-boot-sd.shscript to use the more readable and more stable named-fields sfdisk format for the partitioning command, and set the boot partition size to 64 MB, which should be enough for everyone.Signed-off-by Vincent Stehl? <[email protected]>Cc Luca Ceresoli <[email protected]>Cc Gary Bisson <[email protected]>--- board/freescale/create-boot-sd.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)board/freescale/create-boot-sd.sh +0
-0board/freescale/create-boot-sd.sh sync · line 63
Quoted 6 lines
board/freescale/create-boot-sd.sh +1
-2@@ -60,8 +60,8 @@ sync # - FAT partition starting at 1MB offset, containing uImage and *.dtb # - ext2/3 partition formatted as ext2 or ext3, containing the root filesystem. sfdisk ${DEV} <<EOF -32,480,b -512,,L +start=1MiB, size=64MiB, type=bIs the "MiB" suffix supported on older sfdisk releases? Ubuntu 14.04 ships sfdisk 2.20.1, and its manpage does not contain "MiB".
Quoted 5 lines
If that is not supported, then I guess "--unit M" should work. It's in the manpage, but I haven't tested it yet.
I strongly think we should support the latest Ubuntu LTS, AFAIK it's widely used by embedded Linux developers.
We should also still support Ubuntu 12.02 IMHO and even older RHEL.
So to avoid this kind of issue, it would be better to use genimage. But that's
a much bigger change, of course.
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 1/2 board/freescale: refresh create-boot-sd.sh
Hi,
Quoted 31 lines · Arnout Vandecappelle
Quoted 30 lines · Luca Ceresoli
Dear Vincent,
Quoted 4 lines · Vincent Stehl?
Starting with version 2.26, sfdisk defaults to a unit of 512 B sectors. With those recent versions of sfdisk, the
create-boot-sd.shscript ends up creating a boot partition of 240 KB, which is too small to contain a Linux kernel.Ouch!
Quoted 4 lines
Version 2.25 of sfdisk and older defaulted to cylinders; a media-dependant unit, typically much larger than 512 B. With those versions the
create-boot-sd.shcreates paritions, large enough to hold aparitions -> partitions, and remove the ',' after it.
Quoted 13 lines
kernel.
We update the
create-boot-sd.shscript to use the more readable and more stable named-fields sfdisk format for the partitioning command, and set the boot partition size to 64 MB, which should be enough for everyone.Signed-off-by Vincent Stehl? <[email protected]>Cc Luca Ceresoli <[email protected]>Cc Gary Bisson <[email protected]>---
board/freescale/create-boot-sd.sh| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 8 lines
Quoted 8 lines
board/freescale/create-boot-sd.sh sync · line 61
Quoted 8 lines
board/freescale/create-boot-sd.sh +0
-0@@ -60,8 +60,8 @@ sync # - FAT partition starting at 1MB offset, containing uImage and *.dtb # - ext2/3 partition formatted as ext2 or ext3, containing the root
filesystem.
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
sfdisk ${DEV} <<EOF
-32,480,b
-512,,L
+start=1MiB, size=64MiB, type=bIs the "MiB" suffix supported on older sfdisk releases? Ubuntu 14.04 ships sfdisk 2.20.1, and its manpage does not contain "MiB".
Quoted 7 lines
Quoted 5 lines
If that is not supported, then I guess "--unit M" should work. It's in the manpage, but I haven't tested it yet.
I strongly think we should support the latest Ubuntu LTS, AFAIK it's widely used by embedded Linux developers.
We should also still support Ubuntu 12.02 IMHO and even older RHEL.
Agreed.
Quoted 1 line
So to avoid this kind of issue, it would be better to use genimage. But
that's
Quoted 1 line
a much bigger change, of course.
What about parted instead of sfdisk? Seems to be more consistent across the different releases.
Regards,
Gary
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151015/5f08f60a/attachment.html>
PATCH v2 1/1 board/freescale: switch create-boot-sd.sh to parted
Starting with version 2.26, sfdisk defaults to a unit of 512 B sectors. With those recent versions of sfdisk, the create-boot-sd.sh script ends up creating a boot partition of 240 KB, which is too small to contain a Linux kernel.
As it is difficult to address both pre and post v2.26 sfdisk versions in a single command, we change the create-boot-sd.sh script to use parted instead. While at it, we set the boot partition size to 64 MB, which should be enough for everyone.
---
Hi,
This is a second proposal, using parted this time. Even with sfdisk `--unit' parameter, I could not find an eleguant solution to support all versions of sfdisk, sorry. Please let me know if you find switching to parted acceptable.
This is tested on Sabre AI with an i.MX6 Quad.
Best regards,
V.
Changes in v2
-------------
- Switch to parted, as advised by Gary.
- Fix spelling in commit message, spotted by Luca.
board/freescale/create-boot-sd.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
board/freescale/create-boot-sd.sh +6 -4
@@ -59,10 +59,12 @@ sync # - Bootloader at offset 1024 # - FAT partition starting at 1MB offset, containing uImage and *.dtb # - ext2/3 partition formatted as ext2 or ext3, containing the root filesystem. -sfdisk ${DEV} <<EOF -32,480,b -512,,L -EOF +parted --script "${DEV}" \ + mklabel msdos \ + unit MiB \ + mkpart primary fat16 1 64 \ + mkpart primary ext2 64 100% \ + print sync
Signature · 1 line
2.6.1
PATCH v2 1/1 board/freescale: switch create-boot-sd.sh to parted
Hi Vincent,
Quoted 9 lines · Vincent Stehl?
Starting with version 2.26, sfdisk defaults to a unit of 512 B sectors. With those recent versions of sfdisk, the
create-boot-sd.shscript ends up creating a boot partition of 240 KB, which is too small to contain a Linux kernel.As it is difficult to address both pre and post v2.26 sfdisk versions in a single command, we change the
create-boot-sd.shscript to use parted instead. While at it, we set the boot partition size to 64 MB, which should be enough for everyone.
You should mention in the relevant readme.txt files under board/freescale/ that parted needs to be installed on the host.
Alternatively, you can enable host-parted in the config files, and use that in create-boot-sd.sh.
Quoted 3 lines
Signed-off-by Vincent Stehl? <[email protected]>Cc Luca Ceresoli <[email protected]>Cc Gary Bisson <[email protected]>
baruch
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -PATCH v2 1/1 board/freescale: switch create-boot-sd.sh to parted
In reply to Vincent StehléQuoted 17 lines · Vincent Stehl?
Starting with version 2.26, sfdisk defaults to a unit of 512 B sectors. With those recent versions of sfdisk, the
create-boot-sd.shscript ends up creating a boot partition of 240 KB, which is too small to contain a Linux kernel.As it is difficult to address both pre and post v2.26 sfdisk versions in a single command, we change the
create-boot-sd.shscript to use parted instead. While at it, we set the boot partition size to 64 MB, which should be enough for everyone.Signed-off-by Vincent Stehl? <[email protected]>Cc Luca Ceresoli <[email protected]>Cc Gary Bisson <[email protected]>---
Quoted 6 lines
Hi,
This is a second proposal, using parted this time. Even with sfdisk `--unit' parameter, I could not find an eleguant solution to support all versions of sfdisk, sorry. Please let me know if you find switching to parted acceptable.
I really don't like that we would rely on a tool installed on the host.
Is there any reason why genimage (cfr. wandboard) wouldn't work, like I
suggested earlier?
Regards,
Arnout
Quoted 39 lines
This is tested on Sabre AI with an i.MX6 Quad.
Best regards,
V.
Changes in v2
-------------
- Switch to parted, as advised by Gary.
- Fix spelling in commit message, spotted by Luca.board/freescale/create-boot-sd.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)board/freescale/create-boot-sd.sh +6
-4@@ -59,10 +59,12 @@ sync # - Bootloader at offset 1024 # - FAT partition starting at 1MB offset, containing uImage and *.dtb # - ext2/3 partition formatted as ext2 or ext3, containing the root filesystem. -sfdisk ${DEV} <<EOF -32,480,b -512,,L -EOF +parted --script "${DEV}" \ + mklabel msdos \ + unit MiB \ + mkpart primary fat16 1 64 \ + mkpart primary ext2 64 100% \ + print sync
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH v2 1/1 board/freescale: switch create-boot-sd.sh to parted
On 10/21/2015 08:37 PM, Arnout Vandecappelle wrote:
..
Quoted 2 lines
Is there any reason why genimage (cfr. wandboard) wouldn't work, like I
suggested earlier?
Hi Arnout,
You are right, genimage seems like a nice solution. In fact I think I prefer this SD card image generation approach over the direct SD card modification method.
Thank you for this suggestion.
Best regards,
V.
PATCH 2/2 imx6sabre: use zImage format for kernel
In reply to Vincent StehléStarting with u-boot rel_imx_3.10.53_1.1.0_ga, the default is to boot a zImage instead of an uImage. Update the i.MX6 defconfigs accordingly. This repairs the boot from SD card.
While at it, align freescale_imx6sololiteevk_defconfig a bit more on the other i.MX6 defconfigs, update documentation and SD card creation script comments to reflect the change to zImage.
--- board/freescale/create-boot-sd.sh | 2 +- board/freescale/imx6sabre/readme.txt | 2 +- configs/freescale_imx6dlsabreauto_defconfig | 2 +- configs/freescale_imx6dlsabresd_defconfig | 2 +- configs/freescale_imx6qsabreauto_defconfig | 2 +- configs/freescale_imx6qsabresd_defconfig | 2 +- configs/freescale_imx6sololiteevk_defconfig | 10 +++++++++- 7 files changed, 15 insertions(+), 7 deletions(-)
board/freescale/create-boot-sd.sh +1 -1
@@ -57,7 +57,7 @@ sync # Partition the card. # SD layout for i.MX6 boot: # - Bootloader at offset 1024 -# - FAT partition starting at 1MB offset, containing uImage and *.dtb +# - FAT partition starting at 1MB offset, containing uImage or zImage, and *.dtb # - ext2/3 partition formatted as ext2 or ext3, containing the root filesystem. sfdisk ${DEV} <<EOF start=1MiB, size=64MiB, type=b
board/freescale/imx6sabre/readme.txt +1 -1
@@ -43,7 +43,7 @@ You will find in ./output/images/ the following files: - rootfs.ext2 - rootfs.tar - u-boot.imx - - uImage + - zImage Create a bootable SD card =========================
configs/freescale_imx6dlsabreauto_defconfig +1 -1
@@ -19,7 +19,7 @@ BR2_LINUX_KERNEL_CUSTOM_GIT=y BR2_LINUX_KERNEL_CUSTOM_REPO_URL="git://git.freescale.com/imx/linux-2.6-imx.git" BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="rel_imx_3.14.28_1.0.0_ga" BR2_LINUX_KERNEL_DEFCONFIG="imx_v7" -BR2_LINUX_KERNEL_UIMAGE_LOADADDR="0x10008000" +BR2_LINUX_KERNEL_ZIMAGE=y BR2_LINUX_KERNEL_DTS_SUPPORT=y BR2_LINUX_KERNEL_INTREE_DTS_NAME="imx6dl-sabreauto"
configs/freescale_imx6dlsabresd_defconfig +1 -1
@@ -19,7 +19,7 @@ BR2_LINUX_KERNEL_CUSTOM_GIT=y BR2_LINUX_KERNEL_CUSTOM_REPO_URL="git://git.freescale.com/imx/linux-2.6-imx.git" BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="rel_imx_3.14.28_1.0.0_ga" BR2_LINUX_KERNEL_DEFCONFIG="imx_v7" -BR2_LINUX_KERNEL_UIMAGE_LOADADDR="0x10008000" +BR2_LINUX_KERNEL_ZIMAGE=y BR2_LINUX_KERNEL_DTS_SUPPORT=y BR2_LINUX_KERNEL_INTREE_DTS_NAME="imx6dl-sabresd"
configs/freescale_imx6qsabreauto_defconfig +1 -1
@@ -19,7 +19,7 @@ BR2_LINUX_KERNEL_CUSTOM_GIT=y BR2_LINUX_KERNEL_CUSTOM_REPO_URL="git://git.freescale.com/imx/linux-2.6-imx.git" BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="rel_imx_3.14.28_1.0.0_ga" BR2_LINUX_KERNEL_DEFCONFIG="imx_v7" -BR2_LINUX_KERNEL_UIMAGE_LOADADDR="0x10008000" +BR2_LINUX_KERNEL_ZIMAGE=y BR2_LINUX_KERNEL_DTS_SUPPORT=y BR2_LINUX_KERNEL_INTREE_DTS_NAME="imx6q-sabreauto"
configs/freescale_imx6qsabresd_defconfig +1 -1
@@ -19,7 +19,7 @@ BR2_LINUX_KERNEL_CUSTOM_GIT=y BR2_LINUX_KERNEL_CUSTOM_REPO_URL="git://git.freescale.com/imx/linux-2.6-imx.git" BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="rel_imx_3.14.28_1.0.0_ga" BR2_LINUX_KERNEL_DEFCONFIG="imx_v7" -BR2_LINUX_KERNEL_UIMAGE_LOADADDR="0x10008000" +BR2_LINUX_KERNEL_ZIMAGE=y BR2_LINUX_KERNEL_DTS_SUPPORT=y BR2_LINUX_KERNEL_INTREE_DTS_NAME="imx6q-sabresd"
configs/freescale_imx6sololiteevk_defconfig +9 -1
@@ -2,6 +2,14 @@ BR2_arm=y BR2_cortex_a9=y +# patches +BR2_GLOBAL_PATCH_DIR="board/freescale/imx6sabre/patches" + +# toolchain +BR2_KERNEL_HEADERS_VERSION=y +BR2_DEFAULT_KERNEL_VERSION="3.14.28" +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_3_14=y + # system BR2_TARGET_GENERIC_GETTY_PORT="ttymxc0"
@@ -11,7 +19,7 @@ BR2_LINUX_KERNEL_CUSTOM_GIT=y BR2_LINUX_KERNEL_CUSTOM_REPO_URL="git://git.freescale.com/imx/linux-2.6-imx.git" BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="rel_imx_3.14.28_1.0.0_ga" BR2_LINUX_KERNEL_DEFCONFIG="imx_v7" -BR2_LINUX_KERNEL_UIMAGE_LOADADDR="0x80008000" +BR2_LINUX_KERNEL_ZIMAGE=y BR2_LINUX_KERNEL_DTS_SUPPORT=y BR2_LINUX_KERNEL_INTREE_DTS_NAME="imx6sl-evk"
Signature · 1 line
2.5.3
Jeremy Rosen
Tested-byI know that this patch is still under review and might change, but in it's present form,
usind a imx6sabreq and util-linux 2.26.2-9 from debian
Cordialement
J?r?my Rosen
+33 (0)1 42 68 28 13
fight key loggers : write some perl using vim
Open Wide Ingenierie
23, rue Daviel
75013 Paris - France
www.openwide.fr
----- Le 14 Oct 15, ? 16:03, Vincent Stehl? vincent.stehle at freescale.com a ?crit :
Quoted 24 lines
Hi,
Here is a two-patches series, to repair the boot from SD card on Freescale Sabre boards.
The first patch adapts the SD card creation script to the new versions of sfdisk; a prerequisite to actually preparing an SD card and booting from it.
The second patch switches the defconfigs to building a zImage instead of an uImage, to reflect what u-boot in Freescale releases awaits nowadays.
This was build-tested for all the five touched defconfigs but I did only verify the boot on i.MX6 quad Sabre AI.
Feedbacks and testers welcome!
Best regards,
V.
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot