mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-04 13:14:32 +02:00
change: misaligned partitions now raise an exception
change: alignment for data partitions is now 4kB instead of 4B remove: STRICT_DATA_ALIGNMENT variable remove: warning tests for misaligned partitions add: assertion test for misaligned partitions add: breaking change documentation
This commit is contained in:
@@ -84,13 +84,10 @@ def get_subtype_as_int(ptype, subtype):
|
|||||||
|
|
||||||
ALIGNMENT = {
|
ALIGNMENT = {
|
||||||
APP_TYPE: 0x10000,
|
APP_TYPE: 0x10000,
|
||||||
DATA_TYPE: 0x4,
|
DATA_TYPE: 0x1000,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STRICT_DATA_ALIGNMENT = 0x1000
|
|
||||||
|
|
||||||
|
|
||||||
def get_alignment_for_type(ptype):
|
def get_alignment_for_type(ptype):
|
||||||
return ALIGNMENT.get(ptype, ALIGNMENT[DATA_TYPE])
|
return ALIGNMENT.get(ptype, ALIGNMENT[DATA_TYPE])
|
||||||
|
|
||||||
@@ -400,11 +397,6 @@ class PartitionDefinition(object):
|
|||||||
align = get_alignment_for_type(self.type)
|
align = get_alignment_for_type(self.type)
|
||||||
if self.offset % align:
|
if self.offset % align:
|
||||||
raise ValidationError(self, 'Offset 0x%x is not aligned to 0x%x' % (self.offset, align))
|
raise ValidationError(self, 'Offset 0x%x is not aligned to 0x%x' % (self.offset, align))
|
||||||
# The alignment requirement for non-app partition is 4 bytes, but it should be 4 kB.
|
|
||||||
# Print a warning for now, make it an error in IDF 5.0 (IDF-3742).
|
|
||||||
if self.type != APP_TYPE and self.offset % STRICT_DATA_ALIGNMENT:
|
|
||||||
critical('WARNING: Partition %s not aligned to 0x%x.'
|
|
||||||
'This is deprecated and will be considered an error in the future release.' % (self.name, STRICT_DATA_ALIGNMENT))
|
|
||||||
if self.size % align and secure and self.type == APP_TYPE:
|
if self.size % align and secure and self.type == APP_TYPE:
|
||||||
raise ValidationError(self, 'Size 0x%x is not aligned to 0x%x' % (self.size, align))
|
raise ValidationError(self, 'Size 0x%x is not aligned to 0x%x' % (self.size, align))
|
||||||
if self.size is None:
|
if self.size is None:
|
||||||
|
@@ -393,6 +393,17 @@ class VerificationTests(Py23TestCase):
|
|||||||
csv = """
|
csv = """
|
||||||
# Name,Type, SubType,Offset,Size
|
# Name,Type, SubType,Offset,Size
|
||||||
app,app, factory, 32K, 1M
|
app,app, factory, 32K, 1M
|
||||||
|
"""
|
||||||
|
with self.assertRaisesRegex(gen_esp32part.ValidationError, r'Offset.+not aligned'):
|
||||||
|
t = gen_esp32part.PartitionTable.from_csv(csv)
|
||||||
|
t.verify()
|
||||||
|
|
||||||
|
csv = """
|
||||||
|
# Name, Type, SubType, Offset, Size, Flags
|
||||||
|
nvs, data, nvs, 0x9420, 0x6000,
|
||||||
|
phy_init, data, phy, , 0x1000,
|
||||||
|
factory, app, factory, , 1M,
|
||||||
|
|
||||||
"""
|
"""
|
||||||
with self.assertRaisesRegex(gen_esp32part.ValidationError, r'Offset.+not aligned'):
|
with self.assertRaisesRegex(gen_esp32part.ValidationError, r'Offset.+not aligned'):
|
||||||
t = gen_esp32part.PartitionTable.from_csv(csv)
|
t = gen_esp32part.PartitionTable.from_csv(csv)
|
||||||
@@ -453,19 +464,6 @@ ota_1, 0, ota_1, , 1M,
|
|||||||
self.assertIn('WARNING', sys.stderr.getvalue())
|
self.assertIn('WARNING', sys.stderr.getvalue())
|
||||||
self.assertIn('partition subtype', sys.stderr.getvalue())
|
self.assertIn('partition subtype', sys.stderr.getvalue())
|
||||||
|
|
||||||
sys.stderr = io.StringIO()
|
|
||||||
csv_3 = 'nvs, data, nvs, 0x8800, 32k'
|
|
||||||
gen_esp32part.PartitionTable.from_csv(csv_3).verify()
|
|
||||||
self.assertIn('WARNING', sys.stderr.getvalue())
|
|
||||||
self.assertIn('not aligned to 0x1000', sys.stderr.getvalue())
|
|
||||||
|
|
||||||
sys.stderr = io.StringIO()
|
|
||||||
csv_4 = 'factory, app, factory, 0x10000, 0x100100\n' \
|
|
||||||
'nvs, data, nvs, , 32k'
|
|
||||||
gen_esp32part.PartitionTable.from_csv(csv_4).verify()
|
|
||||||
self.assertIn('WARNING', sys.stderr.getvalue())
|
|
||||||
self.assertIn('not aligned to 0x1000', sys.stderr.getvalue())
|
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
sys.stderr = sys.__stderr__
|
sys.stderr = sys.__stderr__
|
||||||
|
|
||||||
|
@@ -8,3 +8,8 @@ f_mkfs() signature change in FATFS v0.14
|
|||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
New signature is ``FRESULT f_mkfs (const TCHAR* path, const MKFS_PARM* opt, void* work, UINT len);`` which now uses ``MKFS_PARM`` struct as a second argument.
|
New signature is ``FRESULT f_mkfs (const TCHAR* path, const MKFS_PARM* opt, void* work, UINT len);`` which now uses ``MKFS_PARM`` struct as a second argument.
|
||||||
|
|
||||||
|
Partition table generation no longer supports misaligned partitions
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
|
||||||
|
When generating a partiton table, ``esp-idf`` will no longer accept partitions which offset does not align to 4kB. This change only affects generating new partition tables, reading and writing to already existing partitions remains unchanged.
|
Reference in New Issue
Block a user