OPNsense Forum

English Forums => Tutorials and FAQs => Topic started by: d3pr3cat3d on February 14, 2021, 08:39:42 pm

Title: [Tutorial] Compile network driver
Post by: d3pr3cat3d on February 14, 2021, 08:39:42 pm
This tutorial is how to compile and install the latest Intel if_em.ko driver, this may work for other drivers that you want to compile?

The right way is to use a OPNsense version that is the same version that you are using in production.

Thanks to almodovaris for pointing this out.
Quote
https://forum.opnsense.org/index.php?action=post;quote=101093;topic=21484.0;last_msg=101093

I found an old topic from franco that explained how to do this in OPNsense.
Quote
https://forum.opnsense.org/index.php?topic=3689.msg12644#msg12644

Prior to finding franco's post I ran in to this error while trying to compile the driver.
Code: [Select]
root@OPNsense:/tmp/em-7.7.8/src # make
make: "/usr/share/mk/bsd.kmod.mk" line 16: Unable to locate the kernel source tree. Set SYSDIR to override.

This my process for OPNsense version 21.1. I was using Arch Linux and running OPNsense as a VM using KVM with libvirt. The driver was copied to /tmp on the OPNsense VM.

Code: [Select]
root@OPNsense:~ # pkg install git
Updating OPNsense repository catalogue...
Fetching meta.conf: 100%    163 B   0.2kB/s    00:01   
Fetching packagesite.txz: 100%  199 KiB 203.4kB/s    00:01   
Processing entries: 100%
OPNsense repository update completed. 728 packages processed.
All repositories are up to date.
Updating database digests format: 100%
The following 3 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
cvsps: 2.1_2
git: 2.30.0
p5-Error: 0.17029

Number of packages to be installed: 3

The process will require 22 MiB more space.
4 MiB to be downloaded.

Proceed with this action? [y/N]: y
[1/3] Fetching git-2.30.0.txz: 100%    4 MiB   1.1MB/s    00:04   
[2/3] Fetching p5-Error-0.17029.txz: 100%   27 KiB  27.4kB/s    00:01   
[3/3] Fetching cvsps-2.1_2.txz: 100%   41 KiB  41.9kB/s    00:01   
Checking integrity... done (0 conflicting)
[1/3] Installing p5-Error-0.17029...
[1/3] Extracting p5-Error-0.17029: 100%
[2/3] Installing cvsps-2.1_2...
[2/3] Extracting cvsps-2.1_2: 100%
[3/3] Installing git-2.30.0...
===> Creating groups.
Creating group 'git_daemon' with gid '964'.
===> Creating users
Creating user 'git_daemon' with uid '964'.
[3/3] Extracting git-2.30.0: 100%
=====
Message from git-2.30.0:

--
If you installed the GITWEB option please follow these instructions:

In the directory /usr/local/share/examples/git/gitweb you can find all files to
make gitweb work as a public repository on the web.

All you have to do to make gitweb work is:
1) Please be sure you're able to execute CGI scripts in
   /usr/local/share/examples/git/gitweb.
2) Set the GITWEB_CONFIG variable in your webserver's config to
   /usr/local/etc/git/gitweb.conf. This variable is passed to gitweb.cgi.
3) Restart server.


If you installed the CONTRIB option please note that the scripts are
installed in /usr/local/share/git-core/contrib. Some of them require
other ports to be installed (perl, python, etc), which you may need to
install manually.

root@OPNsense:~ # cd /usr

root@OPNsense:/usr # git clone https://github.com/opnsense/plugins
Cloning into 'plugins'...
remote: Enumerating objects: 96, done.
remote: Counting objects: 100% (96/96), done.
remote: Compressing objects: 100% (72/72), done.
remote: Total 45587 (delta 27), reused 67 (delta 16), pack-reused 45491
Receiving objects: 100% (45587/45587), 8.93 MiB | 8.63 MiB/s, done.
Resolving deltas: 100% (17821/17821), done.

