Skip to content

Add Add CONFIG_MTD_PARTITIONED_MASTER kernel config for aspeed arm64 - #622

Open
prajjwal-arista wants to merge 1 commit into
sonic-net:masterfrom
prajjwal-arista:add-aspeed-CONFIG_MTD_PARTITIONED_MASTER
Open

Add Add CONFIG_MTD_PARTITIONED_MASTER kernel config for aspeed arm64#622
prajjwal-arista wants to merge 1 commit into
sonic-net:masterfrom
prajjwal-arista:add-aspeed-CONFIG_MTD_PARTITIONED_MASTER

Conversation

@prajjwal-arista

Copy link
Copy Markdown
Contributor

Description

Add CONFIG_MTD_PARTITIONED_MASTER=y to kernel config for arm64 aspeed config.

Why I did it

CONFIG_MTD_PARTITIONED_MASTER=y enables to retain the master (entire, unpartitioned) Memory Technology Device (MTD) node in user space even when the flash memory is divided into smaller partitions.
Therefore, this enables full device access which will be useful for low-level utilities, firmware backups, or flashing tools

How I did it

Added CONFIG_MTD_PARTITIONED_MASTER=y to file config.local/arm64/config.sonic-aspeed

How I tested it

Manual testing -

without the fix:

admin@sonic:~$ cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00400000 00010000 "u-boot"
mtd1: 00020000 00010000 "u-boot-env"
mtd2: 00900000 00010000 "kernel"
mtd3: 052e0000 00010000 "rofs"
mtd4: 02000000 00010000 "rwfs"
mtd5: 08000000 00010000 "bmc-secondary"

with the fix:

admin@sonic:~$ cat /proc/mtd
dev:    size   erasesize  name
mtd0: 08000000 00010000 "bmc-primary"
mtd1: 00400000 00010000 "u-boot"
mtd2: 00020000 00010000 "u-boot-env"
mtd3: 00900000 00010000 "kernel"
mtd4: 052e0000 00010000 "rofs"
mtd5: 02000000 00010000 "rwfs"
mtd6: 08000000 00010000 "bmc-secondary"

Backport

Backport required in 202608

@prajjwal-arista
prajjwal-arista requested a review from a team as a code owner September 8, 2026 04:53
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@vivekverma-arista

Copy link
Copy Markdown

cc @chander-nexthop @yxieca @saiarcot895 @nats-nokia for review

@paulmenzel paulmenzel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your patch. It’d be great if you amended the commit message:

CONFIG_MTD_PARTITIONED_MASTER=y enables to retain the master (entire, unpartitioned)
Memory Technology Device (MTD) node in user space even when the flash memory is
divided into smaller partitions.
Therefore, this enables full device access which will be useful for low-level utilities,
firmware backups, or flashing tools

Please add a section how to verify, that everything works as expected. New Linux log messages? New devices in /dev/? Please also name the device you tested this on.

CONFIG_MTD_PARTITIONED_MASTER=y retains the master (entire, unpartitioned)
Memory Technology Device (MTD) node in user space even when the flash memory
is divided into smaller partitions. This enables full device access which is
useful for low-level utilities, firmware backups, or flashing tools.

Tested on: AST2700 BMC DUT (Platform: arm64-arista_goldfinch-r0)

Verification:

  Without CONFIG_MTD_PARTITIONED_MASTER:

    $ cat /proc/mtd
    dev:    size   erasesize  name
    mtd0: 00400000 00010000 "u-boot"
    mtd1: 00020000 00010000 "u-boot-env"
    mtd2: 00900000 00010000 "kernel"
    mtd3: 052e0000 00010000 "rofs"
    mtd4: 02000000 00010000 "rwfs"
    mtd5: 08000000 00010000 "bmc-secondary"

    $ ls /dev/mtd/by-name/
    bmc-secondary -> ../../mtd5
    kernel -> ../../mtd2
    rofs -> ../../mtd3
    rwfs -> ../../mtd4
    u-boot -> ../../mtd0
    u-boot-env -> ../../mtd1

  With CONFIG_MTD_PARTITIONED_MASTER=y:

    $ cat /proc/mtd
    dev:    size   erasesize  name
    mtd0: 08000000 00010000 "bmc-primary"
    mtd1: 00400000 00010000 "u-boot"
    mtd2: 00020000 00010000 "u-boot-env"
    mtd3: 00900000 00010000 "kernel"
    mtd4: 052e0000 00010000 "rofs"
    mtd5: 02000000 00010000 "rwfs"
    mtd6: 08000000 00010000 "bmc-secondary"

    $ ls /dev/mtd/by-name/
    bmc-primary -> ../../mtd0
    bmc-secondary -> ../../mtd6
    kernel -> ../../mtd3
    rofs -> ../../mtd4
    rwfs -> ../../mtd5
    u-boot -> ../../mtd1
    u-boot-env -> ../../mtd2

  The master MTD node "bmc-primary" (128MB, mtd0) and its device nodes
  /dev/mtd0 are now visible alongside the individual partitions.

  Kernel log messages (dmesg | grep -i mtd) are identical in both cases —
  no additional log output is produced by this config option.

Signed-off-by: Prajjwal Singh <prajjwal@arista.com>
@prajjwal-arista
prajjwal-arista force-pushed the add-aspeed-CONFIG_MTD_PARTITIONED_MASTER branch from ad9608e to 64c72a1 Compare September 8, 2026 12:24
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@prajjwal-arista

Copy link
Copy Markdown
Contributor Author

@paulmenzel
Thanks. Updated the commit msg.

@nats-nokia nats-nokia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires changes on our platform code.
We will adapt our code to have this kernel config change.

@saiarcot895

Copy link
Copy Markdown
Contributor

@DannyIsa @chander-nexthop can you review these changes? This may require changes to your platform code as there will be an additional mtd device visible, and blind usage of that device will cause issues.

@prajjwal-arista is there any metadata on that mtd0 device to make it apparent that that is a full device and not a partition? Something in udevadm info /dev/mtd0, or similar?

@chander-nexthop

Copy link
Copy Markdown
Contributor

Thanks @saiarcot895. Checked the Nexthop B27 (Aspeed) paths — no Nexthop impact. Our U-Boot env access is name-based (sonic-fw-env-config.sh greps /proc/mtd for the "u-boot-env" label), so it follows the partition after the master shows up at mtd0.

@prajjwal-arista one cleanup request: in sonic-buildimage, platform/aspeed/platform_arm64.conf hardcodes FW_ENV_DEFAULT='/dev/mtd1 ...', which now points at u-boot instead of u-boot-env after this shift. It's a different repo, but please make that change alongside this PR so the index shift is handled in one place.

prajjwal-arista added a commit to prajjwal-arista/sonic-buildimage that referenced this pull request Sep 10, 2026
…ASTER

With CONFIG_MTD_PARTITIONED_MASTER=y enabled in sonic-linux-kernel
(sonic-net/sonic-linux-kernel#622), the master MTD node is retained as mtd0,
shifting all partition indices by one. Update FW_ENV_DEFAULT from /dev/mtd1 to
/dev/mtd2 to point to the correct u-boot-env partition under the new layout.

Signed-off-by: Prajjwal Singh <prajjwal@arista.com>
@prajjwal-arista

Copy link
Copy Markdown
Contributor Author

@saiarcot895

Here is the difference between the master device (mtd0) and a partition (mtd1) visible via udevadm info:

admin@sonic:~$ udevadm info /dev/mtd0 --no-pager
P: /devices/platform/soc@14000000/14000000.spi/spi_master/spi0/spi0.0/mtd/mtd0
M: mtd0
R: 0
J: c90:0
U: mtd
T: mtd
D: c 90:0
N: mtd0
L: 0
S: mtd/by-name/bmc-primary
E: DEVPATH=/devices/platform/soc@14000000/14000000.spi/spi_master/spi0/spi0.0/mtd/mtd0
E: DEVNAME=/dev/mtd0
E: DEVTYPE=mtd
E: OF_NAME=flash
E: OF_FULLNAME=/soc@14000000/spi@14000000/flash@0
E: OF_COMPATIBLE_0=jedec,spi-nor
E: OF_COMPATIBLE_N=1
E: MAJOR=90
E: MINOR=0
E: SUBSYSTEM=mtd
E: USEC_INITIALIZED=17151283
E: NVME_HOST_IFACE=none
E: DEVLINKS=/dev/mtd/by-name/bmc-primary
E: TAGS=:systemd:
E: CURRENT_TAGS=:systemd:

admin@sonic:~$ udevadm info /dev/mtd1 --no-pager
P: /devices/platform/soc@14000000/14000000.spi/spi_master/spi0/spi0.0/mtd/mtd0/mtd1
M: mtd1
R: 1
J: c90:2
U: mtd
T: mtd
D: c 90:2
N: mtd1
L: 0
S: mtd/by-name/u-boot
E: DEVPATH=/devices/platform/soc@14000000/14000000.spi/spi_master/spi0/spi0.0/mtd/mtd0/mtd1
E: DEVNAME=/dev/mtd1
E: DEVTYPE=mtd
E: OF_NAME=u-boot
E: OF_FULLNAME=/soc@14000000/spi@14000000/flash@0/partitions/u-boot@0
E: OF_COMPATIBLE_N=0
E: MAJOR=90
E: MINOR=2
E: SUBSYSTEM=mtd
E: USEC_INITIALIZED=17292618
E: NVME_HOST_IFACE=none
E: DEVLINKS=/dev/mtd/by-name/u-boot
E: TAGS=:systemd:
E: CURRENT_TAGS=:systemd:

Key differences :

  1. DEVPATH: The partition mtd1 is a child of mtd0 in the sysfs hierarchy — .../mtd/mtd0/mtd1 vs .../mtd/mtd0
  2. OF_FULLNAME: The master device points to the whole flash (/soc@.../flash@0), while the partition includes /partitions/ in its path (/soc@.../flash@0/partitions/u-boot@0)

@prajjwal-arista

prajjwal-arista commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

@chander-nexthop
here is the PR for updating the aspeed platform FW_ENV_DEFAULT var.
sonic-net/sonic-buildimage#29461

I dont see this ENV var being used in sonic-buildimage anywhere. Where is this used?
Do we have a hard dependency of both these PRs to go together?

@chander-nexthop

Copy link
Copy Markdown
Contributor

@chander-nexthop here is the PR for updating the aspeed platform FW_ENV_DEFAULT var. sonic-net/sonic-buildimage#29461

I dont see this ENV var being used in sonic-buildimage anywhere. Where is this used? Do we have a hard dependency of both these PRs to go together?

No hard dependency, that was dangling reference and I thought its better to clean that up as any future use of that var will result in bugs with this change. Just request a follow up to ensure that PR too gets merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants