關(guān)于FPGA遠程更新bpi flash中multiboot的實現(xiàn)
- 關(guān)鍵詞: 遠程固化、flash固化、multiboot實現(xiàn)、bpi flash
一.什么叫multiboot ?
multiboot 即 flash多重啟動加載方式,常用于遠程加載場景中,當(dāng)遠程加載失敗時,flash會啟動應(yīng)急預(yù)案,將另一塊地址的備用程序拿來作為加載FPGA的程序,防止由遠程固化失敗導(dǎo)致的FPGA啟動不了的情況。
二.multiboot 實現(xiàn)的基本流程
基本流程為: 將FLASH按照地址劃分為兩段,分別叫Golden Image和MultiBoot Image,使用時,需要在Golden Image和MultiBoot Image固化的程序文件中加入特定的約束。上電后,F(xiàn)PGA會先從Address 0開始加載程序,此時,特定的協(xié)議會告知FPGA從Upper Address加載程序。若MultiBoot Image中有配置完整的程序文件,F(xiàn)PGA將加載程序并運行,否則FPGA將會再次跳轉(zhuǎn)到Golden Image,直接從Address 0加載程序文件并運行。
三、FPGA生成Golden Image和MultiBoot Image固化程序文件
(1)Golden Image的bit文件
在生成所需的bit流文件時,需要額外加入以下約束:
set_property BITSTREAM.CONFIG.NEXT_CONFIG_REBOOT ENABLE [current_design]
set_property BITSTREAM.CONFIG.TIMER_CFG 0x00010000 [current_design]
set_property BITSTREAM.GENERAL.COMPRESS true [current_design]
set_property BITSTREAM.CONFIG.NEXT_CONFIG_ADDR 0x00800000 [current_design]
(2)MultiBoot Image的bit文件
在生成所需的bit流文件時,需要額外加入以下約束
set_property BITSTREAM.CONFIG.CONFIGFALLBACK ENABLE [current_design]
set_property BITSTREAM.GENERAL.COMPRESS true [current_design]
(3)一個工程同時生成兩種bit文件的方法(注:等于(1)+(2))
set boot_bitfile_name "FPGA_boot.bit" ;
set_property BITSTREAM.CONFIG.CONFIGRATE 33 [current_design]
set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 1 [current_design]
set_property BITSTREAM.CONFIG.SPI_32BIT_ADDR Yes [current_design]
set_property BITSTREAM.GENERAL.COMPRESS true [current_design]
set_property BITSTREAM.CONFIG.NEXT_CONFIG_ADDR 0x00800000 [current_design]
set_property BITSTREAM.CONFIG.NEXT_CONFIG_REBOOT ENABLE [current_design]
set_property BITSTREAM.CONFIG.TIMER_CFG 0x00010000 [current_design]
set path_curr_tcl [file dirname [info script]]; #獲取當(dāng)前腳本所在路徑
set OutPath "$path_curr_tcl/../../out"; #腳本路徑返回2級后的out文件夾 "/../"表示上一級路徑
#如果不存在此路徑,則新建
if { ![file exists $OutPath] } {
file mkdir $OutPath ;
}
write_bitstream -force -bin_file [file join $OutPath $boot_bitfile_name]; #在指定路徑上生成bit文件
#到此結(jié)束是生成第一個bit和bin文件
#此處開始生成第二個bit和bin文件
set_property BITSTREAM.CONFIG.NEXT_CONFIG_REBOOT DISABLE [current_design]
set_property BITSTREAM.CONFIG.CONFIGFALLBACK ENABLE [current_design]
set_property BITSTREAM.CONFIG.TIMER_CFG 0x00000000 [current_design]
write_bitstream -force -bin_file [current_design]
并將如上約束復(fù)制到txt文件中,并將后綴改為tcl文件,并將tcl文件添加至比特流設(shè)置的 tcl pre 中,可在工程的out文件夾中的生成Golden Image的bit文件
(4)將bit文件轉(zhuǎn)化為bin文件
如下圖,因為BPI 的bin文件需要進行swapping操作,因此bin文件需要使用如下方法生成。
如上需要選擇 對應(yīng)的flash芯片
四、遠程下載上板驗證
(1)生成合成的mcs文件
可以通過如下方式生成multiboot的合并mcs文件,第一個方框里是本文使用的bpi flash ,第二個方框中是multiboot的flash地址,注意,這里的地址與前面golden image 的約束是一致的,且這里的0x0800000地址,因為這里使用的是bpi x16的數(shù)據(jù)模塊,因此0x0800000對應(yīng)的數(shù)據(jù)位置其實是16M,這點我們在實現(xiàn)該功能的時候走了彎路,需要留意。文章來源:http://www.zghlxwxcb.cn/news/detail-608579.html
(2)將mcs文件固化到flash中,重啟設(shè)置
(3)如何確定目前是multiboot image 還是 golden image的程序?
如上點擊當(dāng)前的fpga芯片,可以找到boot status 寄存器,當(dāng)寄存器中的 BIT0_0_BACK為0 時候,表示這時候跑的是multiboot image的程序,如果BIT0_0_BACK為1 時候,表示這時候跑的是golden image的程序。文章來源地址http://www.zghlxwxcb.cn/news/detail-608579.html
到了這里,關(guān)于關(guān)于FPGA遠程更新bpi flash中multiboot的實現(xiàn)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!