mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
partition_table: add a test for total partition size error
This commit is contained in:
parent
f242a1705a
commit
f071558117
@ -7,19 +7,9 @@
|
|||||||
#
|
#
|
||||||
# (Can also check if the bootloader binary fits before the partition table.)
|
# (Can also check if the bootloader binary fits before the partition table.)
|
||||||
#
|
#
|
||||||
# Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
# SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
#
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
from __future__ import division, print_function, unicode_literals
|
from __future__ import division, print_function, unicode_literals
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
@ -4,19 +4,9 @@
|
|||||||
#
|
#
|
||||||
# This tool generates an empty binary file of the required size.
|
# This tool generates an empty binary file of the required size.
|
||||||
#
|
#
|
||||||
# Copyright 2018 Espressif Systems (Shanghai) PTE LTD
|
# SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
#
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http:#www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
from __future__ import division, print_function, unicode_literals
|
from __future__ import division, print_function, unicode_literals
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
@ -7,19 +7,9 @@
|
|||||||
# See https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/partition-tables.html
|
# See https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/partition-tables.html
|
||||||
# for explanation of partition table structure and uses.
|
# for explanation of partition table structure and uses.
|
||||||
#
|
#
|
||||||
# Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
# SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD
|
||||||
#
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http:#www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
from __future__ import division, print_function, unicode_literals
|
from __future__ import division, print_function, unicode_literals
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
@ -261,6 +251,17 @@ class PartitionTable(list):
|
|||||||
return 0 # empty table!
|
return 0 # empty table!
|
||||||
return last.offset + last.size
|
return last.offset + last.size
|
||||||
|
|
||||||
|
def verify_size_fits(self, flash_size_bytes: int) -> None:
|
||||||
|
""" Check that partition table fits into the given flash size.
|
||||||
|
Raises InputError otherwise.
|
||||||
|
"""
|
||||||
|
table_size = self.flash_size()
|
||||||
|
if flash_size_bytes < table_size:
|
||||||
|
mb = 1024 * 1024
|
||||||
|
raise InputError('Partitions tables occupies %.1fMB of flash (%d bytes) which does not fit in configured '
|
||||||
|
"flash size %dMB. Change the flash size in menuconfig under the 'Serial Flasher Config' menu." %
|
||||||
|
(table_size / mb, table_size, flash_size_bytes / mb))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_binary(cls, b):
|
def from_binary(cls, b):
|
||||||
md5 = hashlib.md5()
|
md5 = hashlib.md5()
|
||||||
@ -531,12 +532,7 @@ def main():
|
|||||||
|
|
||||||
if args.flash_size:
|
if args.flash_size:
|
||||||
size_mb = int(args.flash_size.replace('MB', ''))
|
size_mb = int(args.flash_size.replace('MB', ''))
|
||||||
size = size_mb * 1024 * 1024 # flash memory uses honest megabytes!
|
table.verify_size_fits(size_mb * 1024 * 1024)
|
||||||
table_size = table.flash_size()
|
|
||||||
if size < table_size:
|
|
||||||
raise InputError("Partitions defined in '%s' occupy %.1fMB of flash (%d bytes) which does not fit in configured "
|
|
||||||
"flash size %dMB. Change the flash size in menuconfig under the 'Serial Flasher Config' menu." %
|
|
||||||
(args.input.name, table_size / 1024.0 / 1024.0, table_size, size_mb))
|
|
||||||
|
|
||||||
# Make sure that the output directory is created
|
# Make sure that the output directory is created
|
||||||
output_dir = os.path.abspath(os.path.dirname(args.output))
|
output_dir = os.path.abspath(os.path.dirname(args.output))
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "unity.h"
|
#include "unity.h"
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
from __future__ import division, print_function
|
from __future__ import division, print_function
|
||||||
|
|
||||||
import io
|
import io
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
from __future__ import division, print_function
|
from __future__ import division, print_function
|
||||||
|
|
||||||
import csv
|
import csv
|
||||||
@ -467,6 +469,14 @@ ota_1, 0, ota_1, , 1M,
|
|||||||
finally:
|
finally:
|
||||||
sys.stderr = sys.__stderr__
|
sys.stderr = sys.__stderr__
|
||||||
|
|
||||||
|
def test_size_error(self):
|
||||||
|
csv_txt = """
|
||||||
|
factory, app, factory, 0x10000, 20M
|
||||||
|
"""
|
||||||
|
with self.assertRaisesRegex(gen_esp32part.InputError, r'does not fit'):
|
||||||
|
t = gen_esp32part.PartitionTable.from_csv(csv_txt)
|
||||||
|
t.verify_size_fits(16 * 1024 * 1024)
|
||||||
|
|
||||||
|
|
||||||
class PartToolTests(Py23TestCase):
|
class PartToolTests(Py23TestCase):
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -1346,14 +1346,6 @@ components/openssl/test/test_openssl.c
|
|||||||
components/openthread/include/esp_openthread.h
|
components/openthread/include/esp_openthread.h
|
||||||
components/openthread/include/esp_openthread_lock.h
|
components/openthread/include/esp_openthread_lock.h
|
||||||
components/openthread/include/esp_openthread_netif_glue.h
|
components/openthread/include/esp_openthread_netif_glue.h
|
||||||
components/partition_table/check_sizes.py
|
|
||||||
components/partition_table/gen_empty_partition.py
|
|
||||||
components/partition_table/gen_esp32part.py
|
|
||||||
components/partition_table/parttool.py
|
|
||||||
components/partition_table/test/test_partition.c
|
|
||||||
components/partition_table/test_gen_esp32part_host/check_sizes_test.py
|
|
||||||
components/partition_table/test_gen_esp32part_host/gen_esp32part_tests.py
|
|
||||||
components/partition_table/test_gen_esp32part_host/test_utils.py
|
|
||||||
components/protocomm/include/common/protocomm.h
|
components/protocomm/include/common/protocomm.h
|
||||||
components/protocomm/include/security/protocomm_security.h
|
components/protocomm/include/security/protocomm_security.h
|
||||||
components/protocomm/include/security/protocomm_security0.h
|
components/protocomm/include/security/protocomm_security0.h
|
||||||
|
Loading…
x
Reference in New Issue
Block a user