当前位置:网站首页>STM32 unique ID reading method
STM32 unique ID reading method
2022-07-21 01:39:00 【xqhrs232】
Original address ::STM32 only ID Reading method _jiangchao3392 The blog of -CSDN Blog _stm32 only id
Related articles
1、TI CC1310 sub1G Of SDK Unique identification number of development MAC Address reading ----TI CC1310 sub1G Of SDK Unique identification number of development MAC Address reading _--- These horsemen --- The blog of -CSDN Blog
TM32 The microcontroller has a 96 Unique product identification of bit , In any case, it is unique and cannot be modified 96 Unique product identification of bit , It can be in bytes (8 position ) Read... For units , You can also use half a word (16 position ) Or whole word (32 position ) Read .
Want to read unique ID, You need to know its storage address , In different series MCU There are different addresses in , We checked some MCU And summarize it as follows :
// Read FlashSize
uint16_t cpuGetFlashSize(void)
{
return (**(volatile u16*)(0x1FFF7A22));
// return (*(volatile u32*)(0x1FFF7A20))>>16;
}
// Read ChipID
void cpuidGetId(void)
{
mcuID[0] = *(volatile u32*)(0x1FFF7A10);
mcuID[1] = *(volatile u32*)(0x1FFF7A14);
mcuID[2] = *(volatile u32*)(0x1FFF7A18);
}
Send_data3 = ((CpuID[0]) >> 24)|0x00;
Uart1Write(&Send_data3, 1);
Send_data3 = (CpuID[0] >> 16)|0x00;
Uart1Write(&Send_data3, 1);
Send_data3 = (CpuID[0] >> 8)|0x00;
Uart1Write(&Send_data3, 1);
Send_data3 = (CpuID[0] )|0x00;
Uart1Write(&Send_data3, 1);
Send_data3 = ((CpuID[1]) >> 24)|0x00;
Uart1Write(&Send_data3, 1);
Send_data3 = (CpuID[1] >> 16)|0x00;
Uart1Write(&Send_data3, 1);
Send_data3 = (CpuID[1] >> 8)|0x00;
Uart1Write(&Send_data3, 1);
Send_data3 = (CpuID[1] )|0x00;
Uart1Write(&Send_data3, 1);
Send_data3 = ((CpuID[2]) >> 24)|0x00;
Uart1Write(&Send_data3, 1);
Send_data3 = (CpuID[2] >> 16)|0x00;
Uart1Write(&Send_data3, 1);
Send_data3 = (CpuID[2] >> 8)|0x00;
Uart1Write(&Send_data3, 1);
Send_data3 = (CpuID[2] )|0x00;
Uart1Write(&Send_data3, 1);
Send to... Through serial port PC You can see .
Serial port sending program ;
printf("CPUID IS 0X%X %X %X.\r\n", mcuID[0], mcuID[1], mcuID[2] );
printf("Flash size is %d KB\r\n",cpuGetFlashSize());
It can also be done through STLink Utility see
utilize STM32 Of ID Combine coding to encrypt products , The unique identity of the product is very suitable for :
● Used as a serial number ( for example USB Character serial numbers or other terminal applications )
● Used as a password , When writing flash memory , Combine this unique ID with software encryption and decryption algorithm , Improve the security of code in flash memory .
● The bootstrap process used to activate the belt safety mechanism
96 The reference number provided by the product's unique identity is for any one STM32 Micro controller , In any case, it is unique . Under what circumstances do users , Can't modify this identity .
This 96 Unique product identification of bit , According to different usage of users , It can be in bytes (8 position ) Read... For units , You can also use half a word (16 position ) Or whole word (32 position ) Read .
Base address :0x1FFF F7E8
Every CPU When leaving the factory
One of the configurations ID,96 Bit . This unique code can be used as software encryption .......
static u32 CpuID[3];
static u32 Lock_Code;
void GetLockCode(void)
{
// obtain CPU only ID
CpuID[0]=*(vu32*)(0x1ffff7e8);
CpuID[1]=*(vu32*)(0x1ffff7ec);
CpuID[2]=*(vu32*)(0x1ffff7f0);
// encryption algorithm , A very simple encryption algorithm
Lock_Code=(CpuID[0]>>1)+(CpuID[1]>>2)+(CpuID[2]>>3);
}
Example :
STM32 Use CPUID encryption algorithm , A very simple encryption algorithm
Lock_Code=(CpuID[0]>>1)+(CpuID[1]>>2)+(CpuID[2]>>3);
CpuID[0] CpuID[1] CpuID[2] Lock_Code CpuID[0]>>1 CpuID[0]>>2 CpuID[0]>>3
1 Number CPU 0668FF30 3037564E 43023216 17A29B6D 3347F98 C0DD593 8604642
2 Number CPU 066AFF30 3037564E 43024449 17A39DB4 3357F98 C0DD593 8604889
3 Number CPU 066CFF30 3037564E 43021551 17A497D5 3367F98 C0DD593 86042AA
4 Number CPU 066BFF30 3037564E 43024716 17A41E0D 335FF98 C0DD593 86048E2
5 Number CPU 066CFF30 3037564E 43023851 17A49C35 3367F98 C0DD593 860470A
6 Number CPU 066DFF37 3235564E 43152737 1826FA14 336FF9B C8D5593 862A4E6
Reference resources :
https://blog.csdn.net/ybhuangfugui/article/details/52597133
https://blog.csdn.net/foxclever/article/details/80294516
https://www.cnblogs.com/zyqgold/p/3378993.html
http://www.openedv.com/posts/list/41972.htm
————————————————
Copyright notice : This paper is about CSDN Blogger 「jiangchao3392」 The original article of , follow CC 4.0 BY-SA Copyright agreement , For reprint, please attach the original source link and this statement .
Link to the original text :https://blog.csdn.net/jiangchao3392/article/details/89668629
边栏推荐
- Redux principle
- 二值化神经网络权重的分布规则
- Network security - comprehensive penetration test -cve-2019-15107-webmin remote code execution
- 超分领域常见的损失函数
- Configure dual database
- 2022年度杭州未来科技城数字经济人才编程大赛02.黑白棋游戏_____滑动窗口
- 自定义类型:结构体,枚举,联合
- Tutorial on principles and applications of database system (030) -- data integrity of MySQL (III): defining unique constraints
- Force deduction and question brushing record 4---69 Square root of X
- 元宇宙的发展也是一个逐渐成为人们的生产和生活方式的过程
猜你喜欢
测试人遇到难以重现的bug,要怎么办?
Quick sequencing and optimization
HW2021攻防演练经历碎碎念-见解
网络安全—综合渗透测试-CVE-2019-7238-Nexus远程代码执行
【LeetCode-中等】34. 在排序数组中查找元素的第一个和最后一个位置 - 数组双指针
Shardingsphere proxy with mogdb/opengauss to realize distributed database
理解和应用持续集成-Tekton
网络安全—综合渗透测试-CVE-2018-10933-libssh漏洞分析
JSP custom tags (an article learned that each line of code has comments)
LeetCode.1252. 奇数值单元格的数目___简单模拟 / 行列数组+排列组合
随机推荐
iptables防止nmap端口扫描
Tutorial on the principle and application of database system (024) -- MySQL modifying the structure of data tables
洛谷 P1873 [COCI 2011/2012 #5] EKO / 砍树 二分
Tutorial on principles and applications of database system (032) -- data integrity of MySQL (V): define auto_increment
W806开发板体验
LeetCode_ 78_ subset
Quick sequencing and optimization
Luogu p2440 wood processing
cascade级联关系操作实例分析
元宇宙的发展也是一个逐渐成为人们的生产和生活方式的过程
Day106. Shangyitong: data dictionary list, easyexcel, data dictionary import and export, integrated redis cache
ICLR 2022 | GNNAsKernel: 能提升任意GNN表达能力的通用框架
力扣343-整数分割——动态规划
Summer vacation safety second assignment
基于hog特征的图像处理
Webrtc series -sdp and other relationships
Luogu p1678 troubled college entrance examination volunteers
cannot import name ‘import_ String 'from' Werkzeug '[bug resolution]
微信小程序如何实现select二级下拉
LeetCode.208. 实现 Trie (前缀树)____字典树