如何获得stm32 cpu的唯一ID

发布网友 发布时间:2022-04-20 07:50

我来回答

2个回答

热心网友 时间:2023-07-18 17:49

每个型号的地址不一样的,但做软件加密时不要直接地址,不然很容易被破解
#define SOC_STM32F0_ID_ADDR 0x1FFFF7AC
#define SOC_STM32F1_ID_ADDR 0x1FFFF7E8
#define SOC_STM32F2_ID_ADDR 0x1FFF7A10
#define SOC_STM32F3_ID_ADDR 0x1FFFF7AC
#define SOC_STM32F4_ID_ADDR 0x1FFF7A10
#define SOC_STM32F7_ID_ADDR 0x1FF0F420
#define SOC_STM32L0_ID_ADDR 0x1FF80050
#define SOC_STM32L1_ID_ADDR 0x1FF80050
#define SOC_STM32L4_ID_ADDR 0x1FFF7590
#define SOC_STM32H7_ID_ADDR 0x1FF0F420
1,不要在程序中直接出现id地址,例如STM32:1FFFF7E8 1FFFF7EC 1FFFF7F0 STM8: 0x4865~0x4870
2, 利用校验和或是crc对程序区进行校验,防止改程序

热心网友 时间:2023-07-18 17:49

在数据手册里都有,在最后的设备电子签名那里
stm32F4:

u32 mcuID[3];
mcuID[0] = *(__IO u32*)(0x1FFF7A10);
mcuID[1] = *(__IO u32*)(0x1FFF7A14);
mcuID[2] = *(__IO u32*)(0x1FFF7A18);
printf (" %X %X %X \n",mcuID[0],mcuID[1] ,mcuID[2] );

STM32F1:
SerialID[0] = *(unsigned int*)(0x1FFFF7E8);
SerialID[1] = *(unsigned int*)(0x1FFFF7EC);
SerialID[2] = *(unsigned int*)(0x1FFFF7F0);
声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。
E-MAIL:11247931@qq.com