Skip to contentSkip to conversation

Help needed: How to Specify MTD Partitions on NAND in a Device Tree

DISCUSSION Mauri Sandberg 2 participants 5 messages Feb 7, 2025 – Feb 9, 2025

lore
Share & tools
lore
#0 lore raw

Hello all,

I have a MT7621A basec SoC, which I am trying to update the boot prcess for. As it is now, I have v2024.10 based U-boot running and I can specify MTD partitions using env variable 'mtdparts' and use them all right. But I am looking for a way to specify them in a device tree.

Linux identifies the flash chip as:
[    1.830000] nand: device found, Manufacturer ID: 0xc8, Chip ID: 0xda [    1.840000] nand: ESMT NAND 256MiB 3,3V 8-bit

If someone can give my any pointers it would be much appreciated.

Thanks,
Mauri

#1 lore raw

Hi Mauri,

Here's an example:
https://github.com/openwrt/openwrt/blob/main/package/boot/uboot-mediatek/patches/105-configs-add-usefull-stuff-to-mt7988-rfb.patch#L316

Weijie

Quoted 18 lines · Mauri Sandberg <[email protected]> 于2025年2月8日周六 03:06写道:

Hello all,

I have a MT7621A basec SoC, which I am trying to update the boot prcess for. As it is now, I have v2024.10 based U-boot running and I can specify MTD partitions using env variable 'mtdparts' and use them all right. But I am looking for a way to specify them in a device tree.

Linux identifies the flash chip as:

[    1.830000] nand: device found, Manufacturer ID: 0xc8, Chip ID: 0xda
[    1.840000] nand: ESMT NAND 256MiB 3,3V 8-bit

If someone can give my any pointers it would be much appreciated.

Thanks,
Mauri

#2 lore raw

Hi Weijie

Quoted 2 lines · Weijie Gao

Here's an example:
https://github.com/openwrt/openwrt/blob/main/package/boot/uboot-mediatek/patches/105-configs-add-usefull-stuff-to-mt7988-rfb.patch#L316

Sorry, I should have been more specific. Actually defining the partitions is the simpler part. But the mt7621.dtsi in U-boot tree does not contain NAND controller node to begin with and I was not successful in defining one. I tried copying/mimicking one from the mt7621.dtsi in OpenWrt tree but that did not work out.

At the moment I get NAND working with the raw MT7621 driver only. Can I somehow drive it with "spi-nand" or somthing similar?

Mauri

#3 lore raw
Quoted 7 lines · Mauri Sandberg

Hi Weijie

Quoted 3 lines · Weijie Gao

Here's an example:
https://github.com/openwrt/openwrt/blob/main/package/boot/uboot-
mediatek/patches/105-configs-add-usefull-stuff-to-mt7988-rfb.patch#L316

Quoted 6 lines

Sorry, I should have been more specific. Actually defining the partitions is the simpler part. But the mt7621.dtsi in U-boot tree does not contain NAND controller node to begin with and I was not successful in defining one. I tried copying/mimicking one from the mt7621.dtsi in OpenWrt tree but that did not work out.

With fresh pair of eyes I found that the 'mt7621_nand.c' in OpenWrt tree implements what the U-boot version is lacking and that they are both your work. Are there plans for bringing device tree support to U-boot or would you be able to review/assist if someone tried it?

Thanks,
Mauri

#4 lore raw

I remembered that the raw nand framework does not support dt binding. It's not a uclass driver.
So the way is to rewrite the driver as a mtd uclass driver.

Best Regards,
Weijie

Quoted 25 lines · Mauri Sandberg <[email protected]> 于2025年2月8日周六 17:04写道:
Quoted 7 lines · Mauri Sandberg

Hi Weijie

Quoted 3 lines · Weijie Gao

Here's an example:
https://github.com/openwrt/openwrt/blob/main/package/boot/uboot-
mediatek/patches/105-configs-add-usefull-stuff-to-mt7988-rfb.patch#L316

Quoted 6 lines

Sorry, I should have been more specific. Actually defining the partitions is the simpler part. But the mt7621.dtsi in U-boot tree does not contain NAND controller node to begin with and I was not successful in defining one. I tried copying/mimicking one from the mt7621.dtsi in OpenWrt tree but that did not work out.

With fresh pair of eyes I found that the 'mt7621_nand.c' in OpenWrt tree implements what the U-boot version is lacking and that they are both your work. Are there plans for bringing device tree support to U-boot or would you be able to review/assist if someone tried it?

Thanks,
Mauri