Works on Sparkfun Thing, but fails on custom ESP-Wroom-32

Scalpel78
Posts: 51
Joined: Sun Feb 26, 2017 7:31 am

Works on Sparkfun Thing, but fails on custom ESP-Wroom-32

Postby Scalpel78 » Tue Mar 07, 2017 8:39 pm

Hi,
first a disclaimer - my problem might be related to my own poorly designed PCB, but I'm not sure so I'll ask.

I've made a custom PCB for an ESP-WROOM-32. I've gotten two testprograms, that both work on my Sparkfun Thing, to work. One is a Blinky app, and the other has an interrupt that reacts when a button is clicked. Since both those two programs work just like they are supposed to then I'm fairly sure that my custom circuitboard is not 100% broken :)

The third app I want to try is this. It is a simple WiFi program.

Code: Select all

#include "freertos/FreeRTOS.h"
#include "esp_wifi.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_event_loop.h"
#include "nvs_flash.h"
#include "driver/gpio.h"

esp_err_t event_handler(void *ctx, system_event_t *event)
{
    return ESP_OK;
}

void app_main(void)
{
    nvs_flash_init();
    tcpip_adapter_init();
    ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
    wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
    ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
    ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
    ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
    wifi_config_t sta_config = {
        .sta = {
            .ssid = "Skynet",
            .password = "secret",
            .bssid_set = false
        }
    };
    ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &sta_config) );
    ESP_ERROR_CHECK( esp_wifi_start() );
    ESP_ERROR_CHECK( esp_wifi_connect() );

    gpio_set_direction(GPIO_NUM_23, GPIO_MODE_OUTPUT);
    int level = 0;
    while (true) {
        gpio_set_level(GPIO_NUM_23, level);
        level = !level;
        vTaskDelay(300 / portTICK_PERIOD_MS);
    }
}

When I run it on my Sparkfun Thing I get this output:

Code: Select all

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0x00
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0008,len:8
load:0x3fff0010,len:3488
load:0x40078000,len:7804
load:0x40080000,len:252
entry 0x40080034
I (29) boot: ESP-IDF v2.0-rc1-154-g3b8c9a4 2nd stage bootloader
I (29) boot: compile time 23:50:55
I (63) boot: Enabling RNG early entropy source...
I (63) boot: SPI Speed      : 40MHz
I (63) boot: SPI Mode       : DIO
I (74) boot: SPI Flash Size : 4MB
I (86) boot: Partition Table:
I (97) boot: ## Label            Usage          Type ST Offset   Length
I (120) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (143) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (166) boot:  2 factory          factory app      00 00 00010000 00100000
I (190) boot: End of partition table
I (203) boot: Disabling RNG early entropy source...
I (220) boot: Loading app partition at offset 00010000
I (940) boot: segment 0: paddr=0x00010018 vaddr=0x00000000 size=0x0ffe8 ( 65512) 
I (941) boot: segment 1: paddr=0x00020008 vaddr=0x3f400010 size=0x0829c ( 33436) map
I (957) boot: segment 2: paddr=0x000282ac vaddr=0x3ffb0000 size=0x01c2c (  7212) load
I (986) boot: segment 3: paddr=0x00029ee0 vaddr=0x40080000 size=0x00400 (  1024) load
I (1010) boot: segment 4: paddr=0x0002a2e8 vaddr=0x40080400 size=0x19a94 (105108) load
I (1086) boot: segment 5: paddr=0x00043d84 vaddr=0x400c0000 size=0x00000 (     0) load
I (1087) boot: segment 6: paddr=0x00043d8c vaddr=0x00000000 size=0x0c27c ( 49788) 
I (1103) boot: segment 7: paddr=0x00050010 vaddr=0x400d0018 size=0x3aa88 (240264) map
I (1130) heap_alloc_caps: Initializing. RAM available for dynamic allocation:
I (1153) heap_alloc_caps: At 3FFB6C98 len 00029368 (164 KiB): DRAM
I (1174) heap_alloc_caps: At 3FFE8000 len 00018000 (96 KiB): D/IRAM
I (1195) heap_alloc_caps: At 40099E94 len 0000616C (24 KiB): IRAM
I (1216) cpu_start: Pro cpu up.
I (1228) cpu_start: Single core mode
I (1241) cpu_start: Pro cpu start user code
I (1301) cpu_start: Starting scheduler on PRO CPU.
I (1354) wifi: wifi firmware version: c1c8155
I (1370) wifi: pp_task_hdl : 3ffbe100, prio:23, stack:8192
I (1370) wifi: Init lldesc rx mblock:10
I (1370) wifi: Init lldesc rx ampdu len mblock:7
I (1372) wifi: Init lldesc rx ampdu entry mblock:4
I (1377) wifi: frc2_timer_task_hdl:3ffc4148, prio:22, stack:2048
I (1402) phy: phy_version: 329, Feb 22 2017, 15:58:07, 1, 0
I (1402) wifi: mode : sta (24:0a:c4:00:98:32)
I (3027) wifi: n:11 0, o:1 0, ap:255 255, sta:11 0, prof:1
I (3684) wifi: state: init -> auth (b0)
I (3687) wifi: state: auth -> assoc (0)
I (3691) wifi: state: assoc -> run (10)
I (4654) wifi: connected with Skynet, channel 11
I (7987) event: ip: 192.168.10.106, mask: 255.255.255.0, gw: 192.168.10.1
I (13692) wifi: pm start, type:0

I (310656) wifi: state: run -> auth (3c0)
I (310657) wifi: n:11 0, o:11 0, ap:255 255, sta:11 0, prof:1
I (310657) wifi: pm stop, total sleep time: 0/296965013
But, on my custom build ESP-WROOM-32 board I get this:

Code: Select all

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0x00
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3ffc0000,len:0
load:0x3ffc0000,len:2304
load:0x40078000,len:3788
ho 0 tail 12 room 4
load:0x40098000,len:532
entry 0x4009813c


**************************************
*       hello espressif ESP32!       *
*        2nd boot is running!        *
*            version (V0.1)          *
**************************************
compile time 18:16:58

  SPI Speed      : 40MHz
  SPI Mode       : DIO
  SPI Flash Size : 4MB
Partition Table:
## Label            Usage          Type ST Offset   Length
 0 factory          factory app      00 00 00010000 00100000
 1 rfdata           RF data          01 01 00110000 00040000
 2 wifidata         WiFi data        01 02 00150000 00040000
End of partition table
Loading app partition at offset 00010000
section 0: paddr=0x00000020 vaddr=0x00000000 size=0x0ffe8 ( 65512) 
section 1: paddr=0x00010010 vaddr=0x3f400010 size=0x0829c ( 33436) map
section 2: paddr=0x000182b4 vaddr=0x3ffb0000 size=0x01c2c (  7212) load
section 3: paddr=0x00019ee8 vaddr=0x40080000 size=0x00400 (  1024) load
section 4: paddr=0x0001a2f0 vaddr=0x40080400 size=0x19a94 (105108) load
section 5: paddr=0x00033d8c vaddr=0x400c0000 size=0x00000 (     0) load
section 6: paddr=0x00033d94 vaddr=0x00000000 size=0x0c27c ( 49788) 
section 7: paddr=0x00040018 vaddr=0x400d0018 size=0x3aa88 (240264) map
Fatal exception (0): IllegalInstruction
epc1=0x4009805c, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000
Mind you, I'm new to the ESP world, and this is the first time I'm working with an ESP-WROOM-32.

What can cause this? Do I need to write different code for the Sparkfun Thing and the Wroom? Is there a firmware in the Wroom that needs updating? Any help is appreciated!

Scalpel78
Posts: 51
Joined: Sun Feb 26, 2017 7:31 am

Re: Works on Sparkfun Thing, but fails on custom ESP-Wroom-32

Postby Scalpel78 » Tue Mar 07, 2017 9:01 pm

For some reason it works when I enable Bluetooth, as Rudi describes here.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Works on Sparkfun Thing, but fails on custom ESP-Wroom-32

Postby kolban » Tue Mar 07, 2017 9:40 pm

You didn't mention if you tried a full erase of the flash memory. When working with new boards, that never does any harm. See the esptool erase_flash (or similar words).
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Works on Sparkfun Thing, but fails on custom ESP-Wroom-32

Postby WiFive » Tue Mar 07, 2017 9:51 pm

Why do they have different bootloader output? You did only app-flash?

Scalpel78
Posts: 51
Joined: Sun Feb 26, 2017 7:31 am

Re: Works on Sparkfun Thing, but fails on custom ESP-Wroom-32

Postby Scalpel78 » Tue Mar 07, 2017 10:01 pm

Correct, I only did 'make app-flash' out of habbit, since that's what I normally do on the Sparkfun Thing.
I did a 'make flash' now, and it works even when I turn the Bluetooth back off again :)

Who is online

Users browsing this forum: No registered users and 141 guests