Difference between revisions of "STM32L432Kx Flash Size"

From Stm32World Wiki
Jump to navigation Jump to search
Line 18: Line 18:
 
=== Generating Test Data ===
 
=== Generating Test Data ===
  
First step is to create a 128 kB file with random data.
+
First step is to create a 256 kB file with random data.
  
 
<pre>
 
<pre>
lth@ncpws04:/tmp$ dd if=/dev/urandom of=random.bin bs=1k count=128
+
lth@ncpws04:~/tmp$ dd if=/dev/urandom of=random.bin bs=1k count=256
128+0 records in
+
256+0 records in
128+0 records out
+
256+0 records out
131072 bytes (131 kB, 128 KiB) copied, 0.00250461 s, 52.3 MB/s
+
262144 bytes (262 kB, 256 KiB) copied, 0.0012241 s, 214 MB/s
 
</pre>
 
</pre>
  
Line 34: Line 34:
  
 
<pre>
 
<pre>
lth@ncpws04:/tmp$ st-flash write random.bin 0x8000000
+
lth@ncpws04:~/tmp$ st-flash write random.bin 0x8000000
st-flash 1.7.0-dirty
+
st-flash 1.8.0
2021-07-20T12:14:31 INFO common.c: L43x/L44x: 48 KiB SRAM, 128 KiB flash in at least 2 KiB pages.
+
2024-09-02T10:30:01 INFO common.c: STM32L41x_L42x: 48 KiB SRAM, 128 KiB flash in at least 2 KiB pages.
file random.bin md5 checksum: 9d3a763bd923a4c42ffe5fa434d6109, stlink checksum: 0x00ff70ec
+
file random.bin md5 checksum: 5f7ebd5c822e7408e6279445eb1444a, stlink checksum: 0x01fe53dd
2021-07-20T12:14:31 INFO common.c: Attempting to write 131072 (0x20000) bytes to stm32 address: 134217728 (0x8000000)
+
2024-09-02T10:30:01 INFO common_flash.c: Attempting to write 262144 (0x40000) bytes to stm32 address: 134217728 (0x8000000)
EraseFlash - Page:0x0 Size:0x800 2021-07-20T12:14:31 INFO common.c: Flash page at addr: 0x08000000 erased
+
2024-09-02T10:30:01 ERROR common_flash.c: The size exceeds the size of the flash (0x00020000 bytes available)
EraseFlash - Page:0x1 Size:0x800 2021-07-20T12:14:31 INFO common.c: Flash page at addr: 0x08000800 erased
+
stlink_fwrite_flash() == -1
EraseFlash - Page:0x2 Size:0x800 2021-07-20T12:14:31 INFO common.c: Flash page at addr: 0x08001000 erased
 
EraseFlash - Page:0x3 Size:0x800 2021-07-20T12:14:31 INFO common.c: Flash page at addr: 0x08001800 erased
 
EraseFlash - Page:0x4 Size:0x800 2021-07-20T12:14:31 INFO common.c: Flash page at addr: 0x08002000 erased
 
EraseFlash - Page:0x5 Size:0x800 2021-07-20T12:14:31 INFO common.c: Flash page at addr: 0x08002800 erased
 
EraseFlash - Page:0x6 Size:0x800 2021-07-20T12:14:31 INFO common.c: Flash page at addr: 0x08003000 erased
 
EraseFlash - Page:0x7 Size:0x800 2021-07-20T12:14:31 INFO common.c: Flash page at addr: 0x08003800 erased
 
EraseFlash - Page:0x8 Size:0x800 2021-07-20T12:14:31 INFO common.c: Flash page at addr: 0x08004000 erased
 
EraseFlash - Page:0x9 Size:0x800 2021-07-20T12:14:31 INFO common.c: Flash page at addr: 0x08004800 erased
 
EraseFlash - Page:0xa Size:0x800 2021-07-20T12:14:31 INFO common.c: Flash page at addr: 0x08005000 erased
 
EraseFlash - Page:0xb Size:0x800 2021-07-20T12:14:31 INFO common.c: Flash page at addr: 0x08005800 erased
 
EraseFlash - Page:0xc Size:0x800 2021-07-20T12:14:31 INFO common.c: Flash page at addr: 0x08006000 erased
 
EraseFlash - Page:0xd Size:0x800 2021-07-20T12:14:31 INFO common.c: Flash page at addr: 0x08006800 erased
 
EraseFlash - Page:0xe Size:0x800 2021-07-20T12:14:31 INFO common.c: Flash page at addr: 0x08007000 erased
 
EraseFlash - Page:0xf Size:0x800 2021-07-20T12:14:31 INFO common.c: Flash page at addr: 0x08007800 erased
 
EraseFlash - Page:0x10 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08008000 erased
 
EraseFlash - Page:0x11 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08008800 erased
 
EraseFlash - Page:0x12 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08009000 erased
 
EraseFlash - Page:0x13 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08009800 erased
 
EraseFlash - Page:0x14 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x0800a000 erased
 
EraseFlash - Page:0x15 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x0800a800 erased
 
EraseFlash - Page:0x16 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x0800b000 erased
 
EraseFlash - Page:0x17 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x0800b800 erased
 
EraseFlash - Page:0x18 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x0800c000 erased
 
EraseFlash - Page:0x19 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x0800c800 erased
 
EraseFlash - Page:0x1a Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x0800d000 erased
 
EraseFlash - Page:0x1b Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x0800d800 erased
 
EraseFlash - Page:0x1c Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x0800e000 erased
 
EraseFlash - Page:0x1d Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x0800e800 erased
 
EraseFlash - Page:0x1e Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x0800f000 erased
 
EraseFlash - Page:0x1f Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x0800f800 erased
 
EraseFlash - Page:0x20 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08010000 erased
 
EraseFlash - Page:0x21 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08010800 erased
 
EraseFlash - Page:0x22 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08011000 erased
 
EraseFlash - Page:0x23 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08011800 erased
 
EraseFlash - Page:0x24 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08012000 erased
 
EraseFlash - Page:0x25 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08012800 erased
 
EraseFlash - Page:0x26 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08013000 erased
 
EraseFlash - Page:0x27 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08013800 erased
 
EraseFlash - Page:0x28 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08014000 erased
 
EraseFlash - Page:0x29 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08014800 erased
 
EraseFlash - Page:0x2a Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08015000 erased
 
EraseFlash - Page:0x2b Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08015800 erased
 
EraseFlash - Page:0x2c Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08016000 erased
 
EraseFlash - Page:0x2d Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08016800 erased
 
EraseFlash - Page:0x2e Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08017000 erased
 
EraseFlash - Page:0x2f Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08017800 erased
 
EraseFlash - Page:0x30 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08018000 erased
 
EraseFlash - Page:0x31 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08018800 erased
 
EraseFlash - Page:0x32 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08019000 erased
 
EraseFlash - Page:0x33 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x08019800 erased
 
EraseFlash - Page:0x34 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x0801a000 erased
 
EraseFlash - Page:0x35 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x0801a800 erased
 
EraseFlash - Page:0x36 Size:0x800 2021-07-20T12:14:32 INFO common.c: Flash page at addr: 0x0801b000 erased
 
EraseFlash - Page:0x37 Size:0x800 2021-07-20T12:14:33 INFO common.c: Flash page at addr: 0x0801b800 erased
 
EraseFlash - Page:0x38 Size:0x800 2021-07-20T12:14:33 INFO common.c: Flash page at addr: 0x0801c000 erased
 
EraseFlash - Page:0x39 Size:0x800 2021-07-20T12:14:33 INFO common.c: Flash page at addr: 0x0801c800 erased
 
EraseFlash - Page:0x3a Size:0x800 2021-07-20T12:14:33 INFO common.c: Flash page at addr: 0x0801d000 erased
 
EraseFlash - Page:0x3b Size:0x800 2021-07-20T12:14:33 INFO common.c: Flash page at addr: 0x0801d800 erased
 
EraseFlash - Page:0x3c Size:0x800 2021-07-20T12:14:33 INFO common.c: Flash page at addr: 0x0801e000 erased
 
EraseFlash - Page:0x3d Size:0x800 2021-07-20T12:14:33 INFO common.c: Flash page at addr: 0x0801e800 erased
 
EraseFlash - Page:0x3e Size:0x800 2021-07-20T12:14:33 INFO common.c: Flash page at addr: 0x0801f000 erased
 
EraseFlash - Page:0x3f Size:0x800 2021-07-20T12:14:33 INFO common.c: Flash page at addr: 0x0801f800 erased
 
2021-07-20T12:14:33 INFO common.c: Finished erasing 64 pages of 2048 (0x800) bytes
 
2021-07-20T12:14:33 INFO common.c: Starting Flash write for F2/F4/F7/L4
 
2021-07-20T12:14:33 INFO flash_loader.c: Successfully loaded flash loader in sram
 
2021-07-20T12:14:33 INFO flash_loader.c: Clear DFSR
 
2021-07-20T12:14:35 INFO common.c: Starting verification of write complete
 
2021-07-20T12:14:37 INFO common.c: Flash written and verified! jolly good!
 
 
</pre>
 
</pre>
  
That was to be expected.  Now let us try to flash the next 128 kB of flash:
+
As expected this will failThe [[MCU]] reports 128 kB of flash and we attempt to write 256 kB.  We can however instruct st-flash to ignore that and attempt to write the entire file:
  
 
<pre>
 
<pre>
lth@ncpws04:/tmp$ st-flash write random.bin 0x8020000
+
lth@ncpws04:~/tmp$ st-flash --flash=256k write random.bin 0x8000000
st-flash 1.7.0-dirty
+
st-flash 1.8.0
2021-07-20T12:15:41 INFO common.c: L43x/L44x: 48 KiB SRAM, 128 KiB flash in at least 2 KiB pages.
+
2024-09-02T10:30:26 INFO common.c: STM32L41x_L42x: 48 KiB SRAM, 128 KiB flash in at least 2 KiB pages.
Unknown memory region
 
</pre>
 
 
 
That fails because the st-flash util check the data reported by the [[MCU]].  Fortunately, this can be overwritten by the --flash option:
 
 
 
<pre>
 
lth@ncpws04:/tmp$ st-flash --flash=256k write random.bin 0x8020000       
 
st-flash 1.7.0-dirty
 
2021-07-20T12:16:55 INFO common.c: L43x/L44x: 48 KiB SRAM, 128 KiB flash in at least 2 KiB pages.
 
 
Forcing flash size: --flash=0x00040000
 
