Linux Guide taskit GmbH Linux Guide for Portux 920t EU + SW Portux-MiniPC Portux Panel-PC Panel-Card MoLUX Stamp Page 1 of 65 Version 1.
Linux Guide taskit GmbH taskit GmbH Seelenbinderstr. 33 D-12555 Berlin Germany Tel. +49 (30) 611295-0 Fax +49 (30) 611295-10 http://www.taskit.de © taskit GmbH, Berlin All rights reserved. This document and the products referred to herein are copyrighted works of taskit GmbH. Information in this document is subject to change without notice. No part of this document may be reproduced or transmitted in any form, without the express written permission of taskit GmbH.
Linux Guide taskit GmbH Table of contents 1. Introduction................................................................................................6 2. Supported products...................................................................................7 3. Mounting MMC or SD-cards......................................................................8 4. Using the bootloader „U-Boot“.................................................................9 4.1. Setting up a TFTP server under Linux..........
Linux Guide taskit GmbH 7.5. Testing the new root filesystem............................................................................25 7.6. Installing the new root filesystem permanently..................................................25 8. Creating a new user data partition.........................................................26 8.1. Overview..................................................................................................................26 8.2. Creating a new JFFS2 image........
Linux Guide taskit GmbH 11.4.1. Portux 920t EU + SW, Portux-MiniPC.........................................................43 11.4.2. Portux Panel-PC............................................................................................43 11.4.3. Panel-Card.....................................................................................................43 11.4.4. MoLUX............................................................................................................44 11.4.5. Stamp.......
Linux Guide taskit GmbH 1. Introduction Your product is delivered with an customized Linux and the bootloader U-Boot. This document will describe how to install and customize the operation system and it will also describe how to handle the drivers for the input and output devices. Furthermore it will describe how to setup an development system and you will be given small examples that demonstrate how to compile your own applications and how to use the input devices and the display in your applications.
Linux Guide taskit GmbH 2. Supported products The specifications in this document apply to the following products: ● Portux 920T EU / SW ● Portux-MiniPC ● Portux Panel-PC ● Panel-Card ● MoLUX ● Stamp All specifications concerning memory addresses are exemplary. The accurate memory address specifications for your product can be found in the appendix (memory map). It is possible to skip some chapters of the document, depending on the configuration of your product.
Linux Guide taskit GmbH 3. Mounting MMC or SD-cards An MMC- or SD-card can be used to save larger amounts of data. Before you can mount a card you have to create a directory as mountpoint: mkdir /data . To map a card mounted in the MMC slot to a FAT file system, use the following command: mount -t vfat /dev/mmc/blk0/part1 /data If an ext2 file system is on the MMC card, the command is: mount -t ext2 /dev/mmc/blk0/part1 /data Nowadays some vendors deliver their cards without any partition.
Linux Guide taskit GmbH 4. Using the bootloader „U-Boot“ U-Boot is an open-source boot loader for embedded systems. U-Boot is well-documented, customizable, and loaded with functions. The U-Boot boot loader has been ported to more than 100 platforms. Wolfgang Denk (www.denx.de) maintains this project at www.sourceforge.de. The README in the U-Boot source code contains very detailed documentation of U-Boot.
Linux Guide taskit GmbH The parallel flash is connected to NSC0 and is used as the boot medium. In the first phase of the boot process the Atmel controller starts the bootloader U-Boot. The U-Boot start code loads the boot loader at address 21 F00 000 (SDRAM). U-Boot then initializes the memory. In the second phase of the boot process the bootloader boots the Linux image found in flash memory. The Linux image is decompressed to SDRAM.
Linux Guide taskit GmbH On the other hand, some are set by U-Boot, such as filesize and fileaddr when downloading a file. Printenv outputs the current contents of the environment variables. To show specific variables, you can add their names as arguments. printenv [name[ name[ ...]]] During runtime, changes to variables or new variables are stored in RAM and not saved permanently in flash memory. Saving is done explicitly with the saveenv command.
Linux Guide taskit GmbH U-Boot> echo $(filesize)\; echo Hello U-Boot> 171a4; echo Hello A list of all U-Boot environment variables can be found at the end of this document (chapter U-Boot environment variables). 4.5. Creating a bootscript To demonstrate U-Boot's scripting capabilities, we will now describe the construction of a boot script step by step.
Linux Guide taskit GmbH \$(basicargs) initrd=0x\$(fileaddr),0x\$(filesize) \$(mtdparts)\;bootm \$(kerneladdr) U-Boot> printenv ramboot ramboot=tftpboot 21400000 initrd.bin;setenv bootargs $(basicargs) initrd=0x$(fileaddr),0x$(filesize) $(mtdparts);bootm $(kerneladdr) Once again, note the escape characters before all special characters. Later, when ramboot is run, the variable names will be replaced with their contents. Here, however, when setting the variables, they need to be interpreted as strings.
Linux Guide taskit GmbH 4.6. Updating U-Boot To load a new version of U-Boot, you just need to interrupt the boot process of U-Boot and use the U-Boot running in SDRAM to re-load the U-Boot flash memory area. Since the U-Boot flash range is write-protected, you must first remove the write protection. Then load the new image from the network via TFTP and copy it to flash. The original U-Boot images can be found on the starterkit-CD in the directory /tftpboot: u-boot.bin contains the bootloader u-boot.
Linux Guide taskit GmbH 5. Compiling and debugging applications 5.1. Setting up a development system The development system described here assumes that your device is connected to a separate development computer, using either Ethernet or a serial cable. All transfers between the two systems occur exclusively over this connection. The development system does not have any particular hardware demands; a standard PC is in most cases sufficient.
Linux Guide taskit GmbH in the folder \toolchain\gcc-3.4.1-glibc-2.3.3 of the starter-kit CD. The compilation of a tool chain itself is labour intensive and will not be described here. The toolchain was made with Crosstools, which simplifies the compilation considerable. Have a look at http://kegel.com/crosstool/ for further information. After the installation, corresponding version of binutils, gcc and c++ are available for crosscompiling.
Linux Guide taskit GmbH 5.5. Debugging the sample The GNU debugger (GDB) is one of the most important debugging tools for Linux. To debug an embedded system, set up a gdb server with the gdb package. The gdbserver itself is a small application that carries out commands from the gdb, which runs on the development system. You will find the gdbserver in the Linux starter kit's root file system, in the /usr/bin directory.
Linux Guide taskit GmbH 6. Compiling a new linux kernel If you work with Embedded Linux regularly, you will often face the need to create your own kernel. In most cases, this involves integrating new drivers, e.g. for USB devices, or additional file systems. Because memory space is limited on an embedded board, it does not make sense to set up a large number of drivers to start with (as is common for desktop PCs) unless you know for sure that you actually need them.
Linux Guide taskit GmbH The options can now be selected or deselected in the individual levels. The basic selection consists of „empty“, „*“, „M“. Empty means that the driver will not be compiled with the kernel. * means that the driver will be included in the kernel binary. M means that the driver is configured as a module; in other words, it can be dynamically activated and deactivated at runtime. When you have set the configuration as you like, finish the process with Exit and Save.
Linux Guide taskit GmbH directory. 6.3. Preparing the kernel To install the new kernel on the taskit device, you now need to prepare the zipped kernel image for use by U-Boot. This is done using the mkimage tool. Mkimage is also included in the /scripts directory on the starter-kit CD.
Linux Guide taskit GmbH Note: Keep in mind that the kernel image can not be bigger than the size of the corresponding flash disk partition (see appendix). In case it should be bigger you have to change the flash disk partition sizes (physmap_flash.0) and reinstall the root and config partition. But this is only necessary in rare cases. During development, you can also start the image directly from RAM without copying it to flash memory: bootm 21000000.
Linux Guide taskit GmbH 7. Creating a new root filesystem 7.1. Overview The root filesystem is the place where system applications and libraries are stored. It is loaded from the flash disk and decompressed to an ram disk during the boot process. Thus all changes in the root filesystem will be lost after the next reboot. In case there is the need to save files to flash memory (i.e.: log files) you will have to create and modify them on the root filesystem and copy them to the config partition at the end.
Linux Guide taskit GmbH Then go to the busybox directory: cd /develop/sysapps/busybox-1.00 . You can configure the make options using a graphical interface by entering: make menuconfig You can select individual commands and features here. Enter the path to the cross-compiler under „Build options1“ (normally /usr/bin ). You also need to enter the path to the root file system ( /develop/rootfs in this example) under „Installation options“.
Linux Guide taskit GmbH mv /tmp/sysapps /develop After that go to the util directory: cd /develop/sysapps/mtd/util Edit the makefile here. It is important to set the environment variable CROSS_COMPILE=arm-linux-3.4.2- for indicating the cross-compiler and DESTDIR, which gives the installation directory and must point to the directory with the root file system for the target system (in our example, /develop/rootfs). Now type make to compile the MTD-utils. 7.4.
Linux Guide taskit GmbH Next, compress the image containing the root file system and set the correct access rights: gzip -9 < images/initrd.img > images/initrd.bin chmod 644 images/initrd.bin The parameter -9 tells gzip to use the highest level of compression. You can also carry out this process by running the simple shell script mkfsimage.sh, found in the folder scripts on the starterkit-CD: cd /develop cp /dev/cdrom/scripts/mkfsimage.sh /develop ./mkfsimage.sh Now you can transfer the initrd.
Linux Guide taskit GmbH 8. Creating a new user data partition 8.1. Overview As you can see in chapter the appendix the biggest part of the flash disk is used for a JFFS2 partition. The Journalling Flash File System version 2 or JFFS2 is a log-structured file system for use in flash memory devices. Unlike the ext2 filesystem, used for the root filesystem, with JFFS2 it is possible to create and modify files that are stored directly onto the flash disk.
Linux Guide taskit GmbH line in the bash shell: mount -t nfs -o nolock development_system_ip:/develop/backup /mnt cat /dev/mtd/3 > /mnt/archive2007.jffs2 umount /mnt 8.4. Restoring the JFFS2 partition Enter the following line on the linux shell to restore the above created archive (the flash will automatically be deleted before copying): flashcp -v /mnt/archive2007.jffs2 /dev/mtd/3 Note: See that the copied archive is not bigger the the flash partition it is copied to.
Linux Guide taskit GmbH 9. The input driver 9.1. Overview The input drivers control each input device build in or connected to your product. This includes the touch panel, the matrix keyboard, a PS/2 keyboard, the rotary knob and an infrared remote control. To find out which drivers are available for your product, you will have to read the chapter “Driversupport” in the appendix. The driver consists of several parts, one for each input device.
Linux Guide taskit GmbH insmod /config/panelcard-knob.ko To stop the driver enter: rmmod panelcard-knob.ko You can also compile the driver into the kernel, so that it is started automatically, by changing the entry “Panel-Card Starterkit knob driver” from 'M' (compiled as module) to '*'. 9.3. Customizing the keymap of the matrix keyboard A whole list of assignable keys like KEY_B in the first example can be found in the Linux kernel header /include/linux/input.h of the Linux sources.
Linux Guide }; .value = { .flags .value } = 0, = KEY_B taskit GmbH // assign key 'b' (small b) if(ioctl(fd, PORTUXMATRIX_IOC_SETKEY, &entry)) perror("Error changing key!"); } return 0; Compiling: arm-linux-3.4.2-gcc -Wall matrixsample1.c -o matrixsample1 Example 2: To change the whole keymap and assign the key '(' (shifted '9') to every key you have to code: /* This sample can be found on the starter-kit cd: /dev/cdrom/examples/input/matrixsample2.c ...
Linux Guide taskit GmbH for(y = 0; y < PORTUXMATRIX_MAX_Y; y++) { map[layer][y][x].flags = PORTUXINPUT_MASK_LSHIFT; if(layer == 0) // if is first layer assign 'A' map[layer][y][x].value = KEY_A; else map[layer][y][x].value = KEY_B; } } } // assign the key for switching the keymap to the first key map[layer][0][0].flags = PORTUXINPUT_MASK_SETKEYMAP; if( layer < PORTUXMATRIX_MAX_LAYER – 1) // switch to next keymap map[layer][0][0].
Linux Guide taskit GmbH } } // inform the input driver about the new keyarray if(ioctl(fd, PORTUXINPUT_IOC_SETKEYARRAY, &characters)) { perror("Error changing keyarray!"); return 1; } // assign the keyarray to the keys on row 1 for(arrayNR = 0; arrayNR < PORTUX_MAX_KEYARRAYS; arrayNR++) { map[0][0][arrayNR].flags = PORTUXINPUT_MASK_KEYARRAY; map[0][0][arrayNR].
Linux Guide taskit GmbH irmap map; int IRcmd, mapNR; int fd = open("/dev/portuxinput", O_RDWR); // create the keymaps for(mapNR = 0; mapNR < PORTUXIR_MAX_LAYER; mapNR++) { // assign key 'a' to every key of the ir controller for(IRcmd = 0; IRcmd < PORTUXIR_MAX_COMMANDCODES; IRcmd++) map[mapNR][IRcmd].flags = 0; // no modifier map[mapNR][IRcmd].value = KEY_A; // 'a' } // assign the key for switching the keymap to the first key map[mapNR][0].
Linux Guide taskit GmbH The optional touchscreen can be used as pointer like a pc mouse in graphical applications. To build applications that use the touchscreen as input device you can use the class libraries of the Nano-X Window System or Qtopia Core from Trolltech. The Nano-X Window System will detect the touchscreen as a standard input device automatically.
Linux Guide taskit GmbH 9.7. Using the knob The rotary knob on the Panel-Card starterkit board can be used as input device after the driver has been loaded. The driver module is located in the /config folder. To start the driver automatically at boot time, add the following line to /config/rc.local: insmod /config/modules/panelcard-knob.
Linux Guide taskit GmbH 10. The display 10.1. Un- / Installing the driver By default the driver for the display device is compiled into the linux kernel. To activate or deactivate the driver you have to recompile and install the linux kernel. The reconfiguration of the kernel can be done with menuconfig. After starting menuconfig the display driver can be found at: Device Drivers -> Graphics support. There you can activate or deactivate the display driver and backlight.
Linux Guide taskit GmbH cp /config/ScreenShot /dev/fb0 Another approach to create graphical applications is to use the open source Nano-X Window System or Trolltech's Qtopia Core. These class libraries will automatically detect the display and use it. The Nano-X Window System is installed in the root filesystem. To start your Nano-X application you have to start the Nano-X-server first and then your Nano-X application: Nano-X & .
Linux Guide taskit GmbH 11. Appendix 11.1. Memory map 11.1.1.
Linux Guide taskit GmbH 11.2. Driversupport The following articles show which drivers are availabe for your product. 11.2.1. Portux Panel-PC ● ● ● ● Displaydriver Matrix keyboard driver Touch panel driver PS/2 Keyboard driver 11.2.2. Panel-Card ● ● Displaydriver Rotary knob driver 11.2.3. MoLUX ● ● Displaydriver Matrix keyboard driver Page 39 of 65 Version 1.
Linux Guide taskit GmbH 11.3. U-Boot environment variables A description of all important environment variables used by U-Boot follows. 11.3.1.
Linux Guide default: stderr taskit GmbH serial standard error output interface default: serial serverip IP address of the TFTP server sample: 192.168.4.238 flash_type installed flash (used by script for linux flash tool configuration) default: N_type old value: M_type 11.3.2.
Linux Guide taskit GmbH mtdparts the MTD partitions for the flash unit are defined here default: mtdparts=physmap_flash.0:384k(boot),1664k(linux),3072k(initrd), 10240k(cfg),-(custom) stdin standard input interface default: serial stdout standard output interface default: serial stderr standard error output interface default: serial serverip IP address of the TFTP server sample: 192.168.4.
Linux Guide taskit GmbH 11.4. Product specific kernel settings 11.4.1. Portux 920t EU + SW, Portux-MiniPC General kernel configuration The default kernel configuration is loaded by entering: ARCH=arm make portux920t_defconfig This configuration has to be loaded at least one time after decompressing and compiling the kernel sources from the starterkit-CD. 11.4.2.
Linux Guide taskit GmbH Device drivers -> Graphics support To enable the driver activate the entry “AT91/AT32 LCD Controller support”. To disable the driver deactivate the entry “AT91/AT32 LCD Controller support”. Configure backlight To change the backlight configuration start menuconfig and go to: Device drivers -> Graphics support To enable the backlight activate the entry “taskit Panel-Card Backlight Driver”. To disable the backlight deactivate the entry “taskit Panel-Card Backlight Driver”.
Linux Guide taskit GmbH To activate the input drivers activate (press SPACE until a '*' appears) the entry “Portux/MoLux Input Drivers” and a list of available drivers appears. Then: ● activate the entry “Matrix keyboard component” to enable the driver for the matrix keyboard 11.4.5.
Linux Guide taskit GmbH 11.5. Input driver reference 11.5.1. struct portuxinputevent Name struct portuxinputevent— describes an input event Synopsis struct portuxinputevent { unsigned short flags; unsigned int value; }; Members flags - some additional flags to change the handling of the event value - distance of a mouse movement or one of the key/button values, that can be reported to the input system, refer to include/linux/input.
Linux Guide taskit GmbH Synopsis struct irentry { unsigned char code; struct portuxinputevent value; }; Members code - code for which the event value ought to happen value - event that ought to happen 11.5.4.
Linux Guide taskit GmbH Members address – EEPROM address for read/write operation data – received data or data to store 11.5.6. Defines / Constants These constants define the maximum size of the arrays used by the io-controll functions. They can be modified in the portuxinput.h but then you have to recompile the modules.
Linux Guide taskit GmbH as a relative movement of the mouse cursor. The next two flags describe the direction. They should not be used, if this flag is not set. If this flag and all of the above are not set, than value is treated as a key/button code. PORTUXINPUT_MASK_REL_X: Mouse movement in x direction PORTUXINPUT_MASK_REL_Y: Mouse movement in y direction PORTUXINPUT_MASK_LSHIFT: Left shift key is simulated while sending the key event.
Linux Guide taskit GmbH array must be null terminated (value=0). PORTUXINPUT_IOC_WRITEEEPROM This function requires a pointer of type struct eeprom_t as argument and stores one byte at the selected address in input controller's EEPROM. Note : The EEPROM's size is 1024 bytes where the last 16 bytes are used by the calibration tool of touchpad (TouchTool) to store calibration data. PORTUXINPUT_IOC_READEEPROM Reads one byte from input controller's EEPROM.
Linux Guide taskit GmbH PORTUXTOUCH_IOC_CALIBRATEABORT It stops an already running calibration process and but discards the current calibration values. PORTUXTOUCH_IOC_CALIBRATE It starts a self finishing calibration process. It takes an int as an argument which determines the timeout in seconds. That means that when you stopped touching the touch panel it waits as many seconds as given for new input from the touch panel until it finally stops calibration.
Linux Guide taskit GmbH 11.6. U-Boot commands U-Boot generally interprets numerical arguments as hex values. In other words, 10000000 is 0x10000000 Hex. U-Boot has commands to 1. read and write memory and flash memory, 2. load programs and files via the serial interface or Ethernet, 3. start programs and boot Linux, and 4. set environment variables, as well as 5. additional commands.
Linux Guide setenv tftpboot version taskit GmbH - set environment variables - boot image via network using TFTP protocol - print monitor version 11.6.1. Read and write memory and flash memory cmp - memory compare cmp [.l, .w, .b] Addr1 Addr2 count You can check the contents of two memory ranges with cmp. You can use extensions to determine the size of the memory access: cmp.l -> 32-bit long word (default), .w ->16-bit word or .b -> 8-bit byte.
Linux Guide taskit GmbH 10000030: 02c0 21f0 0320 21f0 0380 21f0 beef dead ...! ..!...!.... base - print or set address offset base [base address] Outputs or sets the current base address. Offsets for all memory commands are calculated from the base address. This option can be helpful when you need to access a certain memory region repeatedly. For example: U-Boot> base Base Address: 0x00000000 U-Boot> md 40 4 00000040: 21f00000 21f00000 21f171a4 21f1b85c ...!...!.q.!\..
Linux Guide taskit GmbH initialize a memory range with a value. This command cannot be used to modify flash memory! For example: Writing 0xff ten times to SDRAM address 20 000 000: U-Boot> md 20000000 20000000: abcdefab cdeff014 20000010: e59ff014 e59ff014 U-Boot> mw.b 20000000 ff 10 U-Boot> md 20000000 20 20000000: ffffffff ffffffff 20000010: e59ff014 e59ff014 e59ff014 e59ff014 ................ e59ff014 e59ff014 ................ ffffffff ffffffff ................ e59ff014 e59ff014 ................
Linux Guide taskit GmbH The crc32 command calculates the check sum for a memory range (from addr1 to addr1+count). You can optionally indicate addr2 to save the calculated check sum there. For example: U-Boot> crc32 21000000 100 20000000 CRC32 for 21000000 ... 210000ff ==> e8d6cfbc U-Boot> md 20000000 10 20000000: e8d6cfbc 0000000b 0000000c 0000000d ................ flinfo - print FLASH memory information flinfo (fli for short) Outputs information about the known flash module.
Linux Guide taskit GmbH protect - enable or disable FLASH write protection protect on|off addr1 addr2 protect on|off all Use the protect command to protect individual flash sectors from unintentional write accesses. This is purely a software protection on the U-Boot level. The protection prevents the cp and erase commands from being carried out on the correspondingly marked sectors. This protection is easy to remove and other programs (e.g.
Linux Guide taskit GmbH Address-based removal of write protection, recreation of starting configuration. When using address-based protect commands, please note that the beginning and ending address are exactly on the sector border.
Linux Guide taskit GmbH the ISC DHCP server, version 3.0.1rc9: host taskit { hardware ethernet 00:50:C2:3A:B0:01; fixed-address 192.168.2.171; next-server 192.168.2.238; //Address of TFTP server filename u-boot.bin; } dhcp - invoke DHCP client to obtain IP/boot params dhcp Loads an image via BOOTP. The name of the image to be loaded must be entered either in the environment variable bootfile or in the DHCPD server configuration.
Linux Guide taskit GmbH For example: U-Boot> rarpboot 21000000 u-boot.bin RARP broadcast 1 TFTP from server 192.168.2.238; our IP address is 192.168.2.239 Filename 'u-boot.bin'. Load address: 0x21000000 Loading: ################### done Bytes transferred = 94628 (171a4 hex) tftpboot- boot image via network using TFTP protocol tftpboot [addr] [filename] Loads a file from the network via TFTP. The IP parameters must already be set. For example: U-Boot> tftpboot 21000000 u-boot.bin TFTP from server 192.168.
Linux Guide taskit GmbH For example: U-Boot> loadb 21000000 115200 ## Ready for binary (kermit) download to 0x21000000 at 115200 bps... ## Total Size = 0x000171a4 = 94628 Bytes ## Start Addr = 0x21000000 11.6.3. Start programs and boot Linux boot - boot default, i.e., run 'bootcmd' bootd - boot default, i.e., run 'bootcmd' boot bootd Both commands run the boot script stored in the bootcmd environment variable. See chapter 3.5. for information about creating scripts.
Linux Guide taskit GmbH Starts an application stored at address addr. This command is not suitable for starting from Linux, since r0, r1 and r2 are not set. It is designed for stand-alone applications written specifically for the AT91RM9200. For example: U-Boot> go 21100000 ## Starting application at 0x21100000 ... 11.6.4. Set environment variables printenv- print environment variables printenv [name[ name[ ...]]] printenv outputs the current contents of the environment variables.
Linux Guide taskit GmbH setenv - set environment variables setenv name value setenv name Sets the environment variable name to the value value. If the variable already exists, its current value is overwritten; if it does not yet exist, it is created. If no value is given, the variable is erased (if it exists).
Linux Guide taskit GmbH coninfo Outputs informations about the current console. For example: U-Boot> coninfo List of available devices: serial 80000003 SIO stdin stdout stderr version - print monitor version Indicates the U-Boot version being used For example: U-Boot> version U-Boot 1.1.2 (Nov 30 2004 - 12:03:10) itest - return true/false on integer compare itest[.b,.w,.l,.s] [*]arg1 op [*]arg2 Returns true/false when comparing two integers. You can specify the data size with .b (byte), .w (word) or .
Linux Guide taskit GmbH 11.7. Important linux shell commands List files ls [-la] Find a file find -type f -name “filename” Copy a file cp /source/file.ext /target Delete a file rm /folder/file.name Move a file mv /source/file.ext /target Rename a file mv /file.ext /newname.ext Create a directory mkdir /myDir Delete a directory rmdir /myDir Start an application or script ./applicationname Decompress a .PK file gunzip filename.pk Get files from .TAR archive tar xvf filename.