大破雑記帳

個人用メモな雑記ブログ いろんなことをざっくりと。

WG600HP & OpenWrt + mainline U-Boot

なんとかここまで来た

WR8750N, WR9500Nも同様にサポート

動作OK

  • SPI (+SPI-NOR)
  • GPIO
  • LED
    • 5カ所全10個全てath9kチップ (AR938x) に接続されている為、利用可能になるのは無線のprobeが走ってから
  • Ethernet
  • WLAN (SoC/PCIe)
    • 認識のみ確認
  • USB
    • ただし内部ハブのRESETがath9kチップ (AR938x) に接続されている関係上、ハブの認識されるタイミングが無線チップのprobe後になる

動作NG

  • WLAN (SoC)
    • 現状何故か機能せずブートが止まる
      • RESETのdeassertが足りていなかったのが原因。QCA955xではath9kドライバによりハンドルされるが、AR934xでは実装が欠落

備考

  • U-BootはNetBSDAterm0x20000 (128KiB) しか無いブートローダ領域に収める為、ネットワークからSPIサポートまでや、コマンド類を最低限のもの以外全て切って徹底的にサイズを落とした。
    • 削る作業が滅茶苦茶キツかった
    • ブートは実質 bootm のみ、復旧の為にイメージを投入する手段は loadb, loadx, loady のみ
    • SPI-NOR内がメモリマップされるので、ファームウェア領域の始点に直接bootmする
    • LZMAGZIPのdecompressionサポートも切った為、LZMA圧縮済kernelの展開はlzma-loaderで実施してU-Bootには未圧縮として渡す
      • lzma-loaderのボードサポート部分では、U-Bootでサイズの関係上入れられていないネットワーク周りなどの構成を行う

bootlog

LuCIを日本語訳無し最低限、USBストレージドライバとvfatドライバを組み込んだビルド

U-Boot 2024.04-OpenWrt-r26058+21-f434643857 (Apr 27 2024 - 05:33:00 +0000)

DRAM:  128 MiB
Core:  5 devices, 4 uclasses, devicetree: separate
Loading Environment from <NULL>... OK
In:    uart@18020000
Out:   uart@18020000
Err:   uart@18020000
Hit any key to stop autoboot:  0 
## Booting kernel from Legacy Image at 9f040000 ...
   Image Name:   MIPS OpenWrt Linux-6.1.86
   Image Type:   MIPS Linux Kernel Image (uncompressed)
   Data Size:    1823309 Bytes = 1.7 MiB
   Load Address: 80060000
   Entry Point:  80060000
   Verifying Checksum ... OK
   Loading Kernel Image to 80060000
NEC Aterm series


OpenWrt kernel loader for AR7XXX/AR9XXX
Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
Decompressing kernel... done!
Starting kernel at 80060000...

