本文均属自己阅读源码的点滴总结,转账请注明出处谢谢。
欢迎和大家交流。qq:1037701636 email:[email protected],[email protected]
本来昨天就该写点总结的,可是一天的时间都去参加党员培训了。总觉得,在做一些新事情后,需要对所学到的新事物,新东西做一个总结,即使对自己学习的一个梳理,也方便以后深入的研究。最近在对Beagleboard-xm 板子做一定的学习,打算将TI的dvsdk移植到bb-xm上去。在这里先从对Bb-xm介绍开始。
bb-xm (详细的资料见官网:狗骨头网http://beagleboard.org/),以一只小狗狗为标记。现在还出现了omap4处理器的熊猫网.bb-xm的大体内容如下:
#--------------------- Location Check ---------------------
# Simple test to see if script is being run from top of DVSDK install directory
if [ -e Makefile ] && [ -e Rules.make ]
then
echo Makefile and Rules.make found... continuing...
else
echo Please run script from root of DVSDK installation
exit
fi
#--------------------- PSP DIRECTORY ---------------------
# Backup EVM files inside PSP directory and softlink the 'prebuilt-images' (which don't exist yet).
cd psp
mkdir evm
mv linux-2.6.32-psp03.00.01.06 evm
mv u-boot-2009.11-psp03.00.01.06 evm
mv x-load-1.46-psp03.00.01.06 evm
mv prebuilt-images evm
mkdir prebuilt-images
cd prebuilt-images
ln -s ../x-load-beagle/x-load.bin.ift MLO
ln -s ../u-boot-beagle/u-boot.bin
ln -s ../linux-beagle/arch/arm/boot/uImage
cd ..
#--------------------- PROXY SETUP ---------------------
# Comment out these 4 lines if you have direct internet connection
#PROXYHOST="foo.com"
#PROXYPORT="80"
#export http_proxy="http://${PROXYHOST}:${PROXYPORT}"
#export GIT_PROXY_COMMAND=./git-proxy.sh
# Generate git proxy command config script
cat > git-proxy.sh <<_EOF
if [ -x /bin/env ] ; then
exec /bin/env corkscrew ${PROXYHOST} ${PROXYPORT} \$*
else
exec /usr/bin/env corkscrew ${PROXYHOST} ${PROXYPORT} \$*
fi
_EOF
chmod +x git-proxy.sh
在这部分内容里,我们可以知道补丁脚本主要针对linux kernel uboot xload进行相应的操作。这里他将dvsdk原装的这3个文件进行保留,同时会在prebuilt-image文件中做3个软连接,指向的内容分别是3个文件编译后形成的镜像文件。此外还创建git,使用git来下载3个全新的文件。#--------------------- X-LOAD ---------------------
# These are the files to build first level loader (x-load)
XLOADPREFIX="http://cgit.openembedded.org/cgit.cgi/openembedded/plain/recipes/x-load/x-load-git/beagleboard"
# from http://cgit.openembedded.org/cgit.cgi/openembedded/tree/recipes/x-load/x-load_git.bb
XLOADPATCHES="\
file://name.patch \
file://bb8547fcbc54ecc7a75f9ad45a31042a04d8a2ce.patch \
file://xm-mem.patch \
file://0001-Fix-reading-FAT32-root-dirs-that-span-1-cluster.patch \
"
# Strip off 'file://'
XLOADPATCHESSTRIPPED=$(echo $XLOADPATCHES | sed s!file://!!g)
# Clone the base x-load repository
git clone git://gitorious.org/x-load-omap3/mainline.git x-load-beagle
cd x-load-beagle
git checkout -b beagle 1c9276af4d6a5b7014a7630a1abeddf3b3177563
# Fetch the patches
mkdir oepatches ; pushd oepatches
for patchfile in ${XLOADPATCHESSTRIPPED} ; do
wget $XLOADPREFIX/$patchfile
done
popd
# One of the x-load patches doesn't have author header - add 'unknown' author, so that it can be applied
cat > oepatches/header.txt <<_EOF
From: anon <anon>
Subject: [PATCH] Change config name
_EOF
cat oepatches/header.txt oepatches/name.patch > oepatches/temp
cp oepatches/temp oepatches/name.patch
# Apply the patches to the local repository
for patchfile in ${XLOADPATCHESSTRIPPED} ; do
# git am oepatches/$patchfile
git am --abort
git apply oepatches/$patchfile
done
cd ..
在这个脚本中,可以依稀看到,使用git clone下载x-load-beagle这套源码,此外根据补丁文件的个数使用wget命令获得patch,最后使用git am命令完成所有的打补丁操作。这里可以看出linux内核系统的基于git的仓库管理机制repository。方便的完成内核的升级。#--------------------- Rules.make ---------------------
# Backup Rules.make
cp Rules.make Rules.make.org
# Replace path to linux kernel
# Don't need to replace paths for x-load and u-boot, since these are handled using wildcards in Makefile instead of full path
sed -i -e s:linux-2.6.32-psp03.00.01.06:linux-beagle:g Rules.make
#--------------------- Makefile ---------------------
# Backup Makefile
cp Makefile Makefile.org
# Replace configs for x-load/u-boot/kernel
sed -i -e s:omap3_evm_defconfig:omap3_beagle_angstrom_defconfig:g Makefile
sed -i -e s:omap3_evm_config:omap3_beagle_config:g Makefile
sed -i -e s:omap3evm_config:beagleboard_config:g Makefile
# Remove subdirectory used for opengl demos and install these files directly to the fs root
# - different versions due to different brackets used in Makefile
sed -i -e s:{EXEC_DIR}/opengl-demos:{EXEC_DIR}:g Makefile
sed -i -e s:\(EXEC_DIR\)/opengl-demos:\(EXEC_DIR\):g Makefile
# Add parallel make for x-load/u-boot/kernel (those which use ARCH flag)
sed -i -e s:ARCH\=:-j8\ ARCH\=:g Makefile
# Re-order the install targets to install opengldemos before cmem, else manually installed modules will be removed by kernel MOD_INSTALL
sed -i -e s:sdma_install\ opengldemos_install\ ceexamples_install:sdma_install\ ceexamples_install:g Makefile
sed -i -e s:linux_install\ cmem_install:linux_install\ opengldemos_install\ cmem_install:g Makefile
# Add new make target to move graphics modules into lib/modules and run depmod
cat >> Makefile <<_EOF
depmod_install: install
cp -a \$(EXEC_DIR)/opt/gfxlibraries/gfx_rel_es5.x/*.ko \$(EXEC_DIR)/lib/modules/\$(KERNEL_VERSION)/kernel
depmod -a -b \$(EXEC_DIR) \$(KERNEL_VERSION)
sed -i \$(EXEC_DIR)/lib/modules/\$(KERNEL_VERSION)/modules.dep -e s:kernel:/lib/modules/\$(KERNEL_VERSION)/kernel:g
_EOF
#--------------------- powervr.ini ---------------------
# Change target graphics config to use double buffered WSEGL driver (FLIP) - slower screen updates, but avoids tearing artifacts
sed -i -e s:FRONT:FLIP:g ./omap35x_graphics_sdk_4.00.00.01/targetfs/powervr.ini
在这里,我们可以发现主要对Rules.make,Makefile的部分基础配置进行了修改。使用sed shell脚本命令,将原先为配置给EVM板的配置文件,修改为Bbeagleboard的内容。
sed -i -e s:omap3_evm_defconfig:omap3_beagle_angstrom_defconfig:g Makefile
sed -i -e s:omap3_evm_config:omap3_beagle_config:g Makefile
sed -i -e s:omap3evm_config:beagleboard_config:g Makefile
#--------------------- mksdboot.sh ---------------------
# Backup SD card creation script
cp bin/mksdboot.sh bin/mksdboot.sh.org
# Replace serial port config passed to kernel for console
sed -i -e s:ttyS0:ttyS2:g bin/mksdboot.sh
# Increase available memory config passed to kernel to use additional 256MB available on -xM
sed -i -e s:128M@:384M@:g bin/mksdboot.sh
# Change display driver config passed to kernel to use 720P60 display timings
sed -i -e s:1280x720@60:hd720:g bin/mksdboot.sh
# Increase framebuffer0 memory allocation passed to kernel (to allow use of double buffered mode by graphics config)
sed -i -e s^vram=0:4M^vram=0:8M^g bin/mksdboot.sh
# Increase overall framebuffer memory allocation passed to kernel
sed -i -e s^vram=4M^vram=8M^g bin/mksdboot.sh
# Remove user prompt for selection of LCD/DVI and hardcode to DVI, since only DVI available on base -xM
sed -i -e '/read\ -p/d' bin/mksdboot.sh
sed -i -e s:display\=\"1\":display\=\"2\":g bin/mksdboot.sh
# Modify TargetFS and Force make-install when creating SD card
# - replace alsa config file
# - configure serial console
# - switch ethernet from eth0 to usb0
# - change hostname for quick visual indication of modified FS
cat >> bin/mksdboot.sh <<_EOF
echo "Updating FS with modified beagleboard-xM files"
execute "mkdir -p /tmp/sdk/\$\$"
execute "mount \${device}2 /tmp/sdk/\$\$"
execute "cp \$sdkdir/psp/asound.state.beagle /tmp/sdk/\$\$/etc/asound.state"
execute "sed -i -e s:ttyS0:ttyS2:g /tmp/sdk/\$\$/etc/inittab"
execute "sed -i -e s:usb0:usb1:g /tmp/sdk/\$\$/etc/network/interfaces"
execute "sed -i -e s:eth0:usb0:g /tmp/sdk/\$\$/etc/network/interfaces"
execute "sed -i -e s:dm37x-evm:beagleboard-dvsdk:g /tmp/sdk/\$\$/etc/hostname"
execute "pushd \$sdkdir"
execute "cp Rules.make Rules.make.sdbak"
echo EXEC_DIR=/tmp/sdk/\$\$ >> Rules.make
execute "make depmod_install"
execute "cp Rules.make.sdbak Rules.make"
execute "popd"
sync
echo "unmounting \${device}2"
execute "umount /tmp/sdk/\$\$"
echo "Done"
_EOF
这部分的内容,主要是在sd卡的配置,从上往下以此是consloe的输出端口,mem内存,framebuffer 分配)这些内容主要是修改uboot的bootargs参数即内核启动时,从uboot处获得的启动参数。