Debug with USB turned on.

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
User avatar
z80
Posts: 20
Joined: Mon Oct 08, 2012 5:36 pm

Debug with USB turned on.

Post by z80 »

Hello!

I've met very strange problem. When there is no USB in firmware everything is fine, debugging works pretty fine. But if I turn it on with

Code: Select all

  sduObjectInit(&SDU1);
  sduStart(&SDU1, &serusbcfg);
  usbConnectBus(serusbcfg.usbp);
  shellInit();
  shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);

debug attempt immediately sends me to HardFaultHandler() even before reaching main()'s first line. But without debugging board works very well. USB interaction works properly. I'd be very much obliged if one could assist me around this issue. CPU is STM32F102C8T6.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Debug with USB turned on.

Post by Giovanni »

Hi,

Usually I am able to debug with USB on, what GDB server are you using? probably this is more related to your debug setup than the driver.

Giovanni
User avatar
z80
Posts: 20
Joined: Mon Oct 08, 2012 5:36 pm

Re: Debug with USB turned on.

Post by z80 »

Dear Giovanni,

First of all, thank you very much for your reply and for your Chibios!

I'm sure that's something very simple. And being a new chibios user I just don't see it.
My GDB server is texane one: https://github.com/texane/stlink.
Could by any chance the problem be similar to this one: http://forum.chibios.org/phpbb/viewtopic.php?f=2&t=654.

May I also clear up a couple of issues related to using Shell.
1) I provide Shell thread with (1024 * 3) bytes. I've no idea how to estimate if it's enough or not.
2) I failed to find any description if chThdTerminated(). After what event/events does shell terminate? If it doesn't could I use shellCreateStatic() instead?

Thank you in advance!
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Debug with USB turned on.

Post by Giovanni »

Hi,

I don't think it is related to that problem. Do you work under windows? if so you could try ChibiStudio which is pre-configured with all required tools.

About your questions:

1) There is a debug plugin for Eclipse that is able to report the used stack size for each thread. There is also an option to fill the thread stacks with a pattern, you can then determine usage by inspecting memory (it is what the debugger plugin does automatically).

2) When a shell terminates it signals the event source "shell_terminated", you can listen for the event. After the event is detected do a chThdWait() on the shell thread reference in order to release the memory allocated to the thread. The Win32/Posix simulators have an example of this in main.c if I remember well.

Giovanni
User avatar
z80
Posts: 20
Joined: Mon Oct 08, 2012 5:36 pm

Re: Debug with USB turned on.

Post by z80 »

Dear Giovanni,

I work under Debian but I'll try to find a way to try ChibiStudio under Windows. Thank you for your support!
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Debug with USB turned on.

Post by Giovanni »

OK, try that, anyway, under Ubuntu I can debug using OpenOCD without problems.

Giovanni
Post Reply