Skip to content

Commit

Permalink
feat(espefuse): Update the way to complete the operation
Browse files Browse the repository at this point in the history
  • Loading branch information
KonstantinKondrashov authored and peterdragun committed Jul 16, 2024
1 parent 328832d commit c147694
Show file tree
Hide file tree
Showing 18 changed files with 90 additions and 54 deletions.
6 changes: 3 additions & 3 deletions espefuse/efuse/esp32c2/emulate_efuse_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, efuse_file=None, debug=False):
self.Fields = EfuseDefineFields()
self.REGS = EfuseDefineRegisters
super(EmulateEfuseController, self).__init__(efuse_file, debug)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)

""" esptool method start >>"""

Expand Down Expand Up @@ -55,10 +55,10 @@ def handle_writing_event(self, addr, value):
self.clean_blocks_wr_regs()
self.check_rd_protection_area()
self.write_reg(addr, 0)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)
elif value == self.REGS.EFUSE_READ_CMD:
self.write_reg(addr, 0)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)
self.save_to_file()

def get_bitlen_of_block(self, blk, wr=False):
Expand Down
10 changes: 7 additions & 3 deletions espefuse/efuse/esp32c2/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,13 @@ def clear_pgm_registers(self):
def wait_efuse_idle(self):
deadline = time.time() + self.REGS.EFUSE_BURN_TIMEOUT
while time.time() < deadline:
# if self.read_reg(self.REGS.EFUSE_CMD_REG) == 0:
if self.read_reg(self.REGS.EFUSE_STATUS_REG) & 0x7 == 1:
return
cmds = self.REGS.EFUSE_PGM_CMD | self.REGS.EFUSE_READ_CMD
if self.read_reg(self.REGS.EFUSE_CMD_REG) & cmds == 0:
if self.read_reg(self.REGS.EFUSE_CMD_REG) & cmds == 0:
# Due to a hardware error, we have to read READ_CMD again
# to make sure the efuse clock is normal.
# For PGM_CMD it is not necessary.
return
raise esptool.FatalError(
"Timed out waiting for Efuse controller command to complete"
)
Expand Down
6 changes: 3 additions & 3 deletions espefuse/efuse/esp32c3/emulate_efuse_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, efuse_file=None, debug=False):
self.Fields = EfuseDefineFields()
self.REGS = EfuseDefineRegisters
super(EmulateEfuseController, self).__init__(efuse_file, debug)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)

""" esptool method start >>"""

Expand Down Expand Up @@ -53,10 +53,10 @@ def handle_writing_event(self, addr, value):
self.clean_blocks_wr_regs()
self.check_rd_protection_area()
self.write_reg(addr, 0)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)
elif value == self.REGS.EFUSE_READ_CMD:
self.write_reg(addr, 0)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)
self.save_to_file()

def get_bitlen_of_block(self, blk, wr=False):
Expand Down
10 changes: 7 additions & 3 deletions espefuse/efuse/esp32c3/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,13 @@ def clear_pgm_registers(self):
def wait_efuse_idle(self):
deadline = time.time() + self.REGS.EFUSE_BURN_TIMEOUT
while time.time() < deadline:
# if self.read_reg(self.REGS.EFUSE_CMD_REG) == 0:
if self.read_reg(self.REGS.EFUSE_STATUS_REG) & 0x7 == 1:
return
cmds = self.REGS.EFUSE_PGM_CMD | self.REGS.EFUSE_READ_CMD
if self.read_reg(self.REGS.EFUSE_CMD_REG) & cmds == 0:
if self.read_reg(self.REGS.EFUSE_CMD_REG) & cmds == 0:
# Due to a hardware error, we have to read READ_CMD again
# to make sure the efuse clock is normal.
# For PGM_CMD it is not necessary.
return
raise esptool.FatalError(
"Timed out waiting for Efuse controller command to complete"
)
Expand Down
6 changes: 3 additions & 3 deletions espefuse/efuse/esp32c6/emulate_efuse_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, efuse_file=None, debug=False):
self.Fields = EfuseDefineFields()
self.REGS = EfuseDefineRegisters
super(EmulateEfuseController, self).__init__(efuse_file, debug)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)

