Contribute
Register

Bluetooth missing after sleep

Status
Not open for further replies.
Joined
Feb 8, 2013
Messages
130
Motherboard
LG gram 17 17Z990-R.AAS8U1
CPU
i7-8565U
Graphics
UHD 620, 2560x1600
Hi guys, I have HP Envy 17 laptop u153nr, i7-7500U, Intel HD 620+GeForce 940MX Kaby Lake running 10.12.6. Almost everything works fine. The only noticeable problem is that most of the times after second sleep the internal bluetooth device stops working. In ioreg it appears, that the system sees 2 identical bluetooth devices. I attached the ioreg with this problem as well as regular reporting data.
Your help would be very much appreciated
Thank you, Dmitry
 

Attachments

  • debug_5835.zip
    8.8 MB · Views: 69
  • MacBook Pro-after 2-nd sleep.ioreg.zip
    757.8 KB · Views: 60
  • ioreg with bluetooth problem.png
    ioreg with bluetooth problem.png
    1.1 MB · Views: 119
Hi guys, I have HP Envy 17 laptop u153nr, i7-7500U, Intel HD 620+GeForce 940MX Kaby Lake running 10.12.6. Almost everything works fine. The only noticeable problem is that most of the times after second sleep the internal bluetooth device stops working. In ioreg it appears, that the system sees 2 identical bluetooth devices. I attached the ioreg with this problem as well as regular reporting data.
Your help would be very much appreciated
Thank you, Dmitry

Read here:
https://www.tonymacx86.com/threads/help-usb-devices-bluetooth-wifi-stop-working-after-sleep.246218/
 
Thank you, RehabMan, I built the specific commit 6ff6f86958191bd5d7777614a7574daeca15ab71 of https://github.com/tluck/OS-X-BrcmPatchRAM as said in the reference you gave me, but it didn't help. The only noticeable change is that with this new firmware I have problem with bluetooth right after the first sleep, while with the older firmware I have it only after second sleep.
 
Thank you, RehabMan, I built the specific commit 6ff6f86958191bd5d7777614a7574daeca15ab71 of https://github.com/tluck/OS-X-BrcmPatchRAM as said in the reference you gave me, but it didn't help. The only noticeable change is that with this new firmware I have problem with bluetooth right after the first sleep, while with the older firmware I have it only after second sleep.

It is for you to investigate (maybe the IOSleep timings need tweaks for your system)... I have nothing to do with that fork.

Also, I have a feeling your USB configuration is not correct...
See USB guides linked from the FAQ:
https://www.tonymacx86.com/threads/faq-read-first-laptop-frequent-questions.164990/
 
It is for you to investigate (maybe the IOSleep timings need tweaks for your system)... I have nothing to do with that fork.
Could you explain, please, how IOSleep timings lead to duplicate device after sleep. I have no idea how this might happen and that's why have no idea how to tweak these IOSleep timings. I think such an explanation might also be helpful to others with the similar problem.

Also, I have a feeling your USB configuration is not correct...
See USB guides linked from the FAQ:
https://www.tonymacx86.com/threads/faq-read-first-laptop-frequent-questions.164990/
I went thru all 3 of the guides mentioned in the reference. Why do you have this feeling?
 
Could you explain, please, how IOSleep timings lead to duplicate device after sleep. I have no idea how this might happen and that's why have no idea how to tweak these IOSleep timings. I think such an explanation might also be helpful to others with the similar problem.

Some sort of race condition between native BT code and the BrcmPatchRAM firmware uploader.

I went thru all 3 of the guides mentioned in the reference. Why do you have this feeling?

Your ioreg shows incorrect ports on XHC (eg. USR1/USR2)..
 
Some sort of race condition between native BT code and the BrcmPatchRAM firmware uploader.
It looks like racing. Once BT survived 6 sleeps before dyeing. May be it is possible to reload a kext to make it work again? At the moment I have to restart the laptop to revive the BT.

Your ioreg shows incorrect ports on XHC (eg. USR1/USR2)..
You right, those are incorrect. I removed them, doesn't help.
 
It looks like racing. Once BT survived 6 sleeps before dyeing. May be it is possible to reload a kext to make it work again? At the moment I have to restart the laptop to revive the BT.

Best option is to experiment with different IOSleep values and see if you can avoid the race.

You right, those are incorrect. I removed them, doesn't help.

You should probably double check your work with USB, as I don't understand at all how you kept those in there had you followed my USB guide... therefore, maybe there are other parts of the guide you did incorrectly (if you read it at all...).
 
Best option is to experiment with different IOSleep values and see if you can avoid the race.
Thanks for the glue. Right now I don't have access to the laptop, I'll continue working on it when I have it again
Regards, Dmitry
 
Thanks for the glue. Right now I don't have access to the laptop, I'll continue working on it when I have it again
Regards, Dmitry

