The question about wifi card

Hi,

We use Ampak6398P wifi bt card(which use BCM4359 chip) connect to nano module.
After booting, it can’t work, and don’t have wlan0 interface.
And lsmod shows:

sercomm@linux:~$ lsmod
Module                  Size  Used by
overlay                48691  0
zram                   26166  4
bcmdhd_pcie           892308  0
cfg80211              589351  1 bcmdhd_pcie
nvgpu                1575721  3
bluedroid_pm           13912  0
ip_tables              19441  0
x_tables               28951  1 ip_tables
sercomm@linux:~$ ifconfig wlan0 up
wlan0: ERROR while getting interface flags: No such device

Then we want to remove bcmdhd_pcie, get crash:

sercomm@linux:~$ sudo rmmod bcmdhd_pcie
[sudo] password for sercomm: 
[  135.890552] ------------[ cut here ]------------
[  135.895201] WARNING: CPU: 2 PID: 5947 at /home/garret/nano/ForCyril/nvidia_src/kernel/kernel-4.9/drivers/base/driver.c:191 driver_unregister+0x4c/0x58
[  135.910356] ---[ end trace 3210391a2f93ce75 ]---
[  135.921327] Unable to handle kernel read from unreadable memory at virtual address 00000000
[  135.929925] Mem abort info:
[  135.932801]   ESR = 0x96000005
[  135.935902]   Exception class = DABT (current EL), IL = 32 bits
[  135.941840]   SET = 0, FnV = 0
[  135.944907]   EA = 0, S1PTW = 0
[  135.948055] Data abort info:
[  135.950945]   ISV = 0, ISS = 0x00000005
[  135.954788]   CM = 0, WnR = 0
[  135.957752] user pgtable: 4k pages, 39-bit VAs, pgd = ffffffc0f2b12000
[  135.964434] [0000000000000000] *pgd=0000000000000000, *pud=0000000000000000
[  135.971476] Internal error: Oops: 96000005 [#1] PREEMPT SMP
[  135.977038] Modules linked in: overlay zram bcmdhd_pcie(-) cfg80211 nvgpu bluedroid_pm ip_tables x_tables
[  135.987001] CPU: 2 PID: 5947 Comm: rmmod Tainted: G        W       4.9.140 #1
[  135.994208] Hardware name: NVIDIA Jetson Nano Developer Kit (DT)
[  136.000263] task: ffffffc0dfb82a00 task.stack: ffffffc0f0b9c000
[  136.006290] PC is at pci_unregister_driver+0x3c/0xb0
[  136.011371] LR is at pci_unregister_driver+0x34/0xb0
[  136.016445] pc : [<ffffff80084e2fcc>] lr : [<ffffff80084e2fc4>] pstate: 00400145
[  136.023948] sp : ffffffc0f0b9fde0
[  136.027350] x29: ffffffc0f0b9fde0 x28: ffffffc0dfb82a00 
[  136.032853] x27: ffffff8008f72000 x26: 000000000000006a 
[  136.038350] x25: 0000000000000123 x24: 0000000000000015 
[  136.043839] x23: 00000000

We find “BCM4359 support” in Kconfig of “kernel/nvidia/drivers/net/wireless/bcmdhd_pcie/”.
Could bcmdhd_pcie.ko can support this card work? If yes, what should we do?

Thanks.

I think you should check with broadcom which driver and kernel version does support bcm4359 first.

https://help.ubuntu.com/community/WifiDocs/Driver/bcm43xx

TX2 supports bcm4354 but it is on SDIO. According to the experience from TX2, you also need the wifi firmware released from broardcom to make this chip work.

Hi WayneWWW,

Thanks for your reply, we have check with vendor that they give us a package source about bcmdhd, and firmware.
Then we find nvidia folder shows “BCM4359 support” in Kconfig of “kernel/nvidia/drivers/net/wireless/bcmdhd_pcie/”.

We boot the Nano, bcmdhd_pcie.ko is insmod automatic. And this bcmdhd_pcie.ko is compiling from “kernel/nvidia/drivers/net/wireless/bcmdhd_pcie/”.
We refer to the guide from vendor to update firmware path:

If bcmdhd driver is built in kernel image, you will need to configure firmware path. 
# echo -n “/etc/firmware/fw_bcmdhd.bin” > /sys/module/bcmdhd/parameters/firmware_path 
# echo -n “/etc/firmware/nvram.txt” > /sys/module/bcmdhd/parameters/nvram_path

We update the firmware and nvram path from the vendor, wlan0 still do not appera.

Could you have some suggestion?
Thanks.

Hi arknights,

According to the vendor, they said “If bcmdhd driver is built in kernel image”, but what you are doing is not a built-in. You build bcmdhd_pcie as a loadable kernel module (.ko) file. Built-in means you need to set it to “=y” in defconfig instead of “=m” and the driver would be inside Image. Though I am not sure whether it is fatal on their driver.

Any other dmesg comes out from their driver after loading fw?

BTW, do you read your device in lspci?

Please check whether this function “dhd_update_fw_nv_path” is called when you try to update the fw/nvram path in sysfs.

Hi WayneWWW,

Thanks.

So let’s talk about Ampak 6398p.

Actually, the bcmdhd_pcie and bcmdhd source code is greatly different from the official bcmdhd.100.10.545.x source code Ampak provided to us. I have thought that Nvidia add many your own code into bcmdhd_pcie and bcmdhd source code.

garret:~/kernel_source/kernel/nvidia/drivers/net/wireless$ ls
bcmdhd  bcmdhd.100.10.545.x  bcmdhd_pcie  Kconfig  Makefile  realtek

(1) Could you tell me what the base function of bcmdh module and bcmdhd_pci module and what the difference between them?

(2) For our customized board, our BT/WIFI pins is defined and described as blow pic.

As for the Ampak 6398p, which source code should we focus on,bcmdhd_pcie or bcmdhd? I mean it seem a litter hard for us to locate the right position where the Pins function relative to Ampak 6398p in the source code. If you can give us more information about how to change that code snippet of the source code, that would be better. We will be very appreciated it.

Thanks in advance.

Hi garretzou,

Yes, I notice some changes in our driver code which differs with upstream kernel source. Actually, for jetson, only TX1/TX2 has on-module wifi which is SDIO based device. For SDIO based device, we use bcmdhd as it driver.

We don’t really have a existing platform that uses bcmdhd_pcie. Thus, if you have a latest driver from Ampak,
please use that instead of our bcmdhd_pcie.

If you could see your device in lspci list, then the pcie part is done and only need to worry about the driver as bcmd* drivers.

Hi WayneWWW,

Thanks

Our industrial board based can be detected with lspci, and lsmod show that bcmdhd_pcie.ko is the driver for Ampak 6398p.

But when rmmod rmmod bcmdhd_pcie, we get below error.

sercomm@localhost:~$ sudo rmmod bcmdhd_pcie
[sudo] password for sercomm: 
[   37.435215] ------------[ cut here ]------------
[   37.439850] WARNING: CPU: 3 PID: 5762 at /home/cyril/jetpack4/SRC/nvidia_src/kernel/kernel-4.9/drivers/base/driver.c:191 driver_unregister+0x4c/0x58
[   37.453955] ---[ end trace ab77c0b9f8e538b6 ]---
[   37.461936] Unable to handle kernel read from unreadable memory at virtual address 00000000
[   37.470326] Mem abort info:
[   37.473149]   ESR = 0x96000005
[   37.476451]   Exception class = DABT (current EL), IL = 32 bits
[   37.482387]   SET = 0, FnV = 0
[   37.485448]   EA = 0, S1PTW = 0
[   37.488594] Data abort info:
[   37.491480]   ISV = 0, ISS = 0x00000005
[   37.495319]   CM = 0, WnR = 0
[   37.498282] user pgtable: 4k pages, 39-bit VAs, pgd = ffffffc0eaa49000
[   37.504946] [0000000000000000] *pgd=0000000000000000, *pud=0000000000000000
[   37.511973] Internal error: Oops: 96000005 [#1] PREEMPT SMP
[   37.517533] Modules linked in: bcmdhd_pcie(-) cfg80211 zram overlay nvgpu bluedroid_pm ip_tables x_tables
[   37.527395] CPU: 3 PID: 5762 Comm: rmmod Tainted: G        W       4.9.140-tegra #1
[   37.535098] Hardware name: NVIDIA Jetson Nano Developer Kit (DT)
[   37.541170] task: ffffffc0de1b3800 task.stack: ffffffc0e02d4000
[   37.547160] PC is at pci_unregister_driver+0x3c/0xb0
[   37.552192] LR is at pci_unregister_driver+0x34/0xb0
[   37.557198] pc : [<ffffff80084e2fcc>] lr : [<ffffff80084e2fc4>] pstate: 00400145
[   37.564648] sp : ffffffc0e02d7de0
[   37.568047] x29: ffffffc0e02d7de0 x28: ffffffc0de1b3800 
[   37.573540] x27: ffffff8008f82000 x26: 000000000000006a 
[   37.579030] x25: 0000000000000123 x24: 0000000000000015 
[   37.584512] x23: 0000000000000000 x22: ffffff800126ad88 
[   37.589986] x21: ffffff800126ad90 x20: ffffff800126ae00 
[   37.595463] x19: ffffff8009ea7000 x18: 0000007fa4a0fa70 
[   37.600941] x17: 0000000000000000 x16: 0000000000000000 
[   37.606414] x15: 0000000000000000 x14: 0000000000000000 
[   37.611892] x13: 0000000000000000 x12: 000000000000

Hi garretzou,

I have another question about your issue. Since your issue only happens when you “rmmod” this driver, does this wifi card work when you insmod this driver?

Hi WayneWWW,
Thanks

It seem not really.

And I find below code snippet in my source code.

\\\\nvidia\drivers\net\wireless\bcmdhd_pcie
garret:~/src_share/nano_kernel/kernel/nvidia/drivers/net/wireless/bcmdhd_pcie$ ack nvidia
dhd_custom_tegra.c
154:    ret = wifi_get_mac_address_dtb("/chosen", "nvidia,wifi-mac", buf);

dhd_linux_platdev.c
308:            sku = of_get_property(of_chosen, "nvidia,sku", NULL);
310:                                            "nvidia,sku_version", NULL);

These two lines indicate the driver would read the mac address from the device tree. Not fatal/related to any error now.

I think we should see if any error log from the driver when modprobe or insmod is called instead of checking rmmod directly.

Hi WayneWWW,

Thanks
We will show you the modprobe and insmod called log tomorrow.

Hi WayneWWW,

We are not sure about the pins connected to AMPAK 6398P match its driver. I mean, do we need to change something related to BT_REG_ON, WL_REG_ON and others in the bcmdhd_pcie driver cause we redefined some pins based on the official pinmux 1.01 which target at R32.2.x while we use it in the lastest version R32.3.1?

Hi WayneWWW,

Please take a look at the log blow relative to bcmdhd_pcie drvier. The bcmdhd_pcie is auto-loaded when booting. But wlan0 can’t be detected.

How should we change the bcmdhd_pcie driver to make it match our customized carrier board?
The BT and WIFI relative pin mapping of our carrier board is as below pic.

Thanks
Serial-COM16_0201_11-16-17.log (42.5 KB)

Hi garretzou,

I think you should firstly remove the “quiet” keyword in /boot/extlinux/extlinux.conf.

This keyword blocks the driver log during boot and all previous logs you attached here didn’t show them.

Also, which bcmdhd_pcie driver are you using now? Do you use it from the vendor or nv codebase?

Hi WayneWWW,

The bcmdhd_pcie driver is from nv codebase.

Thanks

I would suggest to use the driver from the vendor. bcmdhd_pcie is not in use in our side.

Hi WayneWWW,

If we use the driver from the vendor, where should we modify in the driver code?
For example, we found dhd_gpio.c need modify GPIO num for Wifi and BT, we use uart0 for bt, how to calculate GPIO num?

And do you think whether we need to modify device tree?

Thanks.

Hi arknights,

I don’t see dhd_gpio.c here, is that file from vendor?

For gpio number, please refer to this header file.
-> ./kernel-4.9/include/dt-bindings/gpio/tegra-gpio.h

And do you think whether we need to modify device tree?
It depends on whether their driver is reading something from DT or not.

Hi WayneWWW,

I will upload the driver code which vendor provide us in attachment.
The dhd_gpio.c is from vendor, you can see the notes in that file:

/* Please check your schematic and fill right GPIO number which connected to
	* WL_REG_ON and WL_HOST_WAKE.
	*/

Thanks.
bcmdhd.100.10.545.x.7z (1.4 MB)