""" esptool method start >>"""

Expand Down Expand Up @@ -53,10 +53,10 @@ def handle_writing_event(self, addr, value):
self.clean_blocks_wr_regs()
self.check_rd_protection_area()
self.write_reg(addr, 0)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)
elif value == self.REGS.EFUSE_READ_CMD:
self.write_reg(addr, 0)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)
self.save_to_file()

def get_bitlen_of_block(self, blk, wr=False):
Expand Down
10 changes: 7 additions & 3 deletions espefuse/efuse/esp32c6/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,13 @@ def clear_pgm_registers(self):
def wait_efuse_idle(self):
deadline = time.time() + self.REGS.EFUSE_BURN_TIMEOUT
while time.time() < deadline:
# if self.read_reg(self.REGS.EFUSE_CMD_REG) == 0:
if self.read_reg(self.REGS.EFUSE_STATUS_REG) & 0x7 == 1:
return
cmds = self.REGS.EFUSE_PGM_CMD | self.REGS.EFUSE_READ_CMD
if self.read_reg(self.REGS.EFUSE_CMD_REG) & cmds == 0:
if self.read_reg(self.REGS.EFUSE_CMD_REG) & cmds == 0:
# Due to a hardware error, we have to read READ_CMD again
# to make sure the efuse clock is normal.
# For PGM_CMD it is not necessary.
return
raise esptool.FatalError(
"Timed out waiting for Efuse controller command to complete"
)
Expand Down
6 changes: 3 additions & 3 deletions espefuse/efuse/esp32h2/emulate_efuse_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, efuse_file=None, debug=False):
self.Fields = EfuseDefineFields()
self.REGS = EfuseDefineRegisters
super(EmulateEfuseController, self).__init__(efuse_file, debug)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)

""" esptool method start >>"""

Expand Down Expand Up @@ -53,10 +53,10 @@ def handle_writing_event(self, addr, value):
self.clean_blocks_wr_regs()
self.check_rd_protection_area()
self.write_reg(addr, 0)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)
elif value == self.REGS.EFUSE_READ_CMD:
self.write_reg(addr, 0)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)
self.save_to_file()

def get_bitlen_of_block(self, blk, wr=False):
Expand Down
10 changes: 7 additions & 3 deletions espefuse/efuse/esp32h2/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,13 @@ def clear_pgm_registers(self):
def wait_efuse_idle(self):
deadline = time.time() + self.REGS.EFUSE_BURN_TIMEOUT
while time.time() < deadline:
# if self.read_reg(self.REGS.EFUSE_CMD_REG) == 0:
if self.read_reg(self.REGS.EFUSE_STATUS_REG) & 0x7 == 1:
return
cmds = self.REGS.EFUSE_PGM_CMD | self.REGS.EFUSE_READ_CMD
if self.read_reg(self.REGS.EFUSE_CMD_REG) & cmds == 0:
if self.read_reg(self.REGS.EFUSE_CMD_REG) & cmds == 0:
# Due to a hardware error, we have to read READ_CMD again
# to make sure the efuse clock is normal.
# For PGM_CMD it is not necessary.
return
raise esptool.FatalError(
"Timed out waiting for Efuse controller command to complete"
)
Expand Down
6 changes: 3 additions & 3 deletions espefuse/efuse/esp32h2beta1/emulate_efuse_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, efuse_file=None, debug=False):
self.Fields = EfuseDefineFields()
self.REGS = EfuseDefineRegisters
super(EmulateEfuseController, self).__init__(efuse_file, debug)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)

""" esptool method start >>"""

Expand Down Expand Up @@ -53,10 +53,10 @@ def handle_writing_event(self, addr, value):
self.clean_blocks_wr_regs()
self.check_rd_protection_area()
self.write_reg(addr, 0)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)
elif value == self.REGS.EFUSE_READ_CMD:
self.write_reg(addr, 0)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)
self.save_to_file()

