代码是很早之前下载的具体貌似忘了怎么下的,大致是
1 2 3 4 5 6 7 | $ git clone https: //git .openwrt.org /openwrt/openwrt .git/ $ cd openwrt $ . /scripts/feeds update -a $ . /scripts/feeds install -a $ make menuconfig |
合并ptpt上传到github官方的K2t patch
https://github.com/openwrt/openwrt/pull/1031
由于ath79已经包含了k2t的支持,所以该patch被拒绝了,我们可以手动合入。
commented on Jun 19
ath79 support for this device is already merged so I think adding it's support for the old ar71xx is not necessary now.
执行:
1 | $ make |
编译完毕后,在build_dir/target-mips_24kc_musl/linux-ar71xx_generic/目录有
k2t-kernel.bin
root.squashfs-64k
两个文件,前者是内核,后者是rootfs。
启动k2t,进入u-boot,上传并启动内核:
1 2 3 4 | setenv ipaddr 192.168.1.123 setenv serverip 192.168.1.100 tftp 82000000 k2t-kernel.bin bootm 82000000 |
注意:bootm启动的是u-boot uImage格式的镜像,有一个0x40大小的头,包含镜像名称,类型,压缩类型等。可能是内核自解压,也可能是u-boot负责解压。这里要非常主要的是,加载到内存的地址不要是内核运行的地址有重叠区域,比如
1 2 3 4 5 6 7 8 9 10 | ath> bootm 82000000 ## Booting image at 82000000 ... Image Name: MIPS OpenWrt Linux-4.9.123 Created: 2018-08-22 11:47:13 UTC Image Type: MIPS Linux Kernel Image (lzma compressed) Data Size: 1479756 Bytes = 1.4 MB Load Address: 80060000 Entry Point: 80060000 Verifying Checksum at 0x82000040 ...OK Uncompressing Kernel Image ... OK |
运行地址在80060000,那么加载地址不要覆盖这个地址,否则会解压失败。
启动发现cmdline是:
Kernel command line: board=K2T mtdparts=spi0.0:192k(u-boot)ro,64k(config)ro,320k(permanent),15744k(firmware),64k(art)ro console=ttyS0,115200 rootfstype=squashfs noinitrd
内核找不到rootfs,查找原因是,OpenWrt禁止了从u-boot传递参数,这个参数是OpenWrt编译时,传递到内核的。修改target/linux/ar71xx/image/generic.mk 文件:
MTDPARTS := spi0.0:192k(u-boot)ro,64k(config)ro,320k(permanent),1152k(kernel),14592k(rootfs),64k(art)ro
将rootfs写入到rootfs分区
1 2 3 4 5 | ath> tftp 80000000 root.squashfs-64k ath> erase 0x9f1b0000 +0xe40000 ath> cp.b $fileaddr 0x9f1b0000 $filesize ath> tftp 82000000 k2t-kernel.bin ath> bootm 82000000 |
启动log:
ath> bootm 82000000
## Booting image at 82000000 ...
Image Name: MIPS OpenWrt Linux-4.9.123
Created: 2018-08-22 11:47:13 UTC
Image Type: MIPS Linux Kernel Image (lzma compressed)
Data Size: 1479660 Bytes = 1.4 MB
Load Address: 80060000
Entry Point: 80060000
Verifying Checksum at 0x82000040 ...OK
Uncompressing Kernel Image ... OK
No initrd
## Transferring control to Linux (at address 80060000) ...
## Giving linux memsize in bytes, 67108864
Starting kernel ...
[ 0.000000] Linux version 4.9.123 (herbert@herbert-pc) (gcc version 7.3.0 (OpenWrt GCC 7.3.0 r7904-6b4ba11) ) #0 Wed Aug 22 11:47:13 2018
[ 0.000000] bootconsole [early0] enabled
[ 0.000000] CPU0 revision is: 00019750 (MIPS 74Kc)
[ 0.000000] SoC: Qualcomm Atheros QCA956X ver 1 rev 0
[ 0.000000] Determined physical RAM map:
[ 0.000000] memory: 04000000 @ 00000000 (usable)
[ 0.000000] Initrd not found or empty - disabling initrd
[ 0.000000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
[ 0.000000] Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
[ 0.000000] Zone ranges:
[ 0.000000] Normal [mem 0x0000000000000000-0x0000000003ffffff]
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000000000000-0x0000000003ffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000003ffffff]
[ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
[ 0.000000] Kernel command line: board=K2T mtdparts=spi0.0:192k(u-boot)ro,64k(config)ro,320k(permanent),1152k(kernel),14592k(rootfs),64k(art)ro console=ttyS0,115200 rootfstype=squashfs noinitrd
[ 0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[ 0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[ 0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[ 0.000000] Writing ErrCtl register=00000000
[ 0.000000] Readback ErrCtl register=00000000
[ 0.000000] Memory: 59640K/65536K available (3362K kernel code, 165K rwdata, 812K rodata, 324K init, 213K bss, 5896K reserved, 0K cma-reserved)
[ 0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] NR_IRQS:51
[ 0.000000] Clocks: CPU:775.000MHz, DDR:650.000MHz, AHB:258.333MHz, Ref:25.000MHz
[ 0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 4932285024 ns
[ 0.000007] sched_clock: 32 bits at 387MHz, resolution 2ns, wraps every 5541893118ns
[ 0.008217] Calibrating delay loop... 385.84 BogoMIPS (lpj=1929216)
[ 0.071033] pid_max: default: 32768 minimum: 301
[ 0.075980] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.082956] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.092650] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[ 0.103054] futex hash table entries: 256 (order: -1, 3072 bytes)
[ 0.109958] NET: Registered protocol family 16
[ 0.115903] MIPS: machine is Phicomm K2T A1/A2/A3 board
[ 0.355041] registering PCI controller with io_map_base unset
[ 0.372937] PCI host bridge to bus 0000:00
[ 0.377310] pci_bus 0000:00: root bus resource [mem 0x12000000-0x13ffffff]
[ 0.384545] pci_bus 0000:00: root bus resource [io 0x0001]
[ 0.390423] pci_bus 0000:00: root bus resource [??? 0x00000000 flags 0x0]
[ 0.397567] pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
[ 0.406285] pci 0000:00:00.0: BAR 0: assigned [mem 0x12000000-0x121fffff 64bit]
[ 0.414005] pci 0000:00:00.0: using irq 40 for pin 1
[ 0.419828] clocksource: Switched to clocksource MIPS
[ 0.426019] NET: Registered protocol family 2
[ 0.431302] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.438650] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.445395] TCP: Hash tables configured (established 1024 bind 1024)
[ 0.452187] UDP hash table entries: 256 (order: 0, 4096 bytes)
[ 0.458348] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[ 0.465208] NET: Registered protocol family 1
[ 0.473927] Crashlog allocated RAM at address 0x3f00000
[ 0.480451] workingset: timestamp_bits=30 max_order=14 bucket_order=0
[ 0.492723] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 0.498867] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[ 0.517145] io scheduler noop registered
[ 0.521315] io scheduler deadline registered (default)
[ 0.526996] Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
[ 0.534053] console [ttyS0] disabled
[ 0.557889] serial8250.0: ttyS0 at MMIO 0x18020000 (irq = 11, base_baud = 1562500) is a 16550A
[ 0.566984] console [ttyS0] enabled
[ 0.566984] console [ttyS0] enabled
[ 0.574533] bootconsole [early0] disabled
[ 0.574533] bootconsole [early0] disabled
[ 0.586181] m25p80 spi0.0: found gd25q128, expected m25p80
[ 0.593977] m25p80 spi0.0: gd25q128 (16384 Kbytes)
[ 0.598949] 6 cmdlinepart partitions found on MTD device spi0.0
[ 0.605091] Creating 6 MTD partitions on "spi0.0":
[ 0.610057] 0x000000000000-0x000000030000 : "u-boot"
[ 0.616825] 0x000000030000-0x000000040000 : "config"
[ 0.623704] 0x000000040000-0x000000090000 : "permanent"
[ 0.630857] 0x000000090000-0x0000001b0000 : "kernel"
[ 0.637661] 0x0000001b0000-0x000000ff0000 : "rootfs"
[ 0.644145] mtd: device 4 (rootfs) set to be root filesystem
[ 0.650093] 1 squashfs-split partitions found on MTD device rootfs
[ 0.656483] 0x000000420000-0x000000ff0000 : "rootfs_data"
[ 0.663864] 0x000000ff0000-0x000001000000 : "art"
[ 0.671266] libphy: Fixed MDIO Bus: probed
[ 0.686623] switch0: Atheros AR8337 rev. 2 switch registered on ag71xx-mdio.0
[ 1.377871] libphy: ag71xx_mdio: probed
[ 2.011287] ag71xx ag71xx.0: connected to PHY at ag71xx-mdio.0:00 [uid=004dd036, driver=Atheros AR8216/AR8236/AR8316]
[ 2.022846] eth0: Atheros AG71xx at 0xb9000000, irq 4, mode:SGMII
[ 2.030439] NET: Registered protocol family 10
[ 2.037829] NET: Registered protocol family 17
[ 2.042602] 8021q: 802.1Q VLAN Support v1.8
[ 2.052958] VFS: Mounted root (squashfs filesystem) readonly on device 31:4.
[ 2.062040] Freeing unused kernel memory: 324K
[ 2.066626] This architecture does not have kernel memory protection.
[ 2.569876] random: fast init done
[ 2.737174] init: Console is alive
[ 2.740930] init: - watchdog -
[ 3.735061] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[ 3.776681] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[ 3.785470] init: - preinit -
[ 4.381417] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 4.404530] random: procd: uninitialized urandom read (4 bytes read)
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[ 5.391236] eth0: link up (1000Mbps/Full duplex)
[ 5.396216] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 7.637266] mount_root: jffs2 not ready yet, using temporary tmpfs overlay
[ 7.664144] urandom-seed: Seed file not found (/etc/urandom.seed)
[ 7.746022] eth0: link down
[ 7.758529] procd: - early -
[ 7.762183] procd: - watchdog -
[ 8.352383] procd: - watchdog -
[ 8.355846] procd: - ubus -
[ 8.390946] random: ubusd: uninitialized urandom read (4 bytes read)
[ 8.441861] random: ubusd: uninitialized urandom read (4 bytes read)
[ 8.448836] random: ubusd: uninitialized urandom read (4 bytes read)
[ 8.456232] procd: - init -
Please press Enter to activate this console.
[ 8.698538] kmodloader: loading kernel modules from /etc/modules.d/*
[ 8.708948] ip6_tables: (C) 2000-2006 Netfilter Core Team
[ 8.724466] Loading modules backported from Linux version wt-2017-11-01-0-gfe248fc2c180
[ 8.732783] Backport generated by backports.git v4.14-rc2-1-31-g86cf0e5d
[ 8.742603] ip_tables: (C) 2000-2006 Netfilter Core Team
[ 8.754888] nf_conntrack version 0.5.0 (1024 buckets, 4096 max)
[ 8.806506] xt_time: kernel timezone is -0000
[ 8.860791] PPP generic driver version 2.4.2
[ 8.867348] NET: Registered protocol family 24
[ 8.893224] PCI: Enabling device 0000:00:00.0 (0000 -> 0002)
[ 8.899373] ath10k_pci 0000:00:00.0: pci irq legacy oper_irq_mode 1 irq_mode 0 reset_mode 0
[ 9.091691] ath10k_pci 0000:00:00.0: Direct firmware load for ath10k/pre-cal-pci-0000:00:00.0.bin failed with error -2
[ 9.102776] ath10k_pci 0000:00:00.0: Falling back to user helper
[ 9.389967] ath10k_pci 0000:00:00.0: Direct firmware load for ath10k/QCA9888/hw2.0/firmware-6.bin failed with error -2
[ 9.401040] ath10k_pci 0000:00:00.0: Falling back to user helper
[ 9.498067] firmware ath10k!QCA9888!hw2.0!firmware-6.bin: firmware_loading_store: map pages failed
[ 10.104524] ath10k_pci 0000:00:00.0: qca9888 hw2.0 target 0x01000000 chip_id 0x00000000 sub 0000:0000
[ 10.114091] ath10k_pci 0000:00:00.0: kconfig debug 0 debugfs 1 tracing 0 dfs 1 testmode 1
[ 10.134585] ath10k_pci 0000:00:00.0: firmware ver 10.4-3.5.3-00053 api 5 features no-p2p,mfp,peer-flow-ctrl,allows-mesh-bcast,no-ps crc32 a9603656
[ 10.482164] ath10k_pci 0000:00:00.0: board_file api 2 bmi_id 0:18 crc32 d65c17b1
[ 12.641850] ath10k_pci 0000:00:00.0: htt-ver 2.2 wmi-op 6 htt-op 4 cal pre-cal-file max-sta 512 raw 0 hwcrypto 1
[ 12.803191] ath9k qca956x_wmac: Direct firmware load for soc_wmac.eeprom failed with error -2
[ 12.812043] ath9k qca956x_wmac: Falling back to user helper
[ 13.510328] ieee80211 phy1: Atheros AR9561 Rev:0 mem=0xb8100000, irq=47
[ 13.542444] kmodloader: done loading kernel modules from /etc/modules.d/*
[ 13.919234] urandom_read: 5 callbacks suppressed
[ 13.919241] random: jshn: uninitialized urandom read (4 bytes read)
[ 20.570963] jffs2_scan_eraseblock(): End of filesystem marker found at 0x0
[ 20.578088] jffs2_build_filesystem(): unlocking the mtd device... [ 20.613756] done.
[ 20.615763] jffs2_build_filesystem(): erasing all blocks after the end marker... [ 24.171492] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 24.214232] br-lan: port 1(eth0.1) entered blocking state
[ 24.219872] br-lan: port 1(eth0.1) entered disabled state
[ 24.225781] device eth0.1 entered promiscuous mode
[ 24.230771] device eth0 entered promiscuous mode
[ 24.332945] IPv6: ADDRCONF(NETDEV_UP): br-lan: link is not ready
[ 24.410778] IPv6: ADDRCONF(NETDEV_UP): eth0.2: link is not ready
[ 25.231441] eth0: link up (1000Mbps/Full duplex)
[ 25.236330] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 25.319960] br-lan: port 1(eth0.1) entered blocking state
[ 25.325546] br-lan: port 1(eth0.1) entered forwarding state
[ 25.331477] IPv6: ADDRCONF(NETDEV_CHANGE): eth0.2: link becomes ready
[ 25.492613] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
BusyBox v1.29.2 () built-in shell (ash)
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
OpenWrt SNAPSHOT, r7904-6b4ba11
-----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:/#