Digi 9P 9360/9750 Add the module to the build environment, Building and loading of kernel modules

Page 40

W r i t i n g k e r n e l m o d u l e s

Add the module to the build environment

You have to edit "my_kmodule/Makefile.in" so that the build environment knows what files to build.

To include them for the target build, append them to obj-m like "obj-m += my_module.o". The modules must be named like their C-source files. Usable object modules will have the extension ".ko".

#Add your kernel modules here obj-m += my_module.o

Then you have to add the module to the list of available modules. Edit the configure.ac and modify the line adding the module minimal to add your module to the list.

LXNETES_KMODULES([minimal my_kmodule])

Building and loading of kernel modules

For building the new kernel module, just rebuild your project by issuing make in the build directory.

If you reboot your target with the newly created rootfs (or if you mount your rootfs via nfs), The

modules can be loaded in the target with "modprobe my_kmodule"

There is an example "minimal.c" for the most minimalist kernel module. Try it with "modprobe/minimal"

#modprobe /minimal

Minimal driver $Revision: 1.1 $ loaded

#cat /proc/modules

minimal 1536 0 - Live 0xbf000000

#rmmod minimal

Minimal driver unloaded

#cat /proc/modules

Included Kernel modules

minimal

This is a minimalist kernel module which actually does nothing. It is only a module to test the functionality of the load and unload functions of the kernel.

4 0

L x N E T E S U s e r ’ s G u i d e

Image 40
Contents LxNETES User’s Guide ConnectCore 9P 9360/9750 Page Page Page Contents Building the First Project Interfaces & Devices Appendix B Overview IntroductionCross-development environment Template project Linux kernel sourcesExample applications General features FeaturesWhat’s new in LxNETES 3.2? RTC Gpio Conventions used in this manual This is a tip. It contains useful information about a topicAcronyms and abbreviations System Requirements/Prerequisites RequirementsSystem requirements Disk space Optional but recommended componentsApplications & Services Tftp daemonNFS server JTAG-Booster N E T E S U s e r ’ s G u i d e Getting Started Connecting host PC with development boardIntroduction Minicom SeyonConnect power Seyon SettingsTest Ethernet configuration Installing LxNETES # ifconfig eth0Guided Installation Manual Installation N u a l Installation Run configure Building the Default ProjectBuilding the First Project Run make install Run makeWriting applications Application DevelopmentAdding your own applications Included example applications Using C++Display Proc/cpuinfo contents Debugging applications Choose the right architecture for your target Included pre-built applications Shell applications busyboxTelnet daemon utelnetd Web server BoaNano-X/microwindows Embedded QtUseful applications MemWhat is a kernel module? Kernel DevelopmentWriting kernel modules Writing your own kernel modulesBuilding and loading of kernel modules Add the module to the build environmentIncluded Kernel modules Minimal Modifying the default project Advanced TopicsD i f y i n g t h e d e Fault p r o j e c t Building a custom project Boot Boot processIntroduction ConnectCore 9P 9360/9750 Bank # 0 00000000 32 MBLinux boot methods NAND-FlashNOR Flash USBLinux boot process MMUV a n c e d T o p i c s Automating the image download Passing arguments to the kernelUpdating the Flash memory Updating a running system the easy way Updating a running system manuallyErase the Flash partition Download the new image file to RAMWrite the image to Flash Kernel BootRoot File System Updating a corrupted system using a debugger Root File System Types Download the kernel to RAM via Tftp Set bootargs to be passed to the kernelLaunch the kernel from RAM JFFS2 Copy the kernel to RAM O t F i l e S y s t e m T y p e s N E T E S U s e r ’ s G u i d e Interfaces & Devices Serial interfaceUSB host interface I2C interfaceSPI interface LCD interfaceHow to set the initial system date and time Compact flash interfaceSD card interface Real time clock RTCPCI interface Appendix a CD contentsRelated documentation Install.sh Readme.txtRelNotes.txt Docs ImagesSetup ConnectCore 9P 9360 CC9P9360ConnectCore 9P 9750 CC9P9750 HardwareMemory layouts Flash memory layoutConnectCore 9P 9360 / ConnectCore 9P Sdram memory layoutTextbase N E T E S U s e r ’ s G u i d e Boot command reference Appendix BO o t c o m m a n d r e f e r e n c e Skipped CC9C CCXP270 UNC90 User keys Example A9M24x0