Example #1
0
void up_assert(const uint8_t *filename, int lineno)
{
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
  struct tcb_s *rtcb = this_task();
#endif

  board_autoled_on(LED_ASSERTION);

#if CONFIG_TASK_NAME_SIZE > 0
  _alert("Assertion failed at file:%s line: %d task: %s\n",
        filename, lineno, rtcb->name);
#else
  _alert("Assertion failed at file:%s line: %d\n",
        filename, lineno);
#endif

  up_dumpstate();

#ifdef CONFIG_BOARD_CRASHDUMP
  board_crashdump(up_getsp(), this_task(), filename, lineno);
#endif

#ifdef CONFIG_ARCH_USBDUMP
  /* Dump USB trace data */

  (void)usbtrace_enumerate(assert_tracecallback, NULL);
#endif

  _up_assert(EXIT_FAILURE);
}
Example #2
0
void up_assert(const uint8_t *filename, int lineno)
{
#ifdef CONFIG_PRINT_TASKNAME
  struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;
#endif

  board_led_on(LED_ASSERTION);

#ifdef CONFIG_PRINT_TASKNAME
  lldbg("Assertion failed at file:%s line: %d task: %s\n",
        filename, lineno, rtcb->name);
#else
  lldbg("Assertion failed at file:%s line: %d\n",
        filename, lineno);
#endif

  up_dumpstate();

#ifdef CONFIG_ARCH_USBDUMP
  /* Dump USB trace data */

  (void)usbtrace_enumerate(assert_tracecallback, NULL);
#endif

  _up_assert(EXIT_FAILURE);
}
Example #3
0
static int dumptrace(void)
{
  int ret;

  ret =  usbtrace_enumerate(composite_enumerate, NULL);
  if (ret < 0)
    {
      printf("dumptrace: usbtrace_enumerate failed: %d\n", -ret);
    }
  return ret;
}
Example #4
0
void up_assert(void)
#endif
{
#if CONFIG_TASK_NAME_SIZE > 0
  struct tcb_s *rtcb = this_task();
#endif

  board_autoled_on(LED_ASSERTION);

#ifdef CONFIG_HAVE_FILENAME
#if CONFIG_TASK_NAME_SIZE > 0
  lldbg("Assertion failed at file:%s line: %d task: %s\n",
        filename, lineno, rtcb->name);
#else
  lldbg("Assertion failed at file:%s line: %d\n",
        filename, lineno);
#endif
#else
#if CONFIG_TASK_NAME_SIZE > 0
  lldbg("Assertion failed: task: %s\n", rtcb->name);
#else
  lldbg("Assertion failed\n");
#endif
#endif

  up_stackdump();
  up_registerdump();

#ifdef CONFIG_ARCH_USBDUMP
  /* Dump USB trace data */

  (void)usbtrace_enumerate(assert_tracecallback, NULL);
#endif

#ifdef CONFIG_BOARD_CRASHDUMP
  board_crashdump(up_getsp(), this_task(), filename, lineno);
#endif

  _up_assert(EXIT_FAILURE);
}
Example #5
0
void up_assert(void)
#endif
{
#if CONFIG_TASK_NAME_SIZE > 0
  struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;
#endif

  board_led_on(LED_ASSERTION);

#ifdef CONFIG_HAVE_FILENAME
#if CONFIG_TASK_NAME_SIZE > 0
  lldbg("Assertion failed at file:%s line: %d task: %s\n",
        filename, lineno, rtcb->name);
#else
  lldbg("Assertion failed at file:%s line: %d\n",
        filename, lineno);
#endif
#else
#if CONFIG_TASK_NAME_SIZE > 0
  lldbg("Assertion failed: task: %s\n", rtcb->name);
#else
  lldbg("Assertion failed\n");
#endif
#endif

  up_stackdump();
  REGISTER_DUMP();

#ifdef CONFIG_ARCH_USBDUMP
  /* Dump USB trace data */

  (void)usbtrace_enumerate(assert_tracecallback, NULL);
#endif

  _up_assert(EXIT_FAILURE);
}
Example #6
0
static void up_dumpstate(void)
{
  struct tcb_s *rtcb = this_task();
  uint16_t sp = up_getsp();
  uint16_t ustackbase;
  uint16_t ustacksize;
#if CONFIG_ARCH_INTERRUPTSTACK > 3
  uint16_t istackbase;
  uint16_t istacksize;
#endif

  /* Get the limits on the user stack memory */

  if (rtcb->pid == 0)
    {
      ustackbase = g_idle_topstack - 4;
      ustacksize = CONFIG_IDLETHREAD_STACKSIZE;
    }
  else
    {
      ustackbase = (uint16_t)rtcb->adj_stack_ptr;
      ustacksize = (uint16_t)rtcb->adj_stack_size;
    }

  /* Get the limits on the interrupt stack memory */

#if CONFIG_ARCH_INTERRUPTSTACK > 3
  istackbase = (uint16_t)&g_intstackbase;
  istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3) - 4;

  /* Show interrupt stack info */

  lldbg("sp:     %04x\n", sp);
  lldbg("IRQ stack:\n");
  lldbg("  base: %04x\n", istackbase);
  lldbg("  size: %04x\n", istacksize);

  /* Does the current stack pointer lie within the interrupt
   * stack?
   */

  if (sp <= istackbase && sp > istackbase - istacksize)
    {
      /* Yes.. dump the interrupt stack */

      up_stackdump(sp, istackbase);

      /* Extract the user stack pointer which should lie
       * at the base of the interrupt stack.
       */

      sp = g_intstackbase;
      lldbg("sp:     %04x\n", sp);
    }

  /* Show user stack info */

  lldbg("User stack:\n");
  lldbg("  base: %04x\n", ustackbase);
  lldbg("  size: %04x\n", ustacksize);
#else
  lldbg("sp:         %04x\n", sp);
  lldbg("stack base: %04x\n", ustackbase);
  lldbg("stack size: %04x\n", ustacksize);
#endif

  /* Dump the user stack if the stack pointer lies within the allocated user
   * stack memory.
   */

  if (sp > ustackbase || sp <= ustackbase - ustacksize)
    {
#if !defined(CONFIG_ARCH_INTERRUPTSTACK) || CONFIG_ARCH_INTERRUPTSTACK < 4
      lldbg("ERROR: Stack pointer is not within allocated stack\n");
#endif
    }
  else
    {
      up_stackdump(sp, ustackbase);
    }

  /* Then dump the registers (if available) */

  up_registerdump();

#ifdef CONFIG_ARCH_USBDUMP
  /* Dump USB trace data */

  (void)usbtrace_enumerate(assert_tracecallback, NULL);
#endif
}
Example #7
0
int user_start(int argc, char *argv[])
{
  void *handle;
  int ret;

  /* Initialize USB trace output IDs */

  usbtrace_enable(TRACE_BITSET);

  /* Register block drivers (architecture-specific) */

  message("user_start: Creating block drivers\n");
  ret = usbstrg_archinitialize();
  if (ret < 0)
    {
      message("user_start: usbstrg_archinitialize failed: %d\n", -ret);
      return 1;
    }

  /* Then exports the LUN(s) */

  message("user_start: Configuring with NLUNS=%d\n", CONFIG_EXAMPLES_USBSTRG_NLUNS);
  ret = usbstrg_configure(CONFIG_EXAMPLES_USBSTRG_NLUNS, &handle);
  if (ret < 0)
    {
      message("user_start: usbstrg_configure failed: %d\n", -ret);
      usbstrg_uninitialize(handle);
      return 2;
    }
  message("user_start: handle=%p\n", handle);

  message("user_start: Bind LUN=0 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH1);
  ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH1, 0, 0, 0, false);
  if (ret < 0)
    {
      message("user_start: usbstrg_bindlun failed for LUN 1 using %s: %d\n",
               CONFIG_EXAMPLES_USBSTRG_DEVPATH1, -ret);
      usbstrg_uninitialize(handle);
      return 2;
    }

#if CONFIG_EXAMPLES_USBSTRG_NLUNS > 1

  message("user_start: Bind LUN=1 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH2);
  ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH2, 1, 0, 0, false);
  if (ret < 0)
    {
      message("user_start: usbstrg_bindlun failed for LUN 2 using %s: %d\n",
               CONFIG_EXAMPLES_USBSTRG_DEVPATH2, -ret);
      usbstrg_uninitialize(handle);
      return 3;
    }

#if CONFIG_EXAMPLES_USBSTRG_NLUNS > 2

  message("user_start: Bind LUN=2 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH3);
  ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH3, 2, 0, 0, false);
  if (ret < 0)
    {
      message("user_start: usbstrg_bindlun failed for LUN 3 using %s: %d\n",
               CONFIG_EXAMPLES_USBSTRG_DEVPATH3, -ret);
      usbstrg_uninitialize(handle);
      return 4;
    }

#endif
#endif

  ret = usbstrg_exportluns(handle);
  if (ret < 0)
    {
      message("user_start: usbstrg_exportluns failed: %d\n", -ret);
      usbstrg_uninitialize(handle);
      return 5;
    }

  /* Now just hang around and monitor the USB storage activity */

#ifndef CONFIG_DISABLE_SIGNALS
  for (;;)
    {
      msgflush();
      sleep(5);

#ifdef CONFIG_USBDEV_TRACE
      message("\nuser_start: USB TRACE DATA:\n");
      ret =  usbtrace_enumerate(usbstrg_enumerate, NULL);
      if (ret < 0)
        {
          message("user_start: usbtrace_enumerate failed: %d\n", -ret);
          usbstrg_uninitialize(handle);
          return 6;
        }
#else
      message("user_start: Still alive\n");
#endif
    }
#else
     message("user_start: Exiting\n");
 #endif
}
Example #8
0
static void dumptrace(void)
{
  (void)usbtrace_enumerate(trace_callback, NULL);
}
Example #9
0
int MAIN_NAME(int argc, char *argv[])
{
  FAR void *handle;
  int ret;

  /* If this program is implemented as the NSH 'msconn' command, then we need to
   * do a little error checking to assure that we are not being called re-entrantly.
   */

#ifdef CONFIG_EXAMPLES_USBSTRG_BUILTIN

   /* Check if there is a non-NULL USB mass storage device handle (meaning that the
    * USB mass storage device is already configured).
    */

   if (g_usbstrg.mshandle)
     {
       message(MAIN_NAME_STRING ": ERROR: Already connected\n");
       return 1;
     }
#endif

#ifdef CONFIG_EXAMPLES_USBSTRG_DEBUGMM
#  ifdef CONFIG_CAN_PASS_STRUCTS
  g_usbstrg.mmstart    = mallinfo();
  g_usbstrg.mmprevious = g_usbstrg.mmstart;
#  else
  (void)mallinfo(&g_usbstrg.mmstart);
  memcpy(&g_usbstrg.mmprevious, &g_usbstrg.mmstart, sizeof(struct mallinfo));
#  endif
#endif

  /* Initialize USB trace output IDs */

  usbtrace_enable(TRACE_BITSET);
  check_test_memory_usage("After usbtrace_enable()");

  /* Register block drivers (architecture-specific) */

  message(MAIN_NAME_STRING ": Creating block drivers\n");
  ret = usbstrg_archinitialize();
  if (ret < 0)
    {
      message(MAIN_NAME_STRING ": usbstrg_archinitialize failed: %d\n", -ret);
      return 2;
    }
  check_test_memory_usage("After usbstrg_archinitialize()");

  /* Then exports the LUN(s) */

  message(MAIN_NAME_STRING ": Configuring with NLUNS=%d\n", CONFIG_EXAMPLES_USBSTRG_NLUNS);
  ret = usbstrg_configure(CONFIG_EXAMPLES_USBSTRG_NLUNS, &handle);
  if (ret < 0)
    {
      message(MAIN_NAME_STRING ": usbstrg_configure failed: %d\n", -ret);
      usbstrg_uninitialize(handle);
      return 3;
    }
  message(MAIN_NAME_STRING ": handle=%p\n", handle);
  check_test_memory_usage("After usbstrg_configure()");

  message(MAIN_NAME_STRING ": Bind LUN=0 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH1);
  ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH1, 0, 0, 0, false);
  if (ret < 0)
    {
      message(MAIN_NAME_STRING ": usbstrg_bindlun failed for LUN 1 using %s: %d\n",
               CONFIG_EXAMPLES_USBSTRG_DEVPATH1, -ret);
      usbstrg_uninitialize(handle);
      return 4;
    }
  check_test_memory_usage("After usbstrg_bindlun()");

#if CONFIG_EXAMPLES_USBSTRG_NLUNS > 1

  message(MAIN_NAME_STRING ": Bind LUN=1 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH2);
  ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH2, 1, 0, 0, false);
  if (ret < 0)
    {
      message(MAIN_NAME_STRING ": usbstrg_bindlun failed for LUN 2 using %s: %d\n",
               CONFIG_EXAMPLES_USBSTRG_DEVPATH2, -ret);
      usbstrg_uninitialize(handle);
      return 5;
    }
  check_test_memory_usage("After usbstrg_bindlun() #2");

#if CONFIG_EXAMPLES_USBSTRG_NLUNS > 2

  message(MAIN_NAME_STRING ": Bind LUN=2 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH3);
  ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH3, 2, 0, 0, false);
  if (ret < 0)
    {
      message(MAIN_NAME_STRING ": usbstrg_bindlun failed for LUN 3 using %s: %d\n",
               CONFIG_EXAMPLES_USBSTRG_DEVPATH3, -ret);
      usbstrg_uninitialize(handle);
      return 6;
    }
  check_test_memory_usage("After usbstrg_bindlun() #3");

#endif
#endif

  ret = usbstrg_exportluns(handle);
  if (ret < 0)
    {
      message(MAIN_NAME_STRING ": usbstrg_exportluns failed: %d\n", -ret);
      usbstrg_uninitialize(handle);
      return 7;
    }
  check_test_memory_usage("After usbstrg_exportluns()");

  /* It this program was configued as an NSH command, then just exit now.
   * Also, if signals are not enabled (and, hence, sleep() is not supported.
   * then we have not real option but to exit now.
   */

#if !defined(CONFIG_EXAMPLES_USBSTRG_BUILTIN) && !defined(CONFIG_DISABLE_SIGNALS)

  /* Otherwise, this thread will hang around and monitor the USB storage activity */

  for (;;)
    {
      msgflush();
      sleep(5);

#  ifdef CONFIG_USBDEV_TRACE
      message("\nuser_start: USB TRACE DATA:\n");
      ret =  usbtrace_enumerate(usbstrg_enumerate, NULL);
      if (ret < 0)
        {
          message(MAIN_NAME_STRING ": usbtrace_enumerate failed: %d\n", -ret);
          usbstrg_uninitialize(handle);
          return 8;
        }
      check_test_memory_usage("After usbtrace_enumerate()");
#  else
      message(MAIN_NAME_STRING ": Still alive\n");
#  endif
    }
#elif defined(CONFIG_EXAMPLES_USBSTRG_BUILTIN)

   /* Return the USB mass storage device handle so it can be used by the 'misconn'
    * command.
    */

   message(MAIN_NAME_STRING ": Connected\n");
   g_usbstrg.mshandle = handle;
   check_test_memory_usage("After MS connection");

#else /* defined(CONFIG_DISABLE_SIGNALS) */

  /* Just exit */
 
   message(MAIN_NAME_STRING ": Exiting\n");

   /* Dump debug memory usage */
 
   final_memory_usage("Final memory usage");
#endif
   return 0;
}
Example #10
0
void nsh_usbtrace(void)
{
  (void)usbtrace_enumerate(nsh_tracecallback, NULL);
}