Lines Matching refs:esp

171 def load_ram(esp, args):  argument
172 image = LoadFirmwareImage(esp.CHIP_NAME, args.filename)
179 esp.mem_begin(
180 size, div_roundup(size, esp.ESP_RAM_BLOCK), esp.ESP_RAM_BLOCK, seg.addr
185 esp.mem_block(seg.data[0 : esp.ESP_RAM_BLOCK], seq)
186 seg.data = seg.data[esp.ESP_RAM_BLOCK :]
191 esp.mem_finish(image.entrypoint)
194 def read_mem(esp, args): argument
195 print("0x%08x = 0x%08x" % (args.address, esp.read_reg(args.address)))
198 def write_mem(esp, args): argument
199 esp.write_reg(args.address, args.value, args.mask, 0)
203 def dump_mem(esp, args): argument
206 d = esp.read_reg(args.address + (i * 4))
217 def detect_flash_size(esp, args=None): argument
219 if esp.secure_download_mode:
227 flash_id = esp.flash_id()
243 def _update_image_flash_params(esp, address, args, image): argument
252 if address != esp.BOOTLOADER_FLASH_OFFSET:
259 if magic != esp.ESP_IMAGE_MAGIC:
270 test_image = esp.BOOTLOADER_IMAGE(io.BytesIO(image))
275 "so not changing any flash settings." % (address, esp.CHIP_NAME)
289 flash_freq = esp.parse_flash_freq_arg(args.flash_freq)
293 flash_size = esp.parse_flash_size_arg(args.flash_size)
305 image_object = esp.BOOTLOADER_IMAGE(io.BytesIO(image))
338 def write_flash(esp, args): argument
345 if not args.force and esp.CHIP_NAME != "ESP8266" and not esp.secure_download_mode:
347 if esp.get_secure_boot_enabled():
359 image = LoadFirmwareImage(esp.CHIP_NAME, argfile)
364 if image.chip_id != esp.IMAGE_CHIP_ID:
383 rev = esp.get_chip_revision()
401 if esp.CHIP_NAME == "ESP32-C3":
402 rev = esp.get_minor_chip_version()
404 rev = esp.get_major_chip_version()
417 if not esp.secure_download_mode:
418 if esp.get_encrypted_download_disabled():
426 crypt_cfg_efuse = esp.get_flash_crypt_config()
432 enc_key_valid = esp.is_flash_encryption_key_valid()
442 if address % esp.FLASH_ENCRYPTED_WRITE_ALIGN:
445 % (argfile.name, address, esp.FLASH_ENCRYPTED_WRITE_ALIGN)
455 if not args.force and esp.CHIP_NAME != "ESP8266":
458 esp.CHIP_NAME != "ESP32"
459 and esp.secure_download_mode
460 and bin(esp.get_security_info()["flash_crypt_cnt"]).count("1") & 1 != 0
470 not esp.secure_download_mode
471 and esp.get_encrypted_download_disabled()
472 and esp.get_flash_encryption_enabled()
486 if esp.secure_download_mode:
489 flash_end_str = detect_flash_size(esp)
511 erase_flash(esp, args)
517 bytes_over = address % esp.FLASH_SECTOR_SIZE
523 address, esp.FLASH_SECTOR_SIZE, bytes_over
530 div_roundup(write_end, esp.FLASH_SECTOR_SIZE)
531 * esp.FLASH_SECTOR_SIZE
582 image = pad_to(image, esp.FLASH_ENCRYPTED_WRITE_ALIGN if encrypted else 4)
590 bytes_over = address % esp.FLASH_SECTOR_SIZE
594 if not esp.secure_download_mode and not esp.get_secure_boot_enabled():
595 image = _update_image_flash_params(esp, address, args, image)
607 for attempt in range(1, esp.WRITE_FLASH_ATTEMPTS + 1):
613 blocks = esp.flash_defl_begin(uncsize, len(image), address)
615 blocks = esp.flash_begin(
632 block = image[0 : esp.FLASH_WRITE_SIZE]
644 if not esp.IS_STUB:
646 esp.flash_defl_block(block, seq, timeout=timeout)
647 if esp.IS_STUB:
653 block = block + b"\xff" * (esp.FLASH_WRITE_SIZE - len(block))
655 esp.flash_encrypt_block(block, seq)
657 esp.flash_block(block, seq)
660 image = image[esp.FLASH_WRITE_SIZE :]
664 if attempt == esp.WRITE_FLASH_ATTEMPTS or encrypted:
668 esp._port.close()
673 esp._port.open()
675 esp.connect()
676 if esp.IS_STUB:
678 esp.IS_STUB = False
680 esp = esp.run_stub()
689 if esp.IS_STUB:
693 esp.read_reg(ESPLoader.CHIP_DETECT_MAGIC_REG_ADDR, timeout=timeout)
714 if not encrypted and not esp.secure_download_mode:
716 res = esp.flash_md5sum(address, uncsize)
732 if esp.IS_STUB:
735 esp.flash_begin(0, 0)
744 esp.flash_defl_finish(False)
746 esp.flash_finish(False)
761 verify_flash(esp, args)
1122 def read_mac(esp, args): argument
1126 eui64 = esp.read_mac("EUI64")
1129 print_mac("BASE MAC", esp.read_mac("BASE_MAC"))
1130 print_mac("MAC_EXT", esp.read_mac("MAC_EXT"))
1132 print_mac("MAC", esp.read_mac("BASE_MAC"))
1135 def chip_id(esp, args): argument
1137 chipid = esp.chip_id()
1140 print("Warning: %s has no Chip ID. Reading MAC instead." % esp.CHIP_NAME)
1141 read_mac(esp, args)
1144 def erase_flash(esp, args): argument
1145 if not args.force and esp.CHIP_NAME != "ESP8266" and not esp.secure_download_mode:
1146 if esp.get_flash_encryption_enabled() or esp.get_secure_boot_enabled():
1155 esp.erase_flash()
1159 def erase_region(esp, args): argument
1160 if not args.force and esp.CHIP_NAME != "ESP8266" and not esp.secure_download_mode:
1161 if esp.get_flash_encryption_enabled() or esp.get_secure_boot_enabled():
1170 esp.erase_region(args.address, args.size)
1174 def run(esp, args): argument
1175 esp.run()
1178 def detect_flash_id(esp): argument
1179 flash_id = esp.flash_id()
1188 def flash_id(esp, args): argument
1189 detect_flash_id(esp)
1190 flash_type = esp.flash_type()
1195 esp.get_flash_voltage()
1198 def read_flash_sfdp(esp, args): argument
1199 detect_flash_id(esp)
1201 sfdp = esp.read_spiflash_sfdp(args.addr, args.bytes * 8)
1209 def read_flash(esp, args): argument
1223 data = esp.read_flash(args.address, args.size, flash_progress)
1236 def verify_flash(esp, args): argument
1243 image = _update_image_flash_params(esp, address, args, image)
1251 digest = esp.flash_md5sum(address, image_size)
1262 flash = esp.read_flash(address, image_size)
1277 def read_flash_status(esp, args): argument
1278 print("Status value: 0x%04x" % esp.read_status(args.bytes))
1281 def write_flash_status(esp, args): argument
1284 print(("Initial flash status: " + fmt) % esp.read_status(args.bytes))
1286 esp.write_status(args.value, args.bytes, args.non_volatile)
1287 print(("After flash status: " + fmt) % esp.read_status(args.bytes))
1315 def get_security_info(esp, args): argument
1316 si = esp.get_security_info()
1322 if esp.KEY_PURPOSES:
1328 if key_num <= esp.EFUSE_MAX_KEY
1369 if esp.CHIP_NAME == "esp32":