microbit-foundation / microbit-fs

A TypeScript library to manipulate the micro:bit MicroPython filesystem.
https://microbit-foundation.github.io/microbit-fs/
MIT License
12 stars 1 forks source link

MicroPython fs-builder: Incorrect generation of a full chunk. #4

Closed microbit-carlos closed 5 years ago

microbit-carlos commented 5 years ago

Creating a file that takes exactly 1 chunk (128 Bytes) doesn't generate the right hex content:

Code to create the file (Chunk has 1 Byte marker, 1 Byte ail, 1 Byte offset, 1 Byte file name length, 13 Bytes file name, 111 Bytes of data):

microbitFs.write(
    'a.py',
    'a = """abcdefghijklmnopqrstuvwxyz\n' +
        'abcdefghijklmnopqrstuvwxyz\n' +
        'abcdefghijklmnopqrstuvwxyz\n' +
        'abcdefghijklmnopqrstuvwxyz\n' +
        'a"""\n'
);

Generates 1 chunk:

:108D0000FE0004612E707961203D202222226162E2
:108D1000636465666768696A6B6C6D6E6F707172AB
:108D2000737475767778797A0A61626364656667C9
:108D300068696A6B6C6D6E6F70717273747576773B
:108D400078797A0A6162636465666768696A6B6CE0
:108D50006D6E6F707172737475767778797A0A6157
:108D600062636465666768696A6B6C6D6E6F70716B
:108D700072737475767778797A0A612222220AFFF3

MicroPython generates 2 chunks (second one is empty):

:10CA0000FE0004612E707961203D202222226162A5
:10CA1000636465666768696A6B6C6D6E6F7071726E
:10CA2000737475767778797A0A616263646566678C
:10CA300068696A6B6C6D6E6F7071727374757677FE
:10CA400078797A0A6162636465666768696A6B6CA3
:10CA50006D6E6F707172737475767778797A0A611A
:10CA600062636465666768696A6B6C6D6E6F70712E
:10CA700072737475767778797A0A612222220A7E37
:10CA80007DFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF38
:10CA9000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA6
:10CAA000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF96
:10CAB000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF86
:10CAC000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF76
:10CAD000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF66
:10CAE000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56
:10CAF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF46
microbit-carlos commented 5 years ago

Implemented in https://github.com/microbit-foundation/microbit-fs/commit/6aa703416ffe70907d8bc45383339737b3c4b8f2.