def get_bitlen_of_block(self, blk, wr=False):
Expand Down
10 changes: 7 additions & 3 deletions espefuse/efuse/esp32h2beta1/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,13 @@ def clear_pgm_registers(self):
def wait_efuse_idle(self):
deadline = time.time() + self.REGS.EFUSE_BURN_TIMEOUT
while time.time() < deadline:
# if self.read_reg(self.REGS.EFUSE_CMD_REG) == 0:
if self.read_reg(self.REGS.EFUSE_STATUS_REG) & 0x7 == 1:
return
cmds = self.REGS.EFUSE_PGM_CMD | self.REGS.EFUSE_READ_CMD
if self.read_reg(self.REGS.EFUSE_CMD_REG) & cmds == 0:
if self.read_reg(self.REGS.EFUSE_CMD_REG) & cmds == 0:
# Due to a hardware error, we have to read READ_CMD again
# to make sure the efuse clock is normal.
# For PGM_CMD it is not necessary.
return
raise esptool.FatalError(
"Timed out waiting for Efuse controller command to complete"
)
Expand Down
6 changes: 3 additions & 3 deletions espefuse/efuse/esp32p4/emulate_efuse_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, efuse_file=None, debug=False):
self.Fields = EfuseDefineFields()
self.REGS = EfuseDefineRegisters
super(EmulateEfuseController, self).__init__(efuse_file, debug)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)

""" esptool method start >>"""

Expand Down Expand Up @@ -53,10 +53,10 @@ def handle_writing_event(self, addr, value):
self.clean_blocks_wr_regs()
self.check_rd_protection_area()
self.write_reg(addr, 0)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)
elif value == self.REGS.EFUSE_READ_CMD:
self.write_reg(addr, 0)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)
self.save_to_file()

def get_bitlen_of_block(self, blk, wr=False):
Expand Down
10 changes: 7 additions & 3 deletions espefuse/efuse/esp32p4/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,13 @@ def clear_pgm_registers(self):
def wait_efuse_idle(self):
deadline = time.time() + self.REGS.EFUSE_BURN_TIMEOUT
while time.time() < deadline:
# if self.read_reg(self.REGS.EFUSE_CMD_REG) == 0:
if self.read_reg(self.REGS.EFUSE_STATUS_REG) & 0x7 == 1:
return
cmds = self.REGS.EFUSE_PGM_CMD | self.REGS.EFUSE_READ_CMD
if self.read_reg(self.REGS.EFUSE_CMD_REG) & cmds == 0:
if self.read_reg(self.REGS.EFUSE_CMD_REG) & cmds == 0:
# Due to a hardware error, we have to read READ_CMD again
# to make sure the efuse clock is normal.
# For PGM_CMD it is not necessary.
return
raise esptool.FatalError(
"Timed out waiting for Efuse controller command to complete"
)
Expand Down
6 changes: 3 additions & 3 deletions espefuse/efuse/esp32s2/emulate_efuse_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, efuse_file=None, debug=False):
self.Fields = EfuseDefineFields()
self.REGS = EfuseDefineRegisters
super(EmulateEfuseController, self).__init__(efuse_file, debug)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)

""" esptool method start >>"""

Expand Down Expand Up @@ -53,10 +53,10 @@ def handle_writing_event(self, addr, value):
self.clean_blocks_wr_regs()
self.check_rd_protection_area()
self.write_reg(addr, 0)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)
elif value == self.REGS.EFUSE_READ_CMD:
self.write_reg(addr, 0)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)
self.save_to_file()

