Free (small) partition for storing serial number?

In case others google their way to here:
I finally managed to crack this challenge …

The solution was to create extra ufs partitions in the “system” (mtd13) mtd partition with my data.
This way, all can be restored, even if (when) /mnt/flash (“userapp” mtd16) is trashed or cleared.

Incidentally, /home/root lives on the “userapp” partition and will be lost if it is cleared.

Here is my solution from “mdm9x28-image-minimal.bbappend” that adds two extra partitions:

# Spiffy: We can append to the create_ubinize_config() method
create_ubinize_config_append() {

    if [[ -s ${dm_root_hash_path} && -f /tmp/amplex-image.tar.bz2 ]]; then
        echo >> $cfg_path
        echo \[amplex_tbz\] >> $cfg_path
        echo mode=ubi >> $cfg_path
        echo image="/tmp/amplex-image.tar.bz2" >> $cfg_path
        echo vol_id=3 >> $cfg_path
        echo vol_type=static >> $cfg_path
        echo vol_name=amplex_tbz >> $cfg_path
        echo vol_alignment=1 >> $cfg_path
    fi

    if [[ -s ${dm_root_hash_path} && -f /tmp/amplex-param.conf ]]; then
        echo >> $cfg_path
        echo \[amplex_param\] >> $cfg_path
        echo mode=ubi >> $cfg_path
        echo image="/tmp/amplex-param.conf" >> $cfg_path
        echo vol_id=4 >> $cfg_path
        echo vol_type=static >> $cfg_path
        echo vol_name=amplex_param >> $cfg_path
        echo vol_alignment=1 >> $cfg_path
    fi

And the result on the target:

> lsmtd
...
mtd11       90:22  aboot        nand        1M
mtd12       90:24  boot         nand       15M
mtd13       90:26  system       nand       30M
└─ubi0     237:0                         29.1M
  ├─ubi0_0 237:1   rootfs       static   24.9M
  ├─ubi0_1 237:2   rootfs_hs    static    248K
  ├─ubi0_2 237:3   rootfs_rhs   static    248K
  ├─ubi0_3 237:4   amplex_tbz   static    992K
  └─ubi0_4 237:5   amplex_param static    248K
mtd14       90:28  lefwkro      nand      8.8M
└─ubi2     235:0                          8.4M
  ├─ubi2_0 235:1   legato       static    5.1M
  ├─ubi2_1 235:2   legato_hs    static    248K
  └─ubi2_2 235:3   legato_rhs   static    248K
...

> cat /dev/ubi0_4
# Amplex config
serial_0 = 2004042042
1 Like