feat: Add auto-detect ESP chip via security info and improve test coverage#12
feat: Add auto-detect ESP chip via security info and improve test coverage#12gandarez wants to merge 1 commit intotinygo-org:mainfrom
Conversation
…erage Refactor chip detection from magic-register-only approach to use GET_SECURITY_INFO command with ChipID fallback via readReg. Add security_info.go for parsing security info responses (12/20 byte variants) and security flag decoding. Expand protocol layer with securityInfo command support and improve test coverage across flasher, protocol, and security_info packages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| cmdSync byte = 0x08 // Sync with bootloader | ||
| cmdWriteReg byte = 0x09 // Write 32-bit memory-mapped register | ||
| cmdReadReg byte = 0x0A // Read 32-bit memory-mapped register | ||
| cmdSecurityInfoReg byte = 0x14 // Read security info (chip ID, flash encryption, etc.) |
There was a problem hiding this comment.
there does not seem to be much change here, it would make reviewer's life easier if the added line was separated by a empty line so as to not change the formatting of the entire declaration group.
There was a problem hiding this comment.
humm that's the identation caused by go fmt. Adding an extra space and getting it merged will make it look very strange.
| cmdSPISetParams byte = 0x0B // Configure SPI flash parameters | ||
| cmdSPIAttach byte = 0x0D // Attach SPI flash |
There was a problem hiding this comment.
this is not changed, only cmdSecurityInfoReg was added
|
I was just able to do a little testing on my machine. With this PR, the auto-detection no longer works on |
|
|
||
| // detectChip identifies the connected ESP chip. | ||
| func (f *Flasher) detectChip() (*chipDef, error) { | ||
| // Try reading the magic register first |
There was a problem hiding this comment.
The reason to do this first was because of older chips, as mentioned in the comment. This probably why auto-detect is no longer working for esp8266/esp32 in this PR.
There was a problem hiding this comment.
I just bought a legacy ESP32 to give a try with these changes.
magic-register-onlyapproach to useGET_SECURITY_INFOcommand with ChipID fallback viareadReg.security_info.gofor parsing security info responses (12/20 byte variants) and security flag decoding.This PR is essential to get
esp32c6support in this PR