mongoose-os-libs / arduino-compat

Arduino compatibility library for Mongoose OS
https://mongoose-os.com
Other
11 stars 8 forks source link

Arduino Compat starts before dependencies are initialized #3

Open gsc-dev opened 6 years ago

gsc-dev commented 6 years ago

I am specially impacted by the mgos spi lib as the arduino code in setup() sends comms before mgos_spi_create is fired.

[Jan 22 23:50:35.303] I (643) cpu_start: Pro cpu start user code
[Jan 22 23:50:35.310] I (327) cpu_start: Starting scheduler on PRO CPU.
[Jan 22 23:50:35.329] mgos_init2           blynk 1.0 (20180122-060206/master@878e023d+)
[Jan 22 23:50:35.335] mgos_init2           Mongoose OS 1.24 (20180122-023650/1.24@bd8e2958)
[Jan 22 23:50:35.341] mgos_init2           CPU: 160 MHz, RAM: 294644 total, 256260 free
[Jan 22 23:50:35.347] mgos_hal_freertos_pr ESP-IDF v3.0-rc1-r1
[Jan 22 23:50:35.352] mgos_hal_freertos_pr Boot partition: app_0; flash: 4M
[Jan 22 23:50:35.359] mgos_vfs_dev_open    esp32part ({"label": "fs_0", "subtype": 130}) -> 0x3ffc107c
[Jan 22 23:50:35.368] mgos_vfs_mount       Mount SPIFFS @ / (dev 0x3ffc107c, opts {"encr": false}) -> 0x3ffc0fc0
[Jan 22 23:50:35.491] mgos_vfs_mount       /: size 233681, used: 127006, free: 106675
[Jan 22 23:50:35.599] mgos_sys_config_init MAC: 30AEA435CE28
[Jan 22 23:50:35.605] mgos_sys_config_init WDT: 30 seconds
[Jan 22 23:50:35.610] mgos_deps_init       init adc...
[Jan 22 23:50:35.613] mgos_deps_init       init arduino_compat...
[Jan 22 23:50:35.619] setup                arduino.cpp::setup()
[Jan 22 23:50:40.624] setup                arduino.cpp::setup() delay
[Jan 22 23:50:40.630] MD_MAX72XX::begin()
[Jan 22 23:50:40.634] spiInit              Initing MAX72xx...
[Jan 22 23:50:40.640] spiInit              Using ESP32 SPI settings in mos.yml...
[Jan 22 23:50:40.647] SPI spiSend!
[Jan 22 23:50:40.651] spiInit              Initing MAX72xx...
[Jan 22 23:50:40.656] spiInit              Using ESP32 SPI settings in mos.yml...
[Jan 22 23:50:40.664] SPI spiSend!
[Jan 22 23:50:40.667] spiInit              Initing MAX72xx...
[Jan 22 23:50:40.673] spiInit              Using ESP32 SPI settings in mos.yml...
[Jan 22 23:50:40.680] SPI spiSend!
[Jan 22 23:50:40.684] spiInit              Initing MAX72xx...
[Jan 22 23:50:40.689] spiInit              Using ESP32 SPI settings in mos.yml...
[Jan 22 23:50:40.697] SPI spiSend!
[Jan 22 23:50:40.700] spiInit              Initing MAX72xx...
[Jan 22 23:50:40.706] spiInit              Using ESP32 SPI settings in mos.yml...
[Jan 22 23:50:40.713] SPI spiSend!
[Jan 22 23:50:40.717] spiInit              Initing MAX72xx...
[Jan 22 23:50:40.723] spiInit              Using ESP32 SPI settings in mos.yml...
[Jan 22 23:50:40.730] SPI spiSend!
[Jan 22 23:50:40.733] spiInit              Initing MAX72xx...
[Jan 22 23:50:40.739] spiInit              Using ESP32 SPI settings in mos.yml...
[Jan 22 23:50:40.747] SPI spiSend!
[Jan 22 23:50:40.750] spiInit              Initing MAX72xx...
[Jan 22 23:50:40.756] spiInit              Using ESP32 SPI settings in mos.yml...
[Jan 22 23:50:40.763] SPI spiSend!
[Jan 22 23:50:40.767] spiInit              Initing MAX72xx...
[Jan 22 23:50:40.772] spiInit              Using ESP32 SPI settings in mos.yml...
[Jan 22 23:50:40.780] SPI spiSend!
[Jan 22 23:50:40.783] spiInit              Initing MAX72xx...
[Jan 22 23:50:40.789] spiInit              Using ESP32 SPI settings in mos.yml...
[Jan 22 23:50:40.796] SPI spiSend!
[Jan 22 23:50:40.800] spiInit              Initing MAX72xx...
[Jan 22 23:50:40.805] spiInit              Using ESP32 SPI settings in mos.yml...
[Jan 22 23:50:40.813] SPI spiSend!
[Jan 22 23:50:40.816] spiInit              Initing MAX72xx...
[Jan 22 23:50:40.822] spiInit              Using ESP32 SPI settings in mos.yml...
[Jan 22 23:50:40.829] SPI spiSend!
[Jan 22 23:50:40.833] spiInit              Initing MAX72xx...
[Jan 22 23:50:40.839] spiInit              Using ESP32 SPI settings in mos.yml...
[Jan 22 23:50:40.846] SPI spiSend!
[Jan 22 23:50:40.849] spiInit              Initing MAX72xx...
[Jan 22 23:50:40.855] spiInit              Using ESP32 SPI settings in mos.yml...
[Jan 22 23:50:40.863] SPI spiSend!
[Jan 22 23:50:40.866] spiInit              Initing MAX72xx...
[Jan 22 23:50:40.872] spiInit              Using ESP32 SPI settings in mos.yml...
[Jan 22 23:50:40.879] mgos_deps_init       init onewire...
[Jan 22 23:50:40.882] mgos_deps_init       init arduino_onewire...
[Jan 22 23:50:40.886] mgos_deps_init       init arduino_dallas_temperature...
[Jan 22 23:50:40.891] mgos_deps_init       init spi...
[Jan 22 23:50:40.896] mgos_spi_create      SPI3 init ok (MISO: 19, MOSI: 23, SCLK: 18; CS0/1/2: 5/-1/-1; native? yes)
[Jan 22 23:50:40.907] mgos_deps_init       init arduino_spi...
[Jan 22 23:50:40.910] mgos_deps_init       init arduino_md_max72xx...
[Jan 22 23:50:40.915] mgos_deps_init       init arduino_md_parola...
[Jan 22 23:50:40.919] mgos_deps_init       init i2c...
[Jan 22 23:50:40.922] mgos_deps_init       init arduino_wire...
[Jan 22 23:50:40.925] mgos_deps_init       init blynk...
[Jan 22 23:50:40.930] mgos_deps_init       init ca_bundle...
[Jan 22 23:50:40.934] mgos_deps_init       init location...
[Jan 22 23:50:40.937] mgos_deps_init       init sntp...
[Jan 22 23:50:40.942] mgos_deps_init       init cron...
[Jan 22 23:50:40.945] mgos_deps_init       init jstore...
[Jan 22 23:50:40.948] mgos_deps_init       init crontab...
[Jan 22 23:50:40.954] find_mount_by_path   crontab.json -> /crontab.json pl 1 -> 1 0x3ffc0fc0
[Jan 22 23:50:40.968] mgos_vfs_open        crontab.json 0x0 0x1b6 => 0x3ffc0fc0 crontab.json -1 => -1 (refs 0)
[Jan 22 23:50:40.978] mgos_deps_init       init mjs...
[Jan 22 23:50:40.983] mgos_mjs_init        mJS memory stat: before init: 258172 after init: 256768
[Jan 22 23:50:40.992] mgos_deps_init       init pwm...
[Jan 22 23:50:40.995] mgos_deps_init       init rpc_common...
[Jan 22 23:50:41.000] mgos_deps_init       init rpc_service_config...
[Jan 22 23:50:41.007] mgos_deps_init       init rpc_service_fs...
[Jan 22 23:50:41.013] mgos_deps_init       init rpc_uart...
[Jan 22 23:50:41.019] mg_rpc_channel_uart  0x3ffb9d78 UART0
[Jan 22 23:50:41.025] mg_rpc_add_channel_i 0x3ffb9d78 '' UART
[Jan 22 23:50:41.030] mgos_deps_init       init wifi...
[Jan 22 23:50:41.035] mgos_wifi_setup      WiFi mode: AP
[Jan 22 23:50:41.040] esp32_wifi_set_mode  WiFi mode: AP
carldunham commented 5 years ago

Work-around that worked for me:

enum mgos_app_init_result mgos_app_init(void) {
  do_setup();
  return MGOS_APP_INIT_SUCCESS;
}