root@OPNsense:/usr # git clone https://github.com/opnsense/ports
Cloning into 'ports'...
remote: Enumerating objects: 11654, done.
remote: Counting objects: 100% (11654/11654), done.
remote: Compressing objects: 100% (10196/10196), done.
remote: Total 1216799 (delta 2252), reused 7971 (delta 1393), pack-reused 1205145
Receiving objects: 100% (1216799/1216799), 406.62 MiB | 16.51 MiB/s, done.
Resolving deltas: 100% (559702/559702), done.
Updating files: 100% (137844/137844), done.

root@OPNsense:/usr # git clone https://github.com/opnsense/src
Cloning into 'src'...
remote: Enumerating objects: 296, done.
remote: Counting objects: 100% (296/296), done.
remote: Compressing objects: 100% (175/175), done.
remote: Total 218175 (delta 178), reused 164 (delta 115), pack-reused 217879
Receiving objects: 100% (218175/218175), 493.89 MiB | 17.60 MiB/s, done.
Resolving deltas: 100% (134226/134226), done.
Updating files: 100% (80527/80527), done.

root@OPNsense:/usr # cd src/

root@OPNsense:/usr/src # git checkout
COPYRIGHT             ObsoleteFiles.inc     contrib/              libexec/              sys/
LOCKS                 README                crypto/               release/              targets/
MAINTAINERS           README.md             etc/                  rescue/               tests/
Makefile              UPDATING              gnu/                  sbin/                 tools/
Makefile.inc1         UPDATING-HardenedBSD  include/              secure/               usr.bin/
Makefile.libcompat    bin/                  kerberos5/            share/                usr.sbin/
Makefile.sys.inc      cddl/                 lib/                  stand/               

root@OPNsense:/usr/src # git checkout stable/21.1
Branch 'stable/21.1' set up to track remote branch 'stable/21.1' from 'origin'.
Switched to a new branch 'stable/21.1'

root@OPNsense:/tmp # cd /tmp

root@OPNsense:/tmp # tar xzf em-7.7.8.tar.gz

root@OPNsense:/tmp # cd em-7.7.8/src

