5 Replies Latest reply on Aug 3, 2020 9:17 AM by JaCo_4746761

    BCM4339 Moving from bcmdhd to brcmfmac

    JaCo_4746761

      Hello,

       

      Not sure if this is the correct place to ask this or not, but basically i running on a Compulab board (https://www.compulab.com/products/computer-on-modules/cl-som-imx6-nxp-freescale-i-mx-6-system-on-module/ ) With the BCM4339 option.  I was using linux-imx tag rel_imx_4.1.15_1.1.0_ga (the latest version compulab uses) and using bcmdhd and everything was working fine, i am trying to move to rel_imx_5.4.24_2.1.0 to access some other improvements i need, but it seems in this kernel version bcmdhd has went away?  I have been trying to convert to using brcmfmac but haven't had much success so far.  Here is my old device tree setup for bcmdhd:

                /* regulator1 for wifi/bt */
                wlan_pwren_dn: regulator@99 {
                     compatible = "regulator-fixed";
                     regulator-min-microvolt = ;
                     regulator-max-microvolt = ;
                     regulator-name = "wlan_pwren_dn";
                     gpio = <&gpio3 1 0>;
                     enable-active-high;
                };

                wlreg_on: fixedregulator@100 {
                     compatible = "regulator-fixed";
                     regulator-min-microvolt = ;
                     regulator-max-microvolt = ;
                     regulator-name = "wlreg_on";
                     gpio = <&gpio6 16 0>;
                     startup-delay-us = ;
                     enable-active-high;
                };

       

      /* pins for wifi/bt */
                pinctrl_usdhc1: usdhc1grp {
                     fsl,pins = <
                          MX6QDL_PAD_SD1_CMD__SD1_CMD                   0x17071
                          MX6QDL_PAD_SD1_CLK__SD1_CLK                   0x10071
                          MX6QDL_PAD_SD1_DAT0__SD1_DATA0                0x17071
                          MX6QDL_PAD_SD1_DAT1__SD1_DATA1                0x17071
                          MX6QDL_PAD_SD1_DAT2__SD1_DATA2                0x17071
                          MX6QDL_PAD_SD1_DAT3__SD1_DATA3                0x17071
                     >;
                };

       

      /* pins for wifi/bt */
                pinctrl_murata: murata1grp {
                     fsl,pins = <
                          MX6QDL_PAD_NANDF_CS3__GPIO6_IO16           0x80000000 /* WL_REG_ON_3V3 */
                          MX6QDL_PAD_NANDF_CS1__GPIO6_IO14           0x80000000 /* WL_HOST_WAKE */
                          MX6QDL_PAD_EIM_DA1__GPIO3_IO01                0x80000000 /* WLAN_PWREN_PD */
                          MX6QDL_PAD_GPIO_17__GPIO7_IO12                0x80000000 /* BT_REG_ON_3V3 */
                     >;
                };

       

      &usdhc1 {
           pinctrl-names = "default";
           pinctrl-0 = <&pinctrl_usdhc1 &pinctrl_murata>;
           bus-width = ;
           non-removable;
           wifi-host;
           cd-post;
           pm-ignore-notify;
           vmmc-supply = <&wlan_pwren_dn>;
           status = "okay";
      };

       

           /* Murata -- define hook for BCMDHD driver.   */
           bcmdhd_wlan_0: bcmdhd_wlan@0 {
                compatible = "android,bcmdhd_wlan";
                wlreg_on-supply = <&wlreg_on>;
           };

      The i would simply load the module with:  modprobe bcmdhd firmware_path=lib/firmware/bcm/ZP_BCM4339/fw_bcmdhd.bin nvram_path=/lib/firmware/bcm/ZP_BCM4339/bcmdhd.ZP.OOB.cal op_mode=2

       

      So i have tried updating my device tree but i can't get it working when i modprobe brcmutil & brcmfmac they load in but nothing happens like it doesn't find a device which is why i assume my device tree is messed up.  Here is where I am it with the new one:

                /* regulator1 for wifi/bt */
      usdhc1_pwrseq: usdhc1_pwrseq {
                     compatible = "mmc-pwrseq-simple";
                     reset-gpios = <&gpio3 1 GPIO_ACTIVE_HIGH>;
                };


                wlreg_on: fixedregulator@100 {
                     compatible = "regulator-fixed";
                     regulator-min-microvolt = ;
                     regulator-max-microvolt = ;
                     regulator-name = "wlreg_on";
                     gpio = <&gpio6 16 0>;
                     startup-delay-us = ;
                     enable-active-high;
                };

       

      /* pins for wifi/bt */
                pinctrl_usdhc1: usdhc1grp {
                     fsl,pins = <
                          MX6QDL_PAD_SD1_CMD__SD1_CMD                   0x17071
                          MX6QDL_PAD_SD1_CLK__SD1_CLK                   0x10071
                          MX6QDL_PAD_SD1_DAT0__SD1_DATA0                0x17071
                          MX6QDL_PAD_SD1_DAT1__SD1_DATA1                0x17071
                          MX6QDL_PAD_SD1_DAT2__SD1_DATA2                0x17071
                          MX6QDL_PAD_SD1_DAT3__SD1_DATA3                0x17071
                     >;
                };

       

      /* pins for wifi/bt */
                pinctrl_murata: murata1grp {
                     fsl,pins = <
                          MX6QDL_PAD_NANDF_CS3__GPIO6_IO16           0x80000000 /* WL_REG_ON_3V3 */
                          MX6QDL_PAD_NANDF_CS1__GPIO6_IO14           0x80000000 /* WL_HOST_WAKE */
                          MX6QDL_PAD_EIM_DA1__GPIO3_IO01                0x80000000 /* WLAN_PWREN_PD */
                          MX6QDL_PAD_GPIO_17__GPIO7_IO12                0x80000000 /* BT_REG_ON_3V3 */
                     >;
                };

       

      &usdhc1 {
           #address-cells = ;
           #size-cells = ;
           pinctrl-names = "default";
           pinctrl-0 = <&pinctrl_usdhc1 &pinctrl_murata>;
           bus-width = ;
           non-removable;
           wifi-host;
           keep-power-in-suspend;
           pm-ignore-notify;
           cap-power-off-card;
           vmmc-supply = <&wlreg_on>;
           status = "okay";
           mmc-pwrseq = <&usdhc1_pwrseq>;
           brcmf: bcrmf@1 {
                reg = ;
                compatible = "brcm,bcm4329-fmac";
                interrupt-parent = <&gpio6>;
                interrupts = ;
                interrupt-names = "host-wake";
           };
      };

      I have enabled the following options in my kernel too:

      CONFIG_BRCMUTIL=m
      CONFIG_BRCMFMAC=m
      CONFIG_BRCMFMAC_PROTO_BCDC=y
      CONFIG_BRCMFMAC_PROTO_MSGBUF=y
      CONFIG_BRCMFMAC_SDIO=y
      CONFIG_BRCMFMAC_PCIE=y

       

      When i modprobe brcmutil and brcmfmac, nothing happens no error no device loaded or anything.  I don't know i if have something messed up between the regulator and power_down lines for the chip or what?

       

      Any advice or at least a point in the right direction would be greatly appreciated because i can't seem to find the correct information to get me going.

       

      Thanks,

      Jarrod

        • 1. Re: BCM4339 Moving from bcmdhd to brcmfmac
          ZhengbaoZ_96

          Hello:

            I have no the environment for rel_imx_5.4.24_2.1.0 , so I tried fmac in rel_imx_4.1.15_1.1.0_ga . steps areļ¼š

          a.  I am using cypress-fmac-v4.14.77-2019_0503 .

          we update the newest version here.

          Cypress Linux WiFi Driver Release (FMAC) [2020-06-25]

          Cypress Linux FMAC (Gamera)

           

          b. compile cypress driver:

          #### Build the cypress driver/backports modules

          ```bash

          #1. Untar the Cypress backports package

              tar zxvf cypress-backports-*.tar.gz

              cd v4.14.77-backports

          #2. (Native) compile local tools and generate .config (in a new terminal

          #  without sourcing Yoctol toolchain settings)

              bash

              MY_KERNEL=<the 4.9.88 kernel path>

              make KLIB=$MY_KERNEL KLIB_BUILD=$MY_KERNEL defconfig-brcmfmac

          #3. (Cross) compile kernel modules

              source /opt/poky/1.8/environment-setup-cortexa7hf-vfp-neon-poky-linux-gnueabi

              make KLIB=$MY_KERNEL KLIB_BUILD=$MY_KERNEL modules

          #4. The kernel modules are available here

          #      compat/compat.ko

          #      net/wireless/cfg80211.ko

          #      drivers/net/wireless/broadcom/brcm80211/brcmutil/brcmutil.ko

          #      drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko

          ```

          c.  Device tree reference, I think you can read the release from the package to see if it can help you ..

          #### Device tree

          ```bash

          #1. Untar the cypress devicetree package

              tar zxvf cypress-devicetree-*.tar.gz

          #2. Find your board's dtb file, for example

          #      cypress-devicetree/iMX6SX/4.9.88/imx6sx-sdb-btwifi-fmac.dtb

          ```

          Note: If your board's dtb is not available in the cypress devicetree

                package, please refer to the available dts/dtsi files and create

                them for your board, then compile them for the dtb file. iMX dts

                files are located in linux-imx/arch/arm/boot/dts/ folder of the

                Linux kernel tree. Below command compiles a dtb file

          ```bash

              make ARCH=arm <devicetree name>.dtb

          ```

           

          d.  see the running environemt and results.

          insmod compat.ko

          insmod cfg80211.ko

          insmod brcmutil.ko

          sleep 1

          insmod brcmfmac.ko debug=0x0120000e

           

          where to find brcmfmac firmwares ?

              \cypress-fmac-v4.14.77-2019_0503\firmware

                  here you can copy brcmfmac4339-sdio.bin to /lib/firmware/brcm/

          where to find nvram files?

                 you can rename the nvram from your dhd mode test,  and put it into /lib/firmware/brcm/brcmfmac4339-sdio.txt

                         the rename act is needed also.

           

          e.  logs in  my test.

           

          Loading modules backported from Linux version v4.14.77-2019_0503-0-g1dfe0a6

          Backport generated by backports.git v4.14-rc2-1-70-g694b78f

          root@imx6sx_all:~# brcmfmac: brcmf_fw_map_chip_to_name: using brcm/brcmfmac4339-sdio.bin for chip 0x004339(17209) rev 0x000002

          usbcore: registered new interface driver brcmfmac

          brcmfmac mmc2:0001:1: Direct firmware load for brcm/brcmfmac4339-sdio.clm_blob failed with error -2

          brcmfmac mmc2:0001:1: Falling back to user helper

          brcmfmac: brcmf_c_process_clm_blob: no clm_blob available(err=-11), device may have limited channels available

          brcmfmac: brcmf_c_preinit_dcmds: Firmware version = wl0: May  2 2019 12:09:40 version 6.37.39.111 (r714235 CY)

          IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready

           

          root@imx6sx_all:~# ifconfig

          wlan0     Link encap:Ethernet  HWaddr 10:98:34:29:34:20

                    UP BROADCAST MULTICAST  MTU:1500  Metric:1

                    RX packets:0 errors:0 dropped:0 overruns:0 frame:0

                    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

                    collisions:0 txqueuelen:1000

                    RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

           

          root@imx6sx_all:~# wl ver

          1.8 RC0.0

          wl0: May  2 2019 12:09:40 version 6.37.39.111 (r714235 CY)

          • 2. Re: BCM4339 Moving from bcmdhd to brcmfmac
            JaCo_4746761

            Hello!

             

            Thanks for the response.  Would backporting be necessary if my kernel version is 5.4.24, it would seem according to the latest download of cypress-fmac-v5.4.18-2020_0625.zip i should just need to apply the patches to my kernel (they appear to be already applied in the imx branch) and be good to go.  Also for firmware the latest version (cypress-fmac-v5.4.18-2020_0625.zip) README says put the files in /lib/firmware/cypress rather than /lib/firmware/brcm and the firmware files in cypress-firmware-v5.4.18-2020_0625.tar.gz are all named differently, should i rename them to the names and directories you have above?

             

            It seems my device tree if pretty close to the example ones, i think the one thing i have different is i have a regulator control line for the wi-fi as well and am not sure how to set that up correctly.  I'll keep playing with that and see if i can figure something out.

             

            Finally, The second link above: https://community.cypress.com/docs/DOC-19376  Gives me an unauthorized message when i try to go to it.

             

            Thanks,

            Jarrod

            • 3. Re: BCM4339 Moving from bcmdhd to brcmfmac
              JaCo_4746761

              Hello again,

               

              I shouldn't have replied so quickly as i was able to find the answer to my questions in my reply through some more testing.  So the big helper here was this: insmod brcmfmac.ko debug=0x0120000e i think, once i added that in i got some prints about looking for the firmware and the path it was looking was in fact looking for:  /lib/firmware/brcm/brcmfmac4339-sdio.bin  but the latest package from the the link above (cypress-fmac-v5.4.18-2020_0625.zip) has the files as /lib/firmware/cypress/cyfmac4339-sdio.bin.   Once i renamed the file and moved my old cal file to the same location as TXT everything worked!!!  Thanks you so much for the help.

               

              To recap i did the following:

              1. Pulled the linux-imx version rel_imx_5.4.24_2.1.0

              2. Created a device tree with the following:

                      usdhc1_pwrseq: usdhc1_pwrseq {

                          compatible = "mmc-pwrseq-simple";

                          reset-gpios = <&gpio6 16 GPIO_ACTIVE_LOW>;

                      };

               

                      wlreg_on: fixedregulator@100 {

                          compatible = "regulator-fixed";

                          regulator-min-microvolt = <3300000>;

                          regulator-max-microvolt = <3300000>;

                          regulator-name = "wlreg_on";

                          gpio = <&gpio3 1 0>;

                          startup-delay-us = <100>;

                          enable-active-high;

                          regulator-always-on;

                      };

              ..........................

               

              /* pins for wifi/bt */

                      pinctrl_murata: murata1grp {

                          fsl,pins = <

                              MX6QDL_PAD_NANDF_CS3__GPIO6_IO16         0x80000000 /* WL_REG_ON_3V3 */

                              MX6QDL_PAD_NANDF_CS1__GPIO6_IO14         0x80000000 /* WL_HOST_WAKE */

                              MX6QDL_PAD_EIM_DA1__GPIO3_IO01             0x80000000 /* WLAN_PWREN_PD */

                              MX6QDL_PAD_GPIO_17__GPIO7_IO12             0x80000000 /* BT_REG_ON_3V3 */

                          >;

                      };

               

              pinctrl_usdhc1: usdhc1grp {

                          fsl,pins = <

                              MX6QDL_PAD_SD1_CMD__SD1_CMD                0x17071

                              MX6QDL_PAD_SD1_CLK__SD1_CLK                0x10071

                              MX6QDL_PAD_SD1_DAT0__SD1_DATA0             0x17071

                              MX6QDL_PAD_SD1_DAT1__SD1_DATA1             0x17071

                              MX6QDL_PAD_SD1_DAT2__SD1_DATA2             0x17071

                              MX6QDL_PAD_SD1_DAT3__SD1_DATA3             0x17071

                          >;

                      };

              ................

               

              &usdhc1 {

                  #address-cells = <1>;

                  #size-cells = <0>;

                  pinctrl-names = "default";

                  pinctrl-0 = <&pinctrl_usdhc1 &pinctrl_murata>;

                  bus-width = <4>;

                  no-1-8-v;    /* force 3.3V VIO */

                  non-removable;

                  mmc-pwrseq = <&usdhc1_pwrseq>;

                  vmmc-supply = <&wlreg_on>;

                  pm-ignore-notify;

                  cap-power-off-card;

                  status = "okay";


                  brcmf: bcrmf@1 {

                      reg = <1>;

                      compatible = "brcm,bcm4329-fmac";

                      interrupt-parent = <&gpio6>;

                      interrupts = <14 IRQ_TYPE_LEVEL_HIGH>;

                      interrupt-names = "host-wake";

                  };

              };

              3.  Enabled the following and built the kernel (it would seem cypress patches already exist):

              CONFIG_BRCMUTIL=m

              CONFIG_BRCMFMAC=m

              CONFIG_BRCMFMAC_PROTO_BCDC=y

              CONFIG_BRCMFMAC_PROTO_MSGBUF=y

              CONFIG_BRCMFMAC_SDIO=y

              CONFIG_BRCMFMAC_PCIE=y

              4. Downloaded the latest brcmfmac:  Cypress Linux WiFi Driver Release (FMAC) [2020-06-25]

              5. Copied firmware/cypress/cyfmac4339-sdio.bin to my filesystem as:  /lib/firmware/brcm/brcmfmac4339-sdio.bin

              6. Copied my old bcm/ZP_BCM4339/bcmdhd.ZP.OOB.cal to /lib/firmware/brcm/brcmfmac4339-sdio.txt

              7. Probed in the modules:

              modprobe brcmutil
              modprobe brcmfmac

               

              Now everything is working great!  Thank you so much for the help : )

               

              Thanks,

              Jarrod

              • 4. Re: BCM4339 Moving from bcmdhd to brcmfmac
                ErBe_1728341

                The patch that renames the firmware is in the patch set as number 109:

                 

                0109-brcmfmac-move-firmware-path-to-cypress-folder.patch

                 

                 

                -Eric

                2 of 2 people found this helpful
                • 5. Re: BCM4339 Moving from bcmdhd to brcmfmac
                  JaCo_4746761

                  Ah, okay.  I went to apply the patches and it kept saying they were already applied so i just made the assumption they were all already present in the imx-linux branch and didn't go through them all.  That's what happens when you assume i suppose haha.  Thanks for letting me know!

                   

                  -Jarrod