Skip to content

CreateAI HEX over 64 KiB runs on micro:bit but cannot be imported into MakeCode #7062

Description

@lester47

Describe the bug

A project trained in micro:bit CreateAI works correctly when its exported HEX file is flashed directly to a micro:bit V2. The trained model recognizes all seven movement classes.

However, importing the same HEX file back into MakeCode displays:

Sorry, we couldn’t recognize this file.

The students followed the official CreateAI workflow correctly. The problem remains after importing the original sample JSON, retraining the model, exporting to MakeCode, and using “Download as File” again.

Technical inspection indicates that the MakeCode/PXT editable source embedded in Intel HEX record type 0x0E exceeds the 64 KiB boundary.

For the affected file:

  • Actual LZMA-compressed embedded source: 74,688 bytes
  • Length recorded in the embedded-source header: 9,152 bytes
  • Difference: exactly 65,536 bytes
  • Decompressed project size: 764,184 bytes
  • The type-0x0E address reaches 0xFFF0 and then wraps to 0x0000

This appears to be a 16-bit length or address overflow:

74,688 - 65,536 = 9,152

The executable firmware remains valid, so the HEX can still be flashed and run. However, MakeCode cannot reconstruct the editable project because the embedded compressed source is incomplete or overwritten after the address wrap.

The embedded project contains:

  • autogenerated.ts
  • dataset.json
  • main.blocks
  • main.ts
  • ml-metadata.json
  • pxt.json
  • _packaged-extensions.json

The largest embedded files are:

  • dataset.json: 551,230 bytes
  • _packaged-extensions.json: 161,986 bytes
  • autogenerated.ts: 10,498 bytes

We confirmed the suspected cause by recovering the complete wrapped source and creating an editable copy in which only the embedded dataset.json was replaced with {}. The separate CreateAI sample JSON was retained for future retraining.

After this change:

  • Compressed embedded source decreased to 33,535 bytes
  • No type-0x0E address wrap occurred
  • The trained model in autogenerated.ts remained intact
  • All seven ML event blocks remained intact
  • The repaired HEX imported successfully into MakeCode

To Reproduce

  1. Open micro:bit CreateAI.
  2. Create seven movement classes.
  3. Record approximately 20–30 movement samples for each class.
  4. Train and test the model.
  5. Export the trained project to MakeCode.
  6. In MakeCode, use “Download as File” to save the project as a HEX file.
  7. Flash the HEX directly to a micro:bit V2 and confirm that the trained model works.
  8. Return to https://makecode.microbit.org/.
  9. Select Import → Import File.
  10. Select the same downloaded HEX file.
  11. Click Continue.
  12. MakeCode reports that it cannot recognize the file.

The issue appears when the LZMA-compressed PXT embedded-source data exceeds 65,535 bytes.

Expected behavior

A HEX file generated through the official CreateAI and MakeCode workflow should remain importable into MakeCode.

If embedded editable-source data cannot exceed 64 KiB, CreateAI or MakeCode should detect this before export and do one of the following:

  • Store dataset.json separately instead of embedding it in the HEX
  • Use an embedded-source format that supports data beyond the 64 KiB boundary
  • Correctly encode and reconstruct multiple type-0x0E sections
  • Warn the user before downloading a file that cannot be reopened
  • Provide a separate editable project-backup format

Students should not receive an apparently valid project file that runs on the micro:bit but cannot be reopened in MakeCode.

Screenshots

Attached screenshots show:

  1. MakeCode reporting that it cannot recognize the original CreateAI HEX file.
  2. The repaired project successfully opened in MakeCode with all seven ML event blocks visible.

The original failing HEX and repaired HEX can also be attached for comparison.

micro:bit version (please complete the following information):

  • micro:bit V2
  • The issue concerns CreateAI/MakeCode project export and import, rather than a hardware failure.
  • The original HEX runs correctly when flashed to the micro:bit.

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Google Chrome
  • Browser version: Current installed version
  • MakeCode target: 9.0.8
  • PXT version: 13.0.5
  • Project editor: blocksprj
  • Machine-learning extension: pxt-microbit-ml v1.0.14
  • MakeCode URL: https://makecode.microbit.org/

Smartphone (please complete the following information):

  • Device: Not applicable
  • OS: Not applicable
  • Browser: Not applicable
  • Version: Not applicable

The problem was reproduced on a Windows desktop computer.

Additional context

This has caused repeated disruption in a classroom environment. Students successfully complete data collection and model training, download the project, and later discover that it cannot be reopened in MakeCode.

Because the same HEX still runs on the micro:bit, the downloaded file appears valid even though its editable project data cannot be recovered through the normal MakeCode interface.

The failure has occurred repeatedly and is not an isolated student error.

The original CreateAI project used seven movement classes with approximately 20–30 samples per class.

A separate sample JSON backup is available. Because it contains the students’ complete movement-training data, it is not being attached publicly, but it can be provided privately upon request.

Files available for reproduction:

  • Original CreateAI HEX that runs on the micro:bit but cannot be imported into MakeCode
  • Repaired MakeCode-importable HEX
  • Original CreateAI sample JSON, available privately
  • Screenshot of the MakeCode import error
  • Screenshot of the repaired project opened successfully
  • Technical comparison of the original and repaired type-0x0E records

正手-刪減版-data-samples.json

Metadata

Metadata

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions