当前位置:网站首页>Principle analysis of bootloader
Principle analysis of bootloader
2022-07-25 20:23:00 【Loophole】
Catalog
1.1 bootloader Realize five steps
1.1.3 flash Operation driven implementation
1. The basic chapter
1.1 bootloader Realize five steps
1.1.1 Make an agreement
Single frame data : Frame head , Frame tail , Frame size , Frame check ;
Single packet data ( Multiframe ): Package start frame , Packet size frame , Packet data frame , Packet check frame ;
Whole packet data ( Multi package ): Start frame , End frame , Whole packet check frame ;
1.1.2 Fixed partition
bootloader Partition :boot Program store , Usually 0x8000000 Start
Data storage access : Firmware basic information storage area such as flag bit , Usually in boot Zoning and app In the middle of the partition ;
app Partition :app Program store , Leave enough space for the first two partitions , The rest can be defined as app District ;
1.1.3 flash Operation driven implementation
flash The reading of , Write , Erase method implementation ;
read : Read saved in flash Some basic information in ( Such as logo information ,crc Check value , Basic information of firmware );
Write : Will receive bin File data is written to app Of flash Partition ; Write the basic information of firmware ;
erase : Upgrade initial stage , erase app Partition data, etc ;
1.1.4 app Flag bit definition
One 、 Stored in flash in : At present, the common processing logic of this method is , The flag bit exists bootloader Zoning and app A separate erasable area in the middle of the partition , When the upgrade is successful, put the flag at 1. The advantage of this method is simple logic ; The disadvantage is that the flag is not set before the upgrade process 1, Of course, you can make the flag position through single-step debugging 1.
Two 、 Stored in ram in : The method needs to be app Set correspondence in ram Address value ; More flexibility , Whether the burned program or the upgraded firmware can jump normally . It should be noted that bootloader and app Avoid this part ram Operation of space ( The box keil reset ram From ).
1.1.5 Jump
boot Jump to app, Can be said to be bootloader The core skill in , The basic functions can be realized in the following steps :
One 、 Close all interrupts ;
Two 、 obtain app Entry function address ( namely app Partition start address +4);
3、 ... and 、 take app The entry address is assigned to the function pointer *start_app;
Four 、 Set the main stack address ( namely app The address stored in the starting address of the partition );
5、 ... and 、 call app Entry function start_app();
Be careful , These steps are in order . Think about why ?
One , Closing all interrupts before jump is to prevent the program from running error . Because of this 5 The first step does not reset the interrupt vector table , So when you call start_app() after , Before setting the interrupt vector table , Use or bootloader The interrupt .
Two and three , It's to get app Entry function address , Be sure to get before setting the main stack address . If you set the main stack address and then get app The starting address will be wrong . because start_app Is in boot Variables declared in , The box boot Memory requested by the stack , If you change the main stack address and then change start_app Value , It will be used app The address of the middle stack , So there will be memory usage errors .
Four , Prepare the main stack address before jumping , Because it may appear when entering the function NMI Or other fault, You need to use the stack .
5、 ... and , Active call into app Function of , Perform a jump to app.
1.2 Summary of the basic part
According to the above steps, we can realize bootloader 了 , Most scenarios work .
in addition ,app Also according to the agreed address in keil It's set up inside .
But according to this method bootloader It's still flawed , The following questions can be pondered :
One 、 When upgrading to half , What happens when the upgrade is interrupted ?
Two 、 When the upgrade fails , Can you restore the original program ?
3、 ... and 、 When using usb As a communication interface , Whether the above steps are still applicable ?
边栏推荐
- securecrt乱码解决方法[通俗易懂]
- [today in history] June 29: SGI and MIPS merged; Microsoft acquires PowerPoint developer; News corporation sells MySpace
- [today in history] July 17: Softbank acquired arm; The first email interruption; Wikimedia International Conference
- 网络RTK无人机上机测试[通俗易懂]
- wallys//IPQ5018/IPQ6010/PD-60 802.3AT Input Output 10/100/1000M
- TGA file format (waveform sound file format)
- 什么是聚类分析?聚类分析方法的类别[通俗易懂]
- Why did I choose to become a network engineer after graduating from weak current for 3 months
- RF、GBDT、XGboost特征选择方法「建议收藏」
- Timing analysis and constraints based on xlinx (1) -- what is timing analysis? What are temporal constraints? What is temporal convergence?
猜你喜欢

Google pixel 6A off screen fingerprint scanner has major security vulnerabilities

笔记——记录一个CannotFindDataSourceException: dynamic-datasource can not find primary datasource问题解决

Docker 搭建 Redis Cluster集群
![Interpretation of repartitioned network structure in repvgg network [with code]](/img/0b/a2f3b312899043c9d5b9c7d6b22261.png)
Interpretation of repartitioned network structure in repvgg network [with code]
![[today in history] July 7: release of C; Chrome OS came out;](/img/a6/3170080268a836f2e0973916d737dc.png)
[today in history] July 7: release of C; Chrome OS came out; "Legend of swordsman" issued

9. < tag dynamic programming and subsequence, subarray> lt.718. Longest repeated subarray + lt.1143. Longest common subsequence

PMP每日一练 | 考试不迷路-7.25

Working principle of radar water level gauge and precautions for installation and maintenance

「分享」DevExpress ASP.NET v22.1最新版本系统环境配置要求

Increase swap space
随机推荐
Technology cloud report: more than zero trust, the wild hope of Parra's "Digital Security Cloud strategy"
统信UOS下配置安装cocos2dx开发环境
[today in history] July 19: the father of IMAP agreement was born; Project kotlin made a public appearance; New breakthroughs in CT imaging
参与开源社区还有证书拿?
DIY personal server (DIY storage server)
QQ是32位还是64位软件(在哪看电脑是32位还是64位)
MySQL date [plus sign / +] condition filtering problem
[today in history] July 1: the father of time-sharing system was born; Alipay launched barcode payment; The first TV advertisement in the world
How does tiktok break zero?
JVM (XXIII) -- JVM runtime parameters
2022.7.24-----leetcode.1184
wallys//IPQ5018/IPQ6010/PD-60 802.3AT Input Output 10/100/1000M
Technology cloud report: what is the difference between zero trust and SASE? The answer is not really important
雷达水位计的工作原理及安装维护注意事项
Stochastic gradient descent method, Newton method, impulse method, adagrad, rmsprop and Adam optimization process and understanding
“链”接无限可能:数字资产链,精彩马上来!
Chapter VI modified specification (SPEC) class
[today in history] July 15: Mozilla foundation was officially established; The first operation of Enigma cipher machine; Nintendo launches FC game console
[advanced mathematics] [5] definite integral and its application
Notes - record a cannotfinddatasourceexception: dynamic datasource can not find primary datasource problem solving