Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Fix chip detection for ESP8266 #27

Merged
merged 5 commits into from
Jun 23, 2021
Merged

Conversation

conradopoole
Copy link
Collaborator

Changed keys of CHIP_DETECT_MAGIC_VALUES to Strings as the new magic value being added is a negative one and cannot be used as a key.

@TD-er
Copy link

TD-er commented Jun 23, 2021

Isn't this just a matter of a value being interpreted as 32 bit signed value?
So casting it to an unsigned value before trying to create a negative hex value sounds a lot more usable.
Not even sure if negative hex values should even exist, so it feels like it may break in some implementation.

@conradopoole
Copy link
Collaborator Author

Isn't this just a matter of a value being interpreted as 32 bit signed value?
So casting it to an unsigned value before trying to create a negative hex value sounds a lot more usable.
Not even sure if negative hex values should even exist, so it feels like it may break in some implementation.

I think javascript uses by default 64 bit singed, I'm not sure. In any case, it's the unpack/pack functions in the utils.ts that do the conversions... but I don't really fully understand how they work, so perhaps you are right and the original magic value that esptool uses to identify ESP8266, 0xfff0c101, might not be read and interpreted correctly...

The actual integer being read is -999167 which happens to be the decimal from signed 2's complement value for 0xfff0c101.

When I used to have the CHIP_DETECT_MAGIC_VALUES with integer keys, it would not find that key, probably because it is a negative integer.... I'm going to think a bit more about it to try and get that toHex function to return the signed 2 compliment value....

@TD-er
Copy link

TD-er commented Jun 23, 2021

If it uses 64 bit values and you try to convert a negative value into HEX, you should get a lot of leading FF values.
Strange thing is though, that there are other values in that file which are close to 2^32 in value, so why are those read correct?

src/const.ts Outdated
[-999617]: { name: "ESP8266", family: CHIP_FAMILY_ESP8266 },
0x00f01d83: { name: "ESP32", family: CHIP_FAMILY_ESP32 },
0x000007c6: { name: "ESP32-S2", family: CHIP_FAMILY_ESP32S2 },
0x00000009: { name: "ESP32-S3", family: CHIP_FAMILY_ESP32S3 },
0x9: { name: "ESP32-S3", family: CHIP_FAMILY_ESP32S3 },
0xeb004136: { name: "ESP32-S3(beta2)", family: CHIP_FAMILY_ESP32S3 },
Copy link

@TD-er TD-er Jun 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doubt this one will also be matched as expected. ( 0xeb004136 )

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doubt this one will also be matched as expected. ( 0xeb004136 )

@TD-er The better solution for this issue is on #28

@balloob
Copy link
Member

balloob commented Jun 23, 2021

@TD-er I am going to merge this fix and release so that we fix ESP8266 devices. If S3 doesn't work, let's address that in another PR. @conradopoole has ordered a couple of ESPs so we can better test moving forward.

@balloob balloob changed the title Mapped -0x000f3eff to ESP8266 Fix chip detection for ESP8266 Jun 23, 2021
@balloob balloob merged commit 7eb9cdf into NabuCasa:main Jun 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants