CN106293531A - 一种基于flash写保护的防止SD使用过程中flash被意外篡改的方法 - Google Patents

一种基于flash写保护的防止SD使用过程中flash被意外篡改的方法 Download PDF

Info

Publication number
CN106293531A
CN106293531A CN201610648520.2A CN201610648520A CN106293531A CN 106293531 A CN106293531 A CN 106293531A CN 201610648520 A CN201610648520 A CN 201610648520A CN 106293531 A CN106293531 A CN 106293531A
Authority
CN
China
Prior art keywords
flash
write
bootloader
protect
subregion
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201610648520.2A
Other languages
English (en)
Other versions
CN106293531B (zh
Inventor
崔营
周庆伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
SHENZHEN FENGLIAN TECHNOLOGY Co Ltd
Original Assignee
SHENZHEN FENGLIAN TECHNOLOGY Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by SHENZHEN FENGLIAN TECHNOLOGY Co Ltd filed Critical SHENZHEN FENGLIAN TECHNOLOGY Co Ltd
Priority to CN201610648520.2A priority Critical patent/CN106293531B/zh
Publication of CN106293531A publication Critical patent/CN106293531A/zh
Application granted granted Critical
Publication of CN106293531B publication Critical patent/CN106293531B/zh
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/062Securing storage systems
    • G06F3/0623Securing storage systems in relation to content
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1008Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's in individual solid state devices
    • G06F11/1068Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's in individual solid state devices in sector programmable memories, e.g. flash disk
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0629Configuration or reconfiguration of storage systems
    • G06F3/0634Configuration or reconfiguration of storage systems by changing the state or mode of one or more devices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/22Microcontrol or microprogram arrangements
    • G06F9/24Loading of the microprogram
    • GPHYSICS
    • G11INFORMATION STORAGE
    • G11CSTATIC STORES
    • G11C29/00Checking stores for correct operation ; Subsequent repair; Testing stores during standby or offline operation
    • G11C29/04Detection or location of defective memory elements, e.g. cell constructio details, timing of test signals
    • G11C29/08Functional testing, e.g. testing during refresh, power-on self testing [POST] or distributed testing
    • G11C29/12Built-in arrangements for testing, e.g. built-in self testing [BIST] or interconnection details
    • G11C29/38Response verification devices
    • G11C29/42Response verification devices using error correcting codes [ECC] or parity check

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Software Systems (AREA)
  • Quality & Reliability (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)
  • Storage Device Security (AREA)

Abstract

本发明公开了一种基于flash写保护的防止SD使用过程中flash被意外篡改的方法,包括(S1)当所述SD设备启动时,将flash写保护指令集和flash去保护指令集全部载入SD设备的内存中保存;(S2)检测bootloader分区是否需要升级,若需要,则(S3)从外部载入待升级的bootloader内容,同时在该过程中当flash与内存之间的串行接口空闲时,从内存中向该bootloader分区一次性写入所述flash去保护指令集,对该bootloader分区进行去保护操作;(S4)升级bootloader内容;(S6)从内存中一次性写入flash写保护指令集,对所述bootloader分区进行flash写保护操作。本发明巧妙利用flash写保护保证了SD设备中bootloader分区不被意外篡改,也不会被破坏,即便其他分区部分出现被篡改的情况,也能够通过应急通道进行升级,恢复SD设备的功能。

Description

一种基于flash写保护的防止SD使用过程中flash被意外篡改 的方法
技术领域
本发明涉及智能设备技术领域,具体地讲,是涉及一种基于flash写保护的防止SD使用过程中flash被意外篡改的方法。
背景技术
目前很多公司都纷纷尝试智能设备(SD,Smart Device)领域,SD设备功能越来越多,硬件集成度越来越高。但是因为一些成本控制或者设计方案不那么完善,以及一些难以避免的原因(如突然停电)导致了SD使用过程中flash(闪存)上固件被意外篡改,SD设备无法正常工作。
SD在使用过程中,由于硬件设备老化、正常使用突然断电等原因,导致了flash中存放的固件被意外篡改,使SD无法正常使用。图1所示,是常规的flash布局,具体的SD设备制造厂商可能略有不同。第一个分区一定是Bootloader分区,对系统进行引导,同时系统镜像分区也一定会有,实现设备主要的功能。其他区域按照各设备的需求而定。
由于某些特殊原因(如突然断电),flash中的镜像文件被篡改,导致SD无法正常启动。遇到这种情况用户只能选择退换货或者自认倒霉。Flash被意外篡改的情况导致退换货在SD设备制造公司非常普遍。如果能够有效减少flash被意外篡改的发生,可以有效的减少公司的损失。从源头上来减少flash被意外篡改,各大flash厂商正在努力的去改正,但是却无法避免。
发明内容
针对上述现有技术的不足,本发明提供一种基于flash写保护的防止SD使用过程中flash被意外篡改的方法。
为了实现上述目的,本发明采用的技术方案如下:
一种基于flash写保护的防止SD使用过程中flash被意外篡改的方法,所述flash内包括bootloader分区、参数区和系统内核根文件分区,其中,对所述bootloader分区进行flash写保护;
(S1)当所述SD设备启动时,将flash写保护指令集和flash去保护指令集全部载入SD设备的内存中保存;
(S2)检测bootloader分区是否需要升级,若需要,则进行下一步,否则保持所述bootloader分区处于写保护状态;
(S3)从外部载入待升级的bootloader内容,同时在该过程中当flash与内存之间的串行接口空闲时,从内存中向该bootloader分区一次性写入所述flash去保护指令集,对该bootloader分区进行去保护操作;
(S4)对bootloader分区内数据进行擦写操作,升级bootloader内容;
(S5)从flash中读取升级后的bootloader内容进行校验,并与升级前的bootloader的校验值进行对比,判断是否升级成功,若是,则进行下一步,否则跳转至步骤(S4);
(S6)从内存中一次性写入flash写保护指令集,对所述bootloader分区进行flash写保护操作。
进一步地,所述flash中还设有一校验区,用于保存升级前的bootloader内容的校验值。
作为一种优选,所述校验值为ECC校验值。
作为一种优选,所述检验值为MD5码。
与现有技术相比,本发明具有以下有益效果:
(1)本发明巧妙利用flash写保护保证了SD设备中bootloader分区不被意外篡改,也不会被破坏,从而使得SD设备在使用时能够至少启动bootloader,即便其他分区部分出现被篡改的情况,也能够通过应急通道进行升级,恢复SD设备的功能,避免了现有技术中因flash出现意外而导致整个SD设备报废的情况,可有效减少SD设备制造公司的损失,同时本发明中在进行写保护和去保护操作时,均先将相关的指令集载入内存再在SPI空闲时一次性写入flash,实现了纳秒级操作,相比现有技术中多条指令分别下达flash的毫秒级操作有极大的提升,在有效提升操作效率的同时更是避免了毫秒级操作更容易造成flash损害的问题,并且本发明构思巧妙新颖,易于实现,应用性好,成本低廉,具有广泛的应用前景,适合推广应用。
(2)本发明利用校验区单独保存升级前的bootloader校验值,保证了升级成功的准确度,有效避免错误进行flash写保护的情况发生。
附图说明
图1为现有技术中flash内的分区布局示意图。
图2为本发明的流程示意图。
图3为本发明中的flash分区布局示意图。
具体实施方式
下面结合附图和实施例对本发明作进一步说明,本发明的实施方式包括但不限于下列实施例。
实施例
如图2至图3所示,该基于flash写保护的防止SD使用过程中flash被意外篡改的方法,所述flash内包括bootloader分区、参数区和系统内核根文件分区,其中,对所述bootloader分区进行flash写保护;
(S1)当所述SD设备启动时,将flash写保护指令集和flash去保护指令集全部载入SD设备的内存中保存;
(S2)检测bootloader分区是否需要升级,若需要,则进行下一步,否则保持所述bootloader分区处于写保护状态;
(S3)从外部载入待升级的bootloader内容,同时在该过程中当flash与内存之间的串行接口空闲时,从内存中向该bootloader分区一次性写入所述flash去保护指令集,对该bootloader分区进行去保护操作;
(S4)对bootloader分区内数据进行擦写操作,升级bootloader内容;
(S5)从flash中读取升级后的bootloader内容进行校验,并与升级前的bootloader的校验值进行对比,判断是否升级成功,若是,则进行下一步,否则跳转至步骤(S4);
(S6)从内存中一次性写入flash写保护指令集,对所述bootloader分区进行flash写保护操作。
其中,所述flash中还设有一校验区,用于保存升级前的bootloader内容的校验值。优选地,所述校验值为ECC校验值或MD5码。
所述flash写保护是指通过设置flash内置的寄存器,保证flash在没有收到特定的指令时,保护特定区域执行擦除或写入操作不会生效。现有的flash写保护基于硬件特点,只能随机保护一个块或者flash头部或尾部的一个区域。针对SD设备内的flash设置情况,我们选择通过flash写保护保护其flash头部区域,即从bootloader分区起的区域,但是由于SD设备flash中参数区在使用过程中需要频繁擦写,因而其进行flash写保护的意义不大,对其进行flash写保护反而会影响参数读写的效率,因此只能对bootloader分区进行flash写保护,其意义在于SD系统启动过程中,设备需要先加载bootloader然后通过bootloader去引导系统,对bootloader分区进行flash写保护后,即使系统镜像文件发送了篡改,SD设备依然可以进入紧急升级状态,从而通过升级系统等手段恢复SD设备的正常功能。
另一方面,本发明在进行flash写保护操作和flash去保护操作中,先将相应的指令集载入SD设备的内存中保存,在flash和内存之间的串行接口SPI空闲时,一次性写入flash内完成相应的写保护或去保护操作,如此达到纳秒级的指令操作;相比现有技术中对flash的指令是一条条下达的毫秒级操作,效率有极大的提升,并且毫秒级的操作在SD设备掉电情况下,更容易造成flash损害。
上述实施例仅为本发明的优选实施例,并非对本发明保护范围的限制,但凡采用本发明的设计原理,以及在此基础上进行非创造性劳动而作出的变化,均应属于本发明的保护范围之内。

Claims (4)

1.一种基于flash写保护的防止SD使用过程中flash被意外篡改的方法,其特征在于,所述flash内包括bootloader分区、参数区和系统内核根文件分区,其中,对所述bootloader分区进行flash写保护;
(S1)当所述SD设备启动时,将flash写保护指令集和flash去保护指令集全部载入SD设备的内存中保存;
(S2)检测bootloader分区是否需要升级,若需要,则进行下一步,否则保持所述bootloader分区处于写保护状态;
(S3)从外部载入待升级的bootloader内容,同时在该过程中当flash与内存之间的串行接口空闲时,从内存中向该bootloader分区一次性写入所述flash去保护指令集,对该bootloader分区进行去保护操作;
(S4)对bootloader分区内数据进行擦写操作,升级bootloader内容;
(S5)从flash中读取升级后的bootloader内容进行校验,并与升级前的bootloader的校验值进行对比,判断是否升级成功,若是,则进行下一步,否则跳转至步骤(S4);
(S6)从内存中一次性写入flash写保护指令集,对所述bootloader分区进行flash写保护操作。
2.根据权利要求1所述的一种基于flash写保护的防止SD使用过程中flash被意外篡改的方法,其特征在于,所述flash中还设有一校验区,用于保存升级前的bootloader内容的校验值。
3.根据权利要求2所述的一种基于flash写保护的防止SD使用过程中flash被意外篡改的方法,其特征在于,所述校验值为ECC校验值。
4.根据权利要求2所述的一种基于flash写保护的防止SD使用过程中flash被意外篡改的方法,其特征在于,所述检验值为MD5码。
CN201610648520.2A 2016-08-10 2016-08-10 一种基于flash写保护的防止SD使用过程中flash被意外篡改的方法 Expired - Fee Related CN106293531B (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610648520.2A CN106293531B (zh) 2016-08-10 2016-08-10 一种基于flash写保护的防止SD使用过程中flash被意外篡改的方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610648520.2A CN106293531B (zh) 2016-08-10 2016-08-10 一种基于flash写保护的防止SD使用过程中flash被意外篡改的方法

Publications (2)

Publication Number Publication Date
CN106293531A true CN106293531A (zh) 2017-01-04
CN106293531B CN106293531B (zh) 2019-09-06

Family

ID=57667287

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610648520.2A Expired - Fee Related CN106293531B (zh) 2016-08-10 2016-08-10 一种基于flash写保护的防止SD使用过程中flash被意外篡改的方法

Country Status (1)

Country Link
CN (1) CN106293531B (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110888653A (zh) * 2019-11-01 2020-03-17 桃芯科技(苏州)有限公司 存储器中固件读写的控制方法、系统、电子设备、芯片
CN115952564A (zh) * 2023-03-01 2023-04-11 荣耀终端有限公司 数据写入方法和终端设备

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101650662A (zh) * 2009-08-26 2010-02-17 中兴通讯股份有限公司 一种嵌入式系统的存储器件、固件启动及升级方法
CN102902556A (zh) * 2012-09-06 2013-01-30 深圳市共进电子股份有限公司 一种嵌入式设备的多级引导加载方法
CN105204899A (zh) * 2015-09-17 2015-12-30 浪潮软件集团有限公司 一种基于网络的单片机固件升级方法的实现

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101650662A (zh) * 2009-08-26 2010-02-17 中兴通讯股份有限公司 一种嵌入式系统的存储器件、固件启动及升级方法
CN102902556A (zh) * 2012-09-06 2013-01-30 深圳市共进电子股份有限公司 一种嵌入式设备的多级引导加载方法
CN105204899A (zh) * 2015-09-17 2015-12-30 浪潮软件集团有限公司 一种基于网络的单片机固件升级方法的实现

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110888653A (zh) * 2019-11-01 2020-03-17 桃芯科技(苏州)有限公司 存储器中固件读写的控制方法、系统、电子设备、芯片
CN115952564A (zh) * 2023-03-01 2023-04-11 荣耀终端有限公司 数据写入方法和终端设备
CN115952564B (zh) * 2023-03-01 2023-08-15 荣耀终端有限公司 数据写入方法和终端设备

Also Published As

Publication number Publication date
CN106293531B (zh) 2019-09-06

Similar Documents

Publication Publication Date Title
CN104850762B (zh) 防止计算机的动作不良的方法、计算机程序以及计算机
CN106528106B (zh) 一种自适应各种不同Flash芯片类型的嵌入式系统启动方法
CN105808270A (zh) 固件变量更新方法
KR100316981B1 (ko) 플래시 메모리를 구비한 마이크로컴퓨터 및 플래시 메모리에 프로그램을 저장하는 방법
CN104063477B (zh) 嵌入式系统启动异常的处理方法及装置
CN103119554A (zh) 提供平台无关的存储器逻辑
CN104011733B (zh) 在系统预引导期间具有改进的只读存储器锁定的安全数据保护
CN103377063A (zh) 从遗留操作系统环境恢复到uefi预启动环境的方法和系统
CN105378663A (zh) 更新引导代码
CN101634960A (zh) 一种修改bios参数及重新生成校验和的方法
CN102567049A (zh) 嵌入式操作系统的升级方法
US20070226478A1 (en) Secure boot from secure non-volatile memory
CN107566169A (zh) 一种基于openwrt的固件升级方法及路由器
US10824732B1 (en) System and method for protecting firmware of baseboard management controller of computing device
CN104835537A (zh) Soc芯片自适应启动方法及装置
CN104008069A (zh) 一种数据保护方法、装置及设备
CN106293531A (zh) 一种基于flash写保护的防止SD使用过程中flash被意外篡改的方法
CN104484289A (zh) 一种基于扇区的嵌入式系统写保护的装置以及方法
US20160179626A1 (en) Computer system, adaptable hibernation control module and control method thereof
RU2469384C2 (ru) Способ маскировки перехода к концу срока службы электронного устройства и устройство, содержащее соответствующий контрольный модуль
CN106250262A (zh) 一种基于双镜像的防止SD使用过程中flash被意外篡改的方法
CN113094107B (zh) 数据保护方法、装置、设备及计算机存储介质
CN114496052A (zh) Ssd非操作电源状态允许模式功能的测试方法和装置
CN112394965B (zh) 电池管理系统升级和运行方法,控制器,电池管理系统及存储介质
JPH11265283A (ja) 記憶装置におけるファームウェアの修正方法及び記憶装置

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20190906

Termination date: 20210810

CF01 Termination of patent right due to non-payment of annual fee