N2820 Led control not available after my update to 13.2-RELEASE-p11

Hello Everyone!

I'm experiencing an issue with loading the nuvoton-gpio.ko module after upgrading from FreeBSD 12.0 to 13.2-RELEASE The module was functioning correctly under the previous version, but since the upgrade, it fails to load.

When I attempt to load the module using kldload ./nuvoton-gpio.ko, I receive the following errors:

The command I did to load

kldload ./nuvoton-gpio.ko
kldload: an error occurred while loading module ./nuvoton-gpio.ko. Please check dmesg(8) for more details.

Dmesg

dmesg | tail
ipfw2 (+ipv6) initialized, divert loadable, nat loadable, default to deny, logging disabled
KLD nuvoton-gpio.ko: depends on kernel - not available or version mismatch
linker_load_file: /replisys/source/driver/AX000/gpio/nuvoton-gpio.ko - unsupported file type
Security policy loaded: MAC/ntpd (mac_ntpd)
KLD nuvoton-gpio.ko: depends on kernel - not available or version mismatch
linker_load_file: /replisys/source/driver/AX000/gpio/nuvoton-gpio.ko - unsupported file type
KLD nuvoton-gpio.ko: depends on kernel - not available or version mismatch
linker_load_file: ./nuvoton-gpio.ko - unsupported file type
KLD nuvoton-gpio.ko: depends on kernel - not available or version mismatch
linker_load_file: ./nuvoton-gpio.ko - unsupported file type


I search the new driver can support 13.2 but I didn't find it
recompiling the module would may a solution, but I'm not sure if I have the correct source files or if recompilation would address the issue.

File that I have:
nuvoton-gpio.ko

file nuvoton-gpio.ko
nuvoton-gpio.ko: ELF 64-bit LSB relocatable, x86-64, version 1 (FreeBSD), BuildID[sha1]=684019a4d4922319557ef877efce44c8719ba704, not stripped

nuvoton-gpio-ctrl

file nuvoton-gpio-ctrl
nuvoton-gpio-ctrl: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 12.0 (1200086), FreeBSD-style, with debug_info, not stripped


If anyone have an idea :/
I already contact the maker but no response at this point
 
A kernel module needs to be compiled for the kernel version you are using.
A major upgrade (example: 12 -> 13, or 13 -> 14) gets you a new kernel version.
So yes - you will need to recompile that module.
 
A kernel module needs to be compiled for the kernel version you are using.
A major upgrade (example: 12 -> 13, or 13 -> 14) gets you a new kernel version.
So yes - you will need to recompile that module.
I try to that but I have some errors,
one of them:
/usr/include/sys/module.h:262:30: error: 'MAXPATHLEN' undeclared here (not in a function)

I paste the stack error here:
In file included from nuvoton-gpio.c:22:
/usr/include/sys/module.h:262:30: error: 'MAXPATHLEN' undeclared here (not in a function)
262 | char name[MAXMODNAME];
| ^~~~~~~~~~
nuvoton-gpio.c:73:92: warning: 'struct thread' declared inside parameter list will not be visible outside of this definition or declaration
73 | static int nuvoton_gpio_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
| ^~~~~~
nuvoton-gpio.c: In function 'nuvoton_gpio_ioctl':
nuvoton-gpio.c:104:17: warning: implicit declaration of function 'uprintf' [-Wimplicit-function-declaration]
104 | uprintf("[NUVOTON-GPIO]: Unknown IOCTL command\n");
| ^~~~~~~
nuvoton-gpio.c: At top level:
nuvoton-gpio.c:191:15: error: variable 'nuvoton_gpio_cdevsw' has initializer but incomplete type
191 | static struct cdevsw nuvoton_gpio_cdevsw = {
| ^~~~~~
nuvoton-gpio.c:192:10: error: 'struct cdevsw' has no member named 'd_version'
192 | .d_version = D_VERSION,
| ^~~~~~~~~
nuvoton-gpio.c:192:25: error: 'D_VERSION' undeclared here (not in a function); did you mean 'MDT_VERSION'?
192 | .d_version = D_VERSION,
| ^~~~~~~~~
| MDT_VERSION
nuvoton-gpio.c:192:25: warning: excess elements in struct initializer
nuvoton-gpio.c:192:25: note: (near initialization for 'nuvoton_gpio_cdevsw')
nuvoton-gpio.c:193:10: error: 'struct cdevsw' has no member named 'd_name'
193 | .d_name = DEVNAME,
| ^~~~~~
In file included from nuvoton-gpio.c:31:
nuvoton-gpio-ioctl.h:24:17: warning: excess elements in struct initializer
24 | #define DEVNAME "nuvoton_gpio"
| ^~~~~~~~~~~~~~
nuvoton-gpio.c:193:25: note: in expansion of macro 'DEVNAME'
193 | .d_name = DEVNAME,
| ^~~~~~~
nuvoton-gpio-ioctl.h:24:17: note: (near initialization for 'nuvoton_gpio_cdevsw')
24 | #define DEVNAME "nuvoton_gpio"
| ^~~~~~~~~~~~~~
nuvoton-gpio.c:193:25: note: in expansion of macro 'DEVNAME'
193 | .d_name = DEVNAME,
| ^~~~~~~
nuvoton-gpio.c:194:10: error: 'struct cdevsw' has no member named 'd_ioctl'
194 | .d_ioctl = nuvoton_gpio_ioctl
| ^~~~~~~
nuvoton-gpio.c:194:25: warning: excess elements in struct initializer
194 | .d_ioctl = nuvoton_gpio_ioctl
| ^~~~~~~~~~~~~~~~~~
nuvoton-gpio.c:194:25: note: (near initialization for 'nuvoton_gpio_cdevsw')
nuvoton-gpio.c: In function 'nuvoton_gpio_init':
nuvoton-gpio.c:209:23: warning: implicit declaration of function 'make_dev'; did you mean 'makedev'? [-Wimplicit-function-declaration]
209 | g_priv.cdev = make_dev(&nuvoton_gpio_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, DEVNAME);
| ^~~~~~~~
| makedev
nuvoton-gpio.c:209:21: warning: assignment to 'struct cdev *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
209 | g_priv.cdev = make_dev(&nuvoton_gpio_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, DEVNAME);
| ^
nuvoton-gpio.c: In function 'nuvoton_gpio_loader':
nuvoton-gpio.c:227:25: warning: implicit declaration of function 'destroy_dev' [-Wimplicit-function-declaration]
227 | destroy_dev(g_priv.cdev);
| ^~~~~~~~~~~
nuvoton-gpio.c: At top level:
nuvoton-gpio.c:237:46: error: expected ')' before '(' token
237 | DEV_MODULE(nuvoton_gpio, nuvoton_gpio_loader, NULL);
| ^
| )
nuvoton-gpio.c:191:22: error: storage size of 'nuvoton_gpio_cdevsw' isn't known
191 | static struct cdevsw nuvoton_gpio_cdevsw = {
 
Step 1 (assuming you can't or don't want to share the source) - can you compile the code on the OLD version of FreeBSD i.e. the 12.X you were using before?

Make sure it actually compiles and produces the same binaries.

Then you know it will definitely compile and run and (hopefully) just needs some tweaks for the newer version of FreeBSD.
 
Step 1 (assuming you can't or don't want to share the source) - can you compile the code on the OLD version of FreeBSD i.e. the 12.X you were using before?

Make sure it actually compiles and produces the same binaries.

Then you know it will definitely compile and run and (hopefully) just needs some tweaks for the newer version of FreeBSD.
I try to compile that on a 12.x machine

for the file I check that ;)
 
It's from a 13.x machine

when I do "make"

errors stack
Code:
Warning: Object directory not changed from original /media/try-to-compile/src/driver
cc  -O2 -pipe  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -include /media/try-to-compile/src/driver/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.nuvoton-gpio.o -MTnuvoton-gpio.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 nuvoton-gpio.c -o nuvoton-gpio.o
In file included from nuvoton-gpio.c:22:
/usr/src/sys/sys/module.h:262:13: error: use of undeclared identifier 'MAXPATHLEN'
        char            name[MAXMODNAME];
                             ^
/usr/src/sys/sys/module.h:258:20: note: expanded from macro 'MAXMODNAME'
#define MAXMODNAME      MAXMODNAMEV3
                        ^
/usr/src/sys/sys/module.h:257:22: note: expanded from macro 'MAXMODNAMEV3'
#define MAXMODNAMEV3    MAXPATHLEN
                        ^
In file included from nuvoton-gpio.c:23:
In file included from /usr/src/sys/sys/systm.h:101:
/usr/src/sys/sys/param.h:291:1: error: unknown type name 'define'
define MAXPATHLEN       PATH_MAX
^
/usr/src/sys/sys/param.h:291:18: error: expected ';' after top level declarator
define MAXPATHLEN       PATH_MAX
                 ^
                 ;
3 errors generated.
*** Error code 1

I get new file from the maker, this is free software so I could share it ;)
 

Attachments

  • caswell_fdrv_gpio-nuvoton-V1.1.1.zip
    16.6 KB · Views: 9
Another errors appairs
seems I need to made an update for repair that

So, maybe its preferable to do that from the 13.x machine


Code:
/src/driver # make
make: "/usr/share/mk/bsd.kmod.mk" line 16: Unable to locate the kernel source tree. Set SYSDIR to override.
 
Source code is missing in /usr/src. You need access to the source to be able to build a kernel module. The source code has to match the version you're building for.
 
git clone -b releng/13.2 https://git.freebsd.org/src.git /usr/src

Assuming you're on 13.2-RELEASE.

releng/13.2 -> 13.2-RELEASE
releng/13.3 -> 13.3-RELEASE
 
I have two machine
one
Code:
/media/src/driver # freebsd-version
12.0-RELEASE
Code:
/media # freebsd-version
13.2-RELEASE-p11

what we try to do is just to build the C file I get, to update the driver for the 13.2 version

at this point, 13.2 machine have this errors:
Code:
use of undeclared identifier 'MAXPATHLEN'

maybe it's good to just forgot that 12.0 machine 🙃
 
To get it to build on 13.3 I moved param.h above module.h in 3 C files.

e.g. nuvoton-gpio.c was

Code:
 21 #include <sys/types.h>
 22 #include <sys/module.h>
 23 #include <sys/systm.h>  /* uprintf */
 24 #include <sys/errno.h>
 25 #include <sys/param.h>  /* defines used in kernel.h */
 26 #include <sys/kernel.h> /* types used in module initialization */
 27 #include <sys/conf.h>
 28 #include <sys/ioccom.h>
The initial error message was from module.h saying MAXPATHLEN undefined, and from looking at the files that is defined in param.h, so what if we move param.h up in the file so it gets included first?
Code:
 21 #include <sys/types.h>
 22 #include <sys/param.h>  /* defines used in kernel.h */
 23 #include <sys/module.h>
 24 #include <sys/systm.h>  /* uprintf */
 25 #include <sys/errno.h>
 26 #include <sys/kernel.h> /* types used in module initialization */
 27 #include <sys/conf.h>
 28 #include <sys/ioccom.h>
That made one file compile, but then the same error for the other two C files, nct6796d.c and nct6779d.c so I did the same thing - moved param.h before module.h.
Code:
% 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
touch opt_global.h
Warning: Object directory not changed from original /usr/home/user/buildit/src/driver
cc  -O2 -pipe  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -include /usr/home/user/buildit/src/driver/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.nuvoton-gpio.o -MTnuvoton-gpio.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -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=array-parameter -Wno-error=deprecated-non-prototype -Wno-error=strict-prototypes -Wno-error=unused-but-set-variable -Wno-error=unused-but-set-variable -Wno-format-zero-length   -mno-aes -mno-avx  -std=iso9899:1999 -c nuvoton-gpio.c -o nuvoton-gpio.o
cc  -O2 -pipe  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -include /usr/home/user/buildit/src/driver/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.nct6779d.o -MTnct6779d.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -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=array-parameter -Wno-error=deprecated-non-prototype -Wno-error=strict-prototypes -Wno-error=unused-but-set-variable -Wno-error=unused-but-set-variable -Wno-format-zero-length   -mno-aes -mno-avx  -std=iso9899:1999 -c nct6779d.c -o nct6779d.o
cc  -O2 -pipe  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -include /usr/home/user/buildit/src/driver/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.nct6796d.o -MTnct6796d.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -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=array-parameter -Wno-error=deprecated-non-prototype -Wno-error=strict-prototypes -Wno-error=unused-but-set-variable -Wno-error=unused-but-set-variable -Wno-format-zero-length   -mno-aes -mno-avx  -std=iso9899:1999 -c nct6796d.c -o nct6796d.o
nct6796d.c:75:23: warning: overlapping comparisons always evaluate to true [-Wtautological-overlap-compare]
   75 |         } else if (port >= 6 || port <= 8) {
      |                    ~~~~~~~~~~^~~~~~~~~~~~
1 warning generated.
ld -m elf_x86_64_fbsd -warn-common --build-id=sha1 -T /usr/src/sys/conf/ldscript.kmod.amd64 -r  -o nuvoton-gpio.ko nuvoton-gpio.o nct6779d.o nct6796d.o
:> export_syms
awk -f /usr/src/sys/conf/kmod_syms.awk nuvoton-gpio.ko  export_syms | xargs -J% objcopy % nuvoton-gpio.ko
objcopy --strip-debug nuvoton-gpio.ko
I've no idea if this is a good idea, if the module will work, you are on your own, etc. but it seems to compile with those changes.
 
I do the same thing for the three files and the MAXPATHLEN errors was clear, thank you

two errors remain, who seems come from the system :confused:
Code:
/usr/src/sys/sys/param.h:291:1: error: unknown type name 'define'
define MAXPATHLEN       PATH_MAX
^
/usr/src/sys/sys/param.h:291:18: error: expected ';' after top level declarator
define MAXPATHLEN       PATH_MAX
 
Back
Top