Philips LPC3180 Installation and operating instructions

AN10476
Getting started Linux with LPC3180
Rev. 013 — 21 Dec 2006 Application note
Document information
Info Content
Keywords Linux, ARM9, LPC3180
Abstract This application note describes how to start Linux with Philips LPC3180
MCU(ARM926EJ-S core), including how to setup the system and make
small modifications and how to add user applications to the system.

Philips Semiconductors AN10476
Getting started Linux with LPC3180
Revision history
Rev Date Description
01 20060403 Initial version
02 20061220
Add sections about SDRAM/NAND flash related sections.
Update with software updates of JFFS2/USB OTG function.
Update with new SIBL programming method by using LPC3180 Loader.
Add the method of modifying rootfs and creating new rootfs.
More explanation about NFS usage for application debugging.
03 20061221
Support for Phytec LP3180 development board
Contact information
For additional information, please visit: http://www.semiconductors.philips.com
For sales office addresses, please send an email to: sales.addresses@www.semiconductors.philips.com
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 2 of 28

Philips Semiconductors AN10476
Getting started Linux with LPC3180
1. Introduction
This getting started document describes the basics on how to set-up the system as well
as how to make small modifications and how to add user applications.
1.1 Concept
The LPC3180 reference base port consists of a hardware and software package.
Hardware-wise the package comes with a Phytec demonstration board, with a LPC3180
mounted. On-board resources include memories (Nand-Flash/SDRAM), JTAG, Uart
connections, USB, mass storage devices (SD-MMC), etc.
The on board clock source is configured with a 13MHz oscillator. The clock is multiplied
by PLL to generated 208MHz CPU clock for LPC3180.
Software-wise the reference base port includes SIBL, U-Boot, the Linux kernel, and a
Linux root file system and supports the following drivers:
• All basic drivers like Interrupts, DMA, I2C, SPI, UART, etc.
• USB device/host/OTG
• Ethernet (over USB)
1.2 The boot process
The reference base port uses a staged boot process: the bootstrap code in IROM tries to
make a connection over the serial command port to allow an external program to take
over the boot process. If this connection is not made, the bootstrap code will start loading
the code in block zero of the NAND flash. This block contains the SIBL(secondary boot
loader) that will initialize the main functions of the LPC3180. After initialization SIBL will
continue scanning the NAND flash for images and executables and load these in
memory. The first executable it finds will be executed (U-Boot in our case). U-Boot will
then start Linux.
Besides starting Linux U-Boot (Universal boot loader) has quite some features to set-up
and debug the system. More information on U-Boot can be found on the Internet or by
typing help in U-Boot.
2. Setup environment
For development purposes the following packages are recommended/required.
2.1 Hardware
The necessary hardware tools:
• Phytec LPC3180 development board and power supply for the board
• ARM RealView ICE
• A PC with serial port and USB port
• A serial cable
Optional:
• A USB hub
(As the LPC3180 is unable to provide enough power to connected USB device)
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 3 of 28

Philips Semiconductors AN10476
Getting started Linux with LPC3180
• A USB to Ethernet adapter
(For network functions since Phytec board has no Ethernet interface)
• A network cable
(Connect between PC and the board)
• A USB mass storage disk
(For USB mass storage function testing)
• A SD card
(For SD card interface function testing)
2.2 Software under Windows
Software running under Windows environment:
• ARM Realview development suit (preferably version 1.2) or RVDK for Philips
(For running or debugging in SDRAM)
• Cygwin
(For building SIBL)
2.3 Software under Linux
A Linux system with root access is necessary for the development.
On this Linux system, below tools must be available:
• Generic tools like ‘make’.
• arm-linux-xxx cross compile tool chain (which is available in the /tools/ directory)
tar –zxvf arm-linux-gcc-2004-q1-vfp.tar.gz
You can get the ‘release-3.4.0-vfp’directory which includes the arm-linux-xx tools.
[Note]
If user would like to use new version compilers downloaded from internet, please pay
attention that the kernel and the libraries in the root file-system must be built with the
same compiler. That means you must re-compile not only the Linux kernel but also all
libraries and executable files in the root file system.
And you should grab below source packages for building new images and further
development.
• U-boot
Download U-Boot Version 1.1.1 ‘u-boot-1.1.1.tar.gz’ from:
http://u-boot.sourceforge.net/
• Linux kernel
Download Official Kernel Version 2.6.10 ‘linux-2.6.10.tar.gz’ from:
http://www.kernel.org/pub/linux/kernel/v2.6/
3. Building images
There are images files existed in the /images directory, which can be used to run from
SDRAM or program to NAND flash.
Also user can build and get new images with the following steps.
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 4 of 28

Philips Semiconductors AN10476
Getting started Linux with LPC3180
3.1 Building SIBL
To be able to build SIBL, you must have CYGWIN and the ARM tool-suite installed on
your (Windows) system. SIBL can only be built using CYGWIN.
Using the sources in src/sibl, run:
make clean
make phytec
Generated ‘si_phytec.axf, sibl_phytec.bin’ will be used later.
3.2 Building U-boot
To build the sources you must copy U-boot sources and the patch to a drive on your
Linux environment.
Make sure the cross compiler is enabled(refer to linux-2.6.10-lpc3180/setup_links):
export PATH=$PATH:/usr/local/arm/gnu/release-3.4.0-vfp/bin/arm-linux-
gcc:/usr/lucy/uboot/u-boot-1.1.1/tools
export ARCH=arm
export CROSS_COMPILE=arm-linux-
Untar the source:
tar –zxvf u-boot-1.1.1.tar.gz
Apply patch to create full U-Boot version:
cd u-boot-1.1.1
gzip -cd ../u-boot-1.1.1-phytec3180.patch.gz | patch -p1
Then do:
make distclean
make phytec_config
make
make u-boot.axf
This will give you the files u-boot* which you can run using the ARM Debugger or convert
into a U-Boot image, i.e. (must be one line):
./tools/mkimage -A arm -O u-boot -T Firmware -C none -a 81EC0000 -e 81EC0000 -n
"My U-Boot v0.1" -d u-boot.bin uboot_phytec.ubt
3.3 Building kernel
The Linux kernel patch can be found on /src/kernel directory. Make sure the following
environment variables are set(refer to linux-2.6.10-lpc3180/setup_links):
export PATH=$PATH:/usr/local/arm/gnu/release-3.4.0-vfp/bin/arm-linux-
gcc:/usr/lucy/uboot/u-boot-1.1.1/tools
export ARCH=arm
export CROSS_COMPILE=arm-linux-
Actually user can have a look at the ‘linux-2.6.10/setup_links’ and modify it according
to your local settings, then do
source ./setup_links
to get the same result. Same method can apply to U-boot.
Untar the source:
tar –zxvf linux-2.6.10.tar.gz
Apply patch to create LPC3180 ARM Kernel:
cd linux-2.6.10
gzip -cd ../linux-2.6.10-phytec3180.patch.gz | patch -p1
In the linux-2.6.10 directory run:
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 5 of 28

Philips Semiconductors AN10476
Getting started Linux with LPC3180
make clean
make lpc3180_defconfig
make
make uImage
This will give you the images files as ‘arch/arm/boot/uImage’ which you can run using the
ARM Debugger or convert into a U-Boot image, i.e. (must be one line):
mkimage -A arm -O Linux -T Kernel -C none -a 80600000 -e 80600000 -n "Linux-
2.6.10" -d uImage uImage_phytec.ubt
In our case, the ‘uImage’ file is renamed as ‘uImage_phytec’.
After running ‘make xxx_defconfig’ you can change the default kernel parameters by
running ‘make xconfig’ or ‘make menuconfig’.
When a completely new kernel is built and if you have built loadable modules use the
following script to copy the modules to ./lib/modules:
./collect_modules
These then need to be copied to the target arm root file system that you have mounted
(see next section):
cp -dpR ./lib/modules/2.6.10/kernel ~/mnt_rootfs/lib/modules/2.6.10/
3.4 Building root file system
The pre-build root file-system is available on ‘/images/root_fs_arm.ext2.phytec.gz’.
You can modify this file system (as root on your Linux development system) by unzipping
and mounting it:
gzip –d root_fs_arm.ext2.phytec.gz
mount -o loop root_fs_arm.ext2.phytec ./mnt_rootfs/
And simply making the modifications required (in ./mnt_rootfs/). Below are the
instructions on adding user application, updating loadable modules and modifying
network settings.
E.g.
• When we intend to add a new application program as ‘hello’(see chapter 6 on how to
develop such a new application), just copy it to the ./mnt_rootfs/bin/ directory, then the
program can be used as a command directly under Linux Shell.
cp ~apps/hello ~/mnt_rootfs/bin
• To update the loadable modules, collect and copy the new module files to the root file
system as described in section 3.3:
cp -dpR ./lib/modules/2.6.10/kernel ~/mnt_rootfs/lib/modules/2.6.10/
• If user would like to change some boot settings, have a look at the files under
‘./mnt_rootfs/etc/’ directory. It’s a good start to understand the workflow of a root file
system. There are detailed descriptions on the function of these files in Linux
Documentation and Linux-How-To documents. For example, if you would like to
change the Ethernet ip address, open and edit the file
‘./mnt_rootfs/etc/network/interfaces’ would work.
After you did your modifications, un-mount and zip the image again. You can get the new
root file system file.
Also you can make its u-boot image with:
mkimage -A arm -O Linux -T Filesystem -C none -a 0x80800000 -e 0 -n "My RootFS
v0.1" -d root_fs_arm.ext2.phytec.gz rootfs_phytec.ubt
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 6 of 28

Philips Semiconductors AN10476
Getting started Linux with LPC3180
It is probably not a good idea to start a rootfs completely from scratch as the kernel and
the libraries in the root file-system must be built with the same compiler (we use arm-
linux-gcc v3.4.0 with vfp support). But if the customer definitely needs to create a new
rootfs for function customization or reducing rootfs size or other reasons, here is a
example script of generating an empty ext2 file system:
#!/bin/sh
RAMDIR_PATH="initrd"
MNTPOINT="initrd_mnt"
IMAGE="ramdisk"
TARGET="ramdisk.img"
rm -f $TARGET
dd if=/dev/zero of=$IMAGE bs=1k count=6144
mke2fs -F -m0 $IMAGE
mkdir -p $MNTPOINT
mount -t ext2 -o loop $IMAGE $MNTPOINT
cp -a "$RAMDISK_PATH"/* $MNTPOINT
chown root:root -R $MNTPOINT
umount $MNTPOINT
rm -rf $MNTPOINT
gzip -9 < $IMAGE > $TARGET
rm -f $IMAGE
This script file will create an empty ext2 file system with 6MB size. Then you can copy
necessary library files/executable files/startup script files from original mounted
~/mnt_rootfs/ by root_fs_arm.ext2.phytec.
Be careful!
When the file size of root_fs_arm.ext2.phytec.gz is not aligned on word (4 bytes) size,
you will have a problem when downloading the file using Realview debugger. A work-
around is to enlarge the file with 1 byte with the command:
echo >> root_fs_arm.ext2.phytec.gz
’echo’ until the file size is word aligned!
4. Running from SDRAM
4.1 Start Linux kernel and Root file system
• Setup the hardware connection and make sure the Phytec board JP32 jumper is on 2-
3 state(UART5 boot).
• Open a serial terminal and set its parameters as ‘115200,8n1n’.
• In the RealView debugger load the ‘uboot_phytec.inc’ file from the rv directory (make
sure the path directory is set correctly in ‘uboot_phytec.inc’).
Sibl and U-Boot is started automatically. In the Serial terminal window press enter to stop
auto-boot.
43210
Initialize only
Main entry returned
U-Boot 1.1.1 (Jan 25 2006 - 12:00:24)
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 7 of 28

Philips Semiconductors AN10476
Getting started Linux with LPC3180
U-Boot code: 80EC0000 -> 80EF2148 BSS: -> 80EF3A44
SDRAM : 32M detected
RAM Configuration:
Bank #0: 80000000 31 MB
Flash: 0 kB
NAND:NAND device: Manufacturer ID: 0x20, Chip ID: 0x35 (ST Micro NAND 32MiB
1,8V 8-bit)
Scanning device for bad blocks
Bad eraseblock 478 at 0x00778000
Bad eraseblock 1520 at 0x017c0000
Using default environment
In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 2
Phytec #
In the Realview debugger, stop running and download the root file system and kernel
image using commands:
stop
rf
ui
[Remark] rf and ui have been defined as alias in the ‘uboot_phytec.inc’
alias rf=readfile,raw,gui "d:\Linux\Images\root_fs_arm.ext2.premo.gz"=0x80800000
alias ui=readfile,raw,gui "d:\Linux\Images\uImage_premo"=0x80600000
Now start the processor again (press F10 & F5) or using command in the Realview
debugger:
go
And in the serial terminal window type:
Phytec # bootm 0x80600000
The Linux will start up and root file system will be mounted:
Boot reached stage 1
## Booting image at 80600000 ...
Boot reached stage 2
Boot reached stage 3
Image Name: Linux-2.6.10
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1176680 Bytes = 1.1 MB
Load Address: 80008000
Entry Point: 80008000
Boot reached stage 4
Boot reached stage 5
Boot reached stage 6
OK
Boot reached stage 7
Boot reached stage 8
Boot reached stage 14
Boot reached stage 15
Starting kernel ...
Where the display goes silent after “Starting the kernel…”, the serial interface will keep
you informed with the process of booting Linux and will finally come up with a login
prompt. The root password is empty (i.e. simply press enter).
You are now running Linux!
Uncompressing Linux.........................................................
.. done, booting the kernel.
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 8 of 28

Philips Semiconductors AN10476
Getting started Linux with LPC3180
9 (CodeSourcery ARM Q1 2004)) #6 Thu Dec 14 15:48:45 CST 2006
CPU: ARM926EJ-Sid(wt)RR [41069264] revision 4 (ARMv5TEJ)
CPU: D VIVT write-back cache
CPU: I cache: 32768 bytes, associativity 4, 32 byte lines, 256 sets
CPU: D cache: 32768 bytes, associativity 4, 32 byte lines, 256 sets
Machine: LPC3180
serial : early init
Memory policy: ECC disabled, Data cache writethrough
Built 1 zonelists
Kernel command line: console=ttyS0,115200n8 root=/dev/ram initrd=0x80800000,
12M
Interrupt masks are setup
PID hash table entries: 128 (order: 7, 2048 bytes)
Console: colour dummy device 80x30
Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
Memory: 31MB = 31MB total
Memory: 17280KB available (1450K code, 299K data, 88K init)
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
checking if image is initramfs...it isn't (no cpio magic); looks like an ini
trd
Freeing initrd memory: 12288K
NET: Registered protocol family 16
late serial init
serial : late init
SD/MMC card sense IRQ=91
start_module_gpio:601: LPC3180 GPIO driver
start_module_gpio:602: Debug Level 0
start_module_gpio:589: GPIO Userspace driver
start_module_gpio:590: Debug Level 0
SCSI subsystem initialized
usbcore: registered new driver usbfs
usbcore: registered new driver hub
LPC3180 I2C-0: Master at 0xc0199780, irq 51.
USB I2C-0: Master at 0xc0199980, irq 63.
NetWinder Floating Point Emulator V0.97 (double precision)
Serial: 8250/16550 driver $Revision: 1.2.2.5 $ 4 ports, IRQ sharing disabled
ttyS0 at MMIO 0x0 (irq = 9) is a 16550A
ttyS1 at MMIO 0x0 (irq = 7) is a IP3106
ttyS2 at MMIO 0x0 (irq = 8) is a IP3106
ttyS3 at MMIO 0x0 (irq = 10) is a IP3106
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered
RAMDISK driver initialized: 16 RAM disks of 12288K size 1024 blocksize
loop: loaded (max 8 devices)
elevator: using anticipatory as default io scheduler
nbd: registered device at major 43
mice: PS/2 mouse device common for all mice
i2c /dev entries driver
Obelix: Driver for nxpp platform only
NET: Registered protocol family 2
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 2048 bind 4096)
NET: Registered protocol family 1
NET: Registered protocol family 17
VFP support v0.3: implementor 41 architecture 1 part 10 variant 9 rev 1
RAMDISK: Compressed image found at block 0
VFS: Mounted root (ext2 filesystem).
Freeing init memory: 88K
INIT: version 2.85 booting
dma-core : dma core init
ARM PLL080 DMA Controller: Address = 31000000, irq = 28
DMA Controller setup: 16 requestors,
32-bit wide bus,
2 master interfaces,
8 channels
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 9 of 28

Philips Semiconductors AN10476
Getting started Linux with LPC3180
lpc3180_kbd: Requesting IO Region: 40050000 - 0080
lpc3180_kbd: Memory mapped to c2006000
lpc3180_kbd: creating proc entry
keyboard-lpc3180: driver running on platform=lpc3180
lpc3180_kbd: Setting up registers
lpc3180_kbd: initialising driver
lpc3180_kbd: registering device
lpc3180_kbd: lpc3180 keyboard open called
sysfs entry reg
lpc3180_kbd: LPC3180 keyboard driver initialized
LPC3180 Event Router driver
Debug Level 1
Requesting IO Region: 4000C000 - 0018
Memory mapped to c2008000
Requesting IO Region: 40010000 - 0018
Memory mapped to c200a000
Requesting IO Region: 40008000 - 0018
MIC Memory mapped to c200c000
gpio_leds : driver compiled Dec 14 2006 at 15:46:09
Initializing USB Mass Storage driver...
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
usbcore: registered new driver usbhid
drivers/usb/input/hid-core.c: v2.0:USB HID core driver
About to register ohci_hcd_lpc3180_driver
About to register ip3506_ohci
ohci ohci1: at 0xf1020000, irq 59
init_otg_dualrole_fsm
usbcore: registered new driver catc
drivers/usb/net/catc.c: v2.8 CATC EL1210A NetMate USB Ethernet driver
usbcore: registered new driver kaweth
drivers/usb/net/rtl8150.c: rtl8150 based usb-ethernet driver v0.6.2 (2004/08
/27)
usbcore: registered new driver rtl8150
usbcore: registered new driver usbnet
drivers/usb/net/pegasus.c: v0.5.12 (2003/06/06):Pegasus/Pegasus II USB Ether
net driver
usbcore: registered new driver pegasus
spi-lpc3180: SPI Test Dec 14 2006 CS driver running on platform=premo
Found clock frequency for spi-1 is 104000000
initialising CS table
Found clock frequency for spi-2 is 104000000
initialising CS table
isp1301_generic 1-002d: chiprev 2.10, driver 26 May 2006
pshs_uart probe: Using 7 dma req for TX and 8 dma req for RX
ttyPSHS0 at MMIO 0x40018000 (irq = 25) is a PSHS
pshs_uart probe: Using 9 dma req for TX and 10 dma req for RX
ttyPSHS1 at MMIO 0x4001c000 (irq = 25) is a PSHS
pshs_uart probe: Using 5 dma req for TX and 6 dma req for RX
ttyPSHS2 at MMIO 0x40014000 (irq = 25) is a PSHS
usbcore: registered new driver usbserial
drivers/usb/serial/usb-serial.c: USB Serial Driver core v2.0
drivers/usb/serial/usb-serial.c: USB Serial support registered for FTDI SIO
drivers/usb/serial/usb-serial.c: USB Serial support registered for FTDI 8U23
2AM Compatible
drivers/usb/serial/usb-serial.c: USB Serial support registered for FTDI FT23
2BM Compatible
drivers/usb/serial/usb-serial.c: USB Serial support registered for FTDI FT22
32C Compatible
drivers/usb/serial/usb-serial.c: USB Serial support registered for USB-UIRT
Infrared Tranceiver
drivers/usb/serial/usb-serial.c: USB Serial support registered for Home-Elec
tronics TIRA-1 IR Transceiver
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 10 of 28

Philips Semiconductors AN10476
Getting started Linux with LPC3180
usbcore: registered new driver ftdi_sio
drivers/usb/serial/ftdi_sio.c: v1.4.1:USB FTDI Serial Converters Driver
drivers/usb/serial/usb-serial.c: USB Serial support registered for PL-2303
usbcore: registered new driver pl2303
drivers/usb/serial/pl2303.c: Prolific PL2303 USB to serial adaptor driver v0
.12
usb_register_udc returned 0
USB probe done
gs_module_init: Gadget Serial v2.0 loaded
ip3506: start_otg_ip3506
ip3506: ip3506_otg_probe
data->container = c0229244
host = 1
a_bus_req = 1
gadget = 1
id = 1
b_sess_end = 1
ip3503_udc_notification: reason 0
spi_init
SPI : setting spi-1 control to 804E93
Adapter c1b35078 Adapter spi-1 process c057faa0
spi-lpc : Adapter spi-1 registered at 20088000 using irq 55
SPI : setting spi-2 control to 804E93
Adapter c168cce0 Adapter spi-2 process c057f820
spi-lpc : Adapter spi-2 registered at 20090000 using irq 44
spi-lpc : Driver version 1.5 registered
setting divider code to 18 (ratio=38) using base clock = 104000000 freq out
2736842
spi_readtest_init
done spi_readtest_init
NAND device: Manufacturer ID: 0x20, Chip ID: 0x35 (ST Micro NAND 32MiB 1,8V
8-bit)
Scanning device for bad blocks
Bad eraseblock 478 at 0x00778000
Bad eraseblock 1520 at 0x017c0000
Creating 1 MTD partitions on "NAND 32MiB 1,8V 8-bit":
0x01000000-0x01f00000 : "LPC3180 NAND PART 0"
CSLIP: code copyright 1989 Regents of the University of California
PPP generic driver version 2.4.2
PPP Deflate Compression module registered
PPP BSD Compression module registered
mmc-lpc3180: mmc/sd driver running on platform=lpc3180
: MMCI rev 0 cfg 00 at 0x20098000 irq 15,13
JFFS2 version 2.2. (NAND) (C) 2001-2003 Red Hat, Inc.
running on [console=ttyS0,115200n8 root=/dev/ram initrd=0x80800000,12M]
Mounting SD/USB storage
No SD card or unknown filesystem
No USB storage or unknown filesystem
INIT: Entering runlevel: 2
Creating the the /var/dev/ttySA* links
Starting internet superserver: inetd.
Copacabana - ARM Embedded Linux version 1.1-vfp
Monday 20 December 2004 @ 20:40
(none) login: root
BusyBox v0.60.5 (2004.05.11-13:49+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
~ #
4.2 Using MMC/SD card devices
When you insert a SD card at boot time, Linux will automatically detect that and try to
mount the device. If you do so later you will have to mount the device manually.
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 11 of 28

Philips Semiconductors AN10476
Getting started Linux with LPC3180
~ # mount –t auto /dev/mmcblk0p1 /mnt/mmc
or
~ # mount –t auto /dev/mmcblk0 /mnt/mmc
[Remark] A GPIO or GPO is used to control external SD card power. In Phytec board, it’s
GPIO_06/GPO_06. If user has different designs that use other GPIO pin, just change the
corresponding GPIO pin number in below files:
./linux-2.6.10/arch/arm/mach-lpc3180/mmc.c
./linux-2.6.10/drivers/mmc/mmci.c
4.3 Connecting USB
The USB drivers have been updated to support USB-OTG functionality. This means that
after updating to the new release your USB hub and other devices may not be detected
automatically. The board will have gone into gadget mode after booting.
By this time, connecting the board with PC through a normal A-B cable (plugging to
board device connector) or normal A-mini B cable (plugging to board OTG connector),
PC can recognize the board as new USB devices immediately.
For the system to work automatically you will require a mini-A cable to be plugged into
your board. However, as these are still quite hard to come by an option has been
supplied for forcing USB into host mode.
To force your USB into host mode do the following:
~ # echo host > /sys/bus/usb_container/usb_container-dev-1/forced_mode
Then the connected USB devices, e.g. a USB mass storage disk, can be recognized by
the board Linux system. E.g.
~ # mount -t auto /dev/sda1 /mnt/usbdisk
If user wants to make the USB boot with host mode, just add the above forcing command
to the startup script file in rootfs. The command can be executed before system start up.
The way the USB gadget system works has also been modified to allow you to change
the functionality of the gadget without having to remove and reinstall drivers. To set the
personality of the gadget, do one of the following:
For a networking gadget,
~ # echo ether > /sys/bus/usb_container/usb_container-dev-1/udc/function
For a serial gadget,
~ # echo g_serial > /sys/bus/usb_container/usb_container-dev-1/udc/function
4.4 Connecting to the Ethernet
As the LPC3180 does not have an Ethernet controller onboard, the Ethernet connection
is established over USB. To be able to do so the following items are required:
- A USB hub (as the LPC3180 is unable to provide enough power to a connected USB
device)
- A USB to Ethernet adapter
Connect the main input connection of the USB hub to the board USB host connector and
the USB to Ethernet adapter to one of the client sides.
Make sure that the USB has been forced into host mode and the gadget system has
been set for Ethernet personality as stated in section 4.3.
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 12 of 28

Philips Semiconductors AN10476
Getting started Linux with LPC3180
With ‘ifconfig’ in Linux you can check if the Ethernet interface start working.
~ # ifconfig
eth0 Link encap:Ethernet HWaddr 00:E0:4C:00:18:8C
inet addr:192.168.0.2 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1540 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
4.4.1 Connection between PC and the board
Connect PC and the board using a network cable.
Set up the PC IP address as 192.168.0.1.
(The board IP address has been set as 192.168.0.2 by default.)
We can test the connection by using Linux ‘ping’ command.
~ # ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1): 56 data bytes
64 bytes from 192.168.0.1: icmp_seq=0 ttl=128 time=2.5 ms
64 bytes from 192.168.0.1: icmp_seq=1 ttl=128 time=0.8 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=128 time=1.0 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=128 time=1.1 ms
--- 192.168.0.1 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 0.8/1.3/2.5 ms
~ #
If the ‘httpd’ is included in the rootfs package, run it and then the board file system can
be displayed through Windows IE explorer.
~ # httpd &
Type “httpd://192.168.0.2/” in the address bar, the file system contents will display in the
IE window.
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 13 of 28

Philips Semiconductors AN10476
Getting started Linux with LPC3180
4.4.2 Connection using DHCP
If user would like to use DHCP to setup a Ethernet connection, please make sure the file
in ext2 root file system ‘/etc/network/interfaces’ has below contents:
iface eth0 inet dhcp
Instead of
iface eth0 inet static
address 192.168.0.2
, which is for private connection between PC and board.
With “ifconfig” command you can check if it was successful.
[Remark] This function is not fully tested since my company’s network doesn’t
allow a Linux OS machine.
4.5 Mounting file systems
Based on the root file system, user can mount other file systems for various purposes.
4.5.1 Mounting an external file system using NFS
Using the Ethernet you can mount an external drive by typing (when Linux is running –
one line intended):
mkdir /mnt/$NFS_WORK_PATH
mount -o nolock -t nfs $NFS_HOST:$NFS_WORK_PATH /mnt/$NFS_WORK_PATH
Set $NFS_HOST and $NFS_WORK_PATH to the values matching your environment.
e.g.
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 14 of 28

Philips Semiconductors AN10476
Getting started Linux with LPC3180
~ # mkdir /mnt/mynfs
~ # mount -o nolock -t nfs 192.168.0.123:/usr/lucy/Linux/fs/rootfs/ /mnt/mynfs
The NFS is a good method for application debugging. User can compile the program in
host PC Linux environment and then mount the related directory ($NFS_HOST) to the
real board environment ($NFS_WORK_PATH). Then the program can be executed in
the local directory $NFS_WORK_PATH.
4.5.2 JFFS2 support
JFFS2 support is by default enabled in the provided kernel, and all required modules are
loaded at boot-time. When you want to add a JFFS2 flash file system, you will have to
make some space in NAND flash (15 MB). The start offset of the JFFS2 is 0x01000000
while the end is 0x01f00000.
In U-Boot type:
nand erase 0x01000000 0x00F00000
The JFFS2 file system cannot be flashed with U-Boot, but must be copied to /dev/mtd0
when Linux is running (and a remote file system has been mounted over NFS), e.g.:
cp ./mynfs/nand0.jffs2 /dev/mtd0
or
cp ./usbdisk/nand0.jffs2 /dev/mtd0
Now you can add a new JFFS2 mount point:
mkdir /mnt/nand0
mount -t jffs2 /dev/mtdblock0 /mnt/nand0
A new JFFS2 file system can be easily made in your PC Linux environment by using
(should be one line):
mkfs.jffs2 –-eraseblock=0x20000 -–pad=0x01e00000 –n
–d ./your_directory –o nand0.jffs
Note, that the directory contents must not exceed 15 MB. The final JFFS2 image will
always be 15 MB in size.
‘Appendix A Default Flash Layout’ can give you an impression about the JFFS2 location
in the NAND flash device.
5. Flashing images
5.1 Flashing new images
We use Realview and U-boot to flash new image files.
In the RealView debugger load the ‘uboot_phytec.inc’ file from the ’/rv’ (make sure
the image directory is set correctly in ‘uboot_phytec.inc’).
U-Boot is started automatically. In the serial terminal window press enter to stop auto-
boot.
Stop the target and download new images to SDRAM for later flash programming usage.
In the debugger, type ‘stop’ and e.g.:
readfile,raw,gui "d:\Linux\Images\rootfs_phytec.ubt"=0x80000000
readfile,raw,gui "d:\Linux\Images\uboot_phytec.ubt"=0x80900000
readfile,raw,gui "d:\Linux\Images\uImage_phytec.ubt"=0x80600000
Or use the aliases ‘fr, fu, and fk’.
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 15 of 28

Philips Semiconductors AN10476
Getting started Linux with LPC3180
Then start the target again. The U-boot command ‘nand’ or ‘nand.jffs2’ can work for
erasing/writing/reading the NAND sub-system. Below examples use ‘nand’ command.
Before flashing new images, it’s better to erase the locations you want to have replaced.
In the serial terminal window, type e.g.:
NoHau # nand erase 0x00008000 0x00480000 (for erasing the rootfs)
NoHau # nand erase 0x00490000 0x00160000 (for erasing the kernel)
NoHau # nand erase 0x00660000 0x00040000 (for erasing U-boot)
Or:
Phytec # nand erase 0x00008000 0x006A0000 (for erasing all images)
[Note]
1. For details of nand flash command,type:
Phytec # help nand
2. For "nand erase" command the "size" should be block aligned (multiple of 0x4000).
3. If there are bad blocks, please avoid erasing them.
To load the images in SDRAM and flash the image, in the terminal window type e.g.:
NoHau # nand write 0x80000000 0x00008000 0x480000 (rootfs)
NoHau # nand write 0x80600000 0x00490000 0x160000 (kernel)
NoHau # nand write 0x80900000 0x00660000 0x040000 (u-boot)
[Note]
1. For "nand write" command the "size" must be larger than the image size and should be
page aligned (multiple of 0x200).
2. If there are bad blocks, please avoid writing them.
3. Please reserve at least 1 block for SIBL from the flash start address.
5.2 Flashing SIBL
Besides some initialization routines SIBL switches from one nand flash controller (MLC)
to another (NDF). SIBL is loaded by the bootstrap code and must always be at the same
exact location in flash.
Note that you cannot flash SIBL using U-Boot as U-Boot uses a different flash controller
than the bootstrap code!
User can select either of the below two methods to program the SIBL.
- Using LPC3180_Loader program through serial connection
- Using Seehau software and Phytec Emulator through JTAG interface
5.2.1 Using LPC3180 Loader
There Windows program LPC3180_Loader is available in the ‘./tools/flashloader’
directory.
Steps of programming SIBL:
- Install LPC3180_loader;
- Connect PC and Phytec board UART5 with serial cable;
- Make sure no serial terminal is connected to the command port of the Phytec board
and start LPC3180_loader;
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 16 of 28

Philips Semiconductors AN10476
Getting started Linux with LPC3180
- Select s_eroms.bin (in the ‘./tools/flashloader/’ directory) and sibl_phytec.bin (in
the ‘./images/’ directory) as below figure.
- Note the IARM Address of s_eroms.bin should be 0x0 while the Flash Address of
sibl_phytec.bin should be 0x200;
- Press the 'Program Flash' button;
- Reset the board when a dialog pops up, the download process will start automatically.
The whole download process should not take longer than a minute.
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 17 of 28

Philips Semiconductors AN10476
Getting started Linux with LPC3180
5.2.2 Using Seehau software
The Seehau sofeware and corresponding Nohau Emulator can be used to program SIBL.
Below figures reflect the basic settings for the function. For details of the tool usage,
please refer the Nohau’s related user manual.
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 18 of 28

Philips Semiconductors AN10476
Getting started Linux with LPC3180
5.3 Starting from NAND flash
After power on the board or pressing Reset button, you will see the startup messages on
your serial terminal.
During start-up U-Boot will also ask you to press a key to stop auto-boot, right now we do
not want that. The Linux will start up automatically.
43210
My RootFS v0.1++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Linux-2.6.10+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++My U-boot v0.1++++++++++++
U-Boot 1.1.1 (Jan 25 2006 - 12:00:24)
U-Boot code: 80EC0000 -> 80EF2148 BSS: -> 80EF3A44
SDRAM : 32M detected
RAM Configuration:
Bank #0: 80000000 31 MB
Flash: 0 kB
NAND:NAND device: Manufacturer ID: 0x20, Chip ID: 0x35 (ST Micro NAND 32MiB
1,8V 8-bit)
Scanning device for bad blocks
Bad eraseblock 478 at 0x00778000
Bad eraseblock 1520 at 0x017c0000
Using default environment
In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0
Boot reached stage 1
## Booting image at 80600000 ...
Boot reached stage 2
Boot reached stage 3
Image Name: Linux-2.6.10
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1344044 Bytes = 1.3 MB
Load Address: 80008000
Entry Point: 80008000
Boot reached stage 4
Boot reached stage 5
Boot reached stage 6
OK
Boot reached stage 7
Boot reached stage 8
Boot reached stage 14
Boot reached stage 15
Starting kernel ...
Uncompressing Linux.........................................................
............................. done, booting the kernel.
9 (CodeSourcery ARM Q1 2004)) #25 Tue Jan 17 16:41:49 CST 2006
CPU: ARM926EJ-Sid(wt)RR [41069264] revision 4 (ARMv5TEJ)
……
……
……
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 19 of 28

Philips Semiconductors AN10476
Getting started Linux with LPC3180
6. Adding user applications
Besides the basic setup, user may run his own application programs to implement
specific functions. Here we use ‘hello’ program as an example to explain how to add
user application.
The first step should be creating the ’hello’ project. The project, as any Linux project, may
include source files, header files and Makefile. The major difference is the compilation
tool in the Makefile should not be normal ‘gcc’, but the cross compiling tool as ‘arm-linux-
gcc’, which will generate image files that can run on LPC3180 (ARM9 CPU core).
E.g.
EXEC = hello
OBJS = hello.o
CC = arm-linux-gcc
all: $(EXEC)
$(EXEC): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
clean:
-rm -f $(EXEC) *.elf *.gdb *.o
When we get the ‘hello’ executable file, copy it to the ./bin directory of rootfs
(root_fs_arm.ext2.phytec.gz), then the program can be used as a command directly
under Linux Shell.
~ #hello
/******** Hello, World! ********/
/******** Hello, LPC3180! ********/
~ #
7. NAND flash porting
In the Phytec reference board, a ST NAND256R32 32Mbyte NAND flash is mounted.
Users may use different NAND flashes with it. This section gives a guide on how to port
the NAND flash drivers for new type devices.
For frequently used keywords as ‘page, block, small/large page, bad block’ and more
related information on NAND flash, the technical paper can be found on the website:
http://www.linux-mtd.infradead.org/doc/general.html
7.1 Content list
In the Linux staged boot process, SIBL, U-boot and Linux kernel are all involved in NAND
flash function implementation.
The relevant files supporting NAND Flash function in SIBL are:
sibl/sibl_flashboot_phytec.c
sibl/sibl_flashboot_phytec.h
In U-Boot:
uboot/common/cmd_nand.c
uboot/lib_nand/lpc3180_nand_abi_phyte
uboot/lib_nand/lpc3180_nand_phytec.c c.c
uboot/lib_nand/nand_base.c
uboot/lib_nand/nand_ecc.c
uboot/lib_nand/nand_bbt.c
uboot/lib_nand/nand_ids.c
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 20 of 28
Table of contents
Other Philips Microcontroller manuals