Skip to content

Commit a253367

Browse files
committed
test_esptool: Remove "header only" image from tests
write_flash will not adjust it any more, need to flash a real-looking binary image.
1 parent d22613a commit a253367

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

test/images/image_header_only.bin

-8 Bytes
Binary file not shown.

test/test_esptool.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -456,33 +456,36 @@ def test_read_chip_id(self):
456456

457457
class TestKeepImageSettings(EsptoolTestCase):
458458
""" Tests for the -fm keep, -ff keep options for write_flash """
459-
HEADER_ONLY = "images/image_header_only.bin" # 8 byte file, contains image header
459+
if chip == "esp8266":
460+
BL_IMAGE = "images/esp8266_sdk/boot_v1.4(b1).bin"
461+
elif chip == "esp32":
462+
BL_IMAGE = "images/bootloader.bin"
463+
460464
def setUp(self):
461465
super(TestKeepImageSettings, self).setUp()
462466
self.flash_offset = 0x1000 if chip == "esp32" else 0 # bootloader offset
463-
with open(self.HEADER_ONLY, "rb") as f:
467+
with open(self.BL_IMAGE, "rb") as f:
464468
self.header = f.read(8)
465469

466470
def test_keep_does_not_change_settings(self):
467-
# defaults should be keep, except for flash size which has to match header
468-
flash_size = "1MB" if chip == "esp32" else "512KB" # hex 0
469-
self.run_esptool("write_flash -fs %s 0x%x %s" % (flash_size, self.flash_offset, self.HEADER_ONLY))
470-
self.verify_readback(self.flash_offset, 8, self.HEADER_ONLY, False)
471-
# can also explicitly set these options
472-
self.run_esptool("write_flash -fm keep -ff keep -fs %s 0x%x %s" % (flash_size, self.flash_offset, self.HEADER_ONLY))
473-
self.verify_readback(self.flash_offset, 8, self.HEADER_ONLY, False)
471+
# defaults should all be keep
472+
self.run_esptool("write_flash -fs keep 0x%x %s" % (self.flash_offset, self.BL_IMAGE))
473+
self.verify_readback(self.flash_offset, 8, self.BL_IMAGE, False)
474+
# can also explicitly set all options
475+
self.run_esptool("write_flash -fm keep -ff keep -fs keep 0x%x %s" % (self.flash_offset, self.BL_IMAGE))
476+
self.verify_readback(self.flash_offset, 8, self.BL_IMAGE, False)
474477
# verify_flash should also use 'keep'
475-
self.run_esptool("verify_flash -fs %s 0x%x %s" % (flash_size, self.flash_offset, self.HEADER_ONLY))
478+
self.run_esptool("verify_flash -fs keep 0x%x %s" % (self.flash_offset, self.BL_IMAGE))
476479

477480
def test_detect_size_changes_size(self):
478-
self.run_esptool("write_flash 0x%x %s" % (self.flash_offset, self.HEADER_ONLY))
481+
self.run_esptool("write_flash 0x%x %s" % (self.flash_offset, self.BL_IMAGE))
479482
readback = self.readback(self.flash_offset, 8)
480483
self.assertEqual(self.header[:3], readback[:3]) # first 3 bytes unchanged
481484
self.assertNotEqual(self.header[3], readback[3]) # size_freq byte changed
482485
self.assertEqual(self.header[4:], readback[4:]) # rest unchanged
483486

484487
def test_explicit_set_size_freq_mode(self):
485-
self.run_esptool("write_flash -fs 2MB -fm qio -ff 80m 0x%x %s" % (self.flash_offset, self.HEADER_ONLY))
488+
self.run_esptool("write_flash -fs 2MB -fm qio -ff 80m 0x%x %s" % (self.flash_offset, self.BL_IMAGE))
486489

487490
def val(x):
488491
try:
@@ -495,13 +498,12 @@ def val(x):
495498
self.assertEqual(self.header[0], readback[0])
496499
self.assertEqual(self.header[1], readback[1])
497500
self.assertEqual(0, val(readback[2])) # qio mode
498-
self.assertNotEqual(0, val(self.header[2]))
499501
self.assertEqual(0x1f if chip == "esp32" else 0x3f, val(readback[3])) # size_freq
500502
self.assertNotEqual(self.header[3], readback[3])
501503
self.assertEqual(self.header[4:], readback[4:])
502504
# verify_flash should pass if we match params, fail otherwise
503-
self.run_esptool("verify_flash -fs 2MB -fm qio -ff 80m 0x%x %s" % (self.flash_offset, self.HEADER_ONLY))
504-
self.run_esptool_error("verify_flash 0x%x %s" % (self.flash_offset, self.HEADER_ONLY))
505+
self.run_esptool("verify_flash -fs 2MB -fm qio -ff 80m 0x%x %s" % (self.flash_offset, self.BL_IMAGE))
506+
self.run_esptool_error("verify_flash 0x%x %s" % (self.flash_offset, self.BL_IMAGE))
505507

506508

507509
class TestLoadRAM(EsptoolTestCase):

0 commit comments

Comments
 (0)