YTM32的flash应用答疑-详解写保护功能

YTM32的flash应用答疑-详解写保护功能

Introduction

客户提出了一种应用场景:在使用某些授权软件(算法)的场景中,软件(算法)供应商向MCU的一些预留的存储区中写入专用的授权凭证,该凭证一机一码,各不相同,从而确保软件(算法)不会被非法复制。但对于MCU的应用开发者来说,经常需要刷写片内存储空间,更新程序或者数据,此时希望小心保存位于MCU内部存储器上的凭证,在开发和后期正常使用的过程中,不要被意外擦除,否则重新授权需要又需要额外的费用、时间和流程等。

绝大多数MCU的片内flash存储器管理模块都提供了写保护功能,当对已经设置保护功能的存储区进行擦写操作时,擦写的实际效果将失效,被保护存储区中的数据得以幸免留存,已达到防止误擦除的效果。

Principle

YTM32B1MD14微控制器为例,其中片内flash控制器模块EFM,对应有EFM_ADDR_PROT[0]EFM_ADDR_PROT[1]寄存器,其中每个比特可以保护8KB的存储区,按序分布,覆盖全部的片内flash的地址区域。

EFM_ADDR_PROT寄存器位的值为0时,写保护发生作用,对应位的值为1时,写保护不起作用,可以正常擦写。

有两种方式可以配置EFM_ADDR_PROT寄存器的值:

  • CUS_NVR0x100x18地址写数,这里的配置值将作为EFM_ADDR_PROT寄存器的初值,在硬件复位后自动生效(由boot rom复制到EFM_ADDR_PROT寄存器中)。但写入每个寄存器初值时要注意,高32位数必须为0x5A5A5A5A ,然后才是32位的有效配置值。
  • EFM_ADDR_PROT寄存器直接写数,写数之后在程序运行过程中生效,但复位后受CUS_NVR中的初值影响,在软件
### YTM32 IIC (I²C) Programming Tutorial #### Overview of I²C Configuration on YTM32B1MC0 The configuration and use of the Inter-Integrated Circuit (I²C) protocol with the YTM32B1MC0 microcontroller involve setting up specific registers to enable communication between devices over two wires: SDA (Serial Data Line) and SCL (Serial Clock Line). The setup process includes configuring clock speeds, enabling interrupts if necessary, and handling start/stop conditions as well as read/write operations. For initializing an I²C interface on a YTM32 device like the B1 series, one should refer closely to the provided demo examples which serve both demonstration purposes and detailed explanations about how each part works together[^1]. #### Key Points in Setting Up I²C Communication To establish proper I²C communication using YTM32 chips: - **Initialization**: Initialize the I²C peripheral by specifying parameters such as speed mode (standard/fast), address format, own slave address when acting as master/slave. - **Clock Control**: Adjust prescalers within the I²C module according to desired bit rates while ensuring stability under varying power supply voltages. - **Interrupt Handling**: Implement interrupt service routines that can handle events during data transfer including ACKnowledge failures, bus errors, etc., thus maintaining robustness against potential issues arising from hardware bugs similar to those reported for STM32's implementation[^2]. Here is a simplified example demonstrating initialization steps written in C language targeting GCC compiler toolchain commonly used alongside ARM Cortex-M cores found inside these MCUs: ```c #include "ytm32fxxx_hal.h" // Assume `hi2c` has been declared globally somewhere earlier... void MX_I2C_Init(I2C_HandleTypeDef* hi2c){ /* USER CODE BEGIN I2C_Init 0 */ /* USER CODE END I2C_Init 0 */ // Configure I2C settings here... } ``` This code snippet provides only placeholders where actual configurations would take place based upon application requirements. For more comprehensive guidance tailored specifically towards cloud chip products manufactured by YunTu Semiconductor Co Ltd, consulting their official reference manuals becomes essential since they contain precise instructions regarding register mappings along with other critical details pertinent to successful integration into projects involving serial communications protocols like UARTs too[^3]. #### Additional Resources Beyond direct coding practices, understanding underlying principles behind boot processes also plays a significant role especially concerning security aspects related to firmware updates via bootloader mechanisms present even at lower levels affecting higher-level functionalities indirectly through system-wide resets triggered post-update activities[^4]. Moreover, executing commands directly onto flash memory controllers could impact overall performance metrics associated with swapping out executable images stored across different regions depending upon design choices made prior to deployment phases[^5].
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值