gm8126 u-boot - open ip camera forum v1.1/docs/software...the released u-boot for the gm8126 nand...

27
GM8126 U-BOOT User Guide Rev.: 0.2 Issue Date: May 2011

Upload: nguyendan

Post on 02-Jul-2018

230 views

Category:

Documents


0 download

TRANSCRIPT

GM8126

U-BOOT User Guide Rev.: 0.2 Issue Date: May 2011

REVISION HISTORY

GM8126 U-BOOT User Guide

Date Rev. From To

Apr. 2011 0.1 - Original

May 2011 0.2 - ● Modified Chapters 5 and 8

● Added Chapter 7

Copyright © 2011 Grain Media, Inc.

All Rights Reserved.

Printed in Taiwan 2011

Grain Media and the Grain Media Logo are trademarks of Grain Media, Inc. in Taiwan and/or other countries.Other company, product and service names may be trademarks or service marks of others.

All information contained in this document is subject to change without notice. The products described in this document are NOT intended for use in implantation or other life support application where malfunction may result in injury or death to persons . The information contained in this document does not affect or change Grain Media’s product specification or warranties. Nothing in this document shall operate as an express or implied license or indemnity under the intellectual property rights of Grain Media or third parties. All information contained in this document was obtained in specific environments, and is presented as an illustration. The results obtained in other operating environments may vary.

THE INFORMATION CONTAINED IN THIS DOCUMENT IS PROVIDED ON AN “AS IS” BASIS. In no event will Grain Media be liable for damages arising directly or indirectly from any use of the information contained in this document.

Grain Media, Inc.5F, No. 5, Li-Hsin Road III, Hsinchu Science Park, Hsinchu City, Taiwan 300, R.O.C. Grain Media's home page can be found at:http://www.grain-media.com

GM8126 U-BOOT User Guide

www.grain-media.com

i

3

4

4

5

5

6

7

8

8

9

10

10

11

15

17

18

18

21

TABLE OF CONTENTS

Chapter 1 Overview ............................................................................................................................... 1 Chapter 2 Compiler ................................................................................................................................

2.1 Unpack ....................................................................................................................... 2.2 Build SPI System........................................................................................................

2.2.1 Binaries ......................................................................................................... 2.3 Build NAND System ...................................................................................................

2.3.1 Binaries ......................................................................................................... Chapter 3 Add New Chip .......................................................................................................................

3.1 SPI Flash.................................................................................................................... 3.2 NAND Flash ...............................................................................................................

Chapter 4 Modify Address Setting ......................................................................................................... 4.1 SPI Flash.................................................................................................................. 4.2 NAND Flash .............................................................................................................

Chapter 5 MAC Setting ........................................................................................................................ Chapter 6 Boot Function ...................................................................................................................... Chapter 7 Flash Command..................................................................................................................

7.1 SPI Flash.................................................................................................................. 7.2 NAND Flash .............................................................................................................

Chapter 8 Others..................................................................................................................................

GM8126 U-BOOT User Guide

www.grain-media.com

1

Chapter 1 Overview

U-BOOT is closely related to Linux. Some parts of the source code are originated in the Linux source tree

so that some header files are in common and special provision supports the booting of the Linux images.

When the peripheral chip is different from the on-board peripheral chip, the drivers should be modified

according to the new hardware design and the new definition should be configured as required.

Directory hierarchy:

- board Board dependent files

- common Misc architecture independent functions

- cpu CPU specific files

- disk Code for the disk drive partition handling

- doc Documentation (Do not expect too much)

- drivers Commonly used device drivers

- examples Example code for standalone applications, and so on

- include Header files

- lib_arm Files generic to the ARM architecture

GM8126 U-BOOT User Guide

www.grain-media.com

2

- lib_avr32 Files generic to the AVR32 architecture

- lib_generic Files generic to all architectures

- lib_i386 Files generic to the i386 architecture

- lib_m68k Files generic to the m68k architecture

- lib_mips Files generic to the MIPS architecture

- lib_nios Files generic to the NIOS architecture

- lib_ppc Files generic to the PowerPC architecture

- lib_sparc Files generic to the SPARC architecture

- net Networking code

- post Power-On Self Test

- tools Tools used to build the S-Record or U-BOOT images

GM8126 U-BOOT User Guide

www.grain-media.com

3

Chapter 2 Compiler

This chapter contains the following sections:

• 2.1 Unpack

• 2.2 Build SPI System

• 2.3 Build NAND System

GM8126 U-BOOT User Guide

www.grain-media.com

4

The released U-BOOT for the GM8126 NAND system can be found in the “u-boot” directory. In that

directory, users can find the pre-compiled image and the source archive.

2.1 Unpack Users can unpack the source archive by issuing the following command (Replace “u-boot-2008.10.tar.gz”

with a filename as required):

$ tar xvfz u-boot-2008.10.tar.gz Change to the created U-BOOT directory (Replace “u-boot-2008.10” with a file name as required):

$ cd u-boot-2008.10 2.2 Build SPI System Before compiling U-BOOT, the SPI configure of GM8126 has to be enabled. Open the GM8126 U-BOOT

configure file, include/configs/gm8126.h, and ensure that the “CONFIG_SPI***” option is defined and the

“CONFIG_NAND” option is not defined.

GM8126 U-BOOT User Guide

www.grain-media.com

5

2.2.1 Binaries Once U-BOOT has successfully compiled the following files, the compiled files will be stored in the “u-boot”

directory:

File Description

u-boot Compiled ELF image u-boot.bin U-BOOT is converted to a raw binary. u-boot.srec u-boot.bin is converted to the Motorola S-records format.

2.3 Build NAND System Before compiling U-BOOT, the NAND configuration of GM8126 has to be enabled. Open the GM8126

U-BOOT configure file, include/configs/gm8126.h, and ensure that the “CONFIG_NAND” option is defined.

GM8126 U-BOOT User Guide

www.grain-media.com

6

Then, issue the following commands to build an image:

$ make gm8126_config

$ make

2.3.1 Binaries Once U-BOOT has successfully compiled the files listed in the table below, the compiled files will be stored

in the “u-boot” directory.

File Description

u-boot Compiled ELF image

u-boot.bin U-BOOT is converted to a raw binary.

u-boot.srec u-boot.bin is converted to the Motorola S-records format.

GM8126 U-BOOT User Guide

www.grain-media.com

7

Chapter 3 Add New Chip

This chapter contains the following sections:

• 3.1 SPI Flash

• 3.2 NAND Flash

GM8126 U-BOOT User Guide

www.grain-media.com

8

3.1 SPI Flash If users want to add a new SPI chip, the file listed below should be modified:

u-boot-2008.10\drivers\mtd\spi\winbond.c

Users can search for the “SELF” string and update the SPI Flash as required:

u-boot-2008.10\include\configs\gm8126.h

#define CONFIG_SPI_FLASH_SELF 1

#define PHYS_FLASH_SIZE 0x800000

Issue the previous command if the Flash size must be updated:

u-boot-2008.10\drivers\mtd\spi\spi_flash.c

Search for the “SELF” string and update the SPI Flash as required.

3.2 NAND Flash General NAND Flash uses 4-byte ID.

GM8126 U-BOOT User Guide

www.grain-media.com

9

Chapter 4 Modify Address Setting

This chapter contains the following sections:

• 4.1 SPI Flash

• 4.2 NAND Flash

GM8126 U-BOOT User Guide

www.grain-media.com

10

If users want to add a new SPI chip, the following file should be modified:

u-boot-2008.10\include\configs\gm8126.h

4.1 SPI Flash #define CONFIG_ENV_OFFSET 0x6E0000

#define CONFIG_ENV_SIZE 0x20000

#define CONFIG_ENV_SECT_SIZE 0x20000

4.2 NAND Flash #define CONFIG_ENV_OFFSET 0x440000

#define CONFIG_ENV_SIZE 0x20000 /* must reserve 0x20000 for erase */

GM8126 U-BOOT User Guide

www.grain-media.com

11

Chapter 5 MAC Setting

If users want to add a new SPI chip, the following files should be modified:

• Please copy the fw_env.config file to the rootfs-cpio etc directory and copy the fw_printenv AP

to bin or the /usr/sbin directory.

• If users need to modify the MTD5 setting or the Flash address setting, please modify the

fw_env.config file as required.

It is not recommended modifying these files at the initial stage, if the MAC setting works, then users can

modify the setting as required. If users modify the size setting value, the

u-boot-2008.10\include\configs\gm8126.h CONFIG_ENV setting value should be modified at the same

time and compiler again.

GM8126 U-BOOT User Guide

www.grain-media.com

12

For example:

• MTD device name: /dev/mtd5 (U-BOOT environment)

• Device offset: 0x0000

• Environment size: 0x20000

• Flash sector size: 0x20000

• Number of sectors: 0x1

Please refer to the sample below for the fw_env.config file.

# NAND example

/dev/mtd5 0x000000 0x20000 0x20000 0x1

u-boot-2008.10\include\configs\gm8126.h

=> printenv

bootargs=

bootcmd=sf probe 0:0;sf read 0x4000000 0xd6100 0x800000;go 0x4000000

bootdelay=3

baudrate=38400

ethaddr=00:42:70:00:30:22

ipaddr=10.0.1.52

serverip=10.0.1.51

gatewayip=10.0.1.51

netmask=255.0.0.0

ethact=FTMAC110#0

ver=U-Boot 2008.10 (Apr 7 2011 - 09:56:19)

Environment size: 268/131068 bytes

=> saveenv

Saving Environment to SPI Flash...

Erasing SPI flash...Erase: 20 6e 00 00

##Erase: 20 6e 10 00

##Erase: 20 6e 20 00

##Erase: 20 6e 30 00

##Erase: 20 6e 40 00

##Erase: 20 6e 50 00

GM8126 U-BOOT User Guide

www.grain-media.com

13

##Erase: 20 6e 60 00

##Erase: 20 6e 70 00

##Erase: 20 6e 80 00

##Erase: 20 6e 90 00

##Erase: 20 6e a0 00

##Erase: 20 6e b0 00

##Erase: 20 6e c0 00

##Erase: 20 6e d0 00

##Erase: 20 6e e0 00

##Erase: 20 6e f0 00

##Erase: 20 6f 00 00

##Erase: 20 6f 10 00

##Erase: 20 6f 20 00

##Erase: 20 6f 30 00

##Erase: 20 6f 40 00

##Erase: 20 6f 50 00

##Erase: 20 6f 60 00

##Erase: 20 6f 70 00

##Erase: 20 6f 80 00

##Erase: 20 6f 90 00

##Erase: 20 6f a0 00

##Erase: 20 6f b0 00

##Erase: 20 6f c0 00

##Erase: 20 6f d0 00

##Erase: 20 6f e0 00

##Erase: 20 6f f0 00

##Writing to SPI flash...#######################################################

#########################done

=>

GM8126 U-BOOT User Guide

www.grain-media.com

14

fw_printenv prints all environment variables. If users want to pass ethaddr, please run the “fw_printenv

ethaddr” command. If users want to pass ipaddr, please run the “fw_printenv ipaddr” command.

/ # insmod /lib/modules/ftmac100.ko FTMAC with FARADAY Internal PHY support FTMAC110 Driver (Linux 2.6) 01/10/11 - (C) 2011 GM Corp.

reset Faraday Internal PHY.

/ # mdev -s

/ # fw_printenv

bootargs=

bootcmd=sf probe 0:0;sf read 0x4000000 0xd6100 0x800000;go 0x4000000

bootdelay=3

baudrate=38400

ethaddr=00:42:70:00:30:22

ipaddr=10.0.1.52

serverip=10.0.1.51

gatewayip=10.0.1.51

netmask=255.0.0.0

ethact=FTMAC110#0

ver=U-Boot 2008.10 (Apr 7 2011 - 09:56:19)

/ # ifconfig

/ # fw_printenv ethaddr

ADDR:00:e42:th70:a00:d30:d22

r=00:42:70:00:30:22

ftmac110_link_change:2048 <SPEED100>

ftmac110_link_change:2062 <FULL>

/ # ifconfig

eth0 Link encap:Ethernet HWaddr 00:42:70:00:30:22

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:10 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:2233 (2.1 KiB) TX bytes:0 (0.0 B)

Interrupt:3 Base address:0x6000 / #

GM8126 U-BOOT User Guide

www.grain-media.com

15

Chapter 6 Boot Function

If users want to boot from U-BOOT and not using the non-OS boot code, the following line should be

disabled:

u-boot-2008.10\include\configs\gm8126.h

#define CONFIG_SKIP_LOWLEVEL_INIT 1

GM8126 U-BOOT User Guide

www.grain-media.com

17

Chapter 7 Flash Command

This chapter contains the following sections:

• 4.1 SPI Flash

• 4.2 NAND Flash

GM8126 U-BOOT User Guide

www.grain-media.com

18

If users want to run the read, write, or erase command, this command should be set as follow:

7.1 SPI Flash Detect chip (If you want to run SPI flash r/w/e command, please set this command first)

=> sf probe 0:0

#SF: Got idcode ef 40 17

8192 KiB W25Q64CV at 0:0 is now current device

=>

=> help sf

sf probe [bus:]cs [hz] [mode] - init flash device on given SPI bus

and chip select

sf read addr offset len - read `len' bytes starting at

`offset' to memory at `addr'

sf write addr offset len - write `len' bytes from memory

at `addr' to flash at `offset'

sf erase offset len - erase `len' bytes from `offset'

7.2 NAND Flash

=> nand info

Device 0: NAND 128MiB 3,3V 8-bit, sector size 256 KiB

=>

nand read addr offset len - read `len' bytes starting at

`offset' to memory at `addr'

nand write addr offset len - write `len' bytes from memory

at `addr' to flash at `offset'

GM8126 U-BOOT User Guide

www.grain-media.com

19

nand erase offset len - erase `len' bytes from `offset'

GM8126 U-BOOT User Guide

www.grain-media.com

21

Chapter 8 Others

Large size or new NAND Flash of using 5-byte ID is not supported in this version of U-BOOT. When the

change of the DDR timing or size is not modified by U-BOOT, it should be modified by nsboot, and the

modification is defined in the SDK/Spi_nand/nsboot/source/nsboot_mp.tar.gz head.s file.