Skip to content

Commit

Permalink
Require separate partition for RF calibration
Browse files Browse the repository at this point in the history
Ordering is different so use a dedicated partition for RF calibration
Keeping partition table at 0x10000 for 4M devices is dodgy because SPIFFS could be there.
So put it at end of flash in sector before PHY init.

NOTE: Changes partition layout so anyone using current develop branch will need to re-build and re-flash.
  • Loading branch information
mikee47 committed Mar 13, 2021
1 parent 93c7a48 commit 787a900
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 23 deletions.
13 changes: 5 additions & 8 deletions Sming/Arch/Esp8266/Components/esp8266/startup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ extern "C" void WEAK_ATTR user_rf_pre_init(void)

extern "C" uint32 ICACHE_FLASH_ATTR WEAK_ATTR user_rf_cal_sector_set(void)
{
// RF calibration stored in last sector of sysParam
auto sysParam = *Storage::findPartition(Storage::Partition::SubType::Data::sysParam);
return ((sysParam.address() + sysParam.size()) / SPI_FLASH_SEC_SIZE) - 1;
auto rfCal = *Storage::findPartition(Storage::Partition::SubType::Data::rfCal);
return rfCal.address();
}

#ifdef SDK_INTERNAL
Expand All @@ -71,16 +70,14 @@ extern "C" void ICACHE_FLASH_ATTR WEAK_ATTR user_pre_init(void)
Storage::initialize();

auto sysParam = *Storage::findPartition(Storage::Partition::SubType::Data::sysParam);
auto rfCal = *Storage::findPartition(Storage::Partition::SubType::Data::rfCal);
auto phy = *Storage::findPartition(Storage::Partition::SubType::Data::phy);

// RF calibration stored in last sector of sysParam
auto sysParamSize = sysParam.size() - SPI_FLASH_SEC_SIZE;

static const partition_item_t partitions[] = {
{SYSTEM_PARTITION_BOOTLOADER, 0, SPI_FLASH_SEC_SIZE},
{SYSTEM_PARTITION_PHY_DATA, phy.address(), phy.size()},
{SYSTEM_PARTITION_SYSTEM_PARAMETER, sysParam.address(), sysParamSize},
{SYSTEM_PARTITION_RF_CAL, sysParam.address() + sysParamSize, SPI_FLASH_SEC_SIZE},
{SYSTEM_PARTITION_SYSTEM_PARAMETER, sysParam.address(), sysParam.size()},
{SYSTEM_PARTITION_RF_CAL, rfCal.address(), rfCal.size()},
};

enum flash_size_map sizeMap = system_get_flash_size_map();
Expand Down
9 changes: 6 additions & 3 deletions Sming/Arch/Esp8266/legacy/standard-4m.hw
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
{
"name": "Standard config with 4M flash (LEGACY)",
"base_config": "standard-4m",
"partition_table_offset": "0x100000",
"partition_table_offset": "0x3FA000",
"partitions": {
"rom0": {
"address": "0x2000",
"size": "1016K"
},
"phy_init": {
"rf_cal": {
"address": "0x3FB000"
},
"sys_param": {
"phy_init": {
"address": "0x3FC000"
},
"sys_param": {
"address": "0x3FD000"
}
}
}
7 changes: 5 additions & 2 deletions Sming/Arch/Esp8266/legacy/standard.hw
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
"address": "0x2000",
"size": "0x0F8000"
},
"phy_init": {
"rf_cal": {
"address": "0x0FB000"
},
"sys_param": {
"phy_init": {
"address": "0x0FC000"
},
"sys_param": {
"address": "0x0FD000"
}
}
}
15 changes: 6 additions & 9 deletions Sming/Arch/Esp8266/legacy/two-rom-mode.hw
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
{
"name": "Two ROM slots in 1MB of flash (LEGACY)",
"base_config": "two-rom-mode",
"partition_table_offset": "0x0FA000",
"base_config": "legacy/standard",
"partitions": {
"rom0": {
"subtype": "ota_0",
"address": "0x2000",
"size": "504K"
},
"rom1": {
"address": "0x80000",
"size": "488K"
},
"phy_init": {
"address": "0x0FB000"
},
"sys_param": {
"address": "0x0FC000"
"size": "488K",
"type": "app",
"subtype": "ota_1",
"filename": "$(RBOOT_ROM_1_BIN)"
}
}
}
8 changes: 7 additions & 1 deletion Sming/Arch/Esp8266/standard.hw
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@
},
"sys_param": {
"address": "0x004000",
"size": "16K",
"size": "12K",
"type": "data",
"subtype": "sysparam"
},
"rf_cal": {
"address": "0x007000",
"size": "4K",
"type": "data",
"subtype": "rfcal"
},
"rom0": {
"address": "0x008000",
"size": "992K",
Expand Down
1 change: 1 addition & 0 deletions Sming/Components/Storage/Tools/hwconfig/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"nvs_keys": 0x04,
"efuse": 0x05,
"sysparam": 0x40,
"rfcal": 0x41,
"esphttpd": 0x80,
"fat": 0x81,
"spiffs": 0x82,
Expand Down
1 change: 1 addition & 0 deletions Sming/Components/Storage/src/include/Storage/Partition.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
XX(nvsKeys, 0x04, "NVS key information") \
XX(eFuseEm, 0x05, "eFuse emulation") \
XX(sysParam, 0x40, "System Parameters") \
XX(rfCal, 0x41, "RF Calibration") \
XX(espHttpd, 0x80, "ESPHTTPD") \
XX(fat, 0x81, "FAT") \
XX(spiffs, 0x82, "SPIFFS") \
Expand Down

0 comments on commit 787a900

Please sign in to comment.