I'm looking to programmatically read the serial number out of a device which uses an STM32 (L07x / L08x / L010). I can read the serial using the STM32 St-Link Utility GUI by reading addresses 0x1FF80050
, 0x1FF80054
, 0x1FF80064
(using size: 0x4, data width: 32 bits).
I now need to do this programmatically. I'm using st-tools
to flash firmware, so thought I could use this to read the addresses out.
I've tried to do it as follows:
st-flash --format ihex read part1.hex 0x1FF80050 32
st-flash --format ihex read part1.hex 0x1FF80054 32
st-flash --format ihex read part1.hex 0x1FF80064 32
It produces an output which I'm finding difficult to parse to extract the serial I need. E.g. part1.hex produces this:
:020000041FF8E3
:100050003139510E363135341100000000FFFFFFF9
:1000600011008C6715002E00000000111100001116
:00000001FF
...where the St-Link utility gives me 0E513931
.
I'm not hugely familiar with STM32 kit - can anyone advise if there's a more concise way to retrieve the serial number?