root@OPNsense:/tmp/em-7.7.8/src # make
machine -> /usr/src/sys/amd64/include
x86 -> /usr/src/sys/x86/include
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/device_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/bus_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/pci/pci_if.m -h
Warning: Object directory not changed from original /tmp/em-7.7.8/src
cc  -O2 -pipe -DHARDENEDBSD -DINET -DINET6 -DEM_STANDALONE_BUILD  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include   -MD  -MF.depend.if_em.o -MTif_em.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -c if_em.c -o if_em.o
cc  -O2 -pipe -DHARDENEDBSD -DINET -DINET6 -DEM_STANDALONE_BUILD  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include   -MD  -MF.depend.if_lem.o -MTif_lem.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -c if_lem.c -o if_lem.o
cc  -O2 -pipe -DHARDENEDBSD -DINET -DINET6 -DEM_STANDALONE_BUILD  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include   -MD  -MF.depend.e1000_osdep.o -MTe1000_osdep.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -c e1000_osdep.c -o e1000_osdep.o
cc  -O2 -pipe -DHARDENEDBSD -DINET -DINET6 -DEM_STANDALONE_BUILD  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include   -MD  -MF.depend.em_compat.o -MTem_compat.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -c em_compat.c -o em_compat.o
cc  -O2 -pipe -DHARDENEDBSD -DINET -DINET6 -DEM_STANDALONE_BUILD  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include   -MD  -MF.depend.e1000_api.o -MTe1000_api.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -c e1000_api.c -o e1000_api.o
cc  -O2 -pipe -DHARDENEDBSD -DINET -DINET6 -DEM_STANDALONE_BUILD  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include   -MD  -MF.depend.e1000_phy.o -MTe1000_phy.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -c e1000_phy.c -o e1000_phy.o
cc  -O2 -pipe -DHARDENEDBSD -DINET -DINET6 -DEM_STANDALONE_BUILD  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include   -MD  -MF.depend.e1000_nvm.o -MTe1000_nvm.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -c e1000_nvm.c -o e1000_nvm.o
cc  -O2 -pipe -DHARDENEDBSD -DINET -DINET6 -DEM_STANDALONE_BUILD  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include   -MD  -MF.depend.e1000_mac.o -MTe1000_mac.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -c e1000_mac.c -o e1000_mac.o
cc  -O2 -pipe -DHARDENEDBSD -DINET -DINET6 -DEM_STANDALONE_BUILD  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include   -MD  -MF.depend.e1000_manage.o -MTe1000_manage.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -c e1000_manage.c -o e1000_manage.o
cc  -O2 -pipe -DHARDENEDBSD -DINET -DINET6 -DEM_STANDALONE_BUILD  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include   -MD  -MF.depend.e1000_82540.o -MTe1000_82540.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -c e1000_82540.c -o e1000_82540.o
cc  -O2 -pipe -DHARDENEDBSD -DINET -DINET6 -DEM_STANDALONE_BUILD  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include   -MD  -MF.depend.e1000_82542.o -MTe1000_82542.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -c e1000_82542.c -o e1000_82542.o
cc  -O2 -pipe -DHARDENEDBSD -DINET -DINET6 -DEM_STANDALONE_BUILD  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include   -MD  -MF.depend.e1000_82541.o -MTe1000_82541.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -c e1000_82541.c -o e1000_82541.o
cc  -O2 -pipe -DHARDENEDBSD -DINET -DINET6 -DEM_STANDALONE_BUILD  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include   -MD  -MF.depend.e1000_82543.o -MTe1000_82543.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -c e1000_82543.c -o e1000_82543.o
cc  -O2 -pipe -DHARDENEDBSD -DINET -DINET6 -DEM_STANDALONE_BUILD  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include   -MD  -MF.depend.e1000_80003es2lan.o -MTe1000_80003es2lan.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -c e1000_80003es2lan.c -o e1000_80003es2lan.o
cc  -O2 -pipe -DHARDENEDBSD -DINET -DINET6 -DEM_STANDALONE_BUILD  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include   -MD  -MF.depend.e1000_ich8lan.o -MTe1000_ich8lan.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -c e1000_ich8lan.c -o e1000_ich8lan.o
cc  -O2 -pipe -DHARDENEDBSD -DINET -DINET6 -DEM_STANDALONE_BUILD  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include   -MD  -MF.depend.e1000_82571.o -MTe1000_82571.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -c e1000_82571.c -o e1000_82571.o
ld -m elf_x86_64_fbsd -d -warn-common --build-id=sha1 -r -d -o if_em.ko if_em.o if_lem.o e1000_osdep.o em_compat.o e1000_api.o e1000_phy.o e1000_nvm.o e1000_mac.o e1000_manage.o e1000_82540.o e1000_82542.o e1000_82541.o e1000_82543.o e1000_80003es2lan.o e1000_ich8lan.o e1000_82571.o
:> export_syms
awk -f /usr/src/sys/conf/kmod_syms.awk if_em.ko  export_syms | xargs -J% objcopy % if_em.ko
objcopy --strip-debug if_em.ko

There are two files that you want to copy to your production OPNsense system, /tmp/em-7.7.8/src/em.4 and /tmp/em-7.7.8/src/if_em.ko

I copied them to /root.

Copy the man page to the proper directory
Code: [Select]
# gzip -c em.4 > /usr/share/man/man4/em.4.gz
When I copied the if_em.ko driver to /root I changed the name to if_em.ko-OPNsense-21.1v7.7.8 we need to put this in the right place now.

Edit/Update 1
The user DimitriDC posted a link below witch lead to user Franco posting the correct location to put the driver, it should be placed in /boot/modules/
Code: [Select]
cp if_em.ko-OPNsense-21.1v7.7.8 /boot/modules/if_em_updated.ko
Edit /boot/load.conf.local to contain the line:
Code: [Select]
if_em_updated_load="YES
Reboot and test.
Code: [Select]
# kldstat | grep update
12    1 0xffffffff82956000    67bd8 if_em_updated.ko
Title: Re: [Tutorial] Compile network driver
Post by: DimitriDC on March 04, 2021, 07:34:07 am
Hello,

