Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partition tables #2171

Merged
merged 36 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
89af8c7
More CString methods
mikee47 Jan 3, 2021
418b99f
Add gen_esp32part.py from ESP-IDF
mikee47 Feb 6, 2020
408adbd
Fix gen_esp32part alignment handling
mikee47 Dec 3, 2020
e8f40e0
Rename gen_esp32part.py to hwconfig.py
mikee47 Dec 4, 2020
6c8e95b
Implement JSON parsing and construction
mikee47 Dec 2, 2020
61342fa
Move hwconfig into folder
mikee47 Dec 5, 2020
1bd8b73
Split hwconfig into separate units, refactor/revise
mikee47 Dec 5, 2020
245abf3
Fix parse_int() function
mikee47 Dec 6, 2020
ebe1821
Add optional tag override for PrintVariables, PrintVariableSorted and…
mikee47 Feb 4, 2021
e3f5943
Implement Partition API
mikee47 Dec 8, 2020
1d3eeaa
Use Partition API for rBoot, esp8266 startup code and SPIFFS
mikee47 Dec 8, 2020
a92f1ba
Add Storage module to HostTests
mikee47 Dec 2, 2020
f19b5b6
Fix duplicate code in Basic_rBoot
mikee47 Dec 6, 2020
d3ef89a
Update rBoot
mikee47 Dec 18, 2020
a2e1a45
Update Basic_rBoot
mikee47 Dec 7, 2020
d1fdcc7
Handle all flashing via partitions
mikee47 Dec 6, 2020
6a07e9c
Update samples
mikee47 Dec 8, 2020
b148698
Fix compiler warning in ArduCAM library
mikee47 Feb 3, 2021
e1adf68
Add Basic_Storage sample
mikee47 Jan 23, 2021
b875682
Update docs
mikee47 Jan 1, 2021
2e84b9c
Fix CI & CodeQL
mikee47 Feb 4, 2021
7e70932
Tidy up Storage component.mk, fix issue with flashing where chunk fil…
mikee47 Feb 5, 2021
f50479b
Remove `DISABLE_SPIFFS`
mikee47 Feb 5, 2021
39a175f
Fix SPI_SIZE handling
mikee47 Feb 5, 2021
7fdf16a
Remove DISABLE_SPIFFS, SPI_SIZE and SPIFF_SIZE settings from submodules
mikee47 Feb 5, 2021
eab5886
Add `component-samples` build target, execute from ESP8266 CI build
mikee47 Feb 5, 2021
11933b1
Add tests from components
mikee47 Feb 6, 2021
3d63abb
Remove redundant `python-requirements` calls from CI script
mikee47 Feb 6, 2021
8ea9c0c
Replace 'flags' with separate `readonly` and `encrypted` properties
mikee47 Feb 6, 2021
9e276cc
Fix 'config not found' error during `make dist-clean`
mikee47 Feb 6, 2021
863e7ab
Fix network setup for WSL (ifconfig is old, prefer ip)
mikee47 Jan 28, 2021
4c4a200
Include partition table length in build variables
mikee47 Feb 7, 2021
a90dda0
Fix error message when `readmap` invoked against invalid file
mikee47 Feb 7, 2021
e24c22c
Update schema, `target` is required if partition `build` property def…
mikee47 Feb 7, 2021
6b4aeb1
Add sanity check on chunks before writing to flash, critically to ens…
mikee47 Feb 7, 2021
2e76211
Fix warnings when running `make dist-clean`
mikee47 Feb 7, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/install.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
REM Windows install script

python -m pip install --upgrade pip
python -m pip install --upgrade pip -r %SMING_HOME%\..\Tools\requirements.txt

rmdir /s /q c:\MinGW
curl -Lo MinGW.7z %SMINGTOOLS%/MinGW-2020-10-19.7z
Expand Down
2 changes: 1 addition & 1 deletion .ci/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -ex # exit with nonzero exit code if anything fails
sudo apt-get update

sudo update-alternatives --set gcc /usr/bin/gcc-9
python -m pip install --upgrade pip
python -m pip install --upgrade pip -r $SMING_HOME/../Tools/requirements.txt

