日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁(yè) > 單片機(jī) > 單片機(jī)
[導(dǎo)讀] 1,目的 在實(shí)際的產(chǎn)品發(fā)布中,如果不對(duì)儲(chǔ)存在單片機(jī)Flash中的程序做一些保護(hù)的話(huà),就有可能被一些不法公司,通過(guò)仿真器(J-Link,ST-Link等)把Flash中的程序讀取回來(lái),得到bin文件或hex文件,然后去山

1,目的

在實(shí)際的產(chǎn)品發(fā)布中,如果不對(duì)儲(chǔ)存在單片機(jī)Flash中的程序做一些保護(hù)的話(huà),就有可能被一些不法公司,通過(guò)仿真器(J-Link,ST-Link等)把Flash中的程序讀取回來(lái),得到bin文件或hex文件,然后去山寨產(chǎn)品。所以我們需要對(duì)程序進(jìn)行保護(hù),一種比較簡(jiǎn)單可靠的方法就是把Flash設(shè)置成讀保護(hù)。


2,開(kāi)發(fā)環(huán)境

1,適用芯片:STM32F4全部芯片

2,固件庫(kù):STM32F4xx_DSP_StdPeriph_Lib_V1.8.0

3,IDE:MDK517


3,程序源碼


/****************************************************************

* Function: Flash_EnableReadProtection

* Description: Enable the read protection of user flash area.

* Input:

* Output:

* Return: 1: Read Protection successfully enable

* 2: Error: Flash read unprotection failed

*****************************************************************/

uint32_t Flash_EnableReadProtection(void)

{

/* Returns the FLASH Read Protection level. */

if( FLASH_OB_GetRDP() == RESET )

{

/* Unlock the Option Bytes */

FLASH_OB_Unlock();

/* Sets the read protection level. */

FLASH_OB_RDPConfig(OB_RDP_Level_1);

/* Start the Option Bytes programming process. */

if (FLASH_OB_Launch() != FLASH_COMPLETE)

{

/* Disable the Flash option control register access (recommended to protect

the option Bytes against possible unwanted operations) */

FLASH_OB_Lock();

/* Error: Flash read unprotection failed */

return (2);

}

/* Disable the Flash option control register access (recommended to protect

the option Bytes against possible unwanted operations) */

FLASH_OB_Lock();

/* Read Protection successfully enable */

return (1);

}

/* Read Protection successfully enable */

return (1);

}

/****************************************************************

* Function: Flash_DisableReadProtection

* Description: Disable the read protection of user flash area.

* Input:

* Output:

* Return: 1: Read Protection successfully disable

* 2: Error: Flash read unprotection failed

*****************************************************************/

uint32_t Flash_DisableReadProtection(void)

{

/* Returns the FLASH Read Protection level. */

if( FLASH_OB_GetRDP() != RESET )

{

/* Unlock the Option Bytes */

FLASH_OB_Unlock();

/* Sets the read protection level. */

FLASH_OB_RDPConfig(OB_RDP_Level_0);

/* Start the Option Bytes programming process. */

if (FLASH_OB_Launch() != FLASH_COMPLETE)

{

/* Disable the Flash option control register access (recommended to protect

the option Bytes against possible unwanted operations) */

FLASH_OB_Lock();

/* Error: Flash read unprotection failed */

return (2);

}

/* Disable the Flash option control register access (recommended to protect

the option Bytes against possible unwanted operations) */

FLASH_OB_Lock();

/* Read Protection successfully disable */

return (1);

}

/* Read Protection successfully disable */

return (1);

}


本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀(guān)點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專(zhuān)欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除。
換一批
延伸閱讀

中國(guó)北京(2025年9月10日)—— 業(yè)界領(lǐng)先的半導(dǎo)體器件供應(yīng)商兆易創(chuàng)新GigaDevice(股票代碼 603986)亮相于深圳國(guó)際會(huì)展中心舉辦的第26屆中國(guó)國(guó)際光電博覽會(huì)(展位號(hào):12C12),全面展示GD25 SPI...

關(guān)鍵字: 光通信 MCU Flash

在嵌入式系統(tǒng)中,F(xiàn)lash存儲(chǔ)器因其非易失性、高密度和低成本特性,成為代碼存儲(chǔ)和關(guān)鍵數(shù)據(jù)保存的核心組件。然而,MCU驅(qū)動(dòng)Flash讀寫(xiě)時(shí),開(kāi)發(fā)者常因?qū)τ布匦岳斫獠蛔慊虿僮髁鞒淌韬?,陷入性能下降、?shù)據(jù)損壞甚至硬件損壞的陷...

關(guān)鍵字: MCU驅(qū)動(dòng) Flash

深圳2025年4月24日 /美通社/ -- 4月23日,2025上海國(guó)際車(chē)展盛大啟幕,全球汽車(chē)產(chǎn)業(yè)的目光聚焦于這場(chǎng)科技與創(chuàng)新的盛宴。在眾多展示亮點(diǎn)中,汽車(chē)AI+應(yīng)用無(wú)疑是最大的熱點(diǎn)之一,“駕控超級(jí)大腦”技術(shù)概念、車(chē)機(jī)交互...

關(guān)鍵字: GB EMMC Flash PS

在自動(dòng)駕駛、機(jī)器人與工業(yè)檢測(cè)領(lǐng)域,激光雷達(dá)作為環(huán)境感知的核心傳感器,其技術(shù)路線(xiàn)正從機(jī)械式向固態(tài)化演進(jìn)。MEMS、OPA與Flash作為固態(tài)激光雷達(dá)的三大主流架構(gòu),分別通過(guò)微機(jī)電系統(tǒng)、光學(xué)相控陣與泛光面陣技術(shù)實(shí)現(xiàn)掃描與探測(cè)...

關(guān)鍵字: MEMS OPA Flash

在嵌入式系統(tǒng)開(kāi)發(fā)中,外部存儲(chǔ)介質(zhì)的選擇和管理至關(guān)重要。SPI Flash以其高容量、低功耗、高速率等特點(diǎn),成為眾多嵌入式設(shè)備的首選存儲(chǔ)方案。然而,如何高效管理SPI Flash存儲(chǔ),避免數(shù)據(jù)丟失、提高讀寫(xiě)性能,是開(kāi)發(fā)者必...

關(guān)鍵字: 嵌入式SPI Flash LittleFS

STM32單片機(jī)作為一種高性能、低功耗的嵌入式微控制器,廣泛應(yīng)用于各種電子設(shè)備中。在實(shí)際應(yīng)用中,為了擴(kuò)展存儲(chǔ)空間或?qū)崿F(xiàn)數(shù)據(jù)的持久化存儲(chǔ),經(jīng)常需要使用外部FLASH存儲(chǔ)器。本文將詳細(xì)介紹STM32單片機(jī)如何讀寫(xiě)外部FLAS...

關(guān)鍵字: STM32 Flash

在嵌入式系統(tǒng)和存儲(chǔ)設(shè)備領(lǐng)域,F(xiàn)lash和EEPROM(電可擦可編程只讀存儲(chǔ)器)因其非易失性存儲(chǔ)特性而被廣泛應(yīng)用。這些存儲(chǔ)設(shè)備能夠在斷電后保持?jǐn)?shù)據(jù),對(duì)于需要長(zhǎng)期保存配置參數(shù)、程序代碼或用戶(hù)數(shù)據(jù)的應(yīng)用來(lái)說(shuō)至關(guān)重要。然而,關(guān)于...

關(guān)鍵字: Flash EEPROM
關(guān)閉