<<

uClinux CoreCommander BSP User Guide

CoreCommander BSP Version: 2.1.1.1 Document Version: 1.1 Date: January 2009

System Level Solutions, Inc, (USA)

14100 Murphy Avenue, San Martin, CA 95046 (408) 852 - 0067 System Level Solutions, (India) Pvt, Ltd.

Plot # 32, Zone - D/4, Phase 1, G.I.D.C. Estate, V.U. Nagar - 388 121 Gujarat, India 91-2692-229280 http://www.slscorp.com

Copyright © 2008-2009, System Level Solutions, Inc. (SLS) All rights reserved. SLS, an embedded systems company, the stylized SLS logo, specific device designations, and all other words and logos that are identified as trademarks and/or service marks are, unless noted otherwise, the trademarks and service marks of SLS in India and other countries. All other products or service names are the property of their respective holders. SLS products are protected under numerous U.S. and foreign patents and pending applications, mask working rights, and copyrights. SLS reserves the right to changes to any products and services any without notice. SLS assumes no responsibility or liability arising out of the application or use of any information, products, or service described herein except as expressly agreed to in writing by SLS. SLS customers are advised to obtain the latest version of specifications before relying on any published information and before orders for products or services.

ug_CoreCommanderbsp_1.1

ii System Level Solutions

About This Document uClinux CoreCommander BSP

About This Document This document describes the usage of the uClinux CoreCommander board support package. With the of the bsp you can develop embedded applications using CoreCommander board and uClinux. Table below shows the revision of the document. Version Date Description 1.1 January 2009 - Updated document for CoreCommnader BSP, . 2.1.1.1 - Updated section 1.3 Supported devices. - Updated section 4.3 SLS SD Controller IP driver - Updated section 4.5 USB 2.0 IP driver - Added Appendix A, B, C. 1.0 September 2008 First release How to Contact SLS For the up-to-date information about SLS products, go to the SLS worldwide website at http://www.slscorp.com. For additional information about SLS products, consult the source shown below. Information Email

E- Product literature services, SLS [email protected] literature services, Non-technical customer services, Technical

System Level Solutions iii

Typographic Conventions uClinux CoreCommander BSP

Typographic Conventions This document uses the typographic conventions shown as below. Visual Cue Meaning Bold type with initial All headings, subheadings titles in a document are capital letters displayed in bold type with initial capital letters. E.g. Configuring and Compiling. Bold Project names, Menu commands, disk drive names, filenames, filename extensions, and software utility names are shown in bold type. Examples: Helloworld, project name, menu command, romfs/bin , sls_cc_bsp_hw_v10.sof . Courier Anything that must be typed exactly as it appears is shown in Courier type. For example: /home/ uClinux-2.1.1.1/nios2-/uClinux- dist. 1, 2 Numbered steps are used in a list of items, when the sequence of items is important. Such as steps listed in procedure. • Bullets are used in a list of items when the sequence of items is not important. Hand points to special information that requires special attention

Caution indicates required information that needs special consideration and understanding and should be read prior to starting or continuing with the procedure or

process. Warning indicates information that should be read prior to starting or continuing the procedure or processes.

Feet direct you to information on a particular topic.

iv System Level Solutions uClinux CoreCommander BSP

Table of Contents

1. Introduction...... 1 1.1 Software...... 1 1.2 Hardware...... 1 1.3 Development Platform Requirements...... 3 1.4 Setup ...... 3

2. uClinux CoreCommander BSP Development Environment ...... 5 2.1 CoreCommander BSP SOPC System ...... 5 2.2 Development Environment ...... 5 2.2.1 CoreCommander BSP Components...... 6 2.2.2 IP Address Used ...... 6 2.3 Development Host ...... 7 2.3.1 Downloading and Unpacking uClinux CoreCommander BSP ...... 7 2.3.2 Directory Contents...... 8 2.4 Development Target...... 8 2.4.1 Configuring and Compiling uClinux ...... 8 2.4.2 Set System.ptf...... 11 2.4.3 Customization of Kernel Settings ...... 12 2.4.4 Building uClinux zImage...... 14

3. Downloading and Running zImage ...... 15 3.1 Running zImage on Linux Using JTAG UART Console...... 15

4. Configuring Device Drivers and File Systems...... 16 4.1 Board Selection...... 16 4.2 Flash Memory (MTD) Driver ...... 16 4.2.1 JFFS2 File System Configuration...... 17 4.3 SLS SD Host Controller Driver ...... 18 4.3.1 VFAT...... 18 4.4 SLS Ethernet IP Driver ...... 19 4.4.1 NFS ...... 19 4.5 SLS USB 2.0 Driver ...... 20 4.6 SLS Keypad Driver...... 20 4.7 SLS LCD Frame buffer Driver ...... 20 4.8 JTAG UART Driver ...... 21

5. User Applications...... 23 5.1 Flash and JFFS2 Application ...... 23 5.1.1 Flash Tools...... 23 5.1.2 Accessing Flash and JFFS2 Applications ...... 23 5.1.3 Configuring Flash Partition ...... 25 5.2 LCD and SD Card Application ...... 25 5.2.1 Using LCD Frame Buffer Driver API...... 25 5.2.2 Viewing JPEG Images from SD Card...... 26 5.3 Adding New User Application...... 27 5.4 Build New User Application Using SLS IP Drivers...... 28 5.5 Shell Commands ...... 28

System Level Solutions v

Introduction uClinux CoreCommander BSP

6. Configuring Network utilities and NFS (Client)...... 31 6.1 Configuring DHCP Client...... 31 6.2 Static IP Allocation...... 32 6.3 Mounting NFS on CoreCommander ...... 32 6.3.1 NFS Server (Host) Set Up ...... 32 6.3.2 NFS Client (CoreCommander) Setup ...... 33 6.4 Configuring , telnetd, ftpd Server ...... 33 6.5 Configuring boa Server...... 34

7. Debugging Kernel and User Application...... 37 7.1 Debugging uClinux kernel using nios2-elf-insight over JTAG ...... 37 7.2 Debugging User Application using gdbserver over Ethernet ...... 38 7.3 Debugging User application using Eclipse IDE...... 40

8. Demonstrations & Quick Reference...... 43 8.1 Demonstrations ...... 43 8.1.1 Picview ...... 43 8.1.2 ChatServer ...... 45 8.1.3 PortInterface ...... 47 8.2 Quick Reference ...... 54 8.2.1 Prebuilt_zImage...... 54

Appendix A. Ethernet Driver...... 57

Appendix B. SD Host Controller Driver...... 59

Appendix C. USB 2.0 Driver...... 61

System Level Solutions uClinux CoreCommander BSP

1. Introduction uClinux CoreCommander Board support package (BSP) provides developers the easiest and fastest way to create embedded applications on the CoreCommander board (target) using uClinux . The hardware, firmware, and software together form a complete package for building, downloading, and testing applications developed on a host machine: • the uClinux board support package (BSP) on the host PC • Connect JTAG cable between host and target for JTAG communication • Build custom Linux kernel for the CoreCommander board When ready to see your application in action, just download it to the CoreCommander board. Now you can and the kernel and application.

1.1 Software uClinux CoreCommander BSP is the combination of uClinux, IP core drivers and applications developed by SLS Corporation. Current version of the BSP supports Flash, SD Host Controller, Ethernet, and USB 2.0 IP. uClinux is a port of Linux for MMU processor. So many different architectures are supported by uClinux. It has almost all necessary power as an embedded operating system. This document is based on kernel version 2.6.28 Visit www.uclinux.org for more information.

1.2 Hardware The following list summarizes the hardware featuers: Target Hardware Board • SLS CoreCommander Board, Cyclone III Edition Device • System name: sls_cc_bsp_hw_v10 • Family: Cyclone III • Device: 3C25F256C8 • Total logic elements (LE) used: 12,965 / 24,624 (53%) • Total pins used: 119 /157(76%) • Total memory used: 138,080 / 608,256 (23%) Processor • Nios II/f processor core • Nominal metrics: 113 DMIPS at 100 MHz, 1,400–1,800 LEs, MMU/MPU option disabled System Level Solutions 1

Introduction uClinux CoreCommander BSP

• 4-KByte data cache, 4-KByte instruction • JTAG debug module for downloading software, 300–400 LEs This BSP is targeted for Nios II. Nios II is a soft core FPGA processor. It is 32 bit RISC general purpose processor. Nios II processor system is equivalent to a microcontroller or “Computer on a chip” that includes a processor and a combination of peripherals and memory on a single chip. The term “Nios II processor system” refers to a Nios II processor core, a set of on-chip peripherals, on-chip memory, and interfaces to off-chip memory, all implemented on a Single Altera device. Like a microcontroller family, all Nios II processor systems use a consistent instruction set and programming model. Memory Interfaces • Common flash interface (CFI) flash memory • 8 Mbytes • SDRAM Controller • 32 Mbytes • SD Host Controller IP, v2.4 Communication Interfaces • SLS Ethernet 10/100 MAC v2.0 • JTAG UART with integrated read and FIFO • USB 2.0 Device IP Core (USB20HR), v2.3 Display Interfaces • SLS "1.7" TFT LCD Interface System Peripherals • Timers/counters • Interval timer • 32-bit counter size, 1-ms time-out period • 6 Keypad PIOs (input only) • 2 LED PIOs (output only) • System ID If you wish to recompile the reference design, download the following IP cores and interfaces: • USB20HR IP Core • SD Host Controller IP Core • Ethernet 10/100 MAC IP Core • 1.7” TFT LCD Interface After downloading the IP Cores, get the license for each IP Core from http://www.slscorp.com/pages/ipLicenseinfo.php and follow the instructions.

2 System Level Solutions uClinux CoreCommander BSP uClinux CoreCommander BSP Development Environment

1.3 Development Platform Requirements We assume that user is familiar with Altera tools. Following are development platform requirements: • Any Linux distribution having good hardware configuration with at least 2.5 GB free space. • Altera Development Tools (v8.1) This uClinux BSP is tested on Red Hat Fedora Core 7, OpenSUSE 10.3 and Mandriva 2008 but it should work on other Linux Desktop distributions also. You can build the kernel and application on Linux desktop only. Images built on Linux can be downloaded and run on Windows if the Altera Development tools are installed. This BSP will not work on Cygwin environment.

1.4 Setup To startup and begin communicating with the board: 1. Establish communication between target (Board) and host (PC) using JTAG cable. 2. Establish a network connection using RJ45 Ethernet cable to debug the application. (Ethernet Add-on board is required) 3. Apply power to the CoreCommander board.

System Level Solutions 3

2. uClinux CoreCommander BSP Development Environment This chapter provides information to help setup the development environment for the CoreCommander board.

2.1 CoreCommander BSP SOPC System Figure 1 below shows the block diagram of CoreCommander BSP SOPC system. Figure 1 : CoreCommander BSP SOPC System

2.2 Development Environment Nios II embedded development environment consists of two systems: a host system and a target system. Host system is used for compiling, linking, remote debugging, and associated development activities. Target system, such as the CoreCommander board, is used for application development and testing (Figure 2). Board acts as a target for application development

System Level Solutions 5 uClinux CoreCommander BSP Development Environment uClinux CoreCommander BSP

Figure 2 : Development Environment

uClinux CoreCommander BSP Applications

Ethernet RED HAT uClinux JTAG CoreCommander BSP SOPC Host System

Nios II

IP Cores

Target CoreCommander Board

2.2.1 CoreCommander BSP Components Table below lists the components included in the uClinux CoreCommander BSP. Component Description kernel v2.6.28 gcc v3.4.6 Ethernet driver Included Frame buffer driver Included Keypad driver Included SDcard driver Included FLASH driver Included JFFS2 support Included VFAT support Included NFS support Included JPEG support Included

2.2.2 IP Address Used Table below lists the IP address and port used throughout this document. It may be different for your system. Please check your network settings before applying any IP address.

6 System Level Solutions uClinux CoreCommander BSP uClinux CoreCommander BSP Development Environment

IP Address Description 192.168.0.14 Development Target IP address 192.168.0.26 Development Host and NFS server IP address 192.168.0.205 Gateway IP Address 255.255.255.0 Gateway Mask 9999 TCP port

2.3 Development Host Refer to the Red Hat documentation for Red Hat Fedora 7.0 core installation and host setup information.

2.3.1 Downloading and Unpacking uClinux CoreCommander BSP To download the uClinux CoreCommander BSP package visit: http://slscorp.com/pages/ccbspdownload.php. Now, follow the steps below to unpack the BSP package. 1. the entire package in the home directory. 2. Apply command to login as super user #su It will ask super user password for further process. 3. Issue #cd /home # jxfv uClinux-2.1.1.1.tar.bz2 It starts extracting files and it may take some time. 4. Now go into uClinux directory using the following command #cd /home/uClinux-2.1.1.1 And then #tar jxfv uClinux-dist.tar.bz2 It starts extracting files and it may take some time. 5. Now, issue #cd Bintools #tar jxfv nios2gcc-20080203.tar.bz2

System Level Solutions 7 uClinux CoreCommander BSP Development Environment uClinux CoreCommander BSP

It starts extracting files and it may take some time. 6. Return to uClinux-2.1.1.1 #cd .. 7. Issue command # Here you will see nios2-linux, Bintools, and System-files.

2.3.2 Directory Contents You have now successfully unpacked the BSP package. You will see following directory structure: Directory Description uClinux-2.1.1.1 Contains nios2-linux, bintools (binary tool chain) and system files. Users, interested only in software side can working with this directory. Docs Contains BSP documents: uClinux CoreCommander BSP user guide, CoreCommander reference manual and boot_message.txt. Demo Contains SLS uClinux CoreCommander Demos. In each subdirectory you will other necessary files. Ref_design Contains Quartus archive project of SOPC system used in this BSP. Quick Reference Pre-built zImage for ready reference. ReleaseNotes.pdf Contains CoreCommander BSP release notes.

2.4 Development Target

2.4.1 Configuring and Compiling uClinux CoreCommander BSP has two main areas of configurations. Together they define a complete uClinux platform configuration. These two areas include: • Vendor / Product Settings • Kernel Settings In this section, you will learn all the above listed configurations.

Start Configuration Menu To configure the kernel, go to the directory /home/uClinux-2.1.1.1/nios2- linux/uClinux-dist and follow the steps below: 1. Open the Linux terminal.

8 System Level Solutions uClinux CoreCommander BSP uClinux CoreCommander BSP Development Environment

2. On the terminal, change into the $home/uClinux-2.1.1.1/nios2- linux/uClinux-dist directory and change the environment . Use one of the four main kernel configuration methods to start the configuration menu. #cd /home/uClinux-2.1.1.1/nios2-linux/uClinux-dist #PATH=$PATH:/home/uClinux-2.1.1.1/Bintools/opt/nios2/ bin 4. Configure the kernel. #make menuconfig You will see the kernel configuration main menu as shown in Figure 3. Figure 3 : Linux Kernel Configuration Main Menu

Use one of the two main kernel configuration methods to start the configuration. Use or arrow to select the menu item and then press to go into the submenu. Use  or and then press to select the menu command