Contribute
Register

BCM94350ZAE/DW1820A only 802.11n wifi and no bluetooth devices

Status
Not open for further replies.
by the way, after you configure all your usb properly, with custom SSDT.
and your BT device is showing up in ioReg.

but BrcmPatchRam2.kext (with BrcmFirmWareRepo.kext) properly copied into L/E
still is not able to upload the firmware. In my case it even knocks my BT device out of USB - and does not show up in ioreg anymore - when you boot into windows - it has become an unknown usb device. ( i had to physically remove the card, let it discharge a while and then plug it back in to show up again in ioReg.

was getting a bunch of these request failed error on boot
Code:
2018-04-29 11:54:56.587272+1000 0x3b1      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: device request failed ("0xe00002ed (UNDEFINED)" 0xe00002ed).

2018-04-29 11:54:56.589987+1000 0x11d      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Not responding - Delaying next read.


Turns out I needed a slightly adapted BrcmPatchRam2.kext
based on the work by tluck changing ioSleep states

https://github.com/tluck/OS-X-BrcmPatchRAM/commit/6ff6f86958191bd5d7777614a7574daeca15ab71

you can compile his fork at GitHub with Xcode.
I found though I only needed to change one ioSleep state from (20) to (400) on Line 420 for it to work
not all the changes by tluck

Code:
// don't start firmware load when lock is held (instance is shutting down)

    if (IOLockTryLock(mLoadFirmwareLock))

    {

        BrcmPatchRAM* me = static_cast<BrcmPatchRAM*>(arg);

        me->resetDevice();

        IOSleep(400);

        me->uploadFirmware();

#ifndef TARGET_ELCAPITAN

        me->publishPersonality();

#endif

        me->scheduleWork(kWorkFinished);

        IOLockUnlock(mLoadFirmwareLock);

    }

so I am using a custom BrcmPatchRam2.kext

I have a attached BrcmPatchRAM2_iosleep400 line 420.kext-> rename it to BrcmPatchRam2.kext
copy in L/E with
Code:
sudo cp -r  location/BrcmPatchRam2.kext /Library/Extensions

make sure to rebuild cache
Code:
sudo touch /Library/Extensions && sudo kextcache -u /

Please see if the 400 IOSleep can be reduced.
From 20 to 400 is a big jump.

Maybe works with 100.

I'm considering this commit:
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..7279e8e 100644
--- a/BrcmPatchRAM/BrcmPatchRAM.cpp
+++ b/BrcmPatchRAM/BrcmPatchRAM.cpp
@@ -195,8 +195,26 @@ IOService* BrcmPatchRAM::probe(IOService *provider, SInt32 *probeScore)
         mBlurpWait = 400;
 #endif

-    OSString* displayName = OSDynamicCast(OSString, getProperty(kDisplayName));
-    if (displayName)
+    UInt32 delay;
+    mProbeDelay = 0;
+    if (OSNumber* probeDelay = OSDynamicCast(OSNumber, getProperty("ProbeDelay")))
+        mProbeDelay = probeDelay->unsigned32BitValue();
+    if (PE_parse_boot_argn("bpr_probedelay", &delay, sizeof delay))
+        mProbeDelay = delay;
+
+    mInitialDelay = 100;
+    if (OSNumber* initialDelay = OSDynamicCast(OSNumber, getProperty("InitialDelay")))
+        mInitialDelay = initialDelay->unsigned32BitValue();
+    if (PE_parse_boot_argn("bpr_initialdelay", &delay, sizeof delay))
+        mInitialDelay = delay;
+
+    mPostResetDelay = 100;
+    if (OSNumber* postResetDelay = OSDynamicCast(OSNumber, getProperty("PostResetDelay")))
+        mPostResetDelay = postResetDelay->unsigned32BitValue();
+    if (PE_parse_boot_argn("bpr_postresetdelay", &delay, sizeof delay))
+        mPostResetDelay = delay;
+
+    if (OSString* displayName = OSDynamicCast(OSString, getProperty(kDisplayName)))
         provider->setProperty(kUSBProductString, displayName);
    
     mVendorId = mDevice.getVendorID();
@@ -209,6 +227,8 @@ IOService* BrcmPatchRAM::probe(IOService *provider, SInt32 *probeScore)
             firmwareStore->getFirmware(mVendorId, mProductId, firmwareKey);
     }

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

@@ -417,7 +437,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 +1259,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__

It has three different delays (one default to zero, as it was not previously there at all, but in tluck code), and the others increased to 100, with ability to change all three with either Info.plist (for device specific delays), or kernel flags (user customization/experimentation).
 
Last edited:
Please see if the 400 IOSleep can be reduced.
From 20 to 400 is a big jump.

Maybe works with 100.

I'm considering this commit:
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..7279e8e 100644
--- a/BrcmPatchRAM/BrcmPatchRAM.cpp
+++ b/BrcmPatchRAM/BrcmPatchRAM.cpp
@@ -195,8 +195,26 @@ IOService* BrcmPatchRAM::probe(IOService *provider, SInt32 *probeScore)
         mBlurpWait = 400;
 #endif

