feat: add dtb options

This commit is contained in:
spacemeowx2 2021-01-01 01:34:22 +08:00
parent 01c87972b5
commit 405ff37827
3 changed files with 13 additions and 4 deletions

View File

@ -43,6 +43,7 @@ impl Chip for Bl602 {
&self,
mut partition_cfg: PartitionCfg,
mut bootheader_cfg: BootHeaderCfg,
ro_params: Vec<u8>,
bin: &[u8],
) -> Result<Vec<RomSegment>, Error> {
partition_cfg.update()?;
@ -57,7 +58,7 @@ impl Chip for Bl602 {
RomSegment::from_vec(0xf000, partition_cfg),
RomSegment::from_vec(0x10000, fw_image),
// TODO: generate from dts
RomSegment::from_slice(0x1f8000, RO_PARAMS),
RomSegment::from_vec(0x1f8000, ro_params),
];
Ok(segments)

View File

@ -11,6 +11,7 @@ pub trait Chip {
&self,
partition_cfg: PartitionCfg,
bootheader_cfg: BootHeaderCfg,
ro_params: Vec<u8>,
bin: &[u8],
) -> Result<Vec<RomSegment>, Error>;
}

View File

@ -33,11 +33,14 @@ struct Connection {
#[derive(StructOpt)]
struct Boot2Opt {
/// Path to partition_cfg.toml, default to be partition/partition_cfg_2M.toml
#[structopt(parse(from_os_str))]
#[structopt(long, parse(from_os_str))]
partition_cfg: Option<PathBuf>,
/// Path to efuse_bootheader_cfg.conf
#[structopt(parse(from_os_str))]
#[structopt(long, parse(from_os_str))]
boot_header_cfg: Option<PathBuf>,
/// Path to ro_params.dtb
#[structopt(long, parse(from_os_str))]
dtb: Option<PathBuf>,
/// Without boot2
#[structopt(short, long)]
without_boot2: bool,
@ -132,8 +135,12 @@ impl Boot2Opt {
.unwrap_or_else(|| Ok(bl602::DEFAULT_BOOTHEADER_CFG.to_vec()))?;
let partition_cfg = toml::from_slice(&partition_cfg)?;
let BootHeaderCfgFile { boot_header_cfg } = toml::from_slice(&boot_header_cfg)?;
let ro_params = self
.dtb
.map(read)
.unwrap_or_else(|| Ok(bl602::RO_PARAMS.to_vec()))?;
let segments = chip.with_boot2(partition_cfg, boot_header_cfg, image)?;
let segments = chip.with_boot2(partition_cfg, boot_header_cfg, ro_params, image)?;
Ok(segments)
}