Search code examples
provisioningtoit

Provision: how to set the device name?


  1. 20 days ago I've successfully provisioned for ESP-32 and work fine with this device.
  2. Today I've successfully provisioned the second ESP-32 chip on another computer:
5.40 MiB / 5.40 MiB [------------------------------------] 100.00% 14.69 MiB p/s
looking for available hardware identities on disk
no hardware identities found on disk, claiming new hardware identity
Flashing device on port /dev/ttyUSB0
+--------------------------+--------------------------------------+
|         SETTING          |                VALUE                 |
+--------------------------+--------------------------------------+
| Firmware                 | v1.0.2                               |
| Device Model             | esp32-4mb                            |
| Hardware ID              | XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX |
| Hardware Batch & Seq. No | 2020-11-10#524                       |
| context                  | remote                               |
| broker.host              | device.toit.io                       |
| broker.cn                | device.toit.io                       |
| broker.port              | 9426                                 |
| wifi.ssid                | SureDemo                             |
| wifi.password            | suremote                             |
+--------------------------+--------------------------------------+
erasing device flash
successfully erased device flash
writing device partitions
successfully written device partitions
reading hardware chip information
successfully read hardware chip information
+--------------------------+--------------------------------------+
|         SETTING          |                VALUE                 |
+--------------------------+--------------------------------------+
| factory device model     | esp32-4mb                            |
| factory firmware version | v1.0.2                               |
| chip ID                  |                                      |
+--------------------------+--------------------------------------+
device was successfully flashed
  1. However, I cannot start the application on this device:
michael_k @ michaelk: ~ /toit_apps/Hsm2/tests $ toit run test_hsm_switch_async_4.toit
No default device set. Provide the device name (with the --device flag) to the command
michael_k @ michaelk: ~ /toit_apps/Hsm2/tests $
  1. I realized that this new device needs to be given a different name from my default device micrcx-1. By the way, I can see my first appliance:
michael_k @ michaelk: ~ /toit_apps/Hsm2/tests $ toit devices
+--------------------------------------+----------+-------------------+----------+
|              DEVICE ID               |   NAME   |     LAST SEEN     | FIRMWARE |
+--------------------------------------+----------+-------------------+----------+
| XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX | micrcx-1 | Apr 29 2021 04:05 | v1.0.2   |
+--------------------------------------+----------+-------------------+----------+
michael_k@michaelk:~/toit_apps/Hsm2/tests$ 
  1. So, the question is: how to give a name to a new additional device and how to run an application on it?

Thanks in advance, MK

PS. Naturally, I could be wrong, but as far as I remember, the name of the first device was assigned by toit system automatically. I had nothing to do with this. micrcx is my computer's identifier.


Solution

  • It might be that your device wasn't claimed yet. In the current release (but hopefully not in future releases), provisioning a device only puts the Toit framework on the device. At this point it is not yet associated with your account and must be claimed.

    You can simply run: toit device claim <hardware-ID> or toit device claim <hardware-ID> --name=<some-name>.

    If no name is provided, then the system generates one. Typically these are built out of two words, for example nervous-plastic. You can always change the names at a later point.

    Alternatively you can claim the device in the web UI. There is a "CLAIM OR REPLACE DEVICE" button on the top right of the "Devices" view.

    FYI: I have edited your post to remove the hardware ID of the new device, so nobody else claims the device in the meantime.