-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: tessel unbrick #493
Comments
We should start talking about this now that boards are shipping |
👍 Building this feature could be a fun first project for anyone that wants to start getting involved. I also welcome thoughts on the CLI API I wrote about above. |
short read:
long read: I did a successfully unbrick (thanks to @johnnyman727 and @kevinmehall published docs) |
What does dterm/the serial console have to do with unbricking? I wouldn't worry about automating unbricking the samd21 bootloader using openocd. If that ever breaks when someone isn't trying to mess with the bootloader, that's a major problem. The normal update process doesn't touch it. |
Jon's instructions are for updating a device from a samd21 bootloader, firmware, and openwrt that were too old to be compatible with recent tools, and don't have much to do with recovering a device from a state that could happen in a user's hands. There are probably less than 5 Tessels in the world where those instructions are a reasonable thing to do. |
+1 to Kevin's comments. We should either import |
@kevinmehall thanks for clarification. I think to get the point and task to to for this issue. Could you put together basically ideas how a user would be able to brick one or all three parts? And additional which way is the right to fix it. So I will get the point too 😄 |
In my case I changed some passwords on the Tessel 2 which seams to hangup the t2-cli. Only the dfu-util solved this. |
I know there was a root pass somewhere but I couldn't find it once more in the cli code. |
@Student007 you could corrupt either the samd21 firmware or the mediatek firmware by sending improperly generated binaries or by interrupting the standard update process while the memory is being overwritten. We don't expose any standard tools for updating the bootloader but you could mess it up in by using a standard SWD programmer to erase the memory. If you do that, you're probably screwed.
I'm not sure what you mean here. The only thing shared on the T2 is your public SSH key. What were the symptoms you experienced? |
It hangs forever by waiting for open Tessel connections while provisioning. But this also happened while doing
|
@Student007 I think we're getting off topic here so I'll continue the discussion with you on Slack. I know what you ran into. |
@johnnyman727 Thanks again for your help unbricking my t2, discussed here. I am interested in working on this project, please advise. Given that libusb is required and may not be present, I'm thinking your idea to port it to node is best, so we can skip juggling python dependencies on top of node dependencies. |
@majgis fantastic. For now, let's just implement the You should be able to do it with dependencies already installed with the You'll probably want to download the the u-boot and squashfs images only when the command is run rather than adding them directly to the project because they are ~20MB. Just fetch them from the URL I gave you on the forums for now. Our general workflow for adding a command is to first add logic to the parser which then delegates to the controller to actually get the task done. The controller will almost always call Let me know if any of that was confusing. I'm excited that you're working on this feature and will make sure you have everything you need to succeed. |
That sounds straight forward. I'll get a branch going and report back when I have questions, most likely this weekend. |
Good news, I successfully rebricked my tessel. I will pretend the python script doesn't exist, so my only hope is to add this feature. Calling Tessel.get returns an error. The connection is getting created before the error. I will try cutting out the sickly middle man and get the connection directly. |
Let me know if you dislike how I gained access to just the connections: I will continue on now, but I can rework this step if you want something different. |
@johnnyman727 would it be possible to replace the following file with a .tar.gz? If yes, I can extend the logic in the update-fetch.js without having to write something separate, and it looks like I'd need to add a library if I am to stream the zip into memory as you did in that case. |
It's not exactly how I would have done it. I think the easier way might be to just pass
Sure thing! I've uploaded it so it should be available here: https://s3.amazonaws.com/builds.tessel.io/custom/new_build_next.tar.gz |
The error occurs on the call to tessel.connection.open() in discover.js: Digging deeper, the error is "LIBUSB_ERROR_PIPE" here: I thought of returning a tessel in a partially functional state, but then I worried about correcting the error handling for all the other commands that expect it to error in this way. Thank you for uploading the file! |
You'll have to diverge from the normal path before the call to |
@kevinmehall Thank you, your comment was very helpful. I will use an altSetting option, which can ultimately be passed to the setAltSetting method on the usbConnection, to pull out a tessel instance with the connection in the correct state. Questions:
|
Not sure. The OS should reset it to 0 when the interface is released, but that will make sure the endpoints get reset if it is closed and re-opened without releasing the interface. Or maybe working around an OS X bug?
0 disables the interface, 1 is flash mode, and 2 is pipe mode. https://github.com/tessel/t2-firmware/blob/master/firmware/usb.c#L31
The endpoints are the same, but the protocol is entirely different. For details on the protocol used on the interface 1 endpoints:
|
Yes, this was added because OSX has a bug where it doesn't release the interface in the event of a crash or process close. |
@majgis just wanted to check if you were able to make any progress with this. Can I help with anything? We've got another person on the forums with a corrupted image and they'll need this tool as well. |
I made it as far as getting a tessel instance in the correct flash mode and downloading the needed files into buffers (https://github.com/majgis/t2-cli/commits/unbrick-rb1). I'm ready to write the files to the tessel, but I'll admit I'm out of my element, learning as I go on this last part. If someone wants to take it so it can get done faster, that is fine. Otherwise, I'll put a solid effort in this weekend. |
@majgis it sounds like you're on the part of the project where you should be porting script.py into JavaScript. Do you have any specific questions about that that I can help with? |
Correct, script.py is ready to be ported. There are sufficient references to figure it out, and I'm sure I'll have very specific questions once I dive in, but nothing at the moment. I'll devote my weekend to it and see what I can get you by Monday, but no hard feelings if someone else wants to pound it out before then. |
👍 sounds good! |
I feel like I'm close: It gets all the way through writing, but throws an error on the reboot (same error I get when running the python script).
For now, I'm just focusing on the fact that after doing a manual reboot, it is still bricked. I ran the python script and it is still working fine, so definitely an issue with my code. I plan to step through python and node.js debuggers in tandem, unless of course you see something obvious. |
@majgis I didn't have much time to look into this tonight but at first glance, the code looked good (I'm impressed!). Nothing obviously wrong with it. I tried running it on my T2 with poor results. The first time it got stuck on writing uboot and all subsequent times it got stuck while writing squashfs. I added some console output to see if it was just slow at writing the data, but it seems to stop writing data and just hang indefinitely. I'm not sure if that's helpful or not but I'll try to look closer later this week. I think your recommendation of walking through the debugger is a good idea too. |
Thank you. The issues you described I haven't experienced yet...it gives the appearance of having worked on my setup. I will dig into the debuggers as soon as I can and see where that leaves us. |
I found the issue:
If you can confirm that unbricking is working on your end as well, we can move on to solving these two remaining issues: 1 The name is undefined when you do t2 list (same issue when using Python).
Is this something you want to address? 2 Restarting does not work (same issue when using Python)
Here is the python stack trace:
|
@majgis glad you were able to keep making progress! The name is being printed as I got a different error at the end about an argument needing to be a buffer. You should probably change the last argument of these control transfers ( Almost there! |
Thank you for your help. The undefined name issue is fixed. I am still having no luck with the reboot. On linux I get this error:
Is there any chance you have a different setup? How is it you are not seeing this error? I pushed the additional changes you suggested, even though I can't get far enough to test them. Let me know if the reboot is now working for you. |
@majgis I think we can likely just pull out the command to reset the interface. I can't remember why I added it to the Python script - it was likely just a late night trying to get the rest rigs working in China so we could start manufacturing. Additionally, I'm not able to get my Tessel to reboot after toggling the RST line (or the SOC power line). I tried to emulate the boot process in firmware with the following JS:
but my T2 doesn't come back awake. It seems like somehow the packet sent from JS is slightly different than the one sent from Python. I can call I will have to dig deeper later this week - let me know if you make any traction. |
I'm still stuck on device not found error. What do you think about just adding a log message to cycle the power yourself and getting this feature merged in? At least the core feature of unbricking is rolled out and it can be improved later. |
Just a heads up: you'll want to run grunt on that branch. I can tell that it won't pass :/ better to fix it up now. |
Yes, lot's of cleaning, I'll squash history and rebase.
|
@majgis Yeah I totally think it's acceptable to just print out a "please power cycle your Tessel" at the end. We should also make an issue to come back to this at some point 👍 Nice work! I'm super impressed. |
I'll have a PR ready tonight. |
Closes gh-493 - update-fetch.js made testable (TODO: more tests to be written) - restore: adds -f to skip device id check - restore: simplified controller handler - consolidate contents of "flash.js" into "restore.js" - restore.js: eliminate async, uses promises - restore.js: substantial tests, but still lacking coverage in a few areas, this can be done in a follow up - updates to jshintrc and bootstrap.js Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
I think we should add a command to unbrick a Tessel if either the openwrt image or the firmware image is somehow corrupted.
A corrupted openWRT image can be easily fixed with a script like this one because @kevinmehall already wrote a utility to write directly to the OpenWRT Flash from the coprocessor. We could either port it to JS or just include that linked Python file directly. We will need to place the u-boot.bin image either on our build server or ship it with the CLI.
A corrupted coprocessor image can be fixed using
openocd
from the OpenWRT image but this is more involved and you would need to have LAN access to OpenWRT. openocd would have to be installed with opkg (or included by default). Then we would use openocd to load an image file. Basic instructions for this can be found here.We can do the same as the above for a corrupted bootloader by substituting the bootloader image.
I suggest the following commands:
The text was updated successfully, but these errors were encountered: