烧录:保护模式 ================================= **Protection Setting** 保护设置,实际就是配置 HT32 的选项字节 **Option Byte** ,也是类似于 HT8 **锁芯片** 功能。 Option Byte 简介 ------------------------------------ 1. **Protection Setting** 对应的是 HT32 选项字节 **Option Byte** ,详细说明在 ``UserManual.pdf`` FMC 章节中。 2. HT32 选项字节 **Option Byte**,物理上存在于HT32 FLASH 最后一页。 .. figure:: ../_static/image/Tools/Writer_Protection/image002.png :width: 80% :align: center :alt: FMC Option Byte FMC Option Byte .. note:: HT32 FLASH 按页分区(512Byte/Page或1KByte/Page),HT32不同型号页的大小不同,详细说明在 ``HT32Fxxxxx_UserManual.pdf`` FMC章节中。 .. _Protection Setting: Protection Setting 简介 ------------------------------------------------- .. figure:: ../_static/image/Tools/Writer_Protection/image001.png :width: 80% :align: center :alt: Protection Setting Protection Setting - **Update Protection Setting** : 当勾选此功能,将使能 **Page Protection** 配置,並信息将更新到 **.h32** 中。 - **Page Protection** :FLASH页保护,当功能被使能(设为0),则对使能FLASH页保护的FLASH页,不能进行页擦写,只能读取。 .. figure:: ../_static/image/Tools/Writer_Protection/image003.png :width: 80% :align: center :alt: FLASH 页保护 FLASH 页保护 - **Security Protection** :FLASH安全保护,当功能被使能(设为1),不能通过SWD外部操作HT32 FLASH 读写/页擦写,HT32 内部程序不受影响。 .. figure:: ../_static/image/Tools/Writer_Protection/image004.png :width: 80% :align: center :alt: FLASH安全保护 FLASH 安全保护 - **Option Byte Protection** : **Option Byte** 保护,选项字节保护,当功能被使能(设为1),则不能再更改选项字节 **Option Byte** .. important:: - **全片擦除** 一直生效,任何设置都可以正常使用。 - 如果HT32使用 **IAP+AP框架** : - 不能将 **AP区域** 的 **Page Protection** 使能(设置为0),否则无法更新 **AP区域** 。 - 如果将 **IAP区域** 使能页保护,可以防止 **IAP区域** 被意外更改,但是则无法再更新 **IAP区域** ,如要使用请确保 **IAP程序** 万无一失。 Protection Setting 设置建议 ------------------------------------------------- 1. 若不在意程序是否可以被读出,建议: - **Page Protection** : **All 0xF** (无 FLASH页保护) - **Option Byte Protection** : 口 (无 FLASH安全保护) - **Security Protection** : 口 (无 选项字节保护) .. figure:: ../_static/image/Tools/Writer_Protection/image005.png :width: 80% :align: center :alt: Protection Setting 设置 1 Protection Setting 设置 1 .. note:: 如果是使用 WIFI/BLE & 云平台的产品,可和云平台确认是否是平台绑定模块MAC,如绑定模块MAC,建议HT32不需要保护。 2. 若希望程序不被烧录器读出,使用 **IAP+AP框架** ,但是对 **IAP+AP框架** 各自所占空间不是很清楚,建议: - **Page Protection** : **All 0xF** (无FLASH页保护) - **Option Byte Protection** : 口 (无 FLASH安全保护) - **Security Protection** : V (选项字节保护) .. figure:: ../_static/image/Tools/Writer_Protection/image006.png :width: 80% :align: center :alt: Protection Setting 设置 2 Protection Setting 设置 2 3. 若希望程序不被烧录器读出,使用 **IAP+AP框架**,且清楚 **IAP+AP框架** 各自所占 FLASH区域,则建议: - **Page Protection** : **IAP区域** 设为 **0x0** (FLASH页保护), **AP区域** 设为 **0xF** (无FLASH页保护) - **Option Byte Protection** : V (FLASH安全保护) - **Security Protection** : V (选项字节保护) .. figure:: ../_static/image/Tools/Writer_Protection/image007.png :width: 80% :align: center :alt: Protection Setting 设置 3 Protection Setting 设置 3