WARNING
This is a draft
Recently, I got a new wireless PCI card working on atheros. This one should replace the old working for more than 5 years.
# Update the tree
First we will update the tree.
cd /usr/src
doas cvs up -dPrOPNEBSD_6_6
# Find datasheet and references
- https://wireless.wiki.kernel.org/en/users/drivers/ath9k/devices
- https://wireless.wiki.kernel.org/en/users/drivers/ath9k
Here the two card with same information:
- Compex WLE250NX MiniPCIe 9582/9592 0x0033 0x168c 0x3123
- Compex WLE251NX MiniPCIe 9582/9592 0x0033 0x168c 0x3123
# Read the documentation
You can find many documentation. Here the links:
- https://man.openbsd.org/athn
- https://man.openbsd.org/pci.4
- https://man.openbsd.org/ifmedia.4
# Find the firmware in ports tree
- https://openports.se/sysutils/firmware/athn
- https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/?id=f859d9fda9379205c9bcf2eab11fae68891085ee
# Read the code
We are interested in these files:
- http://bxr.su/OpenBSD/sys/dev/pci/if_athn_pci.c
- http://bxr.su/OpenBSD/sys/dev/pci/pcidevs
- http://bxr.su/OpenBSD/sys/dev/pci/pcidevs_data.h
# Get the information
We need to dump information from PCI by using pcidump
pcidump -v
Here the output:
6:0:0: Atheros unknown
0x0000: Vendor ID: 168c, Product ID: 0033
0x0004: Command: 0000, Status: 0010
0x0008: Class: 02 Network, Subclass: 80 Miscellaneous,
Interface: 00, Revision: 01
0x000c: BIST: 00, Header Type: 00, Latency Timer: 00,
Cache Line Size: 00
0x0010: BAR mem 64bit addr: 0x0000000000000000/0x00020000
0x0018: BAR empty (00000000)
0x001c: BAR empty (00000000)
0x0020: BAR empty (00000000)
0x0024: BAR empty (00000000)
0x0028: Cardbus CIS: 00000000
0x002c: Subsystem Vendor ID: 19b6 Product ID: d010
0x0030: Expansion ROM Base Address: 00000000
0x0038: 00000000
0x003c: Interrupt Pin: 01 Line: ff Min Gnt: 00 Max Lat: 00
0x0040: Capability 0x01: Power Management
State: D0
0x0050: Capability 0x05: Message Signalled Interrupts (MSI)
Enabled: no
0x0070: Capability 0x10: PCI Express
Link Speed: 2.5 / 2.5 GT/s, Link Width: x1 / x1
# First try
Let modify some files...
cd /usr/src/sys/pci
Will output:
Index: pci/if_athn_pci.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_athn_pci.c,v
retrieving revision 1.20
diff -u -p -r1.20 if_athn_pci.c
--- pci/if_athn_pci.c 23 Apr 2019 01:17:09 -0000 1.20
+++ pci/if_athn_pci.c 26 Feb 2020 17:31:43 -0000
@@ -97,7 +97,8 @@ static const struct pci_matchid athn_pci
{ PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9285 },
{ PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR2427 },
{ PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9227 },
- { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9287 }
+ { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9287 },
+ { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9580 },
};
int
Index: pci/pcidevs.h
===================================================================
RCS file: /cvs/src/sys/dev/pci/pcidevs.h,v
retrieving revision 1.1889
diff -u -p -r1.1889 pcidevs.h
--- pci/pcidevs.h 26 Sep 2019 12:56:44 -0000 1.1889
+++ pci/pcidevs.h 26 Feb 2020 17:31:44 -0000
@@ -2153,6 +2153,7 @@
#define PCI_PRODUCT_ATHEROS_AR9485 0x0032 /* AR9485 */
#define PCI_PRODUCT_ATHEROS_AR9462 0x0034 /* AR9462 */
#define PCI_PRODUCT_ATHEROS_AR9565 0x0036 /* AR9565 */
+#define PCI_PRODUCT_ATHEROS_AR9580 0x0033 /* AR9580 */
#define PCI_PRODUCT_ATHEROS_AR5210_AP 0x0207 /* AR5210 */
#define PCI_PRODUCT_ATHEROS_AR5212_IBM 0x1014 /* AR5212 */
#define PCI_PRODUCT_ATHEROS_AR5210_DEFAULT 0x1107 /* AR5210 */
Index: pci/pcidevs_data.h
===================================================================
RCS file: /cvs/src/sys/dev/pci/pcidevs_data.h,v
retrieving revision 1.1884
diff -u -p -r1.1884 pcidevs_data.h
--- pci/pcidevs_data.h 26 Sep 2019 12:56:44 -0000 1.1884
+++ pci/pcidevs_data.h 26 Feb 2020 17:31:45 -0000
@@ -6812,6 +6812,10 @@ static const struct pci_known_product pc
"AR9565",
},
{
+ PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9580,
+ "AR9580",
+ },
+ {
PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR5210_AP,
"AR5210",
},
Okay, now, we will compile it and try to run it...
cd /usr/src/sys/arch/amd64/GENERIC.MP
make obj
make configure
make
cp /bsd /bsd.backup
cp obj/bsd /bsd
reboot
The router works but, even with the 2 antennas connectected on the
board, we can't see it. Another thing, pcidump -v doesn't return the
good version.
# Resources
- http://coccinelle.lip6.fr/papers/backport_edcc15.pdf
- http://129.128.5.191/papers/eurobsdcon2017-device-drivers.pdf
- https://2009.asiabsdcon.org/papers/abc2009-P3B-paper.pdf
- https://ftp.openbsd.org/papers/eurobsdcon2017-device-drivers.pdf