| 1 |
TS-7400 Development Setup |
|---|
| 2 |
|
|---|
| 3 |
See also, http://www.embeddedlinuxinterfacing.com/trac/wiki/TS7400 |
|---|
| 4 |
|
|---|
| 5 |
The ts7400 can boot an SD card running debian ARM, which is great because you can |
|---|
| 6 |
natively compile your applications and kernel modules without fooling around with |
|---|
| 7 |
cross-compilation. In order to compile your modules, you need a 'configured' |
|---|
| 8 |
kernel source tree that matches your running board. Unfortunately, the virgin |
|---|
| 9 |
TS SD card is quite full with no room for extracted kernel source. We'll need |
|---|
| 10 |
to NFS mount a dir that contains the ts kernel source. |
|---|
| 11 |
|
|---|
| 12 |
Hardware Setup |
|---|
| 13 |
* 7400 with 9441 for console |
|---|
| 14 |
* 512MD SD card with Debian Root Filesystem |
|---|
| 15 |
* Connect null-RS232 cable between 9441 and desktop |
|---|
| 16 |
* Connect 7400 to ethernet switch |
|---|
| 17 |
* Linux desktop with minicom and NFS server running |
|---|
| 18 |
* Changing 7400 to boot the SD card |
|---|
| 19 |
* fast boot 7400, using desktop minicom |
|---|
| 20 |
* cd / |
|---|
| 21 |
* ln -sf linuxrc-sdroot linuxrc |
|---|
| 22 |
* save |
|---|
| 23 |
* rm /fastboot |
|---|
| 24 |
* Once booted to SD card's debian |
|---|
| 25 |
* change 7400 ip address in /etc/network/interfaces |
|---|
| 26 |
* add your desktop's ip to /etc/hosts |
|---|
| 27 |
|
|---|
| 28 |
Native Kernel Module Development Setup |
|---|
| 29 |
* Kernel source setup |
|---|
| 30 |
* desktop: add 7400 ip address to /etc/hosts with hostname 'ts7400' |
|---|
| 31 |
* desktop: add '/usr/src ts7400(rw,no_root_squash,async,subtree_check)' to /etc/exports, exportfs -a |
|---|
| 32 |
* 7400: get your kernel version with uname -r, mine is 2.4.26-ts11 |
|---|
| 33 |
* desktop: extract the ts kernel tarball into /usr/src, should leave a linux24 directory |
|---|
| 34 |
* 7400: mount -tnfs desktop:/usr/src /usr/src |
|---|
| 35 |
* we're NFS mounting the ts7000 kernel source, not enough space on SD for extracted version |
|---|
| 36 |
* 7400: cd /usr/src; ln -s linux24 linux |
|---|
| 37 |
* 7400: cd /usr/src/linux |
|---|
| 38 |
* 7400: edit Makefile and undef the CROSS_COMPILE = |
|---|
| 39 |
* remove everything after the '=' char |
|---|
| 40 |
* 7400: cp arch/arm/def-configs/ts7400 .config |
|---|
| 41 |
* 7400: ln -sf /usr/bin/gcc-3.3 /usr/bin/gcc |
|---|
| 42 |
* The sd card uses gcc 4.1x, had past issues with 4.x using 3.3 instead |
|---|
| 43 |
* 7400: make oldconfig |
|---|
| 44 |
* 7400: make dep |
|---|
| 45 |
* Coffee/Coke break, this takes a while |
|---|
| 46 |
* Your 7400 can now compile kernel modules |
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
From this point on, execute commands on the 7400. |
|---|
| 52 |
|
|---|
| 53 |
Checkout my module source |
|---|
| 54 |
* apt-get install subversion |
|---|
| 55 |
* svn co http://embeddedlinuxinterfacing.com/svn/elhsi/boards/ts7400/src /root/src |
|---|
| 56 |
* /root/src contains modules userspace |
|---|
| 57 |
|
|---|
| 58 |
Module template file |
|---|
| 59 |
* All my example modules start from 00-template.c |
|---|
| 60 |
* 00-template.c |
|---|
| 61 |
* contains functions init and cleanup |
|---|
| 62 |
* contains macros for MODULENAME and AUTHORNAME |
|---|
| 63 |
* defines GPL license |
|---|
| 64 |
* uses printk, run dmesg to see output |
|---|
| 65 |
|
|---|
| 66 |
Compiling modules |
|---|
| 67 |
* If all is well 'make' should compile your modules |
|---|
| 68 |
* if you have errors, make sure your build symlink point to the NFS kernel source |
|---|
| 69 |
* root@ts7000[29]: ls -als /lib/modules/2.4.26-ts11/build |
|---|
| 70 |
* 0 lrwxrwxrwx 1 root root 14 May 29 04:23 /lib/modules/2.4.26-ts11/build -> /usr/src/linux |
|---|
| 71 |
|
|---|
| 72 |
00-template.c |
|---|
| 73 |
A simple template file for module development. |
|---|
| 74 |
|
|---|
| 75 |
01-prochelloworld.c |
|---|
| 76 |
Dynamically creates r/w file /proc/helloworld during insmod. Stores 8 incoming |
|---|
| 77 |
chars during write and returns them on read. |
|---|
| 78 |
|
|---|
| 79 |
02-led.c |
|---|
| 80 |
Turns board LEDs on during insmod and off during rmmod |
|---|
| 81 |
|
|---|
| 82 |
03-hwtimerinterruptled.c |
|---|
| 83 |
Blink LED at CPU 1Hz timer via interrupt 42 |
|---|
| 84 |
|
|---|
| 85 |
04-ioremapTShwmodel.c |
|---|
| 86 |
Reports the TS model identification |
|---|
| 87 |
|
|---|
| 88 |
05-hwtimerinterruptgpio.c |
|---|
| 89 |
Toggle DIO_0-7 at CPU 1Hz timer via interrupt 42 |
|---|
| 90 |
|
|---|
| 91 |
06-hwtimer2.c |
|---|
| 92 |
Get 10000 interrupts per second. |
|---|
| 93 |
|
|---|
| 94 |
07-gpbusinterrupt.c |
|---|
| 95 |
GPBUS external interrupt example. |
|---|
| 96 |
|
|---|
| 97 |
07-gpbusinterruptdio00set.c |
|---|
| 98 |
Sets dio00 on insmod, clears dio00 on rmmod |
|---|
| 99 |
|
|---|
| 100 |
07-gpbusinterruptsoftwareinterrupt.c |
|---|
| 101 |
Sets soft interrupt 33 |
|---|
| 102 |
|
|---|
| 103 |
08-portbinterrupt.c |
|---|
| 104 |
port B interrupt example. |
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
Is your 7400 to slow to compile modules? |
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
Cross Compile Kernel Module Development Setup |
|---|
| 119 |
* 7400: cat /proc/version to determine kernel version and gcc version that compiled it |
|---|
| 120 |
Linux version 2.4.26-ts11 (root@construct) (gcc version 3.3.4) #35 Thu Jul 6 15:44:29 MST 2006 |
|---|
| 121 |
^^^^^^^^^^^ ^^^^^ |
|---|
| 122 |
* you'll need to match both kernel source and gcc version for your modules to insert properly |
|---|
| 123 |
* we'll being using /tmp for this work, just in case something goes wrong, we won't screw up the desktop filesystem. |
|---|
| 124 |
* on desktop, download kernel source and cross-toolchain |
|---|
| 125 |
* cd /tmp |
|---|
| 126 |
* wget ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7400-linux/sources/tskernel-2.4.26-ts11-src.tar.gz |
|---|
| 127 |
^^^^^^^^^^^ |
|---|
| 128 |
* wget ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7400-linux/cross-toolchains/crosstool-linux-gcc-3.3.4-glibc-2.3.2-0.28rc39.tar.bz2 |
|---|
| 129 |
^^^^^ |
|---|
| 130 |
* tar zxvf tskernel-2.4.26-ts11-src.tar.gz |
|---|
| 131 |
* ln -sf linux24 linux |
|---|
| 132 |
* mkdir cross |
|---|
| 133 |
* cd cross |
|---|
| 134 |
* tar jxvf ../crosstool-linux-gcc-3.3.4-glibc-2.3.2-0.28rc39.tar.bz2 |
|---|
| 135 |
* you should now have unconfigured kernel source in /tmp/linux and cross toolchain in /tmp/cross |
|---|
| 136 |
* configuring the kernel source |
|---|
| 137 |
* cd /tmp/linux |
|---|
| 138 |
* edit Makefile, changing the CROSS_COMPILE def to |
|---|
| 139 |
CROSS_COMPILE = /tmp/cross/usr/local/opt/crosstool/arm-linux/gcc-3.3.4-glibc-2.3.2/bin/arm-linux- |
|---|
| 140 |
* cp arch/arm/def-configs/ts7400 .config |
|---|
| 141 |
* make oldconfig |
|---|
| 142 |
* make dep |
|---|
| 143 |
* you can now cross compile your kernel with |
|---|
| 144 |
* make ( or 'make -j 4' if have multi-core CPU :-) ) |
|---|
| 145 |
* you can now cross compile your kernel module with |
|---|
| 146 |
* make modules |
|---|
| 147 |
|
|---|
| 148 |
Cross Compiling My TS7400 Modules on Desktop |
|---|
| 149 |
* checkout my source |
|---|
| 150 |
* svn co http://embeddedlinuxinterfacing.com/svn/elhsi/boards/ts7400/src /tmp/src |
|---|
| 151 |
* cross compile my modules by overriding CC and INCLUDE Makefile defs |
|---|
| 152 |
* cd /tmp/src |
|---|
| 153 |
* make CC=/tmp/cross/usr/local/opt/crosstool/arm-linux/gcc-3.3.4-glibc-2.3.2/bin/arm-linux-gcc INCLUDE=-I/tmp/linux/include |
|---|
| 154 |
* check the compilation using 'file' |
|---|
| 155 |
* holla@frampton[548]: file 01-prochelloworld.o |
|---|
| 156 |
01-prochelloworld.o: ELF 32-bit LSB relocatable, ARM, version 1 (ARM), not stripped |
|---|
| 157 |
* congratulations! it's for ARM |
|---|
| 158 |
* At this point, you can figure out how to get *.o onto your 7400 |
|---|
| 159 |
|
|---|
| 160 |
|
|---|