Firefly Open Source Community

   Login   |   Register   |
New_Topic
Print Previous Topic Next Topic

How to add a module to android Kernel

41

Credits

0

Prestige

0

Contribution

new registration

Rank: 1

Credits
41

How to add a module to android Kernel

Posted at 1/7/2018 07:43:46      View:2505 | Replies:0        Print      Only Author   [Copy Link] 1#
Hello im new to making modules for android/linux so i apologize if these are obvious questions but ive been having trouble with getting this to work properly.

Ive been trying to add a simple hello module to the android kernel. here are my current steps:
HelloModule.c:
  1. #include <linux/module.h>
  2. #include <linux/kernel.h>
  3. #include <linux/init.h>

  4. static int __init hello_module(void)
  5. {
  6.         printk(KERN_INFO "Hello android kernel...\n");
  7.         return 0;
  8. }

  9. static void __exit goodbye_module(void)
  10. {
  11. printk(KERN_INFO "Goodbye android kernel...\n");
  12. }

  13. module_init(hello_module);
  14. module_exit(goodbye_module);
Copy the code
1. move hellomodule.c to firefly-rk3399/kernel/drivers/misc/
2. add to makefile (in misc):
  1. obj-$(CONFIG_HELLO_MODULE)      += HelloModule.o
Copy the code
3.add to Kconfig(in misc):
  1. config HELLO_MODULE
  2.         tristate "Hello Module"
  3.         default y
Copy the code
4. cd firefly-rk3399/
5. ./FFtools/make.sh -j32
6. ./FFtools/mkupdate/mkupdate.sh
7. sudo upgade_tool uf ./rockdev/Image-rk3399_firefly_box/Firefly-RK3399_Android7.1.1_MP_180106.img

It looks like hellomodule.o was compiled correctly in /misc directory
The diffrences between android kernel and a normal linux kernel have been giving me trouble, So heres my questions:
1. is there  a way to see the installed modules on android adb shell? (lsmod doesnt work )
2. how do you run hellomodule in this case? (modprobe doesnt work)
3. im trying to run
  1. make ARCH=arm64 CROSS_COMPILE=?
Copy the code
to make a .ko for hellomodule.c by itselfWhere is the cross compiler for the rk3399 board?

Reply

Use props Report

You need to log in before you can reply Login | Register

This forum Credits Rules

Quick Reply Back to top Back to list