From d3cdf26c725340c90148dd400e7c4fded3586744 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 28 Sep 2020 16:15:52 +0200 Subject: [PATCH] boards/samr21-xpro: fix reading EUI-64 from EDBG on cold boot The samr21 starts up faster than EDBG, so on cold boot reading the ID will fail. Fix this by re-trying to get the EUI-64 from EUI. On warm boot / reset this works on the first try, but on cold boot it can spin a couple thousand times. --- boards/samr21-xpro/include/board.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/boards/samr21-xpro/include/board.h b/boards/samr21-xpro/include/board.h index a5b558f998..929c7e31b8 100644 --- a/boards/samr21-xpro/include/board.h +++ b/boards/samr21-xpro/include/board.h @@ -65,7 +65,11 @@ extern "C" { static inline int _edbg_get_eui64(const void *arg, eui64_t *addr) { (void) arg; - return edbg_get_eui64(addr); + + /* EDBG can take a while to respond on cold boot */ + unsigned tries = 10000; + while (--tries && edbg_get_eui64(addr)) {} + return tries ? 0 : -1; } /**