thanks for the nice tutorial, when I followed it I ended up in the message.

cannot register pci/em from kernel: already loaded from if_em.ko
pci/em failed to register: 17

Any chance that the onboard intel® ethernet connection i219-v could be used ?

The hardware involved is
https://www.intel.com/content/www/us/en/products/boards-kits/nuc/kits/nuc10i3fnk.html
Title: Re: [Tutorial] Compile network driver
Post by: DimitriDC on March 07, 2021, 10:36:07 am
This helped my out.

https://forum.opnsense.org/index.php?topic=20905.msg97447#msg97447
Title: Re: [Tutorial] Compile network driver
Post by: Gary7 on August 08, 2021, 07:36:31 pm
As an experiment on my home OPNsense firewall, I compiled the updated Intel network drivers for my APU2 system (I210 NIC)

Intel® Network Adapter Gigabit Base Driver for FreeBSD
   version 7.7.8   released 04/07/2020
Intel® Network Adapter Driver for 82575/6 and 82580-Based Gigabit Network Connections under FreeBSD
   Version 2.5.19   released 07/21/2021

I followed the instructions in this tutorial:
   pkg install git
   git clone plugins, ports, & src
   compiled both drivers

Everything went smoothly.
Copied if_igb.ko and if_em.ko to /boot/kernel (renamed the original files for backup)
Modified /boot/loader.conf.local: #if_em_load="YES" & if_igb_load="YES"
If loading the if_igb.ko driver failed, I could modify loader.conf.local to load if_em.ko and reboot again.

Rebooted and everything appeared to start normally. "if_igb.ko" was loaded without error.
Using kldstat, I verified that "if_igb.ko" was being used: 14    1 0xffffffff82968000    397a8 if_igb.ko

So far, networking on my firewall is working normally without error.
Now, some "hw.igb" tuning variables are available ( sysctl hw.igb ).
Performance appears to be normal. I still get my full ISP speed, 200+ Mbps.

I also see that the igb driver is smaller.
   if_igb.ko   223272 bytes
   if_em.ko   407664 bytes

Sharing my experience.
Title: Re: [Tutorial] Compile network driver
Post by: pguridi on May 24, 2023, 02:57:20 pm
Hi all, thanks for the tutorial. I'm trying to compile the em intel driver using the currrent version (OPNsense 23.1.7_3, based on FreeBSD 13.1-RELEASE-p7), and I'm getting the following compilation error.

Code: [Select]
[root@OPNsense /tmp/em-7.7.8/src]# make
machine -> /usr/src/sys/amd64/include
x86 -> /usr/src/sys/x86/include
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/device_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/bus_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/pci/pci_if.m -h
touch opt_global.h
Warning: Object directory not changed from original /tmp/em-7.7.8/src
cc  -O2 -pipe -DINET -DINET6 -DEM_STANDALONE_BUILD  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -include /tmp/em-7.7.8/src/opt_global.h -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include     -MD  -MF.depend.if_em.o -MTif_em.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error=tautological-compare -Wno-error=empty-body -Wno-error=parentheses-equality -Wno-error=unused-function -Wno-error=pointer-sign -Wno-error=shift-negative-value -Wno-address-of-packed-member -Wno-error=unused-but-set-variable -Wno-format-zero-length   -mno-aes -mno-avx  -std=iso9899:1999 -c if_em.c -o if_em.o
if_em.c:557:36: error: incompatible pointer types assigning to 'struct device *' from 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
        adapter->dev = adapter->osdep.dev = dev;
                                          ^ ~~~
if_em.c:1295:18: error: incompatible pointer types passing 'struct device *' to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
                        device_printf(adapter->dev, "Media change is"
                                      ^~~~~~~~~~~~
/usr/src/sys/sys/bus.h:608:28: note: passing argument to parameter 'dev' here
int     device_printf(device_t dev, const char *, ...) __printflike(2, 3);
                               ^
if_em.c:1390:11: error: incompatible pointer types initializing 'device_t' (aka 'struct _device *') with an expression of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
        device_t        dev = adapter->dev;
                        ^     ~~~~~~~~~~~~
if_em.c:1587:7: warning: variable 'ifp' set but not used [-Wunused-but-set-variable]
        if_t ifp;
             ^
if_em.c:1917:17: error: incompatible pointer types passing 'struct device *' to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
                device_printf(adapter->dev, "Unsupported media type\n");
                              ^~~~~~~~~~~~
/usr/src/sys/sys/bus.h:608:28: note: passing argument to parameter 'dev' here
int     device_printf(device_t dev, const char *, ...) __printflike(2, 3);
                               ^
if_em.c:2278:10: error: implicit declaration of function 'if_multiaddr_count' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                mcnt = if_multiaddr_count(ifp, MAX_NUM_MULTICAST_ADDRESSES);
                       ^
if_em.c:2317:2: error: implicit declaration of function 'if_multiaddr_array' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        if_multiaddr_array(ifp, mta, &mcnt, MAX_NUM_MULTICAST_ADDRESSES);
        ^
if_em.c:2395:16: error: incompatible pointer types passing 'struct device *' to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
        device_printf(adapter->dev, "Watchdog timeout Queue[%d]-- resetting\n",
                      ^~~~~~~~~~~~
/usr/src/sys/sys/bus.h:608:28: note: passing argument to parameter 'dev' here
int     device_printf(device_t dev, const char *, ...) __printflike(2, 3);
                               ^
if_em.c:2411:11: error: incompatible pointer types initializing 'device_t' (aka 'struct _device *') with an expression of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
        device_t dev = adapter->dev;
                 ^     ~~~~~~~~~~~~
if_em.c:2532:11: error: incompatible pointer types initializing 'device_t' (aka 'struct _device *') with an expression of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
        device_t dev = adapter->dev;
                 ^     ~~~~~~~~~~~~
if_em.c:2557:11: error: incompatible pointer types initializing 'device_t' (aka 'struct _device *') with an expression of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
        device_t        dev = adapter->dev;
                        ^     ~~~~~~~~~~~~
if_em.c:2586:11: error: incompatible pointer types initializing 'device_t' (aka 'struct _device *') with an expression of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
        device_t dev = adapter->dev;
                 ^     ~~~~~~~~~~~~
if_em.c:2612:26: error: incompatible pointer types passing 'struct device *' to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
            device_get_nameunit(adapter->dev));
                                ^~~~~~~~~~~~
/usr/src/sys/sys/bus.h:594:42: note: passing argument to parameter 'dev' here
const   char *device_get_nameunit(device_t dev);
                                           ^
if_em.c:2618:26: error: incompatible pointer types passing 'struct device *' to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
            device_get_nameunit(adapter->dev));
                                ^~~~~~~~~~~~
/usr/src/sys/sys/bus.h:594:42: note: passing argument to parameter 'dev' here
const   char *device_get_nameunit(device_t dev);
                                           ^
if_em.c:2643:11: error: incompatible pointer types initializing 'device_t' (aka 'struct _device *') with an expression of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
        device_t        dev = adapter->dev;
                        ^     ~~~~~~~~~~~~
if_em.c:2685:27: error: incompatible pointer types passing 'struct device *' to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
                    device_get_nameunit(adapter->dev), cpu_id);
                                        ^~~~~~~~~~~~
/usr/src/sys/sys/bus.h:594:42: note: passing argument to parameter 'dev' here
const   char *device_get_nameunit(device_t dev);
                                           ^
if_em.c:2728:27: error: incompatible pointer types passing 'struct device *' to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
                    device_get_nameunit(adapter->dev), cpu_id);
                                        ^~~~~~~~~~~~
/usr/src/sys/sys/bus.h:594:42: note: passing argument to parameter 'dev' here
const   char *device_get_nameunit(device_t dev);
                                           ^
if_em.c:2772:11: error: incompatible pointer types initializing 'device_t' (aka 'struct _device *') with an expression of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
        device_t        dev = adapter->dev;
                        ^     ~~~~~~~~~~~~
if_em.c:2852:11: error: incompatible pointer types initializing 'device_t' (aka 'struct _device *') with an expression of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
        device_t dev = adapter->dev;
                 ^     ~~~~~~~~~~~~
if_em.c:2874:32: error: incompatible pointer types passing 'struct device *' to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
                        device_printf(adapter->dev,
                                      ^~~~~~~~~~~~
/usr/src/sys/sys/bus.h:608:28: note: passing argument to parameter 'dev' here
int     device_printf(device_t dev, const char *, ...) __printflike(2, 3);
                               ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
*** Error code 1

Stop.
make: stopped in /tmp/em-7.7.8/src

have anyone tried compiling the driver in this version?
Title: Re: [Tutorial] Compile network driver
Post by: bmorgenthaler on July 28, 2023, 03:58:41 am
I'm getting the same error trying to compile it on my 23.1.11-amd64 system.

Hi all, thanks for the tutorial. I'm trying to compile the em intel driver using the currrent version (OPNsense 23.1.7_3, based on FreeBSD 13.1-RELEASE-p7), and I'm getting the following compilation error.

Code: [Select]
[root@OPNsense /tmp/em-7.7.8/src]# make
machine -> /usr/src/sys/amd64/include
x86 -> /usr/src/sys/x86/include
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/device_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/bus_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/pci/pci_if.m -h
touch opt_global.h
Warning: Object directory not changed from original /tmp/em-7.7.8/src
cc  -O2 -pipe -DINET -DINET6 -DEM_STANDALONE_BUILD  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -include /tmp/em-7.7.8/src/opt_global.h -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include     -MD  -MF.depend.if_em.o -MTif_em.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error=tautological-compare -Wno-error=empty-body -Wno-error=parentheses-equality -Wno-error=unused-function -Wno-error=pointer-sign -Wno-error=shift-negative-value -Wno-address-of-packed-member -Wno-error=unused-but-set-variable -Wno-format-zero-length   -mno-aes -mno-avx  -std=iso9899:1999 -c if_em.c -o if_em.o
if_em.c:557:36: error: incompatible pointer types assigning to 'struct device *' from 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
        adapter->dev = adapter->osdep.dev = dev;
                                          ^ ~~~
if_em.c:1295:18: error: incompatible pointer types passing 'struct device *' to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
                        device_printf(adapter->dev, "Media change is"
                                      ^~~~~~~~~~~~
/usr/src/sys/sys/bus.h:608:28: note: passing argument to parameter 'dev' here
int     device_printf(device_t dev, const char *, ...) __printflike(2, 3);
                               ^
if_em.c:1390:11: error: incompatible pointer types initializing 'device_t' (aka 'struct _device *') with an expression of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
        device_t        dev = adapter->dev;
                        ^     ~~~~~~~~~~~~
if_em.c:1587:7: warning: variable 'ifp' set but not used [-Wunused-but-set-variable]
        if_t ifp;
             ^
if_em.c:1917:17: error: incompatible pointer types passing 'struct device *' to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
                device_printf(adapter->dev, "Unsupported media type\n");
                              ^~~~~~~~~~~~
/usr/src/sys/sys/bus.h:608:28: note: passing argument to parameter 'dev' here
int     device_printf(device_t dev, const char *, ...) __printflike(2, 3);
                               ^
if_em.c:2278:10: error: implicit declaration of function 'if_multiaddr_count' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                mcnt = if_multiaddr_count(ifp, MAX_NUM_MULTICAST_ADDRESSES);
                       ^
if_em.c:2317:2: error: implicit declaration of function 'if_multiaddr_array' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        if_multiaddr_array(ifp, mta, &mcnt, MAX_NUM_MULTICAST_ADDRESSES);
        ^
if_em.c:2395:16: error: incompatible pointer types passing 'struct device *' to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
        device_printf(adapter->dev, "Watchdog timeout Queue[%d]-- resetting\n",
                      ^~~~~~~~~~~~
/usr/src/sys/sys/bus.h:608:28: note: passing argument to parameter 'dev' here
int     device_printf(device_t dev, const char *, ...) __printflike(2, 3);
                               ^
if_em.c:2411:11: error: incompatible pointer types initializing 'device_t' (aka 'struct _device *') with an expression of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
        device_t dev = adapter->dev;
                 ^     ~~~~~~~~~~~~
if_em.c:2532:11: error: incompatible pointer types initializing 'device_t' (aka 'struct _device *') with an expression of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
        device_t dev = adapter->dev;
                 ^     ~~~~~~~~~~~~
if_em.c:2557:11: error: incompatible pointer types initializing 'device_t' (aka 'struct _device *') with an expression of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
        device_t        dev = adapter->dev;
                        ^     ~~~~~~~~~~~~
if_em.c:2586:11: error: incompatible pointer types initializing 'device_t' (aka 'struct _device *') with an expression of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
        device_t dev = adapter->dev;
                 ^     ~~~~~~~~~~~~
if_em.c:2612:26: error: incompatible pointer types passing 'struct device *' to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
            device_get_nameunit(adapter->dev));
                                ^~~~~~~~~~~~
/usr/src/sys/sys/bus.h:594:42: note: passing argument to parameter 'dev' here
const   char *device_get_nameunit(device_t dev);
                                           ^
if_em.c:2618:26: error: incompatible pointer types passing 'struct device *' to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
            device_get_nameunit(adapter->dev));
                                ^~~~~~~~~~~~
/usr/src/sys/sys/bus.h:594:42: note: passing argument to parameter 'dev' here
const   char *device_get_nameunit(device_t dev);
                                           ^
if_em.c:2643:11: error: incompatible pointer types initializing 'device_t' (aka 'struct _device *') with an expression of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
        device_t        dev = adapter->dev;
                        ^     ~~~~~~~~~~~~
if_em.c:2685:27: error: incompatible pointer types passing 'struct device *' to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
                    device_get_nameunit(adapter->dev), cpu_id);
                                        ^~~~~~~~~~~~
