Home

SnapGear Linux for LEON

image

Contents

1. Network devices and TCP IP must be selected for standard network communication to be available 3 5 7 GRLib OpenCores Ethernet MAC In the same way as the GRETH is configured the OpenCores MAC can be selected and it s MAC address can be edited The OpenCores MAC is found under General machine setup Vendor OpenCores JX LINUX SNAPGEAR 15 GAISLER RESEARCH 3 5 8 SMC 91x Ethernet MAC The SMC91x driver can be found under Network device support Ethernet 10 100 The Ethernet MAC address must be configured to an unique address as previous MAC controllers The chip is not a Plug amp Play AMBA device and can therefore not be automatically detected by the driver Both address and IRQ number must be given to the driver for it to operate correctly 3 5 9 GRLib GRETH 10 100 1000 over PCI Select GRETH_PCI from Network device support Ethernet 10 100 to include a driver for Gaisler Ethernet MAC connected via PCI Usually GRETH is connected via the AMBA interface and is included as previously described PCI support must also be enabled see the sub section GRLib PCI support below 3 5 10 GRLib OpenCores I C master Enable I2C support and I2C support I2C Hardware Bus support OpenCores I2C Controller The driver will use the GRLib wrapper s interface when the kernel is configured to run on a Leon SoC To use the I C bus selections should also be made under I2C supp
2. LINUX SNAPGEAR 10 GAISLER RESEARCH 3 2 C library Two different C libraries are available for selection from the graphical xconfig utility The libraries differ in binary size and one of them uClibC supports MMU less systems Table 3 2 outlines which C library is available for which version of Linux For configurations that supply their own root filesystem outside of SnapGear such as via NFS a none option is also provided to entirely omit the compilation of a C system library Version LibC LibC GNU uController LibC uCLinux 2 0 x N A Small footprint Linux 2 6 x Normal footprint Small footprint Table 3 2 LibC selection possibilities 3 2 1 Static vs Dynamic linking When linking an application static all code used from libraries are included into the output binary This makes the binary bigger Linking all binaries static will make the same code appear in multiple locations in each binary that uses it both in the file system and in main memory during execution Dynamic linking however runs a dynamic linker during the start of the application on the target hardware this results in smaller main memory usage as code is shared between applications Since the same code may appear in different addresses in different applications the code must be position independent Generating position independent machine code makes the code a bit slower and slightly bigger it is done by passing the argument fPIC
3. LINUX SNAPGEAR 23 GAISLER RESEARCH 4 BUILDING SNAPGEAR After configuring the kernel and the applications it is possible to compile and build the SnapGear LEON Linux distribution There are two very important options passed to the build scripts the FPU and SPARCV8 options found in Gaisler Leon2 3 MMU options Disabling the FPU makes the compiler replace the FPU instructions with software routines that calculates the answer without needing a FPU The compiler is run with the argument msoft float SPARC v8 processors have support for hardware integer multiplier divider through the instructions MUL and DIV instructions whereas SPARC v7 hasn t LEON is a highly configurable processor it can be compiled with or without hardware integer multiplier support To make the compiler generate code without MUL and DIV instruction select n for the v8 option The compiler will generate code compatible with SPARC v7 if started with mcpu v SnapGear is configured and compiled with make xconfig config GUI make dep only Linux 2 0 x needs this make compile kernel libraries boot loader applications and make images The resulting image produced during the build stage is put in snapgear pxx images Image Function image dsu RAM image with partial boot loader grmon nb grmon gt load image dsu grmon gt run image flashbz Compressed Flash PROM Image with complete boot loader grmon nb grmon gt
4. TE 2 LINUX SNAPGEAR 49 GAISLER RESEARCH Name Function Core Applications Bash Shell to parse Debian scripts BusyBox ar cat chmod chown chroot find grep gunzip head init In md5sum mkdir mv printf rm sed sleep sort sync tar touch tr umount wc Table 11 2 Root file system mounted via NFS 11 2 Installing Debian installation utility to PC and LEON target The utility that is able to download extract and install Debian is called debootstrap It can be downloaded from Debian s homepage Since debootstrap is run from the PC as well as the LEON target two versions are needed to be downloaded the SPARC version for the LEON and the 1386 version for the PC Unless of course running on Solaris It is assumed that the Debian package manager is not available Download and install debootstrap on a non debian machine as root S BUSYBOXLINUX export busybox_rootfs DEBOOT debootstrap_0 2 45 0 2_i386 deb TMPDIR tmp debinst ARCH sparc INSTDIR SBUSYBOXLINUX debian DISTNAME sarge MIRROR ftp ftp se debian org debian mkdir p STMPDIR work cd STMPDIR wget http ftp se debian org debian pool main d debootstrap DEBOOT cd work ar xf STMPDIR S SDEBOOT cd tar zxvf STMPDIR work data tar gz NM MMM WW WMMNVUNMNNH Download and install debootstrap to LEON BusyBox root file system DEBOOT debootstrap_0 2 45 0 2_sparc deb mkdir p STMPDIR work_sparc cd STM
5. Name Value Vendor Product Selection Vendor Gaisler Gaisler Product Leon3mmu Gaisler Leon2 3 mmu options SPARC v8 Yes FPU support Yes Clock frequency 40MHz Baudrate 38400 In memory root filesystem initramfs Kernel command line console tty0 video grvga 640x480 60 8 307200 Kernel Library Defaults Section Kernel Version Linux 2 6 x Libc Version Glibc from compiler Customize Kernel Settings Yes Customize Vendor User Settings Yes Table 7 2 Boot loader configuration 7 3 Configuring the Linux kernel Apart from the default configuration support for frame buffer on Gaisler VGA controller and input driver for Gaisler PS 2 controller is enabled as in table 7 3 LINUX SNAPGEAR 37 Name Function Graphics Support FB Frame buffer sub system FB_GRVGA Frame buffer driver for GRVGA controller FRAMEBUFFER_CONSOLE Frame buffer console support FONTS Compiled in fonts FONT_8x16 8x16 Font support LOGO Add boot logo support LOGO_LINUX_CLUT224 Include a coloured Linux logo Input devices SERIO_LEON3 Driver for Gaisler PS 2 controller SERIO_LEON3_KEYB_IRQ The IRQ number of assigned to the PS 2 controller connected to the keyboard INPUT_KEYBOARD Keyboard sub system KEYBOARD_ATKBD AT keyboard driver Table 7 3 Kernel configuration 7 4 Configuring SnapGear Applications Below is a d
6. Add these 4 lines EXECS args OBJS9 args o S EXEC9 S OBJS9 CC S LDFLAGS o S S OBJS9 S LDLIBSS LDLIBS_S Add EXECY9 to the end of the all statement all S EXEC1 S EXEC5 S EXEC6 S EXEC8 S EXEC9 INSMODEXE 5 3 Including application to file system From the Core Applications it is possible to enable custom applications the make utilities will enter the user custom directory and compile it as described by user custom Makefile a Core Applications DR Core Applications yll I n custom tests app Help gt Vv yl Vv n canatinux test apps Help v Y v n Module_init_tools Help v Y i v nl init Help v Yll vil en enable console shell Help Vv Y v n execute firewall rules Help Sash Shell Program Help Illustration 5 1 Custom applications JX LINUX SNAPGEAR 25 GAISLER RESEARCH 6 DEBUGGING LINUX 2 6 AND APPLICATIONS This section discusses different debugging methods used when debugging Linux 2 6 x userspace applications and the kernel itself GRMON is documented in detail in the GRMON manual available at hitp Avww gaisler com doc grmon pdf When debugging with GRMON the SPARC v8 Architecture manual may come in handy for instruction definition and the SPARC assembler conventions used by the C compiler The SPARC v8 manual is available at http gaisler com doc sparcv8 pdf GRLIB IP core doc
7. 00000000 00000000 00000000 F0237000 5 00000000 00000000 00000000 00000000 6 FOOOFDCO 00000000 FOOOFD48 F000E000 7 F010F348 00000000 F01109B8 F0000C7C psr F3901FE3 wim 00000001 tbr F0004050 pc 010edb0 Ildub i2 ol npc f 010edb4 sll ol 24 00 grlib gt vmem 0xF0227518 0x10 40227518 2053756e 20426f6f 74205072 6 f6d2056 6 3 Debugging userspace applications Debugging user space applications is a lot different from kernel debugging One can still use GRMON the same way as for kernel debugging but is only effective in simpler debugging cases When debugging userspace applications a native GDB debugger executing on the LEON target may be used to debug applications using the serial console for input This is similar to debugging PC applications and not described here The CPU may be heavily loaded since GDB share the CPU with the application also application sources and debug binaries are required at the target when debugging natively For targets having a serial port or a network connection it is possible to debug Linux applications remote The debugging interface is presented on a PC unloading the target CPU The most common solution is to use a GDB TCP IP server gdbserver exporting control to a remote PC running GDB sparc linux gdb compiled for target binaries SPARC 0 0 y GAISLER RESEARCH PROMLIB Sun Boo o t Prom Version d Revision available result 00000000 00000
8. Vendor Product Selection Save and Exit Kermel Library Defaults Selection Quit Without Saving Template Configurations Load Configuration from File Store Configuration to File Illustration 3 1 SnapGear main configuration GUI 3 1 Processor type and MMU Selecting processor is mandatory the boot loader needs to know how to initialize low level hardware which in some cases are processor dependant It is also important to select MMU support if memory protection hardware is available for use MMU provides memory protection between kernel and user space and also in between user space processes With MMU a faulty process cannot affect another process memory in a destructive manner as may be the case without MMU Linux 2 6 cannot run without MMU whereas uCLinux runs without MMU indicated in the table below Version MMU MMU MMU less 2 0 x N A uCLinux 2 0 x 2 6 x Linux 2 6 N A Table 3 1 Linux and MMU a Vendor Product Selection 6X Vendor Product Selection Select the Vendor you wish to target _gaisler Vendor Help Select the Product you wish to target LITE Snap Gear Products Help leon3mmu gaisler Products Help DAR ARE at Select the options for a selected Product leon2 Siamani C Nessie opts fy A leon3 leon3mmu Next Prev Illustration 3 2 Vendor Product Selection JX
9. flash erase 0 0x00300000 grmon gt flash load image flashbz grmon gt run 0 image tsim TSIM LEON simulator image if MMU is used TSIM must also support MMU tsim leon3 tsim gt load image tsim tsim gt run Table 4 1 Images available The images can be downloaded and run using grmon as shown in table 4 1 Be sure to invoke grmon with the nb option so that Linux can take care of traps instead of having grmon stop the execution JX LINUX SNAPGEAR 24 GAISLER RESEARCH 5 ADDING CUSTOM APPLICATIONS Custom applications can be added into the SnapGear projects in several ways the simplest ways is to add the source code to the already prepared custom directory snapgear pxx user custom It is also rather easy to modify the menu of the SnapGear Application menu and add a new application to the GUI It also possible to copy a binary compiled outside of the SnapGear distribution folders This chapter shows the simplest possible alternative adding an application to the user custom directory 5 1 Creating an application A simple application that print out the number of arguments it was invoked is saved to user custom args c include lt stdio h gt int main int argc char argv printf s you passed d arguments n argv 0 argc return 0 5 2 Setting up compilation directives For the application to be compiled one must add it to user custom Makefile The Makefile may be edited as follows
10. 0 841471 000000 0 909297 000000 0 141120 000000 0 756802 One can change the execution flow by manipulating variables within the loop The integer i set to 90 the breakpoints are removed and the application are continued to is endpoint gdb set variable i 90 gdb delete Delete all breakpoints y or n y gdb cont Continuing Program exited normally Finally the LEON target s console output was 2 LINUX SNAPGEAR 34 GAISLER RESEARCH Sash command shell version 1 1 1 gt gdbserver 1223 bin testsin Process bin testsin created pid 26 Remote debugging using 1223 testsin Float sin 0 000000 0 000000 Float sin 1 000000 0 841471 Float sin 2 000000 0 909297 Float sin 3 000000 0 141120 Float sin 4 000000 0 756802 Float sin 90 000000 0 958924 Float sin 91 000000 0 105988 Float sin 92 000000 0 779466 Float sin 93 000000 0 948282 Float sin 94 000000 0 245252 Float sin 95 000000 0 683262 Float sin 96 000000 0 983588 Float sin 97 000000 0 379608 Float sin 98 000000 0 573382 Float sin 99 000000 0 999207 exit testsin Child exited with retcode 0 Child exited with status 0 GDBserver exiting gt 6 3 6 DDD and GDB DDD is a graphical frontend run alongside with GDB DDD launches GDB and provides us with direct access to the GDB console and the ability to display information about the debugged application DDD is compiled for PC Linu
11. 2 6 AND APPLICATIONS cccceccsssscsseseeeeseneeseeeseeeeaeeeeaeeeeaeeecaeeneeeaeens 25 6 1 Debus symbols cser sccsetsnsesdeaes sissies cosevsiycededes sua eeedaues cadesueservsdeeasstyiucs eteshestigesenievavertecdentes 25 6 2 WS bp gng the Sri l sssini de a A E E O AER 25 6 2 1 Configuring GRLIB for kernel debugging cceeccesceeseesceeseeeeeseeeeeeseceeeeseceeeeaesesesseenseeeeeaeeaaes 26 6 2 2 Using GRMON iiia a den E e ea a AE EE E E SNES Ann SEA ETE 26 6 2 3 GRMON Example debugging the Linux Kernel ossmsssessrersrsrsrssrsesrsrereresrsrsrsrerernesesrrrsrer rr renen ner rna 26 6 3 Debugging userspace applications cccecesseescesscesecseeeseeseeesecsecesecseeesecceeseceeeeseseseeeeeeeeesteeenaaes 29 6 3 1 Setting up a debugging eNVirOMMeht sssssesessrsrsrsrrsrsrsrsrererrsrsrsrererrsrsrsrer er reses reser ee KRK RR RR KRK Reser ner ennen na 30 6 3 2 GDB introduction saisai asinen dess read ep pe ane ne Re ee el eee oie 30 6 3 3 Starting GDB Server on tar etesas os cces csevsavacnteescda dotaecuestocgiaetstechdecessstaedbavgshedntetassenseeteveeadesbaausipede 30 6 3 4 Connecting with GDB to gdbserver eccccceccesscessesseeseeeeeeseceneeseensecseeesesseeeseeseeeaeenseeaeceeeeeeneseeensaes 31 6 3 5 GDB example USA Se cc cise siev cs sos ics stgocte R a e E S 31 6 3 6 DDD aiid GDB asisezihies ec aad sass 3s eres ed rna Vad vs sas eee ed ees ss ea eee 34 6 3 7 Insight iren e render Gapiaces SNES SN HENNE edz dears EE E EN N S
12. Devices MTD Parallel port support Plug and Play support Block devices ATA ATAPI MFM RLL support SCSI device support Multi device support RAID and LVM Fusion MPT device support IEEE 1394 FireWire support 120 device support gt Network device support PHY device support Ethernet 10 or 100Mbit Ethernet 1000 Mbit Ethernet 10000 Mbit Token Ring devices Mm moo Illustration 3 4 Linux 2 6 x GUI configuration utility Memory model Flat Memory 064 bit Memory and IO resources EXPERIMENTAL Mm I Ki Running on grlib s Leon3 LEON_3 Say Y here if you are running on a Leon3 from grlib download from www gaisler com aA i 3 5 1 LEON processor type The configuration of the processor type is done separately for the Linux boot loader and the kernel itself This is done to eliminate the kernel s dependency on SnapGear LEON Linux can be used without SnapGear LEON must always be selected but LEON 3 is only selected for LEON3 targets Selecting LEON 3 will result in binary unable to run on LEON2 processors and vice versa Certain hardware is only available for LEON3 their drivers will be invisible when LEON2 is selected 3 5 2 Symmetric multi processing support LEON Linux has support for multi processor systems SMP can be enabled for LEON3 systems under General machine setup The LEON Linux boot loader is updated to initialize the SMP system co
13. a short introduction to the two different C Libraries Name Description Location sparc linux 3 2 2 Linux 2 0 and 2 6 GNU LibC toolchain linux linux 2 0 toolchains sparc linux 3 2 2 sparc linux 3 4 4 Linux 2 6 GNU LibC toolchain linux linux 2 6 toolchains sparc linux 3 4 4 sparc uclinux 3 4 4 Linux 2 6 uClibC toolchain linux linux 2 6 toolchains sparc uclinux 3 4 4 Table 2 1 Toolchain description The locations described in table 2 1 are all relative to the Gaisler FTP site ftp ftp gaisler com gaisler com 2 2 Installing the toolchain The installation process for the different toolchains is the same it is only the names and paths that differ All toolchains must be installed to opt and the path to the toolchain binary directory opt sparc uc linux 3 x x bin added to the shell PATH variable Below is an example of how to install the sparc linux 3 2 2 toolchain Install by extracting the toolchain into opt mkdir opt S cd opt tar jxf path to toolchain sparc linux 1 0 0 tar bz2 Add the toolchain to the PATH variable preferably in a shell start up script For bash shells the following is added to profile export PATH SPATH opt sparc linux bin After installing the toolchain it is possible to cross compile applications for SPARC LEON Linux args c int main int argc char argv printf s you passed d argument s n argv 0 argc 1 return 0 Compile args by running LIN
14. and initialize low level hardware The main purpose of the boot loader should be to initialize basic hardware such as memory controllers and console output for debugging before launching LEON Linux The SnapGear graphical interface as been extended to allow users to set boot loader parameters in an easy fashion The boot loader is stored in a non volatile memory at the address where the LEON processor reads its first instructions to be executed usually stored in flash at address 0 During the development process grmon may be used to load the resulting image into RAM directly thus bypassing the flash This shortens the development time drastically Using this method only the last part of the boot loader is executed it is often referred to as stage 2 Instead grmon initializes the hardware before running stage 2 IX LINUX SNAPGEAR 6 GAISLER RESEARCH 1 4 LEON simulator to speed up the development process There are simulators available for LEON and most of its peripherals TSIM and the multiprocessor simulator GRSIM See www gaisler com for more information about simulators 1 5 Obtaining the software The Software is free of charge and distributed under the GPL licence The software bundle can be downloaded from Gaisler s homepage www gaisler com under the downloads section 1 6 Supported hardware Below is a list of supported hardware in addition to the standard kernel e LEON2 with or without MMU FPU MU
15. be set from kernel command line UNIX UNIX domain sockets needed by Debian s logging facilities Device Drivers Network device support NETDEVICES Enables the network device driver interface General machine setup Grlib AMBA Gaisler GRLIB_GAISLER_GRETH Add Gaisler Ethernet 10 100 1000 driver Select a unique Ethernet address in the MSB and LSB fields Device Drivers Block Devices BLK_DEV_INITRD Disable ROMFS RAM root file system File systems Network file systems NFS_FS Network file system support NFS_V3 Support for version 3 of the NFS protocol ROOT_NFS Add support for root file system over NFS Table 8 2 Kernel configuration for NFS root FS 8 4 Building kernel and boot loader As previously described LINUX SNAPGEAR 41 GAISLER RESEARCH make The image will be available for download to the target board from images image dsu 8 5 Running on hardware The far most simplest method of testing the image is to run it using grmon as follows Depending on what debug interface is available the parameters to grmon may differ see grmon documentation for details cd images grmon jtag nb grmon gt load image dsu grmon gt run The NFS share can be tested by changing or adding files at the PC side and watch as they appear on the LEON Linux target JX LINUX SNAPGEAR 42 GAISLER RESEARCH 9 ROOT FILE SYSTEM OVER E
16. described other than with an example entry applied to etc exports it make the NFS server export the root file system to the LEON board 8 1 Setting up NFS server on PC As previously mentioned the NFS server is assumed already to be installed however an entry to etc exports sharing the root file system should be added similar to what described Adding the following line to the etc exports makes the server share the export rootfs directory The NFS server is forced to reread the settings file by invoking exportfs r export rootfs 192 168 0 0 255 255 255 0 rw async no_root_squash insecure In this example we export export rootfs which is a SnapGear ROMFS file system The directory is exported to any computer using the IP address 192 168 0 X su mkdir export cp rpd daniel snapgear pxx romfs export rootfs echo export rootfs 192 168 0 0 255 255 255 0 rw async no_root_squash insecure gt gt tmp exports exportfs r F exit It is also possible to base the root file system on other distributions for example on splack or creating one from scratch A common source of failure is that the initialization scripts run during boot assumes that the file system is of ext2 or ext3 type but it s not This can usually easily be removed 8 2 Configuring the boot loader and main SnapGear options The important thing when running the root file system over NFS is to set up the kernel boot parameter to point
17. frame buffer drivers the Gaisler VGA controller has a frame buffer driver that can be included into the kernel from the AMBA configuration menu but first frame buffer support needs to be enabled Enable Console support and Frame buffer under General setup this makes the VGA support able to select JX LINUX SNAPGEAR 20 GAISLER RESEARCH m General setup DA General setup Yylv n PCI bios support Help xX RSA a v Yj v n Use linux memcpy memmove bcopy et al Help vt ylv w hn Networking support Help vv yl n system virc Help AE n Reduced memory footprint Help Vv Yllv n Kemel support for flat binaries Help Ne hone Vv Help y n Console support Help yj w Frame buffer Help Vj Main Menu Next Illustration 3 15 General setup console on frame buffer 3 6 8 GRLib GRPS2 PS 2 interface keyboard The PS 2 driver is dependent on the VGA driver see the section above on how to include the VGA driver The main purpose of the PS 2 driver is to provide the ability to interface a keyboard Both the PS 2 driver and the PS 2 keyboard driver must be enabled to be able to use the keyboard The keyboard supported is an AT keyboard o PS 2 drivers mE PS2 drivers ey lv E n PS 2 support Help y v n Psi keyboara Hep OK Next Prev Illustration 3 16 AMBA PS 2 drive
18. himemloader Help svane n clear Heap MTD utils Vv Yllv te nl cmp Help wyl v n mtd utils Help Sylva nl cp Help v v nl erase Help v i v nl cut Help vy v n erasealt Help w ni date Help Main Menu Next Prev Main Menu Next Prev Illustration 3 19 Flash Tools MTD utilities Illustration 3 18 BusyBox configuration 3 8 Template configurations The Template configurations from the SnapGear main menu are provided as an source of examples It contains prepared Linux kernel boot loader and SnapGear application configurations However it does not include setting and script files such as inittab and rcS Some of the prepared configuration files has been created for a certain template design The template designs can be found in the design directory in GRLIB These configuration files has been used to generate the images found in ftp ftp gaisler com gaisler com anonftp linux images It is also possible to add custom configurations easily by creating a directory under vendor gaisler target templates config_dir and putting the snapgear pxx config into the config dir named vendor config and snapgear pxx linux x x x config named Jinux config The configuration files will automatically be copied into their respective directory upon selection The template name config dir may not TE 2 LINUX SNAPGEAR 22 GAISLER RESEARCH contain characters JX
19. mainly for GRLib hardware The Linux kernel can be configured using a graphical interface One can remove drivers and features to save space On LEON3 systems the AMBA plug amp play information is used to detect devices and load their respective software drivers LEON2 uses hard coded addresses to find its devices During configuration the processor type is selected LEON2 or LEON3 it is done from the Linux kernel configuration GUI and in the main SnapGear GUI Multi processor LEON3 systems are supported by Linux 2 6 21 1 symmetric multi processing support SMP can be enabled through the Linux kernel configuration The Linux kernel can be used for other projects that need not be based on SnapGear The boot loader will still be needed but it is possible to create custom projects with custom file systems Even though it is out of the scope of this document it is described how to set up Linux with other distributions via NFS 1 2 SnapGear Linux SnapGear Linux is a full source package containing kernel libraries and application code for rapid development of embedded Linux systems It is configured from a graphical interface similar to the Linux 2 4 kernel configuration utility 1 3 Boot loader for LEON Linux A small boot loader has been incorporated into the SnapGear Linux software distribution it is designed especially for the LEON processors both SMP and uniprocessor systems It is capable of passing arguments to any of the Linux kernels
20. new settings After the main GUI has been closed and settings been saved a second GUI will appear that is specific for the kernel selected The kernel configuration GUI for Linux 2 0 is shown below Details on how to configure the kernel can be found in the linux 2 0 x Documentation directory The following sections will be used to describe some of the Linux kernel s settings specific to LEON Linux 3 6 1 LEON processor type The configuration of the processor type is done separately for the Linux boot loader and the kernel itself This is done to eliminate the kernel s dependency on SnapGear LEON Linux can be used without SnapGear Certain hardware is only available for LEON3 their drivers will be invisible when LEON2 is selected a uClinux Sparc w o MMU Kernel Configuration SEEN Code maturity level options Controller Area Network Cards Chips Loadable module support Networking options Platform dependant setup Network device support Save and Exit General setup Filesystems Quit Without Saving Floppy IDE and other block devices Character devices Load Configuration from File Leon3 Amba configuration Store Configuration to File Illustration 3 12 Linux 2 0 x kernel configuration utility EE Vendor Gaisler En x Vendor Gaisler Vv Y lliv n APBUart support Help 74 a Platform dependant setup Elle wv Yllwv vi APBUar d spe Help P
21. of the UART every character sent will be recieved UART hardware flowctrl Hardware flow control will be used In memory root file system Romfs Read only root file system Created from snapgear pxx romfs This option is valid for Linux 2 0 x Initramfs A read and write root file system put in main memory See linux 2 6 x Documentation filesystems ramfs rootfs initramfs txt for more information Custom an initramfs is created similar to initramfs The difference is that with this option one can make an file system externally and provide a description how it is created The description is a text file as described in the Linux kernel documentation at linux 2 6 x Documentation filesystems ramfs rootfs initramfs txt None When specified the linker doesn t include the any root file system This means that Linux must read the root file system from an alternative location for example NFS or ATA disk Custom initramfs source The text file used to create an custom filesystem not necessarily based on SnapGear See linux 2 6 x Documentation filesystems ramfs rootfs initramfs txt for details Kernel command line The kernel parameters is specified by a string The string is interpreted by Linux during the boot sequence See linux 2 6 x Documentation kernel parameters txt for details Default console ttyS0 34800 Note When using Linux 2 0 x the kernel command line is set from within the kernel config
22. place the execution log over the network mount t nfs rw logserver export logs nfslogs app gt 2 gt amp 1 nfslogs out_10sep2007 log 6 5 2 TELNET over TCP IP network Logging onto the target with telnet is an easier solution all that has to be done is to set up a telnet server on the target A telnet server telnetd is available in SnapGear from the SnapGear Application configuration utility under Network Applications pes telnet target username root pass KKK Welcome to SPARC LEON3 Linux root target app as LINUX SNAPGEAR 36 GAISLER RESEARCH 7 PS 2 KEYBOARD AND VGA CONSOLE This is an example of how to configure the Linux 2 6 x kernel set up init and it s settings file inittab the boot loader s parameters and the kernel command line The software can be run on a GR XC3S 1500 Spartan 1500 board available at www gaisler com 7 1 Hardware configuration The hardware set up is based on the template design of GR XC3S 1500 and modified as in table 7 1 Hardware Controller Function LEON3 with MMU HW MUL DIV and FPU SPARC v8 Processor with memory protection logic and floating point unit GRVGA SVGA controller GRPS2 PS 2 controller connected to keyboard Table 7 1 Hardware in addition to GR XC3S 1500 template design 7 2 Configuring the boot loader and main SnapGear options Start SnapGear main GUI and configure as in table 7 2 make xconfig
23. printk grlib gt run breakpoint 1 printk 0xf003lelc grlib gt reg INS LOCALS OUTS GLOBALS 0 F0227510 F0399000 F02275E0 00000000 1 00000000 40000400 00000000 00000002 2 00000000 00000000 00000000 F31010E3 3 F0000C7C 00000000 00000140 F0000D94 4 00000000 00000000 00000000 F0237000 5 00000000 00000000 00000001 00000000 6 FOOOFF38 00000000 FOOOFEDO F000E000 7 F0266124 00000000 F02666BC F0000C7C psr F3401FE6 wim 00000001 tbr F0004050 y 00000000 pe f0031lelc mov i0 00 npc f0031e20 st S il Sfp 0x48 grlib gt dis 0xf0031e10 FOO31le10 81c3e008 retl FOO31e14 01000000 nop FOO31le18 Y9de3bf98 save sp 104 sp FOO31lelc 90100018 mov 10 00 0031e20 227a048 st Sil fp 0x48 f0031e24 f 427a04c st 12 Sfp 0x4c f0031e28 627a050 st 13 Sfp 0x50 FOO3le2c 827a054 st 14 fp 0x54 f0031e30 fa27a058 st 15 Sfp 0x58 FOO031e34 40000004 call 0Oxf0031e44 f0031e38 9207a048 add fp 72 ol FOO31le3c 81c7e008 ret f0031e40 91e80008 restore 00 00 FOO31e44 9de3bf58 save S sp 168 sp f0031e48 113c0e2d sethi hi 0xf038b400 00 f0031e4c d2022000 ld 00 Sol grlib gt vmem 0xF0227510 40227510 50524f4d 4c49423a 2053756e 20426f6f PROMLIB Sun Boo 40227520 74205072 6f6d2056 65727369 6f6e2025 t Prom Version 40227530 64205265 76697369 6f6e2025 640a0000 d Revision d 40227540 61766169 6c61626c 65000000 00000000 available grlib gt walk O
24. target Assuming that the compilation of gdbserver has been successful and that GRMON has been started with the flag nswb the GDB server can be started with the following command at the target T LINUX SNAPGEAR 31 GAISLER RESEARCH target gdbserver 1234 app argl arg2 Where 1234 is the TCP IP port app is the application to be debugged and arg and arg2 are the arguments to app Note The debugged application does not have to include any debugging information It can be stripped 6 3 4 Connecting with GDB to gdbserver Below is an example of how to start GDB on the PC and connecting to the target the target board IP address is assumed to be 192 168 0 52 the TCP port 1234 pc cd sources pc sparc linux gdb app_with_debug_info gdb target remote 192 168 0 52 1234 6 3 5 GDB example usage Configuring SnapGear with glibc from compiler linux 2 6 21 1 with gdbserver pc make xconfig Building SnapGear pcs make The binary application is recompiled manually with debugging symbols pc file romfs bin testsin romfs bin testsin ELF 32 bit MSB executable SPARC version 1 SYSV dynamically linked uses shared libs stripped pcS cd user custom pc sparc linux gcec lm g3 testsin c o testsin g pc file testsin g testsin g ELF 32 bit MSB executable SPARC version 1 SYSV dynamically linked uses shared libs not stripped The serial console is connected to a terminal emulator such as
25. 00 0000014 f039900 0000000 f022740 0000000 0000000 f02275e 0000000 f026672 0000000 f0000c7 0000000 0000000 022740 026612 022751 f000fed trapped me Ls L Ls Kg Kd Ls LI LI LU LU LU LU LU LU LU LU LU 560520 ERMGCGGEBSESSSCDvrmr gr 00000000 Sun Boot sd Prom V JX LINUX SNAPGEAR 30 GAISLER RESEARCH GRMON must be started with the flag nswb in order to instruct GRMON not to interfere with the debugging process or else software breakpoints result in GRMON taking over CPU beware this only needed when debugging userspace applications not when debugging the kernel 6 3 1 Setting up a debugging environment Together with the sparc linux toolchain version 1 0 1 and onwards comes bin sparc linux gdb and bin sparc linux insight sparc linux gdb is GDB built for PC Linux able to read debug SPARC Linux binaries The Data Display Debugger DDD is normally available in for download for any distribution DDD is optional as GDB can be used effectively in text mode The GDB TCP IP server can be built within SnapGear by enabling it from the Application Configuration Utility under Miscellaneous Applications gdbserver With GRMON version 1 1 23 the flag nswb was added it clears bit 3 BS in the DSU control register so that GRMON won t interfere with the software breakpoints ta 0x1 6 3 2 GDB introduction GDB is a debugger able to debug multiple languages including C and SP
26. 0xF0227510 Tablewalk f0 8 27 ctx 0 40002000 ctx gt 4000241 tregion f0 400027c0 region gt 400007e segment gt 400007e page gt 400007e 40227510 pte 400007e LINUX SNAPGEAR 29 grlib gt mem 0x40227510 40227510 50524f4d 4c49423a 2053756e 20426f6f 40227520 74205072 6 6d2056 65727369 6f6e2025 40227530 64205265 76697369 6f6e2025 640a0000 40227540 61766169 6c61626c 65000000 00000000 grlib gt inst 20 time address instruction 9303794 02666d4 cmp 00 9303806 02666d8 bne 0x f0266700 9303807 02666dc mov 320 03 9303808 02666e0 sethi hi 0xf0399000 o 9303819 02666e4 ld 00 0x3c0 02 9303820 02666e8 sethi hi 0xf0227400 o 9303833 02666ec orcc 02 Sol 9303845 02666f0 be Oxf0266724 9303850 02666f4 or 00 Oxle0 00 9303851 0266724 nop 9303861 0266728 ret 9303862 f 026672c restore 9303900 0266114 ld 10 0x34c 00 9303925 0266118 ld 00 0x4 ol 9303944 f 0266llc ld 11 0x354 02 9303955 0266120 sethi hi 0xf0227400 o 9303965 0266124 call Oxf0031e18 9303973 0266128 or 00 0x110 00 9303983 f 0031e18 save S sp 104 sp 9303990 f 003lelc mov 10 00 grlib gt watch 0xF0227519 grlib gt cont watchpoint 1 vsnprintf 0x68 0xf010edb0 grlib gt reg INS LOCALS OUTS GLOBALS 0 FO38B000 00000000 0000003A 00000000 1 00000400 FO38B3F8 0000003A 00000002 2 F0227518 00000000 FFFFFFFF F3401FE5 3 FOOOFF80 FO38AFF8 F00001D4 F0000D94 4
27. ARC assembly In this text GDB is used to access a GDB server running on the target board debugging GDB needs e Binaries of the application and optionally the used libraries e Sources used to compile the binaries e The IP number of the target can be found with target sbin ifconfig e gdbserver running on the target part of SnapGear e The gdbserver also need the binary but with or without debug information Debug information is not needed by the GDB server depending on what to debug The libraries and their source code may not be needed When debugging LibC the sources and libraries are of course needed See the previous section Debugging symbols on how to create binaries with debugging information 6 3 2 1 Adding additional source search paths Sometimes GDB can not list the C code that may be due to missing debug information not even searching for C code or it can not find the source files mentioned in the debug information It is not recommended to change the source files after the debug binary has been created If the binary is compiled on the same computer running sparc linux gdb one need not to add additional paths normally The path information is coded into the binary however when running GDB on a different computer than the build host the path information is invalid and it may be needed to add additional search paths Search paths can be added with the d dir1 dir2 dir3 flag passed to GDB 6 3 3 Starting GDB server on
28. ARE ache Seles SNNE K NEN R 34 6 4 Using NFS to simplify application UPCateS sseerereresesersersrrsrererrerrrrrrrrrerrrrrrnrsnerrrr rr enn rr rr rr rn rr nea 34 6 5 Console output when debUggilQ esserssssrsrrsrsrrsrrrrsrrsrerrrrrsrrr renen rr r rn rr rr REKA KRKA KAR KRKA RR RKA KKR nr e rn 35 6 5 1 Redirecting output to NFS Sh afO tssssssunsss rassnsesss sesiussondersrassnssssaspisanstossssensskpatsdiestapasdessensasoniardnens 35 6 5 2 TELNET over TCP IP network cs scestescoseseseesezsshacdenccscvtts sia a E Te aea a hese esse Ea a 35 7 PS 2 KEYBOARD AND VGA CONSOLE 0 cccsssssssssssseesesesseseeeeseeeeseecaeeeseneeseeeeaeeeeeeesaeeneeeasens 36 7 1 Hardware Configuration ccccccccccesssscessesecessececeeseeeseeseceeesseceaessesesecseceseseesaeseneeaesesesaeeeseeeeeeeereesaes 36 7 2 Configuring the boot loader and main SnapGear OPtiONS sesssrssesrersrsrsrrrrsrsrsreresrsrsrsrrrrrrsrsrsr rn rn 36 7 3 Configuring the Linux Kernel cccccccccescesceeeesseeseeseeeseceeeaeceeeaecaeeseeaeseeensesaeeeaeseeenaeeeeeeeeeeesaes 36 7 4 Configuring SnapGear APpliCatiONS ssesssesssresrsrsrsrsrereresrsrereresrsrsrsrererrsrs rer ere ers r sr ere ere ere rer n nn 37 7 5 Building the kernel and appliCatiONS ssessssrssesresersrrsrerrsrsrrrrrrrernrsrrsrrrrsrer rs eran rr rer r rer KR KRK enn rn era 37 7 6 Setting up eteina Diss ca N eaa a ER E a Ee o susan NGN Eas 37 TT Building again with inittab and re Sh e ce eecesescee
29. GAISLER RESEARCH SnapGear Linux for LEON Manual SnapGear Linux for LEON Written by Daniel Hellstr m LINUX SNAPGEAR Version 1 36 0 December 2007 F rsta L nggatan 19 413 27 G teborg Sweden tel 46 31 7758650 fax 46 31 421407 www gaisler com LINUX SNAPGEAR 2 GAISLER RESEARCH Table of Contents 1 INTRODUCTION i sscicieiavaieats cass ehel eine pide E RG eR eatin ain 5 1 1 LEON VX SAS E E E E 5 1 2 SnapGear LINUX erman rem nire e E veeaed E E E E a e i EOS EENE 5 1 3 Boot loader for LEON Linux cccccceccesceescesesscesseeeceesececessecscecseccesseceaeeseseaeseeseeeseseseseneeesesesseeeneas 5 1 4 LEON simulator to speed up the development PrOCeESS ssereersrersresrsrsrsrerrsrsrsrsreresrsrsrsrersrerrsrrr rr rna 6 1 5 Obtains the Softwares sas cececcsseass lecsvears neiseina EESE ANE Ean E aE RIENA E A ARRES 6 1 6 Supported Ward Ware eneee a E Ea E aaa eE Inre OTE Eie RS eE EA EEEE EN 6 1 7 DUP POM eeii pea aa E a a AT ERN 6 2 INSTALLING GNU TOOLCHAIN AND LEON LINUX sssonsssrsrsssrserersrsesesesererererersrsrserrrrrrsrr rr rn ran 7 2 1 Selecting Wool charts ss c555 dscns degeducdad vaca bees cules cayucss eau te aidesas vosehe ruas nee n Arona EE ENR Hr NT sizes ERKI 7 2 2 Installing the toolchain siirsin aeaa a a ee Meutasdpaaieeensateeed s 7 2 3 Installing SnapGear for LEON Linux 2 0 sesssesrsrrsrsrersreseseresrsrerserrsrerereresrsrsrsrsrer ers renen ert rs rens ens r na 8 2 4 Installin
30. GRLib GRETH 10 100 Ethernet MAC Select GRLIB_GAISLER_GRETH to enable the 10 100 Ethernet MAC The Ethernet MAC address of the GRETH MAC can be edited directly from the GUI The address is made out of an unique 6 byte sequence Byte 0 is the most significant byte The Ethernet hardware address can be found by running sbin ifconfig on a UNIX machine 3 6 5 GRLib OpenCores 10 100 Ethernet MAC OpenCores 10 100 Ethernet MAC modified for the AMBA bus included in GRLib can be used by enabling the driver under Leon3 AMBA Vendor Opencores The Ethernet address must be set to an unique 6 byte network identifier The driver can force the Ethernet MAC to operate on a 1OOMHz signalling frequency by setting Set MII to 100mb 3 6 6 SMC 91C111 10 100 Ethernet MAC After enabling Networking support from the General setup sub menu the SMC driver can be enabled under Network device support The base address IRQ and Ethernet address is configurable The Ethernet address must be unique on the network The base address and the IRQ number can be found by examining the hardware set up of the target board typically found in the user manual or the schematics 3 6 7 GRLib VGA text frame buffer support The VGA text frame buffer make it possible to output text onto a standard monitor The programming interface used to access the AMBA VGA graphics controller is called frame buffer The frame buffer has hardware device drivers called
31. L DIV LEON3 with or without MMU FPU MUL DIV LEON3 multi processor systems SMP APBUART GPTIMER GRETH 10 100 and Gbit OpenCores 10 100 Ethernet MAC SMC91x 10 100 Ethernet MAC APBPS2 APBVGA GRUSBHC GRVGA ATACTRL GRPCI GRETH over PCI GR OpenCores I2CMST SPICTRL Note that new hardware is being added constantly 1 7 Support For support contact the Gaisler Research support team at support gaisler com JX LINUX SNAPGEAR 7 GAISLER RESEARCH 2 INSTALLING GNU TOOLCHAIN AND LEON LINUX SnapGear has been split up into two different distributions one for Linux 2 6 development and one for Linux 2 0 development The toolchain is a composition of several utilities used in the compilation process It is intended to be used with Linux only the most important utilities are the GNU GCC compiler and linker The toolchain is a cross compiler toolchain making it possible to compile LEON SPARC Linux binaries on an ordinary PC running Linux The toolchains are distributed as a binary package freely available at www gaisler com 2 1 Selecting Toolchain For Linux 2 0 selecting toolchain is simple as only one is available the sparc linux 3 2 2 For Linux 2 6 however one select toolchain based on what C Library is going to be used installing multiple toolchains cause no harm The two toolchains available for Linux 2 6 are sparc linux 3 4 4 and sparc uclinux as indicated by the table below The next chapter gives
32. Lib GRETH 10 100 Ethernet MAC ossssesssessiovsssserssassossres rvsnssnsnssnenesns esssenisndessasetsssnss snsosssentensre 19 3 6 5 GRLib OpenCores 10 100 Ethernet MAC ee eesceseesssseenesseeseeseesceseeseeseeeceeceeeeesseeaesneeaeeaeeeaeesaee 19 3 6 6 SMC 91C111 10 100 Ethernet MAC sasssa aa EE A 19 3 6 7 GRLib VGA text frame buffer SUPpPOL s svsssessnssiesevssesrssvssstsssersnrstsnss nsss rssesernssrsrer sE o 19 3 6 8 GRLib GRPS2 PS 2 interface keyboard ecccceccceseesseeeeeeeeseeseeesecaeeeseeseecseceeeeseceeeaeeeneeeeeeeensaes 20 3 7 Applications included in ROMFES o sssssrssrssssrssrsrerreresreresresrersrsrrsrrnrerrsrer rr rer rrr rr n ers nr RR RKA RENAR REK RR Rn rr n na 20 3 8 Memiplate COnh Surat OUs s 635s5s 0s5senwu eosi aipe ies eagyeaieystastsashs age sac eide EA a ara Riders 21 4 BUILDING SNAPGESA R 2a 664 biverk oii ARNE Aes aston ieee R 23 5 ADDING CUSTOM APPLICATIONS ccecccscssssesseseeeeseeesseeeseeeseeecseecseeecseeecseseeaeeecaeseseseeeeaees 24 LINUX SNAPGEAR 3 GAISLER RESEARCH 5 1 Creating an pPpliCallON esssssseesisersibars kassk snssveness r ret isee e EREE ENEE ESENE IES EERS ERER NAT Snr SO dAR RKA eder 24 5 2 Setting up compilation Cirectives ccc sessesescecceseeeceeceeceececeeecsessesseeseeseeseeseeeseeceeeeteeseeneeeneeees 24 5 3 Including application to file SyStem cecescceseeseeesesseeeseeseeeseceeeesecseeesecceesecneeeaeseseseeeeaeeeseeeeeaaes 24 6 DEBUGGING LINUX
33. NSTDIR dev mknod ttyS0O c 4 64 In case of trouble booting Debian it may be of good practice to change the run level to 1 or 2 in inittab before booting The default runlevel id 2 initdefault 11 6 Changing root directory and booting Debian Before booting the kernel command line needs to be updated to reflect the new root file system Enter the make xconfig GUI and update the kernel command line to include the debian directory nfsroot 192 168 0 20 export busybox_rootfs debian Make the configuration rebuild the image and run the image make xconfig make image grmon jtag nb load images image dsu run UY Ut 4 UI i 11 7 Adding a telnet server to Debian During the development process it often comes in handy with a telnet terminal The telnet terminal isn t limited by the bandwidth as the serial terminal making it to an excellent choice when running or debugging new applications The easiest way of installing applications in Debian is using the apt get utility The apt get utility can be setup to fetch binaries from close mirror servers by editing etc apt sources list Setting it up on the LEON target T LINUX SNAPGEAR 51 GAISLER RESEARCH echo deb ftp ftp se debian org debian stable main contrib non free gt etc apt sources list apt get update Installing telnet server can be done as follows apt get install telnetd It is generally an good idea to have a look in the etc in
34. PDIR wget http ftp se debian org debian pool main d debootstrap DEBOOT cd work_sparc ar xf STMPDIR SDEBOOT cd SBUSYBOXLINUX tar zxvf STMPDIR work_sparc data tar gz Nr MMW ANA The two debootstrap applications should now be working both for the LEON target and the PC 11 3 Downloading Debian binaries using PC Downloading Debian binaries to PC 2 LINUX SNAPGEAR 50 GAISLER RESEARCH mkdir p INSTDIR T usr sbin debootstrap download only arch ARCH DISTNAME INSTDIR SMIRROR 11 4 Installing Debain binaries from LEON target The LEON target is able to access the binaries downloaded by the PC in the previous step by entering the debian directory Invoking the Debian installation utility debootstrap with the correct parameters makes it continue the installation process this step may take some time to complete usr sbin debootstrap sarge debian 11 5 Adding a serial console to Debian Even though the system console may be the serial terminal no shell is given unless explicitly telling init to launch one This can be done as previously described by editing the etc inittab in the Debian root file system Add or uncomment T0 234 respawn sbin getty L ttyS0O 38400 vt100 Getty will present us with a login prompt at serial channel 0 One must make sure there is a valid serial terminal device node for getty to open in dev ttyS0 If the device is missing it can be created by mknod cd SI
35. THERNET USING ATA OVER ETHERNET A network root filesystem can also be provided using ATA Over Ethernet on Linux 2 6 This setup requires two steps creating an ATAoE server that exports a block device containing the root filesystem and configuring the LEON to boot using the exported ATAOE root block device ATAoE block devices may be formatted with an arbitrary filesystem For example well supported Linux filesystems such as ext3 or xfs may be used The ATAoE server must be on the same Ethernet Local Area Network as the LEON 9 1 Setting up ATAOE Server The ATAoE server vblade can be run on any supported Unix system including Linux and FreeBSD Vblade can be obtained at http aoetools sourceforge net Installation documentation is included with vblade although typing make followed by make install as root should be sufficient for Linux systems With vblade installed the next step is to configure the block device that will be exported by vblade The block device may be in one of two formats a flat file or an actual block device We will first show how to configure a block device for vblade as this is the easier of the two options This example formats the block device dev hdb using ext3 and then copies a SnapGear root filesystem to dev hdb mke2fs j dev hdb mount dev hdb mnt tmp cp rpd daniel snapgear pxx romfs mnt tmp umount mnt tmp Now we will show how to configure a flat file to be used as a vblad
36. UX SNAPGEAR 8 sparc linux gcc o args args c or sparc uclinux gcc o args args c From the ELF header it can be read that the output binary is a SPARC binary file args args ELF 32 bit MSB executable SPARC version 1 SYSV linked uses shared libs not stripped Running the binary on a SPARC Linux host results in args Gaisler args you passed 1 argument s 2 3 Installing SnapGear for LEON Linux 2 0 Install the SnapGear distribution by extracting it mkdir linux cd linux tar xjf path to dist snapgear 2 0 p36 tar bz2 ls snapgear 2 0 p36 2 4 Installing SnapGear for LEON Linux 2 6 Install the SnapGear distribution by extracting it mkdir linux cd linux tar xjf path to dist snapgear 2 6 p36 tar bz2 ls snapgear 2 6 p36 GAISLER RESEARCH dynamically eo LINUX SNAPGEAR 9 GAISLER RESEARCH 3 CONFIGURING LINUX SnapGear comes with an easy to use graphical interface similar to the Linux kernel s configuration utility From the GUI it is possible to select processor Linux version C library and what applications will be included into the root file system ROMFS image accessed by Linux during runtime It is also possible to configure the boot loader parameters and configure the Linux kernel The GUI can be launched by doing a make xconfig The main configuration menu should appear a Gaisler Leon2 3 mmu options ITA
37. X USB support Virtual Frame Buffer support ONLY FOR TESTING FB_VIRTUAL Illustration 3 10 Adding Frame Buffer driver Multimedia devices Digital Video Broadcasting Devices Graphics support Console display driver support Logo configuration O Backlight amp LCD device support When using the SVGA controller to provide console interface to the system the resolution bit depth and other parameters can be set from the kernel parameters Table 3 4 lists available arguments to the driver The Mem size parameter can be calculated as resolution times bit depth in bytes For example 614400 bytes video buffer makes a resolution of 640x480 8 bit 640x480 16 bit and 800x600 8 bit resolution possible however 800x600 16 bit would not fit into the memory as that would need 960000 bytes LINUX SNAPGEAR 17 GAISLER RESEARCH Order Value Custom All Description 0 video grvga All Needed to select frame buffer driver 1 Custom All Select one of the values to the left When full control 1024x768 60 ea See ane 2 10 are 800x600 72 needed in addition to 11 and 12 800x600 60 640x480 60 2 Pixelclock Custom Pixelclock in ns 3 xres Custom Horizontal resolution in pixels 4 rmargin Custom Horizontal Front porch in pixels 5 hsync_len Custom Horizontal Sync length in pixels 6 Imargin Custom Horizontal Back porch in pixels 7 y
38. ation can be enabled in SnapGear from the Application Configuration Debug Builds build debugable applications 6 2 Debugging the kernel In practice hardware debug support of some kind is needed when debugging the kernel It is possible to debug the kernel using various other methods such as inserting printk calls in the kernel code or using the proc filesystem See the chapter Debugging Techniques in Linux Device Drivers for more information about debugging techniques However these methods are rather time consuming and may change the behaviour and the execution path Using a hardware controlling debugger gives the user a completely new way of controlling and monitoring the execution Hardware debuggers such as GRMON vastly accelerates the development process It is possible to read and manipulate both processor and core registers walk the MMU page set up view cache content list previous instructions instruction trace just to list a few The kernel s addresses are static and can be known on before hand whereas multiple user space applications threads may have the same virtual address making it impractical in many cases to use hardware debuggers Using a software debugger like GDB run natively or a GDB server acting as a server for remote GDB connections is preferred when debugging userspace applications JX LINUX SNAPGEAR 26 GAISLER RESEARCH 6 2 1 Configuring GRLIB for kernel debugging It is assumed that hardwar
39. been made only to the file system one can rebuild the images without having to recompile kernel libraries and applications make image After building the images the image can be found at images image dsu Note that image flashbz does not function correctly since the boot loader s SDRAM and flash settings hasn t been set up properly 7 8 Running on hardware The far most simplest method of testing the image is to run it using grmon as follows Depending on what debug interface is available the parameters to grmon may differ see grmon documentation for details cd images S grmon jtag nb grmon gt load image dsu grmon gt run When everything is working as planned the connected monitor will first display a small penguin kernel messages and then launch a shell on ttyl tty2 and the serial terminal ttyS0 It is possible to switch between tty1 3 by pressing ALT F1 F2 F3 at the connected PS 2 keyboard JX LINUX SNAPGEAR 39 GAISLER RESEARCH 8 ROOT FILE SYSTEM OVER ETHERNET USING NFS Often during development it is favourable to use NFS as root file system as it is a tedious process reprogramming the flash each time a change is made and also there is no need in rebuilding the romfs image Settings can be preserved after system reboot Setting up root over NFS involves two steps installing the NFS server on the PC and configuring the LEON Linux image The NFS server is assumed to be installed and therefore not
40. booting Deblial eseesssrrsrsrrsrrrrrrrsrrsrrnrsrrrnsrrrrrr ner rr ner rr rskr rr n en rn rr rn rna 50 11 7 Adding a telnet server to Debian eee eececsesesseeseeseesesecesceceeecececeseesesseeaeesesaeeaesaeeaeeaeeaeeateeeeeeee 50 11 8 Installing Xorg XIT Servers cs eicint e n E PERE sede dies sd vs as 51 12 SUPPOR Tesnnis iene sie ne a ee ee en eee 52 JX LINUX SNAPGEAR 5 GAISLER RESEARCH 1 INTRODUCTION LINUX support for LEON2 and LEON3 is provided through a special version of the SnapGear Embedded Linux distribution SnapGear Linux is a full source package containing kernel libraries and application code for rapid development of embedded Linux systems The LEON port of SnapGear supports both MMU and non MMU LEON configurations as well as the optional V8 mul div instructions and floating point unit FPU A single cross compilation tool chain is provided which is capable of compiling the kernel and applications for any configuration LEON Linux has support for symmetric multi processing SMP it has not been extensively tested yet but work is in progress 1 1 LEON Linux There are two different versions of the Linux kernel in the Gaisler SnapGear distribution namely 2 6 x and 2 0 x The 2 0 version is modified for use with MMU less LEON systems it is called micro controller Linux uCLinux 2 6 x has support for MMU systems only the kernel is from kernel org with LEON specific patches and additional drivers
41. e breakpoints watchpoints and the instruction trace buffer have been enabled in the GRLIB xconfig during system configuration Depending on the complexity of the problem to be debugged the number of breakpoints and the trace buffer length to select may vary In the template design of the GRXC3S 1500 board the trace buffer can be enabled from Processor Debug Support Unit Instruction trace buffer and hardware breakpoints from Processor Integer Unit Hardware watchpoints in GRLIB xconfig cd designs leon3 grxc3s 1500 make xconfig GRMON can verify the debugging support available by running the command info sys below is a design with 2 hardware breakpoints 2 hwbp and a 128 instruction deep trace buffer itrace 128 grmon jtag grmon gt info sys 02 01 004 Gaisler Research LEON3 Debug Support Unit ver 0x1 ahb 90000000 a0000000 AHB trace 128 lines stack pointer 0x43fffff0 CPU 0 win 8 hwbp 2 itrace 128 V8 mul div srmmu lddel 1 GRFPU lite icache 1 1 kbyte 32 byte line dcache 1 1 kbyte 32 byte line 6 2 2 Using GRMON GRMON can be used to debug the Linux kernel it is primarily an assembler debugger but it is C symbol aware Symbols created by gcc when compiling C code with the g flag are automatically loaded by GRMON after a successful load file command but is also possible to load symbols manually by issuing the command symbol file The symbols last loaded are matched first During the image creating p
42. e exported block device In this example we create a 4GB flat file rootfs img formatted with ext3 containing a SnapGear root filesystem dd if dev zero of rootfs img bs 1024 count 4000000 losetup dev loop0 rootfs img mount dev loopO mnt tmp cp rpd daniel snapgear pxx romfs mnt tmp umount mnt tmp losetup d dev loop0 E E HE He HE E Make sure that the vblade exported root block device has been unmounted and in the case of a flat file that losetup d has detached the file from any loopback devices before running vblade Now run vblade vbladed eth0 0 0 eth0 path to root device In this example vblade is run with shelf 0 slot 0 over Ethernet network interface eth0 exporting the device at path to root device To use the devices set up by our examples we could replace path to root device with dev hdb or rootfs img respectively The shelf and slot numbers are used for naming purposes they allow the server to run multiple vblades As long as each block device is exported with a different shelf or slot number the client can select which of the exported block devices it wishes to access In our examples we will use shelf 0 slot 0 as we are not using multiple vblade servers The ATAOE server is now operational and its output will be sent via syslog to var log messages Note that because vblade operates over Ethernet and not TCP IP it does not bind to a port nor is it accessible from any machine outside of the loca
43. eecsecesseeeseeecseeeeseeeeneseenesaceesaeeesaeeetaeeeeens 14 3 5 5 LEON Serial LEON Jecira e ra AE a T arse a E R TAAS 14 3 5 6 GRLibsGRETH 10 1 00 1000 cisien sinies nennen areena HU Gee 14 3 5 7 GRLib OpenCores Ethernet MAC a ssssnssoqssssnsessnsssnstsosatotsnsisnasesdasensessninssosbsnossnsenvdanssorkeosuemsksenensrsn 14 3 5 8 SMG 91x Ethernet MAG neeaae sis EnA E E ET T SAE N EER 15 3 5 9 GRLib GRETH 10 100 1000 over PCL cccececcesessecesseeeseeseseeseseescseescsesseseescseceeeesaeeesaeeesaeeesaeeeeees 15 3 5 10 GRLib OpenGores 2G miaster is seis cediecsisieccstesesisctassesdecesdvecesaequeesdesneyscuedhestavscndedeleccneviesdeces Gacdeeenes 15 3 5 11 GRLib PCI support iccscec cceedncied ceeds ee senast rnns s n ns Giesteeadli ei nese estan eas eeatvea eee talanads 15 3 5 12 GRIEIDIGR PSD brann A A E EA cupeseae diag eta NR SARAS SAR eee 15 3 5 13 VG RIAD SPIG TR sca cos azact scsecvesstss E EE E E E A E 15 3 5 14 GRIib GRUSBHG orrera een onan hintaan lieder deeasciauletian gino 16 3 5 15 GREB GRV G Accea a a a E a e Gals Masten aaa ere 16 3 5 16 GRED ATA Controllet sensacions aaia oeaan kai e E AN E E ENAA E Aaea E 17 3 6 Configuring the 2 0 x kernel ccc ccccceescesceeseesseesececeeseceaeeseceseesecnsecseseseseeeseceeesaeecnseesenueeenseeeesaes 18 3 6 1 LEON Processor yP sisino a a A E E E E a ER 18 3 6 2 GRLib APBUART LEON 3 Josce oarnein sa E EE 18 3 6 3 LEON Serial TEON i scies cies cathasestehs A A NEE E S 19 3 6 4 GR
44. eeeeeceeeeeeeeeeeeecseeseesessesseeaeeeesaceassaseeseeeneeseratente 44 9 6 Running on hard wate sssecsicissiscc ierssbars sts nis E a R R E A A 45 10 RUNNING GRLINUX SPLACK FROM AN ATA HARD DISKasssossossrsesesrsesessrsrsrsnseserererererensrnr 46 10 1 Installing the kernel onto fl Slh sssssssrssrsersrrsrsrrernrsrernrsrrrrsrrsrsrrsnrr rr rr rer rr RR KRK RAR R RAK R RAK REKA RK Kron rr nera 46 10 2 Preparing the Hard drives 2 25 25 2ccjssacesi hevenetestesadigecetestade ibis davestaqnsidasstagdhanadeanvaliveasd Geclanseotesutines teal 46 10 3 Ruining Splack oo 5 35 isceccschsckentvaceavsesses caidas eae ras O bests sas ea De R E VINER NNE NA 47 11 INSTALLING DEBIAN 3 1 ON LEON LINUX sorsrosesrsrsrsrsnesesesrereneresrsrsrernernesesrensnenenrrrsnener ren n enar 48 LINUX SNAPGEAR 4 GAISLER RESEARCH 11 1 Preparing LEON tatpet aii wvisd cited acne hai es adh nel eel anes ieee 48 11 2 Installing Debian installation utility to PC and LEON t rgets ssssssssrsrssrsrrsresrenrsnesrrnrornerrsrnernrrnnrr nr rn 49 11 3 Downloading Debian binaries using PC eeeseeceseeseeseeseeseeseesesaeeaeesceeeeccsaeeseeneesseeenaeeeateaee 49 11 4 Installing Debain binaries from LEON t rgets sssssssesrsrsrsresrsrsrsrerersesrsrsrsrersrsrsrsrsrererrsrsrsr ere errsr rn r rna 50 11 5 Adding a serial console to Debial sesersrersersrsrsrsrsrrsesrsrsrererrrrsrsrsrrr ers rs rsr enes en rs rer Ren rer r rerna 50 11 6 Changing root directory and
45. el Library Defaults Selection Kemel Library Defaults Selection linux 2 6 18 1 Kernel Version glibc from compiler Libe Version fault all settings lose changes glibc from compiler A microLibe stomize Kernel Settings uClibc stomize Vendor User Settings vy Ma n Update Default Vendor Settings Main Menu Next Illustration 3 3 Kernel LibC and application selection menu 3 4 Configuring the boot loader The boot loader sets up low level hardware before entering the Linux kernel The parameters of the boot loader can be set using the main SnapGear GUI Below is a description of available boot loader parameters LINUX SNAPGEAR o 12 GAISLER RESEARCH Name Description SPARC v8 MUL DIV When Yes the compiler emits hardware integer multiplier instruction If the LEON processor has been configured without hardware multiplier select No the compiler will then generate SPARC v7 compatible code instead without any MUL or DIV instructions FPU support Select Yes if LEON has a Floating point unit FPU Clock frequency The frequency is needed for the boot loader to calculate timing values Value is in kHz Baudrate The baud rate of the first serial terminal Typically 38400 baud It is favourable to use the same baud rate for the Linux kernel UART Loopback on Enables the loopback mode
46. erminal emulator is connected to the serial port at 38400 baud The first boot after power up will fail on the lattice board because the DDR RAM needs to be manually reset Push the reset button and the kernel should boot and mount the CF disk The root password is set to qwerqwetr One must always terminate the system using the shutdown h command before switching of the power This will sync the file systems otherwise data can get corrupted or lost Before it is okay to turn power off or reset it a message will be printed at the console Shutdown hda Power down 2 LINUX SNAPGEAR 48 GAISLER RESEARCH 11 INSTALLING DEBIAN 3 1 ON LEON LINUX Debian is a widely used Linux distribution freely available at www debian org Debian is available platforms including SPARC Debian binaries expect FPU and hardware integer multiplier to be available For further installation information refer to the installation manual at Debian s homepage Normally when installing Debian installation diskettes or compact discs are used to boot Debian Installation program However installing Debian on LEON involves a different approach where it is installed from an UNIX host directly onto a disk or a NFS share The Installation procedure is split in two stages first Debian binaries are downloaded and verified from the internet the second stage involves running the binaries on a LEON target board doing the real installation and config
47. ernel configuration GUI for Linux 2 6 is shown below Details on how to configure the kernel can be found in the linux 2 6 x Documentation directory In later chapters some common configurations will be presented The following sections will be used to describe some of the Linux kernel s settings specific to LEON Linux Features and drivers often depend on other features the dependencies is sometimes not trivial The dependencies can be seen in a C programming similar syntax by enabling Show debug info from the Option menu The dependency can be seen down to the right by selecting the feature in question File Option Help lols m Il E Option Option Code maturity level options OSymmetric multi processing support does not work on sun4 General setup O Support for SUN4 machines disables SUN4 CDM support Configure standard kernel features for small systems Running on SoC Leon the open source sparc VHDL model Loadable module support Block layer O Support for PCI and PS 2 keyboard mouse 1O Schedulers O Openprom tree appears in proc openprom LLL OSun m LED driver Grlib Amba device driver configuration m Kernel support for ELF binaries Vendor Gaisler O Kernel support for a out and ECOFF binaries Vendor Opencores OKernel support for MISC binaries Networking OSunOS binary emulation Device Drivers Generic Driver Options Connector unified userspace lt gt kernelspace linker Memory Technology
48. es Customize Vendor User Settings Yes Libc version None 9 3 Configuring the Linux kernel In addition to the default settings of the Linux 2 6 x kernel add the features described by the following table LINUX SNAPGEAR o 44 GAISLER RESEARCH Name Function Networking NET Networking support INET TCP IP protocol IP_PNP Disable IP PnP kinit will provide this functionality for us Device Drivers Network device support NETDEVICES Enables the network device driver interface General machine setup Grlib AMBA Gaisler GRLIB_GAISLER_GRETH Add Gaisler Ethernet 10 100 1000 driver Select a unique Ethernet address in the MSB and LSB fields Device Drivers Block Devices BLK_DEV_INITRD Disable INITRD support ATA_OVER_ETH Add ATA Over Ethernet block device support File systems Network file systems EXT3_FS Ext3 journalling filesystem support 9 4 Configuring the vendor user applications At a bare minimum klibc kinit support must be enabled for ATAOE root to work Furthermore we recommend disabling all other applications as there will be no need for them This is because kinit immediately switches the root filesystem to the ATAoE block device at startup and does not invoke or require any other applications or libraries Configuring a root filesystem with only klibc kinit while not strictly required will result in a
49. escription of how the SnapGear ROMFS can be configured JES GAISLER RESEARCH Name Function BusyBox Init First application that gets started after boot Init use inittab Make init read etc inittab for settings Table 7 4 SnapGear configuration 7 5 Building the kernel and applications Building the kernel libraries and applications can be done as follows make 7 6 Setting up etc inittab Init reads the etc inittab line after line at start up and launches the etc rc sh system initialization script and spawns applications on each console as set up Jnittab can be created by typing TE a LINUX SNAPGEAR 38 GAISLER RESEARCH cat lt lt EOM gt romfs etc inittab t System initialization script isysinit etc re sh Make serial terminal have a console ttyS0 respawn bin sh t Make consoles appear via frame buffer ttyl respawn bin sh tty2 respawn bin sh tty3 askfirst bin sh EOM rc sh can be typed in as follows cat lt lt EOM gt romfs etc rce sh bin sh mount t proc none proc mount t sysfs none sys mount t devpts devpts dev pts hostname sparky sbin ifconfig lo up 127 0 0 1 netmask 255 0 0 0 route add 127 0 0 1 dev lo EOM For the new script to be able to run one must add execution permission to it chmod x romfs etc rc sh TA Building again with inittab and re sh Since changes has
50. etd conf and verifying that telnetd is correctly configured To make the telnet server appear on the network inetd may need to be restarted to reread it s configuration file sometimes it is enough sending inetd it the SIGHUP signal 11 8 Installing X org X11 Server The graphical X server is normally operated using keyboard and mouse See the chapter PS 2 and VGA on how to setup the monitor and PS 2 keyboard The peripherals and monitor GRVGA is setup in etc X1 1 xorg conf installed with apt get Installing the graphical X server fbset a frame buffer utility X fonts and xterm terminal emulator is similar to installing the telnet server in the previous section apt get install xserver xorg apt get install xfonts base apt get install fbset apt get install xterm Configure the X server by editing etc X11 xorg conf After setting up the X server properly it is possible to start the server with extra debug output by adding the option verbose level X verbose 3 T LINUX SNAPGEAR 52 GAISLER RESEARCH 12 SUPPORT For support contact the Gaisler Research support team at support gaisler com
51. fo on IDE drives Memory Technology Devices MTD O Support for SATA deprecated conflicts with libata SATA dr Parallel port support o Include IDE ATA 2 DISK support NEW Plug and Play support Use multi mode by default NEW Block devices Include IDE ATAPI CDROM support NEW FATA ATAPI MFM RLL D Include IDE ATAPI TAPE support EXPERIMENTAL NEW SCSI device support o Include IDE ATAPI FLOPPY support NEW Multi device support RAID and LVM OIDE Taskfile Access NEW Fusion MPT device support IDE chipset support bugfixes IEEE 1394 FireWire support generic default IDE chipset support NEW 120 device support ae ATACTRL driver ATA Controller suppo Alataarl daiira minnart Illustration 3 11 Enabling ATACTRL Once the ATA controller is enabled the IDE devices that needs to be supported are to be selected most commonly the IDE ATA 2 DISK support is selected N LINUX SNAPGEAR 18 GAISLER RESEARCH 3 5 16 1 DMA Extension The DMA extension of the GRLib ATA controller can be enabled by selecting BLK DEV IDEPCI BLK _DEV_IDEDMA PCI in addition to the options described for the standard ATA controller Note that enabling the DMA extension does not disable the standard ATA controller driver 3 6 Configuring the 2 0 x kernel 6699 From the graphical interface it is possible to configure the selected kernel by selecting y at Customize Kernel Settings and saving the
52. g SnapGear for LEON Linux 2 0 ssssssrssrssrssrrsrrsessrsresreresrerrerrsrsrrrrrrnen renen rr r rr rr rr RR nr RK rr rer enn rr nn 8 3 CONFIGURING LINUX simi rhan erae E b n esda seed ons s ses sens nig AE e aO A sedd 9 3 1 Processortype and WIM s aisset sues giao i eaea aa aE aa aeaa aieeaa Aa aege EERS 9 3 2 BA Porten ia E E E ied 10 3 2 1 Static vs Dy amic linking ssmsssssnssisersyntsdinrs eian aE E A ATE E E AARE NS NEN A 10 3 2 2 Toolchaims for LINUX 20 io enenss raene enno aeea E ESE EE EE Ne E Sa estes 10 3 2 3 Toolchamms for Linux 2 0 narra oes Nees paa E a a Ea Radins 10 3 3 Kemmel Verslo enean eaae E sd Oo aca ei ae E R EE NE 10 3 4 Configuring the boot Loader eee eceeceececceeseeeeeeeeesecseesecaeesesseeaesacseeceasessceseeeseeseesseeenaeeeatesaee 11 3 4 1 Symmetric multi processing cccecessseseeesseseseeseeseeseeeceeceeeeececeeseceeecsesseeseeaeeseseeesneeseereeeeseeees 13 3 5 Configuring the 2 6 x KEIMCl s msssssessersrsersrrsrerrsrrrrrrnrsrrrrerrrrer rer ere rr rr RR RAR ARKA KARA K AKAN K ARR R KRK KRK KR rr n nn 13 3 5 1 LEON Processor BY D siret R esd essensen G R E aE 13 3 5 2 Symmetric multi processing SUPPOTt ccccecceseecessceseeseeeeeeseeeseeseceseeseeeseceeesececeeeseeeeeeteeeneaeeeaes 13 3 5 3 Gaisler AMBA Plug amp Play procfs SUPPOI sssssssresersrsereresrerrernerrerrsrrrrrrrrrrrrrrrr ner rr rrr rr rr rr rr r nr rn n era 14 3 5 4 GRLib APBUART LEONSD cccecescssssctsescseesceeseeeeseeecs
53. guration the applicable host controller drivers are EHCI HCD 2 0 support and UHCI HCD most Intel and VIA support INpUt device support Support for Host side USB USB Hardware VO ports COUSB verbose debug messages USB_DEBUG Character devices Miscellaneous USB options Serial drivers OUSB device filesystem USB_DEVICEFS IPMI ODynamic USB minor allocation EXPERIMENTAL USB_DYNAMIC_MINORS i Watchdog Cards USB Host Controller Drivers TPM devices HCI HCD USB 2 0 support OFull speed ISO transactions EXPERIMENTAL SB EHCI SPLIT ISO ORoot Hub Transaction Translators EXPERIMENTAL SB EHCI ROOT HUB TT USB EHCI HCD U U O Improved Transaction Translator scheduling EXPERIMENTAL USB_EHCI_TT_NEWSCHED U U uU Dallas s 1 wire bus ardware Monitoring suppo ware ring s OISP116X HCD support SB_ISP116x_HCD ultifunction device drivers UHCI HCD most Intel and VIA support SB UHCI HCD Multimedia devices OSL811HS HCD support SB_SL811_HCD Digital Video Broadcastin USB Device Class drivers Graphics support DUSB Modem CDC ACM support USB_ACM GBacklight amp LCD devici USB Printer support USB_PRINTER Console display driver s NOTE USB_STORAGE enables SCSI and SCSI disk support may also be needed see USB STORAGE Help for more information USB Mass Storage support USB_STORAGE i OUSB Mass Storage verbose debug USB_STORAGE_DEBUG USB Network Adapters ODatafab C
54. hardware assistance to work this cannot be done in software The architecture independent starting point of the kernel is at start_kernel at this point the kernel is executing in virtual address space 6 2 3 GRMON Example debugging the Linux kernel Below is an example of how the first call to printk can be debugged By setting a hardware breakpoint on printk the processor halts after the save instruction has been executed Viewing the INS registers one can inspect the arguments passed to the printk function See SPARC v8 manual for SPARC calling conventions From the printk C prototype we know that the first argument must hold a pointer to a format string thus i0 register holds a pointer to a string Zs LINUX SNAPGEAR 27 GAISLER RESEARCH The register content can be viewed by the command reg From the output of reg one can see that i0 is 0xF0227510 Listing the memory with vmem around the virtual address 0xF0227510 reveals that the argument passed to printk was PROMLIB Sun Boot Prom Version d Revision d A virtual address can easily be translated to a physical address by doing a MMU page table walk with the GRMON command walk In the example below the virtual address 0xF0227510 is translated into 0x40227510 by the MMU Listing the memory content this time with mem instead of vmem confirms that the memory content is the same for the physical address as the virtual address By looking at the previous 20 instruct
55. ides the flash image has been create for a single purpose preparing the hard drive from the target hardware using NFS to access the splack distribution This image is called image nomount dsu Booting the Linux kernel can be done as follows grmon jtag nb grmon gt load image nomount dsu grmon gt run In order to copy the splack distribution onto the disk one must be able to access it In this example NFS is used to access the splack distribution mount t nfs 192 168 0 32 home daniel mnt nfs In order for the kernel to read from the hard disk one should create a partition table and a partition on the hard drive with a file system which the kernel can read the root file system from EXT2 typically type 0x83 One can edit the partition table and create new partitions with fdisk it can be started as follows fdisk dev hda add a new partition print the partition table create a new empty DOS partition table write table to disk and exit O O 3 When a partition has been created it is possible to format it using the mke2fs utility and copy the splack distribution to the newly created file system LINUX SNAPGEAR 47 4 mke2fs dev hdal mount t dev hdal mnt hd cd mnt hd 10 3 tar zxpf mnt nfs splack 1 0 tar gz cd umount mnt hd umount mnt nfs Running splack JE GAISLER RESEARCH If not already connected connect the hard drive to the target board Make sure a t
56. ions of the trace buffer it is easy to see that the instruction call is executed two instructions before entering printk As expected the call address is the address of printk In the delay slot or is executed Searching for 0xf0031e18 in image dis tells us that the caller is prom_init from the string passed to printk is seems reasonable As printk processes the string for output it must access the characters at some point or another that point can be found be setting a watchpoint at a character address To demonstrate the watchpoint functionality the processor is stopped when accessing the character S in the string A watchpoint it set to OxF0227519 S As the execution continues it can be observed that the processor is stopped at the space character the character just before S this is because watchpoints must be aligned to a 32 bit boundary GRMON does this for us The GRMON command bt short for backtrace show the current call history from it one can see that prom_init called printk which called vprintk and so on TE 2 LINUX SNAPGEAR 28 GAISLER RESEARCH grmon jtag grlib gt tm both combined instruction AHB tracing grlib gt lo image dsu section stage2 at 0x40000000 size 10240 bytes section vmlinux at 0x40004000 size 3670272 bytes total size 3680512 bytes 226 5 kbit s read 5814 symbols entry point 0x40000000 grlib gt symbol image read 5805 symbols entry point 0xf0004000 grlib gt hbreak
57. l LAN For more information on ATA over Ethernet see linux 2 6 x Documentation aoe aoe txt 9 2 Configuring the boot loader and main SnapGear options To mount a root filesystem using ATAoE we must use Linux 2 6 x with an initramfs initial root filesystem This filesystem should contain only the klibc utility kinit This utility will automatically parse the options we pass to the Linux kernel mount the ATAoE block device and switch the root filesystem over to the filesystem on the ATAoE mount GAISLER RESEARCH LINUX SNAPGEAR 43 An example configuration is outlined in the following table The ATAoE server has slot and shelf number 0 and the target LEON board is configured to 192 168 0 203 Note that the ip option may be omitted as ATAoE requires only Ethernet and will function even if the LEON does not have a valid IP address However LEON system using ATAoE typically enable TCP IP Name Value Vendor Product Selection Vendor Gaisler Gaisler Product Leon3mmu Gaisler Leon2 3 mmu options SPARC v8 Yes FPU support Yes Clock frequency 40MHz Baudrate 38400 In memory root filesystem Initramfs Init pathname bin kinit Kernel command line console ttyS0 38400 root dev etherd e0 0 ip 192 168 0 203 192 168 0 20 192 168 0 1 255 255 255 0 grx c3s_daniel eth0 Kernel Library Defaults Section Kernel Version Linux 2 6 x Customize Kernel Settings Y
58. latform dependant setup y v v n VGA support Help 0xc0000000 Base address of Videomem Help a py Herp 2 y w n GRETH Ethernet support Help Pratf rm b PO A E E y v amp n _LEON over TSIM the remote SPARC simulator Help ROM Kernel executes from Help AR idress byte 1 Help MAC Address byte Help Main Menu Next Prev iAC Address byte 3 Illustration 3 14 Platform set up AAC Addre byte 4 elp Ba _MAC Adress byte 5 Help Psiz drivers sl OK Next Prev Illustration 3 13 LEON3 AMBA device configuration 3 6 2 GRLib APBUART LEON3 Select GRLIB GAISLER APBUART to include a UART driver for APBUART One of the serial terminals can be set up as the system console via the kernel boot parameter ex console ttyS0 38400 selects the first serial channel to act as the system console JX LINUX SNAPGEAR 19 GAISLER RESEARCH The serial terminals will be available by accessing dev ttySx 3 6 3 LEON Serial LEON2 From Character devices sub menu the LEON2 UART driver can be enabled It allows user space to communicate with an arbitrary protocol over the serial line terminal interface dev ttySx This driver uses hard coded addresses instead of probing the AMBA bus for Plug amp Play information This driver is intended for use with LEON2 only LEON3 uses the AMBA Plug amp Play information 3 6 4
59. lustration 3 17 SnapGear application configuration main menu Since SnapGear supports both the 2 0 x and the 2 6 x kernels and some of the applications needs certain kernel interfaces they may only be compiled for one of the kernels A typical example of this is the flash support in Linux from Linux 2 4 and onwards a new interface called MTD memory technology devices has been introduced Linux 2 0 lacks the MTD interface and therefore cannot run applications that depend upon the MTD interface Flash utilities can be found under Flash Tools a BusyBox 0 I Flash Tools SIENER BusyBox asnan ylv n BusyBox Help netflash uses HMAC MD5 signature Help RADE netflash HMAC MD5 key Help As iil Eanes Help v ilv von recover bios only _ Help Savile SR Help vyl v n bootloader uses server config from flash _ Help SS e Help v Yj v n recover Help cae eae Help Re recover ethemet interface _ Help v iliv llvwe recover uses static server _ Help Se as wan chgrp Herp recover static server Help SAN VAU Ree Hep v i lv lino recover preserves existing config Help SARA Z Mt eal _Help sv ylle n flashloader Help v 2 e Hep Y ls n
60. minicom or hyper terminal with 38400baud 8N1 Running the image images image dsu from RAM on target LEON board using GRMON pc grmon jtag nb nswb grmon gt lo images images dsu grmon gt run On the terminal emulator connected to LEON Linux target target gdbserver 1223 bin testsin Process bin testsin created pid 28 Starting GDB on the PC and testing that GDB finds the sources 2 LINUX SNAPGEAR 32 GAISLER RESEARCH sparc linux gdb testsin g GNU gdb 6 4 0 20051202 cvs Copyright 2005 Free Software Foundation Inc GDB is free software covered by the GNU General Public License and you are welcome to change it and or distribute copies of it under certain conditions Type show copying to see the conditions There is absolutely no warranty for GDB Type show warranty for details This GDB was configured as host i686 pc linux gnu target sparc linux gdb list include lt math h gt include lt stdlib h gt int main int argc char argv double i 0 00 int j 0 printf testsin n while i lt 100 0 double v sin i 0 printf float sin f f n i v FPOWMDATNA HEWN Connecting GDB to the remote gdbserver gdb tar rem 192 168 0 80 1223 Remote debugging using 192 168 0 80 1223 0x50001c20 in Setting breakpoints gdb break 7 Breakpoint 1 at 0x10440 file testsin c line 7 gdb break 10 Breakpoint 2 at 0x10494 file tes
61. much shorter build time and a much smaller initial root filesystem Name Function Core Applications Custom tests app Disable custom tests app Shell Program Other Network Applications arp Disable arp portmap Disable portmap tcpd Disable tcpd Busybox Busybox Disable Busybox Miscellaneous Configuration RAMFS Image None klibc build klibc Enable klibc support kinit Enable kinit Statically link all binaries Optional Should result in a slightly smaller size for kinit there s only one binary so static linking actually doesn t waste space in this case 9 5 Building kernel boot loader and kinit As previously described LINUX SNAPGEAR 45 GAISLER RESEARCH S make The image will be available for download to the target board from images image dsu 9 6 Running on hardware The simplest method of testing the image is to run it using grmon as follows Depending on what debug interface is available the parameters to grmon may differ see grmon documentation for details cd images grmon jtag nb grmon gt load image dsu grmon gt run JX LINUX SNAPGEAR 46 GAISLER RESEARCH 10 RUNNING GRLINUX SPLACK FROM AN ATA HARD DISK Splack is a distribution based on the SPARC version of slackware it is prepared especially for demonstrating the ATA interface The GRLinux include tested bitfiles for various boa
62. oard must be specified This is because the PS 2 controllers are identical to the kernel PS 2 controllers found with an IRQ not matching the keyboard IRQ number are assumed to be a PS 2 controller connected to a mouse The default keyboard IRQ number may be overridden by the kernel command line option grps2 kbdirg irqno irqno 0 15 3 5 13 GRLib SPICTRL The Gaisler SPI controller is enabled by selecting SPI support and SPI support Gaisler Research SPI Controller The driver automatically detects the number of available slave select lines Adding support for specific SPI devices requires editing of the SPI initialization code found in linux 2 6 21 1 arch sparc kernel leon_spic c This is necessary since the available SPI devices are normally hard coded in platform specific code and GRLib is used in a wide range of systems The current initialization code contains an example where a M25P05 SPI Flash memory is connected to the first slave select line on SPI bus 1 To enable support for this specific memory device select Memory Technology Devices Self contained MTD device drivers Support for M25 SPI Flash To add support for another type of I LINUX SNAPGEAR 16 GAISLER RESEARCH SPI device modify the example and configure support for the SPI device in question 3 5 14 GRLib GRUSBHC Support for GRUSBHC is enabled under USB support Support for Host side USB Depending on the core s confi
63. ompact Flash Reader support EXPERIMENTAL USB_STORAGE_DATAFAB Lael ICD Carial Canunrtar om Illustration 3 9 Adding support for USB 2 0 host controller To enable support for USB storage devices SCSI SCSI device support and SCSI SCSI disk support must first be enabled USB connected human interface devices such as mice and keyboards are also supported Enable USB USB Human Interface Device full HID support and INPUT KEYBOARD and INPUT_MOUSE under Input device support 3 5 15 GRLib GRVGA GRLib SVGA controller can be used in Linux using the frame buffer video driver written for GRVGA X Windows and or a frame buffer console can be run on top of the frame buffer driver Normally one want mouse or at least a keyboard together with the graphical interface GRPS2 can be used to connect keyboard and mouse devices One may need to consider bus bandwidth when selecting resolution and bit depth The GRVGA controller will cause heavy bus loads for high resolution on slower buses Each word in the frame buffer will be read 60 times on a system with 60 Hertz vertical refresh rate From the Graphics support menu one can enable the GRVGA frame buffer driver o Enable firmware EDID FIRMWARE_EDID Support for frame buffer devices FB Enable Video Mode Handling Helpers FB MODE HELPERS i itti FB TILEBLITTING IFB GRVGA SBUS and UPA framebuffers FB SBUS Sound oO Epson 1D13XXX framebuffer support FB_S1D13XX
64. ort I2C Algorithms and I2C support Miscellaneous I2C Chip support depending on which peripherals that are present in the system 3 5 11 GRLib PCI support GRPCTI is a bridge between the AMBA bus and the PCI bus The GRPCI core is mainly used to connect off chip controllers to the LEON system It can be enabled by selecting PCI support under General machine setup Once the GRPCI driver detects the GRPCI core by probing the AMBA Plug amp Play bus it initializes the core and starts scanning the PCI bus for additional controllers 3 5 12 GRLib GRPS2 Keyboard and mouse drivers are available for the Gaisler PS 2 controller One can enable GRPS2 under input device Hardware I O ports Input devices that use the PS 2 driver such as keyboard and mouse drivers are enabled under Input device support MOUSE PS2 and INPUT KEYBOARD Cie ee ae Serial I O support SERIO k Mi8042 PC Keyboard controller SERIO_18042 SON SURS e Serial port line discipline SERIO_SERPORT Telephony Support Sagrlib ps2 keyboard controller SERIO_LEON3 gt Input device support 5 Default keyboard IRQ number SERIO_LEON3_KEYB_IRQ Hardware I O ports PS 2 driver library SERIO_LIBPS2 n O Raw access to serio ports SERIO RAW Character devices OGameport support GAMEPORT i Serial drivers Illustration 3 8 Adding support for GRPS2 controller To separate keyboard and mouse PS 2 devices from each other the IRQ number of the keyb
65. r 3 7 Applications included in ROMFS Apart from the Linux kernel the SnapGear RAD environment consist of applications in the snapgear pxx user directory that can be included into the root file system The root file system is a read only file system that will be copied and decompressed into RAM during the boot process Custom applications can be easily integrated into the directory structure and SnapGear The steps involving adding custom applications is described in a separate chapter From the main SnapGear GUI one can make a third GUI pop up after the main SnapGear GUI closes This is similar to what was earlier described for the Linux kernel One simply selects y at Customize Vendor User Settings under Kernel Library Defs Selection and press Quit and Save BusyBox is a small footprint replacement for traditional UNIX core applications such as Is find mount etc BusyBox is highly configurable and can be configured from the BusyBox sub menu as shown below GAISLER RESEARCH LINUX SNAPGEAR 21 SnapGear Embedded Linux Application Configuration Core Applications Busy Box Library Configuration Tinylogin Flash Tools MicroWindows Save and Exit Filesystem Applications Games Quit Without Saving Network Applications Miscellaneous Configuration Load Configuration from File Miscellaneous Applications Debug Builds Store Configuration to File Il
66. rcS file in vendors leon3mmu rcS to mount automatically on start up T LINUX SNAPGEAR 35 GAISLER RESEARCH See your distribution manual how to set up an NFS sharer normally you edit etc exports and run exportfs r The same problem is faced in the chapter Root Filesystem over Ethernet using NFS Good practice is to mount the exported directory on to the server PC to verify that the NFS share is set up correctly even if this works it may be wrong After network and NFS server has been set up on the target one can simply mount the NFS share into an empty local directory with target mkdir nfs target mount t nfs o rw nolock workstation export leonshare 6 5 Console output when debugging The console is of great help when debugging applications but often it limits the execution speed or put in another way the console can not output enough information There are ways to speed up the console output two techniques are discussed here 6 5 1 Redirecting output to NFS share The console output can be redirected to a file by the shell The shell simply connects the application s stdout to a file For this to work the shell needs to support redirection only tiny shells doesn t support redirection It is also possible to redirect stderr to file See man stdin and man bash for more info Embedded storage is often limited in size and speed and would fill up the flash device rapidly Instead a NFS server can be used to
67. rds a precompiled kernel with the appropriate features to run the root file system from a hard drive and a temporary image for preparing the hard drive with splack The splack distribution was compiled with support for FPU and integer multiplier The kernel needs support for Gaisler ATA controller when accessing the root file system from an ATA disk or compact flash 10 1 Installing the kernel onto flash The precompiled kernel is loaded onto the boot PROM of the board grmon can be used to program the PROM Flash grmon jtag grmon gt flash erase all grmon gt flash load image flashbz The boot loader is the first to be executed it copies the kernel into main memory and before it starts the execution of the kernel the kernel command line string is made available The kernel needs to know what partition on the disk to search for the file system that can be provided through the kernel command line root dev hda1 The example boot line above make the kernel search the first partition on the first disk for a valid file system In principle the configuration is similar to a NFS root file system as described earlier instead of telling the kernel the IP address of the server and the location of the share on that server the kernel is fed with hard disk and partition number 10 2 Preparing the hard drive The preparation of the hard drive can be made using a PC computer or as described below by using the target hardware Another image bes
68. res Custom Vertical resolution in lines 8 Ilmargin Custom Vertical Front porch in lines 9 vsync_len Custom Vertical Sync length in lines 10 umargin Custom Vertical Back porch in lines 11 bit_per_pixel All Pixel depth in bits 8 16 32 bits 12 Mem_size All Frame buffer memory size in bytes Table 3 4 GRVGA kernel parameter arguments Below is an example how to configure the GRSVGA using 1024x768 resolution 60Hz vertical refresh rate 8 bits pixel depth and 800kb video buffer The system console will be displayed on virtual terminal zero dev tty0 which is connected to the framebuffer dev fb0 instead of a serial terminal console tty0 video grvga 1024x768 60 8 786432 1024x768 60 is a predefined mode by the driver however a custom mode can be entered see the table above and kernel documentation for more details 3 5 16 GRLib ATA Controller Gaisler ATA controller can interface a hard disk or a compact flash card Devices can be accessed from dev hda The ATACTRL can be selected from ATA support menu The ATA controller depend upon the PCI subsystem to function correctly PCI can be included from General Machine Setup gt Device Drivers ATA ATAPI MFM RLL support i Generic Driver Options 5 2 Enhanced IDE MFM RLL disk cdrom tape floppy support Connector unified userspace lt gt ke Please see Documentation ide txt for help in
69. rking 00007A MSB 24 bits of ethern number hex GRLIB_GAISLER_GRETH_MACMSB Device Drivers CC0012 LSB 24 bits of ethern number hex GRLIB_GAISLER_GRETH_MACLSB Illustration 3 6 APBUART and GRETH Linux configuration 3 5 5 LEON Serial LEON2 For LEON2 systems the serial driver can be found under Character devices Serial drivers Selecting SERIAL LEON enables the serial driver the serial devices can be used to communicate over the serial line ISDN subsystem i B Telephony Support Non 8250 serial port support Input device support OSun Zilog8530 serial support SERIAL_SUNZILOG Hardware 1 0 ports oSun SU serial support i SERIAL_SUNSU boCharacter devices osun Siemens SAB82532 serial support SERIAL_SUNSAB 7 ODigi International NEO PCI Support SERIAL_JSM IPMI O Leon SoC serial support NEW SERIAL_LEON Watchdog Cards Ftape the floppy tape device driver Illustration 3 7 Serial support for LEON2 with an arbitrary protocol The serial lines can be accessed from dev ttySx 3 5 6 GRLib GRETH 10 100 1000 Select GRLIB_GAISLER_GRETH to enable the 10 100 Ethernet MAC or for grlib professional users the 10 100 1000 Ethernet MAC The Ethernet MAC address of the GRETH MAC can also be edited directly from the GUI The address is made out of an unique 6 byte sequence One can edit the 24 most significant bits MSB and the 24 least significant bits LSB from GRLIB_GAISLER_GRETH_MACXSB Networking
70. rocess in SnapGear make the image directory is populated with various images image image dis image dsu The image dsu is to be loaded into RAM and run image contain the debug information of the Linux kernel s virtual addresses and image dis is a plain text file containing the disassembly of image Starting GRMON with the nb flag is essential so that Linux can handle traps correctly The trace buffer can be enabled by the command tm both and later listed by inst Breakpoints trigger when the processor fetches an instruction at the given breakpoint address Hardware breakpoints are inserted with hbreak address or hbreak symbol Inserting breakpoints with break instead hbreak causes GRMON to insert an instruction ta 1 Hardware breakpoints is preferred when working with virtual addresses or debugging non writeable areas GRMON stop the processor from executing further when a breakpoint is reached the exact state can be observed and manipulated Breakpoints triggers on addresses the processor executes in this case virtual addresses The watchpoints implemented in GRLIB have support for stopping the processor when an address is being accessed by the software all variants if the instructions d or st are supported As with hardware breakpoints watchpoints trigger on the address the processor accesses before MMU translation thus virtual addresses is to be used when debugging the Linux kernel and its applications with GRMON Watchpoints need
71. rrectly automatically when enabling SMP from the Linux kernel configuration GUI SMP is only available for LEON3 processors Xo LINUX SNAPGEAR 14 GAISLER RESEARCH 3 5 3 Gaisler AMBA Plug amp Play procfs support Procfs is a pseudo file system that is normally mounted onto proc The procfs is directly linked to the kernel s internals and can display information relevant to the system s operation Enabling AMBA PROC makes a directory proc bus amba appear that can display information about devices on the AMBA bus General machine setup Grlib Amba device driver configuration Vendor Gaisler Vendor Opencores Illustration 3 5AMBA procfs support 3 5 4 GRLib APBUART LEON3 If a serial UART is to be used select GRLIB_GAISLER_APBUART be sure to select GRLIB_GAISLER_APBUART_ CONSOLE if one of the serial controllers are interfaced to a console One of the serial terminals can be set up as the system console via the kernel boot parameter ex console ttyS0 38400 selects the first serial channel to act as the system console The serial terminals will be available under dev ttySx Option Option Name General machine setup OE e amp Grlib Amba device driver configuration Grlib apbuart driver GRLIB_GAISLER_APBUART i Vendor Gaisler _ BGrlib apbuart serial console GRLIB_GAISLER_APBUART_CONSOLE i Vendor Opencores Grlib s ethermac driver GRLIB_GAISLER_GRETH Netwo
72. seeeeeeseeeceeseeceesececeeseceeeeaeeeaeceenseseaeeeeeeeseteeensaes 38 7 8 IR Umm on Hard Wale spennan gereen oai egea Ee NAE EEEn EE EE A Sais RTE REGS 38 8 ROOT FILE SYSTEM OVER ETHERNET USING NFS ossosomsrsesersrsrsesrsrororsererensrnrrsrnerrsrernrsrenrsrenrnt 39 8 1 Setting up NFS Servet Om PC 25 cuccc His cccesecetetceesoed biosctnis cuts endbelau hastens EEE RE e EE EEA 39 8 2 Configuring the boot loader and main SnapGear OPtiONS ssessssssrsrsesrsrrsrsrsrsrsnesrsrsrsrrrrnrsrsrrr rna 39 8 3 Configuring the Linux kernel cccccccseesseeseessceseeseeeseesceeseceeeseceeeeseeesesseeesecseeeseeeesaeenseeeteeensaes 40 8 4 Building kernel and boot 1OA0e1 s s ss sss sesssosssnssskossssosposssp nssnovsnpssdrsssdsrssnsisesssninssronsbi rasserenennnsend 40 8 5 Running on hard WOLC yssssesseiesaiovsssssisersnsso er usshi i e e RA A ve Haneda ese owen ae 41 9 ROOT FILE SYSTEM OVER ETHERNET USING ATA OVER ETHERNET sssssssrorsrenereresrsnrn 42 9 1 Sette p ATAOE Servei ennie irira area Rer ae ae E eea aS EE EERE 42 9 2 Configuring the boot loader and main SnapGear OPtiOlS sssssssrrsrersrsrerrrrsrsrerererrsrsrsrerrrrsrsrsr rna 42 9 3 Configuring the Linux Ketnel sssssicssssissossssssessnisdssiceretssbisendssssussennsssnssatnnsesnon ai iaria esai 43 9 4 Configuring the vendor user applications ccccccescesseesceseeeseeeeesecseeeseeseeeseceeesecneeeaeeneeensseeensaes 44 9 5 Building kernel boot loader and Kimit eee eee
73. to the GNU compiler The more applications a file system has the more space can be saved using dynamically linked binaries Depending on needs and resources different embedded systems choose different linking strategies 3 2 2 Toolchains for Linux 2 6 The available SPARC LEON toolchains for Linux 2 6 both contains a precompiled C Library The library has been built four times for CPUs with different combinations of FPU and mul div hardware Two different toolchains are available the sparc linux toolchain includes the GNU C library whereas the sparc uclinux toolchain has uClibC built in The two toolchains are based on GCC 3 4 4 Installing both toolchains will not conflict See previous chapter for installation instructions 3 2 3 Toolchains for Linux 2 0 For Linux 2 0 there are one toolchain available based on GCC 3 2 2 For Linux 2 0 SnapGear projects the toolchain s C Library isn t used but the uClibC Library included in the SnapGear release See installation instructions in previous chapter 3 3 Kernel version Linux kernel version can be selected from the Kernel Library sub menu As described earlier in the introduction there are two variants of the Linux kernel within the SnapGear LEON Linux distribution One is intended to be used with MMU less systems and the other is based on an older version of the Linux kernel 2 0 For MMU based systems Linux 2 6 x is available o LINUX SNAPGEAR 11 GAISLER RESEARCH Kern
74. to the NFS share to be used as root and the network settings such as IP address netmask and gateway To avoid building the image with the unused ROMFS root file system the In memory root filesystem option from the Gaisler Leon2 3 mmu options is set to none The settings in the SnapGear application GUI does not effect the build process once In memory root filesystem is set to none An example configuration is outlined in table 8 1 the PC NFS server has the IP address 192 168 0 20 and the target LEON board is configured to 192 168 0 203 LINUX SNAPGEAR 40 GAISLER RESEARCH Name Value Vendor Product Selection Vendor Gaisler Gaisler Product Leon3mmu Gaisler Leon2 3 mmu options SPARC v8 Yes FPU support Yes Clock frequency 40MHz Baudrate 38400 In memory root filesystem NONE Kernel command line console ttyS0 38400 root dev nfs nfsroot 192 168 0 20 export rootfs nfsvers 3 ip 192 168 0 203 192 168 0 20 192 168 0 1 255 255 255 0 grx c3s_daniel eth0 Kernel Library Defaults Section Kernel Version Linux 2 6 x Customize Kernel Settings Yes Table 8 1 SnapGear main configuration 8 3 Configuring the Linux kernel In addition to the default settings of the Linux 2 6 x kernel add the features described by table 8 2 Name Function Networking NET Networking support INET TCP IP protocol IP_PNP IP settings can
75. tsin c line 10 Running application with cont instead of run since application already has been started and paused on the target side gdb cont Continuing Breakpoint 1 main argc 1 argv Oxefbdled4 at testsin c 7 7 printf testsin n Stepping one C line with next as the printf call is executed the output appears on the target console gdb next 8 while i lt 100 0 Running the loop four times I LINUX SNAPGEAR 33 GAISLER RESEARCH gdb cont Continuing Breakpoint 2 main argc 1 argv Oxefbdled4 at testsin c 10 10 printf float sin f f n i v gdb cont Continuing Breakpoint 2 main argc 1 argv Oxefbdled4 at testsin c 10 10 printf float sin f f n i v gdb cont Continuing Breakpoint 2 main argc 1 argv Oxefbdled4 at testsin c 10 10 printf float sin f f n i v gdb cont Continuing Breakpoint 2 main argc 1 argv Oxefbdled4 at testsin c 10 10 printf float sin f f n i v gdb cont Continuing Breakpoint 2 main argc 1 argv Oxefbdled4 at testsin c 10 10 printf float sin f f n i v gdb print i 1 5 The output on the LEON target terminal is now Sash command shell version 1 1 1 gt gdbserve r 1223 bin testsin Process bin testsin created pid 26 Remote debugging using 1223 testsin float sin loat sin loat sin loat sin f f f f 0 1 loat sin 2 3 4 000000 0 000000 000000
76. umentation is very use full when debugging the kernel and writing new drivers it can be found at Attp gaisler com products grlib grip pdf GDB documentation is available at http sourceware org gdb documentation 6 1 Debugging symbols In order to translate assembler instructions into C code debugging symbols and an application that can read debugging symbols are needed The application sparc linux objdump part of the binutils package provided with the toolchain can provide us with information about compiled applications ELF binaries Debug symbols is made by GCC sparc linux gcc during compile time when at least one of the flags g g3 ggdb gstabs are given The debug symbols enlarges the output binary but the debug symbols can be removed stripped with the sparc linux strip utility prior to usage An example of how the debugging information can be created viewed and removed sparc linux gcc g3 userapp c o userapp sparc linux objdump S userapp gt userapp s sparc linux objdump x userapp gt userapp x sparc linux strip s userapp less userapp sS create app and syms deasm binary list sections remove syms view output DUNMOW E HE HE HE HE Debuggers can read the debug information directly from the binary making some of the steps above unnecessary The GDB server run on the target later discussed does not need debug information to save space the binary is stripped with sparc linux strip Debugging inform
77. uration In this example Debian is installed onto a NFS share that will later become the root file system of the LEON board The LEON board is a low cost GR XC3S 1500 board from www gaisler com 11 1 Preparing LEON target Preparing the LEON target to run the installation binaries is done similar to a NFS root file system set up as described previous the important applications and kernel configuration is listed in two tables below The LEON system consist of a kernel that is using a NFS share with BusyBox as it s root file system The BusyBox root file system is exported from a PC as export busybox and the Debian root file system is placed in export busybox debian Name Function Networking NET Networking support INET TCP IP protocol IP_PNP IP settings can be set from kernel command line Device Drivers Network device support NETDEVICES Enables the network device driver interface General machine setup Grlib AMBA Gaisler GRLIB_GAISLER_GRETH Add Gaisler Ethernet 10 100 1000 driver Select a unique Ethernet address in the MSB and LSB fields Device Drivers Block Devices BLK_DEV_INITRD Disable ROMFS RAM root file system File systems Network file systems NFS_FS Network file system support NFS_V3 Support for version 3 of the NFS protocol ROOT_NFS Add support for root file system over NFS Table 11 1 Kernel configuration for Debian and install program
78. uration tool under General setup ROM bank size Bank size of flash ROM rws Number of ROM Flash read wait states ROM wws Number of ROM Flash write wait states Enable write cycles to PROM Boot loader makes it possible to write to FLASH without tampering with memory configuration registers RAM type RAM type to be used SRAM or SDRAM Alternative physical kernel address It is possible to manually select an address where the kernel will be started from The base address of the stack can be changed as well One can this way make room for a custom data area the Linux kernel will only use the memory between the kernel base address and the stack base Table 3 3 Boot loader parameters LINUX SNAPGEAR 13 GAISLER RESEARCH 3 4 1 Symmetric multi processing Multi LEON3 processor systems is supported by the boot loader The multi processor support is controlled from within the Linux 2 6 x kernel configuration GUI once SMP is enabled the boot loader s SMP support is also included when built the next time See 2 6 x configuration section 3 5 Configuring the 2 6 x kernel 66 99 From the graphical interface it is possible to configure the selected kernel by selecting y at Customize Kernel Settings and saving the new settings After the main GUI has been closed and settings have been saved a second GUI will appear that is specific for the kernel selected The k
79. x and uses a socket protocol to connect to the local GDB sparc linux gdb GDB is responsible for SPARC specific operations and therefore DDD needs not to be recompiled for SPARC binaries pc ddd debugger sparc linux gdb app debug ddd gdb target remote target port ddd gdb b main ddd gdb cont Most Linux distributions distribute DDD as a precompiled binary package in many cases it is installed by default See http www gnu org software ddd for more information about DDD 6 3 7 Insight Insight comes with version 1 0 1 or later of sparc linux toolchains Insight is a graphical debugging interface on top of GDB It is started by running sparc linux insight See Attp sourceware org insight for more information on how to use insight 6 4 Using NFS to simplify application updates During development one i often needed to update the application and rerun it Using the standard procedure is very inefficient rebuild the image reprogram the flash and reboot With GRMON the flash i not needed to be updated the image can be run directly from RAM saving a great deal of time However there are occasions where even rebooting may be troublesome Sharing the files over NFS may be a good alternative to rebooting and rebuilding all SnapGear Only the development files binaries need to updated not all SnapGear Perhaps the easiest way is to create a script file in the SnapGear image which mounts NFS after boot yet another way is to edit the

Download Pdf Manuals

image

Related Search

Related Contents

OPERATING INSTRUCTIONS  User Guide - SPX Corporation  

Copyright © All rights reserved.
Failed to retrieve file