Skip to contentSkip to conversation

distro bootcmd: auto write GPT table in scan_dev_for_boot_part

U-Boot Eddie Cai 2 participants 2 messages Mar 6, 2017 – Mar 7, 2017

lore
Share & tools
lore

Eddie Cai

author
#0 lore raw

scan_dev_for_boot_part will fail when there is no GPT table. So add auto write GPT table if fail to get it.

---
 include/config_distro_bootcmd.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/config_distro_bootcmd.h +8 -0
index 0e01e82..3be8ffa 100644
@@ -368,6 +368,14 @@
 		"\0"                                                      \
 	\
 	"scan_dev_for_boot_part="                                         \
+		"part list ${devtype} ${devnum} -bootable test; "		\
+		"if env exists test; then "		\
+			"echo Found valid partition table; "		\
+		"else "		\
+			"echo No valid partition table, write the original partition table; "		\
+			"gpt write ${devtype} ${devnum} ${partitions}; "		\
+			"mmc rescan;"		\
+		"fi;"		\
 		"part list ${devtype} ${devnum} -bootable devplist; "     \
 		"env exists devplist || setenv devplist 1; "              \
 		"for distro_bootpart in ${devplist}; do "                 \
Signature · 1 line
2.7.4
#1 lore raw
Quoted 17 lines · Eddie Cai

scan_dev_for_boot_part will fail when there is no GPT table. So add auto write GPT table if fail to get it.

---
 include/config_distro_bootcmd.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/config_distro_bootcmd.h +1 -0
index 0e01e82..3be8ffa 100644
@@ -368,6 +368,14 @@
 		"\0"                                                      \
 	\
 	"scan_dev_for_boot_part="                                         \
+		"part list ${devtype} ${devnum} -bootable test; "		\

include/config_distro_bootcmd.h line 381

Quoted 10 lines
include/config_distro_bootcmd.h +7 -0
+		"if env exists test; then "		\
+			"echo Found valid partition table; "		\
+		"else "		\
+			"echo No valid partition table, write the original partition table; "		\
+			"gpt write ${devtype} ${devnum} ${partitions}; "		\
+			"mmc rescan;"		\
+		"fi;"		\
 		"part list ${devtype} ${devnum} -bootable devplist; "     \
 		"env exists devplist || setenv devplist 1; "              \
 		"for distro_bootpart in ${devplist}; do "                 \

Er, this feels rather risky to me. Why are we writing a table? How do we know it exists?

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170307/aa300201/attachment.sig>