carlosperate / ubittool

Utility to extract the contents of flash from a micro:bit, including MicroPython user code.
https://carlosperate.github.io/ubittool/
MIT License
16 stars 4 forks source link

Failure to read code from v1.x Microbit #14

Open kingsfleet opened 2 years ago

kingsfleet commented 2 years ago

Seen this problem when trying to extract code from a microbit where we have lost the source.

 ~/ Downloads/ubittool-0.6.0-mac-cli read-code Executing: Extract the MicroPython code to a file or print it.

MicroPython code will be output to console. Reading the micro:bit flash contents... Traceback (most recent call last): File "ubittool/cmds.py", line 164, in read_python_code File "uflash.py", line 200, in extract_script File "uflash.py", line 128, in unhexlify UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8a in position 1: invalid start byte


Error: Could not decode the MicroPython code from flash  ~/

I have attached the output of the read-flash command for reference.

DETAILS.TXT read-flash-output.txt.gz

carlosperate commented 2 years ago

Hi @kingsfleet, Was this a MakeCode or Python programme? Unfortunately that feature only works for very old Python programmes.

kingsfleet commented 2 years ago

This was with MakeCode using blocks unfortunately it glitched and lost the undo buffer loosing #1 son's Christmas light project. I was hoping to get the code back out. Is there anything useful in the hex dump that I can use?

carlosperate commented 2 years ago

Unfortunately not, sorry, if it was done in a recent version of MakeCode (from the last year or so) then the metadata with the code is no longer stored in flash. MakeCode can have several projects saved in the browser, is it worth a look to see if an old project there might be the one you lost, and if you have an old hex file with that project in your downloads folder you can still load it back into the editor.