sudo apt-get install -y gcc-9-multilib g++-9-multilib python3-setuptools

Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ jobs:
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
Expand Down Expand Up @@ -68,13 +63,14 @@ jobs:
run: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update -y
sudo apt-get install gcc-9-multilib g++-9-multilib
sudo apt-get install gcc-9-multilib g++-9-multilib python3-wheel python3-setuptools
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-9
python3 -m pip install --upgrade pip wheel -r Tools/requirements.txt
env
cd Sming
export SMING_HOME=$(pwd)
cd ../samples/Basic_Blink
make SMING_ARCH=Host
make -j3 SMING_ARCH=Host

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
5 changes: 0 additions & 5 deletions Sming/Arch/Esp32/Components/esp32/sdk/partitions/base.csv

This file was deleted.

2 changes: 2 additions & 0 deletions Sming/Arch/Esp32/Components/esp32/src/startup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <Platform/System.h>
#include <driver/hw_timer.h>
#include <driver/uart.h>
#include <Storage.h>

#ifndef ESP32_STACK_SIZE
#define ESP32_STACK_SIZE 16384U
Expand Down Expand Up @@ -63,6 +64,7 @@ void main(void*)
esp_init_flash();
esp_init_wifi();
ets_init_tasks();
Storage::initialize();
System.initialize();
init();

Expand Down
Empty file.
4 changes: 0 additions & 4 deletions Sming/Arch/Esp32/Components/esp_spiffs/README.rst

This file was deleted.

1 change: 0 additions & 1 deletion Sming/Arch/Esp32/Components/esp_spiffs/component.mk

This file was deleted.

37 changes: 0 additions & 37 deletions Sming/Arch/Esp32/Components/esp_spiffs/spiffs_config.c

This file was deleted.

1 change: 0 additions & 1 deletion Sming/Arch/Esp32/Components/sming-arch/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ COMPONENT_DEPENDS := \
driver \
heap \
fatfs \
esp_spiffs \
esp32 \
gdbstub \
esptool
Expand Down
49 changes: 0 additions & 49 deletions Sming/Arch/Esp32/app.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,52 +42,3 @@ $(TARGET_OUT): $(COMPONENTS_AR)

$(TARGET_BIN): $(TARGET_OUT)
$(Q) $(ESPTOOL_CMDLINE) elf2image --min-rev 0 --elf-sha256-offset 0xb0 $(flashimageoptions) -o $@ $<

##@Flashing

# Partitions
PARTITIONS_CSV ?= $(BUILD_BASE)/partitions.csv
PARTITIONS_BIN = $(FW_BASE)/partitions.bin

CUSTOM_TARGETS += $(PARTITIONS_CSV)

$(BUILD_BASE)/partitions.csv: | $(BUILD_BASE)
$(Q) cp $(SDK_PARTITION_PATH)/base.csv $@
@echo "storage, data, spiffs, $(SPIFF_START_ADDR), $(SPIFF_SIZE)," >> $@

$(PARTITIONS_BIN): $(PARTITIONS_CSV)
$(Q) $(ESP32_PYTHON) $(SDK_COMPONENTS_PATH)/partition_table/gen_esp32part.py $< $@

.PHONY: partitions
partitions: $(PARTITIONS_BIN) ##Generate partitions table


FLASH_PARTITION_CHUNKS := 0x8000=$(PARTITIONS_BIN)

# Application

FLASH_APP_CHUNKS := 0x10000=$(TARGET_BIN)

.PHONY: flashboot
flashboot: $(FLASH_BOOT_LOADER) ##Write just the Bootloader
$(call WriteFlash,$(FLASH_BOOT_CHUNKS))

.PHONY: flashconfig

flashconfig: partitions kill_term ##Write partition config
$(call WriteFlash,$(FLASH_PARTITION_CHUNKS))

flashpartition: flashconfig

.PHONY: flashapp
flashapp: all kill_term ##Write just the application image
$(call WriteFlash,$(FLASH_APP_CHUNKS))

