• FW Read protection in code level


    #1, for ST
    FLASH_OBProgramInitTypeDef OBInit; //flash option bytes
    __HAL_FLASH_PREFETCH_BUFFER_DISABLE(); //prefetch buffer disable

    HAL_FLASHEx_OBGetConfig(&OBInit); //Get the Option byte configuration
    if(OBInit.RDPLevel == OB_RDP_LEVEL_0)//option byte read protection
    {
    OBInit.OptionType = OPTIONBYTE_RDP;
    OBInit.RDPLevel = OB_RDP_LEVEL_1;
    HAL_FLASH_Unlock();
    HAL_FLASH_OB_Unlock();
    HAL_FLASHEx_OBProgram(&OBInit);
    HAL_FLASH_OB_Lock();
    HAL_FLASH_Lock();
    }
    __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
    读保护分三个 级别,具体定义如下:在这里插入图片描述

    #2, for GD

    https://blog.csdn.net/u011106767/article/details/123168468?ops_request_misc=&request_id=&biz_id=102&utm_term=fmc%20GD%E4%BF%9D%E6%8A%A4&utm_medium=distribute.pc_search_result.none-task-blog-2allsobaiduweb~default-3-123168468.142v62js_top,201v3control_1,213v1t3_esquery_v1&spm=1018.2226.3001.4187
    bank0, bank1 解锁
    ![在这里插入图片描述](https://img-blog.csdnimg.cn/9afd25337deb410e89db10a7684cef31.png
    在这里插入图片描述

    1. Option byte解锁
      在这里插入图片描述
      在这里插入图片描述
      在这里插入图片描述
      对于GD303:
      #1, 仅仅只有读保护 & 未保护两种状态
      #2, 读保护设置后,需要重启后生效
      #3, 读保护后,烧录器不能通过Connect来读取flash程序
      #4, 程序本身可以读取flash内容
      #5, 通过烧写程序来取消读保护,和更新程序
      #6, 在读保护的状态下,不能用Keil Debug

    在这里插入图片描述

    Detail code:
    /******************************************

    • Flash read protection
    • option byte setting
    • 303, code can read flash content if read flash enable, simulator can read flash
      ******************************************/
      void SetFlashRdProtection(void)
      {
      fmc_state_enum res = FMC_BUSY;
      if(RESET == ob_spc_get())
      {
      printf(“%s %s %d %s \r\n”,FILE,func, LINE,“set flash reading protection”);
      fmc_unlock(); //unlock bank0 flash
      ob_unlock(); //unlock option byte
      ob_erase(); //option byte erase
      res = ob_security_protection_config(FMC_USPC); //start protection
      ob_lock(); //exit option lock
      fmc_lock(); //exit bank0 flash
      }
      }

    Option bytes memory位置
    在这里插入图片描述

  • 相关阅读:
    消息队列延时聚合通知的重要性
    差分进化算法解析:Scala实现详细指南及其在优化问题中的应用
    2D人体姿态估计 - DeepPose
    (五)socket·socket 实现 服务端广播 -不限制次序,不限制交互次数
    力扣(LeetCode)1726. 同积元组(C++)
    历时2月,动态线程池 DynamicTp 发布里程碑版本 V1.0.8
    剑指 Offer 46. 把数字翻译成字符串(DP)
    GUIslice Builder 安装及使用
    求用matlab写出
    Sigma中的数字增益放大/降低方法
  • 原文地址:https://blog.csdn.net/weixin_39305628/article/details/127550292