This is an automated email from Gerrit. Steven Stallion ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/4165
-- gerrit commit 9d0519311b7c16c7ac474872e199290c8dfeaa20 Author: Steven Stallion <[email protected]> Date: Mon Jun 19 22:33:03 2017 -0700 rtos: version check for uCOS-III This patch adds a version check to uCOS-III support to work around potential issues using uninitialized targets. If the version check fails, update_threads will return an error rather than attempt to update the thread list using bad values. Change-Id: I7b6f084642c392ea7dcb0e074a4e9f2b6b4e3c9b Signed-off-by: Steven Stallion <[email protected]> diff --git a/src/rtos/uCOS-III.c b/src/rtos/uCOS-III.c index 9021167..a2464e5 100644 --- a/src/rtos/uCOS-III.c +++ b/src/rtos/uCOS-III.c @@ -71,6 +71,7 @@ static const struct uCOS_III_params uCOS_III_params_list[] = { }; static const char * const uCOS_III_symbol_list[] = { + "OSDbg_VersionNbr", "OSRunning", "OSTCBCurPtr", "OSTaskDbgListPtr", @@ -87,6 +88,7 @@ static const char * const uCOS_III_symbol_list[] = { }; enum uCOS_III_symbol_values { + uCOS_III_VAL_OSDbg_VersionNbr, uCOS_III_VAL_OSRunning, uCOS_III_VAL_OSTCBCurPtr, uCOS_III_VAL_OSTaskDbgListPtr, @@ -289,6 +291,26 @@ static int uCOS_III_update_threads(struct rtos *rtos) /* free previous thread details */ rtos_free_threadlist(rtos); + /* + * To prevent updating the thread list before the target has had a + * chance to fully initialize, we first verify the version number + * falls within the expected range. + */ + uint16_t rtos_version; + + retval = target_read_u16(rtos->target, + rtos->symbols[uCOS_III_VAL_OSDbg_VersionNbr].address, + &rtos_version); + if (retval != ERROR_OK) { + LOG_ERROR("uCOS-III: failed to read RTOS version"); + return retval; + } + + if (rtos_version < 30000 || rtos_version > 39999) { + LOG_ERROR("uCOS-III: unexpected version: %" PRIu16, rtos_version); + return ERROR_FAIL; + } + /* verify RTOS is running */ uint8_t rtos_running; -- ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
