BBB with Debian is blocked after switching from USB power supply to battery supply.

67 views
Skip to first unread message

bern...@gmail.com

unread,
Apr 30, 2020, 2:22:22 AM4/30/20
to BeagleBoard
Hi, 
I've build  RT kernel 4.19-rt for my BBB and Debian Buster. 
Linux beaglebone 4.19.94+ #1 SMP PREEMPT RT Sun Apr 26 11:04:37 CEST 2020 armv7l GNU/Linux

I use wifi USB stick with kernel module mt760u and it works great.
However after switching-off USB power and switching to battery LiPo power supply Debian is blocked. I'm flooded with messages:
[   75.890362] mt7601u 1-1:1.0: Vendor request req:07 off:1700 failed:-110
[   79.122377] mt7601u 1-1:1.0: Vendor request req:07 off:1704 failed:-110
[   82.354362] mt7601u 1-1:1.0: Vendor request req:07 off:1708 failed:-110
[   85.586380] mt7601u 1-1:1.0: Vendor request req:07 off:101c failed:-110
[   88.818362] mt7601u 1-1:1.0: Vendor request req:07 off:170c failed:-110
[   92.050380] mt7601u 1-1:1.0: Vendor request req:07 off:101c failed:-110
[   95.282362] mt7601u 1-1:1.0: Vendor request req:07 off:1710 failed:-110

I cannot even switched off my BBB using onboard power button. Why there is no normal transition from USB to battery power?
How could I fixed this for my BBB board?
Thanks, 

Robert Nelson

unread,
Apr 30, 2020, 9:17:23 AM4/30/20
to Beagle Board, bern...@gmail.com
Can we assume, when you say "LiPo" it's physcally wired to the 4 pin
terminal next to the DC power jack?

If so, then this would apply:

https://elinux.org/BeagleBone_Power_Management#Battery

Regards,

--
Robert Nelson
https://rcn-ee.com/

bern...@gmail.com

unread,
Apr 30, 2020, 11:03:02 AM4/30/20
to BeagleBoard
Thank you for the tip. 
This issue with inability  to shut down the BBB (after switch from USB power  to battery) seems to relate RT kernel and Ralink wifi  mt7601u module since my new non-RT kernel
Linux beaglebone 4.19.94+ #1 SMP PREEMPT Wed Apr 29 18:35:21 CEST 2020 armv7l GNU/Linux
works ok. I can switchoff BBB using onboard on/off button. 
Yes my LiPo battery is wired to the onboard 4pin terminal. 
I use this battery in one, exclusive purpose: to shutdown/poweroff debian when power is lost. 
I expect BBB (powered by battery) to immediately initiate shutdown procedure. 

Until recently I use the patch for tps65217:
and it worked  very well. However the author of the patch seems to abandon maintaining his patches to BBB. I tried to patch newer kernel but it gives me errors (probably tps65217 driver has been rewritten) . I don't know programming in C language I'm not a coder just music enthusiast and use BBB as a music player. 
I would like to ask  how to restore the previous functionality (e.g. shutdown from battery power supply). 
Maybe there are some scrips or new patches for this task? what do you recommend?
Regards, 
Bern

bern...@gmail.com

unread,
May 4, 2020, 2:02:33 AM5/4/20
to BeagleBoard
I did more tests and I withdraw from what I wrote: the problem concerns RT and non-RT kernels (not only RT as I wrote). 
To cope the problem i tested simple phyton script which poweroff the BBB after transition from USB to battery power supply. 
It works when I remove mt7601u driver sudo rmmod mt7601u   (on USB power) before  running the script:
#!/usr/bin/python
## Read some values from the PMIC and print out what we find
### example i2cget -y -f  0 0x24 0x3

import time
from os import system
import subprocess

I2C_DEVICE = 0

CHIP_ADDRESS = 0x24

# register addresses we are interested in
PPATH = 0x1
CHGCONFIG0 = 0x3


STATUS = 0xA
PGOOD = 0xC

# some bitmasks

STATUS_AC = 1<<3
STATUS_USB = 1<<2

CHGCONFIG0_ACTIVE = 1<<3 # we are charging the battery

# these labels are interpreted from the TPS65217 datasheet
CHG0_LABELS = ["Temp sense error","Pre-charge Timedout","Charge Timedout","Active (charging)","Charge Termination Current","Thermal Suspend", "DPPM Reduction","Thermal Regulation"]
STATUS_LABELS=["Push Button",None,"USB Power", "AC Power"]# skip the rest
PGOOD_LABELS=["LDO2 power-good","LDO1 power-good","DCDC3 power-good","DCDC2 power-good","DCDC1 power-good", "LDO4 power-good","LDO3 power-good"]


# get the I2C register, strip off \n and cast to int from hex
# -y means non-interactive mode (just do it!)
# -f forces the connection
def query(reg=0):
    return  int(subprocess.check_output(["i2cget","-y" ,"-f", str(I2C_DEVICE), str(CHIP_ADDRESS), str(reg)]).strip(),16)

# display value of each bit in the register, along with its label
def describe_bits(val,labels):
    for x in range(0,len(labels)):
        if(not labels[x]): # skip None labels
            continue
        msk = 1<<x
        print "%s = %d"%(labels[x],(val&msk)!=0)


# query a register, print out value breakdown
def show_reg(reg,title,labels):
    val = query(reg)
    print
    print "%s: r[0x%x]=0x%x\r\n"%(title,reg,val)
    describe_bits(val,labels)
    print 

# specific helpers
def onBattery():
    return query(STATUS) & (STATUS_AC | STATUS_USB) == 0
    
def charging():
    return query(CHGCONFIG0) & (CHGCONFIG0_ACTIVE) !=0
 
  
if __name__ == "__main__":
    
    while True:
        if onBattery():
            system("shutdown -h now")
        else:
            print 'beep'
            time.sleep(2)

The script is based on THIS script. However when  I add line 
system("rmmod mt7601u") before system("shutdown -h now") the BBB doesn't want to shut down and produces known messages:
[  337.637916] musb-hdrc musb-hdrc.1: VBUS_ERROR in a_wait_vrise (88, <AValid), retry #3, port1 0008050f
[  340.807612] mt7601u 1-1:1.0: Vendor request req:07 off:180c failed:-110
[  344.040313] mt7601u 1-1:1.0: Vendor request req:02 off:180c failed:-110
[  345.584847] mt7601u 1-1:1.0: Error: send MCU cmd failed:-110
[  348.124973] mt7601u 1-1:1.0: Error: send MCU cmd failed:-110
[  351.335750] mt7601u 1-1:1.0: Vendor request req:07 off:a804 failed:-110
[  354.567797] mt7601u 1-1:1.0: Vendor request req:02 off:a804 failed:-110
[  357.799811] mt7601u 1-1:1.0: Vendor request req:07 off:106c failed:-110
[  361.031934] mt7601u 1-1:1.0: Vendor request req:02 off:106c failed:-110
[  364.263928] mt7601u 1-1:1.0: Vendor request req:02 off:a804 failed:-110
[  367.495958] mt7601u 1-1:1.0: Vendor request req:02 off:1808 failed:-110
[  370.728013] mt7601u 1-1:1.0: Vendor request req:02 off:180c failed:-110
[  373.960074] mt7601u 1-1:1.0: Vendor request req:02 off:1018 failed:-110
[  377.192115] mt7601u 1-1:1.0: Vendor request req:02 off:1010 failed:-110
[  380.424163] mt7601u 1-1:1.0: Vendor request req:02 off:1014 failed:-110

I also experiment with switching off USB power:
devmem2 0x47401c60 b 0x00
but receive well known: mt7601u 1-1:1.0: Vendor request req:02 off:xxx failed:-110
I tried also different USB wifi stick Realtek RTL8188EU but with the same result. 
Is it really impossible to turn off the usb wifi driver after switching from usb to battery power supply?
Regards, 
Bern
Reply all
Reply to author
Forward
0 new messages