RMLL 2009 Hello thank you for coming
Plug it and play with U S B - A 9 2 6 0 Pascal Fougeray IUT of caen http://www.iutc3.unicaen.fr/~fougep/prise_en_main/ 2
Teach embedded systems to First-year university student, with PC running Linux (Ubuntu, Fedora...) USB-a9260 key, World Wide Web..., This book, => And... 3
Before... Students know Linux, Shell, Beginners in C programming, Network, TCP/IP, English, World Wide Web,... 4
Outline About Calao-Systems & USB-A9260 key, Tools to work, 1st pratical : Reset board & SAM-BA, 2nd pratical : Discover Buildroot, 3rd pratical : Compilation of Toolchain, Rootfs, Kernel basics => make 2h :) 4th pratical : Kernel/TFTP, Rootfs/NFS & U-boot configuration, 5th pratical : Cross Compilation, RISC vs CISC, 6th pratical : Patch, Upgrade, Configure, Compile kernel, 7th pratical : Lighttpd, SQLITE, PHP & PHPsysinfo, 8th pratical : RT kernel with Xenomaï patch, 9th pratical : GPRS/SMS daugher board, Conclusion. 5
About Calao-systems (0) CALAO Systems was founded in 2007 by a group of engineers with a specialized expertise in embedded computers. Headquarter is located near Grenoble in the French Alps, a leading region in micro / nanotechnologies and embedded software. CALAO Systems proposes inovative solutions for ARM based embedded computers. These solutions are particularly well adapted for microcontroller type applications up to leading edge mulitmedia performances. Evaluation and development kits are also proposed with free GNU toolchain and a ready to install Linux kernel with a pre-installed file system. The developped software can easily be ported on kits that are dedicated to small or medium manufacturing batch. CALAO Systems proposes these kits «on the shelves» or customization services. By choosing ARM core and standard development tools and operating systems, CALAO Systems' customers fully own their assets and warranty their strategic independance. 6
About Calao-systems (1) www.calao-systems.com7
USB-A9260 key (0) Embedded Computer with USB form-factor (36x85 mm), ATMEL AT91SAM9260 @ 180MHz, 256MB NAND Flash (8bits), 64MB SDRAM (32bits @ 90MHz), 64Kbits serial SPI EEPROM, U-Boot env, 1x50 pins connector (I2C, SPI, USART, SSC, MCI, ISI, TC), Ethernet 10/100base Tx port, 2 USB Host port interfaces, 1 USB Device port interface, 1 USB Debug (Serial DBGU + JTAG + Power Supply), 1 reset button and 1 user button, 2 leds, Software : U-Boot & Linux 2.6. 8
SDRAM Flash EEPROM Memory Memory Memory USB A9260 key (1) JTAG/USB +5V USB Device Reset & users 2*USB AT91SAM9260 buttons host Atmel µc Serial/USB Driver FTDI 50 pins Driver Ethernet Connector Ethernet 10/100 9
Tools to work... USB-A9260 key, TARGET, PC with Ubuntu 8.10 or other, HOST, A PC with : 2 USB connects : 1 for Alim & to connect the TARGET with GTKterm, 1 for SAM-BA & use TCP/IP over USB, 1 Ethernet port, 6GB free on the Host hard disk. Ethernet cable, usb cable A & B, Software for development, binutils, gcc, glibc development files, ncurses, zlib, texinfo, TCL/TK,... The tar.gz file from Calao usb-a9260-buildroot-20080229.tar.gz... 10
We use it for the first time We use GTKterm to log it We configure it : 115200,8,n,1 /dev/ttyusbn Now we are ready to use the USB-A9260 key!!! We can boot linux USB-A9260> boot At the login prompt we type : uclibc login : root We can use linux and the students can play with 11
1st : SAM-BA (0) Goal : Students understand the utility of each file and know the memory map. Reset Board, press 2 buttons reset and users during 3s, after that, the first sector of the flash memory is empty. Prompt begin : RomBOOT> On the Host, install SAM-BA (file readme) Install modules Rmmod ftdi_sio ( GTKterm must be closed ) Rmmod usbserial (since 2.6.28, it's not a module, you have to compile kernel... on Debian not for Fedora...) Modprobe usbserial vendor=0x03eb product=0x6124 SAM Boot Assistant : http://www.atmel.com/dyn/resources/prod_documents/doc6132.pdf 12
1st : SAM-BA (1) With SAM-BA software, we load 4 files in flash memory Second Partition /dev/mtdblock2 120Mo First Partition /dev/mtdblock1 120Mo 1. Bootstrap : Nandflash_usb-a9260.bin at @ 0x0, 0x8800000 2. BootLoader : u-boot.bin at @ 0x20000, 3. Kernel : uimage.bin at @ 0x400000, 0x1000000 Kernel uimage 0x400000 to 0x1000000 0x400000 U-Boot 0x20000 to 0x400000 Nand-flash O to 0x20000 0x20000 4. Root Filesystem : rootfs.arm-xxxxxxxx.jffs2 at @ 0x1000000 or 0x8000000 At the address 0xA0000, We have a second kernel with Ramdisk 0x0 Now, students know the utility of each file. 13
1 st : SAM-BA (2) Type of Memory Flash Select file To send Click here to send file Select Address 0x0, 0x20000, 0x400000,... 14 http://www.linux4sam.org/twiki/bin/view/linux4sam/softwaretools
2 nd : Discover Buildroot Goals : Students discover the architecture of Buildroot, the differents directories, the Makefile... They uncompress tar.gz file, # /buildroot/tar xvzf../usb-a9260-buildrootxxxxxxxx.tar.gz They read some Buildroot Makefiles... They examine some files as Config.in and package_name.mk of some packages. They read Buildroot documentation : http://buildroot.uclibc.org/buildroot.html They begin compilation pratical... 15
3rd : Compilation of Toolchain, Rootfs & Kernel basics (0) Goals : the students will be able to compile the Toolchain, the Rootfs and the Kernel, They learn to install the tools, to configure and deploy the elements of our development system on the host : binutils, gcc, glibc development files, ncurses, zlib, texinfo, TCL/TK,... mkimage static program from http://www.linux4sam.org/twiki/bin/view/linux4sam/softwaretools#mkimage_u_boot They uncompress tar.gz file, # /buildroot/tar xvzf../usb-a9260-buildroot-xxxxxxxx.tar.gz They examine the differents directories, They type make menuconfig and unselect packages as jamvm, classpath to do faster the compilation. 16 After this first compilation of Buildroot, they add other packages.
3rd : Compilation of Toolchain, Rootfs & Kernel basics (1) Start compilation process (use several jobs) and save all messages on stdout # time make tee success.txt During the compilation time, they examine the process. When the compilation is finish, they discover Toolchain, Rootfs & Kernel inside the directories /buildroot/build_arm/staging_dir /buildroot/project_build_arm/usb-a9260/root or /buildroot/binaries/usb-a9260/rootfs.arm-xxxxxx.jffs2 /buildroot/project_build_arm/usb-a9260/linux-2.6.xx/arch/arm/boot/uimage We don't use SAM-BA, because it is too long The next pratical is TFTP and NFS... 17
4 th : TFTP & NFS (0) Goals : Students learn to use some networks services & modify U-Boot environment variables. Modify U-Boot environment variables : bootargs & bootcmd Load files with U-Boot via Ethernet and TFTP, Mount remote directories and access the contents as if the file system was mounted locally, Verify the Kernel configuration of the Target File systems ---> Network File Systems ---> [*] NFS file system support [*] Provide NFSv3 client support The Kernel is downloaded via TFTP, The root filesystem is mounted via NFS, This allows you to quickly make changes to the root filesystem without lengthy reflashing cycles to the device. 18
4 th : TFTP & NFS (1) The kernel is downloaded via TFTP Modify the U-Boot's environment variable : bootcmd USB-A9260> setenv bootcmd tftpboot 21000000 uimage The uimage file must be put in /var/lib/tftpboot directory of the HOST The Host must have same @IP that @IP that U-Boot's environment variable serverip, Install & configure TFTP server on the HOST Tftpd-hpa, /etc/inetd.conf tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot Test it 19
4 th : TFTP & NFS (2) The Target's / directory is mounted in NFS Modify the U-Boot's environment variable : bootargs USB-A9260> setenv bootargs=mem=64m rootfstype=nfs root=/dev/nfs console=ttys0,115200 nfsroot=192.168.2.102:/var/lib/nfs/root ip=192.168.2.101:192.168.2.102:192.168.2.102:255.255.255.0::eth0:on The definition of bootargs can be found in the sources of the kernel. It's the file kernel_sources/documentation/filesystems/nfsroot.txt Verify that the Kernel is ok to mount a NFS directory # cat /proc/filesystems 20
4 th : TFTP & NFS (3) The Target's / directory is mounted in NFS Install & configure NFS server on the Host Complete the following files : /etc/hosts.deny, /etc/hosts.allow, /etc/exports : /var/lib/nfs/root 192.168.2.0/24 (rw,sync,subtree_check,no_root_squash) Copy the root directory from Buildroot to export directory cp -dprf /buildroot/project_build_arm/usb-a9260/root/ /var/lib/nfs The Host must have the same @IP than @IP of the U-Boot's environment variable serverip. 21
4 th : TFTP & NFS (4) HOST @IP 192.169.2.102 TARGET @IP 192.169.2.101 USB : GTKTerm Ethernet ETH0 TFTP : Download uimage file to SDRAM & execute it NFS : /var/lib/nfs/root mount /dev/nfs & access it After the pratical, the students will be able to work faster and to modify easily the root filesystem. 22
5 th : Cross Compilation (0) Goals : Students learn & understand the cross compilation, after they can use it to compile the Kernel and an other application Usually, software development is done on a Host computer using a cross-compilation toolchain. This toolchain is built automatically when you use Buildroot, We modify the environment variable : PATH # export PATH=$PATH:/buildroot/build_arm/staging_dir/usr/bin/ We write a program and compile it with gcc for I386 arm-uclibc-gcc for Arm We compare the 2 binaries with file command 23
5 th : Cross Compilation (1) We develop & compile the program on the HOST GCC & arm-linux-uclibc-gcc Program run on the Target 24
5 th : Cross Compilation (2) # arm-linux-gcc -v Using built-in specs. Target: arm-linux-uclibc Configured with: /buildroot/toolchain_build_arm/gcc-4.2.1/configure -prefix=/usr -build=i386-pc-linux-gnu -host=i386-pc-linux-gnu -target=arm-linux-uclibc -enable-languages=c,c++-with-sysroot=/buildroot/build_arm/staging_dir -with-build-time tools=/buildroot/build_arm/staging_dir/usr/arm-linux-uclibc/bin -disable- cxa_atexit -enable-targetoptspace -with-gnu-ld -enable-shared -with-gmp=/buildroot/toolchain_build_arm/gmp -with -mpfr=/buildroot/toolchain_build_arm/mpfr -disable-nls -enable-threads -disable-multilib -withtune=arm9tdmi Thread model: posix gcc version 4.2.1 # gcc -v Utilisation des specs internes. Target: i486-linux-gnu Configuré avec:../src/configure -v -with-pkgversion='ubuntu 4.3.2-1ubuntu11' -with-bugurl=file:///usr/share/doc/gcc-4.3/readme.bugs -enable-languages=c,c++,fortran,objc,obj-c++ -prefix=/usr -enable-shared -with-system-zlib -libexecdir=/usr/lib -without-included-gettext -enable-threads=posix -enable-nls -with-gxx-include-dir=/usr/include/c++/4.3 -program-suffix=-4.3 -enable-clocale=gnu -enable-libstdcxx-debug -enable-objc-gc -enable-mpfr -enable-targets=all -enable-checking=release -build=i486-linux-gnu -host=i486-linux-gnu -target=i486-linux-gnu Modèle de thread: posix gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu11) 25
5 th : Cross Compilation (3) # file hello_host hello_host: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, not stripped # file hello_target hello_target: ELF 32-bit LSB executable, ARM, version 1, dynamically linked (uses shared libs), not stripped We can also compare the processors CISC (Complex Instruction Set Computer) with the processors RISC (Reduce Instruction Set Computer ) by using the commands : # gcc S file.c o file_x386.s # arm-uclibc-gcc S file.c o file_arm.s to generate files in language of assembly and so to notice the difference between the 2 languages. We can also use the command objdump. 26
6 Th : kernel (0) Goals : Students learn to configure, to upgrade, to patch & to compile a kernel. We already compiled a kernel 2.6.23 version from basics files with : the patch from Calao : calao.patch the Linux kernel patch for the Atmel ARM9 & maintained by Andrew Victor : 2.6.23-at91.patch.gz http://maxim.org.za/at91_26.html during the 3rd pratical : Compilation of Toolchain, Rootfs & Kernel. 27
6 Th : kernel (1) 2 ways to proceed 1. We stay in /Buildroot directory and we use the commands # make linux26-menuconfig to configure it # make linux26 to compile it 2. We move to /Buildroot/project_build_arm/usb-a9260/linux-2.6.xx and we modify the environment variable : PATH # export PATH=$PATH:/buildroot/build_arm/staging_dir/usr/bin/ and we use the commands # make ARCH=arm menuconfig to configure it # make ARCH=arm CROSS_COMPILE=arm-linux-uclibc- to compile it I'd rather the second way. It's more pedagogical & students use their knowledge acquired in previous practical work :) 28
6 Th : kernel (2) Goals : Students learn to add some modules with the kernel and to use the module commands The module can be an USB/Ethernet Gadget drivers, Prolific PL2303 USB to serial adaptor driver... We added some modules to the kernel, and now, it's possible to insert, to remove it with the commands : modprobe, insmod, rmmod... 29
6 Th : kernel (3) We select the corresponding module We save the configuation We compile the kernel and the modules We test it 30
6 Th : kernel (4) Goals : Students understand the utility of a Ramdisk When you get the USB-a9260 key, in the second place of the flash memory, at the address A0000, we have a kernel with a Ramdisk The students configure the kernel and they obtain a new bigger kernel. With SAM-BA we can install this new kernel in the flash memory at the adress A0000 but the best way is to use again tftpboot. The students reboot the board and in U-Boot type command : USB-A9260> tftpboot 21000000 uimage_with_ramdisk 31
6 Th : kernel (5) Kernel without ramdisk # mount rootfs on / type rootfs (rw) /dev/root on / type jffs2 (rw) <- different proc on /proc type proc (rw) devpts on /dev/pts type devpts (rw) tmpfs on /tmp type tmpfs (rw) # df -h Filesystem Size Used Available Use% rootfs 120.0M 20.7M 99.3M 17% /dev/root 120.0M 20.7M 99.3M 17% tmpfs 30.4M 0 30.4M 0% /tmp Mounted on / / <- different <- different Kernel with a ramdisk # mount rootfs on / type rootfs (rw) proc on /proc type proc (rw) devpts on /dev/pts type devpts (rw) tmpfs on /tmp type tmpfs (rw) # df -h Filesystem Size Used Available tmpfs 30.4M 20.0k 30.4M Use% 0% Mounted on /tmp 32
7 Th : LIGHTTPD, SQLITE & PHP (0) Goals : Students learn to install, configure and use a web server : LIGHTTPD an embedded SQL database engine : SQLite a script language : PHP 33
7 Th : LIGHTTPD, SQLITE & PHP (1) The most important parts of the pratical are : to modify the Makefile files of packages, because the differents versions of packages change. Example : PHP 5.2.6 to 5.2.9 /buildroot/package/php/php.mk to modify the conf files to adapt it Example : /etc/lighttpd/lighttpd.conf to learn how to execute a daemon # lighttpd f /etc/lighttpd/lighttpd.conf The 3 packages run. The students also learn the principle of the script CGI and FASTCGI 34
8 Th : RT kernel (0) Goals : Students learn to install, to configure, patch and use a RT kernel with xenomai patch, Xenomai is a real-time extension to the Linux kernel. This practical is not teached to the students this year, but it s for next year... Thanks to Mr Cong Sang TSAN mailto:tsan@isae.fr 35
8 Th : RT kernel (1) This part is like the kernel part Download kernel source linux-2.6.27.4.tar.bz2 from ftp://ftp.kernel.org/pub/linux/kernel/v2.6/ Uncompress it # tar xjf linux-2.6.27.24.tar.bz2 Patch kernel with maxim_org_za patch # patch-kernel.sh linux-2.6.27.24./ 2.6.27-at91.patch.gz Load.config file for USB-a9260 key # cd linux-2.6.27.24 # make ARCH=arm usb-a9260_defconfig 36
8 Th : RT kernel (2) Xenomai part Download Xenomai source xenomai-2.4.8.tar.bz2 from http://download.gna.org/xenomai/stable/ Uncompress it tar xjf xenomai-2.4.8.tar.bz2 Patch kernel with Xenomai patch we use the script prepare-kernel.sh of xenomaï./xenomai-2.4.8/scripts/prepare-kernel.sh --arch=arm --linux=linux-2.6.27.24/ --adeos=./xenomai2.4.8/ksrc/arch/arm/patches/adeos-ipipe-2.6.27-arm-1.1202.patch 37
8 Th : RT kernel (3) Configure kernel When you do # make ARCH=arm menuconfig we have a submenu Realtime sub-system Not FPU Machine ---> [ ] Enable FPU support 38
8 Th : RT kernel (4) Compile kernel make ARCH=arm CROSS_COMPILE=arm-linux- When the kernel boot we obtain the following messages with command dmesg I-pipe: Domain Xenomai registered.xenomai: hal/arm started. Xenomai: real-time nucleus v2.4.8 (Lords Of Karma) loaded. Xenomai: starting native API services. Xenomai: starting POSIX services. Xenomai: starting RTDM services. Test (not yet...) 39
9 Th : GSM/GPRS (0) Goals : Students learn to use the DAB-GPRS daugther board, to patch kernel, to write a script in python language or to write a script in shell with command AT... The daugther board : DAB-GPRS-C01 40
9 Th : GSM/GPRS (1) We can use the DAB-GPRS daughter board with the USB-A9260 embedded computers. First we need to patch the linux kernel sources with the gprs.patch Indeed we need : to enable the serial port 1 & 2 (/dev/ttys1 and /dev/ttys2) to setup PB16 as an output (PB16=POK_IN=on/off Hilo module). Once your linux kernel is recompiled you can reflash it in the Nand flash memory with the SAM-BA utility or use TFTPBOOT. Then we can insert the SIM card and power the board with its DAB-GPRS daughter board. 41
9 Th : GSM/GPRS (2) Once logged in to target, issue the following script in order to switch on the GSM/GPRS module../hilo_on ****************************** #!/bin/sh./gpio9260 -PB16 sleep 5./gpio9260 +PB16 ****************************** Then we can start the microcom utility in order to send the AT commands../microcom -s 115200 /dev/ttys1 or./microcom -s 115200 /dev/ttys2 (depend on the jumper configuration) 42
9 Th : GSM/GPRS (3) How to send a sms. 1. Issue the AT command in order to check the modem. AT OK 2. Issue the command below to enter your pin code AT+CPIN="xxxx" 3. Issue the command below to get the SMS service center address AT+CSCA? 4. Issue the command below to select the SMS format (1=text mode) AT+CMGF=1 5. Send the SMS AT+CMGS="xxxxxxxxxx" xxxxxxxxxx is the phone number 6. Enter your SMS and end your message with the 0x1A (CTRL-Z) 43
9 Th : GSM/GPRS (4) Demonstration :) i hope, it's ok... 44
Conclusion The students are happy, they learnt a lot of principles. It is the first year, i teach these practicals and they are perfectible... There are many points to improve, in particular : The programming of I/O, To develop an application to test RT kernel expansion with xenomai, Use the daughter boards like bluetooth & Wifi, Learn Busybox, U-boot, jamvm To teach embedded systems with the USB-a9260 key and freeware is easy and the students can take a key at home for training. I think that these practicals are a check means to discover the world of Free, Libre and Open Source Software. 45
Acknowledgements Students :) Gregory HERMANT & Stéphane DAVID from Calao-systems, Thomas PETAZZONI & Michael OPDENACKER from Freeelectrons, Patrice KADIONIK from University of Bordeaux France, Cong Sang TSAN from University of Toulouse - France World Wide Web. And you... 46
Related documents http://www.free-electons.com http://www.kernel.org http://buildroot.uclibc.org http://www.linux4sam.org/twiki/bin/view/linux4sam/ http://www.linuxdevices.com/ http://uuu.enseirb.fr/~kadionik/ Book : Linux embarqué of Pierre Ficheux Linux magazine : http://www.linuxmag-france.org/ 47
Questions??? 48