Galzai / MK32

Keyboard firmware for ESP32 microcontrollers
667 stars 117 forks source link

ESP32 fails to boot when compiled in Windows MSYS2 mingw32 #1

Closed bilogic closed 5 years ago

bilogic commented 5 years ago

Hi,

Following the instructions on build wiki with mingw32 from MSYS2, I faced these 2 compilation warnings and after flashing, ESP32 fails to boot:

E:/Temp/esp/msys32/esp/MK32/plugins/plugin_components/wifi_manager/wifi_manager.c: In function 'wifi_connection_init':
E:/Temp/esp/msys32/esp/MK32/plugins/plugin_components/wifi_manager/wifi_manager.c:432:49: warning: passing argument 2 of 'esp_wifi_set_config' from incompatible pointer type [-Wincompatible-pointer-types]
       err = esp_wifi_set_config(ESP_IF_WIFI_STA,&ap_config);
                                                 ^
In file included from E:/Temp/esp/msys32/esp/MK32/plugins/plugin_components/wifi_manager/wifi_manager.h:13:0,
                 from E:/Temp/esp/msys32/esp/MK32/plugins/plugin_components/wifi_manager/wifi_manager.c:1:
E:/Temp/esp/esp-idf/components/esp32/include/esp_wifi.h:759:11: note: expected 'wifi_config_t * {aka union <anonymous> *}' but argument is of type 'wifi_sta_config_t * {aka struct <anonymous> *}'
 esp_err_t esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf);
           ^
E:/Temp/esp/msys32/esp/MK32/components/nkolban_BLE/BLECharacteristic.cpp: In member function 'void BLECharacteristic::setValue(float&)':
E:/Temp/esp/msys32/esp/MK32/components/nkolban_BLE/BLECharacteristic.cpp:721:17: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  *((float *)temp) = data32;
                 ^
E:/Temp/esp/msys32/esp/MK32/components/nkolban_BLE/BLECharacteristic.cpp: In member function 'void BLECharacteristic::setValue(double&)':
E:/Temp/esp/msys32/esp/MK32/components/nkolban_BLE/BLECharacteristic.cpp:727:18: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  *((double *)temp) = data64;
                  ^

ESP32 boot error

$ make monitor
Toolchain path: /opt/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
Toolchain version: crosstool-ng-1.22.0-80-g6c4433a5
Compiler version: 5.2.0
Python requirements from E:/Temp/esp/esp-idf/requirements.txt are satisfied.
MONITOR
--- idf_monitor on COM18 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:5940
load:0x40078000,len:9444
ho 0 tail 12 room 4
load:0x40080400,len:6248
entry 0x40080724
I (30) boot: ESP-IDF v3.3-beta1-136-g97eecfa1b 2nd stage bootloader
I (30) boot: compile time 11:08:49
I (38) boot: Enabling RNG early entropy source...
I (39) boot: SPI Speed      : 40MHz
I (40) boot: SPI Mode       : DIO
I (44) boot: SPI Flash Size : 4MB
I (48) boot: Partition Table:
I (52) boot: ## Label            Usage          Type ST Offset   Length
I (59) boot:  0 nvs              WiFi data        01 02 00009000 00004000
I (67) boot:  1 otadata          OTA data         01 00 0000d000 00002000
I (74) boot:  2 phy_init         RF data          01 01 0000f000 00001000
I (82) boot:  3 factory          factory app      00 00 00010000 00300000
I (89) boot: End of partition table
I (93) boot: Defaulting to factory image
I (98) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x4f844 (325700) map
I (220) esp_image: segment 1: paddr=0x0005f86c vaddr=0x3ffbdb60 size=0x007a4 (  1956) load
I (221) esp_image: segment 2: paddr=0x00060018 vaddr=0x400d0018 size=0xad5d0 (710096) map
0x400d0018: _stext at ??:?

I (472) esp_image: segment 3: paddr=0x0010d5f0 vaddr=0x3ffbe304 size=0x021c4 (  8644) load
I (476) esp_image: segment 4: paddr=0x0010f7bc vaddr=0x3ffc04c8 size=0x00000 (     0) load
I (479) esp_image: segment 5: paddr=0x0010f7c4 vaddr=0x40080000 size=0x00400 (  1024) load
0x40080000: _WindowOverflow4 at E:/Temp/esp/esp-idf/components/freertos/xtensa_vectors.S:1685

I (489) esp_image: segment 6: paddr=0x0010fbcc vaddr=0x40080400 size=0x120ec ( 73964) load
I (526) esp_image: segment 7: paddr=0x00121cc0 vaddr=0x400c0000 size=0x00064 (   100) load
I (526) esp_image: segment 8: paddr=0x00121d2c vaddr=0x50000200 size=0x00000 (     0) load
I (533) esp_image: segment 9: paddr=0x00121d34 vaddr=0x50000200 size=0x00000 (     0) load
I (552) boot: Loaded app from partition at offset 0x10000
I (552) boot: Disabling RNG early entropy source...
I (553) cpu_start: Pro cpu up.
I (557) cpu_start: Application information:
I (562) cpu_start: Project name:     MK32
I (566) cpu_start: App version:      02abecd-dirty
I (572) cpu_start: Compile time:     11:08:55
I (577) cpu_start: Compile date:     Dec 30 2018
I (582) cpu_start: ESP-IDF:          v3.3-beta1-136-g97eecfa1b
I (589) cpu_start: Starting app cpu, entry point is 0x40081224
0x40081224: call_start_cpu1 at E:/Temp/esp/esp-idf/components/esp32/cpu_start.c:265

I (0) cpu_start: App cpu up.
D (599) memory_layout: Checking 11 reserved memory ranges:
D (604) memory_layout: Reserved memory range 0x3ffae000 - 0x3ffae6e0
D (611) memory_layout: Reserved memory range 0x3ffae6e0 - 0x3ffaff10
D (617) memory_layout: Reserved memory range 0x3ffb0000 - 0x3ffb6388
D (624) memory_layout: Reserved memory range 0x3ffb8000 - 0x3ffb9a20
D (630) memory_layout: Reserved memory range 0x3ffbdb28 - 0x3ffbdb5c
D (636) memory_layout: Reserved memory range 0x3ffbdb60 - 0x3ffca928
D (643) memory_layout: Reserved memory range 0x3ffe0000 - 0x3ffe0440
D (649) memory_layout: Reserved memory range 0x3ffe3f20 - 0x3ffe4350
D (656) memory_layout: Reserved memory range 0x40070000 - 0x40078000
D (662) memory_layout: Reserved memory range 0x40078000 - 0x40080000
0x40080000: _WindowOverflow4 at E:/Temp/esp/esp-idf/components/freertos/xtensa_vectors.S:1685

D (669) memory_layout: Reserved memory range 0x40080000 - 0x400924ec
0x40080000: _WindowOverflow4 at E:/Temp/esp/esp-idf/components/freertos/xtensa_vectors.S:1685

D (675) memory_layout: Building list of available memory regions:
D (681) memory_layout: Available memory region 0x3ffaff10 - 0x3ffb0000
D (688) memory_layout: Available memory region 0x3ffb6388 - 0x3ffb8000
D (694) memory_layout: Available memory region 0x3ffb9a20 - 0x3ffbdb28
D (701) memory_layout: Available memory region 0x3ffbdb5c - 0x3ffbdb60
D (708) memory_layout: Available memory region 0x3ffca928 - 0x3ffcc000
D (714) memory_layout: Available memory region 0x3ffcc000 - 0x3ffce000
D (721) memory_layout: Available memory region 0x3ffce000 - 0x3ffd0000
D (727) memory_layout: Available memory region 0x3ffd0000 - 0x3ffd2000
D (734) memory_layout: Available memory region 0x3ffd2000 - 0x3ffd4000
D (741) memory_layout: Available memory region 0x3ffd4000 - 0x3ffd6000
D (747) memory_layout: Available memory region 0x3ffd6000 - 0x3ffd8000
D (754) memory_layout: Available memory region 0x3ffd8000 - 0x3ffda000
D (760) memory_layout: Available memory region 0x3ffda000 - 0x3ffdc000
D (767) memory_layout: Available memory region 0x3ffdc000 - 0x3ffde000
D (774) memory_layout: Available memory region 0x3ffde000 - 0x3ffe0000
D (780) memory_layout: Available memory region 0x3ffe0440 - 0x3ffe3f20
D (787) memory_layout: Available memory region 0x3ffe4350 - 0x3ffe8000
D (793) memory_layout: Available memory region 0x3ffe8000 - 0x3fff0000
D (800) memory_layout: Available memory region 0x3fff0000 - 0x3fff8000
D (807) memory_layout: Available memory region 0x3fff8000 - 0x3fffc000
D (813) memory_layout: Available memory region 0x3fffc000 - 0x40000000
D (820) memory_layout: Available memory region 0x400924ec - 0x40094000
D (826) memory_layout: Available memory region 0x40094000 - 0x40096000
D (833) memory_layout: Available memory region 0x40096000 - 0x40098000
D (840) memory_layout: Available memory region 0x40098000 - 0x4009a000
D (846) memory_layout: Available memory region 0x4009a000 - 0x4009c000
D (853) memory_layout: Available memory region 0x4009c000 - 0x4009e000
D (859) memory_layout: Available memory region 0x4009e000 - 0x400a0000
I (866) heap_init: Initializing. RAM available for dynamic allocation:
D (873) heap_init: New heap initialised at 0x3ffaff10
I (878) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
D (884) heap_init: New heap initialised at 0x3ffb6388
I (889) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
D (896) heap_init: New heap initialised at 0x3ffb9a20
I (901) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (907) heap_init: At 3FFBDB5C len 00000004 (0 KiB): DRAM
D (913) heap_init: New heap initialised at 0x3ffca928
I (918) heap_init: At 3FFCA928 len 000156D8 (85 KiB): DRAM
I (924) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (931) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
D (937) heap_init: New heap initialised at 0x400924ec
I (942) heap_init: At 400924EC len 0000DB14 (54 KiB): IRAM
I (948) cpu_start: Pro cpu start user code
D (961) clk: RTC_SLOW_CLK calibration value: 3677914
D (299) intr_alloc: Connected src 46 to int 2 (cpu 0)
D (299) intr_alloc: Connected src 57 to int 3 (cpu 0)
D (301) intr_alloc: Connected src 24 to int 9 (cpu 0)
I (305) cpu_start: Starting scheduler on PRO CPU.
D (0) intr_alloc: Connected src 25 to int 2 (cpu 1)
I (4) cpu_start: Starting scheduler on APP CPU.
D (329) heap_init: New heap initialised at 0x3ffe0440
D (334) heap_init: New heap initialised at 0x3ffe4350
I (340) gpio: GPIO[13]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (349) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (358) gpio: GPIO[15]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (367) gpio: GPIO[0]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (377) gpio: GPIO[4]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (386) gpio: GPIO[12]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0

13 is level 0
14 is level 0
15 is level 0
16 is level 0
17 is level 0
18 is level 0
0 is level 0
4 is level 0
5 is level 0
12 is level 0D (407) nvs: nvs_flash_init_custom partition=nvs start=9 count=4
I (462) MAIN: loading configuration from NVS
D (462) nvs: nvs_open_from_partition config_c 1
D (462) nvs: nvs_get_str_or_blob btname
I (464) MAIN: bt device name is: MK32 V2.1
I (469) NVS Storage: Loading layouts
I (473) NVS Storage: Opening NVS handle
I (478) NVS Storage: NVS Handle opened successfully
E (483) NVS Storage: Error getting layout num: ESP_ERR_NVS_NOT_FOUND
I (490) NVS Storage: Error getting layout names size: ESP_ERR_NVS_NOT_FOUND
E (498) NVS Storage: Error getting layout name: ESP_ERR_NVS_NOT_FOUND
I (505) NVS Storage: Layouts not found on NVS, loading default layouts
I (512) NVS Storage: Encoder layouts not found on NVS, loading default layouts
I (520) NVS Storage: Slave encoder layouts not found on NVS, loading default layouts
I (528) HAL_BLE: Queues initialized
I (532) HAL_BLE: enabled interfaces
I (537) HIDD: MAIN finished...
I (537) BTDM_INIT: BT controller compile version [0b60040]
I (547) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (558)         OLED: Setting up oled
I (560) u8g2_hal: sda_io_num 23
I (563) u8g2_hal: scl_io_num 22
I (567) u8g2_hal: clk_speed 400000
I (571) u8g2_hal: i2c_param_config 1
I (576) u8g2_hal: i2c_driver_install 0
D (580) intr_alloc: Connected src 49 to int 12 (cpu 0)
I (796) phy: phy_version: 4006, e540b8e, Dec 17 2018, 11:53:06, 0, 0
E (1141) err: esp_err_t = -1
assertion "0 && "i2c_master_cmd_begin(I2C_MASTER_NUM, handle_i2c, I2C_TIMEOUT_MS / portTICK_RATE_MS)"" failed: file "E:/Temp/esp/msys32/esp/MK32/components/u8g2_OLED/u8g2_esp32_hal.c", line 159, function: u8g2_esp32_i2c_byte_cb
abort() was called at PC 0x400de637 on core 0
0x400de637: __assert_func at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdlib/../../../.././newlib/libc/stdlib/assert.c:63 (discriminator 8)

Backtrace: 0x4008d28f:0x3ffbb300 0x4008d55d:0x3ffbb320 0x400de637:0x3ffbb340 0x400dd792:0x3ffbb370 0x4017aad5:0x3ffbb3c0 0x400ddfe3:0x3ffbb3e0 0x400ddf61:0x3ffbb400 0x400de361:0x3ffbb430 0x4017aa61:0x3ffbb450 0x400d86b0:0x3ffbb470 0x400d493c:0x3ffbb4d0 0x400d2940:0x3ffbb
510
0x4008d28f: invoke_abort at E:/Temp/esp/esp-idf/components/esp32/panic.c:707

0x4008d55d: abort at E:/Temp/esp/esp-idf/components/esp32/panic.c:707

0x400de637: __assert_func at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdlib/../../../.././newlib/libc/stdlib/assert.c:63 (discriminator 8)

0x400dd792: u8g2_esp32_i2c_byte_cb at E:/Temp/esp/msys32/esp/MK32/components/u8g2_OLED/u8g2_esp32_hal.c:131 (discriminator 4)

0x4017aad5: u8x8_byte_EndTransfer at E:/Temp/esp/msys32/esp/MK32/components/u8g2_OLED/u8x8_byte.c:61

0x400ddfe3: u8x8_cad_ssd13xx_i2c at E:/Temp/esp/msys32/esp/MK32/components/u8g2_OLED/u8x8_cad.c:106

0x400ddf61: u8x8_cad_SendSequence at E:/Temp/esp/msys32/esp/MK32/components/u8g2_OLED/u8x8_cad.c:106

0x400de361: u8x8_d_ssd1306_128x64_noname at E:/Temp/esp/msys32/esp/MK32/components/u8g2_OLED/u8x8_d_ssd1306_128x64_noname.c:322

0x4017aa61: u8x8_InitDisplay at E:/Temp/esp/msys32/esp/MK32/components/u8g2_OLED/u8x8_display.c:115

0x400d86b0: init_oled at E:/Temp/esp/msys32/esp/MK32/components/u8g2_OLED/oled_tasks.c:290

0x400d493c: app_main at E:/Temp/esp/msys32/esp/MK32/main/mk32_main.cpp:322

0x400d2940: main_task at E:/Temp/esp/esp-idf/components/esp32/cpu_start.c:518

Any ideas? Thank you.

bilogic commented 5 years ago

I have further tried the following esp-idf, all to no avail.

  1. esp-idf (https://github.com/espressif/esp-idf/tree/97eecfa1b2b95a6f77e8e9ffcb676ded687ab68f) (As described in first post)
  2. esp-idf-v3.1.1 (errors in compilation)
    E:/Temp/esp/msys32/esp/MK32/main/matrix.c:94:5: error: implicit declaration of function 'rtc_gpio_wakeup_enable' [-Werror=implicit-function-declaration]
     rtc_gpio_wakeup_enable(MATRIX_ROWS_PINS[row],GPIO_INTR_HIGH_LEVEL);
     ^
    CC build/mbedtls/mbedtls/library/poly1305.o
    cc1.exe: some warnings being treated as errors
E:/Temp/esp/msys32/esp/MK32/components/nkolban_BLE/BLEUtils.cpp: In static member function 'static std::__cxx11::string BLEUtils::gattServerEventTypeToString(esp_gatts_cb_event_t)':
E:/Temp/esp/msys32/esp/MK32/components/nkolban_BLE/BLEUtils.cpp:1061:7: error: 'ESP_GATTS_SEND_SERVICE_CHANGE_EVT' was not declared in this scope
  case ESP_GATTS_SEND_SERVICE_CHANGE_EVT:
       ^
  1. esp-idf-v3.0.7 (errors in compilation)
  2. esp-idf-v3.0.5 (errors in compilation)
  3. esp-idf-v3.0 (errors in compilation)
bilogic commented 5 years ago

I managed to compile and boot using this IDF https://github.com/espressif/esp-idf/tree/97eecfa1b2b95a6f77e8e9ffcb676ded687ab68f The fix was to comment/disable #define OLED_ENABLE in keyboard_config.h. ESP32 boots now.

I (1814) HAL_BLE: Final report map size: 162 B
W (1821) BT_BTC: btc_gatts_arg_deep_copy 8, NULL value
W (1828) BT_BTC: btc_gatts_arg_deep_copy 8, NULL value
W (1836) BT_BTC: btc_gatts_arg_deep_copy 8, NULL value
W (1839) BT_BTC: btc_gatts_arg_deep_copy 8, NULL value
W (1845) BT_BTC: btc_gatts_arg_deep_copy 8, NULL value
W (1851) BT_BTC: btc_gatts_arg_deep_copy 8, NULL value
W (1857) BT_BTC: btc_gatts_arg_deep_copy 8, NULL value
W (1867) BT_BTC: btc_gatts_arg_deep_copy 8, NULL value
W (1872) BT_BTC: btc_gatts_arg_deep_copy 8, NULL value
W (1879) BT_BTC: btc_gatts_arg_deep_copy 8, NULL value
W (1889) BT_BTC: btc_gatts_arg_deep_copy 8, NULL value
I (1897) BLEDevice: create advertising