here one exercise for free, normally i'll take 1300? + vat per head for it. feel free to wikifi it.
get cygwin setup.exe
http://cygwin.com/setup.exe
######## my setup selection #######
1. Root Directory: E:\cygwin (install for all users)
2. local package directory: E:\cygwin_download
3. direct connect to internet
4. mirror:
http://ftp.gwdg.de
select: gcc4 make libncurses-devel (from devel section, use the install-utility's search function)
wget (section Web) unzip (section Archive) vim (section Editors)
let them install depencies too...
start cygwin (doubleclick desktop shortcut)
check free diskspace with df command:
Dateisystem 1K-Bl?cke Benutzt Verf?gbar Verw% Eingeh?ngt auf
E:/cygwin/bin 10229984 6533416 3696568 64% /usr/bin
E:/cygwin/lib 10229984 6533416 3696568 64% /usr/lib
E:/cygwin 10229984 6533416 3696568 64% /
C: 116984828 108619752 8365076 93% /cygdrive/c
E: 10229984 6533416 3696568 64% /cygdrive/e
create workspace:
get packages: toolchain and kernel sources (ca. 400MB).
http://opensource.samsung.com/ search for toolchain, result -> VDLinux-ARMv7-4.4-202-toolchain-v2r2-20110630.tgz (for e-series)
VDLinux-armv7a8-toolchain-lite_20100630.tgz (for c,d arm based)
toolchain_LN52A650.zip (for a-series)
toolchain_mips24ke_nfp_be.tgz (for mips c-series)
VDLinux-mips34kc-toolchain-lite-20100223.tgz (for mips d-series)
search for UNxxES8xxx.zip and put the stuff into SELP directory.
[privat server start]
wget "
http://hiddenserver/UNxxES8xxx%283%29.zip" -O UNxxES8xxx.zip
wget
http://hiddenserver/VDLinux-ARMv7-4.4-2 ... 110630.tgz
[privat server end]
6464028bf166cf48692e909d1de885e4 *UNxxES8xxx.zip
63bd3f271683f383f59b754c6daaf4c7 *VDLinux-ARMv7-4.4-202-toolchain-v2r2-20110630.tgz
insgesamt 417648
-rw-r--r-- 1 arris69 None 247788490 5. Jan 12:31 UNxxES8xxx.zip
-rw-r--r-- 1 arris69 None 179874293 5. Jan 12:25 VDLinux-ARMv7-4.4-202-toolchain-v2r2-20110630.tgz
Archive: UNxxES8xxx.zip
testing: alsa-lib-1.0.23.tgz OK
...
testing: xfsprogs-3.1.5.tgz OK
No errors detected in compressed data of UNxxES8xxx.zip.
extract kernel sources:
Code: Select all
unzip UNxxES8xxx.zip VDLinux_2.6.35.11.tgz
tar xvzf VDLinux_2.6.35.11.tgz
(now kernel sources are in: ~/SELP/VDLinux_2.6.35.11/linux-2.6.35.11)
extract toolchain:
Code: Select all
tar xvzf VDLinux-ARMv7-4.4-202-toolchain-v2r2-20110630.tgz
!!!!!!!!!!!!! big problem is that my partition not support symlinks !!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!! expect troubles on kernel compile !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
make life easier with some enviroment variables:
Code: Select all
export PATH=$PATH:~/SELP/VDLinux-ARMv7-4.4-202-toolchain-v2r2-20110630/bin
export ARCH=arm
export CROSS_COMPILE=arm-v7a8v2r2-linux-gnueabi-
let see if we have all host tools what we need for kernel compile:
Code: Select all
cd ~/SELP/VDLinux_2.6.35.11/linux-2.6.35.11
cp arch/arm/configs/Echo.P_defconfig_release .config
make menuconfig
you should see funny linux configuration menu, btw. just exit from it (don't save or mess around here...)
now we try to compile one module:
oha, error ->
make: arm-v7a8v2r2-linux-gnueabi-gcc: Kommando nicht gefunden
1. maybe due missing symlinks?
check it:
Code: Select all
ls -l ~/SELP/VDLinux-ARMv7-4.4-202-toolchain-v2r2-20110630/bin/arm-v7a8v2r2-linux-gnueabi-gcc*
-rw-r--r-- 1 arris69 None 448920 28. Jun 2011 /home/arris69/SELP/VDLinux-ARMv7-4.4-202-toolchain-v2r2-20110630/bin/arm-v7a8v2r2-linux-gnueabi-gcc-4.4.1
not so funny, it has version in name and it's not executable, lol never use FAT32 for such things...
so we move to NTFS partition on c: drive:
and fix PATH enviroment variable:
Code: Select all
export PATH=$PATH:/cygdrive/c/SELP/VDLinux-ARMv7-4.4-202-toolchain-v2r2-20110630/bin
and go to new directory:
we make a cleanup there and extract packages again, maybe we can save troubles with symlinks easy.:
Code: Select all
rm -rf VDLinux_2.6.35.11 VDLinux-ARMv7-4.4-202-toolchain-v2r2-20110630
and you can remember what we did before? than again (you can use cursor up button to get prev. commands...):
Code: Select all
tar xvzf VDLinux-ARMv7-4.4-202-toolchain-v2r2-20110630.tgz
we check for symlinks and executable flag:
Code: Select all
ls -l VDLinux-ARMv7-4.4-202-toolchain-v2r2-20110630/bin/arm-v7a8v2r2-linux-gnueabi-gcc*
-rwxr-xr-x 2 arris69 None 448920 28. Jun 2011 VDLinux-ARMv7-4.4-202-toolchain-v2r2-20110630/bin/arm-v7a8v2r2-linux-gnueabi-gcc
-rwxr-xr-x 2 arris69 None 448920 28. Jun 2011 VDLinux-ARMv7-4.4-202-toolchain-v2r2-20110630/bin/arm-v7a8v2r2-linux-gnueabi-gcc-4.4.1
oha, like easter-egg...
extract and check kernel sources again:
Code: Select all
tar xvzf VDLinux_2.6.35.11.tgz
cd VDLinux_2.6.35.11/linux-2.6.35.11
cp arch/arm/configs/Echo.P_defconfig_release .config
make menuconfig (then just exit again, btw. you'll see some warnings, don't care.)
make SUBDIRS=fs/rfs modules
urgh..., error again...
/cygdrive/c/SELP/VDLinux-ARMv7-4.4-202-toolchain-v2r2-20110630/bin/arm-v7a8v2r2-linux-gnueabi-gcc: /cygdrive/c/SELP/VDLinux-ARMv7-4.4-202-toolchain-v2r2-20110630/bin/arm-v7a8v2r2-linux-gnueabi-gcc: Kann die Datei nicht ausf?hren.
strange, it's there and axecutable.... let's check dark magic:
Code: Select all
file /cygdrive/c/SELP/VDLinux-ARMv7-4.4-202-toolchain-v2r2-20110630/bin/arm-v7a8v2r2-linux-gnueabi-gcc
/cygdrive/c/SELP/VDLinux-ARMv7-4.4-202-toolchain-v2r2-20110630/bin/arm-v7a8v2r2-linux-gnueabi-gcc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped
/bin/ls: PE32 executable (console) Intel 80386 (stripped to external PDB), for MS Windows
ok we try toolchain from:
http://sourceforge.net/projects/armlinu ... es/2010q1/
Code: Select all
cd -
wget "http://downloads.sourceforge.net/project/armlinux4cygwin/2010q1/arm-linux-toolchain-cygwin-2010q1.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Farmlinux4cygwin%2Ffiles%2F2010q1%2F&ts=1357391966&use_mirror=ignum" -O arm-linux-toolchain-cygwin-2010q1.tar.bz2
extract it:
Code: Select all
tar xvjf arm-linux-toolchain-cygwin-2010q1.tar.bz2
remove samsung toolchain -> it's unusable for cygwin:
Code: Select all
rm -rf VDLinux-ARMv7-4.4-202-toolchain-v2r2-*
let fix us enviroment variables for the new toolchain (you can also use Ctr-r and start to type export CR, see the magic):
Code: Select all
export CROSS_COMPILE=arm-linux-
export PATH=$PATH:${PWD}/arm-linux/bin
(oha, we use here other variable PWD. nice, isn't it?)
little enviroment check:
/cygdrive/c/SELP/arm-linux/bin/arm-linux-gcc
we start check again to compile a kernel module, but keep in mind we use a different cross-toolchain!!!
Code: Select all
cd VDLinux_2.6.35.11/linux-2.6.35.11
make SUBDIRS=fs/rfs modules
make: arm-v7a8v2r2-linux-gnueabi-gcc: Kommando nicht gefunden
so seems samsung had it hardcoded, but the kernel buildsystem is more powerfull..
Code: Select all
grep arm-v7a8v2r2-linux-gnueabi * .*
.config:CONFIG_CROSS_COMPILE="arm-v7a8v2r2-linux-gnueabi-"
aha, it's set in .config, we can change it with "make menuconfig", but let us try the force of kernel-buildsystem:
Code: Select all
make CONFIG_CROSS_COMPILE=${CROSS_COMPILE} SUBDIRS=fs/rfs modules
uh, some errors:
arm-linux-ld: failed to merge target specific data of file fs/rfs/base/ess_bitmap.o
arm-linux-ld: fs/rfs/rfs_glue.o: Unknown mandatory EABI object attribute 44
we need a toolchain what better match the samsung's version (more exactly the binutils)
before we search the web like stupid we build our own version.
samsung use binutils 2.19, on toolchain from sourceforge we have 2.20.
hm, we build the latest one (just for fun):
Code: Select all
cd -
wget http://ftp.gnu.org/gnu/binutils/binutils-2.23.tar.gz
tar xvzf binutils-2.23.tar.gz
mkdir BUILD_binutils
cd BUILD_binutils
../binutils-2.23/configure --prefix=/cygdrive/c/SELP/arm-linux --target=armv7-a-linux-gnueabi --disable-doc --disable-nls --program-prefix=arm-linux- --enable-install-libiberty
make
install it, save install-logfile if you like to inspect it later:
check the version of ld command:
GNU ld (GNU Binutils) 2.23
so we start again with virgin samsung kernel-sources:
Code: Select all
cd ..
rm -rf VDLinux_2.6.35.11
tar xvzf VDLinux_2.6.35.11.tgz
cd VDLinux_2.6.35.11/linux-2.6.35.11
cp arch/arm/configs/Echo.P_defconfig_release .config
time to change the mental level
if someone (in this case samsung) shipps precompiled object files with the kernel sources, it has to be suffixed as _shipped.
now we fix this (at least for rfs):
Code: Select all
for obj in $(find fs/rfs/ -name "*.o" | grep -v -E "(.mod.|built-in)") ; do mv -vf $obj ${obj}_shipped ; done
instead of make menuconfig we use magic command. kernel need some little helpers...:
Code: Select all
make CONFIG_CROSS_COMPILE=${CROSS_COMPILE} prepare scripts
and try to compile rfs module (again...):
Code: Select all
make CONFIG_CROSS_COMPILE=${CROSS_COMPILE} M=fs/rfs modules
, erros again:
arm-linux-ld: error: Source object fs/rfs/rfs_fat.mod.o has EABI version 0, but target fs/rfs/rfs_fat.ko has EABI version 5
arm-linux-ld: failed to merge target specific data of file fs/rfs/rfs_fat.mod.o
/cygdrive/c/SELP/VDLinux_2.6.35.11/linux-2.6.35.11/scripts/Makefile.modpost:124: recipe for target `fs/rfs/rfs_fat.ko' failed
make[1]: *** [fs/rfs/rfs_fat.ko] Error 1
Makefile:1326: recipe for target `modules' failed
make: *** [modules] Error 2
more cleanup:
Code: Select all
find fs/rfs/ -name "*.o" | grep -E "(.mod.|built-in)" | xargs rm -fv
Code: Select all
make CONFIG_CROSS_COMPILE=${CROSS_COMPILE} M=fs/rfs modules
WARNING: Symbol version dump /cygdrive/c/SELP/VDLinux_2.6.35.11/linux-2.6.35.11/Module.symvers
is missing; modules will have no dependencies and modversions.
LD [M] fs/rfs/rfs_glue.o
LD [M] fs/rfs/rfs_fat.o
Building modules, stage 2.
MODPOST 2 modules
CC fs/rfs/rfs_fat.mod.o
LD [M] fs/rfs/rfs_fat.ko
arm-linux-ld: error: Source object fs/rfs/rfs_fat.mod.o has EABI version 0, but target fs/rfs/rfs_fat.ko has EABI version 5
arm-linux-ld: failed to merge target specific data of file fs/rfs/rfs_fat.mod.o
/cygdrive/c/SELP/VDLinux_2.6.35.11/linux-2.6.35.11/scripts/Makefile.modpost:124: recipe for target `fs/rfs/rfs_fat.ko' failed
make[1]: *** [fs/rfs/rfs_fat.ko] Error 1
Makefile:1326: recipe for target `modules' failed
make: *** [modules] Error 2
what the hell, little check on a linux system:
Code: Select all
export PATH=$PATH:/usr/src/OpenEmbedded/SamsungDTV-SELP/Prebuild/Toolchains/VDLinux-ARMv7-4.4-202-toolchain-v2r2-20110630/bin
make ARCH=arm CONFIG_CROSS_COMPILE=arm-v7a8v2r2-linux-gnueabi- M=fs/rfs modules
Building modules, stage 2.
MODPOST 2 modules
CC fs/rfs/rfs_fat.mod.o
LD [M] fs/rfs/rfs_fat.ko
CC fs/rfs/rfs_glue.mod.o
LD [M] fs/rfs/rfs_glue.ko
so now we know why people cross compile on linux and not on windows...
we go back to our cygwin and try to build all modules:
Code: Select all
make CONFIG_CROSS_COMPILE=${CROSS_COMPILE} modules
CHK include/linux/version.h
CHK include/generated/utsrelease.h
make[1]: ?include/generated/mach-types.h? ist bereits aktualisiert.
CALL scripts/checksyscalls.sh
CC [M] arch/arm/plat-ccep/sdp_mac.o
....
CC fs/rfs/rfs_fat.mod.o
LD [M] fs/rfs/rfs_fat.ko
arm-linux-ld: error: Source object fs/rfs/rfs_fat.mod.o has EABI version 0, but target fs/rfs/rfs_fat.ko has EABI version 5
arm-linux-ld: failed to merge target specific data of file fs/rfs/rfs_fat.mod.o
/cygdrive/c/SELP/VDLinux_2.6.35.11/linux-2.6.35.11/scripts/Makefile.modpost:124: recipe for target `fs/rfs/rfs_fat.ko' failed
make[1]: *** [fs/rfs/rfs_fat.ko] Error 1
Makefile:1053: recipe for target `modules' failed
make: *** [modules] Error 2
oha, we failed again on the rfs module, but others looks good -> lesson learned don't mix object files around different architectures and compilers...
just for fun we try to build the kernel:
Code: Select all
make CONFIG_CROSS_COMPILE=${CROSS_COMPILE} Image
.....
LD vmlinux.o
MODPOST vmlinux.o
WARNING: modpost: Found 1 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
GEN .version
CHK include/generated/compile.h
UPD include/generated/compile.h
CC init/version.o
LD init/built-in.o
LD vmlinux
SYSMAP System.map
OBJCOPY arch/arm/boot/Image
Kernel: arch/arm/boot/Image is ready
hm, no modutils for cygwin???
Code: Select all
wget http://www.kernel.org/pub/linux/utils/kernel/module-init-tools/module-init-tools-3.7.tar.gz
tar xvzf module-init-tools-3.7.tar.gz
mkdir BUILD_modutils
cd BUILD_modutils
DOCBOOKTOMAN=true ../module-init-tools-3.7/configure --prefix=/usr
....
configure: error: Linux only, dude!
just fun today!!!
but we can use other tools
:
Code: Select all
strings drivers/usb/storage/usb-storage.ko | grep -i -E "(depe|verm)"
depends=usbcore
vermagic=0079, release SMP preempt mod_unload ARMv7
last exercise for today, own kernel module build outside of kernel dir.
let's take this one:
viewtopic.php?f=50&t=5230#p38377
one line command sample:
Code: Select all
cd /cygdrive/c/SELP ; mkdir testmod && cd testmod
vi hellok1.c -> and insert code from forum
vi Makefile -> insert following code:
Code: Select all
ifneq ($(KERNELRELEASE),)
obj-m += hellok1.o
else
KERNELDIR = /cygdrive/d/zarm/vdl_kernel/linux/linux-2.6.35.11
all:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
Code: Select all
make CONFIG_CROSS_COMPILE=${CROSS_COMPILE} KERNELDIR=/cygdrive/c/SELP/VDLinux_2.6.35.11/linux-2.6.35.11
make -C /cygdrive/c/SELP/VDLinux_2.6.35.11/linux-2.6.35.11 M=/cygdrive/c/SELP/testmod modules
make[1]: Entering directory `/cygdrive/c/SELP/VDLinux_2.6.35.11/linux-2.6.35.11'
CC [M] /cygdrive/c/SELP/testmod/hellok1.o
Building modules, stage 2.
MODPOST 1 modules
CC /cygdrive/c/SELP/testmod/hellok1.mod.o
LD [M] /cygdrive/c/SELP/testmod/hellok1.ko
make[1]: Leaving directory `/cygdrive/c/SELP/VDLinux_2.6.35.11/linux-2.6.35.11'
check the resulting file:
hellok1.ko: ELF 32-bit LSB relocatable, ARM, version 1, BuildID[sha1]=0xc3f3c07f14a498a29f665d74cf2ee334ecde3e35, not stripped
Code: Select all
strings hellok1.ko | grep -i -E "(depe|verm)"
depends=
vermagic=0079, release SMP preempt mod_unload ARMv7
end of lesson, no need to mess around in kernel sources and kill kernels build-system or change anything in kernels Makefile