2/10/2015

U-boot MII 와 NAND 기본명령

1. Uboot의 기본정보

  • 메뉴얼 
http://www.denx.de/wiki/DULG/Manual
http://www.denx.de/wiki/U-Boot/Documentation

  • 소스확인 
http://git.denx.de/?p=u-boot.git;a=summary


  • Uboot Command 
  http://skywheel.tistory.com/entry/uboot-%EB%AA%85%EB%A0%B9%EC%96%B4-%EB%B0%8F-%ED%99%98%EA%B2%BD%EB%B3%80%EC%88%98-%EC%A0%95%EB%A6%AC


1.1 Uboot Config 확인 

  • Uboot 기본설정확인
include/config.h  
include/configs/xxxx   //board name 

#define CONFIG_CMD_xxx         // Command 지원확인
#define CONFIG_ENV_OFFSET      // ENV 저장부분  
#define CONFIG_ENV_ADDR


SoC에따른 Uboot
  http://www.denx.de/wiki/U-Boot/Custodians


1.2 Uboot Env NFS 설정 


  • TI-NFS SETTING EXAMPLE
setenv ethaddr 00:11:22:33:04:55
setenv ipaddr 192.168.1.4
setenv serverip 192.168.1.100
setenv netmask 255.255.255.0
setenv broadcast 192.168.1.255
setenv gateway 192.168.1.1 

setenv bootargs 'console=ttyS1,115200n8 rw mem=48M root=/dev/nfs nfsrootdebug rootdelay=4 nfsroot=192.168.1.100:/home/jhlee/dm368/mt5/Source/ipnc_rdk/target/filesys_dm368,nolock mem=48M cmemk.phys_start="0x83000000" cmemk.phys_end="0x88000000" cmemk.phys_start_1="0x00001000" cmemk.phys_end_1="0x00008000" cmemk.pools_1="1x28672" cmemk.allowOverlap=1 eth=00:0C:0C:A0:04:22 ip=192.168.1.168 nohz=off highres=off clocksource=acpi_pm lpj=1077248 earlyprintk'

안에들어가는 옵션은 Filesystem에 따라 다양하며, 위에서 보는거와 같이 디버깅을 위해서,
earlyprintk , nfsrootdebug 를 추가 가능하다.
또한, mount 시점을 delay를 주는 것도 가능하다.
quiet


2. Uboot의 MII 명령

MII는 Media indepenent interface로 LAN에서 사용하는 표준 Interface이며, 이를 이용하여 일반적으로 사용되어지는 Register 값들을 확인가능하다.

  • Uboot시 아래 mii phy 발견확인 
In:    serial
Out:   serial
Err:   serial
ARM Clock :- 432MHz
DDR Clock :- 340MHz
Ethernet PHY: GENERIC @ 0x01
Hit any key to stop autoboot:  0 

  • MII Device의 갯수 및 주소 파악 
현재 사용되어지는 MII Device 갯수와 주소를 파악가능 (현재 1개만사용)

DM368 IPNC :>mii device
MII devices: 'GENERIC @ 0x01' 
Current device: 'GENERIC @ 0x01'

2.1 Uboot MII 명령어

  • Uboot MII 명령어 
- mii device Lists available devices.  // 사용가능한 MII Device 보여줌
- mii device Set current device.      // MII Device 설정 
- mii read Reads register 'reg' from MII PHY 'addr'.  // MII Device의 Register Read
- mii write Writes 'data' to register 'reg' at MII PHY 'addr'.    // MII Device의 Register Write
- mii dump Displays data of register 'reg' from MII PHY 'addr'.   // MII Device Register Dump 


  • 관련소스