.PHONY: flash
flash: all partitions kill_term ##Write the boot loader, application image, partition table and (if enabled) SPIFFS image
$(call WriteFlash,$(FLASH_BOOT_CHUNKS) $(FLASH_APP_CHUNKS) $(FLASH_PARTITION_CHUNKS) $(FLASH_SPIFFS_CHUNKS))
ifeq ($(ENABLE_GDB), 1)
$(GDB_CMDLINE)
else
$(TERMINAL)
endif
35 changes: 35 additions & 0 deletions Sming/Arch/Esp32/standard.hw
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "Standard config with single ROM",
"comment": "Should work with any Esp32 variant",
"arch": "Esp32",
"partition_table_offset": "0x8000",
"devices": {
"spiFlash": {
"type": "flash",
"size": "4M",
"mode": "dio",
"speed": 40
}
},
"partitions": {
"phy_init": {
"address": "0x00f000",
"size": "0x1000",
"type": "data",
"subtype": "phy"
},
"nvs": {
"address": "0x009000",
"size": "0x6000",
"type": "data",
"subtype": "nvs"
},
"factory": {
"address": "0x010000",
"size": "0x1f0000",
"type": "app",
"subtype": "factory",
"filename": "$(TARGET_BIN)"
}
}
}
5 changes: 0 additions & 5 deletions Sming/Arch/Esp8266/Components/esp8266/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ FLASH_INIT_DATA = $(SDK_BASE)/bin/esp_init_data_default.bin

CUSTOM_TARGETS += $(FLASH_INIT_DATA)

FLASH_INIT_CHUNKS += \
$(call FlashOffset,0x5000)=$(BLANK_BIN) \
$(call FlashOffset,0x4000)=$(FLASH_INIT_DATA) \
$(call FlashOffset,0x2000)=$(BLANK_BIN)

# => 'Internal' SDK - for SDK Version 3+ as submodule in Sming repository
# SDK_BASE just needs to point into our repo as it's overridden with the correct submodule path
# This provides backward-compatiblity, so $(SMING)/third-party/ESP8266_NONOS_SDK) still works
Expand Down
70 changes: 14 additions & 56 deletions Sming/Arch/Esp8266/Components/esp8266/startup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <driver/hw_timer.h>
#include <gdb/gdb_hooks.h>
#include <esp_cplusplus.h>
#include <Storage.h>

extern void init();

Expand Down Expand Up @@ -54,46 +55,9 @@ extern "C" void WEAK_ATTR user_rf_pre_init(void)

extern "C" uint32 ICACHE_FLASH_ATTR WEAK_ATTR user_rf_cal_sector_set(void)
{
enum flash_size_map size_map = system_get_flash_size_map();
uint32 rf_cal_sec = 0;

switch (int(size_map)) {
case FLASH_SIZE_2M:
rf_cal_sec = 64 - 5;
break;

case FLASH_SIZE_4M_MAP_256_256:
rf_cal_sec = 128 - 5;
break;

case FLASH_SIZE_8M_MAP_512_512:
rf_cal_sec = 256 - 5;
break;

case FLASH_SIZE_16M_MAP_512_512:
case FLASH_SIZE_16M_MAP_1024_1024:
rf_cal_sec = 512 - 5;
break;

case FLASH_SIZE_32M_MAP_512_512:
case FLASH_SIZE_32M_MAP_1024_1024:
rf_cal_sec = 1024 - 5;
break;

case 8: // FLASH_SIZE_64M_MAP_1024_1024
rf_cal_sec = 2048 - 5;
break;

case 9: // FLASH_SIZE_128M_MAP_1024_1024
rf_cal_sec = 4096 - 5;
break;

default:
rf_cal_sec = 0;
break;
}

return rf_cal_sec;
// 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;
}

#ifdef SDK_INTERNAL
Expand All @@ -104,25 +68,19 @@ extern "C" uint32 ICACHE_FLASH_ATTR WEAK_ATTR user_rf_cal_sector_set(void)

