TI am335x 核心原始碼編譯命令等
1.插入環境變數:
cd /etc
vim profile
在末尾加入:export PATH=<sdk path>/linux-devkit/sysroots/x86_64-arago-linux/usr/bin:$PATH
Rebuild source using the top-level makefile in the SDK rootdirectory.
· make allrebuilds all components in the SDK
· makelinux configures and builds the kernel
· makeu-boot-spl builds u-boot and u-boot-spl
2.清除Kernel原始碼
make ARCH=armCROSS_COMPILE=arm-linux-gnueabihf- distclean
3.配置核心
在編譯核心之前,需要配置哪些元件成核心映象,哪些模組作為動態模組,
3.1預設配置
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- defconfig
After the configuration step has run the full configuration file is saved to the root of the kernel tree as .config.
e.g: make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-am335x_evm_defconfig
3.2定製化配置
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
3.3編譯核心
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage
This will result in a kernel image filebeing created in the arch/arm/boot/directory called zImage.
3.4編譯裝置樹
在arch/arm/boot/dts/目錄下:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- am335x-evmsk .dtb
3.5編譯核心模組
很多驅動沒有整合到zImage裡面,而是在動態模組中。
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules
這會生成kernel object(.ko)檔案。
4.安裝kernel
4.1 將zImage 、 dtb 拷貝在資料夾(從這裡開始讀)Installing the Kernel Image and Device TreeBinaries。
cd <kernelsources dir>
sudo cparch/arm/boot/zImage <rootfs path>/boot
sudo cparch/arm/boot/dts/<dt file>.dtb <rootfs path>/boot
例如:
if you wanted to copy the kernel image and BeagleBone Black devicetree file to the rootfs partition of a SD card you would enter the below commands
cd <kernelsources dir>
sudo cparch/arm/boot/zImage arch/arm/boot/dts/am335x-boneblack.dtb /media/rootfs/boot
4.2安裝模組
sudomake ARCH=arm INSTALL_MOD_PATH=<pathto root of file system> modules_install
For example if you are installing the moduleson the rootfs partition of the SD card you would do:
sudo make ARCH=arm INSTALL_MOD_PATH=/media/rootfsmodules_install
5.GPIO
http://processors.wiki.ti.com/index.php/Processor_SDK_Linux_GPIO_Driver_Overview
IRQ handling:
irq_num = gpio_to_irq(30)
- Request IRQ, make sure that irq_num should be non-error value
request_irq(irq_num, handler, 0,"gpio_test", NULL);
- Set IRQ type Raising/Falling/Level triggered
set_irq_type(irq_num, IRQ_TYPE_EDGE_RISING);
- During the clean-up path free the IRQ and gpio
free_irq(irq_num, NULL);
gpio_free(30);
Kernel Level
err = gpio_request(30,"sample_name");
gpio_direction_input(30);
Make pin 30 as output and set the value ashigh.
gpio_direction_output(30, 1);
Exporting that particular pin (30) to sysfsentry then use this API
gpio_export(30, true);
gpio_get_value(30);
User Space - Sysfs control
Enable GPIO sysfs support in kernelconfiguration and build the kernel
Device Drivers ---> GPIOSupport ---> /sys/class/gpio/...(sysfs interface)
Sysfs entries
Export the particular GPIO pin for usercontrol. GPIO30 is taken as example.
$ echo 30 >/sys/class/gpio/export
Change the GPIO pin direction to in/out
$ echo "out"> /sys/class/gpio/gpio30/direction
or
$ echo "in"> /sys/class/gpio/gpio30/direction
Change the value
$ echo 1 >/sys/class/gpio/gpio30/value
or
$ echo 0 >/sys/class/gpio/gpio30/value
Unexport the GPIO pin
$ echo 30 >/sys/class/gpio/unexport
檢視GPIO被請求的情況
Run these commands for knowing what are theGPIO's already requested in the drivers.
$ mount -t debugfs debugfs /sys/kernel/debug
$ cat /sys/kernel/debug/gpio
檢視裝置號
$ cat /proc/devices
$ mknod /dev/裝置名 c 主裝置號 0
6. 核心原始碼分析網址
http://www.cnblogs.com/zengjfgit/p/4788923.html