Skip to contentSkip to conversation

imx/genimage: Place the rootfs at a proper offset when BR2_LINUX_KERNEL_INSTALL_TARGET=y

PATCH Applied Fabio Estevam 3 participants 3 messages Nov 13, 2021 – Nov 17, 2021 Arm i.MX and Layerscape

lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH v2 1/1 imx/genimage: Place the rootfs at a proper offset when BR2_LINUX_KERNEL_INSTALL_TARGET=y

Currently, when BR2_LINUX_KERNEL_INSTALL_TARGET=y is selected, issuing a "saveenv" command in the U-Boot prompt may lead to rootfs corruption.

When BR2_LINUX_KERNEL_INSTALL_TARGET is not selected, then board/freescale/common/imx/genimage.cfg.template is used as per the logic inside board/freescale/common/imx/post-image.sh.

board/freescale/common/imx/genimage.cfg.template correctly puts the rootfs at a safe offset.

With BR2_LINUX_KERNEL_INSTALL_TARGET=y, then board/freescale/common/imx/genimage.cfg.template_no_boot_part or board/freescale/common/imx/genimage.cfg.template_no_boot_part_spl are used and no offset to the rootfs is given, which may cause U-Boot environment area to write into the rootfs area, causing the rootfs corruption.

Avoid this problem by placing the rootfs at an 8MB offset, just like it is done in board/freescale/common/imx/genimage.cfg.

Tested on a imx6qp-wandboard and also on a custom imx6ull based board.

"saveenv" does not corrupt the rootfs anymore after this change.

---
Changes since v1:
- Improve commit log (Yann)

 board/freescale/common/imx/genimage.cfg.template_no_boot_part    | 1 +
 .../freescale/common/imx/genimage.cfg.template_no_boot_part_spl  | 1 +
 2 files changed, 2 insertions(+)
board/freescale/common/imx/genimage.cfg.template_no_boot_part +1 -0
index edc34d0fcd12..b8fa43210b91 100644
@@ -11,5 +11,6 @@ image sdcard.img {
   partition rootfs {
     partition-type = 0x83
     image = "rootfs.ext2"
+    offset = 8M
   }
 }
board/freescale/common/imx/genimage.cfg.template_no_boot_part_spl +1 -0
index c29032572aef..ef015918a5b2 100644
@@ -26,5 +26,6 @@ image sdcard.img {
   partition rootfs {
     partition-type = 0x83
     image = "rootfs.ext2"
+    offset = 8M
   }
 }
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 20 lines · On Sat, 13 Nov 2021 18:42:45 -0300 Fabio Estevam <[email protected]> wrote:

Currently, when BR2_LINUX_KERNEL_INSTALL_TARGET=y is selected, issuing a "saveenv" command in the U-Boot prompt may lead to rootfs corruption.

When BR2_LINUX_KERNEL_INSTALL_TARGET is not selected, then board/freescale/common/imx/genimage.cfg.template is used as per the logic inside board/freescale/common/imx/post-image.sh.

board/freescale/common/imx/genimage.cfg.template correctly puts the rootfs at a safe offset.

With BR2_LINUX_KERNEL_INSTALL_TARGET=y, then board/freescale/common/imx/genimage.cfg.template_no_boot_part or board/freescale/common/imx/genimage.cfg.template_no_boot_part_spl are used and no offset to the rootfs is given, which may cause U-Boot environment area to write into the rootfs area, causing the rootfs corruption.

Avoid this problem by placing the rootfs at an 8MB offset, just like it is done in board/freescale/common/imx/genimage.cfg.

Quoted 8 lines

Tested on a imx6qp-wandboard and also on a custom imx6ull based board.

"saveenv" does not corrupt the rootfs anymore after this change.

---
Changes since v1:
- Improve commit log (Yann)

Applied to master, thanks.

Thomas

Signature · 7 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw
In reply to Fabio Estevam
Quoted 22 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Fabio" == Fabio Estevam <[email protected]> writes:

Currently, when BR2_LINUX_KERNEL_INSTALL_TARGET=y is selected, issuing a "saveenv" command in the U-Boot prompt may lead to rootfs corruption.

When BR2_LINUX_KERNEL_INSTALL_TARGET is not selected, then board/freescale/common/imx/genimage.cfg.template is used as per the logic inside board/freescale/common/imx/post-image.sh.

board/freescale/common/imx/genimage.cfg.template correctly puts the rootfs at a safe offset.

With BR2_LINUX_KERNEL_INSTALL_TARGET=y, then board/freescale/common/imx/genimage.cfg.template_no_boot_part or board/freescale/common/imx/genimage.cfg.template_no_boot_part_spl are used and no offset to the rootfs is given, which may cause U-Boot environment area to write into the rootfs area, causing the rootfs corruption.

Avoid this problem by placing the rootfs at an 8MB offset, just like it is done in board/freescale/common/imx/genimage.cfg.

Quoted 8 lines

Tested on a imx6qp-wandboard and also on a custom imx6ull based board.

"saveenv" does not corrupt the rootfs anymore after this change.

---
Changes since v1:
- Improve commit log (Yann)

Committed to 2021.02.x and 2021.08.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot