micropython icon indicating copy to clipboard operation
micropython copied to clipboard

Compiling Problem

Open LlamaLad7 opened this issue 5 years ago • 13 comments

Hi. I have just managed to compile the firmware on a Linux VM, but when I set it as my firmware in Mu, and try to flash a hello world program, It gives an error. Here's the log

2018-11-26 19:30:03,154 - mu.logic:645(restore_session) INFO: Loaded files.
2018-11-26 19:30:03,154 - mu.logic:649(restore_session) INFO: User defined environment variables: []
2018-11-26 19:30:03,154 - mu.logic:653(restore_session) INFO: Minify scripts on micro:bit? False
2018-11-26 19:30:03,154 - mu.logic:658(restore_session) INFO: Custom micro:bit runtime path: D:\Documents\Programming\Python\Microbit\custom\firmware.hex
2018-11-26 19:30:03,176 - mu.logic:1112(change_mode) INFO: Workspace directory: C:\Users\l3gom\mu_code
2018-11-26 19:30:04,966 - mu.logic:695(new) INFO: Added a new tab.
2018-11-26 19:30:22,033 - mu.modes.microbit:239(flash) INFO: Preparing to flash script.
2018-11-26 19:30:22,033 - mu.modes.microbit:249(flash) DEBUG: Python script:
2018-11-26 19:30:22,033 - mu.modes.microbit:250(flash) DEBUG: b'from microbit import *\r\ndisplay.scroll("Hello World!")'
2018-11-26 19:30:22,034 - mu.modes.microbit:297(flash) INFO: Path to micro:bit: F:\
2018-11-26 19:30:22,035 - mu.modes.base:217(find_device) INFO: Found device on port: COM4
2018-11-26 19:30:22,035 - mu.modes.base:218(find_device) INFO: Serial number: 9900000040554E450039400C0000003F0000000097969901
2018-11-26 19:30:22,035 - mu.modes.microbit:302(flash) INFO: Serial port: COM4
2018-11-26 19:30:22,035 - mu.modes.microbit:303(flash) INFO: Device serial number: 9900000040554E450039400C0000003F0000000097969901
2018-11-26 19:30:22,035 - mu.modes.microbit:328(flash) INFO: Checking target device.
2018-11-26 19:30:22,539 - mu.modes.microbit:332(flash) INFO: {'sysname': 'microbit', 'nodename': 'microbit', 'release': '1.0.0', 'version': 'micro:bit v1.0.0+unknown on 2018-11-26; MicroPython v1.9.2-34-gd64154c73 on 2017-09-01', 'machine': 'micro:bit with nRF51822'}
2018-11-26 19:30:22,539 - mu.modes.microbit:351(flash) INFO: Board MicroPython: 1.0.0
2018-11-26 19:30:22,539 - mu.modes.microbit:353(flash) INFO: Mu MicroPython: 1.0.0
2018-11-26 19:30:22,539 - mu.modes.microbit:381(flash) INFO: Flashing new MicroPython runtime onto device
2018-11-26 19:30:26,589 - mu.logic:1039(show_admin) INFO: Showing logs from C:\Users\l3gom\AppData\Local\python\mu\Logs\mu.log
2018-11-26 19:30:31,719 - mu.modes.microbit:505(copy_main) INFO: Copying main.py onto device
2018-11-26 19:30:31,719 - mu.modes.microbit:515(copy_main) INFO: ["fd = open('main.py', 'wb')", 'f = fd.write', 'f(b\'from microbit import *\\r\\ndisplay.scroll("Hello World!")\')', 'fd.close()']
2018-11-26 19:30:32,835 - mu.modes.microbit:532(flash_failed) ERROR: Could not enter raw REPL.
2018-11-26 19:30:32,850 - mu.interface.main:711(show_message) DEBUG: There was a problem flashing the micro:bit.
2018-11-26 19:30:32,850 - mu.interface.main:712(show_message) DEBUG: Please do not disconnect the device until flashing has completed. Please check the logs for more information.
2018-11-26 19:30:34,498 - mu.logic:1039(show_admin) INFO: Showing logs from C:\Users\l3gom\AppData\Local\python\mu\Logs\mu.log
2018-11-26 19:30:43,133 - mu.interface.main:251(get_save_path) DEBUG: Getting save path: C:/Users/l3gom/mu_code/hi
2018-11-26 19:30:43,133 - mu.logic:876(check_for_shadow_module) INFO: Checking path "C:/Users/l3gom/mu_code/hi" for shadow module.
2018-11-26 19:30:43,133 - mu.logic:842(save_tab_to_file) INFO: Saving script to: C:/Users/l3gom/mu_code/hi.py
2018-11-26 19:30:43,133 - mu.logic:843(save_tab_to_file) DEBUG: from microbit import *

display.scroll("Hello World!")
2018-11-26 19:30:45,283 - mu.modes.microbit:239(flash) INFO: Preparing to flash script.
2018-11-26 19:30:45,283 - mu.modes.microbit:249(flash) DEBUG: Python script:
2018-11-26 19:30:45,283 - mu.modes.microbit:250(flash) DEBUG: b'from microbit import *\r\ndisplay.scroll("Hello World!")'
2018-11-26 19:30:45,284 - mu.modes.microbit:297(flash) INFO: Path to micro:bit: F:\
2018-11-26 19:30:45,285 - mu.modes.base:217(find_device) INFO: Found device on port: COM4
2018-11-26 19:30:45,285 - mu.modes.base:218(find_device) INFO: Serial number: 9900000040554E450039400C0000003F0000000097969901
2018-11-26 19:30:45,285 - mu.modes.microbit:302(flash) INFO: Serial port: COM4
2018-11-26 19:30:45,285 - mu.modes.microbit:303(flash) INFO: Device serial number: 9900000040554E450039400C0000003F0000000097969901
2018-11-26 19:30:45,285 - mu.modes.microbit:328(flash) INFO: Checking target device.
2018-11-26 19:30:45,788 - mu.modes.microbit:332(flash) INFO: {'sysname': 'microbit', 'nodename': 'microbit', 'release': '1.0.0', 'version': 'micro:bit v1.0.0+unknown on 2018-11-26; MicroPython v1.9.2-34-gd64154c73 on 2017-09-01', 'machine': 'micro:bit with nRF51822'}
2018-11-26 19:30:45,788 - mu.modes.microbit:351(flash) INFO: Board MicroPython: 1.0.0
2018-11-26 19:30:45,788 - mu.modes.microbit:353(flash) INFO: Mu MicroPython: 1.0.0
2018-11-26 19:30:45,788 - mu.modes.microbit:381(flash) INFO: Flashing new MicroPython runtime onto device
2018-11-26 19:30:54,970 - mu.modes.microbit:505(copy_main) INFO: Copying main.py onto device
2018-11-26 19:30:54,970 - mu.modes.microbit:515(copy_main) INFO: ["fd = open('main.py', 'wb')", 'f = fd.write', 'f(b\'from microbit import *\\r\\ndisplay.scroll("Hello World!")\')', 'fd.close()']
2018-11-26 19:30:56,085 - mu.modes.microbit:532(flash_failed) ERROR: Could not enter raw REPL.
2018-11-26 19:30:56,086 - mu.interface.main:711(show_message) DEBUG: There was a problem flashing the micro:bit.
2018-11-26 19:30:56,086 - mu.interface.main:712(show_message) DEBUG: Please do not disconnect the device until flashing has completed. Please check the logs for more information.
2018-11-26 19:30:57,361 - mu.logic:1039(show_admin) INFO: Showing logs from C:\Users\l3gom\AppData\Local\python\mu\Logs\mu.log

LlamaLad7 avatar Nov 26 '18 19:11 LlamaLad7

2018-11-26 19:30:56,085 - mu.modes.microbit:532(flash_failed) ERROR: Could not enter raw REPL.

This line means there is something wrong with the USB serial connection to the micro:bit. To debug further you'll need to try and access the REPL manually, using eg picocom /dev/ttyACM0 -b115200

dpgeorge avatar Nov 27 '18 05:11 dpgeorge

Hmm, I would have thought that it was a result of not being able to access the REPL as my firmware was corrupt, but I'll give that a go

LlamaLad7 avatar Nov 27 '18 07:11 LlamaLad7

Mu is able to read the MicroPython version info, so it can access the MicroPython serial, as it has to enter the raw REPL and parse the result from os.uname() to get this info:

2018-11-26 19:30:45,285 - mu.modes.microbit:328(flash) INFO: Checking target device.
2018-11-26 19:30:45,788 - mu.modes.microbit:332(flash) INFO: {'sysname': 'microbit', 'nodename': 'microbit', 'release': '1.0.0', 'version': 'micro:bit v1.0.0+unknown on 2018-11-26; MicroPython v1.9.2-34-gd64154c73 on 2017-09-01', 'machine': 'micro:bit with nRF51822'}

This sounds like an issue within Mu, could you open a GH issue in that repository? https://github.com/mu-editor/mu/issues/

carlosperate avatar Nov 27 '18 14:11 carlosperate

Yeah, that sounds like a Mu issue, so I'll do that. Just one more thing though, I followed the firmware flash instructions on: https://microbit.org/guide/firmware/ and the microbit produced FAIL.txt, saying the file wasn't compatible. Is this just because it doesn't support unofficial firmware?

LlamaLad7 avatar Nov 27 '18 19:11 LlamaLad7

Were you trying to load a DAPLink hex file (0250_kl26z_microbit_0x8000.hex) in Maintenance mode, or a MicroPython hex file?

The micro:bit firmware in that article refers to the software running in a secondary microcontroller (KL26), which gives you the USB storage device for flashing the micro:bit main microcontroller (nRF51).

There are no restrictions on the micro:bit loading alternative software. For instance, you can load J-Link as the firmware (https://www.segger.com/products/debug-probes/j-link/models/other-j-links/bbc-microbit-j-link-upgrade/) in the KL26, or load any hex file in the nRF51 (as long as the hex files doesn't try to write to memory locations not available in the microcontroller).

carlosperate avatar Nov 27 '18 21:11 carlosperate

I was just flashing the firmware.hex generated by the "make all" command in the unedited source code from this repo, i.e the micropython

LlamaLad7 avatar Nov 27 '18 22:11 LlamaLad7

My main problem was trying to make room for a larger python program on the microbit, so if anyone has any suggestions for that, or compiling and flashing this repo properly, then I would be very grateful.

LlamaLad7 avatar Nov 28 '18 07:11 LlamaLad7

Ah, don't worry. I see where I went wrong. I thought the micropython firmware was a replacement for the DAPlink firmware, but you have to use makecombinedhex.py first. Thanks guys

LlamaLad7 avatar Nov 28 '18 18:11 LlamaLad7

I have raised before the issue that calling the file generated by MicroPython 'firmware' is a misnoma. The only firmware the micro:bit has is that which is programmed into the interface chip when in MAINTENANCE mode (the DAPLink image) and the DAPLink recovery bootloader (also stored in the interface chip) that provides maintenance mode features.

The file generated by MicroPython is the MicroPython interpreter, the micro:bit API, parts of the Lancaster DAL and other bits and pieces. It is not firmware though, as it is combined with a user script source (via makecombinedhex.py") into a complete hex file that is then flashed in it's entirety onto the micro:bit.

DavidWhaleMEF avatar Nov 28 '18 19:11 DavidWhaleMEF

As David has mentioned, the firmware from https://microbit.org/guide/firmware/ is not related to MicroPython. The MicroPython hex files are flashed like any other micro:bit program and there is no restrictions.

How large was your Python program? Was the problem running out of RAM or flash?

carlosperate avatar Nov 28 '18 23:11 carlosperate

The original issue was running out of flash, but I fixed that and now I'm running out of RAM!

LlamaLad7 avatar Nov 29 '18 07:11 LlamaLad7

@lego3708 rather than me opening up a new issue just yet, can I ask which OS you were running on your Linux VM?

I'm trying to follow the build instructions for various Ubuntu releases, but I'm yet to find one that works.

sdt avatar Dec 06 '18 23:12 sdt

Hi @std, what problems are you seeing? I've been building MicroPython on 16.04 VMs using Vagrant and these scripts: https://github.com/carlosperate/microbit-dev-env/

There is also these two issues more related than this one, where we can continue this thread: https://github.com/bbcmicrobit/micropython/issues/604 and https://github.com/bbcmicrobit/micropython/issues/619

carlosperate avatar Dec 12 '18 08:12 carlosperate