開發板編譯內核
『壹』 如何配置編譯在mini2440開發板上運行的linux內核
參考:http://www.it165.net/os/html/201409/9334.html
系統ubuntu12.04(非虛擬機下)
mini2440
CPU型號: S3C2440AL-40
Nanflash型號:K9F1G08
Norflash型號:SST39VF1601
LCD: 統寶 240 x 320
$: 普通賬戶
#:root賬戶
*當shell下輸入路徑時可使用tab鍵自動補全
(一)建立交叉編譯環境
1.將mini2440光碟中的linux文件夾拷貝到 /home/lianghuiyong 並改名為Linux_share
(其中兩個文檔為我後面添加進去的)
2.Ctrl+Alt+T打開shell
3.$ su - root (切換root許可權)
4.# cd /home/lianghuiyong/Linux_share
5.解壓安裝arm-linux-gcc編輯器
# tar xvzf arm-linux-gcc-4.4.3.tar.gz –C / //注意:C後面有個空格
執行該命令,將把 arm-linux-gcc 安裝到/usr/loca/arm/4.4.3 目錄。這句來自mini2440用戶手冊,我發現其實是安裝到 /opt/FriendlyARM/toolchain/4.4.3 目錄
6.# vim /root/.bashrc
7.在最後一行添加:export PATH=$PATH:/opt/FriendlyARM/toolschain/4.4.3/bin //opt/FriendlyARM/toolschain/4.4.3/bin 為arm-linux-gcc 環境變數
:wq保存退出。
# source ~/.bashrc
8.# sudo gedit /etc/environment
games後面添加標記部分
9.# arm-linux-gcc -v //gcc後面有空格
測試hello.c(這是在安裝了第二部分的linux示常式序才有examples/hello目錄)
# cd /opt/FriendlyARM/mini2440/examples/hello
# arm-linux-gcc -o hello hello.c
# ./hello
(二)安裝源代碼及其他工具
創建工作目錄(以下都為root環境下):
# mkdir -p /opt/FriendlyARM/mini2440
1>>解壓安裝linux內核源代碼
# cd /opt/FriendlyARM/mini2440
# tar xvzf /home/lianghuiyong/Linux_share/linux-2.6.32.2-mini2440-20100106.tar.gz
2>>解壓安裝嵌入式圖形系統qtopia源代碼
# cd /opt/FriendlyARM/mini2440
# tar xvzf /home/lianghuiyong/Linux_share/x86-qtopia.tgz
# tar xvzf /home/lianghuiyong/Linux_share/arm-qtopia.tgz
3>>解壓安裝嵌入式圖形系統 QtE-4.6.1 源代碼
# cd /opt/FriendlyARM/mini2440
# tar xvzf /home/lianghuiyong/Linux_share/arm-qte-4.6.3-20100802.tar.gz
4>>解壓安裝busybox 源代碼
# cd /opt/FriendlyARM/mini2440
# tar xvzf /home/lianghuiyong/Linux_share/busybox-1.13.3-mini2440.tgz
5>>解壓安裝 Linux 示常式序
# cd /opt/FriendlyARM/mini2440
# tar xvzf /home/lianghuiyong/Linux_share/examples-20100108.tgz
6>>解壓安裝 vboot 源代碼
# cd /opt/FriendlyARM/mini2440
# tar xvzf /home/lianghuiyong/Linux_share/vboot-src-20100106.tar.gz
7>>解壓安裝 bootloader 源代碼
# cd /opt/FriendlyARM/mini2440
# tar xvzf /home/lianghuiyong/Linux_share/bootloader.tgz
8>>解壓創建目標文件系統
# cd /opt/FriendlyARM/mini2440
#tar xvzf /home/lianghuiyong/Linux_share/rootfs_qtopia_qt4-20100816.tar.gz
9>>解壓安裝目標文件系統映象製作工具 mkyaffs2image
# cd /opt/FriendlyARM/mini2440
# tar xvzf /home/lianghuiyong/Linux_share/mkyaffs2image.tgz –C /
10>>解壓安裝LogoMaker
# cd /opt/FriendlyARM/mini2440
# tar xvzf /home/lianghuiyong/Linux_share/logomaker.tgz –C /
(三)定製linux內核及製作文件系統
config_mini2440_x35 – 適用於 Sony 3.5」 LCD 的內核配置文件
config_mini2440_t35 – 適用於統寶 3.5」 LCD 的內核配置文件
config_mini2440_l80 – 適用於 Sharp 8」 LCD(或兼容)的內核配置文件
config_mini2440_n35 – 適用於 NEC3.5」 LCD 的內核配置文件
config_mini2440_h43 – 適用於 4.3」 LCD 的內核配置文件
config_mini2440_a70 – 適用於群創 7」 LCD 的內核配置文件
config_mini2440_vga1024x768 – 適用於 VGA 顯示輸出(解析度 1024x768)模塊的內核
配置文件
1.配置預設文件config_t35 (統寶240x320)
# cd /opt/FriendlyARM/mini2440/linux-2.6.32.2
# cp config_mini2440_t35 .config
# make menuconfig
出現界面
不做更改,exit退出。這樣做是為了生成相應配置(統寶240x320)的頭文件。
2.編譯內核
在/opt/FriendlyARM/mini2440/linux-2.6.32.2 目錄下編譯內核
#make zImage
編譯結束後,會在 arch/arm/boot 目錄下生成 linux 內核映象文件:zImage(zImage 可下載到開發板測試)
3.定製linux內核(根據用戶手冊來走一遍)
# cd /opt/FriendlyARM/mini2440/linux-2.6.32.2
# make menuconfig
出現配置選項:
3.1配置cpu
主菜單-->System --> Type S3C2400 Machines --> FriendlyARM Mini2440 development board
3.2配置lcd驅動
主菜單-->Device Drivers-->Graphics support-->Support for frame buffer devices-->Backlight-->LCD select-->3.5 inch 240x320 Toppoly LCD
3.3配置觸摸屏
主菜單-->Device Drivers-->Input device support-->Touchscreens-->Samsung s3c24410 touchscreen input driver
3.4配置usb滑鼠和鍵盤
主菜單-->Device Drivers-->hid devices-->USB Human interface Device
3.5 配置優盤
主菜單-->Device Drivers-->SCSI device support--> SCSI disk
3.6配置萬能驅動USB攝像頭
主菜單-->Device Drivers-->Multimedia devices-->Video capture adapters -->V4L USB devices-->GSPCA based webcams-->ALi USB m 5602 Camera Driver
3.7 配置CMOS攝像頭驅動
主菜單-->Device Drivers-->Multimedia devices-->Video capture adapters-->OV9650 on the s3c2440 driver
3.8配置網卡驅動
主菜單-->Netwoking support-->Networking options -->選擇Unix和TCP/IP
主菜單-->Device Drivers-->Network device support-->Ethernet (10 or 100Mbit)-->
選擇 <*> Generic Media Independent Interface device support
<*> DM9000 support
3.9 配置USB無線網卡驅動
主菜單-->Netwoking support-->wireless-->IEEE 802.11
主菜單-->Device Drivers-->Netwoking device support-->wireless LAN-->Wireless LAN(IEEE 802.11)-->Ralink driver support-->
3.10 配置音頻驅動
主菜單-->Device Drivers-->Sound card supprt-->OSS Mixer API -->ALSA for Soc audio support-->SoC Audio for the samsung S3Cxxxx Chips
3.11 配置SD/MMC卡驅動
主菜單-->Device Drivers-->MMC/SD/SDIO card-->samsung S3C SD/MMC card
3.12 配置看門狗驅動支持
主菜單-->Device Drivers-->Watchdog Timer-->s3c2440 Watchdog
3.13 配置LED驅動
主菜單-->Device Drivers-->Character devices-->LED support for Mini2440
3.14 配置按鍵驅動
主菜單-->Device Drivers-->Character devices-->Buttons driver
3.15 配置PWM控制蜂鳴器驅動
主菜單-->Device Drivers-->Character devices-->buzzer driver for
3.16 配置AD轉換驅動
主菜單-->Device Drivers-->Character devices-->ADC driver for
3.17 配置串口驅動
主菜單-->Device Drivers-->Character devices-->Serial drivers-->samsung S3C2440/S3C2442
3.18 如何配置RTC實時時鍾驅動
主菜單-->Device Drivers-->Real Time Clock-->samsung S3C series SoC RTC
3.19 配置I2C-EEPROM驅動支持
主菜單-->Device Drivers-->I2C support -->I2C Hardware Bus support-->S3C2410 I2C Driver
3.20 配置yaff2s文件系統的支持
主菜單-->Device Drivers-->MTD-->NAND Device Support -->NAND FLASH Support
主菜單-->File systems-->Miscellaneous filesystems -->YAFFS2 file system support
3.21 配置EXT2/VFAT/ NFS等文件系統
主菜單-->File systems-->Network File Systems -->root file system on NFS
為了支持FAT32 文件系統.
主菜單-->File systems-->DOS/FAT/NT Filesystems -->VFAT (windows-95) fs support
關於mini2440 linux內核裁剪到此為止,退出後有一個是否保存提示,選擇保存!
3.22 製作Linux logo
本來想使用Logomaker,結果生成的圖片都是無數據的,這可能和系統內一些參數有關
使用命令方式製作logo:
在圖片(open_show.png)目錄下
# pngtopnm open_show.png > temp.ppm
# ppmquant 224 temp.ppm >temp2.ppm
# pnmnoraw temp2.ppm > logo.ppm
將目錄下生成的logo.ppm改成linux_logo_clut224.ppm,替代linux2.6.32.2/drivers/video/logo 目錄下的同名文件
『貳』 arm開發板為什麼都要自己去編譯linux內核
編譯內核可以定製,把需要的編譯進去,但是新手學的時候就直接全部編譯了,也沒人具體講原理。你先不用急。
『叄』 在RedHat9.0(2.4內核)操作系統下怎樣為開發板編譯2.6驅動模塊
可以,你把環境搭建好就可以編譯大部分。
makefile中指定好平台。如果本身驅動不在kernel代碼樹里,把內核的代碼頭文件等等手動設定好,如果驅動用到其他庫或代碼也手動指定好,不要讓編譯器自動搜索本機環境。
還要查閱下文檔,有些代碼可能壓根就沒有為交叉編譯而特別編寫,這類代碼的交叉編譯需要你打patch、重寫makefile
『肆』 為什麼要編譯linux內核(beaglebone的開發板)
1、頭文件不能用,就是說編譯器找不到,要麼是頭文件的位置不對,要麼是根本沒有所需要的頭文件;比如#include<linux/gpio.h>,那就是在你的linux源碼目錄中的include/linux/目錄下要有gpio.h這個文件,如果沒有,自然就編譯通不過了。
2、你所說的光碟資料source文件夾,因為我也沒有你的光碟,所以無法確定它的內容到底是不是內核,makefile文件是編譯器所需要的依賴關系文件,config文件就不清楚了,如果是kconfig文件,那就是內核的配置文件。
『伍』 如何在2416開發板WINCE6.0上編譯內核
初次看你的題目,感覺有矛盾,但一想,還行,首先,你開發板已經有了wince系統,也就是說內核都是在的,然後你想重新編譯內核的話,只有在電腦上將內核編譯好了之後再燒到板子上,
『陸』 編譯內核模塊常見有關問題怎麼解決
第一次把自己編譯的驅動模塊載入進開發板,就出現問題,還好沒花費多長時間,下面列舉出現的問題及解決方案
1:出現insmod: error inserting 'hello.ko': -1 Invalid mole format
法一(網上的):是因為內核模塊生成的環境與運行的環境不一致,用linux-2.6.27內核源代碼生成的模塊,可能就不能在linux-2.6.32.2內核的linux環境下載入,需要在linux-2.6.27內核的linux環境下載入。
a.執行 uname -r //查看內核版本
b.一般出錯信息被記錄在文件/var/log/messages中,執行下面命令看錯誤信息
# cat /var/log/messages |tail
若出現類似下面:
Jun 4 22:07:54 localhost kernel:hello: version magic '2.6.35.6-45.fc14.i686.PAE
' should be '2.6.35.13-92.fc14.i686.PAE'
則把 Makefile里的KDIR :=/lib/moles/2.6.35.6-45.fc14.i686.PAE/build1 改為
KDIR :=/lib/moles/2.6.35.13-92.fc14.i686.PAE/build1 //改成自己內核源碼路徑
(這里的build1是一個文件鏈接,鏈接到/usr/src/kernels/2.6.35.6-45.fc14.i686.PAE和13-92的)
然並卵,我的fedora 14 /usr/src/kernels下並沒有2.6.35.13-92.fc14.i686.PAE,只有2.6.35.13-92.fc14.i686,雖然不知道兩者有什麼區別,但改成2.6.35.13-92.fc14.i686還是不行,照樣這個問題,還好後來在看教學視頻的到啟發
法二:改的還是那個位置
KDIR :=/opt/FriendlyARM/linux-2.6.32.2 //把這里改成你編譯生成kernel的那個路徑
all:
$ (MAKE) -C $ (KDIR) M = $ (PWD) moles ARCH=arm CROSS_COMPILE=arm-linux- //加這句
2. [70685.298483] hello: mole license 'unspecified' taints kernel.
[70685.298673] Disabling lock debugging e to kernel taint
方法:在模塊程序中加入: MODULE_LICENSE("GPL");
3. rmmod: chdir(2.6.32.2-FriendlyARM): No such file or directory 錯誤解決
方法:lsmod 可查看模塊信息
即無法刪除對應的模塊。
就是必須在/lib/moles下建立錯誤提示的對應的目錄((2.6.32.2)即可。
必須創建/lib/moles/2.6.32.2這樣一個空目錄,否則不能卸載ko模塊.
# rmmod nls_cp936
rmmod: chdir(/lib/moles): No such file or directory
但是這樣倒是可以卸載nls_cp936,不過會一直有這樣一個提示:
rmmod: mole 'nls_cp936' not found
初步發現,原來這是編譯kernel時使用make moles_install生成的一個目錄,
但是經測試得知,rmmod: mole 'nls_cp936' not found來自於busybox,並不是來自kernel
1).創建/lib/moles/2.6.32.2空目錄
2).使用如下源碼生成rmmod命令,就可以沒有任何提示的卸載ko模塊了[luther.gliethttp]
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
int main(int argc, char *argv[])
{
const char *modname = argv[1];
int ret = -1;
int maxtry = 10;
while (maxtry-- > 0) {
ret = delete_mole(modname, O_NONBLOCK | O_EXCL);//系統調用sys_delete_mole
if (ret < 0 && errno == EAGAIN)
usleep(500000);
else
break;
}
if (ret != 0)
printf("Unable to unload driver mole \"%s\": %s\n",
modname, strerror(errno));
}
3).把生成的命令復制到文件系統
# arm-linux-gcc -static -o rmmod rmmod.c
# arm-linux-strip -s rmmod
# cp rmmod /nfs/
cp /nfs/rmmod /sbin
代碼如下:
proc.c
[html] view plain
<span style="font-size:18px;">#include <linux/mole.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/proc_fs.h> /* Necessary because we use the proc fs */
#define procfs_name "proctest"
MODULE_LICENSE("GPL");
struct proc_dir_entry *Our_Proc_File;
int procfile_read(char *buffer,char **buffer_location,off_t offset, int buffer_length, int *eof, void *data)
{ int ret;
ret = sprintf(buffer, "HelloWorld!\n");
return ret;
}
int proc_init()
{ Our_Proc_File = create_proc_entry(procfs_name, 0644, NULL);
if (Our_Proc_File == NULL) {
remove_proc_entry(procfs_name, NULL);
printk(KERN_ALERT "Error: Could not initialize /proc/%s\n",procfs_name);
return -ENOMEM; }
Our_Proc_File->read_proc = procfile_read;//
// Our_Proc_File->owner = THIS_MODULE;
Our_Proc_File->mode = S_IFREG | S_IRUGO;
Our_Proc_File->uid = 0;
Our_Proc_File->gid = 0;
Our_Proc_File->size = 37;
printk("/proc/%s created\n", procfs_name);
return 0;
}
void proc_exit()
{ remove_proc_entry(procfs_name, NULL);
printk(KERN_INFO "/proc/%s removed\n", procfs_name);
}
mole_init(proc_init);
mole_exit(proc_exit);</span></span></span></span></span>
[html] view plain
<span style="font-size:18px;">
ifneq ($(KERNELRELEASE),)
obj-m :=proc.o
else
KDIR :=/opt/FriendlyARM/linux-2.6.32.2
#KDIR :=/lib/moles/2.6.35.13-92.fc14.i686.PAE/build1
PWD :=$(shell pwd)
all:
$(MAKE) -C $(KDIR) M=$(PWD) moles ARCH=arm CROSS_COMPILE=arm-linux-
clean:
rm -f *.ko *.o *.mod.o *.mod.c *.symvers
endif</span></span></span></span></span>
make後生成proc.ko,再在開發板上insmod proc.ko即可
執行 dmesg 就可以看到 產生的內核信息啦
『柒』 友堅s3c6410開發板,內核配置選擇4.3寸屏的時候,編譯出錯。選其他屏比如7寸屏可以編譯通過。
如果文件都在,Kconfig也有配置,那基本就是make menuconfig時候沒有開samsung s3cfb_UT_LDC43C_D 驅動了。