-    OSString* displayName = OSDynamicCast(OSString, getProperty(kDisplayName));
-    if (displayName)
+    UInt32 delay;
+    mProbeDelay = 0;
+    if (OSNumber* probeDelay = OSDynamicCast(OSNumber, getProperty("ProbeDelay")))
+        mProbeDelay = probeDelay->unsigned32BitValue();
+    if (PE_parse_boot_argn("bpr_probedelay", &delay, sizeof delay))
+        mProbeDelay = delay;
+
+    mInitialDelay = 100;
+    if (OSNumber* initialDelay = OSDynamicCast(OSNumber, getProperty("InitialDelay")))
+        mInitialDelay = initialDelay->unsigned32BitValue();
+    if (PE_parse_boot_argn("bpr_initialdelay", &delay, sizeof delay))
+        mInitialDelay = delay;
+
+    mPostResetDelay = 100;
+    if (OSNumber* postResetDelay = OSDynamicCast(OSNumber, getProperty("PostResetDelay")))
+        mPostResetDelay = postResetDelay->unsigned32BitValue();
+    if (PE_parse_boot_argn("bpr_postresetdelay", &delay, sizeof delay))
+        mPostResetDelay = delay;
+
+    if (OSString* displayName = OSDynamicCast(OSString, getProperty(kDisplayName)))
         provider->setProperty(kUSBProductString, displayName);
  
     mVendorId = mDevice.getVendorID();
@@ -209,6 +227,8 @@ IOService* BrcmPatchRAM::probe(IOService *provider, SInt32 *probeScore)
             firmwareStore->getFirmware(mVendorId, mProductId, firmwareKey);
     }

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

@@ -417,7 +437,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 +1259,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__

It has three different delays (one default to zero, as it was not previously there at all, but in tluck code), and the others increased to 100, with ability to change all three with either Info.plist (for device specific delays), or kernel flags (user customization/experimentation).
Ok! Will try out different values -
When I have some time this coming Tuesday Aussie time.

Commit looking good.
 
Thanks in advance.

Oh dear,
I am very new to all this - first time to Xcode- so please forgive.
Made some rookie judgment errors.

Turns out the reason why the tluck version (BRCMPatchRam2) was running well on my system because it was running in debug - which I should have considered also slows down the kext. (DUH)
So when I reduced tluck's version to that 1 line change, and it worked , it was only because it was running debug.

When running tluck in release : it did not work (not even with all changes)
When I run your version in debug (RehabMan 16/2/16) it works.
So it was back to the drawing board.

what I did to find out which debuglog_message was allowing the firmware to load I did the following.

First I had a look at the logs when the release version fails

Code:
12129:2018-05-02 10:57:31.644507+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: Version 2.2.7 starting on OS X Darwin 16.7.
12284:2018-05-02 10:57:31.850946+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: Unknown new Darwin version 16.7, using possible compatible personality.
12290:2018-05-02 10:57:31.853244+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: Published new IOKit personality for BrcmFirmwareStore.
12291:2018-05-02 10:57:31.853464+1000 0x443      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Firmware store start
12292:2018-05-02 10:57:31.859546+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: Published new IOKit personality for BrcmPatchRAMResidency.
12293:2018-05-02 10:57:31.864973+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: getFirmware
12294:2018-05-02 10:57:31.865600+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: loadFirmware
12295:2018-05-02 10:57:31.872049+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource: 00000000
12843:2018-05-02 10:57:32.374505+1000 0x210      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource Callback: dc008006.
12844:2018-05-02 10:57:32.381461+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource: 00000000
12857:2018-05-02 10:57:32.403433+1000 0x210      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource Callback: dc008006.
12858:2018-05-02 10:57:32.410492+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource: 00000000
12876:2018-05-02 10:57:32.420377+1000 0x210      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource Callback: 5886 bytes of data.
12880:2018-05-02 10:57:32.427691+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Loaded firmware "BCM4350C5_003.006.007.0095.1703_v5799.zhx" from resources.
12883:2018-05-02 10:57:32.435824+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Decompressed firmware (5886 bytes --> 14872 bytes).
12886:2018-05-02 10:57:32.443338+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Firmware is valid IntelHex firmware.
12890:2018-05-02 10:57:32.450408+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: USB [ACE010DD2F5E v274] "BCM2045A0" by "Broadcom Corp"
13906:2018-05-02 10:57:33.462377+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: getFirmware


13907:2018-05-02 10:57:33.469687+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Retrieved cached firmware for "BCM4350C5_003.006.007.0095.1703_v5799".
20415:2018-05-02 10:57:37.998381+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: device request failed ("0xe00002ed (UNDEFINED)" 0xe00002ed).
20433:2018-05-02 10:57:38.013212+1000 0x115      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Not responding - Delaying next read.
20449:2018-05-02 10:57:38.025406+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: device request failed ("0xe00002ed (UNDEFINED)" 0xe00002ed).
20465:2018-05-02 10:57:38.038176+1000 0x115      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Not responding - Delaying next read.


20472:2018-05-02 10:57:38.049063+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: device request failed ("0xe00002ed (UNDEFINED)" 0xe00002ed).
20473:2018-05-02 10:57:38.062203+1000 0x115      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Not responding - Delaying next read.
20474:2018-05-02 10:57:38.072766+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: device request failed ("0xe00002ed (UNDEFINED)" 0xe00002ed).
20475:2018-05-02 10:57:38.085285+1000 0x115      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Not responding - Delaying next read.
20476:2018-05-02 10:57:38.095181+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: device request failed ("0xe00002ed (UNDEFINED)" 0xe00002ed).
20477:2018-05-02 10:57:38.108257+1000 0x115      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Not responding - Delaying next read.

20478:2018-05-02 10:57:38.120896+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: device request failed ("0xe00002ed (UNDEFINED)" 0xe00002ed).

then I had a look at the debug_log when it succeeds

Code:
2013:2018-05-02 10:46:41.600374+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: probe
2016:2018-05-02 10:46:41.601406+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: Version 2.2.7 starting on OS X Darwin 16.7.
2183:2018-05-02 10:46:41.802602+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: Unknown new Darwin version 16.7, using possible compatible personality.
2185:2018-05-02 10:46:41.803925+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: 1 matching driver personalities for BrcmFirmwareStore.
2187:2018-05-02 10:46:41.805693+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: Published new IOKit personality for BrcmFirmwareStore.
2188:2018-05-02 10:46:41.805948+1000 0x437      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Firmware store start
2195:2018-05-02 10:46:41.811397+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: 1 matching driver personalities for BrcmPatchRAMResidency.
2200:2018-05-02 10:46:41.812512+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: Published new IOKit personality for BrcmPatchRAMResidency.
2201:2018-05-02 10:46:41.812736+1000 0x43d      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: BrcmPatchRAMResidency start
2211:2018-05-02 10:46:41.818610+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: getFirmware
2248:2018-05-02 10:46:41.851641+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: loadFirmware
2249:2018-05-02 10:46:41.851871+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource: 00000000
2989:2018-05-02 10:46:42.670097+1000 0x20f      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource Callback: dc008006.
3000:2018-05-02 10:46:42.677657+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource: 00000000
3087:2018-05-02 10:46:42.706528+1000 0x20f      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource Callback: dc008006.
3096:2018-05-02 10:46:42.715894+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource: 00000000
3106:2018-05-02 10:46:42.726648+1000 0x20f      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource Callback: 5886 bytes of data.
3113:2018-05-02 10:46:42.735730+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Loaded firmware "BCM4350C5_003.006.007.0095.1703_v5799.zhx" from resources.
3126:2018-05-02 10:46:42.744603+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Decompressed firmware (5886 bytes --> 14872 bytes).
3136:2018-05-02 10:46:42.753304+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Firmware is valid IntelHex firmware.
3144:2018-05-02 10:46:42.762414+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: USB [ACE010DD2F5E v274] "BCM2045A0" by "Broadcom Corp"
3616:2018-05-02 10:46:43.172962+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Available composite configurations: 1.
3626:2018-05-02 10:46:43.181727+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Set device configuration to configuration index 0 successfully.
3632:2018-05-02 10:46:43.190619+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: USBDeviceShim::findFirstInterface
3638:2018-05-02 10:46:43.198359+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: getValidatedInterface returns <private>
3642:2018-05-02 10:46:43.213381+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Interface 0 (class ff, subclass 01, protocol 01) located.
3649:2018-05-02 10:46:43.229721+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: set configuration and interface opened
3667:2018-05-02 10:46:43.249192+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: findPipe: direction = 1, type = 3
3672:2018-05-02 10:46:43.257528+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: endpoint found: epDirection = 1, epType = 3
3673:2018-05-02 10:46:43.266100+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: found matching endpoint
3674:2018-05-02 10:46:43.274301+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: findPipe: direction = 0, type = 2
3693:2018-05-02 10:46:43.283606+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: endpoint found: epDirection = 1, epType = 3
3694:2018-05-02 10:46:43.294823+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: endpoint found: epDirection = 1, epType = 2
3695:2018-05-02 10:46:43.303616+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: endpoint found: epDirection = 0, epType = 2
3702:2018-05-02 10:46:43.313296+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: found matching endpoint
3705:2018-05-02 10:46:43.322497+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: got pipes
3978:2018-05-02 10:46:43.930117+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: State "Unknown" --> "Initialize".
3997:2018-05-02 10:46:43.939515+1000 0x112      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: READ VERBOSE CONFIG complete (status: 0x00, length: 10 bytes).
4010:2018-05-02 10:46:43.948764+1000 0x112      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Firmware version: v4096.
4016:2018-05-02 10:46:43.956994+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: State "Initialize" --> "Firmware version".
4025:2018-05-02 10:46:43.965703+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: getFirmware


4028:2018-05-02 10:46:43.973098+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Retrieved cached firmware for "BCM4350C5_003.006.007.0095.1703_v5799".
4044:2018-05-02 10:46:43.982505+1000 0x112      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: DOWNLOAD MINIDRIVER complete (status: 0x00, length: 4 bytes).
4070:2018-05-02 10:46:43.991676+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: State "Firmware version" --> "Mini-driver complete".


6201:2018-05-02 10:46:44.481546+1000 0x112      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: END OF RECORD complete (status: 0x00, length: 4 bytes).
6202:2018-05-02 10:46:44.490506+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: State "Instruction write" --> "Firmware written".
6277:2018-05-02 10:46:44.569509+1000 0x112      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: RESET complete (status: 0x00, length: 4 bytes).
6278:2018-05-02 10:46:44.578007+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: State "Firmware written" --> "Reset complete".
6292:2018-05-02 10:46:44.587237+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Device reset.
6322:2018-05-02 10:46:44.594886+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Device status 0x00000003.
6329:2018-05-02 10:46:44.602720+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: State "Reset complete" --> "Update complete".
6334:2018-05-02 10:46:44.611086+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Firmware upgrade completed successfully.
6341:2018-05-02 10:46:44.620417+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: brcmBundIdentifier: "com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport"
6354:2018-05-02 10:46:44.629368+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: brcmIOClass: "BroadcomBluetoothHostControllerUSBTransport"
6409:2018-05-02 10:46:44.637795+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: brcmProviderClass: "IOUSBHostDevice"


You can compare the two and see where it fails (Device request failed - repeatedly ---).
look at this


after_retrieved.cached firmware.fail.jpeg


and compare to this

after_retrieved.cached firmware.success.jpeg




So you can see that the fault happens right after
Code:
 Retrieved cached firmware for "BCM4350C5_003.006.007.0095.1703_v5799".

now in the working version after that line "retrieved cached firmware" you get these

Code:
028:2018-05-02 10:46:43.973098+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Retrieved cached firmware for "BCM4350C5_003.006.007.0095.1703_v5799".
4044:2018-05-02 10:46:43.982505+1000 0x112      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: DOWNLOAD MINIDRIVER complete (status: 0x00, length: 4 bytes).
4070:2018-05-02 10:46:43.991676+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: State "Firmware version" --> "Mini-driver complete".
6201:2018-05-02 10:46:44.481546+1000 0x112      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: END OF RECORD complete (status: 0x00, length: 4 bytes).
6202:2018-05-02 10:46:44.490506+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: State "Instruction write" --> "Firmware written".
6277:2018-05-02 10:46:44.569509+1000 0x112      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: RESET complete (status: 0x00, length: 4 bytes).
6278:2018-05-02 10:46:44.578007+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: State "Firmware written" --> "Reset complete".
6292:2018-05-02 10:46:44.587237+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Device reset

so I looked at the code where
Code:
DOWNLOAD MINIDRIVER complete (status: 0x00, length: 4 bytes).
was a debuglog
here is where I found them

Xcode 3  lines debuglog added relase.jpeg


so I changed three debuglog (HCI_OPCODE_END_OF_RECORD, HCI_OPCODE_RESET, HCI_OPCODE_DOWNLOAD MINIDRIVER) to always log - and create a release version to run.
this worked.

So then it was a matter of elimination to see which one was absolutely necessary.
all this is very time consuming of course .

so by elimination I found out that if I only changed one debuglog (HCI_OPCODE_END_OF_RECORD) to always log - the firmware would load.

So then an added a iosleep (20) was enough to make the release work (after changing alwayslog back to debuglog)


xcode_EOF_IOsleep20.jpeg



so this made it work consistently for my Dell - DW1820..


Not sure if this delay is put in a good place - but at least it works for now -
Is there a better place to put this iosleep achieving the same thing?


Sorry again for creating some confusion with tluck version which turned out not to be my solution.
 
Last edited:
Oh dear,
I am very new to all this - first time to Xcode- so please forgive.
Made some rookie judgment errors.

Turns out the reason why the tluck version (BRCMPatchRam2) was running well on my system because it was running in debug - which I should have considered also slows down the kext. (DUH)
So when I reduced tluck's version to that 1 line change, and it worked , it was only because it was running debug.

When running tluck in release : it did not work (not even with all changes)
When I run your version in debug (RehabMan 16/2/16) it works.
So it was back to the drawing board.

what I did to find out which debuglog_message was allowing the firmware to load I did the following.

First I had a look at the logs when the release version fails

Code:
12129:2018-05-02 10:57:31.644507+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: Version 2.2.7 starting on OS X Darwin 16.7.
12284:2018-05-02 10:57:31.850946+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: Unknown new Darwin version 16.7, using possible compatible personality.
12290:2018-05-02 10:57:31.853244+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: Published new IOKit personality for BrcmFirmwareStore.
12291:2018-05-02 10:57:31.853464+1000 0x443      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Firmware store start
12292:2018-05-02 10:57:31.859546+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: Published new IOKit personality for BrcmPatchRAMResidency.
12293:2018-05-02 10:57:31.864973+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: getFirmware
12294:2018-05-02 10:57:31.865600+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: loadFirmware
12295:2018-05-02 10:57:31.872049+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource: 00000000
12843:2018-05-02 10:57:32.374505+1000 0x210      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource Callback: dc008006.
12844:2018-05-02 10:57:32.381461+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource: 00000000
12857:2018-05-02 10:57:32.403433+1000 0x210      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource Callback: dc008006.
12858:2018-05-02 10:57:32.410492+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource: 00000000
12876:2018-05-02 10:57:32.420377+1000 0x210      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource Callback: 5886 bytes of data.
12880:2018-05-02 10:57:32.427691+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Loaded firmware "BCM4350C5_003.006.007.0095.1703_v5799.zhx" from resources.
12883:2018-05-02 10:57:32.435824+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Decompressed firmware (5886 bytes --> 14872 bytes).
12886:2018-05-02 10:57:32.443338+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Firmware is valid IntelHex firmware.
12890:2018-05-02 10:57:32.450408+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: USB [ACE010DD2F5E v274] "BCM2045A0" by "Broadcom Corp"
13906:2018-05-02 10:57:33.462377+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: getFirmware


13907:2018-05-02 10:57:33.469687+1000 0x37b      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Retrieved cached firmware for "BCM4350C5_003.006.007.0095.1703_v5799".
20415:2018-05-02 10:57:37.998381+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: device request failed ("0xe00002ed (UNDEFINED)" 0xe00002ed).
20433:2018-05-02 10:57:38.013212+1000 0x115      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Not responding - Delaying next read.
20449:2018-05-02 10:57:38.025406+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: device request failed ("0xe00002ed (UNDEFINED)" 0xe00002ed).
20465:2018-05-02 10:57:38.038176+1000 0x115      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Not responding - Delaying next read.


20472:2018-05-02 10:57:38.049063+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: device request failed ("0xe00002ed (UNDEFINED)" 0xe00002ed).
20473:2018-05-02 10:57:38.062203+1000 0x115      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Not responding - Delaying next read.
20474:2018-05-02 10:57:38.072766+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: device request failed ("0xe00002ed (UNDEFINED)" 0xe00002ed).
20475:2018-05-02 10:57:38.085285+1000 0x115      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Not responding - Delaying next read.
20476:2018-05-02 10:57:38.095181+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: device request failed ("0xe00002ed (UNDEFINED)" 0xe00002ed).
20477:2018-05-02 10:57:38.108257+1000 0x115      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Not responding - Delaying next read.

20478:2018-05-02 10:57:38.120896+1000 0x37b      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: device request failed ("0xe00002ed (UNDEFINED)" 0xe00002ed).

then I had a look at the debug_log when it succeeds

Code:
2013:2018-05-02 10:46:41.600374+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: probe
2016:2018-05-02 10:46:41.601406+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: Version 2.2.7 starting on OS X Darwin 16.7.
2183:2018-05-02 10:46:41.802602+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: Unknown new Darwin version 16.7, using possible compatible personality.
2185:2018-05-02 10:46:41.803925+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: 1 matching driver personalities for BrcmFirmwareStore.
2187:2018-05-02 10:46:41.805693+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: Published new IOKit personality for BrcmFirmwareStore.
2188:2018-05-02 10:46:41.805948+1000 0x437      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Firmware store start
2195:2018-05-02 10:46:41.811397+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: 1 matching driver personalities for BrcmPatchRAMResidency.
2200:2018-05-02 10:46:41.812512+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: Published new IOKit personality for BrcmPatchRAMResidency.
2201:2018-05-02 10:46:41.812736+1000 0x43d      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: BrcmPatchRAMResidency start
2211:2018-05-02 10:46:41.818610+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: getFirmware
2248:2018-05-02 10:46:41.851641+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: loadFirmware
2249:2018-05-02 10:46:41.851871+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource: 00000000
2989:2018-05-02 10:46:42.670097+1000 0x20f      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource Callback: dc008006.
3000:2018-05-02 10:46:42.677657+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource: 00000000
3087:2018-05-02 10:46:42.706528+1000 0x20f      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource Callback: dc008006.
3096:2018-05-02 10:46:42.715894+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource: 00000000
3106:2018-05-02 10:46:42.726648+1000 0x20f      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: OSKextRequestResource Callback: 5886 bytes of data.
3113:2018-05-02 10:46:42.735730+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Loaded firmware "BCM4350C5_003.006.007.0095.1703_v5799.zhx" from resources.
3126:2018-05-02 10:46:42.744603+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Decompressed firmware (5886 bytes --> 14872 bytes).
3136:2018-05-02 10:46:42.753304+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Firmware is valid IntelHex firmware.
3144:2018-05-02 10:46:42.762414+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: USB [ACE010DD2F5E v274] "BCM2045A0" by "Broadcom Corp"
3616:2018-05-02 10:46:43.172962+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Available composite configurations: 1.
3626:2018-05-02 10:46:43.181727+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Set device configuration to configuration index 0 successfully.
3632:2018-05-02 10:46:43.190619+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: USBDeviceShim::findFirstInterface
3638:2018-05-02 10:46:43.198359+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: getValidatedInterface returns <private>
3642:2018-05-02 10:46:43.213381+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Interface 0 (class ff, subclass 01, protocol 01) located.
3649:2018-05-02 10:46:43.229721+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: set configuration and interface opened
3667:2018-05-02 10:46:43.249192+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: findPipe: direction = 1, type = 3
3672:2018-05-02 10:46:43.257528+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: endpoint found: epDirection = 1, epType = 3
3673:2018-05-02 10:46:43.266100+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: found matching endpoint
3674:2018-05-02 10:46:43.274301+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: findPipe: direction = 0, type = 2
3693:2018-05-02 10:46:43.283606+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: endpoint found: epDirection = 1, epType = 3
3694:2018-05-02 10:46:43.294823+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: endpoint found: epDirection = 1, epType = 2
3695:2018-05-02 10:46:43.303616+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: endpoint found: epDirection = 0, epType = 2
3702:2018-05-02 10:46:43.313296+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: found matching endpoint
3705:2018-05-02 10:46:43.322497+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: got pipes
3978:2018-05-02 10:46:43.930117+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: State "Unknown" --> "Initialize".
3997:2018-05-02 10:46:43.939515+1000 0x112      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: READ VERBOSE CONFIG complete (status: 0x00, length: 10 bytes).
4010:2018-05-02 10:46:43.948764+1000 0x112      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Firmware version: v4096.
4016:2018-05-02 10:46:43.956994+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: State "Initialize" --> "Firmware version".
4025:2018-05-02 10:46:43.965703+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: getFirmware


4028:2018-05-02 10:46:43.973098+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Retrieved cached firmware for "BCM4350C5_003.006.007.0095.1703_v5799".
4044:2018-05-02 10:46:43.982505+1000 0x112      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: DOWNLOAD MINIDRIVER complete (status: 0x00, length: 4 bytes).
4070:2018-05-02 10:46:43.991676+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: State "Firmware version" --> "Mini-driver complete".


6201:2018-05-02 10:46:44.481546+1000 0x112      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: END OF RECORD complete (status: 0x00, length: 4 bytes).
6202:2018-05-02 10:46:44.490506+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: State "Instruction write" --> "Firmware written".
6277:2018-05-02 10:46:44.569509+1000 0x112      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: RESET complete (status: 0x00, length: 4 bytes).
6278:2018-05-02 10:46:44.578007+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: State "Firmware written" --> "Reset complete".
6292:2018-05-02 10:46:44.587237+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Device reset.
6322:2018-05-02 10:46:44.594886+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Device status 0x00000003.
6329:2018-05-02 10:46:44.602720+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: State "Reset complete" --> "Update complete".
6334:2018-05-02 10:46:44.611086+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Firmware upgrade completed successfully.
6341:2018-05-02 10:46:44.620417+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: brcmBundIdentifier: "com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport"
6354:2018-05-02 10:46:44.629368+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: brcmIOClass: "BroadcomBluetoothHostControllerUSBTransport"
6409:2018-05-02 10:46:44.637795+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: brcmProviderClass: "IOUSBHostDevice"


You can compare the two and see where it fails (Device request failed - repeatedly ---).
look at this


View attachment 329010

and compare to this

View attachment 329011



So you can see that the fault happens right after
Code:
 Retrieved cached firmware for "BCM4350C5_003.006.007.0095.1703_v5799".

now in the working version after that line "retrieved cached firmware" you get these

Code:
028:2018-05-02 10:46:43.973098+1000 0x376      Default     0x0                  0      kernel: (BrcmFirmwareRepo) BrcmPatchRAM: Retrieved cached firmware for "BCM4350C5_003.006.007.0095.1703_v5799".
4044:2018-05-02 10:46:43.982505+1000 0x112      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: DOWNLOAD MINIDRIVER complete (status: 0x00, length: 4 bytes).
4070:2018-05-02 10:46:43.991676+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: State "Firmware version" --> "Mini-driver complete".
6201:2018-05-02 10:46:44.481546+1000 0x112      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: END OF RECORD complete (status: 0x00, length: 4 bytes).
6202:2018-05-02 10:46:44.490506+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: State "Instruction write" --> "Firmware written".
6277:2018-05-02 10:46:44.569509+1000 0x112      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: RESET complete (status: 0x00, length: 4 bytes).
6278:2018-05-02 10:46:44.578007+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: State "Firmware written" --> "Reset complete".
6292:2018-05-02 10:46:44.587237+1000 0x376      Default     0x0                  0      kernel: (BrcmPatchRAM2) BrcmPatchRAM2: [0a5c:6412]: Device reset

so I looked at the code where
Code:
DOWNLOAD MINIDRIVER complete (status: 0x00, length: 4 bytes).
was a debuglog
here is where I found them

View attachment 329013

so I changed three debuglog (HCI_OPCODE_END_OF_RECORD, HCI_OPCODE_RESET, HCI_OPCODE_DOWNLOAD MINIDRIVER) to always log - and create a release version to run.
this worked.

So then it was a matter of elimination to see which one was absolutely necessary.
all this is very time consuming of course .

so by elimination I found out that if I only changed one debuglog (HCI_OPCODE_END_OF_RECORD) to always log - the firmware would load.

So then an added a iosleep (20) was enough to make the release work (after changing alwayslog back to debuglog)


View attachment 329014


so this made it work consistently for my Dell - DW1820..


Not sure if this delay is put in a good place - but at least it works for now -
Is there a better place to put this iosleep achieving the same thing?


Sorry again for creating some confusion with tluck version which turned out not to be my solution.

After it enters the kFirmwareWritten state, the next step is to issue a reset.
Note:
Code:
            case kFirmwareWritten:
                hciCommand(&HCI_RESET, sizeof(HCI_RESET));
                break;

I would tend to put the IOSleep there instead:
Code:
            case kFirmwareWritten:
                IOSleep(mPreResetDelay);
                hciCommand(&HCI_RESET, sizeof(HCI_RESET));
                break;

Or, to make it configurable:
Code:
NUC6i7KYK:brcmpatch.git rehabman$ git diff
diff --git a/BrcmPatchRAM/BrcmPatchRAM.cpp b/BrcmPatchRAM/BrcmPatchRAM.cpp
index 7279e8e..e42d021 100644
--- a/BrcmPatchRAM/BrcmPatchRAM.cpp
+++ b/BrcmPatchRAM/BrcmPatchRAM.cpp
@@ -214,6 +214,12 @@ IOService* BrcmPatchRAM::probe(IOService *provider, SInt32 *probeScore)
     if (PE_parse_boot_argn("bpr_postresetdelay", &delay, sizeof delay))
         mPostResetDelay = delay;

+    mPreResetDelay = 20;
+    if (OSNumber* preResetDelay = OSDynamicCast(OSNumber, getProperty("PreResetDelay")))
+        mPreResetDelay = preResetDelay->unsigned32BitValue();
+    if (PE_parse_boot_argn("bpr_preresetdelay", &delay, sizeof delay))
+        mPreResetDelay = delay;
+
     if (OSString* displayName = OSDynamicCast(OSString, getProperty(kDisplayName)))
         provider->setProperty(kUSBProductString, displayName);
     
@@ -1286,6 +1292,7 @@ bool BrcmPatchRAM::performUpgrade()
                 continue;

             case kFirmwareWritten:
+                IOSleep(mPreResetDelay);
                 hciCommand(&HCI_RESET, sizeof(HCI_RESET));
                 break;

diff --git a/BrcmPatchRAM/BrcmPatchRAM.h b/BrcmPatchRAM/BrcmPatchRAM.h
index e6a10e8..ba901d8 100644
--- a/BrcmPatchRAM/BrcmPatchRAM.h
+++ b/BrcmPatchRAM/BrcmPatchRAM.h
@@ -78,6 +78,7 @@ private:
     UInt16 mVendorId;
     UInt16 mProductId;
     UInt32 mProbeDelay;
+    UInt32 mPreResetDelay;
     UInt32 mPostResetDelay;
     UInt32 mInitialDelay;

Although I'm not certain of your analysis... In your failure case (looking at logs), the kFirmwareWritten state is never reached, so how could that added IOSleep have any effect?
 
After it enters the kFirmwareWritten state, the next step is to issue a reset.
Note:
Code:
            case kFirmwareWritten:
                hciCommand(&HCI_RESET, sizeof(HCI_RESET));
                break;

I would tend to put the IOSleep there instead:
Code:
            case kFirmwareWritten:
                IOSleep(mPreResetDelay);
                hciCommand(&HCI_RESET, sizeof(HCI_RESET));
                break;

Or, to make it configurable:
Code:
NUC6i7KYK:brcmpatch.git rehabman$ git diff
diff --git a/BrcmPatchRAM/BrcmPatchRAM.cpp b/BrcmPatchRAM/BrcmPatchRAM.cpp
index 7279e8e..e42d021 100644
--- a/BrcmPatchRAM/BrcmPatchRAM.cpp
+++ b/BrcmPatchRAM/BrcmPatchRAM.cpp
@@ -214,6 +214,12 @@ IOService* BrcmPatchRAM::probe(IOService *provider, SInt32 *probeScore)
     if (PE_parse_boot_argn("bpr_postresetdelay", &delay, sizeof delay))
         mPostResetDelay = delay;

+    mPreResetDelay = 20;
+    if (OSNumber* preResetDelay = OSDynamicCast(OSNumber, getProperty("PreResetDelay")))
+        mPreResetDelay = preResetDelay->unsigned32BitValue();
+    if (PE_parse_boot_argn("bpr_preresetdelay", &delay, sizeof delay))
+        mPreResetDelay = delay;
+
     if (OSString* displayName = OSDynamicCast(OSString, getProperty(kDisplayName)))
         provider->setProperty(kUSBProductString, displayName);
    
@@ -1286,6 +1292,7 @@ bool BrcmPatchRAM::performUpgrade()
                 continue;

             case kFirmwareWritten:
+                IOSleep(mPreResetDelay);
                 hciCommand(&HCI_RESET, sizeof(HCI_RESET));
                 break;

diff --git a/BrcmPatchRAM/BrcmPatchRAM.h b/BrcmPatchRAM/BrcmPatchRAM.h
index e6a10e8..ba901d8 100644
--- a/BrcmPatchRAM/BrcmPatchRAM.h
+++ b/BrcmPatchRAM/BrcmPatchRAM.h
@@ -78,6 +78,7 @@ private:
     UInt16 mVendorId;
     UInt16 mProductId;
     UInt32 mProbeDelay;
+    UInt32 mPreResetDelay;
     UInt32 mPostResetDelay;
     UInt32 mInitialDelay;

Although I'm not certain of your analysis... In your failure case (looking at logs), the kFirmwareWritten state is never reached, so how could that added IOSleep have any effect?
Thanks for the feedback.
Yes, i see what your are saying, it seems odd that an IOSleep at that point makes it work somehow,
????
Will look more deeper into code and see if putting it at other lines make it also work.


Stay tuned :crazy:
 
@asleb
with regards to your bluetooth injection

BrcmFirmwareRepo.kext : has to be copied properly into /L/E - does not work in clover/kext/other
BrcmPatchRAM2.kext: can be via clover or copied properly into /L/E
I would put both into /L/E
and remove them from clover
sudo touch System/Library/Extensions && sudo kextcache -u [/CODE]
Thanks so much @YoshiMac for your suggestions for WiFi. I have now AC connections!
But I tried your suggestion for bluetooth and now it says "no information" meaning it does not find any bluetooth hardware. I also tried to rebuild kextcache but got an error:
Code:
imac$ sudo touch /System/Library/Extensions && sudo kextcache -u
kextcache: option requires an argument -- -u.
unrecognized option -u
 
Thanks so much @YoshiMac for your suggestions for WiFi. I have now AC connections!
But I tried your suggestion for bluetooth and now it says "no information" meaning it does not find any bluetooth hardware. I also tried to rebuild kextcache but got an error:

Great!

Apologies the command is wrong missing a “/“
Also because it is better to copy the extra Kext into L/E instead of S/L/E
And if you have copied the Kext into /L/E Change the touch to /Library/Extensions

Code:
sudo touch /Library/Extensions && kextcache -u /

With regards to BT
Have you defined your USB ports properly?
Post troubleshooting files.
 
Last edited:
Thanks so much @YoshiMac for your suggestions for WiFi. I have now AC connections!
But I tried your suggestion for bluetooth and now it says "no information" meaning it does not find any bluetooth hardware. I also tried to rebuild kextcache but got an error:
Code:
imac$ sudo touch /System/Library/Extensions && sudo kextcache -u
kextcache: option requires an argument -- -u.
unrecognized option -u

So for your USB configuration
at the very least have

USBinjectall.kext installed in L/E
https://bitbucket.org/RehabMan/os-x-usb-inject-all/downloads/
I think you have USBinjectall.kext installed.



and also have the port limit patch for your version of OS in clover config.plist
what version are you on? High Sierra 12.13.?
I also think you have this installed already on your system
only the one patch is needed though, I think you have 4 installed!
so if you are running 12.13.4
only
USB 10.13.4+ by PMHeart patch needed
which according to your config.plist you have.
delete the other three
asleb configplist portlimit patch.jpeg




-------------
if you have BRCMpatchram2.kext and BRCMfirmwareRepo.Kext in L/E.
and your BT was at least showing up as USB device before but not anymore.
and USBinjectall and port limit patch installed

you may have encountered
the problem I had with BRCMpatchram2.kext and my DW1820.
it knocked my BT out so that it even did not show up as a USB device anymore.

I have been able to make it work by running the debug-version of BRCMpatchram2.kext
this version (exactly same as release however) adds a lot of comments to the running of BRCMpatchram2.kext so that you can see more information in the logs about what is going on.
But also it slows the program down a bit - and for some reason this is making my BT firmware upload properly.
See if this works for you.
So just copy the the debug version into L/E ,
sudo cp -r <file> /Library/Extension
delete the original BRCMpatchram2 and
rebuild cache
sudo touch /Library/Extensions && sudo kextcache -u /

shutdown your system completely -
I unplug my system from power (not really necessary)
wait for 10 seconds before rebooting
(this to make sure firmware of BT chip is reset to initial state, and recover from the knockout by brcmpatchram2.kext)
plug power back in
reboot


I have attached debug version of BRCMpatchram2.kext below
unzip


Be aware if this works for you,
a debug version runs slightly slower
(Slower loading of kext not Bluetooth speed)
which you may or may not notice.
For me though I don't mind.


once I figure out a release version for the DW1830 and BT,
I let you know.
 

Attachments

  • BrcmPatchRAM2__debug.kext.zip
    21.6 KB · Views: 144
Last edited:
So for your USB configuration
at the very least have

USBinjectall.kext installed in L/E
https://bitbucket.org/RehabMan/os-x-usb-inject-all/downloads/
I think you have USBinjectall.kext installed.
------
I let you know.
Hi, I tried your suggestions but I am completely frightened about the "..generate USB dst.." stuff. I don't fell competent for that :( What happens now is that the WiFi was working but now it says "no wifi hardware installed". I also tried to install the "gen_debug" tool but it says
Code:
Downloading the latest version from GitHub...
cp: /usr/bin/gen_debug: Operation not permitted
chmod: /usr/bin/gen_debug: No such file or directory
Tool installed successfully.[code]
but will not run then
[code]./install_tools.sh: line 54: gen_debug: command not found

Is there an easier way to get the USB and bluetooth working and Wifi stable?
##UPDATE##
I was able to run gen_debug and have attached the files. Had to disable SIP of course to install it.
If you have time to look maybe you see something? Now I have no WIFI or BT at all!

##UPDATE 2##
Just like you posted my wifi now just dissapeared. It is even gone in Windows 10. Bluetooth is working fine in Windows 10 but it can not find any WIFI device any more!

##UPDATE 3##
Wifi is back again with AC full speed. I really don't know how but this seems pretty unreliable.
 

Attachments

  • debug_12474.zip
    3.2 MB · Views: 97
Last edited:
Status
Not open for further replies.
Back
Top