From: grygorii tertychnyi <grembeter@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH] cmd: mmc: modify partconf to be used in script
Date: Sat, 12 Dec 2020 08:46:33 +0100 [thread overview]
Message-ID: <20201212074633.891704-1-grembeter@outlook.com> (raw)
To implement dual-boot strategy we need to know what is the current
boot partition for U-Boot. It can be easily identified by looking at
the PARTITION_CONFIG value shown by "mmc partconf dev", but I didn't
find any way to use it in the boot script.
Hence, modify it, so that "mmc partboot dev part_num" command returns
true if "part_num" is the current boot partition, otherwise it returns
false.
Signed-off-by: Grygorii Tertychnyi <grygorii.tertychnyi@leica-geosystems.com>
---
cmd/mmc.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/cmd/mmc.c b/cmd/mmc.c
index 1529a3e05ddd..c8db008bc90d 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -792,6 +792,23 @@ static int mmc_partconf_print(struct mmc *mmc)
return CMD_RET_SUCCESS;
}
+static int mmc_partnum_cmp(struct mmc *mmc, u8 part_num)
+{
+ u8 part;
+
+ if (mmc->part_config == MMCPART_NOAVAILABLE) {
+ printf("No part_config info for ver. 0x%x\n", mmc->version);
+ return CMD_RET_FAILURE;
+ }
+
+ part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
+
+ if (part == part_num)
+ return CMD_RET_SUCCESS;
+ else
+ return CMD_RET_FAILURE;
+}
+
static int do_mmc_partconf(struct cmd_tbl *cmdtp, int flag,
int argc, char *const argv[])
{
@@ -799,7 +816,7 @@ static int do_mmc_partconf(struct cmd_tbl *cmdtp, int flag,
struct mmc *mmc;
u8 ack, part_num, access;
- if (argc != 2 && argc != 5)
+ if (argc != 2 && argc != 3 && argc != 5)
return CMD_RET_USAGE;
dev = simple_strtoul(argv[1], NULL, 10);
@@ -815,6 +832,10 @@ static int do_mmc_partconf(struct cmd_tbl *cmdtp, int flag,
if (argc == 2)
return mmc_partconf_print(mmc);
+ if (argc == 3) {
+ part_num = simple_strtoul(argv[2], NULL, 10);
+ return mmc_partnum_cmp(mmc, part_num);
+ }
ack = simple_strtoul(argv[2], NULL, 10);
part_num = simple_strtoul(argv[3], NULL, 10);
--
2.25.1
next reply other threads:[~2020-12-12 7:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20201212181434epcas1p239747ef2ac0096fe61e830e86efde7cc@epcas1p2.samsung.com>
2020-12-12 7:46 ` grygorii tertychnyi [this message]
2020-12-14 9:59 ` [PATCH] cmd: mmc: modify partconf to be used in script Jaehoon Chung
2020-12-14 14:45 ` gr embeter
2020-12-14 21:47 ` Jaehoon Chung
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=20201212074633.891704-1-grembeter@outlook.com \
--to=grembeter@gmail.com \
--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