Skip to content

Commit 8a2addf

Browse files
authored
Support dropping named partitions in hardware configs (#2934)
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.
1 parent e31ee0b commit 8a2addf

File tree

5 files changed

+12
-18
lines changed

5 files changed

+12
-18
lines changed

Sming/Components/Storage/README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,18 @@ To customise the hardware configuration for a project, for example 'my_project':
133133
"rom0": {
134134
"address": "0x10000",
135135
"size": "0x80000"
136+
},
137+
"factory": {
138+
"size": 0
136139
}
137140
}
138141
}
139142
140143
This will adjust flash parameters (previously via SPI_SPEED, SPI_MODE and SPI_SIZE),
141144
and the location/size of the primary application partition.
145+
The **factory** partition is also dropped by setting its size to 0.
146+
This is ignored if no such partition is defined.
147+
142148

143149
3. Add any additional partitions:
144150

Sming/Components/Storage/Tools/hwconfig/partition.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ def parse_dict(self, data, devices):
143143
raise InputError("Duplicate partition '%s'" % name)
144144
partnames += name
145145
part = self.find_by_name(name)
146+
# Setting size=0 drops partition if it exists
147+
if entry.get('size') == 0:
148+
if part:
149+
self.remove(part)
150+
continue
146151
if part is None:
147152
part = Entry(devices[0], name)
148153
self.append(part)

Sming/Libraries/OtaUpgradeMqtt/samples/Upgrade/component.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ COMPONENT_DEPENDS := OtaUpgradeMqtt
4949
RBOOT_ENABLED := 1
5050

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

5454
APP_CFLAGS = -DMQTT_URL="\"$(MQTT_URL)"\" \
5555
-DMQTT_FINGERPRINT_SHA1=$(MQTT_FINGERPRINT_SHA1) \

Sming/Libraries/OtaUpgradeMqtt/samples/Upgrade/ota.hw

Lines changed: 0 additions & 11 deletions
This file was deleted.

samples/Basic_Ota/ota.hw

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
"name": "Basic OTA sample",
33
"base_config": "spiffs-two-roms",
44
"partitions": {
5-
"rom0": {
6-
"subtype": "ota_0"
7-
},
8-
"rom1": {
9-
"subtype": "ota_1"
10-
},
115
"spiffs0": {
126
"size": "512K"
137
},

0 commit comments

Comments
 (0)