Skip to content

Embed Serial Number #4

Description

@JohnAZoidberg

Put somewhere it won't be overridden by the customer flashing their own firmware.

Two options:

  • Embed with linker script
  • Embed with UF2

For both we have to create a build script that builds a different variant of the firmware.
The script accepts the serial number and embeds it in the image.

The regular build script that customers would use builds an image that doesn't include this section with the serial number. And it also must avoid overriding the serial number when flashing.

Linker Script

The serial number could be embedded in the executable via a linker script. QMK let's you easily use your own linker script.
@kiram9 you suggested this. How would we avoid the customer overwriting the serial number when they flash their own binary?

WIP branch: https://github.com/FrameworkComputer/qmk_firmware/commits/lotus-ld

UF2

A UF2 file is just a series of independent 512B blocks that each say which address they should be flashed to and include the data.
I think if we put a block at the end it won't interfere with the firmware. But the script must check that there is enough empty space.
We can reserve one of these blocks for the serial number. The factory build script includes this block in the UF2 file, the regular script doesn't.

This way the serial number is preserved if the customer uses the default build script that we'll upstream to QMK.
They could modify it to overwrite the entire flash.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    cleanupWorking but needs cleanupin progresswork in progresspvtShould be ready for PVTstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions