void ICACHE_FLASH_ATTR init_done_cb(void) { #if DEBUGSOO > 0 os_printf("\nSDK Init - Ok\nHeap size: %d bytes\n", system_get_free_heap_size()); os_printf("Flash ID: %08x, size: %u\n", spi_flash_get_id(), spi_flash_real_size()); os_printf("Curr cfg size: %d b\n", current_cfg_length()); struct ets_store_wifi_hdr whd; spi_flash_read(((flashchip->chip_size/flashchip->sector_size)-1)*flashchip->sector_size, &whd, sizeof(whd)); os_printf("Last sec rw count: %u\n\n", whd.wr_cnt); #endif // wireless_co2_init(2); // init timer/tasks //ets_set_idle_cb(user_idle, NULL); // do not use sleep mode! // #ifdef USE_WEB web_fini(sysinifname); #endif switch(system_get_rst_info()->reason) { case REASON_SOFT_RESTART: case REASON_DEEP_SLEEP_AWAKE: break; default: New_WiFi_config(WIFI_MASK_ALL); break; } #ifdef USE_RS485DRV rs485_drv_start(); init_mdbtab(); #endif }
int8_t ICACHE_FLASH_ATTR cb_flash_read_all(uint8_t IsFirstCall, char* OutputData, uint16_t MaxBytes, uint16_t* RetBytes, uint8_t* RetDone){ /* TAG CALLBACK FUNCTION for [[FLASH_READ_ALL]] * -------------------------------------------- * ! See whttpd_pp_item_struct structure definition to know what is passed to / what is expected from tag callback function. * ! This function could be called multiple times for one tag, if we signal by RetDone that we didn't end yet (probably because MaxBytes was less that what we needed). */ *RetBytes = 0; *RetDone = 0; if(IsFirstCall) cb_fra_CopiedBytes = 0; // uint32_t ID = spi_flash_get_id(); uint32_t FlashSizeB = ((uint32_t)1)<<((uint8_t*)&ID)[2]; //flash size in bytes MaxBytes &= 0xFFFC; //mask out 2 last bits - the same like MaxBytes = (MaxBytes/4)*4 if(MaxBytes==0) return 0; //we are not able to read at least 4 bytes - not enough space in OutputData => skip this call, report no error (don't abort tag preprocessing - it will be called again with more MaxBytes) // //this code using spi_flash_read(...) crashes - why? reads are 4-bytes aligned //if(spi_flash_read(cb_get_flash_download_CopiedBytes, (uint32_t*)OutputData, MaxBytes)!=SPI_FLASH_RESULT_OK) return -1; //error (abort tag preprocessing) //cb_get_flash_download_CopiedBytes += MaxBytes; // //read flash exactly like in wfof.c (after many experiments, this is the code that doesn't crash) uint32_t U32Tmp; uint16_t Cnt = 0; while((Cnt<MaxBytes)&&(cb_fra_CopiedBytes<FlashSizeB)){ U32Tmp = *((uint32_t*)(cb_fra_CopiedBytes+WHTTPD_SPIFLASH_OFFS)); memcpy(&OutputData[Cnt], &U32Tmp, 4); cb_fra_CopiedBytes += 4; Cnt += 4; } *RetBytes += Cnt; // if(cb_fra_CopiedBytes>=FlashSizeB) *RetDone = 1; if(*RetDone) cb_fra_CopiedBytes = 0; //reset for next start (if the tag is multiple times in the preprocessed input data) return 0; //no error (don't abort tag preprocessing) }
int8_t ICACHE_FLASH_ATTR cb_fota_slot_in_use_info(uint8_t IsFirstCall, char* OutputData, uint16_t MaxBytes, uint16_t* RetBytes, uint8_t* RetDone){ /* TAG CALLBACK FUNCTION for [[FOTA_SLOT_IN_USE_INFO]] * -------------------------------------------- * ! See whttpd_pp_item_struct structure definition to know what is passed to / what is expected from tag callback function. * ! This function could be called multiple times for one tag, if we signal by RetDone that we didn't end yet (probably because MaxBytes was less that what we needed). */ //allocate memory for OutString (local) char* OutString = malloc(30); if(OutString==NULL){ *RetBytes = 0; *RetDone = 1; return -1; } if(IsFirstCall) cb_fsiui_CopiedBytes = 0; // //>> ---- generate whole OutString (enter your code here) uint32_t StartAddr = system_get_userbin_addr(); //slot in use uint32_t ID = spi_flash_get_id(); uint32_t FlashSizeB = ((uint32_t)1)<<((uint8_t*)&ID)[2]; //flash size in bytes uint32_t Len = (FlashSizeB/2) - ((StartAddr>(FlashSizeB/2))?StartAddr-(FlashSizeB/2):StartAddr) - 0x04000; //(FlashSizeB/2) - start offset of usercode - 16 kB for system parameter area sprintf(OutString, "0x%05X - 0x%05X, %d kB", StartAddr, StartAddr+Len-1, Len/1024); //<< ---- // whttpd_preproc_manage_cb_output(OutputData, OutString, &cb_fsiui_CopiedBytes, MaxBytes, RetBytes, RetDone); //output into OutputData (if MaxBytes is less than size of our data, manage subsequent chunked output throughout more calls of this tag callback function using global variable *_CopiedBytes) free(OutString); //free allocated memory return 0; //no error (don't abort tag preprocessing) }
LOCAL void ICACHE_FLASH_ATTR initDone_cb() { CFG_Load(); os_printf("\n%s starting ...\n", sysCfg.deviceName); MQTT_InitConnection(&mqttClient, sysCfg.mqtt_host, sysCfg.mqtt_port, sysCfg.security); MQTT_InitClient(&mqttClient, sysCfg.device_id, sysCfg.mqtt_user, sysCfg.mqtt_pass, sysCfg.mqtt_keepalive, 1); char temp[100]; os_sprintf(temp, "/Raw/%s/offline", sysCfg.device_id); MQTT_InitLWT(&mqttClient, temp, "offline", 0, 0); MQTT_OnConnected(&mqttClient, mqttConnectedCb); MQTT_OnDisconnected(&mqttClient, mqttDisconnectedCb); MQTT_OnData(&mqttClient, mqttDataCb); os_printf("SDK version is: %s\n", system_get_sdk_version()); os_printf("Smart-Config version is: %s\n", smartconfig_get_version()); system_print_meminfo(); os_printf("Flash size map %d; id %lx\n", system_get_flash_size_map(), spi_flash_get_id()); WIFI_Connect(sysCfg.sta_ssid, sysCfg.sta_pwd, sysCfg.deviceName, wifiConnectCb); lcdInit(); lightOn(); showString(1, 1, "MQTT Monitor"); }
void ShowInfo() { Serial.printf("\r\nSDK: v%s\r\n", system_get_sdk_version()); Serial.printf("Free Heap: %d\r\n", system_get_free_heap_size()); Serial.printf("CPU Frequency: %d MHz\r\n", system_get_cpu_freq()); Serial.printf("System Chip ID: %x\r\n", system_get_chip_id()); Serial.printf("SPI Flash ID: %x\r\n", spi_flash_get_id()); //Serial.printf("SPI Flash Size: %d\r\n", (1 << ((spi_flash_get_id() >> 16) & 0xff))); }
// Main routine to initialize esp-link. void user_init(void) { // get the flash config so we know how to init things //configWipe(); // uncomment to reset the config for testing purposes bool restoreOk = configRestore(); // Init gpio pin registers gpio_init(); gpio_output_set(0, 0, 0, (1<<15)); // some people tie it to GND, gotta ensure it's disabled // init UART uart_init(flashConfig.baud_rate, 115200); logInit(); // must come after init of uart // Say hello (leave some time to cause break in TX after boot loader's msg os_delay_us(10000L); os_printf("\n\n** %s\n", esp_link_version); os_printf("Flash config restore %s\n", restoreOk ? "ok" : "*FAILED*"); // Status LEDs statusInit(); serledInit(); // Wifi wifiInit(); // init the flash filesystem with the html stuff espFsInit(&_binary_espfs_img_start); //EspFsInitResult res = espFsInit(&_binary_espfs_img_start); //os_printf("espFsInit %s\n", res?"ERR":"ok"); // mount the http handlers httpdInit(builtInUrls, 80); // init the wifi-serial transparent bridge (port 23) serbridgeInit(23, 2323); uart_add_recv_cb(&serbridgeUartCb); #ifdef SHOW_HEAP_USE os_timer_disarm(&prHeapTimer); os_timer_setfn(&prHeapTimer, prHeapTimerCb, NULL); os_timer_arm(&prHeapTimer, 10000, 1); #endif struct rst_info *rst_info = system_get_rst_info(); NOTICE("Reset cause: %d=%s", rst_info->reason, rst_codes[rst_info->reason]); NOTICE("exccause=%d epc1=0x%x epc2=0x%x epc3=0x%x excvaddr=0x%x depc=0x%x", rst_info->exccause, rst_info->epc1, rst_info->epc2, rst_info->epc3, rst_info->excvaddr, rst_info->depc); uint32_t fid = spi_flash_get_id(); NOTICE("Flash map %s, manuf 0x%02lX chip 0x%04lX", flash_maps[system_get_flash_size_map()], fid & 0xff, (fid&0xff00)|((fid>>16)&0xff)); NOTICE("** esp-link ready"); // Init SNTP service cgiServicesSNTPInit(); #ifdef MQTT NOTICE("initializing MQTT"); mqtt_client_init(); #endif NOTICE("initializing user application"); app_init(); NOTICE("Waiting for work to do..."); }
static int node_info( lua_State* L ) { lua_pushinteger(L, NODE_VERSION_MAJOR); lua_pushinteger(L, NODE_VERSION_MINOR); lua_pushinteger(L, NODE_VERSION_REVISION); lua_pushinteger(L, system_get_chip_id()); // chip id lua_pushinteger(L, spi_flash_get_id()); // flash id lua_pushinteger(L, flash_get_size_byte() / 1024); // flash size in KB lua_pushinteger(L, flash_get_mode()); lua_pushinteger(L, flash_get_speed()); return 8; }
/** * Dump the ESP8266 restart information. * This is purely for debugging. * When an ESP8266 crashes, before it ends, it records its exception information. * This function retrieves that data and logs it. */ static void dumpRestart() { struct rst_info *rstInfo = system_get_rst_info(); os_printf("Restart info:\n"); os_printf(" reason: %d=%s\n", rstInfo->reason, rst_codes[rstInfo->reason]); os_printf(" exccause: %x\n", rstInfo->exccause); os_printf(" epc1: %x\n", rstInfo->epc1); os_printf(" epc2: %x\n", rstInfo->epc2); os_printf(" epc3: %x\n", rstInfo->epc3); os_printf(" excvaddr: %x\n", rstInfo->excvaddr); os_printf(" depc: %x\n", rstInfo->depc); uint32_t fid = spi_flash_get_id(); os_printf("Flash map %s, manuf 0x%02lX chip 0x%04lX\n", flash_maps[system_get_flash_size_map()], fid & 0xff, (fid&0xff00)|((fid>>16)&0xff)); }
static int node_info( lua_State* L ) { lua_pushinteger(L, NODE_VERSION_MAJOR); lua_pushinteger(L, NODE_VERSION_MINOR); lua_pushinteger(L, NODE_VERSION_REVISION); lua_pushinteger(L, system_get_chip_id()); // chip id lua_pushinteger(L, spi_flash_get_id()); // flash id #if defined(FLASH_SAFE_API) lua_pushinteger(L, flash_safe_get_size_byte() / 1024); // flash size in KB #else lua_pushinteger(L, flash_rom_get_size_byte() / 1024); // flash size in KB #endif // defined(FLASH_SAFE_API) lua_pushinteger(L, flash_rom_get_mode()); lua_pushinteger(L, flash_rom_get_speed()); return 8; }
//Main routine. Initialize stdout, the I/O, filesystem and the webserver and we're done. void user_init(void) { // get the flash config so we know how to init things //configWipe(); // uncomment to reset the config for testing purposes bool restoreOk = configRestore(); // init gpio pin registers gpio_init(); // init UART uart_init(flashConfig.baud_rate, 115200); logInit(); // must come after init of uart // say hello (leave some time to cause break in TX after boot loader's msg os_delay_us(10000L); os_printf("\n\n** %s\n", esp_link_version); os_printf("Flash config restore %s\n", restoreOk ? "ok" : "*FAILED*"); // Status LEDs statusInit(); serledInit(); // Wifi wifiInit(); // init the flash filesystem with the html stuff espFsInit(&_binary_espfs_img_start); //EspFsInitResult res = espFsInit(&_binary_espfs_img_start); //os_printf("espFsInit %s\n", res?"ERR":"ok"); // mount the http handlers httpdInit(builtInUrls, 80); // init the wifi-serial transparent bridge (port 23) serbridgeInit(23); uart_add_recv_cb(&serbridgeUartCb); #ifdef SHOW_HEAP_USE os_timer_disarm(&prHeapTimer); os_timer_setfn(&prHeapTimer, prHeapTimerCb, NULL); os_timer_arm(&prHeapTimer, 10000, 1); #endif struct rst_info *rst_info = system_get_rst_info(); os_printf("Reset cause: %d=%s\n", rst_info->reason, rst_codes[rst_info->reason]); os_printf("exccause=%d epc1=0x%x epc2=0x%x epc3=0x%x excvaddr=0x%x depc=0x%x\n", rst_info->exccause, rst_info->epc1, rst_info->epc2, rst_info->epc3, rst_info->excvaddr, rst_info->depc); os_printf("Flash map %d, chip %08X\n", system_get_flash_size_map(), spi_flash_get_id()); os_printf("** esp-link ready\n"); }
void ShowInfo() { Serial.printf("\r\nSDK: v%s\r\n", system_get_sdk_version()); Serial.printf("Free Heap: %d\r\n", system_get_free_heap_size()); Serial.printf("CPU Frequency: %d MHz\r\n", system_get_cpu_freq()); Serial.printf("System Chip ID: %x\r\n", system_get_chip_id()); Serial.printf("SPI Flash ID: %x\r\n", spi_flash_get_id()); //Serial.printf("SPI Flash Size: %d\r\n", (1 << ((spi_flash_get_id() >> 16) & 0xff))); Vector<String> files = fileList(); if (files.count() > 0) { Serial.println("\n\rSpiff files:"); Serial.println("----------------------------"); { for (int i = 0; i < files.count(); i++) { Serial.println(files[i]); } } Serial.println("----------------------------"); } else { Serial.println("Empty spiffs!"); } }
int8_t ICACHE_FLASH_ATTR cb_flash_get_info(uint8_t IsFirstCall, char* OutputData, uint16_t MaxBytes, uint16_t* RetBytes, uint8_t* RetDone){ /* TAG CALLBACK FUNCTION for [[FLASH_GET_INFO]] * -------------------------------------------- * ! See whttpd_pp_item_struct structure definition to know what is passed to / what is expected from tag callback function. * ! This function could be called multiple times for one tag, if we signal by RetDone that we didn't end yet (probably because MaxBytes was less that what we needed). */ //allocate memory for OutString (local) char* OutString = malloc(35); if(OutString==NULL){ *RetBytes = 0; *RetDone = 1; return -1; } if(IsFirstCall) cb_fgi_CopiedBytes = 0; // //>> ---- generate whole OutString (enter your code here) uint32_t ID = spi_flash_get_id(); sprintf(OutString, "Size: %d kB, ID: 0x%08X", (((uint32_t)1)<<((uint8_t*)&ID)[2])/1024, ID); //<< ---- // whttpd_preproc_manage_cb_output(OutputData, OutString, &cb_fgi_CopiedBytes, MaxBytes, RetBytes, RetDone); //output into OutputData (if MaxBytes is less than size of our data, manage subsequent chunked output throughout more calls of this tag callback function using global variable *_CopiedBytes) free(OutString); //free allocated memory return 0; //no error (don't abort tag preprocessing) }
// Main routine to initialize esp-link. void ICACHE_FLASH_ATTR user_init(void) { // Init gpio pin registers gpio_init(); gpio_output_set(0, 0, 0, (1<<15)); // some people tie it to GND, gotta ensure it's disabled // init UART uart_init(115200); // Say hello (leave some time to cause break in TX after boot loader's msg os_delay_us(10000L); NOTICE("\n\n** %s\n", esp_link_version); // Wifi wifiInit(); // mount the http handlers httpdInit(builtInUrls, 80); struct rst_info *rst_info = system_get_rst_info(); NOTICE("Reset cause: %d=%s", rst_info->reason, rst_codes[rst_info->reason]); NOTICE("exccause=%d epc1=0x%x epc2=0x%x epc3=0x%x excvaddr=0x%x depc=0x%x", rst_info->exccause, rst_info->epc1, rst_info->epc2, rst_info->epc3, rst_info->excvaddr, rst_info->depc); uint32_t fid = spi_flash_get_id(); NOTICE("Flash map %s, manuf 0x%02lX chip 0x%04lX", flash_maps[system_get_flash_size_map()], fid & 0xff, (fid&0xff00)|((fid>>16)&0xff)); }
uint32_t flashmem_read_internal( void *to, uint32_t fromaddr, uint32_t size ) { fromaddr -= INTERNAL_FLASH_START_ADDRESS; SpiFlashOpResult r; // WRITE_PERI_REG(0x60000914, 0x73); r = spi_flash_read(fromaddr, (uint32 *)to, size); if(SPI_FLASH_RESULT_OK == r) return size; else{ SYSTEM_ERROR( "ERROR in flash_read: r=%d at %08X, size = %d, id = %d \r\n", ( int )r, ( unsigned )fromaddr, size, spi_flash_get_id ()); return 0; } }
// Lua: flashid() static int node_flashid( lua_State* L ) { uint32_t id = spi_flash_get_id(); lua_pushinteger( L, id ); return 1; }
irom void stats_generate(uint16_t size, char *dst) { const struct rst_info *rst_info; struct station_config sc_default, sc_current; uint32_t system_time; system_time = system_get_time(); rst_info = system_get_rst_info(); wifi_station_get_config_default(&sc_default); wifi_station_get_config(&sc_current); snprintf(dst, size, "> firmware version date: %s\n" "> system id: %u\n" "> spi flash id: %u\n" "> cpu frequency: %u\n" "> flash map: %s\n" "> reset cause: %s\n" ">\n" "> heap free: %u bytes\n" "> system clock: %u.%06u s\n" "> uptime: %u %02d:%02d:%02d\n" "> real time: %u %02d:%02d:%02d\n" "> size of config: %u\n" ">\n" "> int uart rx: %u\n" "> int uart tx: %u\n" "> timer_fast fired: %u\n" "> timer_slow fired: %u\n" "> timer_second fired: %u\n" "> background task: %u\n" ">\n" "> default ssid: %s, passwd: %s\n" "> current ssid: %s, passwd: %s\n" "> phy mode: %s\n" "> sleep mode: %s\n" "> channel: %u\n" "> signal strength: %d dB\n", __DATE__ " " __TIME__, system_get_chip_id(), spi_flash_get_id(), system_get_cpu_freq(), flash_map[system_get_flash_size_map()], reset_map[rst_info->reason], system_get_free_heap_size(), system_time / 1000000, system_time % 1000000, ut_days, ut_hours, ut_mins, ut_secs, rt_days, rt_hours, rt_mins, rt_secs, sizeof(config_t), stat_uart_rx_interrupts, stat_uart_tx_interrupts, stat_timer_fast, stat_timer_slow, stat_timer_second, stat_background_task, sc_default.ssid, sc_default.password, sc_current.ssid, sc_current.password, phy[wifi_get_phy_mode()], slp[wifi_get_sleep_type()], wifi_get_channel(), wifi_station_get_rssi()); }
/****************************************************************************** * FunctionName : udp_test_port_recv * Returns : none *******************************************************************************/ LOCAL void ICACHE_FLASH_ATTR udp_test_port_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, ip_addr_t *addr, u16_t port) { uint8 usrdata[32]; if (p == NULL) return; if(p->tot_len < 2) { pbuf_free(p); return; } uint16 length = mMIN(p->tot_len, sizeof(usrdata)-1); #if DEBUGSOO > 0 os_printf("udp " IPSTR ":%u [%d]\n", IP2STR(addr), port, p->tot_len); #endif length = pbuf_copy_partial(p, usrdata, length, 0); pbuf_free(p); uint8 *pudpbuf = (uint8 *)os_zalloc(udpbufsize+1); if(pudpbuf == NULL) return; uint16 udpbuflen = 0; int x = 0; if(length>2) x = atoi((char *)&usrdata[2]); if ((length>1)&&(usrdata[1]=='?')) switch(usrdata[0]) { case 'M': system_print_meminfo(); case 'A': { udp_puts("\nChip_id: %08x Flash_id: %08x\nsys_time:%08x ADC:%d\n", system_get_chip_id(), spi_flash_get_id(), system_get_time(), system_adc_read()); struct softap_config wiconfig; wifi_softap_get_config(&wiconfig); udp_puts("OPMode:%u SSID:'%s' Pwd:'%s' Ch:%u Authmode:%u MaxCon:%u Phu:%u ACon:%u\n", wifi_get_opmode(), wiconfig.ssid, wiconfig.password, wiconfig.channel, wiconfig.authmode, wiconfig.max_connection, wifi_get_phy_mode(), wifi_station_get_auto_connect()); udp_puts("Connect status:%u\n", wifi_station_get_connect_status()); }; case 'I': udp_puts("heapsize: %d\n", system_get_free_heap_size() + udpbufsize); udpbuflen += print_udp_psc(pudpbuf+udpbuflen, udpbufsize-udpbuflen); udpbuflen += print_tcp_psc(pudpbuf+udpbuflen, udpbufsize-udpbuflen); udpbuflen += chow_tcp_connection_info(pudpbuf+udpbuflen, udpbufsize-udpbuflen); break; case 'H': udp_puts("heapsize: %d\n", system_get_free_heap_size() + udpbufsize); break; case 'U': udp_puts("heapsize: %d\n", system_get_free_heap_size() + udpbufsize); udpbuflen += print_udp_psc(pudpbuf+udpbuflen, udpbufsize-udpbuflen); break; case 'T': udp_puts("heapsize: %d\n", system_get_free_heap_size() + udpbufsize); udpbuflen += print_tcp_psc(pudpbuf+udpbuflen, udpbufsize-udpbuflen); break; #ifdef USE_SRV_WEB_PORT case 'S': udp_puts("heapsize: %d\n", system_get_free_heap_size() + udpbufsize); udpbuflen += chow_tcp_connection_info(pudpbuf+udpbuflen, udpbufsize-udpbuflen); break; #endif case 'R': system_restart(); break; case 'P': udp_puts("system_set_os_print(%u)\n", x); system_set_os_print(x); break; case 'O': udp_puts("wifi_set_opmode(%u):%u\n", x, wifi_set_opmode(x)); break; case 'B': udp_puts("wifi_station_set_auto_connect(%u):%u\n", x, wifi_station_set_auto_connect(x)); break; case 'D': switch(x) { case 0: udp_puts("wifi_station_dhcpc_start:%u\n", wifi_station_dhcpc_start()); break; case 1: udp_puts("wifi_station_dhcpc_stop:%u\n", wifi_station_dhcpc_stop()); break; case 2: udp_puts("wifi_softap_dhcps_start:%u\n",wifi_softap_dhcps_start()); break; case 3: udp_puts("wifi_softap_dhcps_stop:%u\n", wifi_softap_dhcps_stop()); break; default: udp_puts("D(%u)?\n", x); } break; case 'F': if(flashchip != NULL) { udp_puts("FlashID: 0x%08x\nChip size: %d\nBlock size: %d\nSector size: %d\nPage size: %d\nStatus mask: 0x%08x\n", flashchip->deviceId, flashchip->chip_size, flashchip->block_size, flashchip->sector_size, flashchip->page_size, flashchip->status_mask ); udp_puts("Real Flash size: %u\n", spi_flash_real_size()); } else udp_puts("Unknown Flash type!\n"); break; case 'E': udp_puts("wifi_set_sleep_type(%d):%u\n", x, wifi_set_sleep_type(x)); break; case 'G': udp_puts("g_ic = %p\n", &g_ic); break; default: udp_puts("???\n"); } if(udpbuflen) { struct pbuf *z = pbuf_alloc(PBUF_TRANSPORT, udpbuflen, PBUF_RAM); if(z != NULL) { err_t err = pbuf_take(z, pudpbuf, udpbuflen); os_free(pudpbuf); if(err == ERR_OK) { udp_sendto(upcb, z, addr, port); } pbuf_free(z); return; } } os_free(pudpbuf); }
// Main routine to initialize esp-link. void user_init(void) { // get the flash config so we know how to init things // configWipe(); // uncomment to reset the config for testing purposes bool restoreOk = configRestore(); // init gpio pin registers gpio_init(); gpio_output_set(0, 0, 0, (1<<15)); // some people tie it to GND, gotta ensure it's disabled // init UART uart_init(flashConfig.baud_rate, 115200); logInit(); // must come after init of uart // say hello (leave some time to cause break in TX after boot loader's msg os_delay_us(10000L); os_printf("\n\n** %s\n", esp_link_version); os_printf("Flash config restore %s\n", restoreOk ? "ok" : "*FAILED*"); #if defined(STA_SSID) && defined(STA_PASS) int x = wifi_get_opmode() & 0x3; if (x == 2) { // we only force the STA settings when a full flash of the module has been made, which // resets the wifi settings not to have anything configured struct station_config stconf; wifi_station_get_config(&stconf); if (os_strlen((char*)stconf.ssid) == 0 && os_strlen((char*)stconf.password) == 0) { os_strncpy((char*)stconf.ssid, VERS_STR(STA_SSID), 32); os_strncpy((char*)stconf.password, VERS_STR(STA_PASS), 64); #ifdef CGIWIFI_DBG os_printf("Wifi pre-config trying to connect to AP %s pw %s\n", (char*)stconf.ssid, (char*)stconf.password); #endif wifi_set_opmode(3); // sta+ap, will switch to sta-only 15 secs after connecting stconf.bssid_set = 0; wifi_station_set_config(&stconf); } } #endif // Status LEDs statusInit(); serledInit(); // Wifi wifiInit(); // init the flash filesystem with the html stuff espFsInit(&_binary_espfs_img_start); //EspFsInitResult res = espFsInit(&_binary_espfs_img_start); //os_printf("espFsInit %s\n", res?"ERR":"ok"); // mount the http handlers httpdInit(builtInUrls, 80); // init the wifi-serial transparent bridge (port 23) serbridgeInit(23, 2323); uart_add_recv_cb(&serbridgeUartCb); #ifdef SHOW_HEAP_USE os_timer_disarm(&prHeapTimer); os_timer_setfn(&prHeapTimer, prHeapTimerCb, NULL); os_timer_arm(&prHeapTimer, 10000, 1); #endif struct rst_info *rst_info = system_get_rst_info(); NOTICE("Reset cause: %d=%s", rst_info->reason, rst_codes[rst_info->reason]); NOTICE("exccause=%d epc1=0x%x epc2=0x%x epc3=0x%x excvaddr=0x%x depc=0x%x", rst_info->exccause, rst_info->epc1, rst_info->epc2, rst_info->epc3, rst_info->excvaddr, rst_info->depc); uint32_t fid = spi_flash_get_id(); NOTICE("Flash map %s, manuf 0x%02lX chip 0x%04lX", flash_maps[system_get_flash_size_map()], fid & 0xff, (fid&0xff00)|((fid>>16)&0xff)); NOTICE("** esp-link ready"); cgiServicesSNTPInit(); #ifdef MQTT NOTICE("initializing MQTT"); mqtt_client_init(); #endif NOTICE("initializing user application"); app_init(); NOTICE("waiting for work to do..."); }
STATIC mp_obj_t esp_flash_id() { return mp_obj_new_int(spi_flash_get_id()); }
uint32_t EspClass::getFlashChipId(void) { return spi_flash_get_id(); }