Added first half of RE'd user_interface.c
This commit is contained in:
parent
3e5af479bc
commit
8c9a77efe8
20 changed files with 745 additions and 30 deletions
|
@ -27,6 +27,7 @@
|
|||
#include "espressif/esp_common.h"
|
||||
#include "espressif/phy_info.h"
|
||||
#include "sdk_internal.h"
|
||||
#include "esplibs/libmain.h"
|
||||
|
||||
/* This is not declared in any header file (but arguably should be) */
|
||||
|
||||
|
@ -345,8 +346,8 @@ static __attribute__((noinline)) void user_start_phase2(void) {
|
|||
sdk_phy_info_t phy_info, default_phy_info;
|
||||
|
||||
sdk_system_rtc_mem_read(0, &sdk_rst_if, sizeof(sdk_rst_if));
|
||||
if (sdk_rst_if.version > 3) {
|
||||
// Bad version number. Probably garbage.
|
||||
if (sdk_rst_if.reason > 3) {
|
||||
// Bad reason. Probably garbage.
|
||||
bzero(&sdk_rst_if, sizeof(sdk_rst_if));
|
||||
}
|
||||
buf = malloc(sizeof(sdk_rst_if));
|
||||
|
@ -357,8 +358,8 @@ static __attribute__((noinline)) void user_start_phase2(void) {
|
|||
get_otp_mac_address(sdk_info.sta_mac_addr);
|
||||
sdk_wifi_softap_cacl_mac(sdk_info.softap_mac_addr, sdk_info.sta_mac_addr);
|
||||
sdk_info._unknown0 = 0x0104a8c0;
|
||||
sdk_info._unknown1 = 0x00ffffff;
|
||||
sdk_info._unknown2 = 0x0104a8c0;
|
||||
sdk_info._unknown4 = 0x00ffffff;
|
||||
sdk_info._unknown8 = 0x0104a8c0;
|
||||
init_g_ic();
|
||||
|
||||
read_saved_phy_info(&phy_info);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "esp/rom.h"
|
||||
#include "esp/uart.h"
|
||||
#include "espressif/esp_common.h"
|
||||
#include "sdk_internal.h"
|
||||
#include "esplibs/libmain.h"
|
||||
|
||||
/* Forward declarations */
|
||||
static void IRAM fatal_handler_prelude(void);
|
||||
|
|
|
@ -90,6 +90,10 @@ _Static_assert(sizeof(struct DPORT_REGS) == 0x60, "DPORT_REGS is the wrong size"
|
|||
|
||||
/* Details for CLOCKGATE_WATCHDOG register */
|
||||
|
||||
// Set and then cleared during sdk_system_restart_in_nmi().
|
||||
// Not sure what this does. May be related to ESPSAR.UNKNOWN_48
|
||||
#define DPORT_CLOCKGATE_WATCHDOG_UNKNOWN_8 BIT(8)
|
||||
|
||||
/* Comment found in pvvx/mp3_decode headers: "use clockgate_watchdog(flg) { if(flg) 0x3FF00018 &= 0x77; else 0x3FF00018 |= 8; }". Not sure what this means or does. */
|
||||
|
||||
#define DPORT_CLOCKGATE_WATCHDOG_DISABLE BIT(3)
|
||||
|
|
|
@ -31,7 +31,8 @@ struct RTC_REGS {
|
|||
uint32_t volatile CTRL0; // 0x00
|
||||
uint32_t volatile COUNTER_ALARM; // 0x04
|
||||
uint32_t volatile RESET_REASON0; // 0x08 //FIXME: need better name
|
||||
uint32_t volatile _unknownc[2]; // 0x0c - 0x10
|
||||
uint32_t volatile _unknownc; // 0x0c
|
||||
uint32_t volatile _unknown10; // 0x10
|
||||
uint32_t volatile RESET_REASON1; // 0x14 //FIXME: need better name
|
||||
uint32_t volatile RESET_REASON2; // 0x18 //FIXME: need better name
|
||||
uint32_t volatile COUNTER; // 0x1c
|
||||
|
@ -40,7 +41,10 @@ struct RTC_REGS {
|
|||
uint32_t volatile INT_ENABLE; // 0x28
|
||||
uint32_t volatile _unknown2c; // 0x2c
|
||||
uint32_t volatile SCRATCH[4]; // 0x30 - 3c
|
||||
uint32_t volatile _unknown40[10]; // 0x40 - 0x64
|
||||
uint32_t volatile _unknown40; // 0x40
|
||||
uint32_t volatile _unknown44; // 0x44
|
||||
uint32_t volatile _unknown48; // 0x48
|
||||
uint32_t volatile _unknown4c[7]; // 0x4c - 0x64
|
||||
uint32_t volatile GPIO_OUT; // 0x68
|
||||
uint32_t volatile _unknown6c[2]; // 0x6c - 0x70
|
||||
uint32_t volatile GPIO_ENABLE; // 0x74
|
||||
|
|
39
core/include/esp/sar_regs.h
Normal file
39
core/include/esp/sar_regs.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* esp/sar_regs.h
|
||||
*
|
||||
* ESP8266 register definitions for the "sar" region (0x3FF2xxx)
|
||||
*
|
||||
* The 0x60000D00 register region is referred to as "sar" by some old header
|
||||
* files. Apparently referenced both by ROM I2C functions as well as ADC
|
||||
* config/read functions.
|
||||
*
|
||||
* Not compatible with ESP SDK register access code.
|
||||
*/
|
||||
|
||||
#ifndef _ESP_SAR_REGS_H
|
||||
#define _ESP_SAR_REGS_H
|
||||
|
||||
#include "esp/types.h"
|
||||
#include "common_macros.h"
|
||||
|
||||
#define SAR_BASE 0x60000d00
|
||||
// Unfortunately,
|
||||
// esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr/include/xtensa/config/specreg.h
|
||||
// already has a "SAR" macro definition which would conflict with this, so
|
||||
// we'll use "ESPSAR" instead..
|
||||
#define ESPSAR (*(struct SAR_REGS *)(SAR_BASE))
|
||||
|
||||
/* Note: This memory region is not currently well understood. Pretty much all
|
||||
* of the definitions here are from reverse-engineering the Espressif SDK code,
|
||||
* many are just educated guesses, and almost certainly some are misleading or
|
||||
* wrong. If you can improve on any of this, please contribute!
|
||||
*/
|
||||
|
||||
struct SAR_REGS {
|
||||
uint32_t volatile _unknown0[18]; // 0x00 - 0x44
|
||||
uint32_t volatile UNKNOWN_48; // 0x48 : used by sdk_system_restart_in_nmi()
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
_Static_assert(sizeof(struct SAR_REGS) == 0x4c, "SAR_REGS is the wrong size");
|
||||
|
||||
#endif /* _ESP_SAR_REGS_H */
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
#include "espressif/esp_wifi.h"
|
||||
#include "espressif/spi_flash.h"
|
||||
#include "espressif/phy_info.h"
|
||||
#include "etstimer.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -13,31 +14,38 @@
|
|||
// 'info' is declared in app_main.o at .bss+0x4
|
||||
|
||||
struct sdk_info_st {
|
||||
uint32_t _unknown0;
|
||||
uint32_t _unknown1;
|
||||
uint32_t _unknown2;
|
||||
uint8_t _unknown3[12];
|
||||
uint8_t softap_mac_addr[6];
|
||||
uint8_t sta_mac_addr[6];
|
||||
uint32_t _unknown0; // 0x00
|
||||
uint32_t _unknown4; // 0x04
|
||||
uint32_t _unknown8; // 0x08
|
||||
ip_addr_t ipaddr; // 0x0c
|
||||
ip_addr_t netmask; // 0x10
|
||||
ip_addr_t gw; // 0x14
|
||||
uint8_t softap_mac_addr[6]; // 0x18
|
||||
uint8_t sta_mac_addr[6]; // 0x1e
|
||||
};
|
||||
|
||||
extern struct sdk_info_st sdk_info;
|
||||
|
||||
// 'rst_if' is declared in user_interface.o at .bss+0xfc
|
||||
|
||||
struct sdk_rst_if_st {
|
||||
uint32_t version;
|
||||
uint8_t _unknown[28];
|
||||
};
|
||||
|
||||
extern struct sdk_rst_if_st sdk_rst_if;
|
||||
extern struct sdk_rst_info sdk_rst_if;
|
||||
|
||||
// 'g_ic' is declared in libnet80211/ieee80211.o at .bss+0x0
|
||||
// See also: http://esp8266-re.foogod.com/wiki/G_ic_(IoT_RTOS_SDK_0.9.9)
|
||||
|
||||
struct sdk_g_ic_netif_info {
|
||||
struct netif *netif;
|
||||
//TODO: rest of this structure is unknown.
|
||||
struct netif *netif; // 0x00
|
||||
ETSTimer timer; // 0x04 - 0x20
|
||||
uint8_t _unknown20[28]; // 0x20 - 0x3c
|
||||
uint32_t _unknown3c; // 0x3c (referenced by sdk_wifi_station_disconnect)
|
||||
uint8_t _unknown40[6]; // 0x40 - 0x46
|
||||
uint8_t _unknown46[66]; // 0x46 - 0x88
|
||||
struct sdk_netif_conninfo *_unknown88; // 0x88
|
||||
uint32_t _unknown8c; // 0x8c
|
||||
struct sdk_netif_conninfo *conninfo[6]; // 0x90 - 0xa8
|
||||
uint8_t _unknowna8[16]; // 0xa8 - 0xb8
|
||||
uint8_t _unknownb8; // 0xb8 (referenced by sdk_wifi_station_connect / sdk_wifi_station_disconnect)
|
||||
uint8_t _unknownb9; // 0xb9 (referenced by sdk_wifi_station_connect / sdk_wifi_station_disconnect)
|
||||
uint8_t connect_status; // 0xba (referenced by sdk_system_station_got_ip_set / sdk_wifi_station_disconnect)
|
||||
};
|
||||
|
||||
// This is the portion of g_ic which is not loaded/saved to the flash ROM, and
|
||||
|
@ -197,7 +205,6 @@ extern struct sdk_g_ic_st sdk_g_ic;
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
_Static_assert(sizeof(struct sdk_info_st) == 0x24, "info_st is the wrong size!");
|
||||
_Static_assert(sizeof(struct sdk_rst_if_st) == 0x20, "sdk_rst_if_st is the wrong size!");
|
||||
_Static_assert(sizeof(struct sdk_g_ic_volatile_st) == 0x1d8, "sdk_g_ic_volatile_st is the wrong size!");
|
||||
_Static_assert(sizeof(struct sdk_g_ic_saved_st) == 0x370, "sdk_g_ic_saved_st is the wrong size!");
|
||||
_Static_assert(sizeof(struct sdk_g_ic_st) == 0x548, "sdk_g_ic_st is the wrong size!");
|
||||
|
@ -221,7 +228,6 @@ void sdk_pp_soft_wdt_init(void);
|
|||
int sdk_register_chipv6_phy(sdk_phy_info_t *);
|
||||
void sdk_sleep_reset_analog_rtcreg_8266(void);
|
||||
uint32_t sdk_system_get_checksum(uint8_t *, uint32_t);
|
||||
void sdk_system_restart_in_nmi(void);
|
||||
void sdk_wDevEnableRx(void);
|
||||
void sdk_wDev_Initialize(void);
|
||||
void sdk_wifi_mode_set(uint8_t);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue