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 <https://github.com/pehrtree/beaglebone_snippets/blob/master/power/powerstatus.py> 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 Source <https://stackoverflow.com/questions/24039420/turn-usb-power-off-on-with-beaglebone-black-kernel-3-8> 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 -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/e82f1e81-67e6-45f0-a50d-72fb4c26bf40%40googlegroups.com.