Skip to content

edbg: long lines flooded over serial become garbled #14548

Open
@bergzand

Description

Description

The virtual COM port provided by the EDBG debuggers doesn't correctly handled rapid bulk transfers from the host computer. This becomes apparent when using a local setup. A remote setup or a slow host such as a raspberry pi doesn't flood the USB serial fast enough to cause issues. That's also why it doesn't fail on the nightlies.

Bisecting turns up this commit: 68a35f5, but that only uncovered the issue.

Steps to reproduce the issue

Locally run tests/shell on a board using EDBG such as the samr21-xpro or the same54-xpro. This fails on the long line test, where it starts to produce garbage chars.

Expected results

The test succeeds both locally and on Murdock/IoT-LAB.

Actual results

The test fails after the EDBG serial produces garbage instead of the long line:

local node FAIL
$ BOARD=samr21-xpro make -C tests/shell/ flash test
make: Entering directory '/home/mlenders/Repositories/RIOT-OS/RIOT/tests/shell'
Building application "tests_shell" for "samr21-xpro" with MCU "samd21".

"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/boards/samr21-xpro
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/core
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/cpu/samd21
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/cpu/cortexm_common
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/cpu/cortexm_common/periph
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/cpu/sam0_common
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/cpu/sam0_common/periph
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/cpu/samd21/periph
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/drivers
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/drivers/periph_common
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/app_metadata
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/auto_init
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/isrpipe
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/newlib_syscalls_default
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/pm_layered
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/ps
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/shell
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/shell/commands
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/stdio_uart
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/tsrb
   text	   data	    bss	    dec	    hex	filename
  12848	    132	   2624	  15604	   3cf4	/home/mlenders/Repositories/RIOT-OS/RIOT/tests/shell/bin/samr21-xpro/tests_shell.elf
/home/mlenders/Repositories/RIOT-OS/RIOT-release/dist/tools/edbg/edbg  --target samr21 --verbose --file /home/mlenders/Repositories/RIOT-OS/RIOT/tests/shell/bin/samr21-xpro/tests_shell.bin --verify || /home/mlenders/Repositories/RIOT-OS/RIOT-release/dist/tools/edbg/edbg  --target samr21 --verbose --file /home/mlenders/Repositories/RIOT-OS/RIOT/tests/shell/bin/samr21-xpro/tests_shell.bin --verify --program
Debugger: ATMEL EDBG CMSIS-DAP ATML2127031800005161 01.1A.00FB (S)
Clock frequency: 16.0 MHz
Target: SAM R21G18 (Rev C)
Verification...................................................... done.

