RPMSG - problem with modified kernel module

I need to make some modifications to the imx_rpmsg_tty kernel module. Firstly, I compiled the imx_rpmsg_tty.c module without any changes, according to these instructions. I copied the compiled module to the SoM and when I run insmod imx_rpmsg_tty.ko, I get the following dmesg output:

[   63.396706] imx_rpmsg_tty: no symbol version for module_layout
[   63.397662] imx_rpmsg_tty virtio0.rpmsg-virtual-tty-channel-1.-1.30: new channel: 0x400 -> 0x1e!
[   63.398405] Install rpmsg tty driver!

The node /dev/ttyRPMSG30 appears in the file system, but when I try to run the following command:
echo "hello" > /dev/ttyRPMSG30, I get kernel panic starting with the following errors:

[  263.782119] Unable to handle kernel read from unreadable memory at virtual address ffff80000939b498
[  263.791208] Mem abort info:
[  263.794007]   ESR = 0x8600000f
[  263.797064]   EC = 0x21: IABT (current EL), IL = 32 bits
[  263.802521]   SET = 0, FnV = 0
[  263.805603]   EA = 0, S1PTW = 0
[  263.808760] swapper pgtable: 4k pages, 48-bit VAs, pgdp=00000000417c1000
[  263.815498] [ffff80000939b498] pgd=00000000bffff003, pud=00000000bfffe003, pmd=00000000b7950003, pte=3
[  263.826338] Internal error: Oops: 8600000f [#1] PREEMPT SMP
[  263.831920] Modules linked in: imx_rpmsg_tty xt_nat xt_tcpudp xt_conntrack xt_MASQUERADE nf_conntrack)
[  263.873424] CPU: 1 PID: 1242 Comm: sh Tainted: G           O      5.4.77-5.1.0+git.afc2df4893e6 #1-Toe
[  263.883428] Hardware name: Toradex Verdin iMX8M Mini WB on Verdin Development Board (DT)
[  263.891523] pstate: 00000005 (nzcv daif -PAN -UAO)
[  263.896325] pc : rpmsgtty_port_ops+0x18/0xffffffffffffeb80 [imx_rpmsg_tty]

I assume that there is something wrong with deploying the compiled kernel module to the SoM, since I didn’t change anything in the module’s source or in the Cortex-M4 application.

To make module you need identical kernel sources to those which were used to build your kernel and identical kernel config. [ 63.396706] imx_rpmsg_tty: no symbol version for module_layout just confirms that config or sources don’t match. As well something like that may happen when you insmod instead of modprobe and some functions are in module, which is not yet loaded. If not sure do depmod -a after replacing module, and then modprobe yourmodule

The kernel sources are identical, I checked out my kernel sources to the commit afc2df4893e6, which matches the output of uname -r. How do I check if the kernel config settings match?

I am not able to run modprobe because I get the error:
imx_rpmsg_tty.ko not found in directory /lib/modules/5.4.77-5.1.0+git.afc2df4893e6

I extracted the .config file, copied it to my kernel sources, and ran make oldconfig. Then I recompiled the kernel module and now everything works. Thank you!

Unless config.gz is disabled in kernel, you may extract config to file entering in you target console: zcat /proc/config.gz > .config. Then you should put .config to your kernel sources.

Perfect that the issue is solved. Thanks for your feedback.