From: Karl Palsson Date: Sat, 12 Nov 2011 20:45:41 +0000 (+0000) Subject: Read chip and core id in device param loading. X-Git-Url: https://git.gag.com/?p=fw%2Fstlink;a=commitdiff_plain;h=0c587eedfd33396cc6da94850e0dfcac15a953f2 Read chip and core id in device param loading. Instead of expecting everyone to read it every time they need to check it. Just assume it's always there. --- diff --git a/src/stlink-common.c b/src/stlink-common.c index 89c2630..3391f4f 100644 --- a/src/stlink-common.c +++ b/src/stlink-common.c @@ -314,6 +314,7 @@ int stlink_load_device_params(stlink_t *sl) { ILOG("Loading device parameters....\n"); chip_params_t *params = NULL; uint32_t chip_id = stlink_chip_id(sl); + sl->chip_id = chip_id; for(size_t i = 0; i < sizeof(devices) / sizeof(devices[0]); i++) { if(devices[i].chip_id == (chip_id & 0xFFF)) { params = &devices[i]; @@ -342,6 +343,8 @@ int stlink_load_device_params(stlink_t *sl) { sl->sys_base = params->bootrom_base; sl->sys_size = params->bootrom_size; + sl->core_id = stlink_core_id(sl); + ILOG("Device connected is: %s\n", params->description); ILOG("SRAM size: %#x bytes (%d KiB), Flash: %#x bytes (%d KiB) in pages of %zd bytes\n", sl->sram_size, sl->sram_size / 1024, sl->flash_size, sl->flash_size / 1024, @@ -742,7 +745,6 @@ int stlink_erase_flash_page(stlink_t *sl, stm32_addr_t page) { /* page an addr in the page to erase */ - stlink_core_id(sl); if (sl->core_id == STM32L_CORE_ID) { #define STM32L_FLASH_REGS_ADDR ((uint32_t)0x40023c00) @@ -1020,7 +1022,6 @@ int stlink_write_flash(stlink_t *sl, stm32_addr_t addr, uint8_t* base, unsigned } } - stlink_core_id(sl); if (sl->core_id == STM32L_CORE_ID) { /* use fast word write. todo: half page. */ diff --git a/src/stlink-common.h b/src/stlink-common.h index 5534b6f..9279c37 100644 --- a/src/stlink-common.h +++ b/src/stlink-common.h @@ -283,6 +283,7 @@ extern "C" { // transport layer verboseness: 0 for no debug info, 10 for lots int verbose; uint32_t core_id; + uint32_t chip_id; int core_stat; #define STM32_FLASH_PGSZ 1024