Page 1 of 1

RTOS_SDK last commit ShowCritical

Posted: Tue May 30, 2017 11:36 am
by gustavomassa
Hello,

The RTOS_SDK last commit e1e17a1to (wujiangang sync: from 61124bba)
1. driver:
1). Fix hw_timer issue, #96;
2). Fix SPI output data error;
3). Fix SPI read data bug;
4). Fix driver lib compile issue;
5). Fix uart flow control issue;

2. lwip:
1). Enable lwip ETHARP_TRUS_IP_MAC;
2). Modify dhcp/dhcps timer from 60 seconds to 1 second;

3. WiFi:
1). Support CSA;

is unstable, it is running on ShowCritical: 0 trap during the wifi station/ap scan.
These are the files that are generating the problem:
files.png
files.png (11.14 KiB) Viewed 1162 times


UPDATE: The problem is not related to the lwip lib, I updated the dhcpserver files and lwip.a and the wifi is working fine.
The problem is related to libmain, lib80211 and libpp

Please investigate.

Regards

Re: RTOS_SDK last commit ShowCritical

Posted: Tue May 30, 2017 2:23 pm
by backupluis
I have the same problem:

Before update:
entry station mode to connect server
bcn 0
del if1
mode : sta(5c:aa:dd:00:12:19)

scandone
state: 0 -> 2 (b0)
Ustate: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2
pm open phy_2,type:2 0 0
cnt

After update:
mode : sta(5c:aa:dd:00:12:19) + softAP(5c:aa:dd:00:12:19)
add if0
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
add if1
bcn 100

entry station mode to connect server
bcn 0
del if1
mode : sta(5c:aa:dd:00:12:19)
scandone
ShowCritical:0

Re: RTOS_SDK last commit ShowCritical

Posted: Wed May 31, 2017 5:03 pm
by ESP_Faye
Hi,

Can you provide the test code for debugging?

Thanks for your interest in ESP8266!

Re: RTOS_SDK last commit ShowCritical

Posted: Thu Jun 01, 2017 2:21 am
by gustavomassa
Hi Faye,

Here is an example:

Code: Select all

#include "espressif/esp_libc.h"
#include "espressif/esp_misc.h"
#include "espressif/esp_common.h"
#include "espressif/esp_wifi.h"
#include "espressif/esp_sta.h"
#include "uart.h"
#include "user_config.h"

#ifdef DEBUG
#include "gdbstub/gdbstub.h"
#endif

bool wifi_set_mode(WIFI_MODE mode){
    if(!mode){
        bool s = wifi_set_opmode(mode);
        wifi_fpm_open();
        wifi_fpm_set_sleep_type(MODEM_SLEEP_T);
        wifi_fpm_do_sleep(0xFFFFFFFF);
        wifi_fpm_close();
        return s;
    }
    return wifi_set_opmode(mode);
}

bool wifi_start_station(const char * ssid, const char * pass) {
    if(!ssid || strcmp(ssid, "") == 0){
       IOT_ERROR("NULL/Empty ssid");
        return false;
    }

    WIFI_MODE mode = wifi_get_opmode();
    if((mode & STATION_MODE) == 0){
        mode |= STATION_MODE;
        if(!wifi_set_mode(mode)){
            IOT_ERROR("Failed to enable Station mode");
            return false;
        }
    }
    struct station_config config;
    memset(&config, 0, sizeof(struct station_config));
    strcpy((char *)config.ssid, ssid);
    if(pass){
        strcpy((char *)config.password, pass);
    }
    if(!wifi_station_set_config(&config)){
       IOT_ERROR("Failed to set Station config");
        return false;
    }

    if(!wifi_station_dhcpc_status()){
       IOT_DEBUG("DHCP client is not started, starting it...");
        if(!wifi_station_dhcpc_start()){
           IOT_ERROR("DHCP client start failed");
            return false;
        }
    }

    IOT_DEBUG("Entered here!");
   
    //IT IS FAILING HERE AND RETURNING FALSE
    return wifi_station_connect();
}

bool wifi_stop_ap() {
    WIFI_MODE mode = wifi_get_opmode();
    mode &= ~SOFTAP_MODE;
    if(!wifi_set_mode(mode)){
       IOT_ERROR("Failed to disable AP mode");
        return false;
    }
    return true;
}

