MTD partitioning & firmware installation on Broadcom devices

Rafał Miłecki zajec5 at gmail.com
Mon Mar 22 18:23:38 GMT 2021


On 08.03.2021 18:37, Rafał Miłecki wrote:
> Solution #2
> Flashing firmware image as is (with cferam.000) and adjusting it.
> This should be nicer as mounting JFFS2 MTD partition is simple. The
> problem is partitioning.
> I'd need to remove MTD partitions and trigger re-partitioning of
> "firmware" partition. Only once I have Linux create "bootfs" and "ubi"
> partitions again for me I could mount "bootfs" and rename the file.
> There is no support for such repartitioning at this point AFAIK.

I've implemented that solution. Kernel part was trivial actually, I just
wired up BLKRRPART ioctl.

The problem is it doesn't work. Doing "mv cferam.000 cferam.123" results
in marking cferam.000 node as deleted and adding a new cferam.123 node
hardlinking to the original content. Sounds good but CFE bootloader is
too stupid for that. It doesn't recognize deleted files (nodes) and
believes cferam.000 is still there.

I don't want to implement JFFS2 hacks changing its rename support
implementation. So I've to proceed with Solution #1 and just write
tool modifying JFFS2 image before flashing it to the MTD.

--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -1015,8 +1015,11 @@ static int mtdchar_ioctl(struct file *fi

  	case BLKRRPART:
  	{
-		/* No reread partition feature. Just return ok */
-		ret = 0;
+		int nr_parts;
+
+		del_mtd_partitions(mtd);
+		nr_parts = parse_mtd_partitions(mtd, NULL, NULL);
+		ret = nr_parts < 0 ? nr_parts : 0;
  		break;
  	}
  	}



More information about the linux-mtd mailing list