I do not understand linkage between device and driver

Hans-Pe

New Member


Messages: 2

Two weeks ago I installed FreeBSD 13.0-Release on my old MacMini, my first encounter with FreeBSD.

After some pkg installs (zsh, vim...) I want to go wireless and activate MacMini's Broadcom BMC4321 WLAN adapter and then I began to stumble:

bwn0: bwn_phy_n_attach: BWN_GPL_PHY not in kernel config; no PHY-N support
bwn0: failed
device_attach: bwn0 attach returned 6

Having found and read several contributions and documents here and elsewhere, I came to the conclusion that I have to use the bwn(4) wireless network driver and
  • install bwn-firmware-kmod from /usr/ports/net.
  • to get rid off the message "no PHY-N Support", I also have to use the kernel option BWN_GPL_PHY, that is I have to customise the kernel.
Reading bwn(4) I have a basic problem of understanding, which is probably not directly related to the Broadcom-stuff:

bwn(4) synopsis states the following:
To compile this driver into the kernel, add the following lines to the kernel configuration file:
device bwn​
<schnipp>​
device firmware​

To load the driver as a module at boot, add the following lines to loader.conf(5):

if_bwn_load="YES"​

Does the synopsis describes two alternatives from which I can choose or do I have to follow both statements?
Is it enough to load the driver via loader.conf or is it required to add all the devices mentioned above? The list of devices is intimidating long and some are already present in GENERIC and others like siba(4) are said to be obsolete now (FreeBSD Broadcom Wi-Fi Improvements)

Generally I do not understand how the link from a device specified in the kernel to its driver (and maybe vice versa) is implemented in FreeBSD.

I started digging through the source codes, but I'm beginning to fear I'm drowning in them.

Clarification and comfort welcome!
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,686
Messages: 39,279

Does the synopsis describes two alternatives from which I can choose or do I have to follow both statements?
It's two alternatives. You can statically link devices in the kernel, or load them as modules. Many devices can be handled that way. You can build a large static kernel with all the devices already built-in, or create a very lean kernel and load the devices as modules afterwards. And everything in between (some modules built-in and others loaded as modules).

Generally I do not understand how the link from a device specified in the kernel to its driver (and maybe vice versa) is implemented in FreeBSD.
In general, all devices are always built as modules. The kernel config just defines which ones are statically included. The device ... just refers to a bit of code in the source tree, that bit of code is the driver for that device. The driver code is the "glue" that allows the kernel to talk to that specific device, it takes care of initializing it, sets registers and knows how to "convert" a system command to the signals required to have that device do what needs to be done.
 
OP
H

Hans-Pe

New Member


Messages: 2

In general, all devices are always built as modules. The kernel config just defines which ones are statically included. The device ... just refers to a bit of code in the source tree, that bit of code is the driver for that device. The driver code is the "glue" that allows the kernel to talk to that specific device, it takes care of initializing it, sets registers and knows how to "convert" a system command to the signals required to have that device do what needs to be done.
Thank you!
As I understand it now, the name after device is used to take a lookup in the source tree. I run find . -name 'bwn' and got the directories

/sys/modules/bwn/
/sys/dev/bwn/
I assume that some files found there will provide the reference to the driver.
 
Top