Skip to content

nmasic: limit retries in wait_for_bootrom() #335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/driver/source/nmasic.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,13 @@



#ifdef ARDUINO
#define TIMEOUT (2000)
#else
#define TIMEOUT (0xfffffffful)
#endif
#define TIMEOUT (2000)
#define WAKUP_TRAILS_TIMEOUT (4)

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)
Expand Down Expand Up @@ -102,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)
{
Expand Down Expand Up @@ -404,6 +401,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,\
Expand All @@ -413,13 +411,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;

Expand Down