(I decided to move here the "unlocking" of Cube IDE here).
*This is for personal use only, I'm not having any benefit from it, neither using ST libraries, just for fun! *
> Genuine check bypass
The OpenOCD hack no longer works, so I took a moment to investigate.
I turns out the latest IDE versions have additional checks in the IDE itself (Previously, it was only done in ST-Link GDB server).
STLINK GDB server (ST-LINK_gdbserver.exe) will still check it, so use OpenOCD or J-Link.
I found the genuine check and patched it, was very simple, I was able to program and debug clones, tested with:
- STLink+OpenOCD: Air32F103.
- J-Link: Air32F103, HK32F030M (HK needs specific flash algorithm, only supported by J-Link).
I didn't had to modify the OpenOCD files.
Attached the patched file, plus the patching details (So it doesn't become too obvious, just in case some ST guy searchs for those strings).
> Add custom device support
The HK32F030M has different peripherals than any other STM32F030x, so I wanted to have native support for it in the IDE.
It turns out it also was pretty easy:
- Download the
DFP pack, rename to zip, extract and rename the SVD file to something simple, ex, "HK32F030M.SVD".
- Copy to plugins\com.st.stm32cube.ide.mcu.productdb.debug_xxx\resources\cmsis\STMicroelectronics_CMSIS_SVD
- Edit plugins\com.st.stm32cube.ide.mcu.productdb_xxx\resources\board_def\stm32targets.xml
- Insert a new mcu block, note how we're defining the cpu architecture and the SVD file we copied earlier!
Version can be anything, but must be there, the IDE will crash without that field.
Also, parent must be stm32fx, or the debugger process won't start! Choose something close (Same architecture) from other existing entry.
<mcu>
<name>HK32K030MF4P6</name>
<status>Active</status>
<parent>stm32f0</parent>
<cpus>
<cpu>
<id>0</id>
<svd>
<name>HK32F030M.svd</name>
<version>v1r0</version>
</svd>
<cores>
<core>
<id>0</id>
<apnum>0</apnum>
<type>arm cortex-m0</type>
<fpu>None</fpu>
</core>
</cores>
</cpu>
</cpus>
</mcu>
- Save the file, open the IDE.
- Create a new C/C++ project (It won't appear under CubeMX, or under a STM32 project), then choose the new MCU in the list.
- Add your code, compile, start a debugging session, and you'll have all the peripherals defined in the SVD!
- Note: STM32 projects and Cube MX are a totally different thing, this is just to be able to use the CMSIS SVD when debugging!