Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

U2conv.py on Win fails if volume names have non-ASCII chars #95

Closed
al1fch opened this issue Apr 8, 2021 · 6 comments · Fixed by #148
Closed

U2conv.py on Win fails if volume names have non-ASCII chars #95

al1fch opened this issue Apr 8, 2021 · 6 comments · Fixed by #148
Labels
bug Something isn't working

Comments

@al1fch
Copy link

al1fch commented Apr 8, 2021

Hi
No problem with Ubuntu, works great !! Thanks !!

On Windows10 I got u2conv.py error when i try to flash Pico Py board
Windows 10 French
Arduino IDE 1.8.13
Raspberry Pi Pico core version 1.0.1
Same error with Fade or any other example code
Error message :

Resetting COM8
Traceback (most recent call last):
Une erreur est survenue lors du transfert du croquis
  File "C:\Users\Lenovo\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\1.0.1/tools/uf2conv.py", line 368, in <module>
Converting to uf2, output size: 439296, start address: 0x2000
    main()
  File "C:\Users\Lenovo\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\1.0.1/tools/uf2conv.py", line 355, in main
    drives = get_drives()
  File "C:\Users\Lenovo\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\1.0.1/tools/uf2conv.py", line 233, in get_drives
    for line in to_str(r).split('\n'):
  File "C:\Users\Lenovo\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\1.0.1/tools/uf2conv.py", line 225, in to_str
    return b.decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe6 in position 225: invalid continuation `byte`

Best Regards

@earlephilhower
Copy link
Owner

Somehow wmic is reporting something very weird on your system. each drive entry should be 2-3 bytes (i.e. C:), not >200, and there shouldn't be anything outside plain ASCII.

Can you open a cmd window and run wmic path win32_logicaldisk get deviceid, volumename, filesystem, drivetype and post the output to let us see what the script is seeing?

@Bodmer
Copy link
Contributor

Bodmer commented Apr 8, 2021

I suspect a volume name has an accented character. Although these are in the range 128-255, some in that range get utf8 encoded.

@al1fch
Copy link
Author

al1fch commented Apr 9, 2021

Thanks ! Solved
No bug ,the problem was on my side : µ character in a volume name
Here was the result of mentionned windows cmd :

DeviceID  DriveType  FileSystem  VolumeName
C:        3          NTFS
D:        3          NTFS
E:        3          FAT32
F:        2          FAT32       µSD

Solved

@Bodmer
Copy link
Contributor

Bodmer commented Apr 9, 2021

Makes sense, mu is 0xE6 in the French extended character set. So the volume name is reported in pure ASCII but is being interpreted in Python as utf8 encoded, and then it is an illegal sequence. So it is a bug, since the extended character set is allowed in Windows volume names.

@earlephilhower
Copy link
Owner

Well, not pure ASCII as that would only have from 0..127, but in the Windows codepage for French which is definitely not UTF-8!

It's a pain because the upload tool is itself from Microsoft(!!!) and they mixed up codepages and utf-8. If SO is correct, WMIC uses the codepage for piped outputs but changes to Unicode if redirected to a file.

@earlephilhower
Copy link
Owner

Oh, and thanks @al1fch for following up. Now that I know how to repro on Windows, I can try and find a solution. Powershell, maybe, as I think that's always unicode...

@earlephilhower earlephilhower changed the title U2conv.py error on Windows10 U2conv.py on Win fails if volume names have non-ASCII chars Apr 9, 2021
@earlephilhower earlephilhower added the bug Something isn't working label Apr 9, 2021
earlephilhower added a commit that referenced this issue May 19, 2021
earlephilhower added a commit that referenced this issue May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants