Preface
STM32 PCROP proprietary code readout protection sets a certain area to only allow execution, which can prevent the code from being illegally read out and modified. The ST website provides free PCROP reference code, but the routine only provides code to set PCROP. To facilitate the development and deployment of intellectual property protection using PCROP, this article provides a method to use code to clear PCROP when the RDP level is set to 1 or 0.
PCROP reference code on the ST website
To learn how to use PCROP, you can download documents and reference code from the ST website. The document has detailed step-by-step instructions. The reference code implements how to set up the compilation development environment to remove the literal pool to avoid the need for read access to the protected area; the reference code also implements how to use code to enable PCROP protection and how to export interface symbols for secondary development.
You can compile and run the PCROP reference code. Once downloaded to the development board and run, sector 2 will automatically be set to PCROP protection. You will not be able to download code to this sector again, nor can you read the contents of this sector. If you want to remove PCROP protection through the STLink tool , the entire Flash will be erased.
Using code to clear PCROP
Based on the familiarity of the PCROP reference code on the ST website, we will discuss how to use code to clear PCROP.
1. Principle
According to the STM32 user manual , to clear PCROP protection, the read protection RDP level must be set from 1 to 0. That is to say, even if the current RDP level is 0, we have to use code to set it to 1. Then, turn off PCROP and set RDP to 0 at the same time. This also shows that even if it is to clear PCROP protection, our code must add the RDP setting function, and cannot simply modify the status field of PCROP_Enable in the reference code to make it PCROP_Disable.
2. Material preparation
Development board: STM32F429I_Discovery
Development tools: STM32Cube_FW_F4 _V1.15.0
STM32CubeExpansion_AN4701_F4_V1.0.0 (reference code downloaded from ST website)
STM32 STLink
IAR/Keil
Note: You can also select other STM32 series that support PCROP, and select the corresponding STM32 development board and STM32 firmware library .
3. Code
● Set RDP to level 1
This function must be used when the RDP level is 0 if you need to clear PCROP.
●Set RDP to level 0
This function is not called directly in the code that clears PCROP protection. The reference manual mentions that clearing PCROP must happen at the same time as RDP goes from 1 to 0, and the following RDP_Disable function is completely independent and cannot be operated at the same time as the Option bytes of PCROP. However, the middle part of this code, which is the actual functional part, will be reused when clearing PCROP.
●Clear PCROP
The following code clears PCROP. It is rewritten based on the PCROP_Enable function in the reference code. First, it sets RDP to 1 through RDP_Enable. Note that you should not set RDP to 2 in the experiment, otherwise all Option bytes will no longer be allowed to be modified. Then, after setting both RDP and PCROP, call HAL_FLASH_OB_Launch once to set RDP to 1 and clear PCROP protection at the same time.
4. Run
in the main function and call PCROP_Disable to remove the PCROP protection. After RDP_Enable, you need to turn off the power, restart, and then run the system normally to remove the PCROP protection. After removing the protection, you can confirm that the PCROP Option bytes have been restored through STLink, and you can also see that the entire Flash content has been erased.
Conclusion
This article discusses the setting and clearing of PCROP completely controlled by code. It can be used in the development and deployment stage of PCROP code protection.
Previous article:How to deal with the MCU system failure
Next article:MSP430 AD Module Notes
Recommended ReadingLatest update time:2024-11-16 14:39
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- 【Qinheng Trial】CH554 Unboxing
- EEWORLD University ---- Operating System (RISC-V)
- [Zero-knowledge ESP8266 tutorial] Quick Start 7- Make a buzzer
- [ATmega4809 Curiosity Nano Review] Using MPLAB Xpress
- I2C Range Extension Reference Design: I2C to CAN
- Recently, the project department has taken on a new project, which requires the performance indicators of IC to meet industrial requirements. Can someone recommend...
- The power supply cannot be completely turned off. There is a leakage of 4~5MA. I hope an expert can give me some advice.
- About the memory mode of TMS320C2X/C5X
- EEWORLD University Hall----Live Replay: When intelligence meets industry, how can technology be implemented?
- catkin_make does not compile all packages