microsoft / uf2

UF2 file format specification
Other
849 stars 164 forks source link

utils/uf2conv.py: Fix padding with Python3 #71

Closed JohnAZoidberg closed 1 year ago

JohnAZoidberg commented 1 year ago

Reproduce with:

echo -n foo12345679 > foo
echo -n bar12345679 > bar

./utils/uf2conv.py foo -c -b 0x100 -o foo.uf2
./utils/uf2conv.py bar -c -b 0x1000 -o bar.uf2

cat foo.uf2 bar.uf2 > combined.uf2
./utils/uf2conv.py -i combined.uf2

Would fail like this

--- UF2 File Header Info ---
All block flag values consistent, 0x0000
----------------------------
Traceback (most recent call last):
  File "/home/zoid/clone/uf2/./utils/uf2conv.py", line 360, in <module>
    main()
  File "/home/zoid/clone/uf2/./utils/uf2conv.py", line 328, in main
    convert_from_uf2(inpbuf)
  File "/home/zoid/clone/uf2/./utils/uf2conv.py", line 109, in convert_from_uf2
    return b"".join(outp)
TypeError: sequence item 1: expected a bytes-like object, int found
vkottler commented 1 year ago

I did a large refactor of this code here as well: https://github.com/microsoft/uf2/issues/42#issuecomment-1551077808.

mmoskal commented 1 year ago

thank you!