nanopi Posted January 30, 2020 Posted January 30, 2020 I would like to reset USB power for some reasons. Now I'm using NanoPi M4 and "uname -a" returns the following Quote LINUX nanopim4 4.4.162-rk3399 I was wondering if I could power off/on of my USB device with commands, and found people are doing it with different PCs like topic below Is this possible with NanoPi M4? and if possible, how?
martinayotte Posted January 30, 2020 Posted January 30, 2020 8 hours ago, NanoP said: Is this possible with NanoPi M4? and if possible, how? According to shcematic, the VBUS regulators seems to be permanently ON ...
nanopi Posted January 31, 2020 Author Posted January 31, 2020 Sorry, that was misleading What I would like to achieve is specifically this part. This post seems to explain how to switch the power supply of USB port.
Werner Posted January 31, 2020 Posted January 31, 2020 The OrangePi One is an sunxi board, the M4 is a RK3399. Cannot be compared Anyway, I took a look at the schematics and at least from the powering point of view there is no way to toggle them by software. The 5V sys voltage is fed into a RT9724 rate controlled load switch (basiclly the overcurrent protecion) and then connected to Pin1 of the USB (VBUS). So no possible switch inbetween. If you are really (REALLY, probably just forget about it) good at soldering you could desolder the EN of the RT9724GQW and add some kind a switch through the GPIOs there..... 1
nanopi Posted January 31, 2020 Author Posted January 31, 2020 Thanks Werner I really appreciate your help The reason why I'm trying this is because my USB3.0 device is only recognized as USB2.0 at boot, while after unplugging/replugging the connector, it recognized as USB3.0 so I tried to do the same things with power off/on with software operation since the pc will be put somewhere I cannot access easily. Do you have any ideas to solve this problem? So far I've planed to pull out the VCC 5V line from the USB cable and attach it to some switching things.
Werner Posted January 31, 2020 Posted January 31, 2020 Did you try a software based reset what does not involve the power line? Something like this:https://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line 1
nanopi Posted January 31, 2020 Author Posted January 31, 2020 Yes, I did. But that changed nothing So I thought somehow USB power reset is needed in this case but I'm not sure...
TRS-80 Posted January 31, 2020 Posted January 31, 2020 There is also possibility of a remote controlled relay switch that you would plug the power supply in to. Sonoff are popular for Wi-Fi based control, bu there are also the ISM bands (315/433Mhz, etc. depending on your country rules). I use the former for SBCs, this way if they get "stuck" somehow to where I cannot ssh in any more, I have that option which I can reach from other devices on the network to remotely turn them off and back on. Sonoff are nice if you get ESPxx ones, there is a vibrant ecosystem of aftermarket firmware, you can add temperature and other sensors to them, etc... and only a few dollars each! 1
nanopi Posted February 4, 2020 Author Posted February 4, 2020 Thank you, TRS-80 yes, that sounds very nice But what I really want to do in the end is just getting USB3.0, and the last solution for me was this, "Reseting USB". Hopefully I want to achieve that without network or Wi-Fi system. So I would like your wise advices or ideas for this. Why do you think, only after unplugging/replugging a usb cable, my device gets recognized as USB3.0? Could it be solved by adding some resistance elements or? Thank you
nanopi Posted February 4, 2020 Author Posted February 4, 2020 Hi there, I have a USB3.0 device which is recognized as USB2.0 at boot but after unplugging/replugging the usb cable, recognized as USB3.0. Do you have any ideas why this happens or any solution for this?
c0rnelius Posted February 4, 2020 Posted February 4, 2020 I don't know why that would be happening, but instead of manually unplugging it, you could try to unbind and bind the port. If that works, you could then create a script to do that for you on each boot. Example: #!/bin/bash sudo sh -c 'echo 8-1 > /sys/bus/usb/drivers/usb/unbind' sudo sh -c 'echo 8-1 > /sys/bus/usb/drivers/usb/bind' I use Mycroft.ai on my Tritium with a USB mic and ran into a similar problem. I found this to be the easiest remedy . Note: If this is a harddrive, then you'll of course want to delay the drive being mounted and mount the drive after the bind. Which should be easy enough to do within the script. Looks like this had already been mentioned:
TRS-80 Posted February 4, 2020 Posted February 4, 2020 @NanoP, Please do not spam multiple topics of same problem. I merged the two topics together. I also gave them a better title, after reading through both. Back to your issue, I am not sure what else to try other than what has already been suggested. An in-line physical switch? Very hacky. There is a low power Sonoff if you end up having to go this route (if nothing else works). Then at least you could remote control the disconnect and reconnect of the USB wire (you said it is in an out of the way location). Have you tried maybe changing USB cables? I am running out of ideas... Maybe someone else will come along who has a better idea. If/when you figure it out, please remember to come back and share the solution. 1
martinayotte Posted February 4, 2020 Posted February 4, 2020 If I had no choice, I would solder a thin wire on the EN side of R289 to a GPIO, but it requires a microscope ...
nanopi Posted February 5, 2020 Author Posted February 5, 2020 Thanks, Cornelius 16 hours ago, Cornelius said: Note: If this is a harddrive, then you'll of course want to delay the drive being mounted and mount the drive after the bind. Which should be easy enough to do within the script. Now I'm thinking that this problem could be the shortage of power for USB port at boot and thus my device is somehow recognized as USB2.0 device. (I don't know if this scenario makes sense or not) If so, the delay of mounting drive may possibly works. Now I want to try it but could you tell me how?
nanopi Posted February 5, 2020 Author Posted February 5, 2020 Thanks, TRS-80 I appreciate all of your work for this issue. Of course I have tried with some different USB cables but that changed nothing. The interesting thing on this issue is that once the device is recognized as USB3.0, even after rebooting, the device is still seen as USB3.0. So I came up with a scenario that, the power supply for USB port is not enough to use USB3.0 only at boot. Since rebooting doesn't undergo power reset, this scenario makes sense.
c0rnelius Posted February 5, 2020 Posted February 5, 2020 @NanoP I don't own a M4, but I do have a T4 and whilst testing on that my drive came up as it should. My own personal experience with Rockchip and USB3 ports hasn't really been a good one and because of that, I do not use them as a NAS. Which is and I'm just guessing here, what ur trying to do. If it is power related, may i suggest getting a small USB powered hub? 2
nanopi Posted February 11, 2020 Author Posted February 11, 2020 @Cornelius On 2/5/2020 at 7:45 PM, Cornelius said: @NanoP If it is power related, may i suggest getting a small USB powered hub? Yes, with additional power hub, now I can get USB3.0 super speed connection at boot. So this can be concluded as a power related issue, I guess. Just out of my curiosity, is it possible to delay a mount of the drive related to USB device operation? I think this also might help to do it To be honest I don't like to use the hub...
TRS-80 Posted February 11, 2020 Posted February 11, 2020 I edited [solved] into the topic. Don't feel bad, this power issue bit even someone as experienced as @lanefu as we witnessed first hand in IRC recently. There is a reason it is harped upon constantly... Back to the issue. I don't want to speak for @Cornelius, but that seems to me like just a diagnostic step (and/or, temporary work-around). Now that you know what the problem is, try and find a better way of powering. Scanning quickly over the issue (so I may have missed it) it seems you were referring to "USB device" earlier and only "drive" later on. Mentioning "drive" earlier on may have helped better grasp the issue at hand (x y problem), as yes they require more power at startup. I'm not picking at you, just saying (and maybe I even missed it). Anyway, quick look at NanoPi M4 (I don't own one) seems to reveal USB type-C power connector, which is better than Micro SD (potentially) but even that can have potential issues as I read some of them are not specced correctly. I have no idea if that is the case here or not. Anyway I think you know where to look now. I would be very surprised if a forum search for "NanoPi M4 power" or similar did not turn up some solutions. But actually I would do (in order): use some USB to SATA adapter that injects power (especially if 3.5" HDD!) [1] make sure throughput of USB Type C connector is sufficient make sure power supply itself, is sufficient if none of above are sufficient, look into powering through GPIO Note 1: This could be the whole problem, especially if you are dealing with 3.5" HDD, which require much more power. I have several of this one because I found them highly recommended by @tkaiser in this thread. 1
nanopi Posted February 12, 2020 Author Posted February 12, 2020 @TRS-80 Thank you for making things be clear like this. First, I don't use HDD for this but some USB3.0 device so the only interface that I can use is just USB. I already checked USB type-C power (actually tried with some cables too) and the power supply level to the connector, and there seems to be no problem. Also tested powering the PC via GPIO but the problem still remained. Any advice would be appreciated again, this is so tough and strange [Edit] I conducted some tests and found that the USB device can be seen as USB3.0 when the connector is plugged to the PC even 1 second after the power supply is started. So I guess since the more power is needed for booting, this happens...?
TRS-80 Posted February 12, 2020 Posted February 12, 2020 13 hours ago, TRS-80 said: Anyway I think you know where to look now. I would be very surprised if a forum search for "NanoPi M4 power" or similar did not turn up some solutions.
nanopi Posted February 13, 2020 Author Posted February 13, 2020 I really appreciate your contribution to this. But for me some things are still unclear and I have to deal with it. I might misunderstand this, but are you suggesting me post a new topic with proper a title? Quote Anyway I think you know where to look now. I would be very surprised if a forum search for "NanoPi M4 power" or similar did not turn up some solutions.
TRS-80 Posted February 14, 2020 Posted February 14, 2020 On 2/12/2020 at 1:49 AM, NanoP said: I conducted some tests and found that the USB device can be seen as USB3.0 when the connector is plugged to the PC even 1 second after the power supply is started. Yes, exactly. Because PC power supply is some hundreds of watts. But even there, some unknown cheap power supplies do not meet specifications on certain rails of power (12v, etc.) and thus the market for known, higher quality enthusiast level power supplies in the PC arena. From building my own PCs since decades I already knew about sites like https://www.jonnyguru.com and others discussing these issues. 11 hours ago, NanoP said: But for me some things are still unclear and I have to deal with it. Yes, this is why those of us who understand well the effects of power on system stability harp on that all the time. And why it is mentioned first and foremost in Getting Started part of Documentation (and why I put that link again in my signature), etc... 12 hours ago, NanoP said: are you suggesting me post a new topic with proper a title? No. I was suggesting to search the forums for those exact terms. I suspect strongly that you should find a lot of useful information. As a side note, I prefer to leave the title as is (describing the symptoms) so that others in future may find it that way. The solution is power, but people don't search for solutions, they search (or should) for symptoms.
nanopi Posted February 14, 2020 Author Posted February 14, 2020 Sorry for the other topic. I had made it before you replied and didn't know how to delete it. Now things seem to be clearer. I used to power it with an 5V/3A AC/DC power and a USB cable which is sold by FriendlyElec, a distributer of NanoPi M4 https://www.friendlyarm.com/index.php?route=product/product&product_id=234 but the power supply for boot was not enough so the USB device was seen as USB2.0 after the boot. Then I changed the power supply from that to a regulated dc power supply and power the pc via USB type-C connector. This resulted in what I've wanted, I finally got the USB3.0 connection at boot. It it strange but FriendlyElec's official power supply system isn't that good. 1
TRS-80 Posted February 14, 2020 Posted February 14, 2020 Glad to hear you got it working finally. And even more importantly, that you start to actually understand the issue. These devices almost require a hobby-like approach, as there are many potential pitfalls. If you enjoy using them like so many of us do (it's hard to beat performance and power wise for the price) perhaps consider lurking around the forums and reading a bit more here and there, it will help a lot in locating information later when you get into trouble (or perhaps not even getting into trouble in the first place). Cheers!
chwe Posted February 14, 2020 Posted February 14, 2020 6 hours ago, NanoP said: FriendlyElec, a distributer of NanoPi M4 it's not the distributor - it's the company behind NanoPi boards.. IMO the whole thread can be moved to: https://forum.armbian.com/forum/31-sd-card-and-psu-issues/ NanoPi M4 being not PD-compliant and therefore might be troublesome is mentioned on the dowloadpage: Quote USB Type-C is not PD-compliant linking to btw @Igor or @lanefu we might add the same disclaimer from nanopi m4 to the orangepi 4 cause this board will have the same issues (I updated the thread but forgot my credentials to the WP admin board to do it on my own - feel free to remove my rights there anyways I didn't do much maintenance of it and honestly don't plan to change that in the future). Spoiler Delay the whole thing might just give you trouble later (in a high load scenario, 3amps at 5V might be not enough to power board and your external drive). If you really wanna try it you could try something like: vcc5v0_usb1: vcc5v0-usb1 { compatible = "regulator-fixed"; regulator-name = "vcc5v0_usb1"; regulator-always-on; regulator-boot-on; + startup-delay-us = <100000>; vin-supply = <&vcc5v0_sys>; }; vcc5v0_usb2: vcc5v0-usb2 { compatible = "regulator-fixed"; regulator-name = "vcc5v0_usb2"; regulator-always-on; regulator-boot-on; + startup-delay-us = <100000>; vin-supply = <&vcc5v0_sys>; }; in the device tree... where you add 0.1s startup delay to the regulator to get ready (I have no idea if 0.1 seconds are sufficient.. I think not but who knows, it's just a random number I picked). Just to make clear, this is an ugly hack which does not help to solve your powering issue. It should just tell the USB driver that the powerrails need 0.1 seconds to get ready.. and in case this is enough delay it might then come up as USB3. I do not recommend to use it in productive systems and if you're not familiar with how to implement this I won't give any advice how to do it - you're either familiar enough with DT to do it on your own, or it's better you go for a proper powering solution (btw. having a proper powering solution is always better than all sorts of ugly hacks - they tend to slap back when you don't expect it). (hidden cause not really an advice more a hack to maybe achieve what you want but not what you should - having a sane powering for your setup) 3 amps at 5V is sufficient for the NanoPi M4 in most scenarios I had. But if you look at their "expansion hats", the USB3 and the SATA "hat" provide a barrel plug and for the sata hat additionally a ATX12V 4 Pin connector indicating that even they do not recommend using USB-C for such set-ups.. 3
Igor Posted February 14, 2020 Posted February 14, 2020 7 minutes ago, chwe said: we might add the same disclaimer from nanopi m4 to the orangepi 4 cause this board will have the same issues There is a text "USB Type-C is not PD-compliant" with link to your topic since months. I did update wording and add it to the missing boards.
chwe Posted February 14, 2020 Posted February 14, 2020 Just now, Igor said: There is a text "USB Type-C is not PD-compliant" with link to your topic since months. I know.. I added that back then (I guess I knew my password back then.. )...
TRS-80 Posted February 14, 2020 Posted February 14, 2020 (edited) Thanks for contribution @chwe. I don't know this board, but in < 1 minute of searching forums I found exactly the post you link above, and also relevant info on Download page, etc. I write up almost exactly what you did (maybe little less in detail) and then I pause when I realize how fast I found the information. After thinking about it for another moment, I delete everything I wrote in order to let OP search and learn things for himself (teach a man to fish, etc.). As far as the meta of where to put it, as I said I prefer to leave it titled with symptoms (which people would search for, hopefully) instead of the solution (which maybe only we know), especially now that we have added explicit links to said solution(s). Which I suppose is OK now after OP also figured it out for himself. EDIT: Other meta of board maintainer stuff, WP permissions is interesting to me as I just became one myself apparently but is offtopic here (maybe I make some post later about that). Edited February 14, 2020 by TRS-80 add last bit
nanopi Posted February 17, 2020 Author Posted February 17, 2020 Thank you guys. This helped me a lot. @chwe I tried to edit my DT but when I compiled the dts file, I got the message bellow Quote rk3399-nanopi4-rev01.dtb: ERROR (phandle_references): Reference to non-existent node or label "vcc5v0_sys" rk3399-nanopi4-rev01.dtb: ERROR (phandle_references): Reference to non-existent node or label "vcc5v0_sys" ERROR: Input tree has errors, aborting (use -f to force output) I used -f option but this changed nothing. What else in DT can I fix to delay it? [Edit] In the first place, my dab file didn't have the term of vcc5v0_usb1 or vcc5v0_usb2
chwe Posted February 17, 2020 Posted February 17, 2020 yours looks like bsp kernel.. well I only had mainline open.. No idea how this stuff is named in bsp.. and I won't dig into it.. check which node is defined for phy supply e.g. something like this: &u2phy1_host { phy-supply = <&vcc5v0_usb2>; }; and then make your changes in the referred regulator.. and as before.. I still don't recommend it..
Recommended Posts