How do I write and read board serial number in IoT Yocto BSP

I have ported the IoT Yocto BSP to my board. I am using Genio 700 (MT8390). Is there a pre-defined partition in the IoT Yocto BSP that I can use to store my board serial number?

In my case, each board must have a different serial number and the list of serial numbers are generated statically. Is there a method to program(flash) a serial number using the flash tool (genio-flash)? and how do I read these serial numbers from my userspace program?

The IoT Yocto BSP uses U-Boot. U-Boot already has a special U-boot environment variable serial# defined for this purpose.

Since the serial# is per-board, they usually need to be programmed during the board flashing process. The genio-tools genio-flash command has an option that allows you to assign the value of serial# during flashing:

For example, run

genio-flash --serialno BID0003

This sets the the U-boot environment variable serial# to BID0003.
During boot, U-Boot boot script then takes this variable and update the serial-number property in the device tree.

You can run this command in the linux console:

fdtdump /sys/firmware/fdt

and find the serial-number is defined in the device tree:

/ {
    serial-number = "ABCD1234";
}

Other drivers and middleware may then take this information as the board identitifer.