I have a version sitting locally (based on my repo, and analysis of the changes in tluck fork), that allows for configuration of the delays:
Code:
diff --git a/BrcmPatchRAM.xcodeproj/project.pbxproj b/BrcmPatchRAM.xcodeproj/project.pbxproj
index dfacc8e..fd4a65b 100644
--- a/BrcmPatchRAM.xcodeproj/project.pbxproj
+++ b/BrcmPatchRAM.xcodeproj/project.pbxproj
@@ -1263,7 +1263,7 @@
        D4F91B071A2998CE0030D10D /* Debug */ = {
            isa = XCBuildConfiguration;
            buildSettings = {
-                CURRENT_PROJECT_VERSION = 2.2.8;
+                CURRENT_PROJECT_VERSION = 2.2.9;
                GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
                MACOSX_DEPLOYMENT_TARGET = 10.6;
                SDKROOT = macosx10.6;
@@ -1274,7 +1274,7 @@
        D4F91B081A2998CE0030D10D /* Release */ = {
            isa = XCBuildConfiguration;
            buildSettings = {
-                CURRENT_PROJECT_VERSION = 2.2.8;
+                CURRENT_PROJECT_VERSION = 2.2.9;
                GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
                MACOSX_DEPLOYMENT_TARGET = 10.6;
                SDKROOT = macosx10.6;
diff --git a/BrcmPatchRAM/BrcmPatchRAM.cpp b/BrcmPatchRAM/BrcmPatchRAM.cpp
index dcdc09f..18133da 100644
--- a/BrcmPatchRAM/BrcmPatchRAM.cpp
+++ b/BrcmPatchRAM/BrcmPatchRAM.cpp
@@ -195,6 +195,21 @@ IOService* BrcmPatchRAM::probe(IOService *provider, SInt32 *probeScore)
         mBlurpWait = 400;
 #endif

+    mProbeDelay = 0;
+    OSNumber* probeDelay = OSDynamicCast(OSNumber, getProperty("ProbeDelay"));
+    if (probeDelay)
+        mProbeDelay = probeDelay->unsigned32BitValue();
+
+    mInitialDelay = 100;
+    OSNumber* initialDelay = OSDynamicCast(OSNumber, getProperty("InitialDelay"));
+    if (initialDelay)
+        mInitialDelay = initialDelay->unsigned32BitValue();
+
+    mPostResetDelay = 20;
+    OSNumber* postResetDelay = OSDynamicCast(OSNumber, getProperty("PostResetDelay"));
+    if (postResetDelay)
+        mPostResetDelay = postResetDelay->unsigned32BitValue();
+
     OSString* displayName = OSDynamicCast(OSString, getProperty(kDisplayName));
     if (displayName)
         provider->setProperty(kUSBProductString, displayName);
@@ -209,6 +224,8 @@ IOService* BrcmPatchRAM::probe(IOService *provider, SInt32 *probeScore)
             firmwareStore->getFirmware(mVendorId, mProductId, firmwareKey);
     }

+    IOSleep(mProbeDelay);
+
     uploadFirmware();
     publishPersonality();

@@ -417,7 +434,7 @@ void BrcmPatchRAM::uploadFirmwareThread(void *arg, wait_result_t wait)
     {
         BrcmPatchRAM* me = static_cast<BrcmPatchRAM*>(arg);
         me->resetDevice();
-        IOSleep(20);
+        IOSleep(me->mPostResetDelay);
         me->uploadFirmware();
 #ifndef TARGET_ELCAPITAN
         me->publishPersonality();
@@ -1239,7 +1256,7 @@ bool BrcmPatchRAM::performUpgrade()
                 // If this IOSleep is not issued, the device is not ready to receive
                 // the firmware instructions and we will deadlock due to lack of
                 // responses.
-                IOSleep(10);
+                IOSleep(mInitialDelay);

                 // Write first instruction to trigger response
                 if ((data = OSDynamicCast(OSData, iterator->getNextObject())))
diff --git a/BrcmPatchRAM/BrcmPatchRAM.h b/BrcmPatchRAM/BrcmPatchRAM.h
index e216533..e6a10e8 100644
--- a/BrcmPatchRAM/BrcmPatchRAM.h
+++ b/BrcmPatchRAM/BrcmPatchRAM.h
@@ -77,7 +77,10 @@ private:
     
     UInt16 mVendorId;
     UInt16 mProductId;
-   
+    UInt32 mProbeDelay;
+    UInt32 mPostResetDelay;
+    UInt32 mInitialDelay;
+
     USBDeviceShim mDevice;
     USBInterfaceShim mInterface;
     USBPipeShim mInterruptPipe;
@@ -190,4 +193,4 @@ public:

 #endif //NON_RESIDENT

-#endif //__BrcmPatchRAM__
\ No newline at end of file
+#endif //__BrcmPatchRAM__
 
Status
Not open for further replies.
Back
Top