Esempio n. 1
0
int device_init_platform(struct sys_config *cfg) {
  /* Initialize debug first */
  uart_debug_init(0, 0);
  uart_redirect_debug(cfg->debug.mode);
  cs_log_set_level(cfg->debug.level);

  return do_wifi(cfg);
}
Esempio n. 2
0
/*
 * SmartJS initialization; for non-RTOS env, called as an SDK timer callback
 * (`os_timer_...()`). For RTOS env, called by the dispatcher task.
 */
void sjs_init(void *dummy) {
  /*
   * In order to see debug output (at least errors) during boot we have to
   * initialize debug in this point. But default we put debug to UART0 with
   * level=LL_ERROR, then configuration is loaded this settings are overridden
   */
  uart_debug_init(0, 0);
  uart_redirect_debug(1);
  cs_log_set_level(LL_ERROR);

#ifndef V7_NO_FS
#ifndef DISABLE_OTA
  fs_init(get_fs_addr(get_current_rom()), get_fs_size(get_current_rom()));
  finish_update();
#else
  fs_init(FS_ADDR, FS_SIZE);
#endif
#endif

  init_v7(&dummy);

  /* disable GC during further initialization */
  v7_set_gc_enabled(v7, 0);

#if !defined(NO_PROMPT)
  uart_main_init(0);
#endif

#ifndef V7_NO_FS
  init_smartjs();
#endif

#if !defined(NO_PROMPT)
  sj_prompt_init(v7);
#endif

#ifdef ESP_UMM_ENABLE
  /*
   * We want to use our own heap functions instead of the ones provided by the
   * SDK.
   *
   * We have marked `pvPortMalloc` and friends weak, so that we can override
   * them with our own implementations, but to actually make it work, we have
   * to reference any function from the file with our implementation, so that
   * linker will not garbage-collect the whole compilation unit.
   *
   * So, we have a call to the no-op `esp_umm_init()` here.
   */
  esp_umm_init();
#endif

  /* SJS initialized, enable GC back, and trigger it */
  v7_set_gc_enabled(v7, 1);
  v7_gc(v7, 1);
}
Esempio n. 3
0
/*
 * Sets output for debug messages.
 * Available modes are:
 * 0 - no debug output
 * 1 - print debug output to UART0 (V7's console)
 * 2 - print debug output to UART1
 */
static v7_val_t Debug_mode(struct v7 *v7) {
  int mode, res;
  v7_val_t output_val = v7_arg(v7, 0);

  if (!v7_is_number(output_val)) {
    printf("Output is not a number\n");
    return v7_create_undefined();
  }

  mode = v7_to_number(output_val);

  uart_debug_init(0, 0);
  res = uart_redirect_debug(mode);

  return v7_create_number(res < 0 ? res : mode);
}
Esempio n. 4
0
/*
 * Sets output for debug messages.
 * Available modes are:
 * 0 - no debug output
 * 1 - print debug output to UART0 (V7's console)
 * 2 - print debug output to UART1
 */
ICACHE_FLASH_ATTR static v7_val_t Debug_set_output(struct v7 *v7,
                                                   v7_val_t this_obj,
                                                   v7_val_t args) {
  int mode, res;
  v7_val_t output_val = v7_array_get(v7, args, 0);

  if (!v7_is_double(output_val)) {
    printf("Output is not a number\n");
    return v7_create_undefined();
  }

  mode = v7_to_double(output_val);

  uart_debug_init(0, 0);
  res = uart_redirect_debug(mode);

  return v7_create_number(res < 0 ? res : mode);
}
Esempio n. 5
0
/*
 * Sets output for debug messages.
 * Available modes are:
 * 0 - no debug output
 * 1 - print debug output to UART0 (V7's console)
 * 2 - print debug output to UART1
 */
static enum v7_err Debug_mode(struct v7 *v7, v7_val_t *res) {
  enum v7_err rcode = V7_OK;
  int mode, ires;
  v7_val_t output_val = v7_arg(v7, 0);

  if (!v7_is_number(output_val)) {
    printf("Output is not a number\n");
    *res = v7_create_undefined();
    goto clean;
  }

  mode = v7_to_number(output_val);

  uart_debug_init(0, 0);
  ires = uart_redirect_debug(mode);

  *res = v7_create_number(ires < 0 ? ires : mode);
  goto clean;

clean:
  return rcode;
}