Cross Compiling Linux Arm Kernel with new driver m

2019-02-28 23:50发布

问题:

I am trying to include a driver for use on my arch linux arm machine. I tried using these steps to include the driver module, but my cross-compiled kernel with the added driver doesn't load.

1) Include the driver I want to add by making it have < M > beside it's 
   name in make ARCH=arm menuconfig

2) run: make ARCH=arm CROSS_COMPILE=/home/z3/bin/arm-   (the path for my cross-compiling toolchain)

3) run: make ARCH=arm CROSS_COMPILE=/home/z3/bin/arm- modules

4) run: make ARCH=arm CROSS_COMPILE=/home/z3/bin/arm- install

5) run: make ARCH=arm CROSS_COMPILE=/home/z3/bin/arm- modules_install

6) copy my uImage from: arch/arm/boot 
   to my boot location: /tftpboot/

Then when my embedded linux arm tries to load the kernel uImage, it hangs with: EDIT: Changed the entry point address to 80008000, so now it hangs with:

Filename '/tftpboot/uImage'.                                                    
Load address: 0x81800000                                                        
Loading: #################################################################      
         #################################################################      
         #################################################################      
         #################################################################      
         #################################################################      
         #################################################################      
         #################################################################      
         #################################################################      
         #################################################################      
         ####################################                                   
done                                                                            

Bytes transferred = 3174848 (3071c0 hex)

Booting kernel from Legacy Image at 81800000 ...

Image Name: 2.6.35-ModifiedEntry
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 3174784 Bytes = 3 MiB
Load Address: 80008000
Entry Point: 80008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK

Starting kernel ...

Am I cross-compiling my kernel wrong? It cannot load the uImage. All I want to do is cross compile my kernel for the linux arm machine with a newly included driver (included in the config from make menuconfig). Am I missing any additional steps?

回答1:

You have done two mistake in kernel building procedure.

1)before make menuconfig

you need to have a .config file should exit in source-code.

How u can get it

1) make ARCH=arm board_defconfig

check your default config in /arch/arm/configs

e.g make ARCH=arm versatile_defconfig

this will write default configuration to .config

2)if you dont know your default configuration you can get it in target board Filesystem.

it will be in /proc/config.gz copy to your host untar it and copy as .config in top source-code. or it may present in /boot/config.x.x.x

if dont follow above step make ARCH=arm menuconfig this will copy host x86 config file from /boot/config-x.x.x which will be wrong config file

Once above step is done then next step make ARCH=arm menuconfig here enable your driver.

2nd mistake is make ARCH=arm CROSS_COMPILE=/home/z3/bin/arm- modules_install

This will install modules in /lib/modules of x86 host machine.

so follow below one

make ARCH=arm CROSS_COMPILE=(path to arm) uImage modules

create a directory to install your dynamic loadable modules

make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- modules_install INSTALL_MOD_PATH=<path to install modules>

Then you need to copy modules to your target.

For more details you can refer this Just black screen after running Qemu