How To Use U-boot on EISC Development Board
Rev 0.1
July 22, 2008
Advanced Digital Chips Inc.
(www.adc.co.kr)
How to use u-boot on EISC Development board
Advanced digital chips inc. 2
How to use u-boot on EISC Development board
Advanced digital chips inc. 3
Contents
1. Downloading U-Boot source for AE32000 CPU .................................................................... 4
2. Compiling U-Boot ................................................................................................................... 4
3. Installing U-Boot to Demo Board ........................................................................................... 4
4. How to run and use u-Boot on eisc demo board ................................................................... 6
4.1. Exceuting the U-Boot .................................................................................................... 6
4.2. Environment variable of u-boot ..................................................................................... 6
4.2.1. List of enviroment variable ................................................................................... 6
4.2.2. Viewing environment variable .............................................................................. 7
4.2.3. Modificaton of Environment variable .................................................................... 8
4.3. Downloading image from external server ..................................................................... 8
4.3.1. Downloading through serial port .......................................................................... 8
4.3.2. Downloading through ethernet port .................................................................... 10
4.4. Handling NAND Flash on u-boot ................................................................................. 11
4.5. Handling NOR Flash on u-boot .................................................................................... 12
4.6. Miscellaneous u-boot command .................................................................................. 13
4.6.1. Display memory ................................................................................................... 13
4.6.2. Write memroy ...................................................................................................... 14
5. How to run AE32000 uClinux Kernel on U-Boot ................................................................ 15
5.1. Storing Kernel Image and ramdisk and setting „bootcmd‟ .......................................... 15
5.2. Running uClinux ............................................................................................................ 16
6. How to run a firmware program on U-Boot ........................................................................ 18
6.1. Setting executing environment of firmware ................................................................ 18
6.2. Setting environment of „bootcmd‟ ................................................................................ 21
7. How to add new environment variable in u-boot ................................................................ 22
How to use u-boot on EISC Development board
Advanced digital chips inc. 4
1. Downloading U-Boot source for AE32000 CPU
① Excecuting environment
- u-boot-1.1.1-NAND-AE32000: It is running on RAM, after copyed to 0xC0F0_0000 by
„NAND boot code‟. It must store in second nand block.
- u-boot-1.1.1-NOR-AE32000: It is also running on RAM(0xC0F0_0000). But It is first
executed on 0 reset vector in NOR flash or ROM, and then self copy to excecute RAM
area.
② Downloading path of the AE32000 U-Boot source
- u-boot-1.1.1-NAND-AE32000
http://www.adc.co.kr/download/uClinux/u-boot-1.1.1-NAND-AE32000.tar.gz
- u-boot-1.1.1-NOR-AE32000
http://www.adc.co.kr/download/uClinux/u-boot-1.1.1-NOR-AE32000.tar.gz
2. Compiling U-Boot
① make mrproper make clean and, reject other configurable files
② make CPUNAME_config make eagle_config, make gmx1000_config, make
eos_config, etc.
③ make you will get u-boot-eagle.bin or u-boot-eos.bin, etc.
3. Installing U-Boot to Demo Board
EAGLE, GMX1000, EOS 등의 EISC 개발 보드에서 U-boot가 설치되어 있지 않는 경우
JTAG으로 Write해야 한다. NAND Booting을 사용하는 Board에서는 „NAND Boot code‟도
함께 JTAG으로 Write해야 한다.
NAND Booting * Use u-boot-1.1.1-NAND
„Nand boot code‟ Write this code to first NAND Block
„u-boot code‟ Write this code to second NAND Block
Normal Booting * Use u-boot-1.1.1-NOR
„u-boot code‟ Write this code to 0 address of NOR flash
JTAG 도구는 Parallel과 USB를 사용할 수 있다. JTAG의 자세한 사용법은 각 매뉴얼을 참조
하여라.
How to use u-boot on EISC Development board
Advanced digital chips inc. 5
아래는 EALGE 보드에서 Parallel JTAG을 사용할 경우 사용되는 명령이다.
eisc_jtag_nand –C EAGLE –f eagle_nand_boot.bin
eisc_jtag_nand –C EAGLE –f u-boot-eagle.bin –b1
eisc_jtag_nor –C EAGLE –f u-boot-eagle.bin
아래 그림은 EISC USB JTAG 도구를 사용하여 U-boot 코드를 Write하는 화면이다.
How to use u-boot on EISC Development board
Advanced digital chips inc. 6
4. How to run and use u-Boot on eisc demo board
4.1. Exceuting the U-Boot
개발 보드를 리셋시킨 후 시리얼 터미널 프로그램(115200bps)에서 아무키나 입력하면 U-
boot 가 명령모드로 실행된다. 아래 그림은 EAGLE 개발 보드에서 U-boot 실행 화면이다.
4.2. Environment variable of u-boot
4.2.1. List of enviroment variable
U-boot에서는 다음과 같이 환경변수값을 Flash의 일정 영역에 저장하여 부팅환경을 변경시
킬 수가 있다.
Environment
variable of U-boot Functions
bootargs 커널에 넘기는 환경변수 (사용하지 않음)
Bootcmd
자동 실행 명령 시퀀스 1
U-boot 실행후 아무런 키가 입력되지 않으면 이 명령 시퀀스가 실행된다.
„bootd‟라는 명령으로도 이 시퀀스가 실행된다.
리눅스 실행 시퀀스 등 기본적인 부팅 명령 리스트를 넣어두고 사용한다.
Bootcmd2 „bootd2‟라는 명령으로 이 시퀀스가 실행됨.
How to use u-boot on EISC Development board
Advanced digital chips inc. 7
기본적인 부팅 명령이외에 자주쓰는 명령어들을 간단히 사용하고 싶을 때 사
용하면편리하다.
bootdelay U-boot 부팅 후 „bootcmd‟를 실행되기 까지 지연지간
baudrate Baudrate of UART. 이 값을 바꾸어 U-boot의 baudrate를 바꿀 수 있다.
ethaddr U-boot와 uClinux가 사용하는 Ethernet address
ipaddr U-boot가 사용하는 IP address
serverip TFTP server의 IP address
gateway 게이트웨이
netmask 넷마스크
bootfile TFTP로 다운로드 받는 파일 이름 (사용하지 않음)
lcdlogo1 ~ lcdlogo4
LCD로 출력되는 메시지 각각 LCD 한 라인에 해당하는 문자들의 환경변수이
다.
* 현재 EOS 개발보드에서만 사용하고 있음.
lcdcontrast
LCD의 contrast의 값을 변경한다. 변경된 값은 보드가 처음 부팅할 때에만
적용된다.
* 현재 EOS 개발보드에서만 사용하고 있음.
4.2.2. Viewing environment variable
„printenv‟ 라는 명령을 사용하면 아래와 같이 U-boot의 환경변수 값을 볼 수 있다.
How to use u-boot on EISC Development board
Advanced digital chips inc. 8
4.2.3. Modificaton of Environment variable
setenv VARIABLE_NAME VALUE 환경변수 VARIABLE_NAME을 VALUE로 변경한다.
Example)
setenv serverip 210.102.3.100
setenv ethaddr 00:33:44:99:66
saveenv 변경된 환경변수를 저장한다.
„bootcmd‟와 같이 명령 리스트를 변경해야 하는 경우 „‟ 사이에 „;‟로 구분하여 명령 리스트를
사용하여라.
setenv bootcmd „nand read.sjffs2 0xc0000000 0x80000 0x180000; nand read.sjffs2
0xc0500000 0x200000 0x100000; go 0xc0000000‟
4.3. Downloading image from external server
4.3.1. Downloading through serial port
U-boot에서 „downlaod‟ 명령과 Windows에서 „Sdownloader.exe‟ 프로그램을 사용하면
UART 포트로 데이터를 다운로드 받을 수 있다.
① Run „download‟ command in U-Boot, and disconnect serial terminal
How to use u-boot on EISC Development board
Advanced digital chips inc. 9
② Run „Sdownloader.exe‟ in Windows
③ Click „Connect‟ button on Sdownloader program, then you can see below message.
④ Blowse binary file.
⑤ Edit Downloading address
⑥ Click „Download to Target‟ to start downloading
How to use u-boot on EISC Development board
Advanced digital chips inc. 10
⑦ After complete downloading, click „Cancel‟ button when appear „Download Finish‟
window.
⑧ Now, You can use next command in U-boot, after reconnect serial terminal to U-Boot.
4.3.2. Downloading through ethernet port
Windows 또는 Linux의 TFTP Server와 U-boot의 „tftp‟ 명령을 사용하면 Ethernet으로 데
이터를 다운로드할 수 있다.1
환경변수 „serverip‟, „ipaddr‟의 값을 변경하여 TFTP Server IP와 개발 보드의 IP를 셋팅한
다.
setenv serverip YOUR_TFTP_SERVER_IP
setenv ipaddr BOARD_LOCAL_IP
1 Cygwin에서 NFS 서버 구축하는 “TFTP NFS 설치 방법” 문서를 참조하여라.
How to use u-boot on EISC Development board
Advanced digital chips inc. 11
다음과 같이 다운로드 하고자 하는 SDRAM 주소를 명시하여 „tftp‟ 명령을 사용하여라.
EOS Board tftp 0xc0000000 linux-eos.bin
tftp 0xc0500000 4mb-rd-eos.img.gz
EAGLE Board tftp 0xc0000000 linux-eagle.bin
tftp 0xc1800000 4mb-rd-ae32000c.img.gz
4.4. Handling NAND Flash on u-boot
다음과 같은 명령으로 NAND Flash에 데이터를 저장한다.
nand write.jffs2 SRAM_ADDRESS NAND_OFFSET SIZE
Example) nand write.jffs2 0xc0000000 0x80000 0x200000
SDRAM의 0xC0000000 번지에서 NAND 0x80000으로 2Mbytes를 저장
다음과 같은 명령으로 NAND flash에서 데이터를 읽는다.
nand read.sjffs2 SRAM_ADDRESS NAND_OFFSET SIZE
Example) nand read.sjffs2 0xc0000000 0x80000 0x200000
NAND 0x80000 번지에서 SDRAM의 0xC0000000으로 2Mbytes를 복사
How to use u-boot on EISC Development board
Advanced digital chips inc. 12
4.5. Handling NOR Flash on u-boot
다음과 같은 명령으로 16bit 인터페이스의 NOR Flash에 데이터를 저장한다.
cp.w 0xC0000000 0x400000 0x100000
SDRAM 0xC0000000 번지에 있는 데이터를 Flash 0x400000 번지로 0x10000
word(2Mbytes)를 저장한다.2
** NOR Flash가 Byte 모드로 인터페이스되어 있는 경우 „cp.b‟ 명령을 사용한다.
다음과 같이 명령을 사용하면 NOR Flash의 데이터를 RAM으로 복사된다.
cp.w 0x400000 0xc0000000 0x100000
Flash 0x400000 번지에 있는 데이터를 SDRAM 0xC0000000 번지로 0x10000
word(2Mbytes)를 복사한다.3
2 Destination 주소가 NOR Flash 영역인 경우 NOR flash write 함수가 사용된다. 3 Source 주소가 NOR Flash 영역인 경우 단순히 Copy 함수가 사용된다.
How to use u-boot on EISC Development board
Advanced digital chips inc. 13
4.6. Miscellaneous u-boot command
4.6.1. Display memory
„md‟ 명령으로 메모리 값을 확인 할 수 있다. 이 명령의 도움말은 다음과 같이 볼수 있다.
EOS # help md
md [.b, .w, .l] address [# of objects]
- memory display
다음은 0xC0000000 번지부터 0x150bytes 만큼 byte 단위로 보여 준다.
How to use u-boot on EISC Development board
Advanced digital chips inc. 14
4.6.2. Write memroy
메모리 write는 „mw‟ 명령을 사용한다. 다음은 „mw‟의 사용법이다. „count‟ 인자는 얼마나
„value‟를 반복적으로 „address‟를 증가시키면서 쓸것인가를 나타낸다.
EOS # help mw
mw [.b, .w, .l] address value [count]
- write memory
다음은 „mw‟ 명령의 사용 예이다.
How to use u-boot on EISC Development board
Advanced digital chips inc. 15
5. How to run AE32000 uClinux Kernel on U-Boot
5.1. Storing Kernel Image and ramdisk and setting ‘bootcmd’
NAND Booting 되는 개발보드에서는 다음과 같은 명령으로 커널 이미지와 램디스크를
NAND flash에 저장할 수 있다.
EAGLE Development board
tftp 0xc0000000 linux-eagle.bin
tftp 0xc1800000 4mb-rd-ae32000c.img.gz
nand write.jffs2 0xc0000000 0x80000 0x180000
nand write.jffs2 0xc1800000 0x200000 0x100000
위와 같이 NAND flash에 데이터를 저장할 경우 아래와 같이 „bootcmd‟의 환경변수 값이
셋팅되어야 한다.
bootcmd=nand read.sjffs2 0xc0000000 0x80000 0x180000; nand read.sjffs2
0xc1800000 0x200000 0x100000; go 0xc0000000
EOS Development board
tftp 0xc0000000 linux-eoa.bin
tftp 0xc0500000 4mb-rd-eos.img.gz
nand write.jffs2 0xc0000000 0x80000 0x160000
nand write.jffs2 0xc0500000 0x200000 0x100000
NOR Flash로 부팅하는 개발 보드에서는 다음과 같이 명령을 사용할 수 있다.
cp.w 0xc0000000 0x30000 0xb0000
cp.w 0xc0500000 0x200000 0x80000
위와 같이 명령을 사용할 경우 „bootcmd‟ 에는 다음과 같은 명령이 있어야 한다.
bootcmd=cp.w 0x30000 0xc0000000 0xb0000; cp.w 0x200000 0xc0500000
0x80000; go 0xc0000000
How to use u-boot on EISC Development board
Advanced digital chips inc. 16
5.2. Running uClinux
Running the kernel in the process of development
리눅스를 개발하는 과정중에 반복적으로 커널을 실행해야 하는 경우 TFTP 명령이나
„download‟ (시리얼 다운로드 명령) 명령으로 커널과 램디스크 이미지를 받고 직접 커널
을 실행하는 것이 개발 시간을 단축시킬 수 있다.
간단히 TFTP 명령으로 커널을 실행하고 싶을 경우 „bootd2‟ 명령을 사용하여라.
„bootd2‟ 명령은 „bootcmd2‟ 환경변수를 실행한다. 이 환경변수의 값은 아래와 같이
TFTP로 커널과 램디스크를 받아 리눅스를 실행할수 있도록 되어 있다.
bootcmd2=tftp 0xc0000000 linux-eagle.bin; tftp 0xc1800000 4mb-rd-
ae32000c.img.gz; go 0xc0000000
Hit any key
How to use u-boot on EISC Development board
Advanced digital chips inc. 17
Running automatically the kernel after executing u-boot
U-boot 실행 후 자동으로 커널이 실행되도록 하려면 „bootcmd‟ 환경변수를 커널이 실행
될 수 있는 명령리스트로 설정하면 된다.
아래와 같이 „bootcmd‟를 Flash에 저장되어 있는 커널 이미지와 램디스크를 SDRAM으로
복사하는 시퀀스를 설정하면, u-boot 부팅 후 „bootdelay‟ 값이 0으로 감소된 후
„bootcmd‟ 시퀀스가 자동으로 실행된다.
bootcmd=nand read.sjffs2 0xc0000000 0x80000 0x180000; nand read.sjffs2
0xc1800000 0x200000 0x100000; go 0xc0000000
Decreasing to zero, and execute „bootcmd‟
How to use u-boot on EISC Development board
Advanced digital chips inc. 18
6. How to run a firmware program on U-Boot
6.1. Setting executing environment of firmware
U-boot를 사용하면 RAM에서 Firmware 프로그램을 실행시킬 수 있다.
Firmware 프로그램을 램에서 실행되도록 하려면 링크스크립트에서 실행 영역을 수정하고 인
터럽트 벡터 Base 주소를 변경해야 한다.
다음은 EOS에서 Firmware를 0xC000_0000 번지에서 실행되도록 하기 위해 필요한 수정사
항이다.
① 링크스크립트
아래와 같이 데이터 영역과 스택 주소를 SDRAM 영역으로 설정한다.
MEMORY
{
rom : ORIGIN = 0xC0000000, LENGTH = 8M
ram : ORIGIN = 0xC0800000, LENGTH = 8M
}
SECTIONS
{
. . . .
. . . .
.stack 0xC0FFEFF0 : {
_stack = .;
PROVIDE (__stack = .);
*(.stack)
}
}
② 인터럽트 벡터 주소 변경
프로그램이 램에서 실행되므로 인터럽트 벡터 Base 주소도 램으로 변경하고 인터럽트 벡
터를 모두 이 주소로 복사해야 한다.
Crt0.S
ldi 0xC1000000-0x400, %r8
mov %r8, %r0
mvtc 0, %r12 # ---------- 백터 Base 변경
ldi _start_vectors, %r0
How to use u-boot on EISC Development board
Advanced digital chips inc. 19
ldi _vectors_size, %r1
ld (%r1, 0), %r1 # copy size
1: ld (%r0, 0), %r9
addq 4, %r0
st %r9, (%r8, 0)
addq 4, %r8
sub 4, %r1
jnz 1b
jal _main
/**********************************************************************/
.extern _invalid_irq
.extern _Uart0TxISRHandler
.extern _Uart0RxISRHandler
.extern _Uart1TxISRHandler
.extern _Uart1RxISRHandler
.extern _KEY_handler
.extern _TEST_IRQ9
.align 3
_start_vectors:
.long _invalid_irq # V00 reset
.long _invalid_irq # V01 NMI
.long _invalid_irq # V02 Interrupt auto vector
.long _invalid_irq # V03 Double fault exception
.long _invalid_irq # V04 Bus error exception
.long _invalid_irq # V05 Reserved
.long _invalid_irq # V06 Reserved
.long _invalid_irq # V07 Reserved
.long _cp0_exception # V08 Co-processor Exception
.long _invalid_irq # V09 Co-processor Exception
.long _invalid_irq # V0A Co-processor Exception
.long _invalid_irq # V0B Co-processor Exception
.long _invalid_irq # V0C OSI Reset vector
.long _invalid_irq # V0D OSI Break exception
.long _invalid_irq # V0E Reserved
.long _invalid_irq # V0F Reserved
.long _invalid_irq # V10 SWI 00
.long _invalid_irq # V11 SWI 01
.long _invalid_irq # V12 SWI 02
.long _swi3_handler # V13 SWI 03
.long _invalid_irq # V14 SWI 04
.long _invalid_irq # V15 SWI 05
How to use u-boot on EISC Development board
Advanced digital chips inc. 20
.long _invalid_irq # V16 SWI 06
.long _invalid_irq # V17 SWI 07
.long _invalid_irq # V18 SWI 08
.long _invalid_irq # V19 SWI 09
.long _invalid_irq # V1A SWI 0A
.long _invalid_irq # V1B SWI 0B
.long _invalid_irq # V1C SWI 0C
.long _invalid_irq # V1D SWI 0E
.long _invalid_irq # V1E SWI 0E
.long _invalid_irq # V1F SWI 0F
.long _invalid_irq # V20 IRQ0
.long _invalid_irq # V21 IRQ1
.long _invalid_irq # V22 IRQ2
.long _invalid_irq # V23 IRQ3
.long _invalid_irq # V24 IRQ4
.long _invalid_irq # V25 IRQ5
.long _invalid_irq # V26 IRQ6
.long _invalid_irq # V27 IRQ7
.long _invalid_irq # V28 IRQ8
.long _invalid_irq # V29 IRQ9
.long _invalid_irq # V2A ADC
.long _invalid_irq # V2B DMA
.long _invalid_irq # V2C TIMER0
.long _invalid_irq # V2D TIMER1
.long _invalid_irq # V2E TIMER2
.long _invalid_irq # V2F TIMER3
.long _Uart0RxISRHandler # V30 UART0 RX
.long _Uart0TxISRHandler # V31 UART0 TX
.long _Uart1RxISRHandler # V32 UART1 RX
.long _Uart1TxISRHandler # V33 UART1 TX
.long _invalid_irq # V34 UART2 RX
.long _invalid_irq # V35 UART2 TX
.long _invalid_irq # V36 UART3 RX
.long _invalid_irq # V37 UART3 TX
.long _invalid_irq # V38 SIO
.long _invalid_irq # V39 IIC
.long _invalid_irq # V3A RTC Alarm
.long _invalid_irq # V3B RTC Interrupt
.long _invalid_irq # V3C Keypad
.long _invalid_irq # V3D PWM
.long _invalid_irq # V3E
_end_vectors:
_vectors_size: .long _end_vectors - _start_vectors
How to use u-boot on EISC Development board
Advanced digital chips inc. 21
다음 그림은 위와 같이 링크 스크립트를 사용하는 firmware와 U-boot가 사용하는 메모
리 영역을 도시한 것이다.
Executing Area
0xC0F0_0000
0xC0FF_FFFF
U-BOOTFirmware
Executing Area
Vector Table
0xC000_0000
0xC0FF_FFFF
0xC0FF_FC00
6.2. Setting environment of ‘bootcmd’
U-boot의 „bootcmd‟에 Firmware 바이너리 크기 만큼 복사하고 실행주소로 점프할 수 있도
록 만든다.
tftp 0xc0000000 myfirmware.bin
nand write.jffs2 0xc0000000 0x80000 0x20000
setenv bootcmd „nand read.sjffs2 0xc0000000 0x80000 0x20000; go 0xc0000000‟
saveenv
How to use u-boot on EISC Development board
Advanced digital chips inc. 22
7. How to add new environment variable in u-boot
때로 사용자는 새로운 환경변수를 추가하여 응용프로그램등에서 그 값을 사용하고 싶어할 것
이다. 다음은 U-Boot에 새로운 환경변수를 추가하는 방법에 대한 설명이다.
새로운 환경변수 추가하는 방법에 대한 예로 „bootcmd2‟라는 환경변수를 추가하기 위해 어떤
파일을 수정해야 하는지 설명하겠다. „bootcmd2‟는 „bootcmd‟ 환경변수와 유사하게 „bootd2‟
라는 명령으로 실행되는 명령시퀀스이다.4
① Include/config/CPU_NAME.h
명령시퀀스 문자열을 CONFIG_BOOTCOMMAND2로 정의한다.
#define CONFIG_BOOTCOMMAND2 "tftp 0xc0000000 linux-eos.bin; tftp 0xc0500000
4mb-rd-eos.img.gz; go 0xc0000000"
② Common/environment.c
#if defined(CONFIG_BOOTCOMMAND2)
"bootcmd2=" CONFIG_BOOTCOMMAND2 "\0"
#endif
③ Common/env_common.c
#ifdef CONFIG_BOOTCOMMAND2
"bootcmd2=" CONFIG_BOOTCOMMAND2 "\0"
#endif
4 „bootcmd‟ 명령시퀀스는 „bootd‟ 명령으로 실행된다.
How to use u-boot on EISC Development board
Advanced digital chips inc. 23
Revision History of Document
Revision No.
Ver 0.1 Initial release 07/22/2008