def get_bitlen_of_block(self, blk, wr=False):
Expand Down
10 changes: 7 additions & 3 deletions espefuse/efuse/esp32s2/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,13 @@ def clear_pgm_registers(self):
def wait_efuse_idle(self):
deadline = time.time() + self.REGS.EFUSE_BURN_TIMEOUT
while time.time() < deadline:
# if self.read_reg(self.EFUSE_CMD_REG) == 0:
if self.read_reg(self.REGS.EFUSE_STATUS_REG) & 0x7 == 1:
return
cmds = self.REGS.EFUSE_PGM_CMD | self.REGS.EFUSE_READ_CMD
if self.read_reg(self.REGS.EFUSE_CMD_REG) & cmds == 0:
if self.read_reg(self.REGS.EFUSE_CMD_REG) & cmds == 0:
# Due to a hardware error, we have to read READ_CMD again
# to make sure the efuse clock is normal.
# For PGM_CMD it is not necessary.
return
raise esptool.FatalError(
"Timed out waiting for Efuse controller command to complete"
)
Expand Down
6 changes: 3 additions & 3 deletions espefuse/efuse/esp32s3/emulate_efuse_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, efuse_file=None, debug=False):
self.Fields = EfuseDefineFields()
self.REGS = EfuseDefineRegisters
super(EmulateEfuseController, self).__init__(efuse_file, debug)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)

""" esptool method start >>"""

Expand Down Expand Up @@ -53,10 +53,10 @@ def handle_writing_event(self, addr, value):
self.clean_blocks_wr_regs()
self.check_rd_protection_area()
self.write_reg(addr, 0)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)
elif value == self.REGS.EFUSE_READ_CMD:
self.write_reg(addr, 0)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)
self.save_to_file()

def get_bitlen_of_block(self, blk, wr=False):
Expand Down
10 changes: 7 additions & 3 deletions espefuse/efuse/esp32s3/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,13 @@ def clear_pgm_registers(self):
def wait_efuse_idle(self):
deadline = time.time() + self.REGS.EFUSE_BURN_TIMEOUT
while time.time() < deadline:
# if self.read_reg(self.EFUSE_CMD_REG) == 0:
if self.read_reg(self.REGS.EFUSE_STATUS_REG) & 0x7 == 1:
return
cmds = self.REGS.EFUSE_PGM_CMD | self.REGS.EFUSE_READ_CMD
if self.read_reg(self.REGS.EFUSE_CMD_REG) & cmds == 0:
if self.read_reg(self.REGS.EFUSE_CMD_REG) & cmds == 0:
# Due to a hardware error, we have to read READ_CMD again
# to make sure the efuse clock is normal.
# For PGM_CMD it is not necessary.
return
raise esptool.FatalError(
"Timed out waiting for Efuse controller command to complete"
)
Expand Down
6 changes: 3 additions & 3 deletions espefuse/efuse/esp32s3beta2/emulate_efuse_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, efuse_file=None, debug=False):
self.Fields = EfuseDefineFields()
self.REGS = EfuseDefineRegisters
super(EmulateEfuseController, self).__init__(efuse_file, debug)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)

""" esptool method start >>"""

Expand Down Expand Up @@ -53,10 +53,10 @@ def handle_writing_event(self, addr, value):
self.clean_blocks_wr_regs()
self.check_rd_protection_area()
self.write_reg(addr, 0)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)
elif value == self.REGS.EFUSE_READ_CMD:
self.write_reg(addr, 0)
self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
self.write_reg(self.REGS.EFUSE_CMD_REG, 0)
self.save_to_file()

def get_bitlen_of_block(self, blk, wr=False):
Expand Down
10 changes: 7 additions & 3 deletions espefuse/efuse/esp32s3beta2/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,13 @@ def clear_pgm_registers(self):
def wait_efuse_idle(self):
deadline = time.time() + self.REGS.EFUSE_BURN_TIMEOUT
while time.time() < deadline:
# if self.read_reg(self.EFUSE_CMD_REG) == 0:
if self.read_reg(self.REGS.EFUSE_STATUS_REG) & 0x7 == 1:
return
cmds = self.REGS.EFUSE_PGM_CMD | self.REGS.EFUSE_READ_CMD
if self.read_reg(self.REGS.EFUSE_CMD_REG) & cmds == 0:
if self.read_reg(self.REGS.EFUSE_CMD_REG) & cmds == 0:
# Due to a hardware error, we have to read READ_CMD again
# to make sure the efuse clock is normal.
# For PGM_CMD it is not necessary.
return
raise esptool.FatalError(
"Timed out waiting for Efuse controller command to complete"
)
Expand Down

0 comments on commit c147694

Please sign in to comment.