usb shell spawn

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

jscott
Posts: 129
Joined: Tue Jul 03, 2012 3:50 pm

Re: usb shell spawn

Post by jscott »

I doubt it is a chibios problem.

Where is your main where you init chibios?

Can you provide your whole file? If not, can you create a short test program that does the
same thing?

Are you running a debugger? can you see what the processor is doing? Do you have all the debug
options turned on?

You might want to add a blinking LED thread. It is amazing how much you can tell just by how
a simple LED blinks. :shock: :shock: :shock:

Check the demo programs. There are one or two around that use the usb port shell.

-John Scott
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: usb shell spawn

Post by Giovanni »

That while(true){} blocks the execution of all threads at lower priority, including the USB thread.

Giovanni
Pask
Posts: 47
Joined: Thu Jun 19, 2014 3:51 pm

Re: usb shell spawn

Post by Pask »

if I add palSetPad (GPIOD, GPIOD_LED6) to the body of the thread, the LED lights up. I found that the thread is running.  The problem is that the condition SDU1.config-> USBP-> state == USB_ACTIVE is not checked in the thread unlike what happens if the code is not in the thread
Pask
Posts: 47
Joined: Thu Jun 19, 2014 3:51 pm

Re: usb shell spawn

Post by Pask »

Giovanni wrote:That while(true){} blocks the execution of all threads at lower priority, including the USB thread.

Giovanni

oh no it is so misleading documentation. I do some testing and will update
how can I not block all threads?
jscott
Posts: 129
Joined: Tue Jul 03, 2012 3:50 pm

Re: usb shell spawn

Post by jscott »

Ah! Yes.

In your main change

Code: Select all

 while(TRUE){}


to

Code: Select all

while(TRUE)
{
    chThdSleepMilliseconds(500);
}


Never use an empty loop in an RTOS... I know from experience. :oops: :oops:

If you have other code that runs in that while() loop, you will probably want to use
a shorter delay. A few milliseconds would be fine. An empty loop does not need
to run often to get its work done! :lol: :lol:

-John Scott
Pask
Posts: 47
Joined: Thu Jun 19, 2014 3:51 pm

Re: usb shell spawn

Post by Pask »

oh my god thanks thanks thanks :D :lol: :roll:
jscott
Posts: 129
Joined: Tue Jul 03, 2012 3:50 pm

Re: usb shell spawn

Post by jscott »

welcome to the school of hard knocks...

Is it working now?
If not, give us an update when you can.

-John Scott
Pask
Posts: 47
Joined: Thu Jun 19, 2014 3:51 pm

Re: usb shell spawn

Post by Pask »

I have another question: if the application crashes and unhandled_Exception function is called, all running threads are blocked or only the thread that caused the crash?
Pask
Posts: 47
Joined: Thu Jun 19, 2014 3:51 pm

Re: usb shell spawn

Post by Pask »

jscott wrote:welcome to the school of hard knocks...

Is it working now?
If not, give us an update when you can.

-John Scott

working working...
jscott
Posts: 129
Joined: Tue Jul 03, 2012 3:50 pm

Re: usb shell spawn

Post by jscott »

Pask wrote:I have another question: if the application crashes and unhandled_Exception function is called, all running threads are blocked or only the thread that caused the crash?


It does what is basically a no-no in an RTOS. However, this time it is just what you want
to happen. Full screaming halt. You NEVER want an unhandled exception to slip by unnoticed.

-John

Code: Select all


00216 /**
00217  * @brief   Unhandled exceptions handler.
00218  * @details Any undefined exception vector points to this function by default.
00219  *          This function simply stops the system into an infinite loop.
00220  *
00221  * @notapi
00222  */
00223 #if !defined(__DOXYGEN__)
00224 __attribute__ ((naked))
00225 #endif
00226 void _unhandled_exception(void) {
00227
00228   while (TRUE)
00229     ;
00230 }


Post Reply