Skip to content

Commit

Permalink
Support dropping named partitions in hardware configs (#2934)
Browse files Browse the repository at this point in the history
This PR adds the ability to 'drop' a previously defined partition from a hardware configuration by setting `"size": 0` in an inherited config. This is silently ignored if the partition is undefined.

Issue #2933 highlighted the need to be able to eliminate the `factory` partition and use OTA partitions instead. 

A couple of sample applications contained redundant `subtype` overrides since these are already defined in `spiffs-two-roms`, so this has been tidied.

Note: Typically the Esp32 `spiffs-two-roms` configuration is used as a base for OTA updates. This retains the `factory` partition so if not required this can be dropped to liberate the 1M allocation.
  • Loading branch information
mikee47 authored Jan 13, 2025
1 parent e31ee0b commit 8a2addf
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
6 changes: 6 additions & 0 deletions Sming/Components/Storage/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,18 @@ To customise the hardware configuration for a project, for example 'my_project':
"rom0": {
"address": "0x10000",
"size": "0x80000"
},
"factory": {
"size": 0
}
}
}
This will adjust flash parameters (previously via SPI_SPEED, SPI_MODE and SPI_SIZE),
and the location/size of the primary application partition.
The **factory** partition is also dropped by setting its size to 0.
This is ignored if no such partition is defined.


3. Add any additional partitions:

Expand Down
5 changes: 5 additions & 0 deletions Sming/Components/Storage/Tools/hwconfig/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ def parse_dict(self, data, devices):
raise InputError("Duplicate partition '%s'" % name)
partnames += name
part = self.find_by_name(name)
# Setting size=0 drops partition if it exists
if entry.get('size') == 0:
if part:
self.remove(part)
continue
if part is None:
part = Entry(devices[0], name)
self.append(part)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ COMPONENT_DEPENDS := OtaUpgradeMqtt
RBOOT_ENABLED := 1

## Use standard hardware config with two ROM slots and two SPIFFS partitions
HWCONFIG := ota
HWCONFIG := spiffs-two-roms

APP_CFLAGS = -DMQTT_URL="\"$(MQTT_URL)"\" \
-DMQTT_FINGERPRINT_SHA1=$(MQTT_FINGERPRINT_SHA1) \
Expand Down
11 changes: 0 additions & 11 deletions Sming/Libraries/OtaUpgradeMqtt/samples/Upgrade/ota.hw

This file was deleted.

6 changes: 0 additions & 6 deletions samples/Basic_Ota/ota.hw
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
"name": "Basic OTA sample",
"base_config": "spiffs-two-roms",
"partitions": {
"rom0": {
"subtype": "ota_0"
},
"rom1": {
"subtype": "ota_1"
},
"spiffs0": {
"size": "512K"
},
Expand Down

0 comments on commit 8a2addf

Please sign in to comment.