extern "C" void ICACHE_FLASH_ATTR WEAK_ATTR user_pre_init(void)
{
const uint32_t MAX_PROGRAM_SECTORS = 0x100000 / SPI_FLASH_SEC_SIZE; // 1MB addressable
Storage::initialize();

// WARNING: Sming supports SDK 3.0 with rBoot enabled apps ONLY!
const partition_type_t SYSTEM_PARTITION_RBOOT_CONFIG = static_cast<partition_type_t>(SYSTEM_PARTITION_CUSTOMER_BEGIN + 0);
const partition_type_t SYSTEM_PARTITION_PROGRAM = static_cast<partition_type_t>(SYSTEM_PARTITION_CUSTOMER_BEGIN + 1);
auto sysParam = *Storage::findPartition(Storage::Partition::SubType::Data::sysParam);
auto phy = *Storage::findPartition(Storage::Partition::SubType::Data::phy);

// Partitions offsets and sizes must be in sector multiples, so work in sectors
#define PARTITION_ITEM(_type, _start, _length) \
{_type, (_start) * SPI_FLASH_SEC_SIZE, (_length) * SPI_FLASH_SEC_SIZE}
// RF calibration stored in last sector of sysParam
auto sysParamSize = sysParam.size() - SPI_FLASH_SEC_SIZE;

// Partitions in position order
uint32_t rfCalSector = user_rf_cal_sector_set();
static const partition_item_t partitions[] = {
PARTITION_ITEM(SYSTEM_PARTITION_BOOTLOADER, 0, 1),
PARTITION_ITEM(SYSTEM_PARTITION_RBOOT_CONFIG, 1, 1),
PARTITION_ITEM(SYSTEM_PARTITION_PROGRAM, 2, std::min(MAX_PROGRAM_SECTORS, rfCalSector) - 2),
PARTITION_ITEM(SYSTEM_PARTITION_RF_CAL, rfCalSector, 1),
PARTITION_ITEM(SYSTEM_PARTITION_PHY_DATA, rfCalSector + 1, 1),
PARTITION_ITEM(SYSTEM_PARTITION_SYSTEM_PARAMETER, rfCalSector + 2, 3),
{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},
};

enum flash_size_map sizeMap = system_get_flash_size_map();
Expand All @@ -134,7 +92,7 @@ extern "C" void ICACHE_FLASH_ATTR WEAK_ATTR user_pre_init(void)
os_printf("partition[%u]: %u, 0x%08x, 0x%08x\n", i, part.type, part.addr, part.size);
}
if(sizeMap < FLASH_SIZE_8M_MAP_512_512) {
os_printf("** Note: SDK 3.0.1 requires SPI_SIZE >= 1M\n");
os_printf("** Note: SDK 3.0.1 requires spiFlash size >= 1M\n");
}
while(1) {
// Cannot proceed
Expand Down
6 changes: 5 additions & 1 deletion Sming/Arch/Esp8266/Tools/ci/build.run.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Esp8266 build.run.sh

make -C "$SMING_PROJECTS_DIR/samples/HttpServer_FirmwareUpload" python-requirements
$MAKE_PARALLEL samples
make clean samples-clean
$MAKE_PARALLEL Basic_Blink ENABLE_CUSTOM_HEAP=1 DEBUG_VERBOSE_LEVEL=3
$MAKE_PARALLEL HttpServer_ConfigNetwork ENABLE_CUSTOM_LWIP=2 STRICT=1

# Some samples (UPnP, for example) require more recent compiler
if [ "$BUILD_COMPILER" == "eqt" ]; then
$MAKE_PARALLEL component-samples
fi
17 changes: 0 additions & 17 deletions Sming/Arch/Esp8266/app.mk
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,7 @@ $(TARGET_OUT_1): $(COMPONENTS_AR) $(LIBMAIN_DST)

##@Flashing

.PHONY: flashboot
flashboot: $(RBOOT_BIN) ##Write just the rBoot boot sector
$(call WriteFlash,$(FLASH_RBOOT_BOOT_CHUNKS))

.PHONY: flashconfig
flashconfig: kill_term ##Erase the rBoot config sector
$(info Erasing rBoot config sector)
$(call WriteFlash,$(FLASH_RBOOT_ERASE_CONFIG_CHUNKS))

.PHONY: flashapp
flashapp: all kill_term ##Write just the application image
$(call WriteFlash,$(FLASH_RBOOT_APP_CHUNKS))

.PHONY: flash
flash: all kill_term ##Write the rBoot boot sector, application image and (if enabled) SPIFFS image
$(call WriteFlash,$(FLASH_RBOOT_BOOT_CHUNKS) $(FLASH_RBOOT_APP_CHUNKS) $(FLASH_SPIFFS_CHUNKS))
ifeq ($(ENABLE_GDB), 1)
$(GDB_CMDLINE)
else
$(TERMINAL)
endif
13 changes: 13 additions & 0 deletions Sming/Arch/Esp8266/spiffs-two-roms.hw
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "Two ROM slots with single SPIFFS",
"base_config": "spiffs",
"partitions": {
"rom1": {
"address": "0x108000",
"size": "992K",
"type": "app",
"subtype": "ota_0",
"filename": "$(RBOOT_ROM_1_BIN)"
}
}
}
Loading