Dafang-Hacks / Main

138 stars 63 forks source link

Compiling ip_tables.ko module #35

Closed sundarnagarajan closed 4 years ago

sundarnagarajan commented 4 years ago

I want to compile ip_tables.ko module for use on the Wyze Cam PAN. I followed the instructions to:

When I transfer the compiled module .ko file to the camera and try to insmod., I get the following error:

insmod: can't insert 'ip_tables.ko': unknown symbol in module or invalid parameter

Any help will be appreciated

nik0 commented 4 years ago

What is the missing symbol? My guess is there is a dependency with another module

sundarnagarajan commented 4 years ago

Sorry, but the eror message did not indicate which symbol.

Is there s Linux kernel script or command to check - similar to 'ldd' ?

On Sun, Nov 17, 2019, 22:43 nik0 notifications@github.com wrote:

What is the missing symbol? My guess is there is a dependency with another module

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Dafang-Hacks/Main/issues/35?email_source=notifications&email_token=AC3K3S5A5JCMQKU6BNM3GPTQUI2QDA5CNFSM4JOOYMYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEJLTUY#issuecomment-554875347, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3K3S66P3TNWJ4AQIR6OFDQUI2QDANCNFSM4JOOYMYA .

nik0 commented 4 years ago

What about dmesgcommand ?

sundarnagarajan commented 4 years ago

I interactively did the insmod. Will additional details go only to dmesg ?

On Sun, Nov 17, 2019, 22:58 nik0 notifications@github.com wrote:

What about dmesg command ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Dafang-Hacks/Main/issues/35?email_source=notifications&email_token=AC3K3S4P4U7AZI4LTNIAGGLQUI4IBA5CNFSM4JOOYMYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEJMQRI#issuecomment-554879045, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3K3SZTB3IEBJ3SUCQRZODQUI4IBANCNFSM4JOOYMYA .

nik0 commented 4 years ago

Yes I think so

sundarnagarajan commented 4 years ago

You're right.

I see the following errors in dmesg when insmodding ip_tables.ko.