/usr/src/sys/sys/bus.h:594:42: note: passing argument to parameter 'dev' here
const   char *device_get_nameunit(device_t dev);
                                           ^
if_em.c:2728:27: error: incompatible pointer types passing 'struct device *' to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
                    device_get_nameunit(adapter->dev), cpu_id);
                                        ^~~~~~~~~~~~
/usr/src/sys/sys/bus.h:594:42: note: passing argument to parameter 'dev' here
const   char *device_get_nameunit(device_t dev);
                                           ^
if_em.c:2772:11: error: incompatible pointer types initializing 'device_t' (aka 'struct _device *') with an expression of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
        device_t        dev = adapter->dev;
                        ^     ~~~~~~~~~~~~
if_em.c:2852:11: error: incompatible pointer types initializing 'device_t' (aka 'struct _device *') with an expression of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
        device_t dev = adapter->dev;
                 ^     ~~~~~~~~~~~~
if_em.c:2874:32: error: incompatible pointer types passing 'struct device *' to parameter of type 'device_t' (aka 'struct _device *') [-Werror,-Wincompatible-pointer-types]
                        device_printf(adapter->dev,
                                      ^~~~~~~~~~~~
/usr/src/sys/sys/bus.h:608:28: note: passing argument to parameter 'dev' here
int     device_printf(device_t dev, const char *, ...) __printflike(2, 3);
                               ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
*** Error code 1

Stop.
make: stopped in /tmp/em-7.7.8/src

have anyone tried compiling the driver in this version?
Title: Re: [Tutorial] Compile network driver
Post by: lilsense on July 28, 2023, 11:49:44 am

Thanks to almodovaris for pointing this out.
Quote
https://forum.opnsense.org/index.php?action=post;quote=101093;topic=21484.0;last_msg=101093


The above link is incorrect, bad link.

Franco/Ad,
   Would the PROPER process of compiling drivers be added to the docs url with an example, PRETTY PLEASE. :)