28757B2 / cc1101-driver

Linux device driver for the Texas Instruments CC1101 radio
GNU General Public License v2.0
31 stars 12 forks source link

bad exit status: 2 #4

Closed ShadowJonathan closed 1 year ago

ShadowJonathan commented 2 years ago

DKMS error:

root@raspberrypi:/usr/src/cc1101-1.3.2# sudo dkms build -m cc1101 -v 1.3.2

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...
KDIR=/lib/modules/5.15.32-v8+/build MDIR=/lib/modules/5.15.32-v8+ make......(bad exit status: 2)
Error! Bad return status for module build on kernel: 5.15.32-v8+ (aarch64)
Consult /var/lib/dkms/cc1101/1.3.2/build/make.log for more information.
The Log ``` DKMS make.log for cc1101-1.3.2 for kernel 5.15.32-v8+ (aarch64) Wed 13 Jul 22:11:38 CEST 2022 make -C /lib/modules/5.15.32-v8+/build M=/var/lib/dkms/cc1101/1.3.2/build modules make[1]: Entering directory '/usr/src/linux-headers-5.15.32-v8+' CC [M] /var/lib/dkms/cc1101/1.3.2/build/cc1101_main.o CC [M] /var/lib/dkms/cc1101/1.3.2/build/cc1101_chrdev.o In file included from ./include/linux/device.h:15, from ./include/linux/cdev.h:8, from /var/lib/dkms/cc1101/1.3.2/build/cc1101_chrdev.c:5: /var/lib/dkms/cc1101/1.3.2/build/cc1101_chrdev.c: In function ‘chrdev_ioctl’: /var/lib/dkms/cc1101/1.3.2/build/cc1101_chrdev.c:253:34: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=] 253 | CC1101_ERROR(cc1101, "Unknown Command %d, %d, %d\n", cmd, sizeof(cc1101_rx_config_t), sizeof(cc1101_tx_config_t)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./include/linux/dev_printk.h:110:16: note: in definition of macro ‘dev_printk_index_wrap’ 110 | _p_func(dev, fmt, ##__VA_ARGS__); \ | ^~~ ./include/linux/dev_printk.h:144:49: note: in expansion of macro ‘dev_fmt’ 144 | dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__) | ^~~~~~~ /var/lib/dkms/cc1101/1.3.2/build/cc1101_internal.h:124:46: note: in expansion of macro ‘dev_err’ 124 | #define CC1101_ERROR(cc1101, format, ...) dev_err(&cc1101->spi->dev, format "\n", ##__VA_ARGS__) | ^~~~~~~ /var/lib/dkms/cc1101/1.3.2/build/cc1101_chrdev.c:253:13: note: in expansion of macro ‘CC1101_ERROR’ 253 | CC1101_ERROR(cc1101, "Unknown Command %d, %d, %d\n", cmd, sizeof(cc1101_rx_config_t), sizeof(cc1101_tx_config_t)); | ^~~~~~~~~~~~ /var/lib/dkms/cc1101/1.3.2/build/cc1101_chrdev.c:253:56: note: format string is defined here 253 | CC1101_ERROR(cc1101, "Unknown Command %d, %d, %d\n", cmd, sizeof(cc1101_rx_config_t), sizeof(cc1101_tx_config_t)); | ~^ | | | int | %ld In file included from ./include/linux/device.h:15, from ./include/linux/cdev.h:8, from /var/lib/dkms/cc1101/1.3.2/build/cc1101_chrdev.c:5: /var/lib/dkms/cc1101/1.3.2/build/cc1101_chrdev.c:253:34: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘long unsigned int’ [-Wformat=] 253 | CC1101_ERROR(cc1101, "Unknown Command %d, %d, %d\n", cmd, sizeof(cc1101_rx_config_t), sizeof(cc1101_tx_config_t)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./include/linux/dev_printk.h:110:16: note: in definition of macro ‘dev_printk_index_wrap’ 110 | _p_func(dev, fmt, ##__VA_ARGS__); \ | ^~~ ./include/linux/dev_printk.h:144:49: note: in expansion of macro ‘dev_fmt’ 144 | dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__) | ^~~~~~~ /var/lib/dkms/cc1101/1.3.2/build/cc1101_internal.h:124:46: note: in expansion of macro ‘dev_err’ 124 | #define CC1101_ERROR(cc1101, format, ...) dev_err(&cc1101->spi->dev, format "\n", ##__VA_ARGS__) | ^~~~~~~ /var/lib/dkms/cc1101/1.3.2/build/cc1101_chrdev.c:253:13: note: in expansion of macro ‘CC1101_ERROR’ 253 | CC1101_ERROR(cc1101, "Unknown Command %d, %d, %d\n", cmd, sizeof(cc1101_rx_config_t), sizeof(cc1101_tx_config_t)); | ^~~~~~~~~~~~ /var/lib/dkms/cc1101/1.3.2/build/cc1101_chrdev.c:253:60: note: format string is defined here 253 | CC1101_ERROR(cc1101, "Unknown Command %d, %d, %d\n", cmd, sizeof(cc1101_rx_config_t), sizeof(cc1101_tx_config_t)); | ~^ | | | int | %ld In file included from /var/lib/dkms/cc1101/1.3.2/build/cc1101_internal.h:9, from /var/lib/dkms/cc1101/1.3.2/build/cc1101_chrdev.c:8: /var/lib/dkms/cc1101/1.3.2/build/cc1101_chrdev.c: In function ‘chrdev_read’: ./include/linux/kfifo.h:696:27: error: initialization of ‘unsigned int *’ from incompatible pointer type ‘size_t *’ {aka ‘long unsigned int *’} [-Werror=incompatible-pointer-types] 696 | unsigned int *__copied = (copied); \ | ^ /var/lib/dkms/cc1101/1.3.2/build/cc1101_chrdev.c:289:9: note: in expansion of macro ‘kfifo_to_user’ 289 | if (kfifo_to_user(&cc1101->rx_fifo, buf, len, &out_bytes) != 0) { | ^~~~~~~~~~~~~ cc1: some warnings being treated as errors make[2]: *** [scripts/Makefile.build:277: /var/lib/dkms/cc1101/1.3.2/build/cc1101_chrdev.o] Error 1 make[1]: *** [Makefile:1868: /var/lib/dkms/cc1101/1.3.2/build] Error 2 make[1]: Leaving directory '/usr/src/linux-headers-5.15.32-v8+' make: *** [Makefile:5: all] Error 2 ```

