ofnode_read_size_cells() returns wrong size

Hello Simon,
I am trying to create a test for DFU on the qemu_arm64_defconfig board. This requires saving environment variables, specifically 'preboot'.
doc/board/emulation/qemu-arm.rst suggests to create a file with:
qemu-img create -f raw envstore.img 64M
The flash can be made available to QEMU via parameter
-drive if=pflash,format=raw,index=1,file=envstore.img
64MiB is the only size that qemu-system-aarch64 accepts: "device requires 67108864 bytes"
So I tried:
qemu-system-aarch64 -machine virt -bios u-boot.bin \ -cpu cortex-a53 -nographic \ -drive if=pflash,format=raw,index=1,file=envstore.img
But I got an error trying to save:
=> saveenv Saving Environment to Flash... Error: start and/or end address not on sector boundary Error: start and/or end address not on sector boundary Failed (1)
This seems strange for CONFIG_ENV_ADDR=0x4000000.
Debugging shows that the base address of the second flash bank is detected as 0x400000000000000.
The device tree has:
#size-cells = <0x00000002>; #address-cells = <0x00000002>; flash@0 { bank-width = <0x00000004>; reg = <0x00000000 0x00000000 0x00000000 0x04000000 0x00000000 0x04000000 0x00000000 0x04000000>; compatible = "cfi-flash"; };
So that 0x400000000000000 base address is wrong.
drivers/mtd/cfi_flash.c(2478) cfi_flash_probe: addrc= 2 drivers/mtd/cfi_flash.c(2479) cfi_flash_probe: sizec= 1
So here the size of the cells is incorrectly determined as 1 by dev_read_size_cells(dev).
The reason is that fdt_address_cells() and and fdt_size_cells() don't walk up the tree as incorrectly assumed in ofnode_read_size_cells() and ofnode_read_size_addr() introduced in commit 878d68c0c357 ("dm: core: Add functions to obtain node's address/size cells").
lib/libfdt/../../scripts/dtc/libfdt/fdt_addresses.c(42) fdt_address_cells: FDT_ERR_NOTFOUND returning 2 lib/libfdt/../../scripts/dtc/libfdt/fdt_addresses.c(54) fdt_size_cells: FDT_ERR_NOTFOUND returning 1
I will provide a patch for drivers/mtd/cfi_flash.c but could you, please, take care of drivers/core/ofnode.c.
Best regards
Heinrich
participants (1)
-
Heinrich Schuchardt