Can I modify nrf52840 manufacturer ID and model ID by using "flash write" command in shell sample?

Hello,

I am looking to conduct a test to simulate a Zigbee device using nrf52840 in the Zigbee:shell sample. This involves modifying the manufacturer ID and model ID. If it is possible to modify them using the "flash write" command in the shell example? If yes, how to input the parameters of the command?

uart:~$ flash --help
flash - Flash shell commands
Subcommands:
erase :[<device>] <page address> [<size>]
read :[<device>] <address> [<Dword count>]
test :[<device>] <address> <size> <repeat count>
write :[<device>] <address> <dword> [<dword>...]

Thank you.

  • Hi jostar,

    The Shell sample only has the mandatory attributes of the Basic cluster (ZB_ZCL_DECLARE_BASIC_ATTRIB_LIST and not ZB_ZCL_DECLARE_BASIC_ATTRIB_LIST_EXT).
    ManufacturerName and ModelIdentifier attributes are optional and only included if you use the extended list, so you will have to modify the Shell sample.

    Using flash write would be tricky because you will have to find where these attributes are stored. It's much easier just to modify it in the code itself (from the light bulb sample):

    ZB_ZCL_SET_STRING_VAL(
         dev_ctx.basic_attr.mf_name,
         BULB_INIT_BASIC_MANUF_NAME,
         ZB_ZCL_STRING_CONST_SIZE(BULB_INIT_BASIC_MANUF_NAME));

    ZB_ZCL_SET_STRING_VAL(
         dev_ctx.basic_attr.model_id,
         BULB_INIT_BASIC_MODEL_ID,
         ZB_ZCL_STRING_CONST_SIZE(BULB_INIT_BASIC_MODEL_ID));

  • Hi Hieu,

        Thanks for your help, if there exist any way to modify the ManufacturerName and ModelIdentifier attributes without rebuild the src code and flash to the nrf52840?

    Best regard~

  • Hi jostar,

    Since you mentioned this is for testing, I will put down some ideas that could be botched up to work, but likely not proper enough for production code.

    Note that ManufacturerName and ModelIdentifier are not supposed to be changed during a device's lifetime, so you probably shouldn't do this for your end-product.

    With Shell, you can consider creating a custom Shell command, which would then write a value in NVS. The application would then initialize NVS, read this value, and use it to setup the attributes.

    This is a nice blog about custom Shell command: https://blog.golioth.io/how-to-add-custom-shell-commands-in-zephyr/.
    My colleague made an unofficial custom Shell command sample here: https://github.com/martelmy/NCS_examples/tree/main/custom_shell.
    NVS sample: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.6.1/zephyr/samples/subsys/nvs/README.html.

    Alternatively, you could use nrfjprog to write the value to UICR, and then read and use the value to setup the attributes.

    A final alternative is using ZB_ZCL_SET_ATTRIBUTE(). This is meant to work with attributes that can change dynamically, so I am not sure if it will work with ManufacturerName and ModelIdentifier though.

    Best regards,

    Hieu

Related