How to add a mtd partition for mt7623a device

I've read document "https://openwrt.org/docs/techref/flash.layout", which tell us the details of flash layout on openwrt, but doesn't tell us how to add or custom the flash layout.

I've learned that there are several ways to custom the flash layout.

  1. kernel cmdline "mtdparts=xxx"
  2. partition definition in dts file
  3. add mtd_partition by defining platform device in kernel.
  4. modify target Makefile on some platform/arch (maybe on old openwrt version).

But I didn't find any clue for mt7623a device, no mtd_partition definition in platform device, no partition definition in dts file, I have no idea where is its original flash layout definition, I have no idea how to custom the flash layout either.

Strange that 'cat /proc/mtd' is empty, and 'cat /proc/partitions', its output is

  7        0    7568192 loop0
 179        0    7634944 mmcblk0
 179        1       8192 mmcblk0p1
 179        2    7589888 mmcblk0p2
 179       16       4096 mmcblk0boot1
 179        8       4096 mmcblk0boot0

Thanks all!

(Moved to the For Developers section.)

1 Like

Unfortunately, the linked document only talks about raw NAND/NOR devices and misses mentioning the 3rd and meanwhile more pre-dominant managed NAND case. What you are looking at by /dev/mmcblk0 is actually an eMMC (given its special hardware area boot partitions *boot0 and *boot1) which is a regular block device just like any other hard drive or SSD. The boot log (aka dmesg) should reveal what exact part it is. Alternatively, cat /sys/kernel/debug/mmc0/ios should tell you some more details as well. The *p1 and *p2 partitions are probably regular GPT or MBR partitions which may be modified e.g. using fdisk. In eMMC speak those are in the eMMC user area while the *boot0, *boot1 and possibly *rpmb ones are in the special boot area. Depending on the eMMC spec version and/or part vendor the boot area may or may not be one time adjustable. From Linux userspace you may also use the mmc-utils to query further options. Have fun!

Thanks for your replying.

Look at the flash layout, there are 4 partitions definition. Why not 3 or 5, or other number or size of partitions? Kernel must know the layout. But where is the layout definition?

I didn't find any definition for this platform. Maybe I miss something I don't know.

No, there are only 2 "regular" partitions mmcblk0p1 and mmcblk0p2 which as mentioned above are regular block device partitions just like on your hard drive or SSD. Upon boot, the kernel basically reads the GPT or MBR to figure those out. The other two mmcblk0boot1 and mmcblk0boot0 are "special" eMMC hardware area partitions basically hard-coded in eMMC devices usually only used by the boot ROM and/or boot loader (e.g. to hold U-Boot and its environment).

The following PDF has a nice introduction about eMMC technology.

BTW: You may find eMMC specs e.g. googling for eMMC spec.

https://www.coursehero.com/file/47959012/JESD84-B451pdf/

http://www.crystalti.com/doc/Jedec/Standards/eMMC/JESD84-B50.pdf