蚂蚁战车使用神州龙芯的cpu CQ8401
文件系统是使用的squashfs v3.3 跟目前在2.6.29内核的v4.0不兼容。
大家可以使用debian lenny的squashfs-tool来打包firmware包, 如果用4.0就会有问题。
bootloader用的是 u-boot, 在flash 中u-boot的区域是设置为readonly的, 一般不会被覆盖重写。
如果rootfs或者kernel 被写坏了, 可以通过串口登录蚂蚁战车, 通过tftp服务器来重写 kernel 和rootfs
串口的电平是ttl的, 可能需要转换一下, 我是直接拿dd-wrt的设备里ttl串口直接跟它连接,然后用microcom -D/dev/tts/1 来连接。
115200,n,8,1
地址空间分配如下:
总的flash 的空间是16M, 一开始的12M用于rootfs,
0xbf000000-0xbfb60000 : "SQUASHFS" 12M mtd0
0xbfb60000-0xbfc00000 : "JFFS2" 655K mtd1
0xbfc00000-0xbfc60000 : "BOOTLOADER" 393K mtd2 u-boot
0xbfc60000-0xbff60000 : "KERNEL" 2M mtd3
0xbff60000-0xc0000000 : "BACKUP" 655K mtd4
通过tftp下载烧写文件系统的命令为:
erase 0xbf000000 0xbfb5ffff
tftp 0xbf000000 fw.bin
烧写内核的命令:
erase 0xbfc60000 0xbff5ffff
tftp 0xbfc60000 cq8401
当然要提前配置好 ip和服务器ip
根据libc的版本, 可以把debian4.0(etch)的2进制软件包, 直接拿进来打包运行。
修改1下原设计,增加一个kernel
0xbf980000 0xbfb5ffff kernel2
0xbf000000 0xbf97ffff SQUASHFS
libc版本:
[admin@Antcor local]# /lib/libc.so.6
GNU C Library stable release version 2.3.6, by Roland McGrath et al.
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 3.3.6.
Compiled on a Linux 2.4.26 system on 2008-12-30.
Available extensions:
GNU libio by Per Bothner
crypt add-on version 2.1 by Michael Glad and others
linuxthreads-0.10 by Xavier Leroy
BIND-8.2.3-T5B
libthread_db work sponsored by Alpha Processor Inc
NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
内核版本:
[admin@Antcor local]# cat /proc/version
Linux version 2.6.22.8 (lanzl@Ubuntu) (gcc version 3.3.6) #21 PREEMPT Tue Nov 3 07:02:59 CST 2009
启动命令行:
[admin@Antcor local]# cat /proc/cmdline
mem=64M console=ttyS0,115200n8 ip=192.168.4.136:::::eth0:off ethaddr=00:0B:4C:5B:35:95 rootfstype=squashfs,jffs2 root=/dev/mtdblock0 rw
[admin@Antcor local]#
bdinfo - print Board Info structure:
Mingddie # bdinfo
boot_params = 0x83F63F9C
memstart = 0x80000000
memsize = 0x04000000
flashstart = 0xBF000000
flashsize = 0x01000000
flashoffset = 0x00000000
ethaddr = 00:50:C2:1E:AF:3E
ip_addr = 192.168.2.19
baudrate = 115200 bps
imls - list all images found in flash:
Mingddie # imls
Image at BFC60000:
Image Name: Linux Kernel Image
Image Type: MIPS Linux Kernel Image (gzip compressed)
Data Size: 1918576 Bytes = 1.8 MB
Load Address: 80010000
Entry Point: 80449000
Verifying Checksum ... OK
Mingddie #
printenv- print environment variables:
Mingddie # printenv
bootdelay=2
baudrate=115200
loads_echo=1
ethaddr=00:50:c2:1e:af:3e
autoload=n
bootfile=uImage
ethact=CLX ETHERNET
filesize=31744
fileaddr=BFC00000
bootcmd=bootm 0xbfc60000
bootargs=mem=64M console=ttyS0,115200n8 ip=192.168.4.136:::::eth0:off ethaddr=00:0B:4C:5B:35:95 rootfstype=squashfs,jffs2 root=/dev/mtdblock0 rw
serverip=192.168.2.2
ipaddr=192.168.2.19
stdin=serial
stdout=serial
stderr=serial
Environment size: 399/131068 bytes
Mingddie #
启动信息:
Mingddie # reset
* * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * *
* * * * * * * * * * * * *
* * * * * * * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * ** * *
* * * * * * * * * * * * *
* * * * * * * * * * * * * * *
* * * * * * * * * * * * * * *
* * * * * * * * * * * * * *
* * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * *
* * * * * * ** * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * **
* * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * **
* * * * * * * * * * * * * * * * * * * * * * * * * * * *
U-Boot 1.1.3 (Sep 7 2009 - 18:37:37)
Board: Clx Mingddie (CPU Speed 335 MHz)
DRAM: 64 MB
Flash: 16 MB
In: serial
Out: serial
Err: serial
Net: CLX ETHERNET
Hit any key to stop autoboot: 0
## Booting image at bfc60000 ...
Image Name: Linux Kernel Image
Image Type: MIPS Linux Kernel Image (gzip compressed)
Data Size: 1918576 Bytes = 1.8 MB
Load Address: 80010000
Entry Point: 80449000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
Starting kernel ...
Linux version 2.6.22.8 (lanzl@Ubuntu) (gcc version 3.3.6) #21 PREEMPT Tue Nov 3 07:02:59 CST 2009
CPU revision is: 02d0824f
System clock setup: iclk=335MHZ sclk=112MHZ mclk=112MHZ pclk=112MHZ
Determined physical RAM map:
memory: 04000000 @ 00000000 (usable)
User-defined physical RAM map:
memory: 04000000 @ 00000000 (usable)
Built 1 zonelists. Total pages: 16256
Kernel command line: mem=64M console=ttyS0,115200n8 ip=192.168.4.136:::::eth0:off ethaddr=00:0B:4C:5B:35:95 rootfstype=squashfs,jffs2 root=/dev/mtdblock0 rw
Primary instruction cache 16kB, physically tagged, 4-way, linesize 32 bytes.
Primary data cache 16kB, 4-way, linesize 32 bytes.
Synthesized TLB refill handler (20 instructions).
Synthesized TLB load handler fastpath (32 instructions).
Synthesized TLB store handler fastpath (32 instructions).
Synthesized TLB modify handler fastpath (31 instructions).
PID hash table entries: 256 (order: 8, 1024 bytes)
Using 27.955 MHz high precision timer.
Console: colour dummy device 80x25
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 60208k/65536k available (3538k kernel code, 5264k reserved, 781k data, 160k init, 0k highmem)
Mount-cache hash table entries: 512
NET: Registered protocol family 16
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Time: MIPS clocksource has been installed.
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
squashfs: version 3.4 (2008/08/26) Phillip Lougher
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
st7565 probe
***st7565_chip_reset*******
fbcon_fb_registered
info->fix.line_length=128
Console: switching to mono frame buffer device 16x8
fb0: ST7565 frame buffer device, using 8K of video memory
Silicon Motion Inc. LYNX Init complete.
CLXSOC: char device family.
initialized
CLXSOC Watchdog Timer: timer margin 60 sec
Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing disabled
serial8250: ttyS0 at MMIO 0x0 (irq = 9) is a 16550A
serial8250: ttyS1 at MMIO 0x0 (irq = 8) is a 16550A
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: module loaded
PPP generic driver version 2.4.2
PPP Deflate Compression module registered
physmap platform flash device: 01000000 at 1c000000
physmap-flash.0: Found 1 x16 devices at 0x0 in 16-bit bank
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
cfi_cmdset_0001: Erase suspend on write enabled
cmdlinepart partition parsing not available
RedBoot partition parsing not available
Using physmap partition information
Creating 5 MTD partitions on "physmap-flash.0":
0x00000000-0x00b60000 : "SQUASHFS"
0x00b60000-0x00c00000 : "JFFS2"
0x00c00000-0x00c60000 : "BOOTLOADER"
0x00c60000-0x00f60000 : "KERNEL"
0x00f60000-0x01000000 : "BACKUP"
In ohci_hcd_cq8401_drv_probe<7>: starting CLX OHCI USB Controller
clx-ohci clx-ohci.0: CQ8401 OHCI
clx-ohci clx-ohci.0: new USB bus registered, assigned bus number 1
clx-ohci clx-ohci.0: irq 13, io mem 0x13030000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usb 1-1: new full speed USB device using clx-ohci and address 2
usb 1-1: configuration #1 chosen from 1 choice
usbcore: registered new interface driver cdc_acm
drivers/usb/class/cdc-acm.c: v0.25:USB Abstract Control Model driver for USB modems and ISDN adapters
Initializing USB Mass Storage driver...
scsi0 : SCSI emulation for USB Mass Storage devices
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
Netfilter messages via NETLINK v0.30.
nf_conntrack version 0.5.0 (512 buckets, 4096 max)
ip_tables: (C) 2000-2006 Netfilter Core Team
ClusterIP Version 0.8 loaded successfully
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
Bridge firewalling registered
Ebtables v2.0 registered
arpnat+ebtables patch v0.5 -- Christophe Lucas <clucas@infosat.tm.fr>
VFS: Mounted root (squashfs filesystem) readonly.
Freeing unused kernel memory: 160k freed
Algorithmics/MIPS FPU Emulator v1.5
net.ipv4.conf.all.forwarding = 1
eth0: CLX On-Chip ethernet (MAC 00:0b:4c:5b:35:95, IRQ 19)
eth0: Found 1 PHY on CLX MAC
eth0: Provide Modes: (1)10BaseT-HD (2)10BaseT-FD (3)100baseTx-HD (4)100baseTx-FD
brctl: bridge br0: File exists
device eth0 entered promiscuous mode
br0: port 1(eth0) entering learning state
br0: topology change detected, propagating
br0: port 1(eth0) entering forwarding state
增加内核模块的方法如下:
用2.6.28.10的内核补丁, 移植到2.6.22.8, 移植过程需要修改几十个地方, 然后我们拿到了2.6.22.8的cq8401的内核源码,这个源码编译出来,应该不一定能启动, 但是一些内核模块是可以工作的。 比如openvpn模块,和一些usb设备等,
编译可以在龙芯电脑进行, chroot到一个 etch版本的debian下, 编译即可
附件 | 大小 |
---|---|
kernel_2.6.22.8_config.gz | 7.9 千字节 |
antcor_uboot_1.1.3.bin.gz | 78.33 千字节 |
antcor_kernel_2.6.22.8.bin.gz | 1.83 兆字节 |
2.6.28.10_gcc4.4-cq8401.patch.gz | 519.99 千字节 |