Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency of bit position reading pkg_version from ESP32-C2 (ESPTOOL-487) #759

Closed
1 task done
xingrz opened this issue Jul 18, 2022 · 1 comment
Closed
1 task done

Comments

@xingrz
Copy link
Contributor

xingrz commented Jul 18, 2022

Operating System

macOS 12.4

Esptool Version

v4.1-15-g65f8614

Python Version

Python 3.9.13

Chip Description

ESP32-C2

Device Description

ESP8684-DevKitM-1

Hardware Configuration

No response

How is Esptool Run

Terminal (iTerm.app)

Full Esptool Command Line that Was Run

esptool.py --port /dev/cu.usbserial-14110 flash_id

Esptool Output

esptool.py v3.3.1
Serial port /dev/cu.usbserial-14110
Connecting....
Detecting chip type... ESP32-C2
Chip is ESP32-C2 (revision 1)
Features: Wi-Fi
Crystal is 40MHz
MAC: 10:97:bd:f1:e6:3c
Uploading stub...
Running stub...
Stub running...
Manufacturer: 5e
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...

More Information

esptool.py works well, actually. But after reviewing the code, I found something inconsistent.

According to esp_efuse_table.csv#L69 in ESP-IDF, the position of PKG_VERSION is at bit 54 of EFUSE_BLK2 (which is also EFUSE_RD_BLK2_DATA0_REG).

As we learn from efuse_reg.h#L312, the value of EFUSE_RD_BLK2_DATA0_REG is DR_REG_EFUSE_BASE + 0x40 and EFUSE_RD_BLK2_DATA1_REG is DR_REG_EFUSE_BASE + 0x44. So we can infer that the bit position of PKG_VERSION counting from 0x044 should be 22.

While in esp32c2.py#L55, we read the forth word (EFUSE_BASE + 0x044 plus 12 bytes) and right shifted 21 bits (considering the byte order, means moving the pointer right 21 bits). This is actually 12 bytes + 21 bits = 117 bits counting from 0x044, or bit 149 counting from EFUSE_BLK2.

num_word = 3
block1_addr = self.EFUSE_BASE + 0x044
word3 = self.read_reg(block1_addr + (4 * num_word))
pkg_version = (word3 >> 21) & 0x0F

Other Steps to Reproduce

No response

I Have Read the Troubleshooting Guide

  • I confirm I have read the troubleshooting guide.
@github-actions github-actions bot changed the title Inconsistency of bit position reading pkg_version from ESP32-C2 Inconsistency of bit position reading pkg_version from ESP32-C2 (ESPTOOL-487) Jul 18, 2022
@dobairoland
Copy link
Collaborator

Thank you for your report!

radimkarnis pushed a commit to radimkarnis/esptool that referenced this issue Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants