public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Fabio Estevam <festevam@gmail.com>
To: sbabic@denx.de
Cc: eduard@lionizers.com, u-boot@lists.denx.de,
	Fabio Estevam <festevam@denx.de>
Subject: [PATCH v5 06/14] smegw01: Only commit to new partition if update was successful
Date: Wed, 26 Apr 2023 13:04:53 -0300	[thread overview]
Message-ID: <20230426160501.1199085-6-festevam@gmail.com> (raw)
In-Reply-To: <20230426160501.1199085-1-festevam@gmail.com>

From: Eduard Strehlau <eduard@lionizers.com>

When performing rootfs update via swupdate, it is convenient to check the
'ustate' variable to decide whether the update succeeded or not.

Signed-off-by: Eduard Strehlau <eduard@lionizers.com>
Signed-off-by: Fabio Estevam <festevam@denx.de>
---
Changes since v4:
- None

 include/configs/smegw01.h | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 05edaac42f8e..277c828d0e07 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -30,13 +30,19 @@
 	"bootm_size=0x10000000\0" \
 	"mmcdev=0\0" \
 	"mmcpart=1\0" \
+	"mmcpart_committed=1\0" \
 	"mmcargs=setenv bootargs console=${console},${baudrate} " \
-		"root=/dev/mmcblk0p${mmcpart} rootwait rw " \
+		"root=/dev/mmcblk0p${mmcpart_committed} rootwait rw " \
 		__stringify(EXTRA_BOOTPARAMS) "\0" \
+	"commit_mmc=if test \"${ustate}\" = 1 -a \"${mmcpart}\" != \"${mmcpart_committed}\"; then " \
+	              "setenv mmcpart_committed ${mmcpart};" \
+								"saveenv;" \
+						  "fi;\0" \
 	"bootlimit=3\0" \
-	"loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} boot/${image}\0" \
-	"loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr} boot/${fdtfile}\0" \
+	"loadimage=load mmc ${mmcdev}:${mmcpart_committed} ${loadaddr} boot/${image}\0" \
+	"loadfdt=load mmc ${mmcdev}:${mmcpart_committed} ${fdt_addr} boot/${fdtfile}\0" \
 	"mmcboot=echo Booting from mmc ...; " \
+	  "run commit_mmc; " \
 		"run mmcargs; " \
 		"if run loadfdt; then " \
 			"if bootz ${loadaddr} - ${fdt_addr}; then " \
@@ -48,10 +54,12 @@
 			"run altbootcmd; " \
 		"fi;\0" \
 	"altbootcmd=echo Performing rollback...; " \
-		"if test \"${mmcpart}\" = 1; then " \
+		"if test \"${mmcpart_committed}\" = 1; then " \
 			"setenv mmcpart 2; " \
+			"setenv mmcpart_committed 2;" \
 		"else " \
 			"setenv mmcpart 1; " \
+			"setenv mmcpart_committed 1;" \
 		"fi; setenv bootcount 0; setenv upgrade_available; setenv ustate 3; saveenv; " \
 		"run bootcmd;\0"
 
-- 
2.34.1


  parent reply	other threads:[~2023-04-26 16:06 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-26 16:04 [PATCH v5 01/14] smegw01: Enable setting additional boot params Fabio Estevam
2023-04-26 16:04 ` [PATCH v5 02/14] smegw01: Select CONFIG_CMD_SQUASHFS Fabio Estevam
2023-05-02 12:46   ` sbabic
2023-04-26 16:04 ` [PATCH v5 03/14] smegw01: Select bootcount support Fabio Estevam
2023-05-02 12:46   ` sbabic
2023-04-26 16:04 ` [PATCH v5 04/14] smegw01: Add altbootcmd Fabio Estevam
2023-05-02 12:47   ` sbabic
2023-04-26 16:04 ` [PATCH v5 05/14] smegw01: Run altbootcmd in the case of failure Fabio Estevam
2023-05-02 12:47   ` sbabic
2023-04-26 16:04 ` Fabio Estevam [this message]
2023-05-02 12:47   ` [PATCH v5 06/14] smegw01: Only commit to new partition if update was successful sbabic
2023-04-26 16:04 ` [PATCH v5 07/14] smegw01: Enable EMMC boot from multiple partitions Fabio Estevam
2023-05-02 12:47   ` sbabic
2023-04-26 16:04 ` [PATCH v5 08/14] smegw01: Change default boot device to eMMC Fabio Estevam
2023-05-02 12:46   ` sbabic
2023-04-26 16:04 ` [PATCH v5 09/14] smegw01: Switch to fitImage Fabio Estevam
2023-05-02 12:47   ` sbabic
2023-04-26 16:04 ` [PATCH v5 10/14] smegw01: Add lockdown U-Boot env support Fabio Estevam
2023-05-02 12:47   ` sbabic
2023-04-26 16:04 ` [PATCH v5 11/14] smegw01: Read the second MAC address Fabio Estevam
2023-05-02 12:46   ` sbabic
2023-04-26 16:04 ` [PATCH v5 12/14] smegw01: Disable additional boot menu options Fabio Estevam
2023-05-02 12:47   ` sbabic
2023-04-26 16:05 ` [PATCH v5 13/14] smegw01: Fix fallback to altbootcmd Fabio Estevam
2023-05-02 12:46   ` sbabic
2023-04-26 16:05 ` [PATCH v5 14/14] smegw01: Convert CFG_EXTRA_ENV_SETTINGS to an env file Fabio Estevam
2023-04-26 17:31   ` Tom Rini
2023-05-02 12:47   ` sbabic
2023-05-02 12:47 ` [PATCH v5 01/14] smegw01: Enable setting additional boot params sbabic

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=20230426160501.1199085-6-festevam@gmail.com \
    --to=festevam@gmail.com \
    --cc=eduard@lionizers.com \
    --cc=festevam@denx.de \
    --cc=sbabic@denx.de \
    --cc=u-boot@lists.denx.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