This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM4378: Install Custom LKM

Part Number: AM4378

Tool/software: Linux

I have a simple LKM that as of right now just has init and exit functions that each only have a single printk statement inside them. I am able to build this LKM against the kernel using a Makefile, but when I try to insmod it on the AM437x EVM board, a ton of errors are output:

[ 85.560199] Unable to handle kernel paging request at virtual address 7e6f426c
[ 85.567700] pgd = edb20000
[ 85.570439] [7e6f426c] *pgd=00000000
[ 85.579318] Internal error: Oops: 5 [#1] PREEMPT ARM
[ 85.584322] Modules linked in: UTI_ring_detect_driver(O+) sha512_generic sha512_arm sha256_generi)
[ 85.652180] CPU: 0 PID: 979 Comm: insmod Tainted: G O 4.9.69-g9ce43c71ae #1
[ 85.660319] Hardware name: Generic AM43 (Flattened Device Tree)
[ 85.666282] task: edb50b00 task.stack: edbac000
[ 85.670863] PC is at load_module+0x1c0c/0x2180
[ 85.675343] LR is at load_module+0x1bf8/0x2180
[ 85.679825] pc : [<c01978c4>] lr : [<c01978b0>] psr: 30070013
[ 85.679825] sp : edbade60 ip : edbade60 fp : edbadf1c
[ 85.691371] r10: 00000007 r9 : 00000000 r8 : edb42ca8
[ 85.696630] r7 : 7e6f4258 r6 : bf37a0c0 r5 : bf37a0cc r4 : edbadf44
[ 85.703196] r3 : bf37a260 r2 : 00000000 r1 : 00000000 r0 : c0c16440
[ 85.709768] Flags: nzCV IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
[ 85.716949] Control: 10c53c7d Table: adb20059 DAC: 00000051
[ 85.722733] Process insmod (pid: 979, stack limit = 0xedbac208)
[ 85.728689] Stack: (0xedbade60 to 0xedbae000)
[ 85.733091] de60: bf37a0cc 00007fff bf37a0c0 c0194e74 bf000000 c099ce6c c099ce44 c099ce9c
[ 85.741330] de80: c099ce38 c08045bc bf37a0cc f23477b4 bf37a260 edbadf44 bf37a108 bf37a1d4
[ 85.749567] dea0: edbadeec edbadeb0 c021d190 c021cadc f2347000 00000000 00000000 00000000
[ 85.757801] dec0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 85.766036] dee0: 00000000 00000000 00000000 00000000 7fffffff 00000000 00000003 00027dc4
[ 85.774272] df00: 0000017b c0107e84 edbac000 00000000 edbadfa4 edbadf20 c0198058 c0195cc4
[ 85.782507] df20: 7fffffff 00000000 00000003 edbadf38 c01dc790 f2347000 00000b80 00000000
[ 85.790742] df40: 00000000 f2347000 00000b80 f23474e4 f2347421 f2347a74 00000280 00000310
[ 85.798977] df60: 00000000 00000000 00000000 0000035c 00000012 00000013 0000000a 00000008
[ 85.807211] df80: 00000006 00000000 00000000 0003a008 00000000 00025a74 00000000 edbadfa8
[ 85.815446] dfa0: c0107cc0 c0197fb4 0003a008 00000000 00000003 00027dc4 00000000 00000000
[ 85.823680] dfc0: 0003a008 00000000 00025a74 0000017b 00000000 00000002 b6f21000 00000000
[ 85.831917] dfe0: beb1fb08 beb1faf8 0001f57c b6e6b9f2 80070030 00000003 80030064 6d800906
[ 85.840134] Backtrace:
[ 85.842632] [<c0195cb8>] (load_module) from [<c0198058>] (SyS_finit_module+0xb0/0xc0)
[ 85.850525] r10:00000000 r9:edbac000 r8:c0107e84 r7:0000017b r6:00027dc4 r5:00000003
[ 85.858398] r4:00000000
[ 85.860982] [<c0197fa8>] (SyS_finit_module) from [<c0107cc0>] (ret_fast_syscall+0x0/0x48)
[ 85.869212] r6:00025a74 r5:00000000 r4:0003a008
[ 85.873874] Code: e51b308c e1530007 e2477008 0a000009 (e5973014)
[ 85.897747] ---[ end trace b2596d9f564123af ]---

Broadcast message from systemd-journald@am437x-evm (Wed 2018-10-24 19:39:20 UTC):

kernel[378]: [ 85.579318] Internal error: Oops: 5 [#1] PREEMPT ARM


Broadcast message from systemd-journald@am437x-evm (Wed 2018-10-24 19:39:20 UTC):

kernel[378]: [ 85.722733] Process insmod (pid: 979, stack limit = 0xedbac208)


Broadcast message from systemd-journald@am437x-evm (Wed 2018-10-24 19:39:20 UTC):

kernel[378]: [ 85.728689] Stack: (0xedbade60 to 0xedbae000)


Broadcast message from systemd-journald@am437x-evm (Wed 2018-10-24 19:39:20 UTC):

kernel[378]: [ 85.733091] de60: bf37a0cc 00007fff bf37a0c0 c0194e74 bf000000 c099ce6c c099ce44 c09c


Broadcast message from systemd-journald@am437x-evm (Wed 2018-10-24 19:39:20 UTC):

kernel[378]: [ 85.741330] de80: c099ce38 c08045bc bf37a0cc f23477b4 bf37a260 edbadf44 bf37a108 bf34


Broadcast message from systemd-journald@am437x-evm (Wed 2018-10-24 19:39:20 UTC):

kernel[378]: [ 85.749567] dea0: edbadeec edbadeb0 c021d190 c021cadc f2347000 00000000 00000000 0000

Segmentation fault

Broadcast message from systemd-journald@am437x-evm (Wed 2018-10-24 19:39:20 UTC):

kernel[378]: [ 85.757801] dec0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000


Broadcast message from systemd-journald@am437x-evm (Wed 2018-10-24 19:39:20 UTC):

kernel[378]: [ 85.766036] dee0: 00000000 00000000 00000000 00000000 7fffffff 00000000 00000003 0004


Broadcast message from systemd-journald@am437x-evm (Wed 2018-10-24 19:39:20 UTC):

kernel[378]: [ 85.774272] df00: 0000017b c0107e84 edbac000 00000000 edbadfa4 edbadf20 c0198058 c014


Broadcast message from systemd-journald@am437x-evm (Wed 2018-10-24 19:39:20 UTC):

kernel[378]: [ 85.782507] df20: 7fffffff 00000000 00000003 edbadf38 c01dc790 f2347000 00000b80 0000


Broadcast message from systemd-journald@am437x-evm (Wed 2018-10-24 19:39:20 UTC):

kernel[378]: [ 85.790742] df40: 00000000 f2347000 00000b80 f23474e4 f2347421 f2347a74 00000280 0000


Broadcast message from systemd-journald@am437x-evm (Wed 2018-10-24 19:39:20 UTC):

kernel[378]: [ 85.798977] df60: 00000000 00000000 00000000 0000035c 00000012 00000013 0000000a 0008


Broadcast message from systemd-journald@am437x-evm (Wed 2018-10-24 19:39:20 UTC):

kernel[378]: [ 85.807211] df80: 00000006 00000000 00000000 0003a008 00000000 00025a74 00000000 edb8


Broadcast message from systemd-journald@am437x-evm (Wed 2018-10-24 19:39:20 UTC):

kernel[378]: [ 85.815446] dfa0: c0107cc0 c0197fb4 0003a008 00000000 00000003 00027dc4 00000000 0000


Broadcast message from systemd-journald@am437x-evm (Wed 2018-10-24 19:39:20 UTC):

kernel[378]: [ 85.823680] dfc0: 0003a008 00000000 00025a74 0000017b 00000000 00000002 b6f21000 0000


Broadcast message from systemd-journald@am437x-evm (Wed 2018-10-24 19:39:20 UTC):

kernel[378]: [ 85.831917] dfe0: beb1fb08 beb1faf8 0001f57c b6e6b9f2 80070030 00000003 80030064 6d86


Broadcast message from systemd-journald@am437x-evm (Wed 2018-10-24 19:39:20 UTC):

kernel[378]: [ 85.873874] Code: e51b308c e1530007 e2477008 0a000009 (e5973014)

Any idea why is this happening?

  • Hi Tanner,

    What is the kernel version running on your AM4378 board?
    Please provide the log showing how exactly you built the kernel module, the module source code, and the Makefile to build the module.
  • The kernel version is 4.9.69.

    The following is the module source code:

    #include <linux/init.h>
    #include <linux/module.h>


    MODULE_LICENSE("GPL");

    static int __init ring_detect_init_function(void)
    {
    printk( KERN_DEBUG "ring detect init function" );

    return 0;
    }
    module_init(ring_detect_init_function);

    static void __exit ring_detect_exit_function(void)
    {
    printk( KERN_DEBUG "ring detect exit function ran successfully\n" );
    }
    module_exit(ring_detect_exit_function);


    And here is the Makefile I used:

    obj-m += UTI_ring_detect_driver.o

    KDIR := /home/ULTRATEC/thunsucker/TI-SDK/board-support/linux-4.9.69+gitAUTOINC+9ce43c71ae-g9ce43c71ae
    PWD := $(shell pwd)
    CROSS=arm-arago-linux-gnueabi-

    ring_detect:
    make -C $(KDIR) M=$(PWD) ARCH=arm CROSS_COMPILE=$(CROSS) modules

    clean:
    make -C $(KDIR) M=$(PWD) clean


    All I did to build the kernel module was run the Makefile.
  • First glance on the source code doesn't pop up anything obvious. I will test it on my setup.
    Please
    - provide $PATH value to show how your toolchain is set;
    - the make log for me to compare
  • I believe this is what $PATH is set to:

    /home/ULTRATEC/thunsucker/TI-SDK/linux-devkit/sysroots/x86_64-arago-linux/usr/bin:/home/ULTRATEC/thunsucker/Barr_Group_Training/Linux_Stuff/toolchain/bin:/home/ULTRATEC/thunsucker/bin:/home/ULTRATEC/thunsucker/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:

    And this is the output when I run make, is that what you mean by the make log?

    make -C /home/ULTRATEC/thunsucker/TI-SDK/board-support/linux-4.9.69+gitAUTOINC+9ce43c71ae-g9ce43c71ae M=/home/ULTRATEC/thunsucker/Documents/ring_detect ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi- modules
    make[1]: Entering directory '/home/ULTRATEC/thunsucker/TI-SDK/board-support/linux-4.9.69+gitAUTOINC+9ce43c71ae-g9ce43c71ae'
    CC [M] /home/ULTRATEC/thunsucker/Documents/ring_detect/UTI_ring_detect_driver.o
    Building modules, stage 2.
    MODPOST 1 modules
    CC /home/ULTRATEC/thunsucker/Documents/ring_detect/UTI_ring_detect_driver.mod.o
    LD [M] /home/ULTRATEC/thunsucker/Documents/ring_detect/UTI_ring_detect_driver.ko
    make[1]: Leaving directory '/home/ULTRATEC/thunsucker/TI-SDK/board-support/linux-4.9.69+gitAUTOINC+9ce43c71ae-g9ce43c71ae'
  • Hi,

    Tanner Hunsucker73 said:
    CROSS=arm-arago-linux-gnueabi-

    The toolchain you used is not correct. Please use the arm-linux-gnueabihf- toolchain provided in the Processor SDK Linux package.

  • That worked, thank you!!