RTT: Crash with `'utf-8' codec can't decode byte` when arrow key is pressed
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 560
- Avg merge
- 1h 41m
- Merged PRs (30d)
- 3
Description
On Windows, on Powershell, if I press an arrow key while pyocd rtt is running, it crashes:
> pyocd rtt --target stm32c011f4px
0001518 I Target type is stm32c011f4px [board]
0001636 I DP IDR = 0x0bc11477 (v1 MINDP rev0) [dap]
0001636 I debugvar 'DbgMCU_APB_Fz1' = 0x0 (0) [pack_target]
0001636 I debugvar 'DbgMCU_APB_Fz2' = 0x0 (0) [pack_target]
0001636 I debugvar 'DbgMCU_CR' = 0x6 (6) [pack_target]
0001636 I AHB-AP#0 IDR = 0x04770031 (AHB-AP var3 rev0) [discovery]
0001636 I AHB-AP#0 Class 0x1 ROM table #0 @ 0xf0000000 (designer=020:ST part=466) [rom_table]
0001652 I [0]<e00ff000:ROM class=1 designer=43b:Arm part=4c0> [rom_table]
0001652 I AHB-AP#0 Class 0x1 ROM table #1 @ 0xe00ff000 (designer=43b:Arm part=4c0) [rom_table]
0001652 I [0]<e000e000:SCS v6-M class=14 designer=43b:Arm part=008> [rom_table]
0001652 I [1]<e0001000:DWT v6-M class=14 designer=43b:Arm part=00a> [rom_table]
0001652 I [2]<e0002000:BPU v6-M class=14 designer=43b:Arm part=00b> [rom_table]
0001652 I CPU core #0: Cortex-M0+ r0p1, v6.0-M architecture [cortex_m]
0001652 I Extensions: [MPU] [cortex_m]
0001652 I Setting core #0 (Cortex-M0+) default reset sequence to ResetSystem [pack_target]
0001652 I 2 hardware watchpoints [dwt]
0001652 I 4 hardware breakpoints, 0 literal comparators [fpb]
0001704 I 3 up channels and 3 down channels found [rtt_cmd]
0001704 I Reading from up channel 0 ("Terminal") [rtt_cmd]
0001706 I Writing to down channel -1 ("") [rtt_cmd]
My micro output while I not press the arrow key...
and when I press an arrow key by accident:
0002058 C 'utf-8' codec can't decode byte 0xe0 in position 0: unexpected end of data [__main__]
When I press the arrows key, Powershell writes ANSI code to stdin:
> cat.exe > outptu.txt # press up, down, left, right, end, ctrl-c
> xxd .\outptu.txt
00000000: 1b5b 411b 5b42 1b5b 441b 5b43 0a .[A.[B.[D.[C.
Version Info
> pyocd --version
0.36.0
> pwsh --version
PowerShell 7.4.6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the pyocd rtt command's stdin handling and reproduce the crash on Windows PowerShell 7.4.6 using pyOCD 0.36.0. Compare arrow-key ANSI input with the UTF-8 decoding failure shown in the report. Done means pressing arrow keys no longer crashes and RTT output continues.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell, python
- Domain
- cli, embedded-iot
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100