Philips LPC3180 Application Note

Page 1
AN10476
Getting started Linux with LPC3180
Rev. 013 — 21 Dec 2006 Application note
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.
Page 2
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
Page 3
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 mult iplied 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 recommende d/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
Page 4
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
Page 5
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_li nks):
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
Page 6
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
Page 7
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
Page 8
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 comman d 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
Page 9
Philips Semiconductors
AN10476
Getting started Linux with LPC3180
Linux version 2.6.10 (root@localhost.localdomain) (gcc version 3.4.0 2004040 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
Page 10
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
Page 11
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. Installing knfsd (copyright (C) 1996 okir@monad.swb.de). 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
Page 12
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
Page 13
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
Page 14
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 su c cessful.
[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
Page 15
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 exe cuted 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
Page 16
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 connecte d 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
Page 17
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 downloa d 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
Page 18
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 progra m 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
Page 19
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.
Linux version 2.6.10 (root@localhost.localdomain) (gcc version 3.4.0 2004040 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
Page 20
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
Page 21
Philips Semiconductors
AN10476
Getting started Linux with LPC3180
And in Linux:
linux-2.6.10/drivers/mtd/nand/lpc3180_nand_phytec.c
linux-2.6.10/drivers/mtd/nand/Makefile linux-2.6.10/drivers/mtd/nand/Kconfig linux-2.6.10/arch/arm/configs/lpc3180_defconfig
[Remark] The boldface files are the key files for NAND flash driver porting.
When users use different NAND flash devices, they still use the same LPC3180 on-chip NAND flash controller that has the same code implementation. We can port the NAND flash driver with modifying only the device dependent codes. Basically the listed files without boldface don’t need to be modified.
7.2 NAND flash support in SIBL
Basically NAND flash functions include read, write and erase. But in SIBL, only ‘read’ is used to load images from NAND flash to SDRAM.
In file
sibl/sibl_flashboot_phytec.c, the device dependent functions in reading data
include:
void set_addr( UInt32 page, UInt32 column); void set_page_addr( UInt32 page); int check_bad_block(int block); static int crc_check(image_header_t * iheader); UInt32 oob_check_ff_on_byte5( UInt8 *p_buf ); Void waitForReady(void);
For a new NAND flash device, these functions should be modified according to its user manual.
7.2.1 Loading image algorithm
For better understanding in reading and modifying the source code, this section gives detailed descriptions on SIBL loading image algorithm. Just for your reference.
In file sibl/sibl_flashboot_phytec.c, functions for reading image data from NAND flash are:
int read_page_data(UInt8 * buf, UInt32 page); int read_data(UInt8 * buf, int len); int read_block(UInt8 * buf, int block, int offset); int read_first_block( UInt8 *p_buf, int block_nr, int page_offset, unsigned int hdr_size);
The most common situation for the image allocation in the NAND flash is shown as below figure:
one block
1
2
31
30
0
one page
1
2
31
30
29
0
1
2
31
30
29
0
1
2
31
30
29
0
1
2
31
30
29
0
1
2
31
30
29
0
1
2
31
29
0
1
2
31
30
29
0
...
read_first_block
read_block
read_page_data
read_data
the star t a ddr ess o f t h e image
the last block
the last page
blue area : the allocation of t he image
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 21 of 28
Page 22
Philips Semiconductors
AN10476
Getting started Linux with LPC3180
Further explanation to the figure:
1) The first block data of the image is not guaranteed to start from the head of the first block. So read_first_block() is first invoked when performing load_image(), and its main job includes:
o Start reading the image data from the page address where the image
starts.
o Cut off the header info data of the image and reallocate the rest of the
first block into the SDRAM address space specified by the header info.
2) Then
read_block() is invoked for reading the sequent blocks until the last one.
3) The last block data of the image is not guaranteed to fill with the whole block, and the last page data is not guaranteed to fill with a completed page.
oad_image() invokes read_page_data() in reading the full pages in the last block
and
read_data() in reading the last incomplete page.
7.3 NAND flash support in U-Boot
U-Boot plays important roles in NAND flash operations as reading, writing, erasing, bad block checking, etc.
Below is a list of the related source files and their functions.
Directory Source file name Description
lpc3180_nand_phytec.c
Deal with low-level access to the specific nand flash on the board.
lpc3180_nand_abi_phytec.c
Interface between the Linux NAND driver MTD and the U-boot NAND command.
nand_base.c NAND low-level MTD interface functions.
nand_ecc.c
Contain an ECC algorithm that detect and correct 1 bit errors in a 256 byte block data.
nand_bbt.c Bad block table support for the NAND driver.
lib_nand/
nand_ids.c
A chip list than contains the chip info supported by the NAND driver.
common/ cmd_nand.c The U-boot NAND command functions.
7.3.1 Device ID list
The first step in NAND flash driver poring is to check whether your NAND flash device type is listed in the file
nand_ids.c. If not, you need to add the corresponding device info
to the list manually. E.g. the info structure for ST NAND256R3A:
struct nand_flash_dev nand_flash_ids[] = { …… {"NAND 32MiB 1,8V 8-bit",// the string identifies the device type 0x35, // the device ID code which you can find in its datasheet 512, // the page size of the device (B) 32, // the total chip size of the device (MB) 0x4000, // the erase block size of the device (B) 0}, // the bit-field to store chip relevant options …… }; struct nand_manufacturers nand_manuf_ids[] = { ……
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 22 of 28
Page 23
Philips Semiconductors
AN10476
Getting started Linux with LPC3180
{NAND_MFR_STMICRO, //the manufacture ID code of the device "ST Micro"}, //the string identifies the manufacture name …… };
The definitions of both data structures can be found in ./uboot/_nand.h. [Remark] The type nand_flash_dev is only a little different with the one defined in the
Linux MTD driver
./linux-2.6/include/linux/mtd/nand.h.
7.3.2 Device dependent functions porting
We should be clear that users may connect different kinds of NAND flash devices, but they use the same NAND flash controller – LPC3180 on-chip NAND flash controller. It’s the NAND flash controller that gives the sequential logic control on the NAND flash device. This feature greatly simplifies the porting process.
NAND flash related functions in
./lib_nand/lpc3180_nand_phytec.c:
No. Function Description
1
LPC3180_nand_write_byte
Write one byte to Data Register, then the data is independently transferred to the Nand Flash Device by the controller.
2
LPC3180_nand_read_byte
Read one byte from Data Register, the read of Data Register is translated to read cycles to the Nand Flash device by the controller.
3
LPC3180_nand_write_buf_8
Write len bytes data to Data Register, then the data are written to the Nand Flash Device sequentially.
4
LPC3180_nand_read_buf_8 Read len bytes from Data Register.
5
LPC3180_nand_verify_buf_8 Verify len bytes data.
6
LPC3180_nand_select_chip A NULL function.
7
LPC3180_device_ready Function for checking on device ready signal.
8
LPC3180_nand_command_lp
Resolve the command passed through the up-level interface, and perform the specific operations on the Nand Flash Device.
The top 1-7 functions are based on the NAND Flash Controller, we don’t need to modify the codes unless the hardware configuration is changed.
While the last one LPC3180_nand_command_lp is based on the NAND flash controller and the NAND flash device, we need to add specific device operations in the function. It is declared as:
int LPC3180_nand_command_lp(
struct mtd_info* mtd, //pointer to structure mtd_info unsigned command, //operation command int column, //column address int page_addr //page address
)
7.4 NAND flash support in Linux MTD driver
The NAND flash driver in Linux is mainly for the file system JFFS2. Actually we can get the Linux MTD driver file based on u-boot ./lib_nand/lpc3180_nand_phytec.c. The
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 23 of 28
Page 24
Philips Semiconductors
AN10476
Getting started Linux with LPC3180
source file ./linux-2.6.10/drivers/mtd/nand/lpc3180_nand_phytec.c is quite similar with that.
User can know their minor difference by comparing the current two files. E.g. Add MTD partitions definitions in Linux driver
const static struct mtd_partition partition_info[] = { #define NUM_PARTITIONS 1 { .name = "LPC3180 NAND PART 0", .offset = 0x01000000, .size = 15*1024*1024 } };
8. SDRAM porting
In the Phytec reference board, a Micron MT48H8M16LF 32Mbyte SDRAM is mounted. Users may use different SDRAM with it. This section gives a guide on how to make the necessary modification for new type SDRAM in SIBL and U-boot.
8.1 SDRAM initialization in SIBL
In the Linux staged boot process, SIBL does the SDRAM initialization before loading images from NAND flash to SDRAM.
In the file
./sibl/sibl_startup.s, SDRAM size and working frequency are defined:
; -----------------------------------------------------------­; Sdram init ;
TMBT_SDRAM_SZ EQU 256 ; Mbit
IMPORT tmbtSdramInit
MOV r0, #(((TMBT_AHB_FREQ/13)-1)*4) MOV r1, #(((TMBT_SDRAM_SZ/128)-1)*4) BL tmbtSdramInit ; ------------------------------------------------------------
The overall implementation of SDRAM initialization is in ./sibl/lpc3180_sdram.s, including the functions of SDRAM controller control, mode control, memory control, bus control, etc. All of the listed registers should be initialized properly according the specific SDRAM device user manual:
MPMCControl MPMCConfig MPMCAHBControl0 MPMCAHBControl2 MPMCAHBControl3 MPMCAHBControl4 MPMCDynamicConfig0 MPMCDynamicRasCas0 MPMCDynamicReadConfig MPMCDynamictRP MPMCDynamictRAS MPMCDynamictSREX MPMCDynamictWR MPMCDynamictRC MPMCDynamictRFC MPMCDynamictXSR MPMCDynamictRRD MPMCDynamictMRD MPMCDynamicCDLR MPMCDynamicControl MPMCDynamicControl MPMCDynamicRefresh
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 24 of 28
Page 25
Philips Semiconductors
AN10476
Getting started Linux with LPC3180
MPMCDynamicRefresh MPMCDynamicRasCas0 MPMCDynamicConfig0 MPMCDynamicControl MPMCAHBTimeOut0 MPMCAHBTimeOut2
MPMCAHBTimeOut3
MPMCAHBTimeOut4
MPMCStatus;
8.2 SDRAM definitions in U-boot
Before U-boot running, SIBL must have finished the SDRAM initialization. In U-boot, there are no necessary SDRAM operations but only some parameter settings need to be defined.
In
./u-boot/include/configs/phytec.h, define the SDRAM start address and effective
size:
/*----------------------------------------------------------------------­ * Physical Memory Map */ #define CONFIG_NR_DRAM_BANKS 1 #define PHYS_SDRAM_1 0x80000000 #define PHYS_SDRAM_1_SIZE 0x02000000 /* 32 MB */
In
./u-boot/board/phytec/config.mk, define the TEXT section start address of u-boot
image file:
# # image should be loaded at 32M - 256k # TEXT_BASE = 0x81EC0000
In
./u-boot/board/phytec/u-boot.lds, align the TEXT section start address with that
defined in
config.mk:
ENTRY(_start) SECTIONS { . = 0x81EC0000; . = ALIGN(4);
In ./u-boot/board/phytec/phytec.c, there are SDRAM detection and initialization routines
sdram_init and dram_init. Actually the sdram_init wouldn’t be called at all. Have
a look at the
dram_init may help you understand more about the U-boot process for
SDRAM. But neither need modification.
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 25 of 28
Page 26
Philips Semiconductors
AN10476
Getting started Linux with LPC3180
Appendix -- Default flash layout
miniboot
0x0000.0000
sibl
Sibl size approx 0xd44 (3.396)
Rootfs.ubt
Miniboot 52 bytes. Program 0x200 because of ECC!
0x0000.0200
0x0049.0000
uImage.ubt
uboot.ubt
0x0000.8000
0x0066.0000
15 MB
partition for
JFFS2 filesytem
0x0100.0000
0x00EF.FFFF
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 26 of 28
Page 27
Philips Semiconductors
AN10476
Getting started Linux with LPC3180
9. Disclaimers
Life support — These products are not designed for use in life support
appliances, devices, or systems where malfunction of these products can reasonably be expected to result in personal injury. Philips Semiconductors customers using or selling these products for use in such applications do so at their own risk and agree to fully indemnify Philips Semiconductors for any damages resulting from such application.
Right to make changes — Philips Semiconductors reserves the right to make changes in the products - including circuits, standard cells, and/or software - described or contained herein in order to improve design and/or performance. When the product is in full production (status ‘Production’), relevant changes will be communicated via a Customer Product/Process Change Notification (CPCN). Philips Semiconductors assumes no responsibility or liability for the use of any of these products, conveys no licence or title under any patent, copyright, or mask work right to these products, and makes no representations or warranties that these products are free from patent, copyright, or mask work right infringement, unless otherwise specified.
Application information — Applications that are described herein for any of these products are for illustrative purposes only. Philips Semiconductors make no representation or warranty that such applications will be suitable for the specified use without further testing or modification.
10. Licenses
Purchase of Philips I2C components
Purchase of Philips I2C components conveys a license
under the Philips’ I
2
C patent to use the components in the
I
2
C system provided the system conforms to the I2C specification defined by Philips. This specification can be ordered using the code 9398 393 40011.
Purchase of Philips RC5 components
Purchase of Philips RC5 components conveys a license under the Philips RC5 patent to use the components in RC5 system products conforming to the RC5 standard UATM-5000 for allocation of remote control commands defined by Philips.
11. Patents
Notice is herewith given that the subject device uses one or more of the following patents and that each of these patents may have corresponding patents in other jurisdictions.
<Patent ID> — <patent owner>
12. Trademarks
<trademark name> — is a trademark of <owner> <registered trademark name> — is a registered trademark of <owner>
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 27 of 28
Page 28
Philips Semiconductors
AN10476
Getting started Linux with LPC3180
13. Contents
1. Introduction .........................................................3
1.1 Concept ..............................................................3
1.2 The boot process................................................3
2. Setup environment..............................................3
2.1 Hardware ............................................................3
2.2 Software under Windows....................................4
2.3 Software under Linux..........................................4
3. Building images...................................................4
3.1 Building SIBL ......................................................5
3.2 Building U-boot...................................................5
3.3 Building kernel ....................................................5
3.4 Building root file system......................................6
4. Running from SDRAM.........................................7
4.1 Start Linux kernel and Root file system...............7
4.2 Using MMC/SD card devices............................11
4.3 Connecting USB ...............................................12
4.4 Connecting to the Ethernet ...............................12
4.4.1 Connection between PC and the board ............13
4.4.2 Connection using DHCP...................................14
4.5 Mounting file systems .......................................14
4.5.1 Mounting an external file system using NFS.....14
4.5.2 JFFS2 support ..................................................15
5. Flashing images ................................................15
5.1 Flashing new images ........................................15
5.2 Flashing SIBL....................................................16
5.2.1 Using LPC3180 Loader.....................................16
5.2.2 Using Seehau software.....................................18
5.3 Starting from NAND flash..................................19
6. Adding user applications..................................20
7. NAND flash porting...........................................20
7.1 Content list........................................................20
7.2 NAND flash support in SIBL ..............................21
7.2.1 Loading image algorithm...................................21
7.3 NAND flash support in U-Boot ..........................22
7.3.1 Device ID list.....................................................22
7.3.2 Device dependent functions porting..................23
7.4 NAND flash support in Linux MTD driver ..........23
8. SDRAM porting..................................................24
8.1 SDRAM initialization in SIBL.............................24
8.2 SDRAM definitions in U-boot ............................25
Appendix -- Default flash layout....................................26
9. Disclaimers........................................................27
10. Licenses.............................................................27
11. Patents ...............................................................27
12. Trademarks........................................................27
13. Contents.............................................................28
<12NC> © Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Application note Rev.03 — 21 Dec 2006 28 of 28
Loading...