1 / 71

MontaVista Linux Professional Edition Jump Start Training

MontaVista Linux Professional Edition Jump Start Training. Embedded Linux Technology Inc., Taiwan Branch Email: jesse@emblit.co.jp TEL: 02-23784056. 10:10 ~ 11:00 Preparing Development System Development Environment Boot ROM 11:10 ~ 12:00 Boot Configure and Download

elinor
Download Presentation

MontaVista Linux Professional Edition Jump Start Training

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MontaVista LinuxProfessional EditionJump Start Training Embedded Linux Technology Inc., Taiwan Branch Email: jesse@emblit.co.jp TEL: 02-23784056

  2. 10:10 ~ 11:00 Preparing Development System Development Environment Boot ROM 11:10 ~ 12:00 Boot Configure and Download MontaVista Development Tools (I) 13:10 ~ 14:00 MontaVista Development Tools (II) 14:10 ~ 15:00 File Systems Kernel Modules 15:10 ~ 16:00 MontaVista Realtime Agenda

  3. Preparing Development System • MontaVista Software Package Installation • Supported Host Distributions • MVL PE 2.1: MVL PE 3.0: • Mandrake 7.2, 8.0 and 8.1 8.1 • RedHat 6.2, 7.0, 7.1 and 7.2 7.2 and 7.3 • SuSE 7.3 7.3 • Yellow Dog 2.1 2.1 • Solaris 7 and 8 7 and 8 • VMware[tm] Workstation 3.1 on Windows(R) NT/2000/XP with a Red Hat 7.2 Host • Host Configuration • NFS, bootp, tftp, firewall, $PATH, … • $PATH: /opt/hardhat/devkit/host/bin /opt/hardhat/devkit/arm/xscale_be/bin

  4. Development Environment

  5. Boot ROM • Possible Duties • Turn on various chip enables (so RAM exists) • Initialize I/O chips possibly including serial port to report Boot ROM success/fail and a network or disk device interface to boot the OS • Perform system self-test, report results • Provide an command line interface (CLI) • Receive S Records into RAM, and then burn that compressed data into Flash

  6. Boot ROM • Contents • Board- and CPU architecture-specific initialization code • Ability to download the operating system image through one or more mechanisms • Transfer control to that software • May also assist in debugging the application system, and running system integrity tests

  7. Boot ROM • Booting the Target System • Step #1: Press the target Reset button (if it has one) or apply power to the target • Boot ROM begins executing for the very first time • Step #1A: Boot ROM looks to you for help. • Step #1B: Configure Boot ROM according to how you want it to boot your test software. Tell Boot ROM to remember those settings.

  8. Boot ROM • Booting the Target System (cont’d) • Step #2: Press target Reset or cycle the power • Boot ROM downloads your test software and jumps into it • Your test software is now running • Repeat Step #2 as needed

  9. Boot ROM • Who, in general, creates Boot ROMs? • Who is responsible for the Boot ROM you will be using? • Redboot: frequently used Xscale bootstrap • Developed by RedHat • How to get source and toolchain for Redboot • URL: http://sources.redhat.com/redboot • “Embedded Software Development with eCOS”, A. J. Massa, Prentice Hall

  10. Boot Config. & Download • Assumptions for the Lab Equipment • Using BOOTP and TFTP to transfer the booting operating system from the host system disk to the target system memory • A portion of the host’s file system will be available to the target operating system by an NFS mount • The Steps • Step B - Build the target binary (vmlinux) • Step C - Configure the target & host network capabilities • Step D - Download the binary to the target • Step E - Execute program(s) on the target

  11. Boot Config. & Download • Step B - Build the target binary (vmlinux) • Linux uses the make utility extensively. • Sources organized into subdirectories • vmlinux built from archives and libraries • If compressed, it is then called vmlinuz • Booter and optional RAM disk are then added and the composite is named zvmlinuz, zImage or bzImage • Some boards need S-Records / other formats • Convert as needed (zsrec utility, etc...)

  12. Boot Config. & Download • Step C: Configure the host network capabilities • BOOTP (uses DHCP) • TFTP Daemon • NFS Information • Minicom • Refer to the MontaVista Linux Professional Edition User’s Guide and Quick Start Guide for your LSP

  13. Boot Config. & Download • Step D: Download the binary to the target • Configure the target board (as previously described) • Configure any host daemons (as previously described) • Interconnect host and target • Activate the target’s firmware to retrieve the previously built zImage binary file and transfer control into it • The first part of zImage, the Linux Boot Loader, uncompresses Linux and places it at the appropriate memory address

  14. Boot Config. & Download • Step D: Download the binary to the target (cont’d) • The Linux Boot Loader also uncompresses the RAM disk image, if present, and places it in memory • Finally, the Linux Boot Loader transfers control to the uncompressed Linux image • (vmlinux) along with a command line describing the RAM disk image (if present) • Linux initializes itself including the hardware Memory Management Unit (MMU) that translates logical (or virtual) addresses into physical (or real addresses.)

  15. Loading: Image Loader

  16. Loading: Linux Boot Loader

  17. Loading: Linux Startup

  18. Boot Config. & Download • Step E: Execute program(s) on the target • Linux mounts the initial file system from RAM Disk, or NFS Disk, or Local Disk. • Linux, in init/main.c searches for the init first as /sbin/init, then as /etc/init, then /bin/init and finally /bin/sh (any of which could be a binary executable, a shell script, or any other file that Linux knows how to execute) and then executes it. • Typically, it is the /sbin/init program that is executed at this point. • /sbin/init processes the /etc/inittab file. See man init and man inittab for complete details on starting your own application programs via the init process.

  19. Development Tools • Kdevelop • Enhanced for development of remote targets by MontaVista • Integrated Development Environment (IDE) • Microsoft Visual C++ -like • Brief tutorial included in MontaVista Linux Professional Edition, Reference Guide • More extensive instructions are available in the on-line help within kdevelop itself. • Works best with C and C++ • Works with Assembler also

  20. Development Tools • GNU gcc and g++ • gcc - C Compiler • g++ - C++ Compiler • A family of compilers for various target CPUs • A front-end for the build process including preprocessor, compiler, assembler and linker • Assembler and Linker • as • ld

  21. Development Tools • Binutils: a collection of binary tools • ar - Manages object file archives • nm - List symbols from object files • objcopy - Copy and translate object files • size - List text, data and bss sizes • strip - Remove symbols • addr2line - Convert addresses to file and line

  22. Development Tools • make and Makefile • Traditional Unix tool • Almost anything you can do by hand (and then some) can be done through a Makefile • Lots of good books from which to learn • Notably "Managing Projects with Make" (Pub: O’Reilly)

  23. Development Tools • A simple Makefile example # Makefile for ferret CC=xsacle_be-gcc TARGET=/opt/hardhat/devkit/arm/xscale_be/target all: install install: ferret cp ferret $(TARGET) ferret: ferret.c Makefile $(CC) -D_REENTRANT -O $< -o $@ -lpthread clean: - rm -f ferret.o ferret $(TARGET)/ferret

  24. Development Tools • Source Debugging • gdb (on host) with gdbserver (on target) • Preparing the object files (compiling with -g and –ggdb option) • No optimization makes it easier to follow execution but performance may change dramatically when recompiled with full optimization • Full optimization may lead to surprising leaps and jumps when executing and "watching" with gdb • Optimization is optional for user-level applications but in the kernel it is mandatory.

  25. Development Tools • Source Debugging • Starting the gdbserver on the target • Receives requests from gdb on host • Sends answers to gdb on host • gdbserver is very small • Symbol table and source files on host system • Full (-g or -ggdb) contents needed only on host • Only the executable binary is on the target • Connecting gdb and gdbserver • DDD: GUI front-end for gdb

  26. Development Tools • Learning more about gdb • The GNU Web-Site, http://www.gnu.org/ • Books, see “Beginning Linux Programming”, Richard Stones and Neil Matthew , WROX Press, Ltd., 1-861002-97-1. • Use the help command in gdb itself.

  27. Development Tools • Target Configuration Tool (TCT) • The tool that customize your Kernel and file system • Features • Project and Configuration Management • Kernel Configure • Package Selector • Dependencies Check • The targetpkg Utility • Library Optimzation Tool (LOT)

  28. Development Tools • Linux Trace Toolkit (LTT) • Fully-featured tracing system for the Linux kernel. It includes both the kernel components required for tracing and the user-level tools required to view the traces. • Micro-second event time-stamps • Minimal performance overhead (< 2.5 %). • Multi-platform support • Friendly GUI with event graph, system and per-process analysis, and raw event descriptions.

  29. Development Tools • Linux Trace Toolkit (LTT) Usage Steps • Enable Linux "Kernel Tracing" configuration • Create the tracer device entry in target's /dev if they are not available in your file system. • Start the trace daemon in target:tracedaemon -ts10 /dev/tracer ./out.trace ./out.proc • Run "tracevisualizer" in host and load the above out.trace and out.proc files

  30. Development Tools • Kernel GDB (KGDB) • Source debugging of the Kernel • Requirements: • Enabling the CONFIG_KGDB entry in the Kernel Hacking section • Recompile with -ggdb • Enable frame pointers • Connect serial port • Download and boot target • Launch DDD and gdb to use the serial port • Upon connection, set breakpoints and go • Kernel Modules Debugging

  31. File Systems • File Systems Supported (partial list) • EXT2/3 • ReiserFS • XFS • CramFS • JFFS/JFFS2 • Network File System (NFS)

  32. File Systems • How Do I Enable a Local Root File System? • A practice: Use ramdisk as root file system • Kernel configuration: • Edit kernel bootup command line option: “root=/dev/ram” • Block devices: enable RAMDISK support, init ramdisk support, default ramdisk size 4096kB • File Systems: Disable network file system as root option • Networking Options: Disable IP auto configuration in bootp

  33. File Systems • Use ramdisk as root file system (cont’d): • Use TCT to generate my root file system, convert to ext2 format and compress it. • Download to the target and run<Redboot> load –r –v –b 0xnnnnnnnn <ramdisk> <Redboot> load –r –v –b 0xuuuuuuuu <kernel>    <Redboot> go 0xuuuuuuuu

  34. File Systems • Use ramdisk as root file system (cont’d): • rm -rf /tmp/tmpmnt • mkdir /tmp/tmpmnt • rm -rf /tmp/ramrootfs • dd if=/dev/zero of=/tmp/ramrootfs bs=1k count=10240 • mke2fs -F -m 0 -i 2000 /tmp/ramrootfs • mount -o loop -t ext2 /tmp/ramrootfs /tmp/tmpmnt • cd /tmp/tmpmnt • cp -av /my_workdir/my_filesystem/pxa250/fs1/* . • cd /tmp • umount /tmp/tmpmnt • cat /tmp/ramrootfs | gzip -9 > /tftpboot/pxa250.ram

  35. File Systems • Use JFFS/JFFS2 as root file system • You have to use /opt/hardhat/devkit/arm/xscale_be/target/sbin/mkfs.jffs2 to make your jffs2 file system. • The mkfs.jffs2 needs /usr/lib/libz.so.1 ; /lib/libc.so.6 ; /lib/ld-linux.so.2 • Bootup your target with root=nfs or /dev/ram which contains the above binaries and your target file system directory. • Run /usr/sbin/mkfs.jffs2 -d <target dir> -o my.jffs2

  36. File Systems • Use JFFS/JFFS2 as root file system (cont’d) • Rebuild the kernel with "root=/dev/mtdblock? rw ip=off" • Use Redboot commands to downloadthe my.jffs2 and the new kernel • Reboot the system with the new kernel and jffs2 file system.

  37. Kernel Modules • An object file (e.g., myfile.o) that is dynamically loaded and added to the kernel at run-time • Often used to add/remove optional items to/from the system such as device drivers • Useful when kernel footprint or alternative drivers is an issue • May also be used with proprietary code to avoid licensing issues in GPL

  38. Kernel Modules • Often have a custom /proc interface built-in to the module • Written by the kernel module programmer • Can be written to provide both a read and a write interface • Typically used initially to assist in kernel module debugging • But the long-term use is typically to help the system administrator either by providing information about system configuration and operation, and allowing parameters in the kernel module to be modified as may be needed by the administrator

  39. Kernel Modules • Loading and Unloading Modules • insmod - Install (load) a module • rmmod - Remove (unload) a module • lsmod - List installed modules • depmod - Show dependencies of a module • modprobe - Loads a module and its dependencies • modinfo - Displays information about a module • Start-Up • insmod may be used in /etc/init.d/* and /etc/rc*.d/*

  40. Kernel Modules • A Simple Kernel Module #include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> static int __init my_init_module(void){ printk("<1> Yup, I’m here!\n"); /* Logged to /dev/console */ return 0; } static void __exit my_cleanup_module(void) { printk("<1> And now I’m leaving.\n"); /* Logged to /dev/console */ } module_init(my_init_module); module_exit(my_cleanup_module);

  41. Kernel Modules • Kernel Module Compiling • Kernel modules need to be built using the kernel headers rather than the user-space headers • <architecture-prefix>-gcc -D__KERNEL__ -Wall -O2 -I <path-to-kernel>/include -I <path-to-kernel>/arch/<architecture> -DMODULE -c mymod.c • When more than one '-I' option is used, the directories are scanned in left-to-right order. These directories are searched before the standard system directories.

  42. Kernel Modules • Compiling with version information is only necessary when compiling a module for a kernel that has "CONFIG_MODVERSIONS" enabled. • Version mismatch: # insmod mymod.o mod1.o: kernel-module version mismatch mod1.o was compiled for kernel version 2.4.17_mvl21 while this kernel is version 2.4.17_mvl21-cllf. • Solutions: • Insmod –f • recompile the module with "version information" in the kernel

  43. Kernel Modules • How do I compile a module with "version information" in the kernel? • <architecture-prefix>-gcc -D__KERNEL__ -Wall -O2 -I<path-to-kernel>/include -I <path-to-kernel>/arch/<architecture> -DMODULE -DMODVERSIONS -include <path-to-kernel>/include/linux/version.h -c mymod.c

  44. Kernel Modules • depmod - Module Dependencies Database • Creates a database of module dependencies • Scans modules in /lib/modules • Generates /lib/modules/*/modules.dep • * will be replaced by the kernel version and build number • Update when adding new modules to the system that should be automatically inserted • Modules that will be loaded manually do not need to be in the database

  45. Kernel Modules • depmod Example # insmod lp ./lp.o: unresolved symbol parport_register_device_R9b846d61 ./lp.o: unresolved symbol parport_release_R93e35225 ./lp.o: unresolved symbol parport_claim_or_block_Rca62ba8c ./lp.o: unresolved symbol parport_unregister_device_Re6842bfb ./lp.o: unresolved symbol parport_enumerate_R6a5c148b # depmod -a /lib/modules/2.2.12-20b/modules.dep /lib/modules/2.2.12-20b/misc/lp.o: /lib/modules/2.2.12-20b/misc/parport.o

  46. Kernel Modules • modprobe - Load Module and its Dependencies • May be used instead of insmod • Check dependency database • Loads dependent modules in the correct order • Checks /etc/conf.modules for parameters • Can pass additional parameters

  47. Kernel Modules • PassingValuesto theModule • modprobeparport_pc.o demo=1 • This works with insmod also • In the module’s source /* parport_pc.c */ #ifdef MODULE static int demo = 0; MODULE_PARM(demo, "i"); MODULE_PARM_DESC(demo, "Demo variable, defaults to 0"); #endif

  48. Kernel Modules • Add Module via Linux Configuration Process • Used when a kernel module must be built at the same time as the kernel; Not required for simple testing of the kernel module • Steps • First: Add a selection to the kernel configuration • Second: Add the object module to kernel Makefile • Third: Configure and Build the Linux kernel

  49. Kernel Modules • Add Module via Linux Configuration Process • Step#1: Add a selection to the configuration • Locate the appropriate [Cc]onfig.in file • Add the appropriate lines for your module • To allow "y", "m" or "n" selection: • tristate ’User-readable description goes here’ CONFIG_YOURSYMBOL • Refer to Documentation/Configure.help and Documentation/kbuild/config-language.txt

  50. Kernel Modules • Add Module via Linux Configuration Process • Step#2: Add the object module to Makefile • Determine appropriate <path-to-kernel>/drivers/*/Makefile • Add command to include your module • obj-$(CONFIG_YOURSYMBOL) += yourfilename.o • Copy source files to same directory • If necessary, add compile options, etc. to Makefile

More Related