From 849cf69b01a6d226238882e28281c4285f0ddfbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=85strand?= Date: Tue, 24 Nov 2020 07:39:55 +0100 Subject: Restore default init values as init_v2 The addition of init_v3 accidentely changed default values for soft resetting Ethos-U. Restore the default parameters to non-secure, user mode for init_v1 and init_v2 and also make sure to check return value from ethosu_soft_reset. Change-Id: If7377f11ad1db7ff988fdcba03320a54e6e0c0c1 --- include/ethosu_driver.h | 4 ++-- src/ethosu_driver.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/ethosu_driver.h b/include/ethosu_driver.h index 345f82f..46f777a 100644 --- a/include/ethosu_driver.h +++ b/include/ethosu_driver.h @@ -95,9 +95,9 @@ int ethosu_init_v3(const void *base_address, uint32_t secure_enable, uint32_t privilege_enable); -#define ethosu_init(base_address) ethosu_init_v3(base_address, NULL, 0, 1, 1) +#define ethosu_init(base_address) ethosu_init_v3(base_address, NULL, 0, 0, 0) #define ethosu_init_v2(base_address, fast_memory, fast_memory_size) \ - ethosu_init_v3(base_address, fast_memory, fast_memory_size, 1, 1) + ethosu_init_v3(base_address, fast_memory, fast_memory_size, 0, 0) /** * Get Ethos-U version. diff --git a/src/ethosu_driver.c b/src/ethosu_driver.c index fcb3fbb..3c9c55b 100644 --- a/src/ethosu_driver.c +++ b/src/ethosu_driver.c @@ -179,7 +179,7 @@ void ethosu_irq_handler(void) if (ethosu_status_has_error(ðosu_drv.dev)) { - ethosu_soft_reset(ðosu_drv.dev); + (void)ethosu_soft_reset(ðosu_drv.dev); ethosu_drv.status_error = true; } } @@ -264,7 +264,10 @@ int ethosu_init_v3(const void *base_address, return -1; } - ethosu_soft_reset(ðosu_drv.dev); + if (ETHOSU_SUCCESS != ethosu_soft_reset(ðosu_drv.dev)) + { + return -1; + } if (ETHOSU_SUCCESS != ethosu_wait_for_reset(ðosu_drv.dev)) { @@ -355,7 +358,10 @@ int ethosu_invoke_v2(const void *custom_data_ptr, if (ethosu_drv.dev.reset != ethosu_read_reg(ðosu_drv.dev, NPU_REG_PROT)) { - ethosu_soft_reset(ðosu_drv.dev); + if (ETHOSU_SUCCESS != ethosu_soft_reset(ðosu_drv.dev)) + { + return -1; + } } ethosu_drv.status_error = false; ethosu_set_clock_and_power(ðosu_drv.dev, ETHOSU_CLOCK_Q_ENABLE, ETHOSU_POWER_Q_DISABLE); -- cgit v1.2.1