1 Star 0 Fork 10

马氏天下/010 Editor 脚本

forked from RustSBI/010 Editor 模板 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
BL808Image.bt 9.74 KB
一键复制 编辑 原始数据 按行查看 历史
//------------------------------------------------
//--- 010 Editor v12.0.1 Binary Template
//
// File: bl-flash
// Authors: Zhouqi Jiang
// Version: 0.0.0
// Purpose:
// Category:
// File Mask:
// ID Bytes:
// History:
//------------------------------------------------
RequiresVersion( 12 );
/**** STRUCTURES ****/
struct HAL_BOOTHEADER;
struct HAL_FLASH_CONFIG;
struct SPI_FLASH_CFG_TYPE;
struct HAL_PLL_CONFIG;
struct HAL_SYS_CLK_CONFIG;
struct HAL_BASIC_CONFIG;
struct HAL_CPU_CFG;
struct HAL_PATCH_CFG;
typedef struct {
uint32 magic <format=hex>;
uint32 revision;
HAL_FLASH_CONFIG flashCfg;
HAL_PLL_CONFIG clkCfg;
HAL_BASIC_CONFIG basicCfg;
HAL_CPU_CFG cpuCfg[3];
uint32 boot2_pt_table_0 <comment="address of partition table 0">;
uint32 boot2_pt_table_1 <comment="address of partition table 1">;
uint32 flashCfgTableAddr <format=hex,comment="address of flashcfg table list">;
uint32 flashCfgTableLen <format=hex,comment="flashcfg table list len">;
local quad off = FTell();
if(flashCfgTableAddr < FileSize() && flashCfgTableAddr + flashCfgTableLen <= FileSize()) {
FSeek(flashCfgTableAddr);
ubyte flashCfgTable[flashCfgTableLen] <comment="flashCfgTable",bgcolor=cPurple>;
} else {
Warning("flashCfgTable appears to either overlap with header, exist after the end of the file or overlap with the end of the file!");
}
FSeek(off);
HAL_PATCH_CFG patch_on_read[4] <comment="do patch when read flash">;
HAL_PATCH_CFG patch_on_jump[4] <comment="do patch when jump">;
uint32 reserved[5];
uint32 crc32 <format=hex>;
} HAL_BOOTHEADER;
typedef struct {
uint32 magic <format=hex>;
SPI_FLASH_CFG_TYPE cfg;
uint32 crc32 <format=hex>;
} HAL_FLASH_CONFIG;
// source: bouffalo boot2 project
typedef struct {
ubyte ioMode <comment="Serail flash uint32erface mode,bit0-3:IF mode,bit4:unwrap,bit5:32-bits addr mode support">;
ubyte cReadSupport <comment="Support continuous read mode,bit0:continuous read mode support,bit1:read mode cfg">;
ubyte clkDelay <comment="SPI clock delay,bit0-3:delay,bit4-6:pad delay">;
ubyte clkInvert <comment="SPI clock phase invert,bit0:clck invert,bit1:rx invert,bit2-4:pad delay,bit5-7:pad delay">;
ubyte resetEnCmd <comment="Flash enable reset command">;
ubyte resetCmd <comment="Flash reset command">;
ubyte resetCreadCmd <comment="Flash reset continuous read command">;
ubyte resetCreadCmdSize <comment="Flash reset continuous read command size">;
ubyte jedecIdCmd <comment="JEDEC ID command">;
ubyte jedecIdCmdDmyClk <comment="JEDEC ID command dummy clock">;
ubyte enter32BitsAddrCmd <comment="Enter 32-bits addr command">;
ubyte exit32BitsAddrCmd <comment="Exit 32-bits addr command">;
ubyte sectorSize <comment="*1024bytes">;
ubyte mid <comment="Manufacturer ID">;
uint16 pageSize <comment="Page size">;
ubyte chipEraseCmd <comment="Chip erase cmd">;
ubyte sectorEraseCmd <comment="Sector erase command">;
ubyte blk32EraseCmd <comment="Block 32K erase command,some Micron not support">;
ubyte blk64EraseCmd <comment="Block 64K erase command">;
ubyte writeEnableCmd <comment="Need before every erase or program">;
ubyte pageProgramCmd <comment="Page program cmd">;
ubyte qpageProgramCmd <comment="QIO page program cmd">;
ubyte qppAddrMode <comment="QIO page program address mode">;
ubyte fastReadCmd <comment="Fast read command">;
ubyte frDmyClk <comment="Fast read command dummy clock">;
ubyte qpiFastReadCmd <comment="QPI fast read command">;
ubyte qpiFrDmyClk <comment="QPI fast read command dummy clock">;
ubyte fastReadDoCmd <comment="Fast read dual output command">;
ubyte frDoDmyClk <comment="Fast read dual output command dummy clock">;
ubyte fastReadDioCmd <comment="Fast read dual io comamnd">;
ubyte frDioDmyClk <comment="Fast read dual io command dummy clock">;
ubyte fastReadQoCmd <comment="Fast read quad output comamnd">;
ubyte frQoDmyClk <comment="Fast read quad output comamnd dummy clock">;
ubyte fastReadQioCmd <comment="Fast read quad io comamnd">;
ubyte frQioDmyClk <comment="Fast read quad io comamnd dummy clock">;
ubyte qpiFastReadQioCmd <comment="QPI fast read quad io comamnd">;
ubyte qpiFrQioDmyClk <comment="QPI fast read QIO dummy clock">;
ubyte qpiPageProgramCmd <comment="QPI program command">;
ubyte writeVregEnableCmd <comment="Enable write reg">;
ubyte wrEnableIndex <comment="Write enable register index">;
ubyte qeIndex <comment="Quad mode enable register index">;
ubyte busyIndex <comment="Busy status register index">;
ubyte wrEnableBit <comment="Write enable bit pos">;
ubyte qeBit <comment="Quad enable bit pos">;
ubyte busyBit <comment="Busy status bit pos">;
ubyte wrEnableWriteRegLen <comment="Register length of write enable">;
ubyte wrEnableReadRegLen <comment="Register length of write enable status">;
ubyte qeWriteRegLen <comment="Register length of contain quad enable">;
ubyte qeReadRegLen <comment="Register length of contain quad enable status">;
ubyte releasePowerDown <comment="Release power down command">;
ubyte busyReadRegLen <comment="Register length of contain busy status">;
ubyte readRegCmd[4] <comment="Read register command buffer">;
ubyte writeRegCmd[4] <comment="Write register command buffer">;
ubyte enterQpi <comment="Enter qpi command">;
ubyte exitQpi <comment="Exit qpi command">;
ubyte cReadMode <comment="Config data for continuous read mode">;
ubyte cRExit <comment="Config data for exit continuous read mode">;
ubyte burstWrapCmd <comment="Enable burst wrap command">;
ubyte burstWrapCmdDmyClk <comment="Enable burst wrap command dummy clock">;
ubyte burstWrapDataMode <comment="Data and address mode for this command">;
ubyte burstWrapData <comment="Data to enable burst wrap">;
ubyte deBurstWrapCmd <comment="Disable burst wrap command">;
ubyte deBurstWrapCmdDmyClk <comment="Disable burst wrap command dummy clock">;
ubyte deBurstWrapDataMode <comment="Data and address mode for this command">;
ubyte deBurstWrapData <comment="Data to disable burst wrap">;
uint16 timeEsector <comment="4K erase time">;
uint16 timeE32k <comment="32K erase time">;
uint16 timeE64k <comment="64K erase time">;
uint16 timePagePgm <comment="Page program time">;
uint16 timeCe <comment="Chip erase time in ms">;
ubyte pdDelay <comment="Release power down command delay time for wake up">;
ubyte qeData <comment="QE set data">;
} SPI_FLASH_CFG_TYPE;
typedef struct {
uint32 magic <format=hex>;
HAL_SYS_CLK_CONFIG cfg;
uint32 crc32 <format=hex>;
} HAL_PLL_CONFIG;
typedef struct {
ubyte xtal_type;
ubyte mcu_clk;
ubyte mcu_clk_div;
ubyte mcu_bclk_div;
ubyte mcu_pbclk_div;
ubyte lp_div;
ubyte dsp_clk;
ubyte dsp_clk_div;
ubyte dsp_bclk_div;
ubyte dsp_pbclk;
ubyte dsp_pbclk_div;
ubyte emi_clk;
ubyte emi_clk_div;
ubyte flash_clk_type;
ubyte flash_clk_div;
ubyte wifipll_pu;
ubyte aupll_pu;
ubyte cpupll_pu;
ubyte mipipll_pu;
ubyte uhspll_pu;
} HAL_SYS_CLK_CONFIG;
typedef struct {
uint32 sign_type : 2 <comment="for sign">; uint32 encrypt_type : 2 <comment="for encrypt">; uint32 key_sel : 2 <comment="key slot">; uint32 xts_mode : 1 <comment="for xts mode">; uint32 aes_region_lock : 1 <comment="rsvd">; uint32 no_segment : 1 <comment="no segment info">; uint32 boot2_enable : 1 <comment="boot2 enable">; uint32 boot2_rollback : 1 <comment="boot2 rollback">; uint32 cpu_master_id : 4 <comment="master id">; uint32 notload_in_bootrom : 1 <comment="notload in bootrom">; uint32 crc_ignore : 1 <comment="ignore crc">; uint32 hash_ignore : 1 <comment="hash ignore">; uint32 power_on_mm : 1 <comment="power on mm">; uint32 em_sel : 3 <comment="em_sel">; uint32 cmds_en : 1 <comment="command spliter enable">; uint32 cmds_wrap_mode : 2 <comment="cmds wrap mode">; uint32 cmds_wrap_len : 4 <comment="cmds wrap len">; uint32 icache_invalid : 1 <comment="icache invalid">; uint32 dcache_invalid : 1 <comment="dcache invalid">; uint32 fpga_halt_release : 1 <comment="FPGA halt release function">;
uint32 group_image_offset <format=hex,comment="flash controller offset">;
uint32 aes_region_len <comment="aes region length">;
uint32 img_len_cnt <comment="image length or segment count">;
uint32 hash[8] <comment="hash of the image">;
local quad off = FTell();
if(img_len_cnt < FileSize() && img_len_cnt + group_image_offset <= FileSize()) {
FSeek(group_image_offset);
ubyte image[img_len_cnt] <comment="Segment data">;
} else {
Warning("Segment data appears to either overlap with header, exist after the end of the file or overlap with the end of the file!");
}
FSeek(off);
} HAL_BASIC_CONFIG;
typedef struct {
ubyte config_enable <comment="config this cpu">;
ubyte halt_cpu <comment="halt this cpu">;
ubyte cache_flags <comment="cache setting">;
ubyte rsvd;
uint32 cache_range_h <comment="cache range high">;
uint32 cache_range_l <comment="cache range low">;
uint32 image_address_offset <format=hex,comment="image address on flash">;
uint32 boot_entry <format=hex,comment="entry point of the m0 image">;
uint32 msp_val <comment="msp value">;
} HAL_CPU_CFG;
typedef struct {
uint32 addr <format=hex>;
uint32 value <format=hex>;
} HAL_PATCH_CFG;
/**** PARSING CODE ****/
LittleEndian();
HAL_BOOTHEADER BootHeader <bgcolor=cLtPurple>;
if (BootHeader.magic != 0x504e4642)
{
Printf("Invalid Magic.\n");
return 1;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mashitianxia/010-editor-scripts.git
git@gitee.com:mashitianxia/010-editor-scripts.git
mashitianxia
010-editor-scripts
010 Editor 脚本
main

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385