Programmatically set Device Name and ID

In the documentation it is possible to set the device name and ID manually while executing the provisioning command.

Can this be done programmatically through an /etc/sota/conf.d/ file instead just like how the hardware ID can be customized?

Can it be changed after the device has been provisioned without needing to re-provision the device?

In essence I’m hoping to be able to make the device name reflect the product and serial number for easy overview in Torizon Platform, without having to manually edit them after the fact.

Thanks!

Greetings @bw908,

First of all before I comment further I want to make sure I understand what you mean when you say “device name” and “device ID”, since these can be very loaded terms. Here’s a screenshot of a device I have on my account:
image

So when you say “device name” are you referring to the default randomized name we give the device? Which in the screenshot above would be “Ultimate-Popcorn”.

Then as for the “device ID”, I assume you mean the “Device ID” field correct? Which in my screenshot is “apalis-imx8-06738453-e4b0”.

Before I go further, can you confirm this please. Just to make sure we’re talking about the same things.

Best Regards,
Jeremias

Yes, I’m referring to changing “Ultimate Popcorn” in this way. In retrospect I don’t particularly care about the device ID (apalis-imx-06…) , just looking whether I can update one of these two fields to be something more meaningful to a viewer.

With that clarified let me discuss what options there are here.

First of all the images provision command of TorizonCore Builder does not currently support setting the device name or ID. Though this sounds like a reasonable feature request that I can make to the team, though of course it will take time for this to be picked up and done.

As for what you can do now there are still some possibilities. First let me clear up some of your questions from your initial post.

Can this be done programmatically through an /etc/sota/conf.d/ file instead just like how the hardware ID can be customized?

The answer for this is no. The configuration files here are for the update client on the device. The update client does not use the device name or ID. These descriptors are only used on the server-side of things.

Can it be changed after the device has been provisioned without needing to re-provision the device?

Device name yes, device ID I don’t think you can, but I may need to check this.

Now moving on to what your options are. When you run the images provision command with TorizonCore Builder this will place the provisioning information into the image at flashing time. When the device boots up for the first time if the provisioning information is present then a systemd service called auto-provisioning.service is ran. The service can be seen here: https://github.com/toradex/meta-toradex-torizon/blob/kirkstone-6.x.y/recipes-sota/auto-provisioning/auto-provisioning/auto-provisioning.sh

As you can see this service then runs a script that does the actual provisioning. The script source is found here: https://github.com/toradex/meta-toradex-torizon/blob/kirkstone-6.x.y/recipes-sota/auto-provisioning/auto-provisioning/auto-provisioning.service

The important bit you’re concerned about is in the register_device function. Here we set the device ID and device name that gets registered to the server. In the script you see we don’t set the device name which results in the randomized name on the server. For device ID we just use the hostname of the device which is the default behavior.

Knowing this what can you do right now. You can modify the service to point to another script of your design that sets the device name and or ID. Or you can just modify the script itself. Alternatively you can just change the hostname of the device. This way the original script will used your custom hostname for the device ID anyways. Either way such changes should be possible with TorizonCore Builder.

These would probably be your most straightforward options until we actually have a feature for this.

Let me know if I can help further clear any of this up.

Best Regards,
Jeremias

Perfect - we have a winner. Modifying the hostname of the device is likely what we want here since it brings a few other organizational benefits. Much appreciated!

Off the wall follow-on question - is it possible to bring up a terminal during TEZI for the purposes of developing/testing a custom wrapup.sh script?

Off the wall follow-on question - is it possible to bring up a terminal during TEZI for the purposes of developing/testing a custom wrapup.sh script?

It should be. While Tezi is running on the device you should be able to connect via serial to get a terminal like usual. Do note that Tezi does not have SSH configured however so this is not an option.

1 Like

Great, thanks!