X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fstlink-usb.c;h=e7a9ba6428f85e4b949775810cadd198e58bca85;hb=27448f5a6f8ed867e8ddab77f5b9663e9dadc20f;hp=ff9ef71de7a4e6afc0b632342b473cc97826ff0b;hpb=165e5fd66c8aea8e237a11b02835e78ad419fd68;p=fw%2Fstlink diff --git a/src/stlink-usb.c b/src/stlink-usb.c index ff9ef71..e7a9ba6 100644 --- a/src/stlink-usb.c +++ b/src/stlink-usb.c @@ -586,19 +586,6 @@ stlink_t* stlink_open_usb(const int verbose) { sl->core_stat = STLINK_CORE_STAT_UNKNOWN; - /* flash memory settings */ - sl->flash_base = STM32_FLASH_BASE; - sl->flash_size = STM32_FLASH_SIZE; - sl->flash_pgsz = STM32_FLASH_PGSZ; - - /* system memory */ - sl->sys_base = STM32_SYSTEM_BASE; - sl->sys_size = STM32_SYSTEM_SIZE; - - /* sram memory settings */ - sl->sram_base = STM32_SRAM_BASE; - sl->sram_size = STM32L_SRAM_SIZE; - if (libusb_init(&(slu->libusb_ctx))) { fprintf(stderr, "failed to init libusb context, wrong version of libraries?\n"); goto on_error; @@ -698,6 +685,41 @@ stlink_t* stlink_open_usb(const int verbose) { stlink_exit_dfu_mode(sl); } stlink_version(sl); + + /* per device family initialization */ + stlink_core_id(sl); + if (sl->core_id == 0x2ba01477) /* stm32l */ { + + /* flash memory settings */ + sl->flash_base = STM32_FLASH_BASE; + sl->flash_size = STM32_FLASH_SIZE; + sl->flash_pgsz = STM32L_FLASH_PGSZ; + + /* system memory */ + sl->sys_base = STM32_SYSTEM_BASE; + sl->sys_size = STM32_SYSTEM_SIZE; + + /* sram memory settings */ + sl->sram_base = STM32_SRAM_BASE; + sl->sram_size = STM32L_SRAM_SIZE; + + } else /* stm32vl */ { + + /* flash memory settings */ + sl->flash_base = STM32_FLASH_BASE; + sl->flash_size = STM32_FLASH_SIZE; + sl->flash_pgsz = STM32_FLASH_PGSZ; + + /* system memory */ + sl->sys_base = STM32_SYSTEM_BASE; + sl->sys_size = STM32_SYSTEM_SIZE; + + /* sram memory settings */ + sl->sram_base = STM32_SRAM_BASE; + sl->sram_size = STM32_SRAM_SIZE; + + } + error = 0; on_libusb_error: