在xilinx的SDK下生成boot.bin的過程,有時非常讓人惱火...
得手動選幾個文件xx.fsbl, xx.bit, xx.elf.....選來選去的非常麻煩,
而且SDK還常常Browse時...還不指定在當前工程目錄下...
所以,我一怒之下,想寫個批處理...沒有寫出來...拖延症嚴重.. *_*
最后還是高老師出馬,我基本照抄...寫了個簡單注釋...
總之是非常方便,手動把要轉的bit,fsbl.elf,xx.elf一起拖到這個批處理中....
如xxxx.bit, xxx_fsbl.elf(fsble一定要包含,否則無法和app.elf區別), xxx.elf(IDE下的應用程序);
就在當前目錄下生成BOOT.bin
內容如下,
1 @echo off 2 @echo ******************************************** 3 @echo Generate Boot.bin 4 @echo ******************************************** 5 :: bootgen地址,根據安裝的ISE修改 6 set cmdpath=J:/ISE14_4/14.4/ISE_DS/ISE/bin/nt/ 7 8 :: 輸入文件 9 set filename1=%1 10 set filename2=%2 11 set filename3=%3 12 13 :: 文件名是帶有絕對路徑的,所以將\轉換為/ 14 set filename1=%filename1:\=/% 15 set filename2=%filename2:\=/% 16 set filename3=%filename3:\=/% 17 18 :: 生成bif文件 19 echo the_ROM_image: >bootimage.bif 20 echo { >>bootimage.bif 21 22 :: 分析文件,bif中順序寫入fsbl.elf,XXX.bit,app.elf 23 24 if [%filename1:~-8%]==[fsbl.elf] ( ::此處括號必須在這個位置... 25 echo [bootloader]%filename1:~2,200% >>bootimage.bif ::不能含盤符 26 if [%filename2:~-3%] == [bit] ( 27 echo %filename2:~2,200% >>bootimage.bif 28 echo %filename3:~2:200% >>bootimage.bif 29 ) else ( 30 echo %filename3:~2,200% >>bootimage.bif 31 echo %filename2:~2,200% >>bootimage.bif 32 ) 33 echo } >>bootimage.bif 34 ) 35 36 if [%filename2:~-8%] == [fsbl.elf] ( 37 echo [bootloader]%filename2:~2,200% >>bootimage.bif 38 if [%filename1:~-3%] == [bit] ( 39 echo %filename1:~2,200% >>bootimage.bif 40 echo %filename3:~2,200% >>bootimage.bif 41 ) else ( 42 echo %filename3:~2,200% >>bootimage.bif 43 echo %filename1:~2,200% >>bootimage.bif 44 ) 45 echo } >>bootimage.bif 46 ) 47 if [%filename3:~-8%] == [fsbl.elf] ( 48 echo [bootloader]%filename3:~2,200% >>bootimage.bif 49 if [%filename1:~-3%] == [bit] ( 50 echo %filename1:~2,200% >>bootimage.bif 51 echo %filename2:~2,200% >>bootimage.bif 52 ) else ( 53 echo %filename2:~2,200% >>bootimage.bif 54 echo %filename1:~2,200% >>bootimage.bif 55 ) 56 echo } >>bootimage.bif 57 ) 58 ::生成BOOT.bin 59 %cmdpath%bootgen -image bootimage.bif -o i BOOT.bin -w on 60 @echo BOOT.bin generated! 61 pause
涉及批處理的字符串處理的知識,不懂可以查閱相關知識;