[    0.000000] Linux version 6.1.86 (musashino205@TAIHA.NET) (mips-openwrt-linux-musl-gcc (OpenWrt GCC 13.2.0 r26058+37-f434643857) 13.2.0, GNU ld (GNU Binutils) 2.40.0) #0 Sat Apr 27 20:37:45 2024
[    0.000000] printk: bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 0001974c (MIPS 74Kc)
[    0.000000] MIPS: machine is NEC Aterm WG600HP
[    0.000000] SoC: Atheros AR9344 rev 1
[    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-0x0000000007ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 32512
[    0.000000] Kernel command line: console=ttyS0,115200 rootfstype=squashfs,jffs2
[    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
[    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
[    0.000000] Writing ErrCtl register=00000000
[    0.000000] Readback ErrCtl register=00000000
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 122692K/131072K available (4517K kernel code, 541K rwdata, 716K rodata, 1192K init, 195K bss, 8380K 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] CPU clock: 560.000 MHz
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 6825930166 ns
[    0.000001] sched_clock: 32 bits at 280MHz, resolution 3ns, wraps every 7669584382ns
[    0.008767] Calibrating delay loop... 278.93 BogoMIPS (lpj=1394688)
[    0.085702] pid_max: default: 32768 minimum: 301
[    0.091658] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.099851] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.111092] cblist_init_generic: Setting adjustable number of callback queues.
[    0.119162] cblist_init_generic: Setting shift to 0 and lim to 1.
[    0.131449] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.142493] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[    0.150135] pinctrl core: initialized pinctrl subsystem
[    0.158037] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    0.169013] gpio-13 (switch-reset): hogged as output/high
[    0.188174] clocksource: Switched to clocksource MIPS
[    0.195709] NET: Registered PF_INET protocol family
[    0.201522] IP idents hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.210774] tcp_listen_portaddr_hash hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.220285] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.228960] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.237520] TCP bind hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.245429] TCP: Hash tables configured (established 1024 bind 1024)
[    0.252702] UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.260079] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.268293] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    0.274672] PCI: CLS 0 bytes, default 32
[    0.283191] workingset: timestamp_bits=30 max_order=15 bucket_order=0
[    0.296036] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.302613] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.319340] pinctrl-single 1804002c.pinmux: 544 pins, size 68
[    0.327328] Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
[    0.335479] printk: console [ttyS0] disabled
[    0.340415] 18020000.uart: ttyS0 at MMIO 0x18020000 (irq = 11, base_baud = 2500000) is a 16550A
[    0.350196] printk: console [ttyS0] enabled
[    0.350196] printk: console [ttyS0] enabled
[    0.359119] printk: bootconsole [early0] disabled
[    0.359119] printk: bootconsole [early0] disabled
[    0.383583] spi-nor spi0.0: mx25l6405d (8192 Kbytes)
[    0.388865] 4 fixed-partitions partitions found on MTD device spi0.0
[    0.395403] OF: Bad cell count for /ahb/spi@1f000000/flash@0/partitions
[    0.402193] OF: Bad cell count for /ahb/spi@1f000000/flash@0/partitions
[    0.409369] Creating 4 MTD partitions on "spi0.0":
[    0.414297] 0x000000000000-0x000000020000 : "bootloader"
[    0.425703] 0x000000020000-0x000000030000 : "config"
[    0.432064] OF: Bad cell count for /ahb/spi@1f000000/flash@0/partitions
[    0.439249] 0x000000030000-0x000000040000 : "art"
[    0.448072] OF: Bad cell count for /ahb/spi@1f000000/flash@0/partitions
[    0.455261] 0x000000040000-0x000000800000 : "firmware"
[    0.463251] 2 uimage-fw partitions found on MTD device firmware
[    0.469346] Creating 2 MTD partitions on "firmware":
[    0.474445] 0x000000000000-0x0000001be000 : "kernel"
[    0.480602] 0x0000001be000-0x0000007c0000 : "rootfs"
[    0.488698] mtd: setting mtd5 (rootfs) as root device
[    0.493926] 1 squashfs-split partitions found on MTD device rootfs
[    0.500257] 0x0000005ae000-0x0000007c0000 : "rootfs_data"
[    0.854572] switch0: Atheros AR8327 rev. 4 switch registered on mdio.0
[    1.508636] ag71xx 19000000.eth: connected to PHY at mdio.0:00 [uid=004dd034, driver=Atheros AR8216/AR8236/AR8316]
[    1.520107] eth0: Atheros AG71xx at 0xb9000000, irq 4, mode: rgmii
[    1.529621] NET: Registered PF_INET6 protocol family
[    1.543821] Segment Routing with IPv6
[    1.547647] In-situ OAM (IOAM) with IPv6
[    1.551876] NET: Registered PF_PACKET protocol family
[    1.557365] 8021q: 802.1Q VLAN Support v1.8
[    1.584368] PCI host bridge to bus 0000:00
[    1.588585] pci_bus 0000:00: root bus resource [mem 0x10000000-0x13ffffff]
[    1.595585] pci_bus 0000:00: root bus resource [io  0x0000]
[    1.601267] pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
[    1.609382] pci 0000:00:00.0: [168c:0030] type 00 class 0x028000
[    1.615530] pci 0000:00:00.0: reg 0x10: [mem 0x00000000-0x0001ffff 64bit]
[    1.622495] pci 0000:00:00.0: reg 0x30: [mem 0x00000000-0x0000ffff pref]
[    1.629462] pci 0000:00:00.0: supports D1
[    1.633548] pci 0000:00:00.0: PME# supported from D0 D1 D3hot
[    1.641568] pci_bus 0000:00: busn_res: [bus 00-ff] end is updated to 00
[    1.648393] pci 0000:00:00.0: BAR 0: assigned [mem 0x10000000-0x1001ffff 64bit]
[    1.655849] pci 0000:00:00.0: BAR 6: assigned [mem 0x10020000-0x1002ffff pref]
[    1.678212] VFS: Mounted root (squashfs filesystem) readonly on device 31:5.
[    1.690438] Freeing unused kernel image (initmem) memory: 1192K
[    1.696467] This architecture does not have kernel memory protection.
[    1.703044] Run /sbin/init as init process
[    2.445567] init: Console is alive
[    2.449690] init: - watchdog -
[    4.124241] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    4.182561] usbcore: registered new interface driver usbfs
[    4.188353] usbcore: registered new interface driver hub
[    4.193849] usbcore: registered new device driver usb
[    4.230788] SCSI subsystem initialized
[    4.246004] ehci-platform 1b000000.usb: EHCI Host Controller
[    4.251873] ehci-platform 1b000000.usb: new USB bus registered, assigned bus number 1
[    4.259966] ehci-platform 1b000000.usb: irq 3, io mem 0x1b000000
[    4.288199] ehci-platform 1b000000.usb: USB 2.0 started, EHCI 1.00
[    4.295742] hub 1-0:1.0: USB hub found
[    4.300604] hub 1-0:1.0: 1 port detected
[    4.313162] usbcore: registered new interface driver usb-storage
[    4.323185] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    4.341233] init: - preinit -
[    7.838196] random: crng init done
[    9.467510] Atheros AR8216/AR8236/AR8316 mdio.0:00: Port 1 is up
[    9.474283] Atheros AR8216/AR8236/AR8316 mdio.0:00: Port 5 is up
[    9.481854] eth0: link up (1000Mbps/Full duplex)
[    9.502715] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[    9.519507] IPv6: ADDRCONF(NETDEV_CHANGE): eth0.1: link becomes ready
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
[   11.760888] jffs2_scan_eraseblock(): End of filesystem marker found at 0x2000
[   11.768362] jffs2_build_filesystem(): unlocking the mtd device... 
[   11.768392] done.
[   11.776609] jffs2_build_filesystem(): erasing all blocks after the end marker... 
[   14.588608] platform ath9k-leds: deferred probe pending
[   31.220225] done.
[   31.222233] jffs2: notice: (317) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
[   31.239995] mount_root: overlay filesystem has not been fully initialized yet
[   31.253442] mount_root: switching to jffs2 overlay
[   31.262893] overlayfs: upper fs does not support tmpfile.
- config restore -
[   31.900453] urandom-seed: Seed file not found (/etc/urandom.seed)
[   31.954425] eth0: link down
[   31.988429] procd: - early -
[   31.991753] procd: - watchdog -
[   32.627759] procd: - watchdog -
[   32.632646] procd: - ubus -
[   32.707654] procd: - init -
Please press Enter to activate this console.
[   34.025384] kmodloader: loading kernel modules from /etc/modules.d/*
[   34.671682] Loading modules backported from Linux version v6.6.15-0-g51f354b815c4
[   34.679351] Backport generated by backports.git 193becf2
[   35.181601] PPP generic driver version 2.4.2
[   35.199452] NET: Registered PF_PPPOX protocol family
[   35.338436] ieee80211 phy0: Atheros AR9340 Rev:1 mem=0x5efd72e6, irq=14
[   35.345657] ath9k 0000:00:00.0: enabling device (0000 -> 0002)
[   35.369476] gpio-506 (usb-hub-reset): hogged as output/high
[   35.375581] ieee80211 phy1: Atheros AR9300 Rev:3 mem=0xdd091c5a, irq=17
[   35.548704] kmodloader: done loading kernel modules from /etc/modules.d/*
[   35.738257] usb 1-1: new high-speed USB device number 2 using ehci-platform
[   35.962346] hub 1-1:1.0: USB hub found
[   35.978312] hub 1-1:1.0: 4 ports detected
[   37.122347] urngd: v1.0.2 started.
[   63.227717] eth0: link up (1000Mbps/Full duplex)
[   63.246282] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   63.279047] br-lan: port 1(eth0.1) entered blocking state
[   63.284567] br-lan: port 1(eth0.1) entered disabled state
[   63.290496] device eth0.1 entered promiscuous mode
[   63.295384] device eth0 entered promiscuous mode
[   63.357619] br-lan: port 1(eth0.1) entered blocking state
[   63.363191] br-lan: port 1(eth0.1) entered forwarding state
[   64.268812] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready



BusyBox v1.36.1 (2024-04-27 16:13:55 UTC) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt SNAPSHOT, r26058+38-f434643857
 -----------------------------------------------------
=== 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:/# ubus call system board
{
        "kernel": "6.1.86",
        "hostname": "OpenWrt",
        "system": "Atheros AR9344 rev 1",
        "model": "NEC Aterm WG600HP",
        "board_name": "nec,wg600hp",
        "rootfs_type": "squashfs",
        "release": {
                "distribution": "OpenWrt",
                "version": "SNAPSHOT",
                "revision": "r26058+38-f434643857",
                "target": "ath79/tiny",
                "description": "OpenWrt SNAPSHOT r26058+38-f434643857"
        }
}
root@OpenWrt:/# ubus call system info
{
        "localtime": 1714250895,
        "uptime": 211,
        "load": [
                10240,
                18496,
                8640
        ],
        "memory": {
                "total": 126857216,
                "free": 90873856,
                "shared": 184320,
                "buffered": 0,
                "available": 75001856,
                "cached": 16924672
        },
        "root": {
                "total": 2120,
                "free": 1980,
                "used": 140,
                "avail": 1980
        },
        "tmp": {
                "total": 61940,
                "free": 61760,
                "used": 180,
                "avail": 61760
        },
        "swap": {
                "total": 0,
                "free": 0
        }
}
root@OpenWrt:/# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 3.9M      3.9M         0 100% /rom
tmpfs                    60.5M    180.0K     60.3M   0% /tmp
/dev/mtdblock6            2.1M    140.0K      1.9M   7% /overlay
overlayfs:/overlay        2.1M    140.0K      1.9M   7% /
tmpfs                   512.0K         0    512.0K   0% /dev
root@OpenWrt:/#