• Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    unipi-kernel-modules-dkms does not generate modules on upgrade

    Scheduled Pinned Locked Moved Official API - Evok
    16 Posts 5 Posters 4.9k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Martin KudláčekM
      Martin Kudláček @Achilleas Kotsis
      last edited by

      Hello @achilleas-kotsis,
      I cannot reproduce it. I took current 2.2.0.20 image and ran apt install unipi-kernel-modules-dkms. The replacement for unipi-kernel-modules worked out of the box. Can you share a bit more about your setup?

      Thanks,
      Martin

      A 1 Reply Last reply
      Reply Quote 0
      • A
        Achilleas Kotsis @Martin Kudláček
        last edited by

        Hi @martin-kudláček,

        Initial installation of unipi-kernel-modules-dkms or replacing unipi-kernel-modules works. Upgrading unipi-kernel-modules-dkms to a newer version doesn't work.

        Using raspbian and packages from https://repo.unipi.technology/debian. Happens on both stretch and buster.

        1 Reply Last reply
        Reply Quote 0
        • M
          martin_triska
          last edited by

          Hello @Achilleas-Kotsis,

          the issue is caused by kernel-headers version mismatch because one of the kernel versions has been "stashed" by the author. Therefore, the apt versioning got a little confused by this.

          Please make sure you have the latest all the related packages - kernel, headers, unipi-kernel-modules-dkms:

          root@UNIPI1-sn1:/home/pi#dpkg -l *kernel*
          ...
          ii  raspberrypi-kernel         1.20190925+1-1      armhf        Raspberry Pi bootloader
          ii  raspberrypi-kernel-headers 1.20190925+1-1      armhf        Header files for the Raspberry Pi Linux kernel
          ii  unipi-kernel-modules-dkms  1.36                all          UniPi Neuron/Axon kernel modules - DKMS source
          ...
          

          If you upgraded kernel, reboot the system. Check the appropriate version of your headers:

          root@UNIPI1-sn1:/home/pi# uname -r
          4.19.75-v7+
          root@UNIPI1-sn1:/home/pi# ls /usr/src/
          linux-headers-4.19.75+  linux-headers-4.19.75-v7+  linux-headers-4.19.75-v7l+  unipi-1.36
          

          Then, remove the package:

          apt purge unipi-kernel-modules-dkms
          

          And install it again

          apt install unipi-kernel-modules-dkms
          

          Have you been successful with the procedure?

          1 Reply Last reply
          Reply Quote 0
          • A
            Achilleas Kotsis
            last edited by

            Upon further investigation, I have located the issue.
            dkms checks for installed kernels using the presence of files in /boot directory, including config-* files
            As you can see on a normal x64 debian:

            akots@xps:~$ ls -l /boot/config-*
            -rw-r--r-- 1 root root 235827 Nov 12 10:46 /boot/config-5.3.0-23-generic
            -rw-r--r-- 1 root root 235885 Nov 14 00:41 /boot/config-5.3.0-24-generic
            

            On raspbian, package unipi-common installs two scripts

            root@basementplc:# dpkg -S /etc/initramfs-tools/scripts/init-bottom/setbootconfig.sh
            unipi-common: /etc/initramfs-tools/scripts/init-bottom/setbootconfig.sh
            root@basementplc:~# dpkg -S /etc/kernel/postinst.d/initrd-config
            unipi-common: /etc/kernel/postinst.d/initrd-config
            

            These two scripts create two files in /boot matching the config-* expression

            root@basementplc:/etc# ls -l /boot/config-*
            -rwxr-xr-x 1 root root 212 Nov 10 11:01 /boot/config-initrd.inc
            -rwxr-xr-x 1 root root 108 Sep 29 05:38 /boot/config-unipi.inc
            

            These are the culpit. Renaming these to config_initrd.inc and config_unipi.inc, and changing the relevant includes in /boot/config.txt fixes the issue.

            So, you need to patch unipi-common in order to create files that don't match files that dkms mistakes for kernel configs.
            Attached patches for both files.

            --- initrd-config.orig	2019-12-18 16:18:34.483277993 +0200
            +++ initrd-config	2019-12-18 16:19:31.032380354 +0200
            @@ -1,10 +1,15 @@
             #!/bin/bash
             
             CONFIGTXT=/boot/config.txt
            -CONFIGINC=config-initrd.inc
            +CONFIGINC=config_initrd.inc
             PATHINC="/boot/${CONFIGINC}"
             
            -# check or insert include directive  into config.txt  
            +# Remove old file using '-' instead of '_'
            +rm -f "/boot/config-initrd.inc"
            +# Change include using '-' instead of '_'
            +sed -i "s/include config-initrd\.inc/include config_initrd.inc/" "${CONFIGTXT}"
            +
            +# check or insert include directive into config.txt  
             INCLUDE="include ${CONFIGINC}"
             grep -q -e "^[[:blank:]]*${INCLUDE}" "${CONFIGTXT}" || sed "1 i${INCLUDE}" -i "${CONFIGTXT}"
            
            --- setbootconfig.sh.orig	2019-09-20 12:43:10.000000000 +0300
            +++ setbootconfig.sh	2019-12-18 16:34:06.618599153 +0200
            @@ -54,10 +54,15 @@
             	echo "dtoverlay=i2c-rtc,mcp7941x"
             	echo "dtoverlay=unipiee"
             	[ "$IS_UNIPI1" = "1" ] || echo "dtoverlay=neuron-spi-new"
            -) >"${MNTDIR}/config-unipi.inc"
            +) >"${MNTDIR}/config_unipi.inc"
            +
            +# Remove old file using '-' instead of '_'
            +rm -f "${MNTDIR}/config-unipi.inc"
            +# Change include using '-' instead of '_'
            +sed -i "s/include config-unipi\.inc/include config_unipi.inc/" "${MNTDIR}/config.txt"
             
             # check or insert include into config.txt
            -INCLUDE="include config-unipi.inc"
            +INCLUDE="include config_unipi.inc"
             grep -q -e "^[[:blank:]]*${INCLUDE}" "${MNTDIR}/config.txt" || sed "1 i${INCLUDE}" -i "${MNTDIR}/config.txt"
             
             if [ "${DO_MOUNT}" = "1" ]; then
            
            Martin KudláčekM 1 Reply Last reply
            Reply Quote 0
            • Martin KudláčekM
              Martin Kudláček @Achilleas Kotsis
              last edited by

              Hi @achilleas-kotsis, thank you for such a detailed explanation. We have merged your patch into unipi-common 1.2.17.test.20191219101434 available in our testing repository. If you have recent image, all you have to do is: apt install unipi-common=1.2.17.test.20191219101434. After some testing we will merge it into master branch.

              As a small reward, you have a discount of 50EUR for your next purchase. We have set it for your account, but please remind it in the order of the description as well.

              Thank you and have a nice day,
              Martin

              A 1 Reply Last reply
              Reply Quote 0
              • A
                Achilleas Kotsis @Martin Kudláček
                last edited by

                Hi @martin-kudláček,
                thanks for the reward.

                Can't find the testing repository url, can you please send it?

                Thanks,
                Achilleas

                Martin KudláčekM 1 Reply Last reply
                Reply Quote 0
                • Martin KudláčekM
                  Martin Kudláček @Achilleas Kotsis
                  last edited by Martin Kudláček

                  Hi @achilleas-kotsis,
                  the change has been merged to the 1.2.18.

                  The testing repository has the same url, just make sure to add component test:

                  deb https://repo.unipi.technology/debian buster main test

                  To prefer packages from main, add file /etc/apt/preferences.d/10-unipi-prefer-main with this content:

                  Package: *
                  Pin: release o=unipi,c=main
                  Pin-Priority: 900
                  

                  All of that is preconfigured in our images.

                  1 Reply Last reply
                  Reply Quote 0
                  • A
                    Achilleas Kotsis
                    last edited by

                    One more patch against the latest version that renames the old file during package configuration, because if it gets upgraded on a live system, the previously inserted code is not executed (script exits early if devices are found)

                    --- setbootconfig.sh.orig	2019-12-19 21:39:51.490185707 +0200
                    +++ setbootconfig.sh	2019-12-19 22:04:27.094799784 +0200
                    @@ -9,6 +9,10 @@
                     if [ "$1" = "--noreboot" -o -n "${DESTDIR}" ]; then
                         ## called from package install
                         MNTDIR=/boot
                    +    # Move old file using '-' instead of '_'
                    +    [ -f "${MNTDIR}/config-unipi.inc" ] && mv -f "${MNTDIR}/config-unipi.inc" "${MNTDIR}/config_unipi.inc"
                    +    # Change include using '-' instead of '_'
                    +    sed -i "s/include config-unipi\.inc/include config_unipi.inc/" "${MNTDIR}/config.txt"
                         # check if running from "real" Neuron system
                         grep -q '^/dev/mmcblk[[:digit:]]p1 /boot ' /proc/mounts && IS_REAL_SYSTEM=1
                     else
                    

                    This cleaned up my system perfectly doing a dpkg-reconfigure unipi-common so I suppose it should be working on the package being upgraded also. I can test one of my systems if you generate a testing package to see if it applies cleanly.

                    Martin KudláčekM 1 Reply Last reply
                    Reply Quote 0
                    • Martin KudláčekM
                      Martin Kudláček @Achilleas Kotsis
                      last edited by

                      Hi @achilleas-kotsis,
                      thank you for the testing. Your patch is included in the testing version 1.2.19.test.20191220083937 available in the testing repository.

                      Best regards,
                      Martin

                      A 1 Reply Last reply
                      Reply Quote 0
                      • A
                        Achilleas Kotsis @Martin Kudláček
                        last edited by

                        @martin-kudláček said in unipi-kernel-modules-dkms does not generate modules on upgrade:

                        1.2.19.test.20191220083937

                        I can confirm the package works as intended on my systems.

                        Thanks,
                        Achilleas

                        1 Reply Last reply
                        Reply Quote 0
                        • A
                          Achilleas Kotsis
                          last edited by

                          Hi @Martin-Kudláček,

                          found another issue on latest rpi kernel.

                          Building initial module for 4.19.93+
                          Error!  Build of unipi.ko failed for: 4.19.93+ (armv7l)
                          Consult the make.log in the build directory
                          /var/lib/dkms/unipi/1.36/build/ for more information.
                          root@vkplc-home:~# cat /var/lib/dkms/unipi/1.36/build/make.log 
                          DKMS make.log for unipi-1.36 for kernel 4.19.93+ (armv7l)
                          Wed 22 Jan 2020 12:33:22 PM EET
                          make: Entering directory '/usr/src/linux-headers-4.19.93+'
                            CC [M]  /var/lib/dkms/unipi/1.36/build/unipi/src/unipi_spi.o
                            CC [M]  /var/lib/dkms/unipi/1.36/build/unipi/src/unipi_iio.o
                            CC [M]  /var/lib/dkms/unipi/1.36/build/unipi/src/unipi_gpio.o
                            CC [M]  /var/lib/dkms/unipi/1.36/build/unipi/src/unipi_uart.o
                          /var/lib/dkms/unipi/1.36/build/unipi/src/unipi_uart.c: In function ‘neuronspi_uart_handle_rx’:
                          /var/lib/dkms/unipi/1.36/build/unipi/src/unipi_uart.c:320:31: error: passing argument 1 of ‘uart_handle_sysrq_char’ from incompatible pointer type [-Werror=incompatible-pointer-types]
                              if (uart_handle_sysrq_char(port, ch))
                                                         ^~~~
                          In file included from /var/lib/dkms/unipi/1.36/build/unipi/src/unipi_common.h:36,
                                           from /var/lib/dkms/unipi/1.36/build/unipi/src/unipi_uart.h:22,
                                           from /var/lib/dkms/unipi/1.36/build/unipi/src/unipi_uart.c:19:
                          ./include/linux/serial_core.h:514:42: note: expected ‘struct uart_port *’ but argument is of type ‘struct neuronspi_port *’
                           uart_handle_sysrq_char(struct uart_port *port, unsigned int ch) { return 0; }
                                                  ~~~~~~~~~~~~~~~~~~^~~~
                            CC [M]  /var/lib/dkms/unipi/1.36/build/unipi/src/unipi_sysfs.o
                          cc1: some warnings being treated as errors
                          make[1]: *** [scripts/Makefile.build:303: /var/lib/dkms/unipi/1.36/build/unipi/src/unipi_uart.o] Error 1
                          make[1]: *** Waiting for unfinished jobs....
                          make: *** [Makefile:1522: _module_/var/lib/dkms/unipi/1.36/build/unipi] Error 2
                          make: Leaving directory '/usr/src/linux-headers-4.19.93+'
                          make: Entering directory '/usr/src/linux-headers-4.19.93+'
                            CC [M]  /var/lib/dkms/unipi/1.36/build/rtc-unipi/rtc-unipi.o
                          /var/lib/dkms/unipi/1.36/build/rtc-unipi/rtc-unipi.c: In function ‘rtc_unipi_probe’:
                          /var/lib/dkms/unipi/1.36/build/rtc-unipi/rtc-unipi.c:666:6: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
                                struct nvmem_config nvmem_cfg = {
                                ^~~~~~
                            Building modules, stage 2.
                            MODPOST 1 modules
                            CC      /var/lib/dkms/unipi/1.36/build/rtc-unipi/rtc-unipi.mod.o
                            LD [M]  /var/lib/dkms/unipi/1.36/build/rtc-unipi/rtc-unipi.ko
                          make: Leaving directory '/usr/src/linux-headers-4.19.93+'```
                          

                          Line 320 in unipi_uart.c

                          if (uart_handle_sysrq_char(port, ch))
                          

                          passes "port" as an arqument to uart_handle_sysrq_char, which is of type "struct neuronspi_port", but uart_handle_sysrq_char expects a type of "struct uart_port", which is part of struct neuronspi_port as seen on unipi_common.h.

                          Changing line 320 as below seems to fix the issue.

                          if (uart_handle_sysrq_char(&port->port, ch))
                          
                          Martin KudláčekM P 2 Replies Last reply
                          Reply Quote 0
                          • Martin KudláčekM
                            Martin Kudláček @Achilleas Kotsis
                            last edited by

                            Hi @achilleas-kotsis,
                            thanks again for the fix:) We have merged it into a testing repository alongside with fix of the Makefile, which masked this error to the Gitlab CI and allowed building it in the first place. We will test it and soon merge into the master branch.

                            1 Reply Last reply
                            Reply Quote 0
                            • P
                              pmandeli @Achilleas Kotsis
                              last edited by

                              Hi @achilleas-kotsis , @Martin-Kudláček ,

                              has it been fixed in the master branch? I am facing to the same problem.

                              Thank you

                              Martin KudláčekM 1 Reply Last reply
                              Reply Quote 0
                              • Martin KudláčekM
                                Martin Kudláček @pmandeli
                                last edited by

                                Hi @pmandeli,
                                not yet, but the change is available for testing here: https://repo.unipi.technology/debian/pool/test/u/unipi-kernel-modules/unipi-kernel-modules-dkms_1.37.test.20200122161658_all.deb

                                1 Reply Last reply
                                Reply Quote 0
                                • wbm smartW
                                  wbm smart
                                  last edited by

                                  Thank you

                                  1 Reply Last reply
                                  Reply Quote 0

                                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                  With your input, this post could be even better 💗

                                  Register Login
                                  • First post
                                    Last post