STM32芯片写保护/解除写保护的方法
一. 写保护
1. 目的
2. 开发环境
3. 程序
通过flash_if.c源程序中的FLASH_If_EnableReadProtection()函数来加密Flash。函数代码如下:
/*** @brief Enable the read protection of user flash area.* @param None* @retval 1: Read Protection successfully enable* 2: Error: Flash read unprotection failed*/uint32_t FLASH_If_EnableReadProtection(void){/* Returns the FLASH Read Protection level. */if( FLASH_OB_GetRDP() == RESET ){/* Unlock the Option Bytes */FLASH_OB_Unlock();/* Sets the read protection level. */FLASH_OB_RDPConfig(OB_RDP_Level_1);/* Start the Option Bytes programming process. */ if (FLASH_OB_Launch() != FLASH_COMPLETE){/* Disable the Flash option control register access (recommended to protect the option Bytes against possible unwanted operations) */FLASH_OB_Lock();/* Error: Flash read unprotection failed */return (2);}/* Disable the Flash option control register access (recommended to protect the option Bytes against possible unwanted operations) */FLASH_OB_Lock();/* Read Protection successfully enable */return (1);}/* Read Protection successfully enable */return (1);}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
二. 解除写保护
1. 建立MDK工程,程序设置为SRAM启动,在程序中解除Flash的锁定。
/***************************************************************** Function: Flash_DisableReadProtection* Description: Disable the read protection of user flash area.* Input:* Output:* Return: 1: Read Protection successfully disable* 2: Error: Flash read unprotection failed
*****************************************************************/
uint32_t Flash_DisableReadProtection(void)
{/* Returns the FLASH Read Protection level. */if( FLASH_OB_GetRDP() != RESET ){/* Unlock the Option Bytes */FLASH_OB_Unlock();/* Sets the read protection level. */
FLASH_OB_RDPConfig(OB_RDP_Level_0);/* Start the Option Bytes programming process. */
if (FLASH_OB_Launch() != FLASH_COMPLETE)
{/* Disable the Flash option control register access (recommended to protect the option Bytes against possible unwanted operations) */FLASH_OB_Lock();/* Error: Flash read unprotection failed */return (2);
}/* Disable the Flash option control register access (recommended to protect the option Bytes against possible unwanted operations) */
FLASH_OB_Lock();/* Read Protection successfully disable */
return (1);}/* Read Protection successfully disable */return (1);
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
该函数调用完成后,Flash芯片也已经解锁成功。
Flash芯片内的程序会被清除。
2. 通过J-Flash解锁
参考网上文章《STM32-读保护功能和清除读保护功能设置》,根据自己操作。如有侵权,请联系我删除
可以在主程序当中设置一按键专门清除“读保护”,一旦按下按键则清除“读保护”时芯片可以重新被烧写。
(3)Debuger选项Download tab中勾全部去掉。
按上面设置完成后,按Debug按钮,执行上面程序,读保护可解除。
(4)点击下载运行时。可能会提示错误(有时不提示)
当下载时,提示 CRC校验失败,选择 NO(右边)。
当下载时,提示无法擦除 sector 0,选择NO(右边)
(5)运行前使用J-Flash ARM"工具,Target->unsercure chip 解除了芯片的读保护。不然会出现上述各种报错。
if (FLASH_GetReadOutProtectionStatus() == SET)
{
启动"J-Flash ARM"工具,Target->unsercure chip 就解除了芯片的读保护。Target->unsercure chip 后一定要上电复位,系统不复位是不行的。
STM32芯片写保护/解除写保护的方法相关推荐
- STM32芯片解除写保护的方法(亲测有效)
STM32芯片解除写保护的方法(亲测有效) 前言 方法 一.用J-Flash来解除写保护 二.用FLYMCU来解除写保护 总结 前言 最近项目上用到STM32系列的单片机,因去年在淘宝上看到芯片便宜, ...
- 关于stm32芯片解锁方法
在调试stm32芯片的时候经常会出现下载不进去,出现类似下面的错误,这个时候就要怀疑是不是芯片被异常锁死了: 我亲测有效的解决方法主要有以下两种: 1.JLINK烧录器解锁:这是最简单的方法 SEGG ...
- gprs模块http mqtt_在GPRS模块(SIM800C)和STM32芯片上实现MQTT协议 | TsonTec:测量解决方案提供者...
最近真是的好一个劲的折腾,算是完全搞明白了如何在STM32上实现MQTT协议了. 目录 [显示] 一.本教程中说明的内容 先说说本文化的适用范围吧: 一.使用的芯片是STM32F103C8T6,但是并 ...
- STM32芯片ADC内部的CH17参考电压的用途
每个STM32芯片都有一个内部的参照电压,相当于一个标准电压测量点,在芯片内部连接到ADC1的通道17. 根据数据手册中的数据,这个参照电压的典型值是1.20V,最小值是1.16V,最大值是1.24V ...
- STM32芯片烧录的三种方式介绍,串口、STM32 ST-LINK Utility以及STM32CubeProgrammer
STM32芯片烧录的三种方式介绍,串口.STM32 ST-LINK Utility以及STM32CubeProgrammer 1 概述 1.1资源概述 1.2 STM32串口烧录方式 2.KEIL软件 ...
- Keil5创建新工程时找不到STM32芯片
手动添加STM32芯片包 在安装完Keil5之后,需要导入STM32芯片包,但是按照网上提供的安装教程,直接点击资料包会报错,如下图: 没有显示可用STM32芯片 尝试解决: 在安装的 ...
- STM32检查不到STLink处理方法
目录 前言 一.未安装ST-Link驱动 二.Win10系统未禁用驱动程序强制签名 三.Keil5的某些设置没有设置好 四.STM32芯片被锁住了 五.解决结果如下 六.总结 前言 有不少人会出现以下 ...
- STM32延时函数的四种方法:普通延时(2种)、SysTick 定时器延时(2种)
STM32延时函数的三种方法:普通延时.SysTick 定时器延时(1.中断方式:2.非中断方式) 单片机编程过程中经常用到延时函数,最常用的莫过于微秒级延时delay_us( )和毫秒级delay_ ...
- 帧率ffmepg 摄像头_【WIN电竞】CSGO解除锁帧方法介绍
很多CSGO设置FPS锁定300了,但是发现电脑很多时候FPS是超过300的,现在按照原样已经解不开了,重上游戏就得设置一下.接下来小编就给大家带来CSGO解除锁帧方法介绍,感兴趣的玩家就快来看看吧. ...
最新文章
- (0013)iOS 开发之集成友盟第三方登录
- python编程入门t-Python GUI编程完整示例
- UITextView实现PlaceHolder的方式
- JS高级程序设置笔记(二)
- PyTorch基础-softmax函数mnist数据集识别-03
- Python--day 3
- Scala 入门2(数组、List、Set、Map、元组、Option、Iterator)
- mysql不区分大小写设置_mysql设置不区分大小写
- 如果成为一名高级安卓开发_想成为一名开发人员? 这是您需要考虑的。
- 489 - Hangman Judge
- Vue2.x总结(1)
- 利用dxflib读写cad文件
- 华为的手册和官网视频,学习网络基础
- mac系统dns的服务器地址,苹果Mac快速切换DNS地址的方法图文详解
- 2021齐齐哈尔实验中学高考成绩查询,齐齐哈尔名列前茅的4所高中,成绩一目了然,谁是市内最强中学?...
- Java实现将文件(图片)上传到七牛云对象存储,并实现下载和删除功能
- 地球物理:大地测量学综述002
- ZipArchive压缩文件夹[转载]
- 华为HCIA复习--传输层协议内容--必看必会
- Antd+Vue2实现动态编辑表格