socat - open:/dev/ttyACM0,b115200,echo=0,raw
�	"R�
shell: incorrect quoting
> bufsize
x�
> 
> bufsize
128
> ________________________________________________________________________________________________________________________________verylong
________________________________________________________________�8����A 8
                                                                         	$�`�@��^�吧���!:۳
shell: command not found: ________________________________________________________________�8����A
> -j1/��$n�H�"<P)�I�{mː�v�?DnTimeout in expect script at "child.expect('shell: maximum line length exceeded')" (../RIOT/tests/shell/tests/01-run.py:150)

make: *** [/home/mlenders/Repositories/RIOT-OS/RIOT-release/Makefile.include:770: test] Error 1
make: Leaving directory '/home/mlenders/Repositories/RIOT-OS/RIOT/tests/shell'

However, it doesn't fail when using the same setup on the IoT-LAB:

On Saclay site of IoT-LAB PASS
$ BOARD=samr21-xpro IOTLAB_NODE=auto-ssh make -C tests/shell/ flash test
make: Entering directory '/home/mlenders/Repositories/RIOT-OS/RIOT/tests/shell'
Building application "tests_shell" for "samr21-xpro" with MCU "samd21".

"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/boards/samr21-xpro
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/core
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/cpu/samd21
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/cpu/cortexm_common
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/cpu/cortexm_common/periph
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/cpu/sam0_common
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/cpu/sam0_common/periph
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/cpu/samd21/periph
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/drivers
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/drivers/periph_common
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/app_metadata
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/auto_init
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/isrpipe
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/newlib_syscalls_default
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/pm_layered
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/ps
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/shell
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/shell/commands
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/stdio_uart
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT-release/sys/tsrb
   text	   data	    bss	    dec	    hex	filename
  12848	    132	   2624	  15604	   3cf4	/home/mlenders/Repositories/RIOT-OS/RIOT/tests/shell/bin/samr21-xpro/tests_shell.elf
iotlab-node --jmespath='keys(@)[0]' --format='int'  --list saclay,samr21,10 --flash /home/mlenders/Repositories/RIOT-OS/RIOT/tests/shell/bin/samr21-xpro/tests_shell.bin | grep 0
0

ssh -t lenders@saclay.iot-lab.info 'socat - tcp:samr21-10.saclay.iot-lab.info:20000'

> 
> bufsize
bufsize
128
> ________________________________________________________________________________________________________________________________verylong
________________________________________________________________________________________________________________________________verylong
shell: maximum line length exceeded
> garbage1234
garbage1234
> 
> start_test
start_test
[TEST_START]
> 

> 
> 


> 
> echo a string
echo a string
"echo""a""string"
> echo   multiple   spaces   between   argv
echo   multiple   spaces   between   argv
"echo""multiple""spaces""between""argv"
> echo 	 tabs		 processed 		like	 		spaces
echo 	 tabs		 processed 		like	 		spaces
"echo""tabs""processed""like""spaces"
> 123456789012345678901234567890123456789012345678901234567890
123456789012345678901234567890123456789012345678901234567890
shell: command not found: 123456789012345678901234567890123456789012345678901234567890
> unknown_command
unknown_command
shell: command not found: unknown_command
>      echo leading spaces
     echo leading spaces
"echo""leading""spaces"
> 					echo leading tabs
					echo leading tabs
"echo""leading""tabs"
> echo trailing spaces     
echo trailing spaces     
"echo""trailing""spaces"
> echo trailing tabs					
echo trailing tabs					
"echo""trailing""tabs"
> hello-world
hello-world
shell: command not found: hello-world
echo
echo
"echo"
> echo \'
echo \'
"echo""'"
> echo \"
echo \"
"echo""""
> echo escaped\ space
echo escaped\ space
"echo""escaped space"
> echo escape within '\s\i\n\g\l\e\q\u\o\t\e'
echo escape within '\s\i\n\g\l\e\q\u\o\t\e'
"echo""escape""within""singlequote"
> echo escape within "\d\o\u\b\l\e\q\u\o\t\e"
echo escape within "\d\o\u\b\l\e\q\u\o\t\e"
"echo""escape""within""doublequote"
> echo "t\e st" "\"" '\'' a\ b
echo "t\e st" "\"" '\'' a\ b
"echo""te st"""""'""a b"
> echo "hello"world
echo "hello"world
"echo""helloworld"
> echo hel"lowo"rld
echo hel"lowo"rld
"echo""helloworld"
> echo hello"world"
echo hello"world"
"echo""helloworld"
> echo quoted space " "
echo quoted space " "
"echo""quoted""space"" "
> echo abc"def'ghijk"lmn
echo abc"def'ghijk"lmn
"echo""abcdef'ghijklmn"
> echo abc'def"ghijk'lmn
echo abc'def"ghijk'lmn
"echo""abcdef"ghijklmn"
> echo "'" '"'
echo "'" '"'
"echo""'""""
> echo a\
echo a\
shell: incorrect quoting
> echo "
echo "
shell: incorrect quoting
> echo '
echo '
shell: incorrect quoting
> echo abcdef"ghijklmn
echo abcdef"ghijklmn
shell: incorrect quoting
> echo abcdef'ghijklmn
echo abcdef'ghijklmn
shell: incorrect quoting
> ps
ps
	pid | state    Q | pri 
	  1 | pending  Q |  15
	  2 | running  Q |   7
> help
help
Command              Description
---------------------------------------
bufsize              Get the shell's buffer size
start_test           starts a test
end_test             ends a test
echo                 prints the input command
reboot               Reboot the node
version              Prints current RIOT_VERSION
pm                   interact with layered PM subsystem
ps                   Prints information about running threads.
app_metadata         Returns application metadata
> reboot
reboot
main(): This is RIOT! (Version: 2020.10-devel-18-gab072-2020.07-branch)
test_shell.
> end_test
end_test
[TEST_END]
> 
make: Leaving directory '/home/mlenders/Repositories/RIOT-OS/RIOT/tests/shell'

Metadata

Assignees

No one assigned

    Labels

    Area: toolsArea: Supplementary toolsType: bugThe issue reports a bug / The PR fixes a bug (including spelling errors)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions