pybricks / support

Pybricks support and general discussion
MIT License
109 stars 6 forks source link

[Bug] Short Press did not boot stock firmware #208

Closed HeyLlama closed 3 years ago

HeyLlama commented 3 years ago

I have "successfully" flashed ('primehub', '3.0.0a13', 'v3.0.0a13-1-g2aa1cfef on 2021-01-08') into my inventor hub. At least the Mindstorms app was saying it was successful.

It did reboot right after flashing but it was booting up pybricks instead of standard firmware as stated in #167 . Tested https://code.pybricks.com/ on Chrome, that works.

I tried both short press and long press. It was all pybricks for some reason. I'm not sure how to access standard firmware to charge the battery...Please help : (

HeyLlama commented 3 years ago

https://github.com/pybricks/pybricksdev/blob/master/README_dfu.rst This saved me. Thank you πŸ™

laurensvalk commented 3 years ago

Thanks for sharing this.

What happened when you tried a short press (~half a second)? Did Pybricks come on straight away? Or did nothing happen at all?

If you ever feel like trying this again, it would be great to know what happens if you power on by plugging in USB, instead of pressing any buttons. The expected result is the same as a short press, so stock firmware.

For your information, we intend to implement the DFU recovery step in our online app so users won't have to install anything. That's why the Prime Hub / Inventor Hub is not in beta just yet for now.

HeyLlama commented 3 years ago

I'll try again tonight now I know how to restore the stock OS :)

Half a second short press didn't boot up anything. Nor does plugging in USB.

One red flag was after flashing Pybricks, my hub rebooted Pybricks instead of stock firmware. I'll let you know if I could reproduce this behaviour.

Cheers

laurensvalk commented 3 years ago

I can confirm this. Thanks a lot for highlighting this issue.

laurensvalk commented 3 years ago

I think we will update that installation guide with a link to a fixed version that is known to work, instead of the latest build, just in case.

I'm rolling back a few changes to make one that works.

HeyLlama commented 3 years ago

Thank you!

laurensvalk commented 3 years ago

Can you try it with [this build]? EDIT: link removed. Working link below.

That would be super helpful - thanks!

laurensvalk commented 3 years ago

When you open the new file, you should see the version in the comments at the top. Just to make sure, the new version is:

# Version: v3.0.0a13-7-g97e3745a
HeyLlama commented 3 years ago

Will do! I'll let you know

Cheers

HeyLlama commented 3 years ago

Unfortunately, the build you provided did not work either. Same behaviour, no reboot at all this time after the bluetooth light blinked pink-green-blue. No reaction from plugging in USB cable nor short press. Long press does boot Pybricks tho. I'm starting to suspect if this has anything to do with the newest firmware update from MINDSTORMS. Perhaps they changed the bootloader?

HeyLlama commented 3 years ago

image This was the console output from the app.

laurensvalk commented 3 years ago

Thanks for looking into this. This is interesting. This build did work for me, so I’d have to dig a bit deeper to see what could cause it.

Good reason to expedite the work on the easy installer and recovery from within our online app πŸ˜„

HeyLlama commented 3 years ago

Can't wait for the beta release! Thank you for the hard work πŸ˜„

HeyLlama commented 3 years ago

image I ran the download program again and this showed up in the console. Looks like there was an error before the installation program.

laurensvalk commented 3 years ago

This is the expected output for the download program. It’s a lot of data that doesn’t do anything by itself.

The installer then reads it as a text file. Line by line instead of all at once to avoid that memory error.

HeyLlama commented 3 years ago

Gotcha. Thank you!

laurensvalk commented 3 years ago

To get a taste of the easier recovery, check out this page.

For vendor ID, choose 0x0694:

image

Put the hub in DFU mode:

Click connect. Then select this one from the popup:

image

After connecting, choose this from the given options:

image

You can use the default for everything else. Then select the firmware file (You can find them here) and click download.

image

The only caveat is that some sort of USB driver must already be installed or access to the USB device must be given. For Windows this one works.

danielgaertner commented 3 years ago

Hello, my name is Daniel. I am a beginner and I flash the pybricks firmware on my lego inventor hub with the original lego software for use in Linux. The dual boot dosn't work any more with the new firmware from pybricks. Can you tell me easy and exact steps to flash a new firmware on the inventor hub with dual boot, or restore the original lego firmware. Thank you!

laurensvalk commented 3 years ago

Thanks Daniel. Yes, we’ll give you step by step instructions. Specifically which OS do you have?

I’m also going to temporarily close the beta on the dual boot, until we document the restore step a bit better. Thank you both for highlighting this.

HeyLlama commented 3 years ago

Hello, my name is Daniel. I am a beginner and I flash the pybricks firmware on my lego inventor hub with the original lego software for use in Linux. The dual boot dosn't work any more with the new firmware from pybricks. Can you tell me easy and exact steps to flash a new firmware on the inventor hub with dual boot, or restore the original lego firmware. Thank you!

Hi Daniel, I'm running MacOS so if you have other unix based system this method should work too.

Follow the steps to install pybricksdev https://github.com/pybricks/pybricksdev

Make sure poetry and pyenv are installed. And you'd need dfu-util too. I’d recommend homebrew for installing these packages: https://brew.sh/

Pick a newer firmware (1.0ish) from the firmware folder and download (.bin), rename to a simpler name if you will https://github.com/gpdaniels/spike-prime

This shows you how to get into DFU mode https://github.com/gpdaniels/spike-prime/blob/master/firmware/README.md

To check if your hub is connected, use this command: sudo dfu-util --list

Finally, to restore the stock firmware: https://github.com/pybricks/pybricksdev/blob/master/README_dfu.rst

Remark: remember to cd into pybricksdev before calling the restore command

laurensvalk commented 3 years ago

Thanks for helping out @HeyLlama --- much appreciated.

If you want to try it, I'm curious to hear if the web page above works on Mac. I've confirmed it on Windows and Linux.

If it works on all platforms, this maybe a bit easier for most people, compared to installing pybricksdev.

laurensvalk commented 3 years ago

Daniel, feel free to ask if you need any additional help.

HeyLlama commented 3 years ago

Hmm...I can't seem to find 0x0694 in the Vendor ID list on MacOS. Hub was indeed in DFU mode since I see it in the dfu-util --list OS version is Catalina 10.15.7 Chrome version 87.0.4280.141

laurensvalk commented 3 years ago

You can just type it in. The listed devices (dapboot, mbed) are only (apparently frequently used) suggestions.

danielgaertner commented 3 years ago

Yes I need more help! I tried to install poetry and a runtime error appares! daniel@PC-Stift:~$ poetry install

RuntimeError

Poetry could not find a pyproject.toml file in /home/daniel or its parents

at .local/lib/python3.8/site-packages/poetry/core/factory.py:367 in locate 363β”‚ if poetry_file.exists(): 364β”‚ return poetry_file 365β”‚ 366β”‚ else: β†’ 367β”‚ raise RuntimeError( 368β”‚ "Poetry could not find a pyproject.toml file in {} or its parents".format( 369β”‚ cwd 370β”‚ ) 371β”‚ )

danielgaertner commented 3 years ago

Poetry is now installed correctly! The error above is when I type poetry run pybricksdev udev | sudo tee /etc/udev/rules.d/99-pybricksdev.rules

laurensvalk commented 3 years ago

Poetry could not find a pyproject.toml file in /home/daniel or its parents

Did you download (or clone) pybricksdev? You need to be in that folder before calling poetry install. Then it can find the required files.

HeyLlama commented 3 years ago

Hey Daniel! Try this one instead: https://devanlai.github.io/webdfu/dfu-util/ You'd just need the .bin firmware for this one. Much easier. Thank you! @laurensvalk image image

laurensvalk commented 3 years ago

I guess that confirms it works on Mac too :smile: Thanks!

danielgaertner commented 3 years ago

whitch vendor id can I use!

HeyLlama commented 3 years ago

whitch vendor id can I use!

Type in 0x0694 and select the Lego option PS make sure your hub is in DFU mode

laurensvalk commented 3 years ago

Daniel, check out this post above which has some screenshots for guidance.

danielgaertner commented 3 years ago

I shows SecurityError: Access denied.

laurensvalk commented 3 years ago

At which step does it show that?

danielgaertner commented 3 years ago

After I tried to connect!

laurensvalk commented 3 years ago

Would you like to move over to this discussion forum here?

laurensvalk commented 3 years ago

@HeyLlama, I think I was able to reproduce it. It was due to two distinct issues so it took a while to find it. I would be greatful if you want to test this build. (v3.0.0a13-5-g9a80bef6).

HeyLlama commented 3 years ago

@HeyLlama, I think I was able to reproduce it. It was due to two distinct issues so it took a while to find it. I would be greatful if you want to test this build. (v3.0.0a13-5-g9a80bef6).

Excellent! I'll let you know :D

HeyLlama commented 3 years ago

v3.0.0a13-5-g9a80bef6 works! Thank you so much!!

laurensvalk commented 3 years ago

Yes! :rocket: Thanks for the help.

I've updated #167 to use this version instead of the latest build, just to be safe. Latest builds are only for those who know how to use recovery mode, which now includes you :wink:

laurensvalk commented 3 years ago

@HeyLlama, @danielgaertner: https://dfu.pybricks.com/

HeyLlama commented 3 years ago

@HeyLlama, @danielgaertner: https://dfu.pybricks.com/

Can confirm it works :D

laurensvalk commented 3 years ago

The firmware zip file also contains the .bin file for Pybricks, by the way. That will give you the regular boot instead of dual boot.

danielgaertner commented 3 years ago

I installed build # 838! No dual boot possible! Only Pybricks! In future I will use a older build!

danielgaertner commented 3 years ago

I tried to restore the original lego firmware with

"poetry run pybricksdev dfu restore ~/Downloads/96112deb24a934bfc19a13c7ea620f54.bin"

and the error "dfu-util: Invalid DFU suffix signature dfu-util: A valid DFU suffix will be required in a future dfu-util release!!! dfu-util: No DFU capable USB device available"

appiers!

danielgaertner commented 3 years ago

Now it works! I have not put the hub in DFU Mode!

laurensvalk commented 3 years ago

You can also restore the original firmware with that website. It's just a convenient alternative to pybricksdev.

Thanks for sharing that it is working for you.