diff --git a/blflash/src/chip/bl602/cfg/ro_params.dtb b/blflash/src/chip/bl602/cfg/ro_params.dtb new file mode 100644 index 0000000..1aeeacb Binary files /dev/null and b/blflash/src/chip/bl602/cfg/ro_params.dtb differ diff --git a/blflash/src/chip/bl602/mod.rs b/blflash/src/chip/bl602/mod.rs index be6abcd..2e703f3 100644 --- a/blflash/src/chip/bl602/mod.rs +++ b/blflash/src/chip/bl602/mod.rs @@ -4,6 +4,7 @@ use deku::prelude::*; pub const DEFAULT_PARTITION_CFG: &'static [u8] = include_bytes!("cfg/partition_cfg_2M.toml"); pub const DEFAULT_BOOTHEADER_CFG: &'static [u8] = include_bytes!("cfg/efuse_bootheader_cfg.conf"); +pub const RO_PARAMS: &'static [u8] = include_bytes!("cfg/ro_params.dtb"); pub const BLSP_BOOT2: &'static [u8] = include_bytes!("image/blsp_boot2.bin"); pub const EFLASH_LOADER: &'static [u8] = include_bytes!("image/eflash_loader_40m.bin"); const ROM_START: u32 = 0x23000000; @@ -28,17 +29,17 @@ impl Bl602 { let boot2image = bootheader_cfg.make_image(0x2000, Vec::from(BLSP_BOOT2))?; let fw_image = bootheader_cfg.make_image(0x1000, Vec::from(bin))?; - log::trace!("{}", hex::encode(&boot2image[0..200])); - let _segments = vec![ + let segments = vec![ RomSegment::from_vec(0x0, boot2image), RomSegment::from_vec(0xe000, partition_cfg.clone()), RomSegment::from_vec(0xf000, partition_cfg), - RomSegment::from_vec(0x10000, fw_image.clone()), - // FlashSegment::from_slice(0x1f8000, &d), + RomSegment::from_vec(0x10000, fw_image), + // TODO: generate from dts + RomSegment::from_slice(0x1f8000, RO_PARAMS), ]; - todo!() + Ok(segments) } } diff --git a/blflash/src/elf.rs b/blflash/src/elf.rs index aed5205..4fba5d3 100644 --- a/blflash/src/elf.rs +++ b/blflash/src/elf.rs @@ -96,6 +96,12 @@ impl<'a> RomSegment<'a> { data: Cow::Owned(data), } } + pub fn from_slice(addr: u32, data: &'a [u8]) -> RomSegment<'a> { + RomSegment { + addr, + data: Cow::Borrowed(data), + } + } pub fn from_code_segment(addr: u32, code_segment: CodeSegment<'a>) -> RomSegment<'a> { Self { diff --git a/blflash/src/main.rs b/blflash/src/main.rs index d80f791..9516d29 100644 --- a/blflash/src/main.rs +++ b/blflash/src/main.rs @@ -16,8 +16,10 @@ struct FlashOpt { #[structopt(parse(from_os_str))] image: PathBuf, /// Path to partition_cfg.toml, default to be partition/partition_cfg_2M.toml + #[structopt(parse(from_os_str))] partition_cfg: Option, /// Path to efuse_bootheader_cfg.conf + #[structopt(parse(from_os_str))] boot_header_cfg: Option, /// With boot2 #[structopt(short, long)]