You are on page 1of 38

http://www.farsight.com.

cn

Linux

Linux

Linux

Linux minicom Windows


Linux Windows TFTP
NFS
Linux
Linux
Linux
Bootloader
U-Boot

< Linux >

5.1

http://www.farsight.com.cn

5.1.1

BUG

ftp://gcc.gnu.org/pub/

binutilsgccglibc binutils objdump


asld gcc arm-linux-gcc
Linux

glibc

2.95.3 3.3.2
Linux2.4 Linux2.6

cross-3.3.2

2
2
/usr/local/arm cross-3.3.2.bar.bz2
[root@localhost arm]# tar jxvf cross-3.3.2.bar.bz2
[root@localhost arm]# ls
3.3.2 cross-3.3.2.tar.bz2
[root@localhost arm]# cd ./3.3.2
[root@localhost arm]# ls
arm-linux bin etc include info lib libexec man sbin share VERSIONS
[root@localhost bin]# which arm-linux*
/usr/local/arm/3.3.2/bin/arm-linux-addr2line
/usr/local/arm/3.3.2/bin/arm-linux-ar
/usr/local/arm/3.3.2/bin/arm-linux-as

< Linux >

Linux 5 Linux
/usr/local/arm/3.3.2/bin/arm-linux-c++
/usr/local/arm/3.3.2/bin/arm-linux-c++filt
/usr/local/arm/3.3.2/bin/arm-linux-cpp
/usr/local/arm/3.3.2/bin/arm-linux-g++
/usr/local/arm/3.3.2/bin/arm-linux-gcc
/usr/local/arm/3.3.2/bin/arm-linux-gcc-3.3.2
/usr/local/arm/3.3.2/bin/arm-linux-gccbug
/usr/local/arm/3.3.2/bin/arm-linux-gcov
/usr/local/arm/3.3.2/bin/arm-linux-ld
/usr/local/arm/3.3.2/bin/arm-linux-nm
/usr/local/arm/3.3.2/bin/arm-linux-objcopy
/usr/local/arm/3.3.2/bin/arm-linux-objdump
/usr/local/arm/3.3.2/bin/arm-linux-ranlib
/usr/local/arm/3.3.2/bin/arm-linux-readelf
/usr/local/arm/3.3.2/bin/arm-linux-size
/usr/local/arm/3.3.2/bin/arm-linux-strings
/usr/local/arm/3.3.2/bin/arm-linux-strip

/usr/local/arm/3.3.2/bin/ arm
VERSION
Versions
gcc-3.3.2
glibc-2.3.2
binutils-head
Tool chain binutils configuration:
../binutils-head/configure
../glibc-2.3.2/configure
Tool chain gcc configuration
../gcc-3.3.2/configure

binutilsgccglibc
Version

5.1.2

Minicom

Windows Linux

< Linux >

http://www.farsight.com.cn

Windows
Linux Minicom

1
Windows

5.1
COM1
1 5.2

FS2410
115200 8 1
5.3

PC
5.4

5.1

< Linux >

Linux 5 Linux

5.2

5.3

1 2UART1

UATR2

2Minicom
Minicom Linux

Minicom

5.4
< Linux >

http://www.farsight.com.cn

minicom
minicom Minicom
5.5

5.5 minicom

Minicom CTRL-A Z
CTRL
A

5.5 CTRL+A Z minicom 5.6

O
Configure Minicom minicom
CTRL-A O 5.7

< Linux >

Linux 5 Linux

5.6 minicom

5.7 minicom

< Linux >

http://www.farsight.com.cn

Serial port setup 5.8


minicom

5.9 Change which setting A

minicom ttyS0COM1

ttyS1COM2

5.8 minicom

< Linux >

Linux 5 Linux

5.9 minicom

E
5.10

5.11
5.8

< Linux >

5.10

5.11

http://www.farsight.com.cn

minicom

minicom

< Linux >

Linux 5 Linux

5.12

minicom

minicom
5.13

5.12

minicom

< Linux >

5.13

http://www.farsight.com.cn

minicom

5.1.3

SDRAM SDRAM Flash


tftpftp
USB
tftp
1tftp
Tftp FTP FTP

FTP tftp tftp


< Linux >

Linux 5 Linux

tftp
tftp

tftp
Linux Windows
1Linux tftp
Linux tftp xinetd
tftp tftp
[root@sunq tftpboot]# vi /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
#

protocol. The tftp protocol is often used to boot diskless \

workstations, download configuration files to network-aware printers, \

and to start the installation process for some operating systems.

service tftp
{
socket_type

= dgram

protocol

= udp

wait

= yes

user

= root

server

= /usr/sbin/in.tftpd

server_args

= -s /tftpboot

disable

= no

per_source

= 11

cps

= 100 2

flags

= IPv4

disable=yesnoserver_argstftp
/tftpboot

xinetd
[root@sunq tftpboot]# service xinetd restart
xinetd

[ ]

xinetd

[ ]

netstat -au tftp


[root@sunq tftpboot]# netstat -au
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address

Foreign Address

< Linux >

State

http://www.farsight.com.cn

udp

0 *:32768

*:*

udp

0 *:831

*:*

udp

0 *:tftp

*:*

udp

0 *:sunrpc

*:*

udp

0 *:ipp

*:*

/tftpboot tftp

tftp

=>tftpboot 0x30200000 zImage


TFTP from server 192.168.1.1; our IP address is 192.168.1.100
Filename 'zImage'.
Load address: 0x30200000
Loading: #################################################################
###############################################################
#############################################
done
Bytes transferred = 881988 (d7544 hex)

IP 192.168.1.100
IP 192.168.1.1

0x30200000zImage

2Windows tftp
Windows tftp tftp tftpd32
tftpd32 5.14
tftp
tftpd32
tftp tftp
5.15 5.16

< Linux >

Linux 5 Linux

5.14 tftpd32

5.15 tftp

5.16 tftp
tftp
tftp 2003

8 12 Worm.Blaster tftp
tftp
tftp /tftpboot

2
DNW
< Linux >

http://www.farsight.com.cn

Windows
IP DNW

DNW
ConfigurationOptions 5.17

5.17

DNW

Serial PortConnect

Serial PortTransmit
5.18
5.19 DNW 0x30200000

5.18

DNW

< Linux >

Linux 5 Linux

5.19

5.1.4

DNW

Linux

Linux
Linux Linux
Linux
Linux make
3 MakefileLinux Makefile
Makefile

3
1

ARM Multimedia capabilities port


drivers Makefile ARCH

ARCH

:= arm

4
< Linux >

http://www.farsight.com.cn

.config

4
make config
make menuconfig
make xconfigXwindow
make oldconfig.config

4 make menuconfig make menuconfig


5.20
Linux 18
18 help
menuconfig Tab
5.21 System Type

Y
N
3
*

*
M

< Linux >

Linux 5 Linux

5.20

make menuconfig

5.21

System Type

< Linux >

http://www.farsight.com.cn

2.6 2.4 2.4 COM1


ttyS0
2.6 COM1ttySAC0

5.22

5.23

5.22

< Linux >

Linux 5 Linux

5.23

Makefile
.dependmake dep

3
make zImagemake bzImage

Linux
zImagearch/$ARCH/boot
vmlinux

Linux
.config

autoconf.h

config.h

.config make menuconfig


autoconf.h

config.h make menuconfig


autoconf.hconfig.h
/include/linux/

< Linux >

5.1.5

http://www.farsight.com.cn

Linux

Linux 5.24
/include

/init

/arch
armi386alpha
/drivers
SCSI
/fs ext2
vfat
/net
/mm
/ipc
/kernel

5.1.6

5.24

Linux

5.25

5.25
< Linux >

Linux 5 Linux

2 Linux
Linux Linux
head.S
Linux
Linux

NFS

1
Linux Linux
Linux

cramfsromfsjffsyaffs cramfs
cramfs

cramfs mkcramfs mkcramfs


cramfs /root/workplace/
fs/guo
[root@localhost guo]# ls
bin dev etc home lib linuxrc proc Qtopia ramdisk sbin tmp usr var
mkcramfs mkcramfs dir name
[root@localhost fs]# ./mkcramfs guo FS2410XP_camare_demo4.cramfs
-21.05% (-64 bytes)

Tongatapu

-21.03% (-49 bytes)

Truk

-21.03% (-49 bytes)

Wake

-22.41% (-52 bytes)

Wallis

-21.95% (-54 bytes)

Yap

-17.19% (-147 bytes)

WET

-47.88% (-8158 bytes)

zone.tab

-55.24% (-17421 bytes)

usb-storage.o

-54.18% (-16376 bytes)

usbvideo.o

-54.07% (-2736 bytes)

videodev.o

Everything: 27628 kilobytes


Super block: 76 bytes
CRC: e3a6d7ca

< Linux >

http://www.farsight.com.cn

mkcramfs
mount
[root@localhost fs]# mkdir sunq
[root@localhost fs]# mount -o loop FS2410XP_camare_demo4.cramfs ./sunq
[root@localhost fs]# ls sunq
bin dev etc home lib linuxrc proc Qtopia ramdisk sbin tmp usr var

2NFS
NFS Network FileSystem Sun
NFS
NFS NFS
NFS

NFS
mount NFS

NFS /etc/exports

[] [ IP] [ 1 2]

IP IP IP
*
5.1
5.1

rw

ro

no_root_squash

NFS root
root

sync

async

/etc/exports
< Linux >

Linux 5 Linux
[root@localhost fs]# cat /etc/exports
/root/workplace

*(rw,no_root_squash)

nfs portmap portmap


NFS NFS 111 sun
RPC NFS

[root@localhost fs]# service portmap start


portmap:

[]

[root@localhost fs]# service nfs start


NFS :

[]

NFS :

[]

NFS :

[]

NFS mountd:

[]

NFS mountd NFS


NFSD
cat/var/log/messages NFS
NFS
exportfs/etc/exports
/etc/exports
NFS
exportfs []
exportfs 5.2
5.2

-a

/etc/exports

-r

/etc/exports

-u

-v

export

showmount
showmount [] hostname

showmount 5.3
5.3

-a

-e

hostname /etc/exports
< Linux >

5.2

http://www.farsight.com.cn

U-Boot
5.2.1

Bootloader

1
Bootloader PC
BIOS

Bootloader
Bootloader Bootloader
Bootloader
1Bootloader CPU
CPU Bootloader Bootloader
CPU U-Boot ARM MIPS
CPU Bootloader
2Bootloader
CPU CPU
CPU ROMEEPROM
FLASH CPU Bootloader

3Bootloader Bootloader

4Bootloader Bootloader

Bootloader
RAM

Bootloader
Host
Bootloader RAM Bootloader
FLASH Bootloader
Bootloader
5Bootloader
Bootloader xmodem/
ymodem/zmodem
TFTP

< Linux >

Linux 5 Linux

2Bootloader
Bootloader stage1 stage2

1Bootloader stage1
stage1 Bootloader
CPU RAM
LED CPU cache
stage2 RAM stage2
RAM
Bootloader stage2 RAM
stage2 RAM stage2
RAM
sp stage2 C
2Bootloader stage2
stage2 Bootloader
main
stage2 C
C Bootloader
glibc

4GB
RAM
Flash

5.2.2

U-Boot

1U-Boot
U-BootUniversalBootloader
GPL FADSROM
8xxROMPPCBOOT Linux
U-Boot Linux
U-Boot U-Boot Linux
NetBSDVxWorksQNXRTEMSARTOSLynxOS
OpenBSDNetBSDFreeBSD4.4BSDLinuxSVR4Esix
SolarisIrixSCODellNCRVxWorks,LynxOSpSOSQNXRTEMSARTOS
U-Boot Universal U-Boot PowerPC
MIPSx86ARMNIOSXScale
< Linux >

http://www.farsight.com.cn

U-Boot
U-Boot PowerPC Linux
2U-Boot
U-Boot

LinuxNetBSDVxWorksQNXRTEMSARTOS
LynxOS
PowerPCARMx86MIPSXScale

U-Boot
SDRAMFLASHLCDNVRAMEEPROM
RTC

3U-Boot
U-Boot
NFS RAMDISK
NFS FLASH

Linux
FLASHNVRAMEEPROMCRC32 FLASH
RAMDISK
SDRAMFLASHLCDNVRAMEEPROM
USBPCMCIAPCIRTC
SDRAMFLASH SDRAM CPU
XIP

5.2.3

U-Boot

1U-Boot
U-Boot 5.26
board Makefile
U-Boot.lds
common C

< Linux >

5.26

U-Boot

Linux 5 Linux

cpuCPU U-BOOT CPU


arm926ejsmipsmpc8260 nios cpu.c interrupt.c
start.S cpu.c CPU Cache Cache interrupt.c

start.S U-BOOT C

diskdisk
doc
drivers CFI Flash USB
fsU-BOOT cramfsfatfdosjffs2 registerfs
include

netBOOTP TFTP RARP NFS

lib_arm ARM
tools S-Record U-BOOT images
2U-Boot
1cpu/arm920t/start.S
U-Boot
Flash
.globl_start
_start:

reset

ldr

pc, _undefined_instruction

ldr

pc, _software_interrupt

ldr

pc, _prefetch_abort

ldr

pc, _data_abort

ldr

pc, _not_used

ldr

pc, _irq

ldr

pc, _fiq

_undefined_instruction: .word undefined_instruction


_software_interrupt:

.word software_interrupt

_prefetch_abort:

.word prefetch_abort

_data_abort:

.word data_abort

_not_used:

.word not_used

_irq:

.word irq

_fiq:

.word fiq

< Linux >

http://www.farsight.com.cn

_TEXT_BASE:
.word

TEXT_BASE

.globl _armboot_start
_armboot_start:
.word _start

/*
* These are defined in the board-specific linker script.
*/
.globl _bss_start
_bss_start:
.word __bss_start

.globl _bss_end
_bss_end:
.word _end
reset:
/*
* set the cpu to SVC32 mode
*/
mrs

r0,cpsr

bic

r0,r0,#0x1f

orr

r0,r0,#0xd3

msr

cpsr,r0

relocate:

/* relocate U-Boot to RAM

adr

r0, _start

ldr

r1, _TEXT_BASE

cmp

r0, r1

beq

stack_setup

*/

/* r0 <- current position of code

*/

/* test if we run from flash or RAM */


/* don't reloc during debug

ldr

r2, _armboot_start

ldr

r3, _bss_start

sub

r2, r3, r2

/* r2 <- size of armboot

add

r2, r0, r2

/* r2 <- source end address

*/

*/
*/

copy_loop:
ldmia r0!, {r3-r10}

/* copy from source address [r0]

< Linux >

*/

Linux 5 Linux
stmia r1!, {r3-r10}
cmp

r0, r2

ble

copy_loop

/* copy to

target address [r1]

/* until source end addreee [r2]

/* Set up the stack

*/

*/

*/

stack_setup:
ldr

r0, _TEXT_BASE

/* upper 128 KiB: relocated uboot

*/

sub

r0, r0, #CFG_MALLOC_LEN /* malloc area

*/

sub

r0, r0, #CFG_GBL_DATA_SIZE /* bdinfo

*/

clear_bss:
ldr

r0, _bss_start

/* find start of bss segment

ldr

r1, _bss_end

/* stop here

mov

r2, #0x00000000

/* clear

clbss_l:str r2, [r0]

/* clear loop...

add

r0, r0, #4

cmp

r0, r1

bne

clbss_l

ldr

pc, _start_armboot

_start_armboot: .word start_armboot

2interrupts.c

#ifdef CONFIG_USE_IRQ
/* enable IRQ interrupts */
void enable_interrupts (void)
{
unsigned long temp;
__asm__ __volatile__("mrs %0, cpsr\n"
"bic %0, %0, #0x80\n"
"msr cpsr_c, %0"
: "=r" (temp)
:
: "memory");
}

< Linux >

*/
*/
*/

*/

http://www.farsight.com.cn

/*
* disable IRQ/FIQ interrupts
* returns true if interrupts had been enabled before we disabled them
*/
int disable_interrupts (void)
{
unsigned long old,temp;
__asm__ __volatile__("mrs %0, cpsr\n"
"orr %1, %0, #0xc0\n"
"msr cpsr_c, %1"
: "=r" (old), "=r" (temp)
:
: "memory");
return (old & 0x80) == 0;
}
#else
void enable_interrupts (void)
{
return;
}
int disable_interrupts (void)
{
return 0;
}
#endif
void show_regs (struct pt_regs *regs)
{
unsigned long flags;
const char *processor_modes[] = {
"USER_26", "FIQ_26",

"IRQ_26",

"SVC_26",

"UK4_26",

"UK5_26",

"UK6_26",

"UK7_26",

"UK8_26",

"UK9_26",

"UK10_26", "UK11_26",

"UK12_26", "UK13_26", "UK14_26", "UK15_26",


"USER_32", "FIQ_32",

"IRQ_32",

"SVC_32",

"UK4_32",

"UK5_32",

"UK6_32",

"ABT_32",

"UK8_32",

"UK9_32",

"UK10_32", "UND_32",

"UK12_32", "UK13_32", "UK14_32", "SYS_32",


};

< Linux >

Linux 5 Linux

}
void do_fiq (struct pt_regs *pt_regs)
{
printf ("fast interrupt request\n");
show_regs (pt_regs);
bad_mode ();
}

void do_irq (struct pt_regs *pt_regs)


{
printf ("interrupt request\n");
show_regs (pt_regs);
bad_mode ();
}

3cpu.c

int cpu_init (void)


{
/*
* setup up stacks if necessary
*/
#ifdef CONFIG_USE_IRQ
DECLARE_GLOBAL_DATA_PTR;

IRQ_STACK_START=_armboot_start - CFG_MALLOC_LEN - CFG_GBL_DATA_SIZE - 4;


FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ;
#endif
return 0;
}
int cleanup_before_linux (void)
{
/*
* this function is called just before we call linux
* it prepares the processor for linux
*
* we turn off caches etc ...
*/
< Linux >

http://www.farsight.com.cn

unsigned long i;

disable_interrupts ();

/* turn off I/D-cache */


asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i));
i &= ~(C1_DC | C1_IC);
asm ("mcr p15, 0, %0, c1, c0, 0": :"r" (i));

/* flush I/D-cache */
i = 0;
asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i));
return (0);
}

OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
. = 0x00000000;
. = ALIGN(4);
.text

{
cpu/arm920t/start.o

(.text)

*(.text)
}

. = ALIGN(4);
.rodata : { *(.rodata) }

. = ALIGN(4);
.data : { *(.data) }

. = ALIGN(4);
.got : { *(.got) }

__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
< Linux >

Linux 5 Linux
__u_boot_cmd_end = .;

. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
_end = .;
}

4memsetup.S

//memsetup.c
/* memory control configuration */
/* make r0 relative the current location so that it */
/* reads SMRDATA out of FLASH rather than memory ! */
ldr

r0, =SMRDATA

ldr r1, _TEXT_BASE


sub r0, r0, r1
ldr r1, =BWSCON /* Bus Width Status Controller */
add
r2, r0, #52
0:
ldr

r3, [r0], #4

str

r3, [r1], #4

cmp

r2, r0

bne

0b

/* everything is fine now */


mov pc, lr

.ltorg

5.2.4

U-Boot

1
Makefile Makefile
s3c2410_config: unconfig @./mkconfig (@:_config=) arm arm920t s3c2410

ARM CPU arm920t ARM CPU s3c2410

l board s3c2410 smdk2410 cp smdk2410/*


s3c2410

< Linux >

http://www.farsight.com.cn

include/configs/ smdk2410.hcp smdk2410.h s3c2410.h

ARM

#make s3c2410_config
#make
2
board/s3c2410 config.mk
U-Boot 6MB 33F80000 33A00000
U-Boot GO loadb tftp U-Boot board/
s3c2410 memsetup.S 0: 5
mov r3, pc
ldr r4, =0x3FFF0000
and r3, r3, r4 // 3
aad r0, r0, r3 // GO u-boot RAM
add r2, r2, r3 //

2 FLASH SDRAM
include/configs/s3c2410
#define CONFIG_DRIVER_DM9000 1 /* we have a CS8900 on-board */
#define DM9000_BASE 0x08000000
#define DM9000_BUS16 1 /* the Linux driver does accesses as shorts */
#define CONFIG_ETHADDR 08:00:3e:26:0a:5b
#define CONFIG_NETMASK 255.255.255.0
#define CONFIG_IPADDR 192.168.2.120
#define CONFIG_SERVERIP 192.168.2.122

