Friday, October 9, 2015

U-boot porting JZ2440 - support DM9000

3.7 修改UBOOT支持DM9000網卡
3.7.1 搜尋DM9000關鍵字, 發現/driver/net/Makefile中,
 ======================================================
Makefile
......

COBJS-$(CONFIG_BFIN_MAC) += bfin_mac.o
COBJS-$(CONFIG_CALXEDA_XGMAC) += calxedaxgmac.o
COBJS-$(CONFIG_CS8900) += cs8900.o
COBJS-$(CONFIG_TULIP) += dc2114x.o
COBJS-$(CONFIG_DESIGNWARE_ETH) += designware.o
COBJS-$(CONFIG_DRIVER_DM9000) += dm9000x.o
COBJS-$(CONFIG_DNET) += dnet.o
COBJS-$(CONFIG_E1000) += e1000.o
......
======================================================
如果將dm9000x.c編譯進內核,需要定義 CONFIG_DRIVER_DM9000,因此需修改
smdk2440.h
======================================================
smdk2440.h

/*

 * Hardware drivers
 */
#if 0
#define CONFIG_CS8900 /* we have a CS8900 on-board */
#define CONFIG_CS8900_BASE 0x19000300
#define CONFIG_CS8900_BUS16 /* the Linux driver does accesses as shorts */
#else
#define CONFIG_DRIVER_DM9000
#endif
======================================================
3.7.2 重新編譯,發現error如下, 
.........
dm9000x.o dm9000x.c -c
dm9000x.c: In function 'dm9000_outblk_8bit':
dm9000x.c:156: error: 'DM9000_DATA' undeclared (first use in this function)
dm9000x.c:156: error: (Each undeclared identifier is reported only once
dm9000x.c:156: error: for each function it appears in.)
dm9000x.c: In function 'dm9000_outblk_16bit':

dm9000x.c:165: error: 'DM9000_DATA' undeclared (first use in this function)
...........


