Skip to content

Conversation

@laurensvalk
Copy link
Member

This way we don't need to do things like detaching the kernel driver.

This should improve our odds of being able to install NXT firmware from the browser.

This way we don't need to do things like detaching the kernel driver.

This should improve our odds of being able to install NXT firmware from the browser.
@dlech
Copy link
Member

dlech commented Dec 18, 2025

Did you check that this works on Windows and Mac too?

@laurensvalk
Copy link
Member Author

This was only tested on Ubuntu. Hoping for some feedback before we merge. Maybe @BertLindeman wants to try Windows? 😄

We don't even need to merge it into Pybricksdev per se. This is more of a stepping stone to make things simpler for the Pybricks Code implementation down the line.

@BertLindeman
Copy link

Maybe @BertLindeman wants to try Windows? 😄

sure but not manual 😉

Thinking of how to do this....

@dlech
Copy link
Member

dlech commented Dec 18, 2025

Thinking of how to do this....

Maybe something like this?

uvx --refresh --from git+https://github.com/pybricks/pybricksdev/tree/nxtflash pybricksdev ...

@BertLindeman
Copy link

BertLindeman commented Dec 18, 2025

Thanks David, but on uvx here.

Downloaded the nxtflash branch zip.
unzipped
renamed pybricksdev-nxtflash to pybricksdev
in that directory:
python -m pip install .
But that fails. Maybe just me doing this?

pybricksdev flash "\users\bert\downloads\lego\pybricks\CI firmware\firmware Build 4515 master"\ev3-firmware-build-4515-gitf3f6ccbe.zip
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Python311\Scripts\pybricksdev.exe\__main__.py", line 2, in <module>
    # Copyright (c) 2019-2020 The Pybricks Authors
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\pybricksdev\pybricksdev\cli\__init__.py", line 25, in <module>
    from pybricksdev.connections.pybricks import (
  File "C:\Python311\Lib\site-packages\pybricksdev\pybricksdev\connections\pybricks.py", line 20, in <module>
    from usb.core import Device as USBDevice
ModuleNotFoundError: No module named 'usb.core'

Verified that in the current pybricksdev/_vendored/pynxt/samba.py the updates are there..

[EDIT] pyusb is installed.

python -m pip show pyusb
Name: pyusb
Version: 1.2.1
Summary: Python USB access module
Home-page: https://pyusb.github.io/pyusb
Author: Jonas Malaco
Author-email: me@jonasmalaco.com
License: UNKNOWN
Location: C:\Users\bert\AppData\Roaming\Python\Python311\site-packages
Requires:
Required-by: pybricksdev

Could that be due to the usb directory in pybricksdev?

@dlech
Copy link
Member

dlech commented Dec 18, 2025

Thanks David, but no uvx here.

I highly recommend it. It is like pipx but better/faster/stronger. But you could do something similar with pipx as well.

Could that be due to the usb directory in pybricksdev?

If you are running from a directory that has usb subdirectory, then yes. Try running from a different directory.

@BertLindeman
Copy link

I am not so good in this plain python is better for me.
Temporary renamed usb to usbx in the installed ybricksdev (nxtflash)

Shows:

Creating firmware...
REPLY TO GET VERSION:  b'\x04\x00\x00\x00\x01\xf6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
hwid: 0
Erasing memory and preparing firmware download...
100%|███████████████████████████████████████████████████████████████████████████████████████████████████▋| 784k/786k [00:04<00:00, 179kB/s]
Downloading firmware...
100%|████████████████████████████████████████████████████████████████████████████████████████████████████| 786k/786k [00:03<00:00, 254kB/s]
Verifying...OK.
Restarting EV3...Done.

hwid zero while it is 6 on a flash on linux.

@laurensvalk
Copy link
Member Author

For this pull request, try it with a zip for NXT 😄

@BertLindeman
Copy link

Wow, I am sharp today (Flu)

Now:

>pybricksdev flash "\users\bert\downloads\lego\pybricks\CI firmware\firmware Build 4515 master"\nxt-firmware-build-4515-gitf3f6ccbe.zip
Creating firmware...
Looking for the NXT in SAM-BA mode...
Brick found!
Flashing firmware...
Flashing complete, jumping to 0x100000...
Firmware started.

The hub keeps clicking though.
Battery-out helps

@laurensvalk
Copy link
Member Author

Thanks for confirming Bert! (And hope you feel better soon. I'm down with the flu too.)

Yeah, the clicking sound tends to happen the first time after flashing sometimes. See pybricks/support#2430

As far as this pull request goes, that's fine. If it came up the second time that means flashing was successful.

What we changed here is something that should make it easier to support NXT installation from the browser, even though we're testing it with Python first.

@BertLindeman
Copy link

David, installed uv, interesting for one time tests. Thanks

@laurensvalk
Copy link
Member Author

laurensvalk commented Dec 19, 2025

This is getting a few steps ahead, but I'm curious about the following @BertLindeman:

Open the web developer tools (with ctrl+shift+i) on any website. Could be Pybricks Code or even here on GitHub. In the web console, paste and run the following:

await navigator.serial.requestPort({
  filters: [
    { usbVendorId: 0x03eb, usbProductId: 0x6124 }
  ]
});

If an NXT in update mode is connected, you should get something like this:

image

Then on the output you'll see a small structure containing connected: true

Connecting won't do anything, of course, but it's a good next step. It's probably too early to declare victory, but at this rate firmware installation on NXT is going to be easier than on SPIKE 😄

@BertLindeman
Copy link

BertLindeman commented Dec 19, 2025

Friday afternoon is library time.. But this takes only a second 😄

The pybricks connect pop-up comes up
with "No compatible device found"
and the console shows:

Irrelevant data ``` 129:1 Autofocus processing was blocked because a document already has a focused element. 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000110b-0000-1000-8000-00805f9b34fb, name='Buds FE van B S Ap' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000110c-0000-1000-8000-00805f9b34fb, name='Buds FE van B S Ap' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000110e-0000-1000-8000-00805f9b34fb, name='Buds FE van B S Ap' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000111e-0000-1000-8000-00805f9b34fb, name='Buds FE van B S Ap' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=00001200-0000-1000-8000-00805f9b34fb, name='Buds FE van B S Ap' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=00001105-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000110a-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000110c-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000110e-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=00001112-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=00001115-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=00001116-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000111f-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000112d-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000112f-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=00001132-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=00001800-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=00001801-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=00001855-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000fcf1-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000fef3-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=00001801-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=00001800-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000111f-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=00001132-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=00001116-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=00001115-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000112d-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000fcf1-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000110a-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000110e-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000112f-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000110c-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=00001855-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=00001105-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=00001112-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000fef3-0000-1000-8000-00805f9b34fb, name='A55 van Bert' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000110e-0000-1000-8000-00805f9b34fb, name='Buds FE van B S Ap' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000111e-0000-1000-8000-00805f9b34fb, name='Buds FE van B S Ap' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000110c-0000-1000-8000-00805f9b34fb, name='Buds FE van B S Ap' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=00001200-0000-1000-8000-00805f9b34fb, name='Buds FE van B S Ap' 129:1 Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000110b-0000-1000-8000-00805f9b34fb, name='Buds FE van B S Ap' ```

Something is blocking? No pybricks panels active.

No idea here.

[EDIT]
BUT I need to read your question....
NXT was not in update mode (yet).

@laurensvalk
Now:
image

Console shows (after select of the hub):

SerialPort {onconnect: null, ondisconnect: null, readable: null, writable: null, connected: true}
connected:true
onconnect:null
ondisconnect:null
readable:null
writable:null
[[Prototype]]:SerialPort

@laurensvalk
Copy link
Member Author

laurensvalk commented Dec 19, 2025

Awesome, thanks!

BOSSA is a flash programming utility for Atmel's SAM family of flash-based ARM microcontrollers. The motivation behind BOSSA is to create a simple, easy-to-use, open source utility to replace Atmel's SAM-BA software. BOSSA is an acronym for Basic Open Source SAM-BA Application to reflect that goal.

So Windows is even picking up the right driver out of the box. Would you believe it!

@dlech
Copy link
Member

dlech commented Dec 19, 2025

Would you believe it!

I would believe it if I also was which driver was currently in use on Windows. Is it the LEGO driver or some other driver? For example, if you install Arduino tools, it will match the bootloader on NXT instead of the LEGO driver.

@laurensvalk
Copy link
Member Author

We should test that also. If it's still available as a serial port but under a different name, that should be fine too.

It should be incredibly rare that another device with usbVendorId: 0x03eb, usbProductId: 0x6124 is attached and it looks like we can request some information from the device before we flash if we want to be sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants