Skip to content

Commit bfba9a0

Browse files
committed
Also write nvs and phy_init partitions for the basic part table
1 parent 13dfa1c commit bfba9a0

File tree

3 files changed

+61
-11
lines changed

3 files changed

+61
-11
lines changed

espflash/src/chip/esp32.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ const DROM_MAP_END: u32 = 0x3F800000;
2424

2525
const BOOT_ADDR: u32 = 0x1000;
2626
const PARTION_ADDR: u32 = 0x8000;
27+
const NVS_ADDR: u32 = 0x9000;
28+
const PHY_INIT_DATA_ADDR: u32 = 0xf000;
2729
const APP_ADDR: u32 = 0x10000;
2830

31+
const NVS_SIZE: u32 = 0x6000;
32+
const PHY_INIT_DATA_SIZE: u32 = 0x1000;
33+
const APP_SIZE: u32 = 0x3f0000;
34+
2935
impl ChipType for Esp32 {
3036
const CHIP_DETECT_MAGIC_VALUE: u32 = 0x00f01d83;
3137

@@ -49,7 +55,14 @@ impl ChipType for Esp32 {
4955
) -> Box<dyn Iterator<Item = Result<RomSegment<'a>, Error>> + 'a> {
5056
let bootloader = include_bytes!("../../bootloader/esp32-bootloader.bin");
5157

52-
let partition_table = PartitionTable::basic(0x10000, 0x3f0000).to_bytes();
58+
let partition_table = PartitionTable::basic(
59+
NVS_ADDR,
60+
NVS_SIZE,
61+
PHY_INIT_DATA_ADDR,
62+
PHY_INIT_DATA_SIZE,
63+
APP_ADDR,
64+
APP_SIZE,
65+
);
5366

5467
fn get_data<'a>(image: &'a FirmwareImage) -> Result<RomSegment<'a>, Error> {
5568
let mut data = Vec::new();

espflash/src/chip/esp32c3.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ const DROM_MAP_END: u32 = 0x3c800000;
2424

2525
const BOOT_ADDR: u32 = 0x0;
2626
const PARTITION_ADDR: u32 = 0x8000;
27+
const NVS_ADDR: u32 = 0x9000;
28+
const PHY_INIT_DATA_ADDR: u32 = 0xf000;
2729
const APP_ADDR: u32 = 0x10000;
2830

31+
const NVS_SIZE: u32 = 0x6000;
32+
const PHY_INIT_DATA_SIZE: u32 = 0x1000;
33+
const APP_SIZE: u32 = 0x3f0000;
34+
2935
impl ChipType for Esp32c3 {
3036
const CHIP_DETECT_MAGIC_VALUE: u32 = 0x6921506f;
3137
const CHIP_DETECT_MAGIC_VALUE2: u32 = 0x1b31506f;
@@ -50,7 +56,15 @@ impl ChipType for Esp32c3 {
5056
) -> Box<dyn Iterator<Item = Result<RomSegment<'a>, Error>> + 'a> {
5157
let bootloader = include_bytes!("../../bootloader/esp32c3-bootloader.bin");
5258

53-
let partition_table = PartitionTable::basic(0x10000, 0x3f0000).to_bytes();
59+
let partition_table = PartitionTable::basic(
60+
NVS_ADDR,
61+
NVS_SIZE,
62+
PHY_INIT_DATA_ADDR,
63+
PHY_INIT_DATA_SIZE,
64+
APP_ADDR,
65+
APP_SIZE,
66+
)
67+
.to_bytes();
5468

5569
fn get_data<'a>(image: &'a FirmwareImage) -> Result<RomSegment<'a>, Error> {
5670
let mut data = Vec::new();

espflash/src/partition_table.rs

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,39 @@ pub struct PartitionTable {
7272
}
7373

7474
impl PartitionTable {
75-
/// Create a basic partition table with a single app entry
76-
pub fn basic(app_offset: u32, app_size: u32) -> Self {
75+
/// Create a basic partition table with NVS, PHY init data, and the app partition
76+
pub fn basic(
77+
nvs_offset: u32,
78+
nvs_size: u32,
79+
phy_init_data_offset: u32,
80+
phy_init_data_size: u32,
81+
app_offset: u32,
82+
app_size: u32,
83+
) -> Self {
7784
PartitionTable {
78-
partitions: vec![Partition::new(
79-
String::from("factory"),
80-
SubType::App(AppType::Factory),
81-
app_offset,
82-
app_size,
83-
0,
84-
)],
85+
partitions: vec![
86+
Partition::new(
87+
String::from("nvs"),
88+
SubType::Data(DataType::Nvs),
89+
nvs_offset,
90+
nvs_size,
91+
0,
92+
),
93+
Partition::new(
94+
String::from("phy_init"),
95+
SubType::Data(DataType::Phy),
96+
phy_init_data_offset,
97+
phy_init_data_size,
98+
0,
99+
),
100+
Partition::new(
101+
String::from("factory"),
102+
SubType::App(AppType::Factory),
103+
app_offset,
104+
app_size,
105+
0,
106+
),
107+
],
85108
}
86109
}
87110

0 commit comments

Comments
 (0)