void user_init(void) {
   uart_init();

   #ifdef DEBUG
   gdbstub_init();
   #endif
   
   IOT_DEBUG("SDK version: %s", system_get_sdk_version());

   bool test = wifi_stop_ap();
   if(!test) {
      IOT_ERROR("Failed to stop softAP mode");
   }

   test = wifi_start_station("MassaHome", "Massaneirohome1607");
   if(!test) {
       IOT_ERROR("Failed to connect to network");
   }
}


Used flags:

Code: Select all

SDK_INCDIR   = include extra_include include/espressif include/nopoll include/json include/udhcp include/lwip include/lwip/lwip include/lwip/ipv4 include/lwip/ipv6 include/mbedtls
LIBS = c gcc hal phy pp net80211 wpa main freertos lwip minic crypto mbedtls
LDFLAGS      = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,--gc-sections
LD_SCRIPT   = eagle.app.v6.ld
MODULES   = src/user gdbstub
CFLAGS      = -g -Og -ggdb -DDEBUG -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -fno-builtin-printf -fno-jump-tables -DICACHE_FLASH -D__STDC_NO_ATOMICS__=1 -DESP8266_RTOS -D__STDC_VERSION__=201112L -DFREERTOS_ARCH_ESP8266


Output:

Code: Select all

445,692 (gdb)
445,711 @"(user_init) 4577081 - SDK versio"
445,715 @"n: 1.5.0-dev(1aafc07)\n"
445,721 @"(wifi_start_station) 4577563 - E"
445,723 @"ntered here!\n"
445,729 @"(user_init) 4585115 - ERROR(L#14"
445,735 @"9): Failed to connect to network"
445,736 @"\n"
445,741 @"mode : sta(5c:cf:7f:0f:08:eb)\n"
445,743 @"add if0\n"
447,863 @"scandone\n"
451,307 @"ShowCritical:1\n"
451,505 ~"\nProgram received signal "
451,505 ~"SIGTRAP, Trace/breakpoint trap.\n"
451,505 ~"gdbstub_do_break_breakpoint_addr () at gdbstub/gdbstub-entry.S:399\n"
451,508 ~"399\t\tbreak 0,0\n"


OBS: The network that ESP8266 STATION MODE is going to connect must exist to reproduce the error.
OBS2: This example works fine using the old version of libmain, libpp and lib80211.

Another question, can you folks please improve the port.c file from RTOS_SDK/third_party/freertos, that file is really a mess, there are a lot of commented code inside it... Also please update the ShowCritical() function to use os_printf instead of ets_printf, and print the entire stack, so we can see where the problem is hapenning...

Code: Select all

void ShowCritical(void)
{
    ets_printf("ShowCritical:%d\n",uxCriticalNesting);
    ets_delay_us(50000);
}


Thanks

Re: RTOS_SDK last commit ShowCritical

Posted: Fri Jun 02, 2017 5:48 am
by backupluis
One more vote for this:

Please improve the port.c file from RTOS_SDK/third_party/freertos
Update the ShowCritical() function to use os_printf instead of ets_printf, and print the entire stack

And please, can you remove the "pwm version nnnn" from pwm library.

Thanks.

Re: RTOS_SDK last commit ShowCritical

Posted: Mon Jun 12, 2017 9:22 am
by gustavomassa
After the lastest commit the "ShowCritical" bug that was occurring during the wifi scan was partially fixed, sometimes it is still happening.

Code: Select all

231,694 (gdb)
231,713 @"(user_init) 124189383 - SDK vers"
231,717 @"ion: 1.5.0-dev(1aafc07)\n"
231,723 @"(user_init) 124190051 - Free hea"
231,727 @"p size: 38920\n"
231,732 @"mode : sta(5c:cf:7f:0f:08:eb)\n"
231,734 @"add if0\n"
235,310 @"ShowCritical:0\n"


Also sometimes while debugging the code using gdbstub, I face the ShowCritical: 0 and ShowCritical: 1 messages, something related to the freeRTOS scheduler, probably during the context switch/vPortMalloc/vPortEnterCritical/vPortExitCritical.
Please update the port.c file with the ShowCritical function to include the entire stack on the print.

Re: RTOS_SDK last commit ShowCritical

Posted: Sun Sep 10, 2017 1:12 am
by ritesh
Hi,

We are using ESP8266 RTOS SDK 1.5.0 in which we have faced ShowCritical:1 issue and after that Board restarted due to Watchdog Reset Reason.

So, Here We are using some spi_flash_write APIs in which we have put xTaskEnterCritical and xTaskExitCritical while writing any data into ESP8266 SPI Flash Memory.

So, how to recover that issue if anyone knows about that?