#include "info.h"
#include <windows.h>
#include <stdio.h>
namespace esp{
static const Info1 info1[]={
{"8266", 66,0xFFF0C101},
{"32", 32,0x00F01D83},
{"32S2", 2,0x000007C6},
{"32S3b2", 4,0xEB004136},
{"32C3e2", 5,0x6921506F},
{"32C3e3", 5,0x6921506F},
{"32C3e6", 5,0x6921506F},
{"32C3e7", 5,0x6921506F},
{"32C6b", 7,0x0DA1806F},
{"32S3", 9,0x00000009},
{"32H2b1",10,0xCA26CC22},
{"32C2e0",12,0x6F51306F},
{"32C2e1",12,0x7C41A06F},
{"32C6", 13,0x2CE0806F},
{"32H2b2",14,0x6881B06F},
{"32H2", 16,0xD7B73E80},
{"32P4", 18,0x00000000},
}; // 13 Chips, davon 32C3 mit 4 IDs und 32C2 mit 2 IDs
const Info1*find1(Chipmagic chip) {
if (chip==undefined) return 0;
for (int i=0; i<elemof(info1); i++) {
const Info1&cur=info1[i];
if (Chipmagic(cur.magic)==chip) return&cur;
}
return 0;
}
const Info1*find1(char image_id) {
if (!image_id) return 0;
for (int i=0; i<elemof(info1); i++) {
const Info1&cur=info1[i];
if (cur.image_chip_id==image_id) return&cur;
}
return 0;
}
const Info1*find1(const char*chip) {
if (!chip) return 0;
if (!StrCmpNIA(chip,"esp",3)) chip+=3; // skip optional "ESP" prefix
for (int i=0; i<elemof(info1); i++) {
const Info1&cur=info1[i];
int k=StrCSpnA(cur.name,"Ee"); // E-Suffix ignorieren
if (!StrCmpNIA(cur.name,chip,k)) return&cur;
}
return 0;
}
static const Info2 info2[]={
// H-Teile bestimmter Adressbereiche, zurzeit unklar
{66, 0, 0, 0, 0,0x60000200}, // ESP8266
{32,0x400D,0x4040,0x3F40,0x3F80,0x3FF42000,0x3FF5A000}, // ESP32
{ 2,0x4008,0x40B8,0x3F00,0x3F3F,0x3F402000,0x3F41A030}, // ESP32S2
{ 9,0x4200,0x4400,0x3C00,0x3E00,0x60002000,0x60007030}, // ESP32S3
{12,0x4200,0x4240,0x3C00,0x3C40}, // ESP32C2
{ 5,0x4200,0x4280,0x3C00,0x3C80,0x60002000,0x60008830}, // ESP32C3
{16,0x4200,0x4280,0x3C00,0x3C80,0x60002000,0x6001A030}, // ESP32H2
{13,0x4200,0x4280,0x4280,0x4300,0x60003000,0x600B0830}, // ESP32C6
{18,0x4000,0x4C00,0x4000,0x4C00,0x5008D000,0x5012D030}, // ESP32P4
}; // 9 tatsächlich verschiedene Chips, die durch coerceBetas() aus den 13 zusammengefasst werden
static char coerceBetas(char image_id) {
switch (image_id) {
case 4: return 9; // ESP32S3b2 => ESP32S3
case 10: // ESP32H2b1 => ESP32H2
case 14: return 16; // ESP32H2b2 => ESP32H2
case 7: return 13; // ESP32C6b => ESP32C6
}
return image_id;
}
const Info2*find2(char image_id) {
if (!image_id) return 0;
image_id=coerceBetas(image_id);
for (int i=0; i<elemof(info2); i++) {
const Info2&cur=info2[i];
if (cur.image_chip_id==image_id) return&cur;
}
return 0;
}
const byte*stub(char image_id) {
return (const byte*)LockResource(LoadResource(0,FindResource(0,MAKEINTRESOURCE(image_id),RT_RCDATA)));
}
/* Calculate checkbyte of a blob, as it is defined by the ROM */
byte xor8(const void*data, int dlen, byte state) {
const byte*d=reinterpret_cast<const byte*>(data);
if (dlen) do state^=*d++; while(--dlen);
return state;
}
struct Memarea{
unsigned aadr,eadr;
const char*name;
};
template<byte N>struct Memareas{
char id[3]; // up to 3 chip IDs
byte n; // must match to N
Memarea areas[N];
};
static const struct Memareass{
Memareas<4> mem8266;
Memareas<15> mem32;
Memareas<12> mem32s2;
Memareas<12> mem32s3;
Memareas<8> mem32c2;
Memareas<11> mem32c3;
Memareas<11> mem32c6;
}memareass={{
{66},4, // ESP8266
{{0x3FF00000, 0x3FF00010, "DPORT"},
{0x3FFE8000, 0x40000000, "DRAM"},
{0x40100000, 0x40108000, "IRAM"},
{0x40201010, 0x402E1010, "IROM"}}
},{
{32,18},15, // ESP32, ESP32P4
{{0x00000000, 0x00010000, "padding"},
{0x3F400000, 0x3F800000, "DROM"},
{0x3F800000, 0x3FC00000, "EXTRAM_DATA"},
{0x3FF80000, 0x3FF82000, "RTC_DRAM"},
{0x3FF90000, 0x40000000, "byte_accessible"},
{0x3FFAE000, 0x40000000, "DRAM"},
{0x3FFE0000, 0x3FFFFFFC, "DIRAM_DRAM"},
{0x40000000, 0x40070000, "IROM"},
{0x40070000, 0x40078000, "CACHE_PRO"},
{0x40078000, 0x40080000, "CACHE_APP"},
{0x40080000, 0x400A0000, "IRAM"},
{0x400A0000, 0x400BFFFC, "DIRAM_IRAM"},
{0x400C0000, 0x400C2000, "RTC_IRAM"},
{0x400D0000, 0x40400000, "IROM"},
{0x50000000, 0x50002000, "RTC_DATA"}}
},{
{2},12, // ESP32S2
{{0x00000000, 0x00010000, "padding"},
{0x3F000000, 0x3FF80000, "DROM"},
{0x3F500000, 0x3FF80000, "EXTRAM_DATA"},
{0x3FF9E000, 0x3FFA0000, "RTC_DRAM"},
{0x3FF9E000, 0x40000000, "byte_accessible"},
{0x3FF9E000, 0x40072000, "mem_internal"},
{0x3FFB0000, 0x40000000, "DRAM"},
{0x40000000, 0x4001A100, "IROM_MASK"},
{0x40020000, 0x40070000, "IRAM"},
{0x40070000, 0x40072000, "RTC_IRAM"},
{0x40080000, 0x40800000, "IROM"},
{0x50000000, 0x50002000, "RTC_DATA"}}
},{
{9},12, //ESP32S3
{{0x00000000, 0x00010000, "padding"},
{0x3C000000, 0x3D000000, "DROM"},
{0x3D000000, 0x3E000000, "EXTRAM_DATA"},
{0x600FE000, 0x60100000, "RTC_DRAM"},
{0x3FC88000, 0x3FD00000, "byte_accessible"},
{0x3FC88000, 0x403E2000, "mem_internal"},
{0x3FC88000, 0x3FD00000, "DRAM"},
{0x40000000, 0x4001A100, "IROM_MASK"},
{0x40370000, 0x403E0000, "IRAM"},
{0x600FE000, 0x60100000, "RTC_IRAM"},
{0x42000000, 0x42800000, "IROM"},
{0x50000000, 0x50002000, "RTC_DATA"}}
},{
{12},8, //ESP32C2
{{0x00000000, 0x00010000, "padding"},
{0x3C000000, 0x3C400000, "DROM"},
{0x3FCA0000, 0x3FCE0000, "DRAM"},
{0x3FC88000, 0x3FD00000, "byte_accessible"},
{0x3FF00000, 0x3FF50000, "DROM_MASK"},
{0x40000000, 0x40090000, "IROM_MASK"},
{0x42000000, 0x42400000, "IROM"},
{0x4037C000, 0x403C0000, "IRAM"}}
},{
{12},11, //ESP32C3
{{0x00000000, 0x00010000, "padding"},
{0x3C000000, 0x3C800000, "DROM"},
{0x3FC80000, 0x3FCE0000, "DRAM"},
{0x3FC88000, 0x3FD00000, "byte_accessible"},
{0x3FF00000, 0x3FF20000, "DROM_MASK"},
{0x40000000, 0x40060000, "IROM_MASK"},
{0x42000000, 0x42800000, "IROM"},
{0x4037C000, 0x403E0000, "IRAM"},
{0x50000000, 0x50002000, "RTC_IRAM"},
{0x50000000, 0x50002000, "RTC_DRAM"},
{0x600FE000, 0x60100000, "mem_internal2"}}
},{
{13,16},11, // ESP32C6, ESP32H2
{{0x00000000, 0x00010000, "padding"},
{0x42800000, 0x43000000, "DROM"},
{0x40800000, 0x40880000, "DRAM"},
{0x40800000, 0x40880000, "byte_accessible"},
{0x4004AC00, 0x40050000, "DROM_MASK"},
{0x40000000, 0x4004AC00, "IROM_MASK"},
{0x42000000, 0x42800000, "IROM"},
{0x40800000, 0x40880000, "IRAM"},
{0x50000000, 0x50004000, "RTC_IRAM"},
{0x50000000, 0x50004000, "RTC_DRAM"},
{0x600FE000, 0x60100000, "mem_internal2"}}
}};
String<80>memareas(char image_id,unsigned A, unsigned E) {
MAKEPRINTBUF(80)
if (!image_id) return buf;
image_id=coerceBetas(image_id);
const Memareas<16>*areas=reinterpret_cast<const Memareas<16>*>(&memareass);
for(int i=0; i<7; i++) {
for (int j=0; j<3; j++) if (image_id==areas->id[j]) {
const Memarea*area=areas->areas;
bool komma=false;
for (int k=0; k<areas->n; k++,area++) {
if (A < area->eadr && E >= area->aadr) {
print("%c%s",komma?',':'[',area->name);
komma=true;
}
}
if (komma) print("%c",']');
return buf;
}
areas=reinterpret_cast<const Memareas<16>*>(reinterpret_cast<const byte*>(areas)+4+areas->n*sizeof(Memarea));
}
return buf;
}
}
Detected encoding: ANSI (CP1252) | 4
|
|