fixed partitions issue
Dear all,
I'm encountering an issue with fixed-partitions on spinor with v2025.07.0 that was not there in v2025.01.0.
The partitions are configured as follows:
partitions {
compatible = "fixed-partitions";
#size-cells = <1>;
#address-cells = <1>;
barebox: partition@0 {
label = "barebox";
reg = <0x0 0x0100000>;
};
barebox_env: partition@100000 {
label = "barebox-env";
reg = <0x0100000 0x100000>;
};
barebox_state: partition@200000 {
label = "barebox-state";
reg = <0x0100000 0x100000>;
};
};It seems to me the partition offsets (0, 0x100000, 0x200000) are not taken into account so the results is that all the partitions point to the same piece of memory. That's how I tested it:
############
# v2025.01.0
barebox@mk8:/ md5sum /dev/nor0.barebox 937e462b306c7295096fb9446a97645f /dev/nor0.barebox barebox@mk8:/ md5sum /dev/nor0.barebox-env 2fdd6851b32ae931637d4845c037b550 /dev/nor0.barebox-env barebox@mk8:/ md5sum /dev/nor0.barebox-state 2fdd6851b32ae931637d4845c037b550 /dev/nor0.barebox-state
barebox@mk8:/ nv a=a
nv variable modified, will save nv variables on shutdown barebox@mk8:/ nv -s
envfs: no envfs (magic mismatch) - envfs never written?
barebox@mk8:/ md5sum /dev/nor0.barebox 937e462b306c7295096fb9446a97645f /dev/nor0.barebox barebox@mk8:/ md5sum /dev/nor0.barebox-env392559d1b391d7fe69e36d068998983c /dev/nor0.barebox-env -> it is expected to change
barebox@mk8:/ md5sum /dev/nor0.barebox-state 2fdd6851b32ae931637d4845c037b550 /dev/nor0.barebox-state
############
# v2025.07.0
barebox@mk8:/ md5sum /dev/nor0.barebox 01b367b04e57af6f4153b0043da594bc /dev/nor0.barebox barebox@mk8:/ md5sum /dev/nor0.barebox-env 01b367b04e57af6f4153b0043da594bc /dev/nor0.barebox-env barebox@mk8:/ md5sum /dev/nor0.barebox-state 01b367b04e57af6f4153b0043da594bc /dev/nor0.barebox-state
barebox@mk8:/ nv a=a
nv variable modified, will save nv variables on shutdown barebox@mk8:/ nv -s
envfs: no envfs (magic mismatch) - envfs never written?
barebox@mk8:/ md5sum /dev/nor0.bareboxd41d8cd98f00b204e9800998ecf8427e /dev/nor0.barebox -> it is NOT expected to change
barebox@mk8:/ md5sum /dev/nor0.barebox-envd41d8cd98f00b204e9800998ecf8427e /dev/nor0.barebox-env -> it is expected to change
barebox@mk8:/ md5sum /dev/nor0.barebox-stated41d8cd98f00b204e9800998ecf8427e /dev/nor0.barebox-state -> it is NOT expected to change
Do you have any hint? After the changes on drivers/of/partition.c between v2025.01.0 and v2025.07.0 shall I need to change something in my dts?
Best,
Stefano
Hi Stefano,
Quoted 18 lines · Stefano Manni
Dear all,
I'm encountering an issue with fixed-partitions on spinor with v2025.07.0 that
was not there in v2025.01.0.The partitions are configured as follows:
partitions {
compatible = "fixed-partitions";
#size-cells = <1>;
#address-cells = <1>;barebox: partition@0 {
label = "barebox";
reg = <0x00x0100000>;
};
Quoted 8 lines
barebox_env: partition@100000 {
label = "barebox-env";
reg = <0x01000000x100000>;
};
barebox_state: partition@200000 {
label = "barebox-state";
reg = <0x01000000x100000>;
The first cell is the start address, so this should be 0x200000, not 0x0100000.
Quoted 5 lines
};
};It seems to me the partition offsets (0,
0x100000,0x200000) are not taken into account
The unit address in the node name is never parsed as address, neither in barebox or in Linux. What's in reg is what matters.
Quoted 2 lines
so the results is that all the partitions point to the same piece of memory. That's how I tested it:
The devinfo command without arguments will show you the start/end address of all partitions.
Quoted 2 lines
Do you have any hint? After the changes on
drivers/of/partition.cbetween v2025.01.0 and v2025.07.0
I don't know how it worked before, but that DT description is buggy. What changed is that barebox doesn't refuse identical partitions, it just makes the dupes a link to the first registered.
Do you maybe have board code that calls devfs_add_partition()?
The output of devinfo in both versions would be useful as well to understand this.
Quoted 1 line
shall I need to change something in my dts?
It should work after fixing the reg properties. There has been changes around the partition handling stuff, but they affected only fixed partitions in eMMC/EEPROM. The MTD binding is an upstream binding and no intentional changes happened here.
Cheers,
Ahmad
Quoted 15 lines
Best,
Stefano
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hi Ahmad,
Quoted 7 lines · Ahmad Fatoum
Quoted 4 lines
barebox_state: partition@200000 { label = "barebox-state"; reg = <0x0100000 0x100000>;The first cell is the start address, so this should be
0x200000, not0x0100000.
you are right I was in the mid of a change to resize partitions. Now the dts looks like:
barebox: partition@0 {
label = "barebox";
reg = <0x0 0x0200000>;
};
barebox_env: partition@200000 {
label = "barebox-env";
reg = <0x0200000 0x040000>;
};
barebox_state: partition@240000 {
label = "barebox-state";
reg = <0x0240000 0x040000>;
};
Quoted 2 lines
Do you maybe have board code that calls
devfs_add_partition()?
no
Quoted 3 lines
The output of devinfo in both versions would be useful as well to understand this.
unfortunately devinfo reports the same information on both v2025.01.0 and v2025.07.0
`-- [email protected]
`-- flash@00
`-- nor0 `-- 0x00000000-0x00ffffff ( 16 MiB): /dev/nor0 `-- nor0.barebox `-- 0x00000000-0x001fffff ( 2 MiB): /dev/nor0.barebox `-- nor0.barebox-env `-- 0x00000000-0x0003ffff ( 256 KiB): /dev/nor0.barebox-env `-- nor0.barebox-state `-- 0x00000000-0x0003ffff ( 256 KiB): /dev/nor0.barebox-state
On v2025.07.0 every time I write barebox-env part (e.g. with nv command) also barebox part is written. This on v2025.01.0 does not happen.
I supposed the problem was in the fixed-partition bindings but maybe it is somewhere else, for example in the spinor driver.
Is that something I may test to understand more?
Best,
Stefano
Hello Stefano,
Quoted 7 lines · Stefano Manni
On v2025.07.0 every time I write barebox-env part (e.g. with nv command) also barebox part is written. This on v2025.01.0 does not happen.
I supposed the problem was in the fixed-partition bindings but maybe it is somewhere else, for example in the spinor driver.
Is that something I may test to understand more?
The issue was easily reproducible in QEMU with the virt platform or vexpress platform, e.g. for multi_v8_defconfig:
pytest --lg-env test/arm/multi_v8_defconfig.yaml --interactive
and then
barebox@ARM QEMU virt64:/ md -s /dev/nor0.initramfs 0+16 ; md -s /dev/nor0.barebox-environment 0+16
00000000: 00000000 00000000 00000000 00000000 ................
00000000: 00000000 00000000 00000000 00000000 ................
barebox@ARM QEMU virt64:/ saveenv
saving environment to /dev/nor0.barebox-environment
barebox@ARM QEMU virt64:/ md -s /dev/nor0.initramfs 0+16 ; md -s /dev/nor0.barebox-environment 0+16
00000000: 798fba79 00000000 00000000 00000000 y..y............
00000000: 798fba79 00000000 00000000 00000000 y..y............
I ran a git bisect and found the issue to be introduced by Sascha's commit 6d2b6f399c07 ("cdev: pass master cdev to cdev ops").
This was first included in v2025.07.0.
@Sascha, can you look into this?
Thanks,
Ahmad
Quoted 11 lines
Best,
Stefano
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |