You are on page 1of 43

Introduction to Embedded

System
using Zoom ColdFire
M5474LiteKit Development
Board

Embedded System Workshop


LIPI, November 2009
By: Gunawan, ST.
Computer Evolution

Source: Evolution Of Computer and Computing, Ruth M. Davis (Evoutionof Computers.pdf)


Embedded Microcomputer System
Architecture

Embedded means: specific function of hardware placed on a single


microcomputer chip (SoC)
Source: http://www.engr.colostate.edu/.../MicroC_overview.pdf
Usef ull inf o: STES-Lecture 1. What is Embedded System.ppt
Embedded Operating System

Operating System on Embedded Microcomputer were needed to perform


multitasking and scheduling process on a complex function system.

Usef ull inf o: EmbeddedLinuxTalkUniForum.ppt


Embedded Linux
• Open Source
• POSIX: Portable Operating System Interface for
UNIX
• GPL: GNU Public License (free licensed)
• GNU Linux: Gnu Not Unix
• Realtime OS Availability

• Limitation Scope
– 32Bit Processor
– Processor with MMU (Memory Management Unit)
– Few Mbyte Code Size
Usef ull inf o: EmbeddedLinuxTalkUniForum.ppt
Embedded Linux Basic
BootLoader
• BOOTLOADERS Target Board
– Used to initialize the hardware Bootloader
– Provides mechanism for initial interaction
Kernel
with board
– Provides mechanism to boot kernel File system
– Configured and built for specific board
• Common bootloader
– ColdFire: Colilo, u-boot, dBUG
– Power Architecture™: u-boot
– ARM: blob, redboot, u-boot
– I386: GRUB, LILO

Source: linux_presentation1.pdf
Embedded Linux Basic
Kernel
• KERNEL Target Board
– Continued initialization of the board Bootloader
– Provides mechanism to interact Kernel
with devices (drivers)
File system
– Provides underlying protocol
support
– (TCP/IP) and OS
– The Linux kernel configuration
allows many features to be
selected and configured
Embedded Linux Basic
Kernel Modules
• KERNEL MODULES Target Board
Bootloader
– Implement device drivers Kernel
– Provide additional File system
functionality to kernel Kernel Modules

– Reside in the file system


and can be loaded and
unloaded from the kernel
Embedded Linux Basic
File Systems
• FILE SYSTEM Target Board
– Protected by Memory Bootloader
Management Unit (MMU) (user
land) Kernel

– Applications live here File system


– Common Embedded File
SystemTypes
• EXT2/3
• Journaling Flash File System
version 2 (JFFS2)
• CRAMFS
• YAFFS
Conceptual Architecture of Linux
Kernel

Source: Design and Implementation of Embedded Linux System.pdf


Linux Kernel System Structure
Conceptual Decomposition Concrete Decomposition

Source: Lab1_linux_arch_and_commands.ppt
Building Embedded Linux
• Toolchain and library
– Cross Compiler Gcc, Glibc, uClibc, Binutils
• Linux Kernel Source Code
• File system and basic application
– BusyBox: combined several native linux command

• Preconfigured Buildtools:
– Buildroot
– SnapGear
– LTIB: Linux the image builder
– Comercial licensed: IAR, Green Hils, etc.
Linux Kernel Source Code Tree
Linux File System Structure

Source: 3.1. General overview of the Linux f ile system.html


Usef ull inf o: Source: Lab1_linux_arch_and_commands.ppt
Compiling Linux on Zoom Coldfire
M5474Litekit Development Board
Common Features
•Fire Engine Included (MCF5474Lite, 64MB DDR, 4MB Boot
Flash)
•PC Card Expansion One PCI 2.2 slot (32 Bit, 33 or 66MHz, 3.3V)
•Serial Ports One 115.2kbps RS-232 serial ports; Two TTL serial
ports
•Can 2.0b One port (MCF5485 only)
•USB USB 2.0 One High speed device (on Fire Engine)
•SPI
•RTC
•Network Support One RJ45 Ethernet jack connectors
(application/debug)
•BDM Interface
•Software
• LogicLoader™ (bootloader/monitor)
• Freescale dBUG ROM Monitor
• Third party development tools and software wrapped
in individual CDs
• Cygwin and GNU Cross Development Toolchain
•Mechanical Mini-ITX
• 6.7” (170mm) long x 6.7” (170mm) wide x 1.3” (33mm) high
M5474Litekit Limitation
Curently not directly supported model,
linux source code currently only
support for:
M5475EVB, M5484Lite & M5485EVB
model
Fire Engine CPLD
The CPLD device, on Fire Engine SOMs
shipped as part of a development kit,
is in an un-programmed state. A
programmed CPLD is not required for
microprocessor, memory, or on-chip
peripheral functionality.
The CPLD program that Logic has
developed gives the system additional CPLD shipped un programmed
functionality (such as a Memory-Mode State, no second f lash f or application
CompactFlash interface). Please read image, no access to compact f lash
the CPLD license agreement below for
more information on gaining access to
CPLD programming files.
http://support.logicpd.com/products/devkit/freescale/coldf
ire_litekit
M5474Litekit Source Finding
Hint:
Available model supported by u-boot are:
M5475AFE: - boot 2MB, RAM 64MB
M5475BFE: - boot 2MB, code 16MB, RAM 64MB
M5475CFE: - boot 2MB, code 16MB, Video, USB, RAM 64MB
M5475DFE: - boot 2MB, USB, RAM 64MB
M5475EFE: - boot 2MB, Video, USB, RAM 64MB
M5475FFE: - boot 2MB, code 32MB, Video, USB, RAM 128MB
M5475GFE: - boot 2MB, RAM 64MB
Kernel
Only support AFE model to FFE Model
Current relese kernel only support for mcf5484 which differ from mcf5474 who doesn‟t have security engine (SEC)
driver.

From HW. Spec Says 4MB Boot Flash, but the upper 2MB access had been blocked by hardware

Conclusion:
Current flash size will only hold the bootloader code, the linux system may only run via a server,
a tftp server needed to deploy the kernel image and a nfs server to deploy the file server
Some changes to be made in the linux the image builder (LTIB) due to unsupported model.

Future work:
Asking for firmware CPLD code to vendor, to enable the compact flash access to get the system had ability to run
linux in standalone mode.
LTIB – Linux The Image Builder
Software Prerequisite
Requerment to build:
• Source Code m547x_8x_evb_20080811-final-ltib.iso, Available to download
at:
http://www.freescale.com/webapp/sps/download/license.jsp?colCode=CWF -MCF547X-548X-2-6-
KL&location=null&fpsp=1&WT_TYPE=Board%20Support%20Packages&WT_VENDOR=FREESCALE&WT
_FILE_FORMAT=iso&WT_ASSET=Downloads&Parent_nodeId=1100875301996736292646&Parent_pageT
ype=product

• A Host PC running linux, in the practice using opensuse11 with installed


packages: Kernel development, Console tools and File Server. Note: turn
off Firewall to make server function work properly.

• Another Host PC running in windows xp with Serial Communication to run


terminal like Terra Term and a LPT port connection to run CF Flasher to be
able to flash the board using BDM interface.
– CF Flasher
http://www.freescale.com/files/soft_dev_tools/software/programmers/CFFLASHER.zip?fps
p=1&WT_TYPE=Programmers%20(Flash,%20etc.)&WT_VENDOR=FREESCALE&WT
_FILE_FORMAT=zip&WT_ASSET=Downloads
– P&E driver available for download at:
https://www.pemicro.com/login.cfm?from_url=/downloads/download_file.cfm?do
wnload_id=53
LTIB – Linux The Image Builder
Hardware Prerequisite

LPT
LAN with Cable PC
PC Cross Cable Windows
Running Xp
Linux Serial Cable
Cross F-F

LAN BDM Serial


port Jtag Port
Port
Target Board PSU
M5474LiteKit 5V
Installing LTIB
• The user manual to deploy the LTIB, available from BSP Targeting
the Freescale_M547X_8X.pdf included inside the
m547x_8x_evb_20080811-final-ltib.iso
• Note: The AN2950 from freescale web site pointed to earlier linux
BSP (savannah_ltib-20070321.tar.gz) in this case it cannot be use.

• Mounting The m547x_8x_evb_20080811-final-ltib.iso


