FYI: ChibiOS shell on USB virtual serial (CDC ACM) on Linux needs a delay

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

Moderators: RoccoMarco, lbednarz, utzig, tfAteba, barthess

stapelberg
Posts: 10
Joined: Wed Jun 03, 2020 9:17 pm
Has thanked: 4 times
Been thanked: 3 times

FYI: ChibiOS shell on USB virtual serial (CDC ACM) on Linux needs a delay

Postby stapelberg » Tue Apr 27, 2021 7:39 am

Hey!

I recently took a closer look at why the ChibiOS shell prompt would often not appear correctly on the USB virtual serial device, and wrote down the individual problems that I found, and solution I settled on:

https://michael.stapelberg.ch/posts/202 ... l-cdc-acm/

This issue was reproducible across platforms (ST32, KINETIS, MIMXRT1062), and the workaround works on Linux, macOS and Windows.

Perhaps this is something to apply to the other demos that use a USB virtual serial device, too?

Hope this helps a few people :)

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: FYI: ChibiOS shell on USB virtual serial (CDC ACM) on Linux needs a delay

Postby Giovanni » Tue Apr 27, 2021 8:18 am

Hi,

Good article, have you tried to exit the shell and see if it restarts? the semaphore is not necessarily signaled again.

Giovanni

stapelberg
Posts: 10
Joined: Wed Jun 03, 2020 9:17 pm
Has thanked: 4 times
Been thanked: 3 times

Re: FYI: ChibiOS shell on USB virtual serial (CDC ACM) on Linux needs a delay

Postby stapelberg » Tue Apr 27, 2021 8:30 am

Giovanni wrote:Hi,

Good article, have you tried to exit the shell and see if it restarts? the semaphore is not necessarily signaled again.

Giovanni


Unfortunately, there’s another bug with exiting the shell (causes a hardfault) that I haven’t had time to look into. Until that one is fixed, I can’t test the restart scenario.

Does resetting the semaphore not signal all waiters? Is there a better way to use a semaphore, or perhaps a different primitive, in this case?

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: FYI: ChibiOS shell on USB virtual serial (CDC ACM) on Linux needs a delay

Postby Giovanni » Tue Apr 27, 2021 8:37 am

stapelberg wrote:Unfortunately, there’s another bug with exiting the shell (causes a hardfault) that I haven’t had time to look into.


Is the shell susystem initialized? (calling shellInit()).

What you could do is something like this:

Code: Select all

forever
  if USB is not active then
    wait on the semaphore
  end
  spawn shell
  wait shell
  sleep a little bit
end


This way it waits on the semaphore if USB is not active, making sure it will be signaled on the next connection. Note that the Serial_USB driver has connect/disconnect events, you may try those too (CHN_CONNECTED, CHN_DISCONNECTED).

Giovanni


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 19 guests