MII에서 MDIO설정하는 부분확인
drivers/net/stmmac/mdio.c

  • Offset Register Name
  1. 00 Basic Mode Configuration
  2. 01 Basic Mode Status
  3. 02 PHY ID #1
  4. 03 PHY ID #2
  5. 04 AutoNegotation Advertisement
  6. 05 Link Partner Ability
  7. 06 AutoNegotation Expansion

  • The bits of the MII status 
  1. 0x8000 Capable of 100baseT4.
  2. 0x7800 Capable of 10/100 HD/FD (most common).
  3. 0x0040 Preamble suppression permitted.
  4. 0x0020 Autonegotiation complete.
  5. 0x0010 Remote fault.
  6. 0x0008 Capable of Autonegotiation.
  7. 0x0004 Link established ("sticky"* on link failure)
  8. 0x0002 Jabber detected ("sticky"* on transmit jabber)
  9. 0x0001 Extended MII register exist.

  https://en.wikipedia.org/wiki/Media-independent_interface

2.2 Uboot MII 사용방법 및 확인


  • Basic Mode Configuration

DM368 IPNC# mii write 1 0 0  // addr reg data
DM368 IPNC# mii read 1 0   // addr reg data 
0000
DM368 IPNC# mii write 1 0 3100     // default setting (Basic Mode Configuration)
DM368 IPNC# mii read 1 0
3100
DM368 IPNC# mii write 1 0 B100    // + Reset 
DM368 IPNC# mii read 1 0
3100


  • 상위 Register 들 점검
DM368 IPNC :>mii read 1 0  // Basic Mode Configuration
3100
DM368 IPNC :>mii read 1 1  // Basic Mode Status 
7849
DM368 IPNC :>mii read 1 2  // PHY ID #1
0181
DM368 IPNC :>mii read 1 3  // PHY ID #2
B8B0
DM368 IPNC :>mii read 1 4  // AutoNegotation Advertisement
01E1
DM368 IPNC :>mii write 1 0 1000
DM368 IPNC :>mii read 1 0


  • MII Dump로 쉽게 분석

# mii dump 1 0  // Basic Mode Configuration
0.     (3100)                 -- PHY control register --
  (8000:0000) 0.15    =     0    reset
  (4000:0000) 0.14    =     0    loopback
  (2040:2000) 0. 6,13 =   b01    speed selection = 100 Mbps
  (1000:1000) 0.12    =     1    A/N enable   // Auto Nego
  (0800:0000) 0.11    =     0    power-down
  (0400:0000) 0.10    =     0    isolate
  (0200:0000) 0. 9    =     0    restart A/N
  (0100:0100) 0. 8    =     1    duplex = full
  (0080:0000) 0. 7    =     0    collision test enable
  (003f:0000) 0. 5- 0 =     0    (reserved)

# mii dump 1 1 // Basic Mode Status 
1.     (786d)                 -- PHY status register --
  (8000:0000) 1.15    =     0    100BASE-T4 able
  (4000:4000) 1.14    =     1    100BASE-X  full duplex able
  (2000:2000) 1.13    =     1    100BASE-X  half duplex able
  (1000:1000) 1.12    =     1    10 Mbps    full duplex able
  (0800:0800) 1.11    =     1    10 Mbps    half duplex able
  (0400:0000) 1.10    =     0    100BASE-T2 full duplex able
  (0200:0000) 1. 9    =     0    100BASE-T2 half duplex able
  (0100:0000) 1. 8    =     0    extended status
  (0080:0000) 1. 7    =     0    (reserved)
  (0040:0040) 1. 6    =     1    MF preamble suppression
  (0020:0020) 1. 5    =     1    A/N complete  //Auto Nego 
  (0010:0000) 1. 4    =     0    remote fault
  (0008:0008) 1. 3    =     1    A/N able
  (0004:0004) 1. 2    =     1    link status
  (0002:0000) 1. 1    =     0    jabber detect
  (0001:0001) 1. 0    =     1    extended capabilities


# mii dump 1 2 // PHY ID #1
2.     (0243)                 -- PHY ID 1 register --
  (ffff:0243) 2.15- 0 =   579    OUI portion


# mii dump 1 3 // PHY ID #2
3.     (0c54)                 -- PHY ID 2 register --
  (fc00:0c00) 3.15-10 =     3    OUI portion
  (03f0:0050) 3. 9- 4 =     5    manufacturer part number
  (000f:0004) 3. 3- 0 =     4    manufacturer rev. number