– Mkdir <mount_dir>
– Mount –o loop m547x_8x_evb_20080811-final-ltib.iso < mount_dir >
– Cd < mount_dir >
• Installing LTIB
– ./insatall.sh <install_dir>
• This will extract ltib packages to directory <install_dir>/ltib-
m5475evb-20080808. Make a backup of original source
– Tar czvf ltib-m5475evb-20080808.tgz ltib-m5475evb-20080808/
Installing LTIB
• Default configured package are targeted for
M5475EVB.
• Later on we will need to change the source code
to meet M5474Lite.

• First install install the Toolchain and rebuild all


package, make sure your not running as root.
> Cd ltib-m5475evb-20080808
>./ltib
Installing LTIB

Since we running as non root, it will output an error, but we must not run as
root to prevent any damage to system
Installing LTIB
• Change user to root
> Su
> Password: <type in
Password>
> Visudo
• Add the above needed
lines into user privilaged
section
Note: Change user name
„huntu2‟ to your local
username

To finish type in
“:wq”
Installing LTIB
• Now Change back to normal user from root by type in
> Exit
• Run the ltib again
> ./ltib
• To Follow the process, open in a new shell type in:
> cd <install_dir>/ ltib-m5475evb-20080808
> tail host_config.log –f
• Upon Succesfull build thoolchain are located at “/opt”, while other
remains at install dir. You may use it for creating your applications.

/<root> /<install_dir>/ltib-m5475evb-20080808/

/opt

freescale/usr/local/gcc-4.2.125-eglibc-2.5.125/m68k-linux

bin M68k_linux-* <Cross Compiler>


lib
LTIB Directory Structure
/<install_dir>/ltib-m5475evb-20080808/ Ltib, rootfs.jffs2
Flash File system image
bin/
config/ platform/ mcf4e/ Main.lkc Main Configuration
Need to be changed
dist/

doc/
Uboot and kernel
rootfs/ boot u-boot.bin, uImage
image
release_log/ Directory that hold source
rpm/ BUILD/ code if modified
RPMS m68k *.rpm Rpm sources
tmp/
packages
Configuring the u-boot
• Current Board default for
M5475EVB
– Differ from M5474Lite
which don‟t have second
code flash

• Available u-boot
config don‟t have
M5474lite option
Configuring the u-boot
• From the u-boot Readme
files of the source it self,
there are M5475AFE to
M5475GFE model
supported by u-boot

• Change the main.lkc at


config/platform/mcf4e
directory
> vi
config/platform/mcf4e/main.l
kc

Reference:1000331_Rev_B.pdf (ColdFire
Lite Development Kit QuickStart Guide)
Configuring the u-boot
• Press “i” to insert new character
• Add These lines below last option
conf ig PKG_U_BOOT_M5475AFE
bool "UBoot M5475AFE boot2MB,RAM64MB"
conf ig PKG_U_BOOT_M5475BFE
bool "UBoot M5475BFE boot2MB,code16MB,RAM 64MB“
conf ig PKG_U_BOOT_M5475CFE
bool "UBoot M5475CFE
boot2MB,code16MB,Video,USB,RAM64MB"
conf ig PKG_U_BOOT_M5475DFE
bool "UBoot M5475DFE boot2MB,USB,RAM64MB"
conf ig PKG_U_BOOT_M5475EFE
bool "UBoot M5475EFE boot2MB,Video,USB,RAM64MB"
conf ig PKG_U_BOOT_M5475FFE
bool "UBoot M5475FFE
boot2MB,code32MB,Video,USB,RAM128MB"
conf ig PKG_U_BOOT_M5475GFE
bool "UBoot M5475GFE boot2MB,RAM64MB”

• Add Another lines to make boolean


had mean to u-boot config
def ault "M5475AFE_conf ig" if PKG_U_BOOT_M5475AFE
def ault "M5475BFE_conf ig" if PKG_U_BOOT_M5475BFE
def ault "M5475CFE_conf ig" if PKG_U_BOOT_M5475CFE
def ault "M5475DFE_conf ig" if PKG_U_BOOT_M5475DFE
def ault "M5475EFE_conf ig" if PKG_U_BOOT_M5475EFE
def ault "M5475FFE_conf ig" if PKG_U_BOOT_M5475FFE
def ault "M5475GFE_conf ig" if PKG_U_BOOT_M5475GFE

