Issue with NervesKey and NervesHubLink - [error] ATECC508A: Request failed: [3, 7, <<2, 128, 16, 0>>, <<10, 29>>], 5 ms -> {:error, :timeout}

I am having an issue with my device not starting correctly because NervesHubLink is failing to start. This is occurring about 50% of boot cycles.

I have a provisioned NervesKey and have it setup in NervesCloud. This all works about 50% of the time. But the other half I see the following:

....
19:37:56.347 [error] ATECC508A: Request failed: [3, 7, <<2, 128, 16, 0>>, <<10, 29>>], 5 ms -> {:error, :timeout}
19:37:56.555 [error] ATECC508A: Transaction failed: {:error, :i2c_nak}
19:37:57.624 [error] ATECC508A: Transaction failed: {:error, :i2c_nak}
19:37:57.731 [info] Application nerves_hub_link exited: exited in: NervesHubLink.Application.start(:normal, [])
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: {:error, {:no_more_retries, {:error, :i2c_nak}}}
            (nerves_key 1.2.0) lib/nerves_key.ex:147: NervesKey.device_cert/3
            (nerves_hub_link 2.7.3) lib/nerves_hub_link/configurators/nerves_key.ex:52: anonymous fn/2 in NervesHubLink.Configurator.NervesKey.maybe_add_cert/3
            (elixir 1.17.2) lib/keyword.ex:809: Keyword.put_new_lazy/3
            (nerves_hub_link 2.7.3) lib/nerves_hub_link/configurators/nerves_key.ex:40: NervesHubLink.Configurator.NervesKey.build/1
            (nerves_hub_link 2.7.3) lib/nerves_hub_link/configurator.ex:96: NervesHubLink.Configurator.build/0
            (nerves_hub_link 2.7.3) lib/nerves_hub_link/application.ex:26: NervesHubLink.Application.start/2
            (kernel 10.0.1) application_master.erl:295: :application_master.start_it_old/4

Because of this my main app (:firmware) does not start either which is confirmed by seeing the following in NervesMOTD

Applications : 93 started (firmware, nerves_hub_link not started)

I am running on a BeagleBone Black with a custom cape that has the ATECC608A chip on i2c-2

Thanks in advance for any insights you may have!

1 Like

You may already have fixed this. I hope you have.

I haven’t seen this exact thing. I have seen various commands fail with timeouts. I’ve had provisioning “fail” and then when I check the device is provisioned. I’ve also found commands where the timeouts required were longer on different devices.

If you try hacking your version of nerves_key or atecc508a (the library) to have a longer timeout. Does that make the device work consistently? If so, please report findings with a PR :slight_smile:

I have some ATECC608A that have not had particular problems when properly powered but that were very flaky over the qwiic connector. I now have some ATECC608B as well and I’ve only done weird things to them so far but might try something vanilla if that’s helpful.