5.2.5

U-Boot


helphelp usb USB
ping PING
setenv
saveenv
ftptftp 32000000 vmlinux serverIP= serverip/tftpdroot/
vmlinux TFTP 32000000
kgo linux kgo 32000000
bootm UBOOT TOOLS LINUX bootm 3200000
protect FLASH protect on 1:0-3 FLASH
< Linux >

Linux 5 Linux

0-3
protect off 1:0-3
erase FLASH erase 1:0-2 FLASH 0-2

cpcp 32000000 0 40000 0x32000000 0x40000


0x0

mw RAM mw 32000000 ff 10000 0x32000000


0x10000 0xFF
md RAM md 32000000
usbusb start usb usb info usb scan usb storage
U
fatls DOS FAT fatls usb 0 U
fatload FAT fatload usb 0:0 32000000 aa.txt
flinfo flash
loadb KERMIT kermit
nfsnfs 32000000 192.168.0.2:aa.txt 192.168.0.2LINUX NFS
NFS aa.txt 0x32000000

5.3

Linux
1

Linux Linux

2
Linux minicom
Linux2.6
3
1 minicomCTRL-A O
2
3 Linux Makefile
4make menuconfig

5make dep

6make zImage

7 tftp
8
4

< Linux >

http://www.farsight.com.cn


Linux minicom
Linux U-Boot

1 Linux
2 NFS

< Linux >

You might also like