• Press “esc” to exit insert mode, then


type in “:wq” to save and quit
Configuring the u-boot
• Recall the “./ltib –configure” we had:

• Choose the AFE (closest ones) model, exit and save, LTIB will
Compile and producing all images
Deploying u-boot
• The simplest way is to use the
CFlasher from windows xp
• You may also use dBug console
to flash the u-boot image
U-boot Result
• Upon sussesfull u-boot
load tou may check the
board info using “bdinfo”
and check the
environment using
“printenv” or in short “pri”
Configuring Kernel
• Recall “./ltib –
configure”
• Check on “configure
kernel” and “leave
kernel source”
• Exit and save
• LTIB will copy linux
source to
“rpm/BUILD/linux”
Configuring Kernel
• On The Kernel
configuration, click
paltform dependent
setup

• Click on
MCF547x/548x
support
Configuring Kernel
• The processor model
available are listed in the
menu, choose the same
as the u-boot model, that
will be MCF5474AFE
• Click select then exit and
save
• The LTIB will then
compile the kernel and
produced all images
• This kernel cannot be use,
since it still involve SEC
driver as previous finding,
if deployed to the board,
the kernel will halt at
loading M5484_device
Configuring Kernel
• The kernel source code placed in
the “rpm/BUILD/linux” directory
since we checked the “leave kernel
source” option.
• The processor spesific option are
placed at the “arch/” directory, as
explained before.
• Go to the
> cd rpm/BUILD/linux-
2.6.25/arch/m68k/coldfire/
> vi mcf548x-devices.c
• Press „I‟ to insert „//‟ in front of
“platform_device_register(&coldfire
_sec_device);” lines
• Press “:wq” to write and exit
Final LTIB Compilation Image
• Recall “./ltib” to compile all over again, this
time no need to configure because are
config are already in the correct place
• The ltib will produce all usabele images:
– u-boot.bin -> binary bootloader
– uImage -> binary kernel image
– rootfs/ -> root folder for nfs deployment
– rootfs.jffs2 -> root file system image for deploy
in flash
Host PC: Setting TFTP Server
• Re login as root by type in
> su
> password: <type in our
password>
• Call YAST to configure server
> yast
• Choose Network server->tftp
server->enable
• Click ok and finish.
> exit
• Copy uImage to /tftpboot
> cp rootfs/boot/uImage
/tftpboot/.
• Your kernel image is ready at
tftp server
Host PC: Setting NFS Server
• Copy the “rootfs/”
directory to “/tftpboot”
> cp –vrf rootfs/ /tftpboot/.
• Call “yast” to configure
server
• Choose “network service”
-> “NFS Server”
• Checklist “start”, disable
“NFSv4”, then press
“next”
Host PC: Setting NFS Server
• Choose “add” then browse to
“/tftpboot/rootfs”
• On the host wildcard, type in:
“rw,no_root_squash,async,no_
subtree_check”
• Click finish and exit
• Your NFS server are ready
u-boot Script
• TO make the u-boot to be able to
boot linux you must edit u-boot
environment.
• Set the ip address and server
> set ipaddr <board_ip>
> set serverip <server_ip>
• Set the boot argument to pass as
kernel command line that will be
executed by kernel
> set bootargs root=/dev/nfs rw
nfsroot=192.168.0.20:/tftpboot/rootfs
ip=192.168.0.30:192.168.0.20:192.168
.0.30:255.255.255.0::eth0:off
mtdparts=physmap-
flash.0:4M(uboot)ro
• Set the bootcmd that will executed
automaticly each u-boot resart
> set bootcmd „tftp 2000000 uImage;
bootm 2000000‟
• Save the environment to flash
> save
Linux First Run
• Reset the board, it will
execute script in the
u-boot environment
setting.
• First it will load kernel
(uImage) via tftp
server then loading
file system via nfs
server.
Linux First Run
• Congratulation you have
succeeded running linux
on your embedded board,
• You may use installed
application, adding new
application by
reconfiguring ltib (kernel,
package and busybox)
and or creating your own
application, just like
programming in native
linux running on PC.
Thank You

You might also like