STM32 F4系列设置Flash读保护

2023-05-16

适用芯片:STM32F4全部芯片
 

1 开启读保护

/****************************************************************
 * Function:    Flash_EnableReadProtection
 * Description: Enable the read protection of user flash area.
 * Input:
 * Output:
 * Return:      1: Read Protection successfully enable
 *              2: Error: Flash read unprotection failed
*****************************************************************/
uint32_t Flash_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);
}
 

2 解除读保护

/****************************************************************
 * 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);
}

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

STM32 F4系列设置Flash读保护 的相关文章

  • 字节4轮面试,3轮都问了RecyclerView

    阿里面试总共4轮 xff0c 其中有3轮面试都问到了RecyclerView的问题 面试的点各不相同 xff0c 有原理 嵌套问题 有缓存实现 xff0c 但是最终都是殊途同归 xff0c 所有的问题都汇集在 如何对RecyclerView
  • 重庆思庄Linux技术分享-创建容器对应的systemd服务并设置其开机自启动失败

    容器已启动 xff0c 服务文件也生成在user文件里 xff0c 运行systemctl user daemmon reload 命令重新加载失败 xff0c 在我退出服务端的时候 xff0c 重新用ssh 进入就解决了 要使用 syst
  • Linux下添加应用程序图标

    为没有快捷方式的程序生成快捷方式图标 以SecureCRT为例 生成 desktop图标 编辑文本文件 xff0c 命名为SecureCRT desktop 内容如下 xff1a Desktop Entry Name 61 SecureCR
  • 如何改变Debian桌面 或者 gnome桌面图标的大小

    要改变Debian桌面图标的size xff0c 我们在图标上点击右键 xff0c 会有一个stretch选项 xff0c 通过这个 xff0c 可以用托拽的方法 xff0c 一个一个来改变图标大小 但这个方法很费劲 xff0c 而且托拽的
  • gradle,gradle/wrapper,build.gradle区别

    1 gradle 跟 maven ant一样是构建工具 2 gradle wrapper Gradle Wrapper是Gradle项目的一部分 引入gradle wrapper xff0c 通过读取配置文件中gradle的版本 xff0c
  • AI一般是用来制作什么的

    AI一般用来制作logo 分页 xff0c 海报等等 面板堆栈的话就是很多功能堆放的位置 一般打印出来的话用cmyk模式 如果是在web端的话用RGB模式 xff0c 因为cmyk模式在你进行存储的过程中颜色可能会丢失 出血值就是在你打印东
  • NetworkX画图:nx.draw_networkx(函数详解)

    NetworkX画图 xff1a nx draw networkx 函数详解 draw networkx span class token punctuation span G span class token punctuation sp
  • 小程序代码构成

    了解项目的基本结构 1 pages xff1a 用来存放所有小程序的页面 2 utils xff1a 用来存放工具性质的模块 xff08 例如 xff1a 格式化事件的自定义模块 xff09 3 app js xff1a 小程序项目的入口文
  • 操作系统笔记

    第一章 xff1a 导论 1 计算机系统 的四个组成成分 xff1a 计算机硬件 操作系统 系统程序和用户 可以大致分为硬件 软件和数据 定义 xff1a 现代通用计算机系统由一个或多个CPU和若干设备控制器通过共同的总线相连而成 xff0
  • 高性能 TCP/UDP/HTTP 通信框架 HP-Socket v4.1.2

    HP Socket 是一套通用的高性能 TCP UDP HTTP 通信框架 xff0c 包含服务端组件 客户端组件和 Agent 组件 xff0c 广泛适用于各种不同应用场景的 TCP UDP HTTP 通信系统 xff0c 提供 C C
  • java根据图片的url地址下载图片到本地

    java根据图片的url地址下载图片到本地 已知图片的url地址 xff0c 通过java代码下载到本地 xff0c 直接上代码 package demo import java io ByteArrayOutputStream impor
  • 【Android -- 动画】Lottie 动画的基本使用

    一 简介 Lottie 是 Airbnb 开源的一个面向 iOS Android React Native 的动画库 xff0c 能分析 Adobe After Effects 导出的动画 xff0c 并且能让原生 App 像使用静态素材一
  • 【Android Studio 使用教程】-- 配置 Kotlin

    简介 Kotlin 是一个基于 JVM 的新的编程语言 xff0c 由 JetBrains 开发 JetBrains xff0c 作为目前广受欢迎的 Java IDE IntelliJ 的提供商 xff0c 在 Apache 许可下已经开源
  • SSM框架整合教程(Spring+SpringMVC+MyBatis)

    SSM框架 1 ssm在各层中的作用 ssm框架与ssh框架类似 xff0c 使用springmvc代替strusts2 mybatis代替hibernate Spring xff1a 主要作用是依赖注入 控制反转以达到解耦的目的 xff0
  • 虚幻引擎VR游戏开发基础教程

    虚幻引擎VR游戏开发基础教程 了解如何使用 Oculus Quest 2 的蓝图在虚幻引擎 4 中从头开始构建基本的 VR 机制 课程英文名 xff1a Unreal Engine VR Development Fundamentals 此
  • 对于人工智能的认识,我们需要更深入全面的理解

    20世纪50年代以来 xff0c 计算机科学家们致力于研发与人类智能类似的程序 当这些程序被开发到一定水平后 xff0c 它们就可以在一些特定的应用场景中替代人类 它们被称为人工智能 xff08 AI xff09 和认知计算 20世纪80年
  • [技巧]如何使用Windows 10 1903中的Windows Sandbox沙箱功能

    微软计划在五月底向大家推送 Windows 10 1903 更新 xff0c 感兴趣的 Insider 测试者们已经可以通过预览通道 xff08 Release Preview Ring xff09 来获得这个最新版本 Windows 10
  • httprunner4.x问题: 运行testcase时, 调用的用例会运行两次

    httprunner4 x问题 运行testcase时 调用的用例会运行两次 问题描述 在测试用例脚本A中使用RunTestCase带参数调用其他api脚本B来构建测试用例时 发现每次运行用例都会有两次运行 产生两份运行日志 第一次 运行脚
  • httprunner中使用JMESPath进行数据提取技巧

    在使用httprunner时 其进行数据提取是使用JMESPath进行的 httprunner示例中的提取未涉及一些稍复杂的提取 所以专门学习了一下JMESPath的使用 做个总结 JMESPath 官方文档路径 https jmespat
  • 解决httprunner3.x上$符号无法当成普通符号用的方法

    前言 由于要测试的api中会涉及 符号的传递 要求其放在参数中当一个普通符号使用 但由于httprunner框架处理逻辑 会将如 coe当成一个变量 从而报错找不到该变量的值 现象 接口某参数为 coeConfig coal 08d99cc

随机推荐