Skip to content

espflash save-image produces a different image inside and outside of Nix package build #935

@flippette

Description

@flippette

I'm building a firmware with this flake, and espflash is being called like this:

postInstall = ''
  # generate a flat firmware binary (for OTA, etc.)
  ${espflash}/bin/espflash save-image \
    --chip esp32c6 \
    $out/bin/$pname \
    $out/bin/$pname-$version.bin
'';

Running esptool on this generated firmware binary shows that the checksum and validation hash are invalid:

esp-template on  main ❯ nix run nixpkgs#esptool -- image_info result/bin/esp-template-0.1.0.bin | tail -n 2
Checksum: 42 (invalid - calculated 52)
Validation Hash: 7ee766842072a8493801cbfd70096c5541a57c15ff2d8add597f54793bf0847f (invalid)

However, if I run espflash save-image myself after the build on the same ELF binary, that image is valid by esptool:

esp-template on  main ❯ espflash save-image --chip esp32c6 result/bin/esp-template output.bin
Chip type:         esp32c6
Merge:             false
Skip padding:      false
App/part. size:    28,160/4,128,768 bytes, 0.68%
[2025-07-30T19:42:31Z INFO ] Image successfully saved!
esp-template on  main [?] ❯ nix run nixpkgs#esptool -- image_info output.bin | tail -n 2
Checksum: 52 (valid)
Validation Hash: 940606d072d9b290e9f0af23fbba19a11f537d0f73a12c72d538a563e9a1aaed (valid)

Diffing the 2 binary files shows this:

esp-template on  main [?] ❯ diff valid.hex invalid.hex
1758,1760c1758,1760
< 00006dd0: 0000 0000 0000 0000 0000 0000 0000 0052  ...............R
< 00006de0: 9406 06d0 72d9 b290 e9f0 af23 fbba 19a1  ....r......#....
< 00006df0: 1f53 7d0f 73a1 2c72 d538 a563 e9a1 aaed  .S}.s.,r.8.c....
---
> 00006dd0: 0000 0000 0000 0000 0000 0000 0000 0042  ...............B
> 00006de0: 4bdc b57b 2dbb 21cc 913a 311a e3e5 03a7  K..{-.!..:1.....
> 00006df0: f325 8ec7 f04b 3257 ce4e 45b2 4075 48ca  .%...K2W.NE.@uH.

espflash is version 4.0.1 both inside and outside of the flake.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions