-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18214 from benpicco/drivers/atwinc15x0-timeout
drivers/atwinc15x0: add timeout to init
- Loading branch information
Showing
3 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
pkg/driver_atwinc15x0/patches/0007-nmasic-always-use-2000-retries.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
From 9664046ab3fb2355fc3058bef90cc8727a67730b Mon Sep 17 00:00:00 2001 | ||
From: Benjamin Valentin <benjamin.valentin@ml-pa.com> | ||
Date: Wed, 15 Jun 2022 18:06:09 +0200 | ||
Subject: [PATCH 1/3] nmasic: always use 2000 retries | ||
|
||
--- | ||
src/driver/source/nmasic.c | 6 +----- | ||
1 file changed, 1 insertion(+), 5 deletions(-) | ||
|
||
diff --git a/src/driver/source/nmasic.c b/src/driver/source/nmasic.c | ||
index 91c0e5a..9f46398 100644 | ||
--- a/src/driver/source/nmasic.c | ||
+++ b/src/driver/source/nmasic.c | ||
@@ -59,11 +59,7 @@ | ||
|
||
|
||
|
||
-#ifdef ARDUINO | ||
-#define TIMEOUT (2000) | ||
-#else | ||
-#define TIMEOUT (0xfffffffful) | ||
-#endif | ||
+#define TIMEOUT (2000) | ||
#define WAKUP_TRAILS_TIMEOUT (4) | ||
|
||
sint8 chip_apply_conf(uint32 u32Conf) | ||
-- | ||
2.34.1 | ||
|
50 changes: 50 additions & 0 deletions
50
pkg/driver_atwinc15x0/patches/0008-nmasic-limit-retries-in-wait_for_bootrom.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
From 142506c9ed4e2d3a1c59cf39cd86473074981c6a Mon Sep 17 00:00:00 2001 | ||
From: Benjamin Valentin <benjamin.valentin@ml-pa.com> | ||
Date: Wed, 15 Jun 2022 14:01:42 +0200 | ||
Subject: [PATCH 2/3] nmasic: limit retries in wait_for_bootrom() | ||
|
||
If no device is connected or init failed, wait_for_bootrom() will | ||
be stuck in an infinite loop trying to get a result from nm_read_reg(). | ||
|
||
Place an upper limit on the number of retries so we can recover from | ||
this instead of being stuck here. | ||
--- | ||
src/driver/source/nmasic.c | 9 ++++++++- | ||
1 file changed, 8 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/src/driver/source/nmasic.c b/src/driver/source/nmasic.c | ||
index 9f46398..b77dc5a 100644 | ||
--- a/src/driver/source/nmasic.c | ||
+++ b/src/driver/source/nmasic.c | ||
@@ -400,6 +400,7 @@ sint8 chip_reset(void) | ||
sint8 wait_for_bootrom(uint8 arg) | ||
{ | ||
sint8 ret = M2M_SUCCESS; | ||
+ uint16 retries = TIMEOUT; | ||
uint32 reg = 0, cnt = 0; | ||
uint32 u32GpReg1 = 0; | ||
uint32 u32DriverVerInfo = M2M_MAKE_VERSION_INFO(M2M_RELEASE_VERSION_MAJOR_NO,\ | ||
@@ -409,13 +410,19 @@ sint8 wait_for_bootrom(uint8 arg) | ||
|
||
|
||
reg = 0; | ||
- while(1) { | ||
+ while(--retries) { | ||
reg = nm_read_reg(0x1014); /* wait for efuse loading done */ | ||
if (reg & 0x80000000) { | ||
break; | ||
} | ||
nm_bsp_sleep(1); /* TODO: Why bus error if this delay is not here. */ | ||
} | ||
+ | ||
+ /* communication with device failed */ | ||
+ if(retries == 0) { | ||
+ return M2M_ERR_INIT; | ||
+ } | ||
+ | ||
reg = nm_read_reg(M2M_WAIT_FOR_HOST_REG); | ||
reg &= 0x1; | ||
|
||
-- | ||
2.34.1 | ||
|
36 changes: 36 additions & 0 deletions
36
pkg/driver_atwinc15x0/patches/0009-nmasic-limit-retries-in-chip_apply_conf.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
From c1efd943abeb7ddf643bdb0849d1d70ae748ac5d Mon Sep 17 00:00:00 2001 | ||
From: Benjamin Valentin <benjamin.valentin@ml-pa.com> | ||
Date: Wed, 15 Jun 2022 18:05:45 +0200 | ||
Subject: [PATCH 3/3] nmasic: limit retries in chip_apply_conf() | ||
|
||
--- | ||
src/driver/source/nmasic.c | 5 +++-- | ||
1 file changed, 3 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/src/driver/source/nmasic.c b/src/driver/source/nmasic.c | ||
index b77dc5a..bcc766d 100644 | ||
--- a/src/driver/source/nmasic.c | ||
+++ b/src/driver/source/nmasic.c | ||
@@ -65,6 +65,7 @@ | ||
sint8 chip_apply_conf(uint32 u32Conf) | ||
{ | ||
sint8 ret = M2M_SUCCESS; | ||
+ uint16 retries = TIMEOUT; | ||
uint32 val32 = u32Conf; | ||
|
||
#if (defined __ENABLE_PMU__) || (defined CONF_WINC_INT_PMU) | ||
@@ -98,9 +99,9 @@ sint8 chip_apply_conf(uint32 u32Conf) | ||
} else { | ||
break; | ||
} | ||
- } while(1); | ||
+ } while(--retries); | ||
|
||
- return M2M_SUCCESS; | ||
+ return retries ? M2M_SUCCESS : M2M_ERR_TIME_OUT; | ||
} | ||
void chip_idle(void) | ||
{ | ||
-- | ||
2.34.1 | ||
|