[110015.716593] ip_tables: Unknown symbol xt_free_table_info (err 0)
[110015.728051] ip_tables: Unknown symbol xt_alloc_table_info (err 0)
[110015.735585] ip_tables: Unknown symbol nf_register_sockopt (err 0)
[110015.749557] ip_tables: Unknown symbol xt_check_match (err 0)
[110015.756335] ip_tables: Unknown symbol xt_request_find_target (err 0)
[110015.770913] ip_tables: Unknown symbol xt_unregister_matches (err 0)
[110015.784994] ip_tables: Unknown symbol xt_request_find_match (err 0)
[110015.792099] ip_tables: Unknown symbol nf_unregister_sockopt (err 0)
[110015.799433] ip_tables: Unknown symbol xt_unregister_targets (err 0)
[110015.812160] ip_tables: Unknown symbol xt_recseq (err 0)
[110015.817718] ip_tables: Unknown symbol xt_register_targets (err 0)
[110015.832279] ip_tables: Unknown symbol xt_register_table (err 0)
[110015.839330] ip_tables: Unknown symbol xt_proto_init (err 0)
[110015.856661] ip_tables: Unknown symbol xt_replace_table (err 0)
[110015.877118] ip_tables: Unknown symbol xt_find_table_lock (err 0)
[110015.900697] ip_tables: Unknown symbol xt_table_unlock (err 0)
[110015.906883] ip_tables: Unknown symbol xt_proto_fini (err 0)
[110015.912930] ip_tables: Unknown symbol xt_register_matches (err 0)
[110015.919566] ip_tables: Unknown symbol xt_check_target (err 0)
[110015.934496] ip_tables: Unknown symbol xt_find_revision (err 0)
[110015.945670] ip_tables: Unknown symbol xt_unregister_table (err 0)
[110078.145637] ip_tables: Unknown symbol xt_free_table_info (err 0)
[110078.152356] ip_tables: Unknown symbol xt_alloc_table_info (err 0)
[110078.158951] ip_tables: Unknown symbol nf_register_sockopt (err 0)
[110078.173593] ip_tables: Unknown symbol xt_check_match (err 0)
[110078.184923] ip_tables: Unknown symbol xt_request_find_target (err 0)
[110078.192295] ip_tables: Unknown symbol xt_unregister_matches (err 0)
[110078.199013] ip_tables: Unknown symbol xt_request_find_match (err 0)
[110078.211579] ip_tables: Unknown symbol nf_unregister_sockopt (err 0)
[110078.223277] ip_tables: Unknown symbol xt_unregister_targets (err 0)
[110078.230544] ip_tables: Unknown symbol xt_recseq (err 0)
[110078.236181] ip_tables: Unknown symbol xt_register_targets (err 0)
[110078.249925] ip_tables: Unknown symbol xt_register_table (err 0)
[110078.260775] ip_tables: Unknown symbol xt_proto_init (err 0)
[110078.268279] ip_tables: Unknown symbol xt_replace_table (err 0)
[110078.274527] ip_tables: Unknown symbol xt_find_table_lock (err 0)
[110078.280940] ip_tables: Unknown symbol xt_table_unlock (err 0)
[110078.293597] ip_tables: Unknown symbol xt_proto_fini (err 0)
[110078.304129] ip_tables: Unknown symbol xt_register_matches (err 0)
[110078.311141] ip_tables: Unknown symbol xt_check_target (err 0)
[110078.317667] ip_tables: Unknown symbol xt_find_revision (err 0)
[110078.332825] ip_tables: Unknown symbol xt_unregister_table (err 0)
[110202.569340] iptable_filter: Unknown symbol xt_hook_link (err 0)
[110202.580326] iptable_filter: Unknown symbol ipt_alloc_initial_table (err 0)
[110202.588245] iptable_filter: Unknown symbol ipt_do_table (err 0)
[110202.594739] iptable_filter: Unknown symbol ipt_unregister_table (err 0)
[110202.601759] iptable_filter: Unknown symbol xt_hook_unlink (err 0)
[110202.613531] iptable_filter: Unknown symbol ipt_register_table (err 0)
[110670.839419] ip_tables: Unknown symbol xt_free_table_info (err 0)
[110670.851147] ip_tables: Unknown symbol xt_alloc_table_info (err 0)
[110670.862563] ip_tables: Unknown symbol nf_register_sockopt (err 0)
[110670.869790] ip_tables: Unknown symbol xt_check_match (err 0)
[110670.876012] ip_tables: Unknown symbol xt_request_find_target (err 0)
[110670.894759] ip_tables: Unknown symbol xt_unregister_matches (err 0)
[110670.915406] ip_tables: Unknown symbol xt_request_find_match (err 0)
[110670.925047] ip_tables: Unknown symbol nf_unregister_sockopt (err 0)
[110670.934947] ip_tables: Unknown symbol xt_unregister_targets (err 0)
[110670.946379] ip_tables: Unknown symbol xt_recseq (err 0)
[110670.952649] ip_tables: Unknown symbol xt_register_targets (err 0)
[110670.959183] ip_tables: Unknown symbol xt_register_table (err 0)
[110670.973137] ip_tables: Unknown symbol xt_proto_init (err 0)
[110670.983826] ip_tables: Unknown symbol xt_replace_table (err 0)
[110670.990563] ip_tables: Unknown symbol xt_find_table_lock (err 0)
[110670.997077] ip_tables: Unknown symbol xt_table_unlock (err 0)
[110671.008341] ip_tables: Unknown symbol xt_proto_fini (err 0)
[110671.019143] ip_tables: Unknown symbol xt_register_matches (err 0)
[110671.026249] ip_tables: Unknown symbol xt_check_target (err 0)
[110671.032487] ip_tables: Unknown symbol xt_find_revision (err 0)
[110671.038631] ip_tables: Unknown symbol xt_unregister_table (err 0)
[112033.596775] ip_tables: Unknown symbol xt_free_table_info (err 0)
[112033.610350] ip_tables: Unknown symbol xt_alloc_table_info (err 0)
[112033.621905] ip_tables: Unknown symbol nf_register_sockopt (err 0)
[112033.629156] ip_tables: Unknown symbol xt_check_match (err 0)
[112033.635249] ip_tables: Unknown symbol xt_request_find_target (err 0)
[112033.642247] ip_tables: Unknown symbol xt_unregister_matches (err 0)
[112033.653985] ip_tables: Unknown symbol xt_request_find_match (err 0)
[112033.665391] ip_tables: Unknown symbol nf_unregister_sockopt (err 0)
[112033.672571] ip_tables: Unknown symbol xt_unregister_targets (err 0)
[112033.679353] ip_tables: Unknown symbol xt_recseq (err 0)
[112033.692309] ip_tables: Unknown symbol xt_register_targets (err 0)
[112033.703641] ip_tables: Unknown symbol xt_register_table (err 0)
[112033.710553] ip_tables: Unknown symbol xt_proto_init (err 0)
[112033.716550] ip_tables: Unknown symbol xt_replace_table (err 0)
[112033.727527] ip_tables: Unknown symbol xt_find_table_lock (err 0)
[112033.738649] ip_tables: Unknown symbol xt_table_unlock (err 0)
[112033.745681] ip_tables: Unknown symbol xt_proto_fini (err 0)
[112033.751565] ip_tables: Unknown symbol xt_register_matches (err 0)
[112033.758207] ip_tables: Unknown symbol xt_check_target (err 0)
[112033.771817] ip_tables: Unknown symbol xt_find_revision (err 0)
[112033.783085] ip_tables: Unknown symbol xt_unregister_table (err 0)
nik0 commented 4 years ago

Have a look here: https://forums.gentoo.org/viewtopic-t-842310-start-0.html Maybe some configs are not enabled

sundarnagarajan commented 4 years ago

That was useful, and helped me make some progress.

I found that CONFIG_NETFILTER in kernel config is a boolean - and has to be 'Y'.

With remaining changes to .config, my modules still do not load - presumably because some of the symbols (e.g. nfregister*) are part of kernel and not in any external module.

E.g. grepping for nf_register | nf_unregister in Module.symvers in newly compiled kernel yields:

egrep '(nf_register|nf_unregister)' Module.symvers 
0x00000000  nf_unregister_queue_handler vmlinux EXPORT_SYMBOL
0x00000000  nf_register_hook    vmlinux EXPORT_SYMBOL
0x00000000  nf_register_afinfo  vmlinux EXPORT_SYMBOL_GPL
0x00000000  nf_register_queue_handler   vmlinux EXPORT_SYMBOL
0x00000000  nf_register_hooks   vmlinux EXPORT_SYMBOL
0x00000000  nf_unregister_hook  vmlinux EXPORT_SYMBOL
0x00000000  nf_unregister_hooks vmlinux EXPORT_SYMBOL
0x00000000  nf_unregister_sockopt   vmlinux EXPORT_SYMBOL
0x00000000  nf_unregister_afinfo    vmlinux EXPORT_SYMBOL_GPL
0x00000000  nf_register_sockopt vmlinux EXPORT_SYMBOL

So it appears I need to copy the newly compiled kernel to the T20 device also.

I built a uImage, and file on my uImage compared with the standard kernel-t20.bin is below:

file kernel-t20.bin; file Main/kernel/arch/mips/boot/uImage.lzma
kernel-t20.bin: u-boot legacy uImage, Linux-3.10.14, Linux/MIPS, OS Kernel Image (lzma), 1709528 bytes, Wed Jul 18 20:58:52 2018, Load Address: 0x80010000, Entry Point: 0x803B3F00, Header CRC: 0xDA2B2B5B, Data CRC: 0x58ED80B1
Main/kernel/arch/mips/boot/uImage.lzma: u-boot legacy uImage, Linux-3.10.14, Linux/MIPS, OS Kernel Image (lzma), 1687401 bytes, Mon Nov 18 15:29:09 2019, Load Address: 0x80010000, Entry Point: 0x803A7FB0, Header CRC: 0x69C19EC4, Data CRC: 0x7B850304

I presume the steps to use my new kernel are:

However, how do I compile the kernel modules that come with the dafang rootfs (.ko names below):

mt7601Usta.ko
rtl8189es.ko
rtl8189fs.ko
sample_motor.ko
sensor_jxf22.ko
sensor_jxf23.ko
sensor_jxh62.ko
sinfo.ko
tx-isp-t10.ko
tx-isp-t20.ko

I cannot find source or kernel options for these - e.g. I looked specifically for rtl8189es.ko and rtl8189fs.ko

Any help will be appreciated

sundarnagarajan commented 4 years ago

I opened Issue 36 asking about how to compile the drivers that come with the standard rootfs.

nik0 commented 4 years ago

Try copying the compiled kernel and keep the other modules unchanged I can’t remember where these modules come from (either from the original kernel or compiled from whatever sources)

sundarnagarajan commented 4 years ago

I tried copying the compiled kernel and kept the modules from the standard rootfs unchanged. The device did not boot. I keep hearing clicking sounds, and neither yellow nor blue LED lights up at all.

I presume that is because the standard modules are not loading because they are somehow not compatible with the newly compiled kernel?

/var/log/startup.log is not created.

I modified /etc/init.d/rcS to write dmesg to /var/log, but dmesg was not written at all.

On Mon, Nov 18, 2019 at 9:50 AM nik0 notifications@github.com wrote:

Try copying the compiled kernel and keep the other modules unchanged I can’t remember where these modules come from (either from the original kernel or compiled from whatever sources)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Dafang-Hacks/Main/issues/35?email_source=notifications&email_token=AC3K3SZ7Y6LQXU37MWHVTKDQULIXZA5CNFSM4JOOYMYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEELKAMA#issuecomment-555130928, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3K3SZWDD4G7KQNAA73FOTQULIXZANCNFSM4JOOYMYA .

nik0 commented 4 years ago

Try installing them after boot up

sundarnagarajan commented 4 years ago

You mean .....

How will I get access to SSH in if module for wireless card is not loaded?

nik0 commented 4 years ago

Right, forget what I said 😜

sundarnagarajan commented 4 years ago

I have made progress on this. Now I am able to compile MOST modules (all the modules required for the 128 MB Ingenic T20-based Wyze Cam Pan, at least). I am closing this issue - will open a different issue asking about kernel config for the kernel standard rootfs, and compiling and using the rtl8189es.ko module in particular.

Thanks for your help.