Tlv eeprom

Hy Ladies and Gentlemen :slight_smile:

Thanks to this link here;
i can custom some information for my boards ( product name and serial number).

I need to extract one information during uboot :
-product name : to select the good device tree

I know how to display all information, but i failed to read only the product name .

DiagBox>> tlv
TLV: 0
TlvInfo Header:
   Id String:    TlvInfo
   Version:      1
   Total Length: 38
TLV Name             Code Len Value
-------------------- ---- --- -----
Serial Number        0x23  17 Orange00000000001
Product Name         0x21  11 DiagBox pro
CRC-32               0xFE   4 0x9E8C2BA2
Checksum is valid.
DiagBox>> tlv help
tlv_eeprom - Display and program the system EEPROM data block.

Usage:
tlv_eeprom [read|write|set <type_code> <string_value>|erase|list]
tlv_eeprom
    - With no arguments display the current contents.
tlv_eeprom dev [dev]
    - List devices or set current EEPROM device.
tlv_eeprom read
    - Load EEPROM data from device to memory.
tlv_eeprom write
    - Write the EEPROM data to persistent storage.
tlv_eeprom set <type_code> <string_value>
    - Set a field to a value.
    - If no string_value, field is deleted.
    - Use 'tlv_eeprom write' to make changes permanent.
tlv_eeprom erase
    - Reset the in memory EEPROM data.
    - Use 'tlv_eeprom read' to refresh the in memory EEPROM data.
    - Use 'tlv_eeprom write' to make changes permanent.
tlv_eeprom list
    - List the understood TLV codes and names.

DiagBox>> tlv read
EEPROM data loaded from device to memory.
DiagBox>>

Can someone help me please?

Thanks by advance

This functionality was never exposed through the tlv_eeprom command in u-boot. Generally this is done programatically for the specific board. You can reference the patch here to see how we are doing it with our SKU, but of course it can be easily adapted to your Product Name. cn913x_build/0013-find-fdtfile-from-tlv-eeprom.patch at master · SolidRun/cn913x_build · GitHub

1 Like

I will add that if you do feel this is feature you would like, we can probably add it to our u-boot patches easy enough. We already have a patch to pull a single TLV entry out, there just isn’t a command interface for it yet.

1 Like

Thank you to answer.

In fact, i use a fit files with kernel,dtbs into.
I have two configurations : pro and base.

/dts-v1/;
/ {
description = “Kernel et dtb”;

#address-cells = <1>;
images {
    kernel {
        description = "Kernel";
        data = /incbin/("/a/Image");
        type = "kernel";
        arch = "arm64";
        os = "linux";
        compression = "none";
        load = <0x44000000>;
        entry = <0x44000000>;
        hash-1 {
            algo = "sha1";
        };
    };
    fdt-pro {
        description = "dtb";
        data = /incbin/("/a/diagbox_pro.dtb");
        type = "flat_dt";
        arch = "arm64";
        load = <0x47000000>;
        compression = "none";
        hash-1 {
            algo = "sha1";
        };
    };
    fdt-base {
        description = "dtb";
        data = /incbin/("/a/diagbox_base.dtb");
        type = "flat_dt";
        arch = "arm64";
        load = <0x47000000>;
        compression = "none";
        hash-1 {
            algo = "sha1";
        };
    };
};

configurations {
    default = "conf-pro";
    conf-pro {
        description = "Configuration";
        kernel = "kernel";
        fdt = "fdt-pro";
        hash-1 {
            algo = "sha1";
        };
    };
    conf-base {
        description = "Configuration";
        kernel = "kernel";
        fdt = "fdt-base";
        hash-1 {
            algo = "sha1";
        };
    };
};

I tried to select thé configuration thanks to thé product name.
I will try to adapt your patch with my product names.

1 Like

I forgot to say : i don’t use a distro boot but a uEnv.txt system.

That’s why i try to get the name of board for my environnment.

One question please.
With your patch, we can know the type or thé board(base or pro) thanks to tlv if i understand.
Is it possible by modifying your patch, ro create a files or folder ,its name depending thé board(base or pro)?

With our patches we parse the SKU that is programmed to the TLV and then construct the name of the dtb file to load based on the hardware properties that the SKU designates. The specific .dtb file and name need to already be built as part of the OS image, specifically for the kernel.

You could create files and folders, based on the information parsed but generally this is not something a firmware should be doing. It should only be trying to load and determine the existing environment it is trying to boot.

1 Like

Hy,
So if i undestand, i can parse some information from tlv for my new environnment by modifying your patch.
your patch select the right Device tree, so i can replace the information to select base or pro board?

Yes that is correct. With the included patches we make it easy to pull out a single value from the TLV. You can then use that to build your device-tree path, or set an env variable for you to read out and use to load the device-tree you want.

If you want any code reviewed just email me, or support and we can do that for you.

1 Like

Hy
Thank you to answer me :slight_smile:

I will try to modify the patch, to learn and if i don’t succeed, i will send you an email with my code.