| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| kernel_modules [2026-06-08 06:50 UTC (6 months ago)] – [Problems] fredchan | kernel_modules [2026-11-23 00:54 UTC (5 days ago)] (current) – clarity on dirty suffixes, and more accurate reference to INIT's configs applied qkb |
|---|
| ====== Kernel Modules ====== | ====== Kernel Modules ====== |
| ===== List factory default kernel modules ===== | |
| You can list the factory default kernel modules with the command: | The unit runs ''%%4.9.166-fsl-imx-INIT-004%%'', built from [[https://github.com/nxp-imx/linux-imx|NXP's linux-imx tree]] at tag ''%%v4.9.166%%'', with INIT's config and version suffix. The running config is ''%%/proc/config.gz%%''. The stock build used OSELAS.Toolchain-2018.12.0 (gcc 8.2.1), per ''%%/proc/version%%''. |
| | |
| | The kernel is uniprocessor. ''%%CONFIG_SMP%%'' is not set, so only CPU0 comes up even though the i.MX6DL has two cores. It is a config choice, not a hardware limit, and it changes what ''%%/proc/cpuinfo%%'' and the scheduler look like: |
| | |
| | <code> |
| | zcat /proc/config.gz | grep CONFIG_SMP |
| | # CONFIG_SMP is not set |
| | cat /proc/cpuinfo |
| | </code> |
| | |
| | ===== Stock modules ===== |
| | |
| | List what shipped with the image: |
| <code> | <code> |
| find /lib/modules/$(uname -r) -type f -name '*.ko' | find /lib/modules/$(uname -r) -type f -name '*.ko' |
| </code> | </code> |
| | |
| | The image ships 36. By family: |
| | |
| | ^ family ^ modules ^ |
| | | USB serial | ''%%ftdi_sio%%'', ''%%usbserial%%'' | |
| | | video, backlight | ''%%coda%%'', ''%%v4l2-mem2mem%%'', ''%%videobuf2-vmalloc%%'', ''%%lcd%%'' | |
| | | crypto | ''%%cmac%%'', ''%%xor%%'', ''%%crc8%%'', ''%%sha1-arm-neon%%'', ''%%sha256-arm%%'', ''%%xor-neon%%'' | |
| | | filesystems | ''%%btrfs%%'', ''%%cifs%%'', ''%%fat%%'', ''%%vfat%%'', ''%%ntfs%%'', ''%%squashfs%%'', ''%%fscache%%'' | |
| | | NFS | ''%%nfs%%'', ''%%nfsv3%%'', ''%%nfsv4%%'', ''%%lockd%%'', ''%%grace%%'', ''%%sunrpc%%'', ''%%auth_rpcgss%%'' | |
| | | netfilter | ''%%ip_tables%%'', ''%%x_tables%%'', ''%%xt_tcpudp%%'', ''%%nf_reject_ipv4%%'' | |
| | | WiFi | ''%%mac80211%%'', ''%%wlcore%%'', ''%%wlcore_sdio%%'', ''%%wl18xx%%'' | |
| | | lib | ''%%raid6_pq%%'', ''%%oid_registry%%'' | |
| | |
| | ''%%ftdi_sio%%'' is the barcode bridge on ''%%ttyUSB0%%''. The CAAM crypto engine is built in, not a module, and registers its algorithms in ''%%/proc/crypto%%''. It has nothing to do with the cVEND HSM. |
| |
| ===== Building ===== | ===== Building ===== |
| Tip: You can use [[https://github.com/dockcross/dockcross|Dockcross]] to cross-compile from a Docker container to the PM3. Use the ''dockcross/linux-armv7-lts'' container. | |
| |
| - Download the i.MX Linux kernel source code from the [[https://github.com/nxp-imx/linux-imx/tree/v4.9.166|nxp-imx/linux-imx Github repo]], selecting the git tag that matches your kernel version (e.g. ''4.9.166'' for a ''uname -r'' of ''4.9.166-fsl-imx-INIT-004''). | Dockcross works for this. Use the ''%%dockcross/linux-armv7-lts%%'' container. |
| - Obtain the Linux kernel config from the PM3, located at ''/proc/config.gz''. Unzip this file to ''.config'' in the root of the kernel source. | |
| - In ''.config'', change the line ''CONFIG_LOCALVERSION_AUTO=y'' to ''CONFIG_LOCALVERSION_AUTO=n''. | - Fetch the matching source: [[https://github.com/nxp-imx/linux-imx/tree/v4.9.166|nxp-imx/linux-imx at v4.9.166]]. The tag is the base version from ''%%uname -r%%'', so ''%%4.9.166%%'' for ''%%4.9.166-fsl-imx-INIT-004%%''. |
| - If you're trying to build kernel modules that are already in the Linux source code, set the appropriate config options to ''m''. For example, setting ''CONFIG_SLIP=m'' enabled SLIP support to be compiled to ''drivers/net/slip/.ko''. | - Copy ''%%/proc/config.gz%%'' off the unit and gunzip it to ''%%.config%%'' in the source root. |
| - In ''Makefile'', change the line ''EXTRAVERSION ='' to ''EXTRAVERSION = -fsl-imx-INIT-004'', or whatever comes after the PM3's ''uname -r'' for you. | - Set ''%%CONFIG_LOCALVERSION_AUTO=n%%''. |
| - In ''/scripts/dtc/dtc-lexer.lex.c'' and ''/scripts/dtc/dtc-lexer.lex.c_shipped'', change ''YYLTYPE yylloc;'' to ''extern YYLTYPE yylloc;'' | - Set what you need to ''%%m%%''. ''%%CONFIG_SLIP=m%%'' builds ''%%drivers/net/slip/slip.ko%%'', and the same pattern applies elsewhere. |
| - Run ''git add .'' and ''git commit''. | - Set ''%%EXTRAVERSION = -fsl-imx-INIT-004%%'' in the top-level ''%%Makefile%%''. Take the suffix from ''%%uname -r%%'' if yours differs. |
| - Run ''make LOCALVERSION= -C . modules'' | - In ''%%scripts/dtc/dtc-lexer.lex.c%%'' and ''%%scripts/dtc/dtc-lexer.lex.c_shipped%%'', change ''%%YYLTYPE yylloc;%%'' to ''%%extern YYLTYPE yylloc;%%''. |
| - ''scp'' your new kernel module to the PM3 and load it with ''insmod your_module.ko''. If it fails, check ''dmesg'' to see what's wrong. | - Commit the tree if you leave ''%%CONFIG_LOCALVERSION_AUTO%%'' on; uncommitted files add ''%%-dirty%%''. |
| | - Build with ''%%make LOCALVERSION= -C . modules%%''. Inside Dockcross you may need ''%%sudo make%%''. |
| | - ''%%scp%%'' the module over and ''%%insmod%%'' it. If it refuses, check ''%%dmesg%%''. |
| | |
| | ===== Problems ===== |
| | |
| | A module built against the wrong config or tree fails to load with: |
| |
| ==== Problems ==== | |
| If you fail to load a kernel module and dmesg shows something like the following: | |
| <code> | <code> |
| version magic '4.9.166-fsl-imx-INIT-004+ preempt ARMv7 p2v8 ' should be '4.9.166-fsl-imx-INIT-004 preempt ARMv7 p2v8 ' | version magic '4.9.166-fsl-imx-INIT-004+ preempt ARMv7 p2v8 ' should be '4.9.166-fsl-imx-INIT-004 preempt ARMv7 p2v8 ' |
| </code> | </code> |
| | |
| <code> | <code> |
| version magic '4.9.166-fsl-imx-INIT-004-dirty preempt ARMv7 p2v8 ' should be '4.9.166-fsl-imx-INIT-004 preempt ARMv7 p2v8 ' | version magic '4.9.166-fsl-imx-INIT-004-dirty preempt ARMv7 p2v8 ' should be '4.9.166-fsl-imx-INIT-004 preempt ARMv7 p2v8 ' |
| </code> | </code> |
| Then double check: | |
| * That ''CONFIG_LOCALVERSION_AUTO=n'' is set in ''.config''. | The suffixes only show up when ''%%CONFIG_LOCALVERSION_AUTO%%'' is on. ''%%+%%'' means it picked up a git version, ''%%-dirty%%'' that the tree had uncommitted changes. Check: |
| * That your ''make'' command has the option ''LOCALVERSION= ''. | |
| * That you have no uncommitted changes according to git. | * ''%%CONFIG_LOCALVERSION_AUTO=n%%'' in ''%%.config%%''. |
| | * ''%%LOCALVERSION=%%'' on the make line. |
| | * A clean ''%%git status%%'', if you left ''%%CONFIG_LOCALVERSION_AUTO%%'' on. |