dm9000x.c:585: error: 'DM9000_DATA' undeclared (first use in this function)
make[1]: *** [dm9000x.o] Error 1
make[1]: Leaving directory `/home/scyu/share/linux_source/uboot/u-boot-2012.04.01/drivers/net'
make: *** [drivers/net/libnet.o] Error 2
======================================================
搜尋關鍵字 "grep "DM9000_DATA" * -nR",找到相關資訊如下
......
include/configs/at91sam9261ek.h:159:#define DM9000_DATA                 (CONFIG_DM9000_BASE + 4)
include/configs/devkit8000.h:81:#define DM9000_DATA                     (CONFIG_DM9000_BASE + 0x400)
include/configs/ip04.h:78:#define DM9000_DATA           (CONFIG_DM9000_BASE + 2)
include/configs/colibri_pxa270.h:84:#define DM9000_DATA                 (CONFIG_DM9000_BASE + 4)
include/configs/scb9328.h:249:#define DM9000_DATA                       (CONFIG_DM9000_BASE+4)
include/configs/M5253DEMO.h:95:#        define DM9000_DATA              (CONFIG_DM9000_BASE + 4)
include/configs/davinci_dm355evm.h:56:#define DM9000_DATA                       (CONFIG_DM9000_BASE + 2)
include/configs/trizepsiv.h:303:#define DM9000_DATA                     (CONFIG_DM9000_BASE+0x8004)
include/configs/davinci_dm355leopard.h:55:#define DM9000_DATA                   (CONFIG_DM9000_BASE + 16)
include/configs/vpac270.h:113:#define   DM9000_DATA                     (CONFIG_DM9000_BASE + 4)
include/configs/pm9261.h:258:#define DM9000_DATA                                (CONFIG_DM9000_BASE + 4)
======================================================
vim include/configs/davinci_dm355evm.h +56
.....
/* Ethernet:  external DM9000 */
#define CONFIG_DRIVER_DM9000            1
#define CONFIG_DM9000_BASE              0x04014000
#define DM9000_IO                       CONFIG_DM9000_BASE
#define DM9000_DATA                     (CONFIG_DM9000_BASE + 2)
....
======================================================
3.7.3 DM9000是內存類設備,對於訪問這類設備,需要知道:

  • 位寬
  • 訪問地址

片選引腳nGCS4接到了DM9000,從手冊知道訪問位址0x20000000-0x28000000時,將會使能片選信號nGCS4,2440位址線LADDR2接到了DM9000CMD引腳,進行控制訪問,
參考如上資訊,修改smdk2440.h
......
#if 0
#define CONFIG_CS8900        /* we have a CS8900 on-board */
#define CONFIG_CS8900_BASE    0x19000300
#define CONFIG_CS8900_BUS16    /* the Linux driver does accesses as shorts */
#else
// 這裡增加對DM9000的定義
#define CONFIG_DRIVER_DM9000            
#define CONFIG_DM9000_BASE  0x20000000    // 定義基底位址 0x20000000
#define DM9000_IO           CONFIG_DM9000_BASE
#define DM9000_DATA         (CONFIG_DM9000_BASE + 4)   // LADDR2相當於bit2引腳 bit2 = 4

#endif
......
======================================================
修改SDRAM控制器,在lowlevel_init.S中
......
/* the literal pools origin */
SMRDATA:
    .long 0x22011110  //BWSCON
.long 0x00000700  //BANKCON0
.long 0x00000700  //BANKCON1
.long 0x00000700  //BANKCON2
.long 0x00000700  //BANKCON3  
.long 0x00000740  //BANKCON4
.long 0x00000700  //BANKCON5
.long 0x00018005  //BANKCON6
.long 0x00018005  //BANKCON7
.long 0x008C04F4  //REFRESH
.long 0x000000B1  //BANKSIZE
.long 0x00000030  //MRSRB6
.long 0x00000030  //MRSRB7c

======================================================
3.7.4 重新編譯,燒寫測試,發現ERROR如下


U-Boot 2012.04.01 (Sep 16 2015 - 20:09:36)

CPUID: 32440001
FCLK:      400 MHz
HCLK:      100 MHz
PCLK:       50 MHz
DRAM:  64 MiB
WARNING: Caches not enabled
Flash: 2 MiB
NAND:  256 MiB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   No ethernet found.
======================================================
程式追蹤:
        eth_initialize
                board_eth_init
                        cs8900_initialize

修正/board/samsung/smdk2410.c
.......
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_CS8900
rc = cs8900_initialize(0, CONFIG_CS8900_BASE);
#endif
#ifdef CONFIG_DRIVER_DM9000
    rc = dm9000_initialize(bis);
#endif
return rc;
}
#endif
........
重新編譯燒寫、測試
DM9000通了

======================================================
3.7.5 驗證


U-Boot 2012.04.01 (Sep 17 2015 - 04:34:23)

CPUID: 32440001
FCLK:      400 MHz
HCLK:      100 MHz
PCLK:       50 MHz
DRAM:  64 MiB
WARNING: Caches not enabled
Flash: 2 MiB
NAND:  256 MiB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   dm9000
SMDK2410 # print
baudrate=115200
bootdelay=5
ethact=dm9000
ipaddr=10.0.0.110
netmask=255.255.255.0
serverip=10.0.0.1
stderr=serial
stdin=serial
stdout=serial

Environment size: 160/65532 bytes
SMDK2410 # set ipaddr 192.168.0.110
SMDK2410 # set ethaddr 08:00:3e:26:0a:5b
SMDK2410 # setenv gatewayip 192.168.0.254
SMDK2410 # ping 192.168.0.101
ERROR: resetting DM9000 -> not responding
dm9000 i/o: 0x20000000, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:5b
could not establish link
Using dm9000 device
host 192.168.0.101 is alive  < -- ok

燒寫uImag.bin:
SMDK2410 # set serverip 192.168.0.254
SMDK2410 # tftp 30000000 uImage
ERROR: resetting DM9000 -> not responding
dm9000 i/o: 0x20000000, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:5b
could not establish link
Using dm9000 device
TFTP from server 192.168.0.254; our IP address is 192.168.0.110
Filename 'uImage'.
Load address: 0x30000000
Loading: T #################################################################
         #############################################################
done
Bytes transferred = 1848720 (1c3590 hex)
SMDK2410 # bootm 30000000
## Booting kernel from Legacy Image at 30000000 ...
   Image Name:   Linux-2.6.22.6
   Created:      2011-01-27  14:22:53 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1848656 Bytes = 1.8 MiB
   Load Address: 30008000
   Entry Point:  30008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux...................................................................................................................... done, booting the kernel.
Linux version 2.6.22.6 (book@book-desktop) (gcc version 3.4.5) #1 Thu Jan 27 22:22:51 CST 2011
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
Machine: SMDK2410
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz
S3C24XX Clocks, (c) 2004 Simtec Electronics
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
Built 1 zonelists.  Total pages: 16256
Kernel command line: root=/dev/hda1 ro init=/bin/bash console=ttySAC0
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
PID hash table entries: 256 (order: 8, 1024 bytes)
timer tcon=00500000, tcnt a2c1, tcfg 00000200,00000000, usec 00001eb8
Console: colour dummy device 80x30
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 61056KB available (3264K code, 458K data, 140K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
S3C2410 Power Management, (c) 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C2440: Clock Support, DVS off
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
DMA channel 0 at c4800000, irq 33
DMA channel 1 at c4800040, irq 34
DMA channel 2 at c4800080, irq 35
DMA channel 3 at c48000c0, irq 36
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NetWinder Floating Point Emulator V0.97 (double precision)
Registering GDB sysrq handler
JFFS2 version 2.2. (NAND) c 2001-2006 Red Hat, Inc.
yaffs Jan 27 2011 22:22:18 Installing.
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
Console: switching to colour frame buffer device 30x40
fb0: s3c2410fb frame buffer device
lp: driver loaded but no devices found
ppdev: user-space parallel port driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing enabled
s3c2440-uart.0: s3c2410_serial0 at MMIO map 0x50000000 mem 0xf0400000 (irq = 70) is a S3C2440
s3c2440-uart.1: s3c2410_serial1 at MMIO map 0x50004000 mem 0xf0404000 (irq = 73) is a S3C2440
s3c2440-uart.2: s3c2410_serial2 at MMIO map 0x50008000 mem 0xf0408000 (irq = 76) is a S3C2440
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: module loaded
line 400 <DM9KS> I/O: c486a000, VID: 90000a46
line 408 <DM9KS> I/O: c486a000, VID: 90000a46
<DM9KS> error version, chip_revision = 0x1a, chip_info = 0x3
id_val=0
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c2440-nand s3c2440-nand: Tacls=3, 30ns Twrph0=7 70ns, Twrph1=3 30ns
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 1663 at 0x0cfe0000
Creating 4 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x00000000-0x00040000 : "bootloader"
0x00040000-0x00060000 : "params"
0x00060000-0x00260000 : "kernel"
0x00260000-0x10000000 : "root"
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
mice: PS/2 mouse device common for all mice
s3c2410 TouchScreen successfully loaded
input: s3c2410 TouchScreen as /class/input/input0
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2440-i2c s3c2440-i2c: slave address 0x10
s3c2440-i2c s3c2440-i2c: bus frequency set to 390 KHz
s3c2440-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
mapped channel 0 to 0
s3c2410-sdi s3c2410-sdi: powered down.
s3c2410-sdi s3c2410-sdi: initialisation done.
usbcore: registered new interface driver hiddev
usbcore: registered new interface driver usbhid
drivers/hid/usbhid/hid-core.c: v2.6:USB HID core driver
Advanced Linux Sound Architecture Driver Version 1.0.14 (Thu May 31 09:03:25 2007 UTC).
ASoC version 0.13.1
s3c2410iis_probe...
UDA1341 audio driver initialized
ALSA device list:
  No soundcards found.
TCP cubic registered
NET: Registered protocol family 1
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
Root-NFS: No NFS server available, giving up.
VFS: Unable to mount root fs via NFS, trying floppy.
VFS: Cannot open root device "hda1" or unknown-block(2,0)
Please append a correct "root=" boot option; here are the available partitions:
1f00        256 mtdblock0 (driver?)
1f01        128 mtdblock1 (driver?)
1f02       2048 mtdblock2 (driver?)
1f03     259712 mtdblock3 (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)

No comments:

Post a Comment