The chips arrived!
I bought these:
https://www.aliexpress.com/item/1005005631825445.htmlThe measured current @ 64MHz was 5.6mA, very close to the datasheet specs, also the flash is really 64KB, so I'd say they're original.
To use all the peripherals simply choose the STM32G041F8P6 when creating the project.
However, to access the full 64KB flash a small modification is needed to bypass the programmer check.
Find the die used by your stm32 in the folder
C:\ST\STM32CubeIDE_1.12.1\STM32CubeIDE\plugins\com.st.stm32cube.common.mx_xxxxxx\db\mcu.
For example,
STM32G030F6Px.xml, it contains
<Die>DIE466</Die>.
You can also make a full list of dies running this command in linux or cygwin, creating stm32_dies.txt (Source:
Mikrocontroller.net).
I'm also attaching the extracted dies from CubeIDE 1.13.0.
cd (...fix this...)/STM32CubeIDE/plugins/com.st.stm32cube.common.mx_xxxxxx/db/mcu
grep -o "DIE..." STM* | sed -e "s/\(.*\).xml:\(DIE.*\)/\2 \1/" | sort >stm32_dies.txt
Now we have the first indication that our die has 64KB instead 32, as DIE466 is used both for the STM32G030F6P (32KB) and the STM32G031F8 (64KB):
DIE466 STM32G030F6Px
(...)
DIE466 STM32G031F(4-6-8)Px
So let's open the DIE466 XML file:
plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_xxx\tools\Data_Base\STM32_Prog_DB_0x466.xmlOriginal:
<!-- Embedded Flash -->
<Peripheral>
<Name>Embedded Flash</Name>
...
<!-- 64 KB Single Bank -->
<Configuration config="3,4,5">
Modified:
<!-- Embedded Flash -->
<Peripheral>
<Name>Embedded Flash</Name>
...
<!-- 64 KB Single Bank -->
<Configuration config="0,1,2,3,4,5,6">
This also works for CubeProgrammer:
STM32CubeProgrammer\Data_Base\STM32_Prog_DB_0x466.xmlSTM32CubeProgrammer\api\Data_Base\STM32_Prog_DB_0x466.xmlTest: The ST-Link still reports 32KB, but writes a 64KB program just fine.
ST-LINK SN : -------------------------------
ST-LINK FW : V2J41M27
Board : --
Voltage : 3.18V
SWD freq : 4000 KHz
Connect mode: Under Reset
Reset mode : Hardware reset
Device ID : 0x466
Revision ID : Rev 1.1
Device name : STM32G03x/STM32G04x
Flash size : 32 KBytes
Device type : MCU
Device CPU : Cortex-M0+
BL Version : 0x53
Memory Programming ...
Opening and parsing file: ST-LINK_GDB_server_a14288.srec
File : ST-LINK_GDB_server_a14288.srec
Size : 63.91 KB
Address : 0x08000000
Erasing memory corresponding to segment 0:
Download in Progress:
File download complete
Time elapsed during download operation: 00:00:01.118
Verifying ...
Download verified successfully
The RNG works, all registers can be accessed/modified, and DR reg generates random numbers all the time.
However the AES registers are always read 0, nor can be modified, so probably it's permanently disabled at die level (Of course, RCC peripheral clock was enabled).
ST has never blocked the flash before, so it woudl be rare that hey started now. Lots of 32, 64, 256 and even 512KB devices have double the flash!
Doing this for large-scale production would be risky, as you never know if the the second flash block could be defective somehow, not inmediately failing on programming verification.
China products have been doing this for ages with the STM32F101, although reduced SRAM, still has fully working 128KB and USB from the STM32F103.