Forcing flash size: --flash=0x00040000
file random.bin md5 checksum: 9d3a763bd923a4c42ffe5fa434d6109, stlink checksum: 0x00ff70ec
+
file random.bin md5 checksum: 5f7ebd5c822e7408e6279445eb1444a, stlink checksum: 0x01fe53dd
2021-07-20T12:16:55 INFO common.c: Attempting to write 131072 (0x20000) bytes to stm32 address: 134348800 (0x8020000)
+
2024-09-02T10:30:26 INFO common_flash.c: Attempting to write 262144 (0x40000) bytes to stm32 address: 134217728 (0x8000000)
EraseFlash - Page:0x40 Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08020000 erased
+
EraseFlash - Page:0x10 Size:0x800 -> Flash page at 0x8008000 erased (size: 0x800EraseFlash - Page:0x11 Size:0x800 -> Flash page at 0x8008800 erased (size: 0x800EraseFlash - Page:0x12 Size:0x800 -> Flash page at 0x8009000 erased (size: 0x800EraseFlash - Page:0x13 Size:0x800 -> Flash page at 0x8009800 erased (size: 0x800EraseFlash - Page:0x14 Size:0x800 -> Flash page at 0x800a000 erased (size: 0x800EraseFlash - Page:0x15 Size:0x800 -> Flash page at 0x800a800 erased (size: 0x800EraseFlash - Page:0x16 Size:0x800 -> Flash page at 0x800b000 erased (size: 0x800EraseFlash - Page:0x17 Size:0x800 -> Flash page at 0x800b800 erased (size: 0x800EraseFlash - Page:0x18 Size:0x800 -> Flash page at 0x800c000 erased (size: 0x800EraseFlash - Page:0x19 Size:0x800 -> Flash page at 0x800c800 erased (size: 0x800EraseFlash - Page:0x1a Size:0x800 -> Flash page at 0x800d000 erased (size: 0x800EraseFlash - Page:0x1b Size:0x800 -> Flash page at 0x800d800 erased (size: 0x800EraseFlash - Page:0x1c Size:0x800 -> Flash page at 0x800e000 erased (size: 0x800EraseFlash - Page:0x1d Size:0x800 -> Flash page at 0x800e800 erased (size: 0x800EraseFlash - Page:0x1e Size:0x800 -> Flash page at 0x800f000 erased (size: 0x800EraseFlash - Page:0x1f Size:0x800 -> Flash page at 0x800f800 erased (size: 0x800EraseFlash - Page:0x20 Size:0x800 -> Flash page at 0x8010000 erased (size: 0x800EraseFlash - Page:0x21 Size:0x800 -> Flash page at 0x8010800 erased (size: 0x800EraseFlash - Page:0x22 Size:0x800 -> Flash page at 0x8011000 erased (size: 0x800EraseFlash - Page:0x23 Size:0x800 -> Flash page at 0x8011800 erased (size: 0x800EraseFlash - Page:0x24 Size:0x800 -> Flash page at 0x8012000 erased (size: 0x800EraseFlash - Page:0x25 Size:0x800 -> Flash page at 0x8012800 erased (size: 0x800EraseFlash - Page:0x26 Size:0x800 -> Flash page at 0x8013000 erased (size: 0x800EraseFlash - Page:0x27 Size:0x800 -> Flash page at 0x8013800 erased (size: 0x800EraseFlash - Page:0x28 Size:0x800 -> Flash page at 0x8014000 erased (size: 0x800EraseFlash - Page:0x29 Size:0x800 -> Flash page at 0x8014800 erased (size: 0x800EraseFlash - Page:0x2a Size:0x800 -> Flash page at 0x8015000 erased (size: 0x800EraseFlash - Page:0x2b Size:0x800 -> Flash page at 0x8015800 erased (size: 0x800EraseFlash - Page:0x2c Size:0x800 -> Flash page at 0x8016000 erased (size: 0x800EraseFlash - Page:0x2d Size:0x800 -> Flash page at 0x8016800 erased (size: 0x800EraseFlash - Page:0x2e Size:0x800 -> Flash page at 0x8017000 erased (size: 0x800EraseFlash - Page:0x2f Size:0x800 -> Flash page at 0x8017800 erased (size: 0x800EraseFlash - Page:0x30 Size:0x800 -> Flash page at 0x8018000 erased (size: 0x800EraseFlash - Page:0x31 Size:0x800 -> Flash page at 0x8018800 erased (size: 0x800EraseFlash - Page:0x32 Size:0x800 -> Flash page at 0x8019000 erased (size: 0x800EraseFlash - Page:0x33 Size:0x800 -> Flash page at 0x8019800 erased (size: 0x800EraseFlash - Page:0x34 Size:0x800 -> Flash page at 0x801a000 erased (size: 0x800EraseFlash - Page:0x35 Size:0x800 -> Flash page at 0x801a800 erased (size: 0x800EraseFlash - Page:0x36 Size:0x800 -> Flash page at 0x801b000 erased (size: 0x800EraseFlash - Page:0x37 Size:0x800 -> Flash page at 0x801b800 erased (size: 0x800EraseFlash - Page:0x38 Size:0x800 -> Flash page at 0x801c000 erased (size: 0x800EraseFlash - Page:0x39 Size:0x800 -> Flash page at 0x801c800 erased (size: 0x800EraseFlash - Page:0x3a Size:0x800 -> Flash page at 0x801d000 erased (size: 0x800EraseFlash - Page:0x3b Size:0x800 -> Flash page at 0x801d800 erased (size: 0x800EraseFlash - Page:0x3c Size:0x800 -> Flash page at 0x801e000 erased (size: 0x800EraseFlash - Page:0x3d Size:0x800 -> Flash page at 0x801e800 erased (size: 0x800EraseFlash - Page:0x3e Size:0x800 -> Flash page at 0x801f000 erased (size: 0x800EraseFlash - Page:0x3f Size:0x800 -> Flash page at 0x801f800 erased (size: 0x800EraseFlash - Page:0x40 Size:0x800 -> Flash page at 0x8020000 erased (size: 0x800EraseFlash - Page:0x41 Size:0x800 -> Flash page at 0x8020800 erased (size: 0x800EraseFlash - Page:0x42 Size:0x800 -> Flash page at 0x8021000 erased (size: 0x800EraseFlash - Page:0x43 Size:0x800 -> Flash page at 0x8021800 erased (size: 0x800EraseFlash - Page:0x44 Size:0x800 -> Flash page at 0x8022000 erased (size: 0x800EraseFlash - Page:0x45 Size:0x800 -> Flash page at 0x8022800 erased (size: 0x800EraseFlash - Page:0x46 Size:0x800 -> Flash page at 0x8023000 erased (size: 0x800EraseFlash - Page:0x47 Size:0x800 -> Flash page at 0x8023800 erased (size: 0x800EraseFlash - Page:0x48 Size:0x800 -> Flash page at 0x8024000 erased (size: 0x800EraseFlash - Page:0x49 Size:0x800 -> Flash page at 0x8024800 erased (size: 0x800EraseFlash - Page:0x4a Size:0x800 -> Flash page at 0x8025000 erased (size: 0x800EraseFlash - Page:0x4b Size:0x800 -> Flash page at 0x8025800 erased (size: 0x800EraseFlash - Page:0x4c Size:0x800 -> Flash page at 0x8026000 erased (size: 0x800EraseFlash - Page:0x4d Size:0x800 -> Flash page at 0x8026800 erased (size: 0x800EraseFlash - Page:0x4e Size:0x800 -> Flash page at 0x8027000 erased (size: 0x800EraseFlash - Page:0x4f Size:0x800 -> Flash page at 0x8027800 erased (size: 0x800EraseFlash - Page:0x50 Size:0x800 -> Flash page at 0x8028000 erased (size: 0x800EraseFlash - Page:0x51 Size:0x800 -> Flash page at 0x8028800 erased (size: 0x800EraseFlash - Page:0x52 Size:0x800 -> Flash page at 0x8029000 erased (size: 0x800EraseFlash - Page:0x53 Size:0x800 -> Flash page at 0x8029800 erased (size: 0x800EraseFlash - Page:0x54 Size:0x800 -> Flash page at 0x802a000 erased (size: 0x800EraseFlash - Page:0x55 Size:0x800 -> Flash page at 0x802a800 erased (size: 0x800EraseFlash - Page:0x56 Size:0x800 -> Flash page at 0x802b000 erased (size: 0x800EraseFlash - Page:0x57 Size:0x800 -> Flash page at 0x802b800 erased (size: 0x800EraseFlash - Page:0x58 Size:0x800 -> Flash page at 0x802c000 erased (size: 0x800EraseFlash - Page:0x59 Size:0x800 -> Flash page at 0x802c800 erased (size: 0x800EraseFlash - Page:0x5a Size:0x800 -> Flash page at 0x802d000 erased (size: 0x800EraseFlash - Page:0x5b Size:0x800 -> Flash page at 0x802d800 erased (size: 0x800EraseFlash - Page:0x5c Size:0x800 -> Flash page at 0x802e000 erased (size: 0x800EraseFlash - Page:0x5d Size:0x800 -> Flash page at 0x802e800 erased (size: 0x800EraseFlash - Page:0x5e Size:0x800 -> Flash page at 0x802f000 erased (size: 0x800EraseFlash - Page:0x5f Size:0x800 -> Flash page at 0x802f800 erased (size: 0x800EraseFlash - Page:0x60 Size:0x800 -> Flash page at 0x8030000 erased (size: 0x800EraseFlash - Page:0x61 Size:0x800 -> Flash page at 0x8030800 erased (size: 0x800EraseFlash - Page:0x62 Size:0x800 -> Flash page at 0x8031000 erased (size: 0x800EraseFlash - Page:0x63 Size:0x800 -> Flash page at 0x8031800 erased (size: 0x800EraseFlash - Page:0x64 Size:0x800 -> Flash page at 0x8032000 erased (size: 0x800EraseFlash - Page:0x65 Size:0x800 -> Flash page at 0x8032800 erased (size: 0x800EraseFlash - Page:0x66 Size:0x800 -> Flash page at 0x8033000 erased (size: 0x800EraseFlash - Page:0x67 Size:0x800 -> Flash page at 0x8033800 erased (size: 0x800EraseFlash - Page:0x68 Size:0x800 -> Flash page at 0x8034000 erased (size: 0x800EraseFlash - Page:0x69 Size:0x800 -> Flash page at 0x8034800 erased (size: 0x800EraseFlash - Page:0x6a Size:0x800 -> Flash page at 0x8035000 erased (size: 0x800EraseFlash - Page:0x6b Size:0x800 -> Flash page at 0x8035800 erased (size: 0x800EraseFlash - Page:0x6c Size:0x800 -> Flash page at 0x8036000 erased (size: 0x800EraseFlash - Page:0x6d Size:0x800 -> Flash page at 0x8036800 erased (size: 0x800EraseFlash - Page:0x6e Size:0x800 -> Flash page at 0x8037000 erased (size: 0x800EraseFlash - Page:0x6f Size:0x800 -> Flash page at 0x8037800 erased (size: 0x800EraseFlash - Page:0x70 Size:0x800 -> Flash page at 0x8038000 erased (size: 0x800EraseFlash - Page:0x71 Size:0x800 -> Flash page at 0x8038800 erased (size: 0x800EraseFlash - Page:0x72 Size:0x800 -> Flash page at 0x8039000 erased (size: 0x800EraseFlash - Page:0x73 Size:0x800 -> Flash page at 0x8039800 erased (size: 0x800EraseFlash - Page:0x74 Size:0x800 -> Flash page at 0x803a000 erased (size: 0x800EraseFlash - Page:0x75 Size:0x800 -> Flash page at 0x803a800 erased (size: 0x800EraseFlash - Page:0x76 Size:0x800 -> Flash page at 0x803b000 erased (size: 0x800EraseFlash - Page:0x77 Size:0x800 -> Flash page at 0x803b800 erased (size: 0x800EraseFlash - Page:0x78 Size:0x800 -> Flash page at 0x803c000 erased (size: 0x800EraseFlash - Page:0x79 Size:0x800 -> Flash page at 0x803c800 erased (size: 0x800EraseFlash - Page:0x7a Size:0x800 -> Flash page at 0x803d000 erased (size: 0x800EraseFlash - Page:0x7b Size:0x800 -> Flash page at 0x803d800 erased (size: 0x800EraseFlash - Page:0x7c Size:0x800 -> Flash page at 0x803e000 erased (size: 0x800EraseFlash - Page:0x7d Size:0x800 -> Flash page at 0x803e800 erased (size: 0x800EraseFlash - Page:0x7e Size:0x800 -> Flash page at 0x803f000 erased (size: 0x800EraseFlash - Page:0x7f Size:0x800 -> Flash page at 0x803f800 erased (size: 0x800)
EraseFlash - Page:0x41 Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08020800 erased
+
2024-09-02T10:30:29 INFO flash_loader.c: Starting Flash write for F2/F4/F7/L4
EraseFlash - Page:0x42 Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08021000 erased
+
2024-09-02T10:30:29 INFO flash_loader.c: Successfully loaded flash loader in sram
EraseFlash - Page:0x43 Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08021800 erased
+
2024-09-02T10:30:29 INFO flash_loader.c: Clear DFSR
EraseFlash - Page:0x44 Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08022000 erased
+
2024-09-02T10:30:35 INFO common_flash.c: Starting verification of write complete
EraseFlash - Page:0x45 Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08022800 erased
+
2024-09-02T10:30:37 INFO common_flash.c: Flash written and verified! jolly good!
EraseFlash - Page:0x46 Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08023000 erased
 
EraseFlash - Page:0x47 Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08023800 erased
 
EraseFlash - Page:0x48 Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08024000 erased
 
EraseFlash - Page:0x49 Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08024800 erased
 
EraseFlash - Page:0x4a Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08025000 erased
 
EraseFlash - Page:0x4b Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08025800 erased
 
EraseFlash - Page:0x4c Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08026000 erased
 
EraseFlash - Page:0x4d Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08026800 erased
 
EraseFlash - Page:0x4e Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08027000 erased
 
EraseFlash - Page:0x4f Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08027800 erased
 
EraseFlash - Page:0x50 Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08028000 erased
 
EraseFlash - Page:0x51 Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08028800 erased
 
EraseFlash - Page:0x52 Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08029000 erased
 
EraseFlash - Page:0x53 Size:0x800 2021-07-20T12:16:55 INFO common.c: Flash page at addr: 0x08029800 erased
 
EraseFlash - Page:0x54 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0802a000 erased
 
EraseFlash - Page:0x55 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0802a800 erased
 
EraseFlash - Page:0x56 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0802b000 erased
 
EraseFlash - Page:0x57 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0802b800 erased
 
EraseFlash - Page:0x58 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0802c000 erased
 
EraseFlash - Page:0x59 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0802c800 erased
 
EraseFlash - Page:0x5a Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0802d000 erased
 
EraseFlash - Page:0x5b Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0802d800 erased
 
EraseFlash - Page:0x5c Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0802e000 erased
 
EraseFlash - Page:0x5d Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0802e800 erased
 
EraseFlash - Page:0x5e Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0802f000 erased
 
EraseFlash - Page:0x5f Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0802f800 erased
 
EraseFlash - Page:0x60 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08030000 erased
 
EraseFlash - Page:0x61 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08030800 erased
 
EraseFlash - Page:0x62 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08031000 erased
 
EraseFlash - Page:0x63 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08031800 erased
 
EraseFlash - Page:0x64 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08032000 erased
 
EraseFlash - Page:0x65 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08032800 erased
 
EraseFlash - Page:0x66 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08033000 erased
 
EraseFlash - Page:0x67 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08033800 erased
 
EraseFlash - Page:0x68 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08034000 erased
 
EraseFlash - Page:0x69 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08034800 erased
 
EraseFlash - Page:0x6a Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08035000 erased
 
EraseFlash - Page:0x6b Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08035800 erased
 
EraseFlash - Page:0x6c Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08036000 erased
 
EraseFlash - Page:0x6d Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08036800 erased
 
EraseFlash - Page:0x6e Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08037000 erased
 
EraseFlash - Page:0x6f Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08037800 erased
 
EraseFlash - Page:0x70 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08038000 erased
 
EraseFlash - Page:0x71 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08038800 erased
 
EraseFlash - Page:0x72 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08039000 erased
 
EraseFlash - Page:0x73 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x08039800 erased
 
EraseFlash - Page:0x74 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0803a000 erased
 
EraseFlash - Page:0x75 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0803a800 erased
 
EraseFlash - Page:0x76 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0803b000 erased
 
EraseFlash - Page:0x77 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0803b800 erased
 
EraseFlash - Page:0x78 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0803c000 erased
 
EraseFlash - Page:0x79 Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0803c800 erased
 
EraseFlash - Page:0x7a Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0803d000 erased
 
EraseFlash - Page:0x7b Size:0x800 2021-07-20T12:16:56 INFO common.c: Flash page at addr: 0x0803d800 erased
 
EraseFlash - Page:0x7c Size:0x800 2021-07-20T12:16:57 INFO common.c: Flash page at addr: 0x0803e000 erased
 
EraseFlash - Page:0x7d Size:0x800 2021-07-20T12:16:57 INFO common.c: Flash page at addr: 0x0803e800 erased
 
EraseFlash - Page:0x7e Size:0x800 2021-07-20T12:16:57 INFO common.c: Flash page at addr: 0x0803f000 erased
 
EraseFlash - Page:0x7f Size:0x800 2021-07-20T12:16:57 INFO common.c: Flash page at addr: 0x0803f800 erased
 
2021-07-20T12:16:57 INFO common.c: Finished erasing 64 pages of 2048 (0x800) bytes
 
2021-07-20T12:16:57 INFO common.c: Starting Flash write for F2/F4/F7/L4
 
2021-07-20T12:16:57 INFO flash_loader.c: Successfully loaded flash loader in sram
 
2021-07-20T12:16:57 INFO flash_loader.c: Clear DFSR
 
2021-07-20T12:16:57 INFO flash_loader.c: Clear CFSR
 
2021-07-20T12:16:59 INFO common.c: Starting verification of write complete
 
2021-07-20T12:17:01 INFO common.c: Flash written and verified! jolly good!
 
 
</pre>
 
</pre>
  
Lo and behold - it appeared to have workedThe st-flash utility actually read back the data and verify that it was written correctly.
+
That went well - no errors reportedNow let's try to read that flash into a file:
  
 
=== Reading data from the MCU ===
 
=== Reading data from the MCU ===
Line 209: Line 67:
  
 
<pre>
 
<pre>
lth@ncpws04:/tmp$ st-flash --flash=128k read random2.bin 0x8020000 0x020000
+
lth@ncpws04:~/tmp$ st-flash --flash=256k read random2.bin 0x8000000 0x40000
st-flash 1.7.0-dirty
+
st-flash 1.8.0
2021-07-20T12:19:52 INFO common.c: L43x/L44x: 48 KiB SRAM, 128 KiB flash in at least 2 KiB pages.
+
2024-09-02T10:31:51 INFO common.c: STM32L41x_L42x: 48 KiB SRAM, 128 KiB flash in at least 2 KiB pages.
2021-07-20T12:19:52 INFO common.c: read from address 0x08020000 size 131072
+
Forcing flash size: --flash=0x00040000
 +
2024-09-02T10:31:51 INFO common.c: read from address 0x08000000 size 262144
 
</pre>
 
</pre>
  
Line 222: Line 81:
  
 
<pre>
 
<pre>
lth@ncpws04:/tmp$ md5sum random*
+
lth@ncpws04:~/tmp$ md5sum random*
9d3a763bd923a4c42ffe5fa434d61009 random2.bin
+
5f7ebd5c822e07408e6279445eb1444a random2.bin
9d3a763bd923a4c42ffe5fa434d61009 random.bin
+
5f7ebd5c822e07408e6279445eb1444a random.bin
 
</pre>
 
</pre>
  

Revision as of 03:37, 2 September 2024

FidoKey rev. a - top view.jpg

The STM32L432Kx is available with two different flash sizes. The STM32L432KB has got 128 kB while the STM32L432KC has got 256 kB. I recently created a USB "key" using the STM32L432. The reason for using this specific STM32 MCU was twofold:

  1. It is small
  2. It's got a built-in 48 MHz oscillator precise enough to use USB without an external crystal

Unfortunately, while I wanted the 256 kB version, only the 128 kB version was available.

STM32L432 Part Numbering.png

The STM32 Blue Pill boards mostly use Chinese clone MCUs but there has been a lot of writing about the original ones having 128 kB of flash rather than the 64 kB specified by the datasheet. There is even a test tool available which can test for the hidden flash.

Inspired by this, I decided to test the STM32L432KB on my own board. As per the datasheet this processor is supposed to have 128 kB of flash ranging from 0x8000000 to 0x801FFFF.

Testing

Generating Test Data

First step is to create a 256 kB file with random data.

lth@ncpws04:~/tmp$ dd if=/dev/urandom of=random.bin bs=1k count=256
256+0 records in
256+0 records out
262144 bytes (262 kB, 256 KiB) copied, 0.0012241 s, 214 MB/s

Writing data to MCU

The random.bin file is of a size which can be flashed on both the STM32L432KB and STM32L432KC.

First step is to flash normal:

lth@ncpws04:~/tmp$ st-flash write random.bin 0x8000000
st-flash 1.8.0
2024-09-02T10:30:01 INFO common.c: STM32L41x_L42x: 48 KiB SRAM, 128 KiB flash in at least 2 KiB pages.
file random.bin md5 checksum: 5f7ebd5c822e7408e6279445eb1444a, stlink checksum: 0x01fe53dd
2024-09-02T10:30:01 INFO common_flash.c: Attempting to write 262144 (0x40000) bytes to stm32 address: 134217728 (0x8000000)
2024-09-02T10:30:01 ERROR common_flash.c: The size exceeds the size of the flash (0x00020000 bytes available)
stlink_fwrite_flash() == -1

As expected this will fail. The MCU reports 128 kB of flash and we attempt to write 256 kB. We can however instruct st-flash to ignore that and attempt to write the entire file:

lth@ncpws04:~/tmp$ st-flash --flash=256k write random.bin 0x8000000
st-flash 1.8.0
2024-09-02T10:30:26 INFO common.c: STM32L41x_L42x: 48 KiB SRAM, 128 KiB flash in at least 2 KiB pages.
Forcing flash size: --flash=0x00040000
file random.bin md5 checksum: 5f7ebd5c822e7408e6279445eb1444a, stlink checksum: 0x01fe53dd
2024-09-02T10:30:26 INFO common_flash.c: Attempting to write 262144 (0x40000) bytes to stm32 address: 134217728 (0x8000000)
EraseFlash - Page:0x10 Size:0x800 -> Flash page at 0x8008000 erased (size: 0x800EraseFlash - Page:0x11 Size:0x800 -> Flash page at 0x8008800 erased (size: 0x800EraseFlash - Page:0x12 Size:0x800 -> Flash page at 0x8009000 erased (size: 0x800EraseFlash - Page:0x13 Size:0x800 -> Flash page at 0x8009800 erased (size: 0x800EraseFlash - Page:0x14 Size:0x800 -> Flash page at 0x800a000 erased (size: 0x800EraseFlash - Page:0x15 Size:0x800 -> Flash page at 0x800a800 erased (size: 0x800EraseFlash - Page:0x16 Size:0x800 -> Flash page at 0x800b000 erased (size: 0x800EraseFlash - Page:0x17 Size:0x800 -> Flash page at 0x800b800 erased (size: 0x800EraseFlash - Page:0x18 Size:0x800 -> Flash page at 0x800c000 erased (size: 0x800EraseFlash - Page:0x19 Size:0x800 -> Flash page at 0x800c800 erased (size: 0x800EraseFlash - Page:0x1a Size:0x800 -> Flash page at 0x800d000 erased (size: 0x800EraseFlash - Page:0x1b Size:0x800 -> Flash page at 0x800d800 erased (size: 0x800EraseFlash - Page:0x1c Size:0x800 -> Flash page at 0x800e000 erased (size: 0x800EraseFlash - Page:0x1d Size:0x800 -> Flash page at 0x800e800 erased (size: 0x800EraseFlash - Page:0x1e Size:0x800 -> Flash page at 0x800f000 erased (size: 0x800EraseFlash - Page:0x1f Size:0x800 -> Flash page at 0x800f800 erased (size: 0x800EraseFlash - Page:0x20 Size:0x800 -> Flash page at 0x8010000 erased (size: 0x800EraseFlash - Page:0x21 Size:0x800 -> Flash page at 0x8010800 erased (size: 0x800EraseFlash - Page:0x22 Size:0x800 -> Flash page at 0x8011000 erased (size: 0x800EraseFlash - Page:0x23 Size:0x800 -> Flash page at 0x8011800 erased (size: 0x800EraseFlash - Page:0x24 Size:0x800 -> Flash page at 0x8012000 erased (size: 0x800EraseFlash - Page:0x25 Size:0x800 -> Flash page at 0x8012800 erased (size: 0x800EraseFlash - Page:0x26 Size:0x800 -> Flash page at 0x8013000 erased (size: 0x800EraseFlash - Page:0x27 Size:0x800 -> Flash page at 0x8013800 erased (size: 0x800EraseFlash - Page:0x28 Size:0x800 -> Flash page at 0x8014000 erased (size: 0x800EraseFlash - Page:0x29 Size:0x800 -> Flash page at 0x8014800 erased (size: 0x800EraseFlash - Page:0x2a Size:0x800 -> Flash page at 0x8015000 erased (size: 0x800EraseFlash - Page:0x2b Size:0x800 -> Flash page at 0x8015800 erased (size: 0x800EraseFlash - Page:0x2c Size:0x800 -> Flash page at 0x8016000 erased (size: 0x800EraseFlash - Page:0x2d Size:0x800 -> Flash page at 0x8016800 erased (size: 0x800EraseFlash - Page:0x2e Size:0x800 -> Flash page at 0x8017000 erased (size: 0x800EraseFlash - Page:0x2f Size:0x800 -> Flash page at 0x8017800 erased (size: 0x800EraseFlash - Page:0x30 Size:0x800 -> Flash page at 0x8018000 erased (size: 0x800EraseFlash - Page:0x31 Size:0x800 -> Flash page at 0x8018800 erased (size: 0x800EraseFlash - Page:0x32 Size:0x800 -> Flash page at 0x8019000 erased (size: 0x800EraseFlash - Page:0x33 Size:0x800 -> Flash page at 0x8019800 erased (size: 0x800EraseFlash - Page:0x34 Size:0x800 -> Flash page at 0x801a000 erased (size: 0x800EraseFlash - Page:0x35 Size:0x800 -> Flash page at 0x801a800 erased (size: 0x800EraseFlash - Page:0x36 Size:0x800 -> Flash page at 0x801b000 erased (size: 0x800EraseFlash - Page:0x37 Size:0x800 -> Flash page at 0x801b800 erased (size: 0x800EraseFlash - Page:0x38 Size:0x800 -> Flash page at 0x801c000 erased (size: 0x800EraseFlash - Page:0x39 Size:0x800 -> Flash page at 0x801c800 erased (size: 0x800EraseFlash - Page:0x3a Size:0x800 -> Flash page at 0x801d000 erased (size: 0x800EraseFlash - Page:0x3b Size:0x800 -> Flash page at 0x801d800 erased (size: 0x800EraseFlash - Page:0x3c Size:0x800 -> Flash page at 0x801e000 erased (size: 0x800EraseFlash - Page:0x3d Size:0x800 -> Flash page at 0x801e800 erased (size: 0x800EraseFlash - Page:0x3e Size:0x800 -> Flash page at 0x801f000 erased (size: 0x800EraseFlash - Page:0x3f Size:0x800 -> Flash page at 0x801f800 erased (size: 0x800EraseFlash - Page:0x40 Size:0x800 -> Flash page at 0x8020000 erased (size: 0x800EraseFlash - Page:0x41 Size:0x800 -> Flash page at 0x8020800 erased (size: 0x800EraseFlash - Page:0x42 Size:0x800 -> Flash page at 0x8021000 erased (size: 0x800EraseFlash - Page:0x43 Size:0x800 -> Flash page at 0x8021800 erased (size: 0x800EraseFlash - Page:0x44 Size:0x800 -> Flash page at 0x8022000 erased (size: 0x800EraseFlash - Page:0x45 Size:0x800 -> Flash page at 0x8022800 erased (size: 0x800EraseFlash - Page:0x46 Size:0x800 -> Flash page at 0x8023000 erased (size: 0x800EraseFlash - Page:0x47 Size:0x800 -> Flash page at 0x8023800 erased (size: 0x800EraseFlash - Page:0x48 Size:0x800 -> Flash page at 0x8024000 erased (size: 0x800EraseFlash - Page:0x49 Size:0x800 -> Flash page at 0x8024800 erased (size: 0x800EraseFlash - Page:0x4a Size:0x800 -> Flash page at 0x8025000 erased (size: 0x800EraseFlash - Page:0x4b Size:0x800 -> Flash page at 0x8025800 erased (size: 0x800EraseFlash - Page:0x4c Size:0x800 -> Flash page at 0x8026000 erased (size: 0x800EraseFlash - Page:0x4d Size:0x800 -> Flash page at 0x8026800 erased (size: 0x800EraseFlash - Page:0x4e Size:0x800 -> Flash page at 0x8027000 erased (size: 0x800EraseFlash - Page:0x4f Size:0x800 -> Flash page at 0x8027800 erased (size: 0x800EraseFlash - Page:0x50 Size:0x800 -> Flash page at 0x8028000 erased (size: 0x800EraseFlash - Page:0x51 Size:0x800 -> Flash page at 0x8028800 erased (size: 0x800EraseFlash - Page:0x52 Size:0x800 -> Flash page at 0x8029000 erased (size: 0x800EraseFlash - Page:0x53 Size:0x800 -> Flash page at 0x8029800 erased (size: 0x800EraseFlash - Page:0x54 Size:0x800 -> Flash page at 0x802a000 erased (size: 0x800EraseFlash - Page:0x55 Size:0x800 -> Flash page at 0x802a800 erased (size: 0x800EraseFlash - Page:0x56 Size:0x800 -> Flash page at 0x802b000 erased (size: 0x800EraseFlash - Page:0x57 Size:0x800 -> Flash page at 0x802b800 erased (size: 0x800EraseFlash - Page:0x58 Size:0x800 -> Flash page at 0x802c000 erased (size: 0x800EraseFlash - Page:0x59 Size:0x800 -> Flash page at 0x802c800 erased (size: 0x800EraseFlash - Page:0x5a Size:0x800 -> Flash page at 0x802d000 erased (size: 0x800EraseFlash - Page:0x5b Size:0x800 -> Flash page at 0x802d800 erased (size: 0x800EraseFlash - Page:0x5c Size:0x800 -> Flash page at 0x802e000 erased (size: 0x800EraseFlash - Page:0x5d Size:0x800 -> Flash page at 0x802e800 erased (size: 0x800EraseFlash - Page:0x5e Size:0x800 -> Flash page at 0x802f000 erased (size: 0x800EraseFlash - Page:0x5f Size:0x800 -> Flash page at 0x802f800 erased (size: 0x800EraseFlash - Page:0x60 Size:0x800 -> Flash page at 0x8030000 erased (size: 0x800EraseFlash - Page:0x61 Size:0x800 -> Flash page at 0x8030800 erased (size: 0x800EraseFlash - Page:0x62 Size:0x800 -> Flash page at 0x8031000 erased (size: 0x800EraseFlash - Page:0x63 Size:0x800 -> Flash page at 0x8031800 erased (size: 0x800EraseFlash - Page:0x64 Size:0x800 -> Flash page at 0x8032000 erased (size: 0x800EraseFlash - Page:0x65 Size:0x800 -> Flash page at 0x8032800 erased (size: 0x800EraseFlash - Page:0x66 Size:0x800 -> Flash page at 0x8033000 erased (size: 0x800EraseFlash - Page:0x67 Size:0x800 -> Flash page at 0x8033800 erased (size: 0x800EraseFlash - Page:0x68 Size:0x800 -> Flash page at 0x8034000 erased (size: 0x800EraseFlash - Page:0x69 Size:0x800 -> Flash page at 0x8034800 erased (size: 0x800EraseFlash - Page:0x6a Size:0x800 -> Flash page at 0x8035000 erased (size: 0x800EraseFlash - Page:0x6b Size:0x800 -> Flash page at 0x8035800 erased (size: 0x800EraseFlash - Page:0x6c Size:0x800 -> Flash page at 0x8036000 erased (size: 0x800EraseFlash - Page:0x6d Size:0x800 -> Flash page at 0x8036800 erased (size: 0x800EraseFlash - Page:0x6e Size:0x800 -> Flash page at 0x8037000 erased (size: 0x800EraseFlash - Page:0x6f Size:0x800 -> Flash page at 0x8037800 erased (size: 0x800EraseFlash - Page:0x70 Size:0x800 -> Flash page at 0x8038000 erased (size: 0x800EraseFlash - Page:0x71 Size:0x800 -> Flash page at 0x8038800 erased (size: 0x800EraseFlash - Page:0x72 Size:0x800 -> Flash page at 0x8039000 erased (size: 0x800EraseFlash - Page:0x73 Size:0x800 -> Flash page at 0x8039800 erased (size: 0x800EraseFlash - Page:0x74 Size:0x800 -> Flash page at 0x803a000 erased (size: 0x800EraseFlash - Page:0x75 Size:0x800 -> Flash page at 0x803a800 erased (size: 0x800EraseFlash - Page:0x76 Size:0x800 -> Flash page at 0x803b000 erased (size: 0x800EraseFlash - Page:0x77 Size:0x800 -> Flash page at 0x803b800 erased (size: 0x800EraseFlash - Page:0x78 Size:0x800 -> Flash page at 0x803c000 erased (size: 0x800EraseFlash - Page:0x79 Size:0x800 -> Flash page at 0x803c800 erased (size: 0x800EraseFlash - Page:0x7a Size:0x800 -> Flash page at 0x803d000 erased (size: 0x800EraseFlash - Page:0x7b Size:0x800 -> Flash page at 0x803d800 erased (size: 0x800EraseFlash - Page:0x7c Size:0x800 -> Flash page at 0x803e000 erased (size: 0x800EraseFlash - Page:0x7d Size:0x800 -> Flash page at 0x803e800 erased (size: 0x800EraseFlash - Page:0x7e Size:0x800 -> Flash page at 0x803f000 erased (size: 0x800EraseFlash - Page:0x7f Size:0x800 -> Flash page at 0x803f800 erased (size: 0x800)
2024-09-02T10:30:29 INFO flash_loader.c: Starting Flash write for F2/F4/F7/L4
2024-09-02T10:30:29 INFO flash_loader.c: Successfully loaded flash loader in sram
2024-09-02T10:30:29 INFO flash_loader.c: Clear DFSR
2024-09-02T10:30:35 INFO common_flash.c: Starting verification of write complete
2024-09-02T10:30:37 INFO common_flash.c: Flash written and verified! jolly good!

That went well - no errors reported. Now let's try to read that flash into a file:

Reading data from the MCU

To be absolutely certain, read the data back into a new file:

lth@ncpws04:~/tmp$ st-flash --flash=256k read random2.bin 0x8000000 0x40000
st-flash 1.8.0
2024-09-02T10:31:51 INFO common.c: STM32L41x_L42x: 48 KiB SRAM, 128 KiB flash in at least 2 KiB pages.
Forcing flash size: --flash=0x00040000
2024-09-02T10:31:51 INFO common.c: read from address 0x08000000 size 262144

No complaints!

Compare data

Finally we can verify that the data read from the MCU matches the data we wrote to the MCU:

lth@ncpws04:~/tmp$ md5sum random*
5f7ebd5c822e07408e6279445eb1444a  random2.bin
5f7ebd5c822e07408e6279445eb1444a  random.bin

They are identical, so it is absolutely confirmed that this particular STM32L432KB is in fact a STM32L432KC which identifies as a STM32L432KB.

Miscellaneous Links