From 11e357ae2a34c5f5911c0051fa513659b9bbd7fa Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 8 Jan 2025 21:48:43 +0100 Subject: [PATCH] General project update - Updated version_support - Updated tutorial - Updated CHANGELOG - Updated list of contributors - Fixed parsing of unit prefixes (Closes #1445) - Updated list of supported devices - Added support for STM32C051/71/91 chips - Added support for STM32U031/73/83 chips (Closes #1436) --- CHANGELOG.md | 23 ++++++++++++++++++++++- config/chips/C051xx.chip | 14 ++++++++++++++ config/chips/C071xx.chip | 14 ++++++++++++++ config/chips/C091xx.chip | 14 ++++++++++++++ config/chips/L45x_L46x.chip | 2 +- config/chips/U031xx.chip | 14 ++++++++++++++ config/chips/U073xx_083xx.chip | 14 ++++++++++++++ contributors.txt | 1 + doc/compiling.md | 18 +++++++++--------- doc/supported_devices.md | 1 + doc/version_support.md | 16 +--------------- inc/stm32.h | 13 +++++++++---- src/stlink-lib/helper.c | 29 ++++++++++++++++------------- src/stlink-lib/option_bytes.c | 3 +++ 14 files changed, 133 insertions(+), 43 deletions(-) create mode 100644 config/chips/C051xx.chip create mode 100644 config/chips/C071xx.chip create mode 100644 config/chips/C091xx.chip create mode 100644 config/chips/U031xx.chip create mode 100644 config/chips/U073xx_083xx.chip diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f8c2b3..0e8b85a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ # v1.8.1 -Release date: 2024-09-01 +Release date: 2025-03-xx This release drops support for some older operating systems. Check project README for details. @@ -13,6 +13,8 @@ Updated system requirements: - `libgtk-dev` >= 3.24.18 Features: + +- Show all info during full erase ([#1363](https://github.com/stlink-org/stlink/pull/1363), commit [#6a6718b](https://github.com/stlink-org/stlink/commit/6a6718b3342b6c5e282a4e33325b9f97908a0692)) - Added support for STLINK-V3PWR ([#1388](https://github.com/stlink-org/stlink/pull/1388), [#1389](https://github.com/stlink-org/stlink/pull/1389)) - Dynamic SRAM size for F4 memory map ([#1390](https://github.com/stlink-org/stlink/pull/1390)) - Modifications to allow building of toolset in OpenBSD ([#1392](https://github.com/stlink-org/stlink/pull/1392)) @@ -21,26 +23,36 @@ Features: - Improvements for stlink-gui ([#1411](https://github.com/stlink-org/stlink/pull/1411)) - [STM32U575/585]: Added support for OTP bytes ([#1419](https://github.com/stlink-org/stlink/pull/1419)) - [STM32Gx]: Added erase support for multi-bank products ([#1420](https://github.com/stlink-org/stlink/pull/1420)) +- libusb-cmake as libusb provider and added support for MSVC ([#1424](https://github.com/stlink-org/stlink/pull/1424), [#1440](https://github.com/stlink-org/stlink/pull/1440)) +- [STM32L4Q5CG]: Added support for device ([#1438](https://github.com/stlink-org/stlink/pull/1438), [#1439](https://github.com/stlink-org/stlink/pull/1439)) Updates & changes: + +- [stlink-lib] Clarified warning message for data alignment ([#1371](https://github.com/stlink-org/stlink/pull/1371), commit [#40ee5f4](https://github.com/stlink-org/stlink/commit/40ee5f4bd1151cec65f291f0166429b061c6e5c0)) +- Rewrite commandline usage text for st-flash tool ([#1372](https://github.com/stlink-org/stlink/pull/1372), commit [#95862cc](https://github.com/stlink-org/stlink/commit/95862cc687203ca20e328804f149959c51da2947)) - Debian 11 x64 doesn't work with v1.8.0 because of incompatible glibc ([#1376](https://github.com/stlink-org/stlink/pull/1376), commit [#ece34ef](https://github.com/stlink-org/stlink/commit/ece34efbce579ca7d367c58f903ffa6dc7bd96e6)) - [STM32L4R5ZI]: gdb-multiarch uses wrong osabi ([#1386](https://github.com/stlink-org/stlink/pull/1386), [#1387](https://github.com/stlink-org/stlink/pull/1387), [#1394](https://github.com/stlink-org/stlink/pull/1394)) - [doc] STM32H573 reports chipid 0x000 ([#1398](https://github.com/stlink-org/stlink/pull/1398), commit [#3655871](https://github.com/stlink-org/stlink/commit/3655871f8dd97294bbee191c1c7341c8a129af2f)) Fixes: +- Can't build stlink 1.8.0 for Fedora ([#1365](https://github.com/stlink-org/stlink/pull/1365), [#1444](https://github.com/stlink-org/stlink/pull/1444), commit [#6a6718b](https://github.com/stlink-org/stlink/commit/6a6718b3342b6c5e282a4e33325b9f97908a0692)) +- Fixed include path for header file poll.h ([#1370](https://github.com/stlink-org/stlink/pull/1370), commit [#710e1d3](https://github.com/stlink-org/stlink/commit/710e1d3c3b72187769fcc6a4878c73e35ce03f9b)) - Cmake minimal version mismatch ([#1374](https://github.com/stlink-org/stlink/pull/1374), [#1375](https://github.com/stlink-org/stlink/pull/1375), commit [#1ee7f6b](https://github.com/stlink-org/stlink/commit/1ee7f6b6c05e305112bb070ae571ebbe26c55946)) - Added a graceful way to terminate st-util ([#1395](https://github.com/stlink-org/stlink/pull/1395), [#1396](https://github.com/stlink-org/stlink/pull/1396)) - [st-trace] Bug in function static bool read_trace( ) ([#1400](https://github.com/stlink-org/stlink/pull/1400), commit [#32ce4bf](https://github.com/stlink-org/stlink/commit/32ce4bf88a816fb6a9841a33e6c5f6b593a9b927)) - Fixed STM32H7 FLASH_OPTCR unlock sequence ([#1401](https://github.com/stlink-org/stlink/pull/1401), [#1416](https://github.com/stlink-org/stlink/pull/1416)) - Restored support for STM32G4 Cat4 device STM32G491 ([#1403](https://github.com/stlink-org/stlink/pull/1403), [#1414](https://github.com/stlink-org/stlink/pull/1414)) +- Target reset is less reliable on testing branch ([#1409](https://github.com/stlink-org/stlink/pull/1409), commit [#733893a](https://github.com/stlink-org/stlink/commit/733893a50b1cc9323765a62c456c129ed6807886)) - Fixed STM32H7 option byte programming ([#1417](https://github.com/stlink-org/stlink/pull/1417)) - Latest release stlink-1.8.0-win32 doesn't run ([#1364](https://github.com/stlink-org/stlink/pull/1364), [#1410](https://github.com/stlink-org/stlink/pull/1410), commit [#e493109](https://github.com/stlink-org/stlink/commit/e4931097f887d8a048d1d188388b82ced918cf08)) - Make path to .chip files relative to installation directory on Windows ([#1421](https://github.com/stlink-org/stlink/pull/1421)) +- Re-add support for STM32F411xC/xE option bytes read/write ([#1422](https://github.com/stlink-org/stlink/pull/1422)) - Replaced deprecated cmd to fix package uninstall ([#1426](https://github.com/stlink-org/stlink/pull/1426)) - Fixed compilation error -Wshorten-64-to-32 in stlink-lib/usb.c ([#1427](https://github.com/stlink-org/stlink/pull/1427)) - st-util cannot parse -V and -F options and --freq option results in a segmentation fault ([#1428](https://github.com/stlink-org/stlink/pull/1428), [#1429](https://github.com/stlink-org/stlink/pull/1429)) + # v1.8.0 Release date: 2024-02-01 @@ -148,6 +160,7 @@ Fixes: - stlink-gui: failed to allocate 139988352155568 bytes ([#1356](https://github.com/stlink-org/stlink/pull/1356)) - [STM32U575RGT6]: Verification failed at offset 43008 ([#1362](https://github.com/stlink-org/stlink/pull/1362), commit [#0145bae](https://github.com/stlink-org/stlink/commit/0145baeb2e3bac31bf9d3cbd0dab38d70618d46b)) + # v1.7.0 Release date: 2021-04-25 @@ -218,6 +231,7 @@ Fixes: - Applied missing changes to tests ([#1119](https://github.com/stlink-org/stlink/pull/1119)) - Fixed reading of chip ID on Cortex-M0+ core ([#1017](https://github.com/stlink-org/stlink/pull/1017), [#1125](https://github.com/stlink-org/stlink/pull/1125), [#1126](https://github.com/stlink-org/stlink/pull/1126), [#1133](https://github.com/stlink-org/stlink/pull/1133)) + # v1.6.1 Release date: 2020-06-01 @@ -315,6 +329,7 @@ Fixes: - Fixed udev rules installing to wrong directory ([#966](https://github.com/stlink-org/stlink/pull/966)) - Fixed formatting for options display in `st-flash` & `st-info` (commits [#c783d0e](https://github.com/stlink-org/stlink/commit/c783d0e777ccc83a7a8be26a4f4d3414e0478560) and [#562cd24](https://github.com/stlink-org/stlink/commit/562cd2496e696dbd22950925866aac662d81ee5f)) + # v1.6.0 Release date: 2020-02-20 @@ -367,6 +382,7 @@ General project updates: - Added `CODE_OF_CONDUCT` (Nightwalker-87) - Archived page from github project wiki to doc/wiki_old.md (Nightwalker-87) + # v1.5.1 Release date: 2018-09-13 @@ -400,6 +416,7 @@ Updates and fixes: - Return correct value on `EOF` for semihosting `SYS_READ` ([#726](https://github.com/stlink-org/stlink/pull/726), [#727](https://github.com/stlink-org/stlink/pull/727), [#728](https://github.com/stlink-org/stlink/pull/728), [#729](https://github.com/stlink-org/stlink/pull/729), [#730](https://github.com/stlink-org/stlink/pull/730), [#731](https://github.com/stlink-org/stlink/pull/731), [#732](https://github.com/stlink-org/stlink/pull/732)) - FreeBSD defines `LIBUSB_API_VERSION` instead of `LIBUSBX_API_VERSION` ([#733](https://github.com/stlink-org/stlink/pull/733)) + # v1.5.0 Release date: 2018-02-16 @@ -422,6 +439,7 @@ Updates and fixes: - Added debian/triggers to run `ldconfig` ([#664](https://github.com/stlink-org/stlink/pull/664)) - Fixed build on Fedora with GCC 8 ([#666](https://github.com/stlink-org/stlink/pull/666), [#667](https://github.com/stlink-org/stlink/pull/667), [#668](https://github.com/stlink-org/stlink/pull/668)) + # v1.4.0 Release date: 2017-07-01 @@ -449,6 +467,7 @@ Updates and fixes: - Fixed flashing to `F0 device` targets ([#594](https://github.com/stlink-org/stlink/pull/594), [#595](https://github.com/stlink-org/stlink/pull/595)) - Fixed wrong counting when flashing ([#605](https://github.com/stlink-org/stlink/pull/605)) + # v1.3.1 Release date: 2017-02-25 @@ -468,6 +487,7 @@ Updates and fixes: - Fixed incorrect release folder name in docs ([#560](https://github.com/stlink-org/stlink/pull/560)) - Fixed compilation when path includes spaces ([#561](https://github.com/stlink-org/stlink/pull/561)) + # v1.3.0 Release date: 2017-01-28 @@ -517,6 +537,7 @@ Updates and fixes: - Wrong extract command in `FindLibUSB.cmake` ([#510](https://github.com/stlink-org/stlink/pull/510), [#511](https://github.com/stlink-org/stlink/pull/511)) - Fixed compilation error on Ubuntu 16.10 ([#514](https://github.com/stlink-org/stlink/pull/514), [#525](https://github.com/stlink-org/stlink/pull/525)) + # v1.2.0 Release date: 2016-05-16 diff --git a/config/chips/C051xx.chip b/config/chips/C051xx.chip new file mode 100644 index 0000000..ebfb215 --- /dev/null +++ b/config/chips/C051xx.chip @@ -0,0 +1,14 @@ +# Chip-ID file for STM32C051xx device +# +dev_type STM32C051xx +ref_manual_id 0490 +chip_id 0x44C // STM32_CHIPID_C051xx +flash_type C0 +flash_size_reg 0x1fff75a0 +flash_pagesize 0x800 // 2 KB +sram_size 0x3000 // 12 KB +bootrom_base 0x1fff0000 +bootrom_size 0x1800 // 6 KB +option_base 0x1fff7800 // STM32_C0_OPTION_BYTES_BASE +option_size 0x80 // 128 B +flags none diff --git a/config/chips/C071xx.chip b/config/chips/C071xx.chip new file mode 100644 index 0000000..323d6db --- /dev/null +++ b/config/chips/C071xx.chip @@ -0,0 +1,14 @@ +# Chip-ID file for STM32C071xx device +# +dev_type STM32C071xx +ref_manual_id 0490 +chip_id 0x493 // STM32_CHIPID_C071xx +flash_type C0 +flash_size_reg 0x1fff75a0 +flash_pagesize 0x800 // 2 KB +sram_size 0x6000 // 24 KB +bootrom_base 0x1fff0000 +bootrom_size 0x1800 // 6 KB +option_base 0x1fff7800 // STM32_C0_OPTION_BYTES_BASE +option_size 0x80 // 128 B +flags none \ No newline at end of file diff --git a/config/chips/C091xx.chip b/config/chips/C091xx.chip new file mode 100644 index 0000000..d224b06 --- /dev/null +++ b/config/chips/C091xx.chip @@ -0,0 +1,14 @@ +# Chip-ID file for STM32_C091xx_C92xx device +# +dev_type STM32_C091xx_C92xx +ref_manual_id 0490 +chip_id 0x44D // STM32_CHIPID_C091xx_C92xx +flash_type C0 +flash_size_reg 0x1fff75a0 +flash_pagesize 0x800 // 2 KB +sram_size 0x9000 // 36 KB: C92xx: 30 KB + 6KB FDCAN RAM (RM490 rev. 5 2.4 FDCAN RAM) +bootrom_base 0x1fff0000 +bootrom_size 0x1800 // 6 KB +option_base 0x1fff7800 // STM32_C0_OPTION_BYTES_BASE +option_size 0x80 // 128 B +flags none diff --git a/config/chips/L45x_L46x.chip b/config/chips/L45x_L46x.chip index c32030b..1082df0 100644 --- a/config/chips/L45x_L46x.chip +++ b/config/chips/L45x_L46x.chip @@ -13,4 +13,4 @@ option_base 0x0 option_size 0x0 flags swo otp_base 0x1fff7000 -otp_size 0x400 // 1 KB +otp_size 0x400 // 1 KB diff --git a/config/chips/U031xx.chip b/config/chips/U031xx.chip new file mode 100644 index 0000000..8dbfea5 --- /dev/null +++ b/config/chips/U031xx.chip @@ -0,0 +1,14 @@ +# Chip-ID file for STM32U031xx device +# +dev_type STM32U031xx +ref_manual_id 0503 +chip_id 0x459 // STM32_CHIPID_U031xx +flash_type C0 +flash_size_reg 0x1fff3ea0 +flash_pagesize 0x800 // 2 KB +sram_size 0x3000 // 12 KB +bootrom_base 0x1fff0000 +bootrom_size 0x1400 // 5 KB +option_base 0x1fff7000 // STM32_U0_OPTION_BYTES_BASE +option_size 0x1000 // 4 KB +flags swo \ No newline at end of file diff --git a/config/chips/U073xx_083xx.chip b/config/chips/U073xx_083xx.chip new file mode 100644 index 0000000..e5546a4 --- /dev/null +++ b/config/chips/U073xx_083xx.chip @@ -0,0 +1,14 @@ +# Chip-ID file for STM32U073xx / STM32U083xx device +# +dev_type STM32U073xx_U083xx +ref_manual_id 0503 +chip_id 0x489 // STM32_CHIPID_U073xx_U083xx +flash_type C0 +flash_size_reg 0x1fff6ea0 +flash_pagesize 0x800 // 2 KB +sram_size 0xa000 // 40 KB +bootrom_base 0x1fff0000 +bootrom_size 0x1400 // 5 KB +option_base 0x1fff7000 // STM32_U0_OPTION_BYTES_BASE +option_size 0x1000 // 4 KB +flags swo \ No newline at end of file diff --git a/contributors.txt b/contributors.txt index dacb4e4..b2dfce0 100644 --- a/contributors.txt +++ b/contributors.txt @@ -4,6 +4,7 @@ Alexey Cherevatenko Alexey Panarin Anatoli Klassen [dev26th] Andrea Mucignat +Andreas Michelis [a-michelis] Andrew Andrianov [nekromant] Andrey Yurovsky Andy Isaacson diff --git a/doc/compiling.md b/doc/compiling.md index f914898..7c1037c 100644 --- a/doc/compiling.md +++ b/doc/compiling.md @@ -9,31 +9,31 @@ On Windows users should ensure that the following software is installed: - `git` (_optional, but recommended_) - `7zip` -- `cmake` - `MSYS2` ### Installation -1. Install `git` from -2. Install `cmake` from --> Binary distributions --> Windows x64 Installer
- Ensure that you add cmake to the $PATH system variable when following the instructions by the setup assistant. -3. Install `MSYS2` from
+1. Install `MSYS2` from
Follow the installation instructions on the website. -4. Install `mingw-w64` via the MSYS2 UCRT64 Shell: `pacman -S mingw-w64-x86_64-make` -5. Fetch the project sourcefiles by running `git clone https://github.com/stlink-org/stlink.git`from the command-line (cmd.exe)
+2. Install `mingw-w64` via the MSYS2 UCRT64 Shell: `pacman -S mingw-w64-x86_64-cmake mingw-w64-x86_64-make mingw-w64-x86_64-gcc git` +3. Fetch the project sourcefiles by running `git clone https://github.com/stlink-org/stlink.git`from the command-line (cmd.exe)
or download and extract (`7zip`) the stlink zip-sourcefolder from the Release page on GitHub. ### Building 1. Open the command-line (cmd.exe) with administrator privileges -2. Move to the `stlink` directory with `cd C:\$Path-to-your-stlink-folder$\` -3. Execute `mingw64-build.bat` +2. Move to the `stlink` directory and execute `C:\$Path-to-your-stlink-folder$\mingw64-build.bat` Depending on the flavour of compilation the final executables will be placed in the following directories: - Local compilation: `\build-mingw\bin` - Local installation: `C:\Program Files (x86)\stlink\bin` - Package Generation (portable): `C:\Users\swift\Desktop\stlink\build-mingw\dist` +#### Removal: + +Remove `C:\Program Files (x86)\stlink\` and `C:\$Path-to-your-stlink-folder$`. + + **NOTE:** [ST-LINK drivers](https://www.st.com/en/development-tools/stsw-link009.html) are required for programmers to work with `stlink`. diff --git a/doc/supported_devices.md b/doc/supported_devices.md index f2895ed..038386f 100644 --- a/doc/supported_devices.md +++ b/doc/supported_devices.md @@ -9,6 +9,7 @@ More commonly these are: | STM32C0 | M0+ | | | STM32G0 | M0+ | | | STM32L0 | M0+ | | +| STM32U0 | M0+ | *preliminary, limited and partial support only!* | | STM32F10**0** | M3 | Value line | | STM32F10**1** | M3 | Access line | | STM32F10**2** | M3 | USB Access line | diff --git a/doc/version_support.md b/doc/version_support.md index f1ac1d3..9e61141 100644 --- a/doc/version_support.md +++ b/doc/version_support.md @@ -65,22 +65,8 @@ Systems with highlighted versions remain compatible with this toolset. | Fedora 32 [x64] | 1.0.**23** (`libusbx`) | 3.**17.0** | May 2021 | | openSUSE Leap 15.2 [x64] | 1.0.21 | 3.**17.0** | Dec 2021 | | Ubuntu 20.10 (Groovy) | 1.0.**23** | 3.**16.3** | Jul 2021 | -| NetBSD 7.x | 1.0.22 | 3.16.1 | Jun 2020 | | Alpine 3.11 | 1.0.**23** | 3.15.5 | Nov 2021 | -| FreeBSD 11.x | 1.0.16-18 (API 0x01000102) | 3.15.5 | Sep 2021 | -| ALT Linux P9 | 1.0.22 | 3.**16.3** | | -| Alpine 3.10 | 1.0.22 | 3.14.5 | May 2021 | -| Fedora 31 [x64] | 1.0.22 (`libusbx`) | 3.14.5 | Nov 2020 | -| Mageia 7.1 | 1.0.22 | 3.14.3 | Jun 2021 | -| Fedora 30 | 1.0.22 (`libusbx`) | 3.14.2 | May 2020 | +| ALT Linux P9 | 1.0.22 | 3.**16.3** | | Ubuntu 19.10 (Eoan) | 1.0.**23** | 3.13.4 | Jul 2020 | -| Alpine 3.9 | 1.0.22 | 3.13.0 | Jan 2021 | -| Debian 10 (Buster) | 1.0.22 | 3.13.4 | Jun 2024 | -| Ubuntu 18.04 LTS (Bionic) | 1.0.21 | 3.10.2 | Apr 2023 | -| openSUSE Leap 15.1 [x64] | 1.0.21 | 3.10.2 | Jan 2021 | -| Debian 9 (Stretch) | 1.0.21 | 3.7.2 | Jun 2022 | -| Slackware 14.2 | 1.0.20 | 3.5.2 | Jan 2024 | -| OpenMandriva Lx 3.0x | 1.0.20 | 3.4.2 | Jul 2019 | -| CentOS / Rocky Linux / AlmaLinux 7 [x64] | 1.0.21 (`libusbx`) | 2.8.12.2 | Jun 2024 | _All other operating systems which are not listed are unsupported._ diff --git a/inc/stm32.h b/inc/stm32.h index 3b70797..a7f33cd 100644 --- a/inc/stm32.h +++ b/inc/stm32.h @@ -103,21 +103,24 @@ enum stm32_chipids { STM32_CHIPID_F0 = 0x440, STM32_CHIPID_F412 = 0x441, STM32_CHIPID_F09x = 0x442, - STM32_CHIPID_C011xx = 0x443, /* RM0490 (revision 3), section 26.10.1 "DBG device ID code register (DBG_IDCODE)" */ + STM32_CHIPID_C011xx = 0x443, /* RM0490 (revision 5), section 30.10.1 "DBG device ID code register (DBG_IDCODE)" */ STM32_CHIPID_F0xx_SMALL = 0x444, STM32_CHIPID_F04 = 0x445, STM32_CHIPID_F303_HD = 0x446, /* high density */ STM32_CHIPID_L0_CAT5 = 0x447, STM32_CHIPID_F0_CAN = 0x448, STM32_CHIPID_F7 = 0x449, /* Nucleo F746ZG board */ + STM32_CHIPID_C051xx = 0x44C, /* RM0490 (revision 5), section 30.10.1 "DBG device ID code register (DBG_IDCODE)" */ + STM32_CHIPID_C091xx_C92xx = 0x44D, /* RM0490 (revision 5), section 30.10.1 "DBG device ID code register (DBG_IDCODE)" */ STM32_CHIPID_H74xxx = 0x450, /* RM0433, p.3189 */ STM32_CHIPID_F76xxx = 0x451, STM32_CHIPID_F72xxx = 0x452, /* Nucleo F722ZE board */ - STM32_CHIPID_C031xx = 0x453, /* RM0490 (revision 3), section 26.10.1 "DBG device ID code register (DBG_IDCODE)" */ + STM32_CHIPID_C031xx = 0x453, /* RM0490 (revision 5), section 30.10.1 "DBG device ID code register (DBG_IDCODE)" */ STM32_CHIPID_U535_U545 = 0x455, /* RM0456, p.3604 */ STM32_CHIPID_G0_CAT4 = 0x456, /* G051/G061 */ STM32_CHIPID_L0_CAT1 = 0x457, STM32_CHIPID_F410 = 0x458, + STM32_CHIPID_U031xx = 0x459, STM32_CHIPID_G0_CAT2 = 0x460, /* G07x/G08x */ STM32_CHIPID_L496x_L4A6x = 0x461, STM32_CHIPID_L45x_L46x = 0x462, @@ -137,6 +140,8 @@ enum stm32_chipids { STM32_CHIPID_U575_U585 = 0x482, /* RM0456, p.3604 */ STM32_CHIPID_H72x = 0x483, /* RM0468, p.3199 */ STM32_CHIPID_H5xx = 0x484, /* RM0481, p.3085 */ + STM32_CHIPID_U073xx_U083xx = 0x489, + STM32_CHIPID_C071xx = 0x493, /* RM0490 (revision 5), section 30.10.1 "DBG device ID code register (DBG_IDCODE)" */ STM32_CHIPID_WB55 = 0x495, STM32_CHIPID_WLE = 0x497, }; @@ -197,8 +202,8 @@ enum stm32_chipids { #define STM32WB_DBGMCU_APB1FZR1_WWDG_STOP 11 #define STM32WB_DBGMCU_APB1FZR1_IWDG_STOP 12 -#define STM32C0_RCC_AHBENR 0x40021038 // RM0490 (revision 3), section 5.4.25 "RCC register map" -#define STM32C0_RCC_DMAEN 0x00000001 // DMAEN // RM0490 (revision 3), section 5.4.25 "RCC register map" +#define STM32C0_RCC_AHBENR 0x40021038 // RM0490 (revision 5), section 6.4.24 "RCC register map" +#define STM32C0_RCC_DMAEN 0x00000001 // DMAEN // RM0490 (revision 5), section 6.4.24 "RCC register map" #define STM32F1_RCC_AHBENR 0x40021014 #define STM32F1_RCC_DMAEN 0x00000003 // DMA2EN | DMA1EN diff --git a/src/stlink-lib/helper.c b/src/stlink-lib/helper.c index 8fff8bc..50e6df7 100644 --- a/src/stlink-lib/helper.c +++ b/src/stlink-lib/helper.c @@ -23,18 +23,21 @@ uint32_t time_ms() { } int32_t arg_parse_freq(const char *str) { - int32_t value = -1; - if (str != NULL) { - char* tail = NULL; - value = strtol(str, &tail, 10); - if (tail != NULL) { - if (tail[0] == 'M' && tail[1] == '\0') { - value = value*1000; - } - else if (tail[0] != '\0' && !(tail[0] == 'k' && tail[1] == '\0')) { - value = -1; // error - } - } + if (str == NULL) { + return -1; // faulty input } - return value; // frequency in kHz + + char* tail = NULL; + int32_t value = strtol(str, &tail, 10); + + if (tail == NULL) { + return -1; // faulty integer conversion + } else if (tail[0] == '\0') { + return value; // no prefix: Hz + } else if (tail[0] == 'M' && tail[1] == '\0') { + return value * 1000 * 1000; // M prefix: MHz + } else if ((tail[0] == 'k' || tail[0] == 'K') && tail[1] == '\0') { + return value * 1000; // k prefix: kHz + } + return -1; // invalid prefix } diff --git a/src/stlink-lib/option_bytes.c b/src/stlink-lib/option_bytes.c index 8bf749f..228f388 100644 --- a/src/stlink-lib/option_bytes.c +++ b/src/stlink-lib/option_bytes.c @@ -1085,6 +1085,9 @@ int32_t stlink_read_option_bytes32(stlink_t *sl, uint32_t *option_byte) { switch (sl->chip_id) { case STM32_CHIPID_C011xx: case STM32_CHIPID_C031xx: + case STM32_CHIPID_C051xx: + case STM32_CHIPID_C071xx: + case STM32_CHIPID_C091xx_C92xx: return stlink_read_option_bytes_c0(sl, option_byte); case STM32_CHIPID_F2: return stlink_read_option_bytes_f2(sl, option_byte);