# mii dump 1 4 // AutoNegotation Advertisement
4.     (01e1)                 -- Autonegotiation advertisement register --
  (8000:0000) 4.15    =     0    next page able
  (4000:0000) 4.14    =     0    reserved
  (2000:0000) 4.13    =     0    remote fault
  (1000:0000) 4.12    =     0    reserved
  (0800:0000) 4.11    =     0    asymmetric pause
  (0400:0000) 4.10    =     0    pause enable
  (0200:0000) 4. 9    =     0    100BASE-T4 able
  (0100:0100) 4. 8    =     1    100BASE-TX full duplex able
  (0080:0080) 4. 7    =     1    100BASE-TX able
  (0040:0040) 4. 6    =     1    10BASE-T   full duplex able
  (0020:0020) 4. 5    =     1    10BASE-T   able
  (001f:0001) 4. 4- 0 =     1    selector = IEEE 802.3

# mii dump 1 5  //Link Partner Ability
5.     (45e1)                 -- Autonegotiation partner abilities register --
  (8000:0000) 5.15    =     0    next page able
  (4000:4000) 5.14    =     1    acknowledge
  (2000:0000) 5.13    =     0    remote fault
  (1000:0000) 5.12    =     0    (reserved)
  (0800:0000) 5.11    =     0    asymmetric pause able
  (0400:0400) 5.10    =     1    pause able
  (0200:0000) 5. 9    =     0    100BASE-T4 able
  (0100:0100) 5. 8    =     1    100BASE-X full duplex able
  (0080:0080) 5. 7    =     1    100BASE-TX able
  (0040:0040) 5. 6    =     1    10BASE-T full duplex able
  (0020:0020) 5. 5    =     1    10BASE-T able
  (001f:0001) 5. 4- 0 =     1    selector = IEEE 802.3

# mii info  // MII PHY 관련정보
PHY 0x01: OUI = 0x90C3, Model = 0x05, Rev = 0x04, 100baseT, FDX

  https://en.wikipedia.org/wiki/Management_Data_Input/Output
  https://en.wikipedia.org/wiki/Autonegotiation
  http://lostintransit.se/tag/autonegotiation/
  http://units.folder101.com/cisco/sem1/Notes/ch6-ethernet/autonegotiation.htm


3. Uboot I2C 와 USB 명령어 

  • Uboot에서 USB 명령어

# usb dev 0
USB device 0:
    Device 0: Vendor: General  Rev: 5.00 Prod:              
            Type: Removable Hard Disk
            Capacity: 3950.0 MB = 3.8 GB (8089600 x 512)
... is now current device

# usb part 0
Partition Map for USB device 0  --   Partition Type: DOS
Partition     Start Sector     Num Sectors     Type
    1            778135908      1141509631      72
    2            168689522      1936028240      65
    3           1869881465      1936028192      79
    4           -1409286144          55499       d

  • Uboot에서 I2C명령어

imd {i2c_chip} {addr}{.0, .1, .2} {len}
imm{.b, .w, .l} {i2c_chip} {addr}{.0, .1, .2}
imw {i2c_chip} {addr}{.0, .1, .2} {data} [{count}]


4. Uboot NAND 명령어

CPU마다 기본적으로 지원되는 Command는 많이 다르며, 특정 CPU에서만 지원되는 CMD도 있다.
본인이 원하면 CMD를 추가하여 설정을 하고 포팅을 해서 사용을 해야 하며 관련내용은 Command Config에서 확인하자.

nand write 관련 command

nand write       : 일반적인 raw data를 기록한다.
nand write.e     : NAND의 ecc block을 사용하여 기록을 한다.
nand write.jffs2 : jffs2 filesystem을 기록한다.


nandecc hw 2
nandecc hw 0   : ecc 변경

  https://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/100/t/210595


nand scrub : bbt까지 다 없애고 초기화
nand erase : nand erase 진행

세부설명은 이곳을 봐도 될 것 같음
  http://wiki.openmoko.org/wiki/U-Boot_commands#Loading_Kernel_from_NAND
  http://wiki.openmoko.org/wiki/NAND_bad_blocks


  http://www.aesop.or.kr/index.php?mid=Board_Community_QandA&page=41&listStyle=webzine&document_srl=77412