This is on the latest raspberry pi OS

28757B2 commented 2 years ago

Thanks for the issue report. It looks like I'm using the wrong sized type for kfifo_to_user, which is causing the error on the 64-bit version of Raspberry Pi OS. The latest commit in the 64-bit branch fixes the compiler errors, but I'm having some further issues configuring the radio.

The issue may be in the userspace client rather than the driver. I'll need to do some more investigation.

ShadowJonathan commented 1 year ago

Thanks, that seems to fix the build issue.

However, i'm also having problems in userspace, when trying to receive a packet, i get the following in journald;

Log ``` Jul 25 11:59:30 raspberrypi kernel: cc1101 spi0.0: Unknown Command 1076126467, 40, 32 Jul 25 11:59:31 raspberrypi kernel: cc1101 spi0.0: Unknown Command -2145099002, 40, 32 Jul 25 11:59:31 raspberrypi kernel: cc1101 spi0.0: Unknown Command 1076126467, 40, 32 Jul 25 11:59:31 raspberrypi kernel: cc1101 spi0.0: Unknown Command -2145099002, 40, 32 Jul 25 11:59:31 raspberrypi kernel: cc1101 spi0.0: Unknown Command 1076126467, 40, 32 Jul 25 11:59:31 raspberrypi kernel: cc1101 spi0.0: Unknown Command -2145099002, 40, 32 Jul 25 11:59:31 raspberrypi kernel: cc1101 spi0.0: Unknown Command 1076126467, 40, 32 Jul 25 11:59:31 raspberrypi kernel: cc1101 spi0.0: Unknown Command -2145099002, 40, 32 Jul 25 11:59:31 raspberrypi kernel: cc1101 spi0.0: Unknown Command 1076126467, 40, 32 Jul 25 11:59:31 raspberrypi kernel: cc1101 spi0.0: Unknown Command -2145099002, 40, 32 Jul 25 11:59:31 raspberrypi kernel: cc1101 spi0.0: Unknown Command 1076126467, 40, 32 Jul 25 11:59:31 raspberrypi kernel: cc1101 spi0.0: Unknown Command -2145099002, 40, 32 Jul 25 11:59:31 raspberrypi kernel: cc1101 spi0.0: Unknown Command 1076126467, 40, 32 Jul 25 11:59:31 raspberrypi kernel: cc1101 spi0.0: Unknown Command -2145099002, 40, 32 Jul 25 11:59:31 raspberrypi kernel: cc1101 spi0.0: Unknown Command 1076126467, 40, 32 Jul 25 11:59:31 raspberrypi kernel: cc1101 spi0.0: Unknown Command -2145099002, 40, 32 Jul 25 11:59:31 raspberrypi kernel: cc1101 spi0.0: Unknown Command 1076126467, 40, 32 Jul 25 11:59:31 raspberrypi kernel: cc1101 spi0.0: Unknown Command -2145099002, 40, 32 Jul 25 11:59:31 raspberrypi kernel: cc1101 spi0.0: Unknown Command 1076126467, 40, 32 Jul 25 11:59:32 raspberrypi kernel: cc1101 spi0.0: Unknown Command -2145099002, 40, 32 Jul 25 11:59:32 raspberrypi kernel: cc1101 spi0.0: Unknown Command 1076126467, 40, 32 Jul 25 11:59:32 raspberrypi kernel: cc1101 spi0.0: Unknown Command -2145099002, 40, 32 Jul 25 11:59:32 raspberrypi kernel: cc1101 spi0.0: Unknown Command 1076126467, 40, 32 Jul 25 11:59:32 raspberrypi kernel: cc1101 spi0.0: Unknown Command -2145099002, 40, 32 Jul 25 11:59:32 raspberrypi kernel: cc1101 spi0.0: Unknown Command 1076126467, 40, 32 Jul 25 11:59:32 raspberrypi kernel: cc1101 spi0.0: Unknown Command -2145099002, 40, 32 Jul 25 11:59:32 raspberrypi kernel: cc1101 spi0.0: Unknown Command 1076126467, 40, 32 ```

Edit: Fiddling more, it seems the basic IOCTL works, but the RX and TX config get (and set, I presume, haven't tested) functions do not work properly with the python driver.

ShadowJonathan commented 1 year ago

I figured it out, on amd64, it adds 4 extra padding bytes to the end of the struct, adding xxxx to each STRUCT_FORMAT fixed it for the python driver.

28757B2 commented 1 year ago

Thanks for tracking down the padding issue, that was really helpful.

I couldn't find a format string that would make the struct module produce a struct with the correct alignment on both 32 and 64-bit, so I've ended up replacing it with ctypes.

The compile error and warnings are now fixed in the master branch and version 1.2.1 of the Python module on PyPi fixes the incorrect struct alignments.