Skip to content

Commit b64ed9e

Browse files
committed
read_info: Fix detection ReadOnly flag for mtd partition
1 parent 1874aa6 commit b64ed9e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

read_info.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ def get_part_info(self, mtd_max_num, verbose = None):
245245
cmd += f" cat {mtd_dev}/mtdblock$i/ro {dn} | {trim} | {a2f} ; {delim} ;"
246246
cmd += f" cat {mtd_dev}/dev {dn} | {trim} | {a2f} ; {delim} ;"
247247
cmd += f" readlink -f {mtd_dev}/device {dn} | {trim} | {a2f} ; {delim} ;"
248+
cmd += f" mtd -l 1 dump /dev/mtd$i {dn} | wc -c | {trim} | {a2f} ; {delim} ;"
248249
cmd += f'done'
249250
out_text = self.run_command(cmd, fn)
250251
if not out_text:
@@ -259,7 +260,7 @@ def get_part_info(self, mtd_max_num, verbose = None):
259260
info[mtd_num]["addr"] = int(mtd_info[0], 0) if len(mtd_info[0]) > 0 else None
260261
info[mtd_num]["type"] = mtd_info[1].strip()
261262
info[mtd_num]["flags"] = int(mtd_info[2], 0) if len(mtd_info[2]) > 0 else None
262-
info[mtd_num]["ro"] = int(mtd_info[3], 0) if len(mtd_info[3]) > 0 else None
263+
info[mtd_num]["ro"] = 0 if mtd_info[6] == '1' else 1
263264
info[mtd_num]["dev"] = mtd_info[4].strip()
264265
info[mtd_num]["device"] = mtd_info[5].strip()
265266
return info

0 commit comments

Comments
 (0)