Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nvmem: layouts: u-boot-env: add optional "env-size" property

Some devices reserve a larger NVMEM region for the U-Boot environment
than the actual environment data length used by U-Boot itself. The CRC32
in the U-Boot header is calculated over the smaller data length, causing
CRC validation to fail when Linux reads the full partition.

Allow an optional device tree property "env-size" to specify the
environment data size to use for CRC computation.

v2: add missing $ref line to DT binding

Signed-off-by: Jascha Sundaresan <flizarthanon@gmail.com>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
Link: https://patch.msgid.link/20251114110636.143268-5-srini@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jascha Sundaresan and committed by
Greg Kroah-Hartman
5b2f8c13 2f9fae50

+10 -1
+7
Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml
··· 46 46 type: object 47 47 description: Command to use for automatic booting 48 48 49 + env-size: 50 + description: 51 + Size in bytes of the environment data used by U-Boot for CRC 52 + calculation. If omitted, the full NVMEM region size is used. 53 + $ref: /schemas/types.yaml#/definitions/uint32 54 + 49 55 ethaddr: 50 56 type: object 51 57 description: Ethernet interfaces base MAC address. ··· 110 104 111 105 partition-u-boot-env { 112 106 compatible = "brcm,env"; 107 + env-size = <0x20000>; 113 108 114 109 ethaddr { 115 110 };
+3 -1
drivers/nvmem/layouts/u-boot-env.c
··· 99 99 uint32_t crc32; 100 100 uint32_t calc; 101 101 uint8_t *buf; 102 + u32 env_size; 102 103 int bytes; 103 104 int err; 104 105 105 - dev_size = nvmem_dev_size(nvmem); 106 + dev_size = device_property_read_u32(dev, "env-size", &env_size) ? 107 + nvmem_dev_size(nvmem) : (size_t)env_size; 106 108 107 109 buf = kzalloc(dev_size, GFP_KERNEL); 108 110 if (!buf) {