MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / getInfo

Method getInfo

tools/xsbug/esptool.js:132–232  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130 this.#serial.set({DTR: false, RTS: false});
131 }
132 async getInfo() {
133 const result = {};
134
135 if ("esp8266" == this.#mcu) {
136 result.wifi = true;
137 result.cores = 1;
138 result.bluetooth = false;
139
140 // description
141// const efuse0 = await this.readRegister(0x3ff0005c);
142 const efuse1 = await this.readRegister(0x3ff00058);
143// const efuse2 = await this.readRegister(0x3ff00054);
144 const efuse3 = await this.readRegister(0x3ff00050);
145 if ((efuse3 & (1 << 4)) || (efuse1 & (1 << (80 - 64)))) {
146 result.chip = {name: "ESP8285"}
147 result.embeddedFlash = true;
148 }
149 else {
150 result.chip = {name: "ESP8266EX"}
151 result.embeddedFlash = false;
152 }
153
154 // mac address
155 const ESP_OTP_MAC0 = 0x3ff00050;
156 const ESP_OTP_MAC1 = 0x3ff00054;
157 const ESP_OTP_MAC3 = 0x3ff0005c;
158 const mac0 = await this.readRegister(ESP_OTP_MAC0)
159 const mac1 = await this.readRegister(ESP_OTP_MAC1)
160 const mac3 = await this.readRegister(ESP_OTP_MAC3)
161
162 let oui;
163 if (mac3 !== 0)
164 oui = [(mac3 >> 16) & 0xff, (mac3 >> 8) & 0xff, mac3 & 0xff];
165 else if (((mac1 >> 16) & 0xff) == 0)
166 oui = [0x18, 0xfe, 0x34];
167 else if (((mac1 >> 16) & 0xff) == 1)
168 oui = [0xac, 0xd0, 0x74];
169 else
170 throw new Error("unexpected value");
171 oui.push((mac1 >> 8) & 0xff);
172 oui.push(mac1 & 0xff);
173 oui.push((mac0 >> 24) & 0xff);
174 oui = oui.map(value => value.toString(16).padStart(2, "0"));
175 result.MAC = oui.join(":");
176 }
177 else if ("esp32" === this.#mcu) {
178 // chip description
179 const DR_REG_SYSCON_BASE = 0x3ff66000;
180 const efuse1 = await this.readEfuse(1);
181 const efuse2 = await this.readEfuse(2);
182 const efuse3 = await this.readEfuse(3);
183 const efuse4 = await this.readEfuse(4);
184 const efuse5 = await this.readEfuse(5);
185 const efuse6 = await this.readEfuse(6);
186 const apb_ctl_date = await this.readRegister(DR_REG_SYSCON_BASE + 0x7C)
187
188 let revision = 0;
189 if ((efuse3 >> 15) & 1) { // revbit 0

Callers 1

DebugBehavior.jsFile · 0.80

Calls 6

readRegisterMethod · 0.95
readEfuseMethod · 0.95
readMethod · 0.95
mapMethod · 0.80
pushMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected