::log.2009

[ TOP | Recently ]

NetWalker / STR9102その7 / itojun / STR9105その6.5 - have a *BREAK* / STR9105その6 - PCI config register / STR9105その5 / STR9105その4 / STR9105その3 / STR9105その2 / i.MX memo / MZK-W04G / STR9105その1 / STR8132その9 - GPIO と watchdog / STR8132その8 - mac address と flash と SPI / STR8132その7 - RTC / STR8132その6 / STR8132その5 / Sheeva Plug Serial / Sheeva Plug / STR8100/STR9100デバイスまとめ / Eye-Fi / 00:aa:bb:cc:dd:10 / ICMP6 / Embedded PHY / gcc -fno-delete-null-pointer-checks / cpu_initclocks / TWR-350 / mountroot / copyright / pmap / panic / STR8132その4 / STR8132 その3 / STR8132 その2 / AIR BONE ZT-351 / NetBSD src/usr.sbin/inetd / simple twitter client / /usr/bin/top: show full commandline patch / Hashed and Hierarchical Timing Wheels / canvasで遊ぶ / timetable queue

2009-12-28 NetWalker


発売日に買ってたんだけど普通にX端末として使っていたNetWalker。
i.MX51 の pdf も既に公開されているので、 RedBoot(Linuxのdmesgでわかる)に落ちることさえできれば任意バイナリbootできるようになって、あとはNetBSD移植は単なる作業かなぁと思ってたんだけど、 数ヶ月経ってもORCA愉快日記氏とこ以上の分解を誰もやってくれないようなので、しょうがなく自分で開腹。

基板表

基板裏

基板SDカードスロットおよび電源まわり

基板裏、SDカードスロット横の4つのランドがシリアルだった。写真ではコネクタ取り付け改造済。
SDスロットに近い順から VCC, TXD, GND, RXD RXD, TXD, GND, VCC の順。ADM3202 経由で 115200bps で繋がる。
(配線間違っていたので修正しました! Thanks to @h_kenken)


しかし通常状態だと電源ONしてもいきなり flash から Linux kernel の inflate が始まってしまってシリアルからは何もできない。
こんな感じ

基板表のディップスイッチを UART-1 HHLLLLHH にしたらbootloaderに落ちるかなと思ったら、そもそもブートしなくなった。なんじゃそりゃ。
というかそもそも UART-1 も USB-OTG も HHLLLLHH になっててよくわからないなぁ。

左右ボタン両押し状態でのリカバリSDからのブートだと何か変わるかと思って試してみたが、 SDからbootしてるっぽいだけでほとんど変わらず…。うーむ。

2009-12-02 STR9102その7


微妙に忙しくてサボっていたがちょっとだけ復活。
STR9105のCWR-635Mがぶっこわれたので、STR9102のPLANEX MZK-W04Gを使って作業を続けようとしていた所でSuspendしていた。

MZK-W04GはSTR9102の内蔵PHYではなくスイッチを別に積んでいるのでそのへんに対応。
これはあっさりできた。内蔵PHYの設定をすっとばす程度でほとんど動いた。

MZK-W04G で作業するようになってから、謎のメモリ壊れる問題がまったく再現しなくなった。やっぱりハードかよ…

ral (RT2561C) を付けて PCI を動かそうとしているが、どうもPCIの割り込みが入らない。
ifconfig ral0 up すると ral0: device timeout となる。どうも up した直後から beacon を送信するが、送信完了割り込みが入ってこずに ifnet が device timeout してるようだ。
割り込みが入らないのは star_pci 側の問題かと思って一ヶ月くらい試行錯誤していたのだが、if_ral の中で ral 自信の割り込みステータスレジスタを表示するようにしても、一向に割り込みがかかっている様子がない。
PCI device が割り込みを出していないんじゃしょうがないなぁ、と思いつつ、ふと ifconfig ral0 mediaopt adhoc とすると割り込みが入った。豪謎。
つまり star_pci 側は問題なかったようだ。ral のせい??? そんなバカな。

別のデバイスではどうかと思って、秋葉原で1000円で買ってきた iwi で試すが、こちらは firmware load の所で timeout となってエラーになる。
同じく割り込みが入ってないんだろう。

なんかよくわからないなぁ…。一度適当なマシンで ral や iwi の正常な動作を把握しないとダメっぽい。
というわけで、こんなこともあろうかと買っておいたALIXが役に立つ日がやっと来たのだった

(つづく)

2009-10-29 itojun


墓参り。


おまけ。管理事務所に住んでいる(?)眠そうな猫。

2009-10-18 STR9105その6.5 - have a *BREAK*


TWR-350 が突然ブートしなくなった。電源を入れなおすと一瞬LEDが付くが、その後完全に沈黙する。シリアルにも何も出ない。
ググると故障報告がチラホラ。故障率高いのか? どうもダメハードっぽい。

というわけで続きは、こんなこともあろうかと買っておいたW04G (CPU:STR9102) でやればいいのだが、 こいつはNICのPHYがCPU内蔵PHYではなくVitesseのvsc7385というphyを使っているので、 またドライバに手を入れないといけなかったのであった。諸行無常。

しかもVSC7385のpdfを拾おうと思ってレジストレーションしたら、さらにNDAがどうのこうので契約しないと読めなかった。個人情報返せfuck you!!!11
いろいろ探してたらLinuxのSTR9100のソースの中に初期化コードがあったのでこれをパク参考にすればでいけるかね。


どうでもいいけどLinuxのぜんぜん統合できてないマイナーなarchのソースの探しにくさはどうにかならないものか。

2009-10-16 STR9105その6 - PCI config register


PCI config base address register に write しても書けなかったのは、PCI tag の作り方が間違ってたからというアホなミスだった。

データシートに

31 RW Enable
30:24 RW Reserved
23:16 RW Bus number
15:11 RW Device number
10:8 RW Function number
7:2 RW Register number
1:0 RW Reserved

と書いてあったので、思わず

bus_space_write_4(sc->sc_iot, sc->sc_ioh_addr, 0,
    0x80000000 | tag | (reg << 2));

としてしまったのですよ。
本当はレジスタは4の倍数しか受けつけないというだけなので

bus_space_write_4(sc->sc_iot, sc->sc_ioh_addr, 0,
    0x80000000 | tag | reg);

が正解。今は後悔している。

上のバグコードでも register 0 の PCI vendor/PCI product は正常に読めてしまうので気づくのに時間がかかった…
よく見たら以前の PCI_CONFIG_DUMP の値がめちゃくちゃだな。ここで気づけよ>俺

というわけで修正するとpci deviceのattachまで来た。

	:
starpci0 at star0 addr 0xa0000000-0xa0000003 irq 8: PCI Host Bridge
pci0 at starpci0
unknown vendor 0xeeee product 0x0000 (undefined subclass 0x00) at pci0 dev 0 function 0: PCI configuration registers:
  Common header:
    0x00: 0x0000eeee 0x04000147 0xff000000 0x0000ff04

    Vendor ID: 0xeeee
    Device ID: 0x0000
    Command register: 0x0147
      I/O space accesses: on
      Memory space accesses: on
      Bus mastering: on
      Special cycles: off
      MWI transactions: off
      Palette snooping: off
      Parity error checking: on
      Address/data stepping: off
      System error (SERR): on
      Fast back-to-back transactions: off
      Interrupt disable: off
    Status register: 0x0400
      Capability List support: off
      66 MHz capable: off
      User Definable Features (UDF) support: off
      Fast back-to-back capable: off
      Data parity error detected: off
      DEVSEL timing: slow (0x2)
      Slave signaled Target Abort: off
      Master received Target Abort: off
      Master received Master Abort: off
      Asserted System Error (SERR): off
      Parity error detected: off
    Class Name: undefined (0xff)
    Subclass ID: 0x00
    Interface: 0x00
    Revision ID: 0x00
    BIST: 0x00
    Header Type: 0x00 (0x00)
    Latency Timer: 0xff
    Cache Line Size: 0x04

  Type 0 ("normal" device) header:
    0x10: 0x00000000 0xa8000001 0x00000000 0x00000000
    0x20: 0x00000000 0x00000000 0x00000000 0x0000eeee
    0x30: 0x00000000 0x00000000 0x00000000 0x00000000

    Base address register at 0x10
      not implemented(?)
    Base address register at 0x14
      type: 32-bit i/o
      base: 0xa8000000, size: 0x01000000
    Base address register at 0x18
      not implemented(?)
    Base address register at 0x1c
      not implemented(?)
    Base address register at 0x20
      not implemented(?)
    Base address register at 0x24
      not implemented(?)
    Cardbus CIS Pointer: 0x00000000
    Subsystem vendor ID: 0xeeee
    Subsystem ID: 0x0000
    Expansion ROM Base Address: 0x00000000
    Reserved @ 0x34: 0x00000000
    Reserved @ 0x38: 0x00000000
    Maximum Latency: 0x00
    Minimum Grant: 0x00
    Interrupt pin: 0x00 (none)
    Interrupt line: 0x00

  Device-dependent header:
    0x40: 0x00000000 0x00000000 0x00000000 0x00000000
    0x50: 0x00000000 0x00000000 0x00000000 0x00000000
    0x60: 0x00000000 0x00000000 0x00000000 0x00000000
    0x70: 0x00000000 0x00000000 0x00000000 0x00000000
    0x80: 0x00000000 0x00000000 0x00000000 0x00000000
    0x90: 0x00000000 0x00000000 0x00000000 0x00000000
    0xa0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xb0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xc0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xd0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xe0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xf0: 0x00000000 0x00000000 0x00000000 0x00000000

    Don't know how to pretty-print device-dependent header.

unknown vendor 0xeeee product 0x0000 (undefined subclass 0x00) at pci0 dev 0 function 0 (intrswiz 0, intrpin 0, i/o on, mem on, no quirks) not configured
ral0 at pci0 dev 2 function 0: PCI configuration registers:
  Common header:
    0x00: 0x03021814 0x04100147 0x02800000 0x0000ff04

    Vendor Name: Ralink Technologies (0x1814)
    Device Name: RT2561 802.11b/g (0x0302)
    Command register: 0x0147
      I/O space accesses: on
      Memory space accesses: on
      Bus mastering: on
      Special cycles: off
      MWI transactions: off
      Palette snooping: off
      Parity error checking: on
      Address/data stepping: off
      System error (SERR): on
      Fast back-to-back transactions: off
      Interrupt disable: off
    Status register: 0x0410
      Capability List support: on
      66 MHz capable: off
      User Definable Features (UDF) support: off
      Fast back-to-back capable: off
      Data parity error detected: off
      DEVSEL timing: slow (0x2)
      Slave signaled Target Abort: off
      Master received Target Abort: off
      Master received Master Abort: off
      Asserted System Error (SERR): off
      Parity error detected: off
    Class Name: network (0x02)
    Subclass Name: miscellaneous (0x80)
    Interface: 0x00
    Revision ID: 0x00
    BIST: 0x00
    Header Type: 0x00 (0x00)
    Latency Timer: 0xff
    Cache Line Size: 0x04

  Type 0 ("normal" device) header:
    0x10: 0xb0000000 0x00000000 0x00000000 0x00000000
    0x20: 0x00000000 0x00000000 0x00000601 0x922116ef
    0x30: 0x00000000 0x00000040 0x00000000 0x00000100

    Base address register at 0x10
      type: 32-bit nonprefetchable memory
      base: 0xb0000000, size: 0x00008000
    Base address register at 0x14
      not implemented(?)
    Base address register at 0x18
      not implemented(?)
    Base address register at 0x1c
      not implemented(?)
    Base address register at 0x20
      not implemented(?)
    Base address register at 0x24
      not implemented(?)
    Cardbus CIS Pointer: 0x00000601
    Subsystem vendor ID: 0x16ef
    Subsystem ID: 0x9221
    Expansion ROM Base Address: 0x00000000
    Capability list pointer: 0x40
    Reserved @ 0x38: 0x00000000
    Maximum Latency: 0x00
    Minimum Grant: 0x00
    Interrupt pin: 0x01 (pin A)
    Interrupt line: 0x00

  Capability register at 0x40
    type: 0x01 (Power Management, rev. 1.0)

  PCI Power Management Capabilities Register
    Capabilities register: 0x0002
      Version: 1.1
      PME# clock: off
      Device specific initialization: off
      3.3V auxiliary current: self-powered
      D1 power management state support: off
      D2 power management state support: off
      PME# support: 0x00
    Control/status register: 0x0000
      Power state: D0
      PCI Express reserved: off
      No soft reset: off
      PME# assertion disabled
      PME# status: off

  Device-dependent header:
    0x40: 0x00020001 0x00000000 0x00000000 0x00000000
    0x50: 0x00000000 0x00000000 0x00000000 0x00000000
    0x60: 0x00000000 0x00000000 0x00000000 0x00000000
    0x70: 0x00000000 0x00000000 0x00000000 0x00000000
    0x80: 0x00000000 0x00000000 0x00000000 0x00000000
    0x90: 0x00000000 0x00000000 0x00000000 0x00000000
    0xa0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xb0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xc0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xd0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xe0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xf0: 0x00000000 0x00000000 0x00000000 0x00000000

    Don't know how to pretty-print device-dependent header.

Ralink Technologies RT2561 802.11b/g (miscellaneous network) at ? dev 2 function 0 (intrswiz 0, intrpin 0x1, i/o on, mem on, no quirks): Ralink Technologies RT2561 802.11b/g (rev. 0x00)
ral0: interrupting at pin 1
ral0: 802.11 address 00:d0:41:b0:ff:32
ral0: MAC/BBP RT2561C, RF RT2527
ral0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
ral0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps
~#Stopped in pid 0.1 (system) at  netbsd:cpu_Debugger+0x4:        mov     r15, r14

db> bt
netbsd:comintr+0x10
        scp=0xc001bb94 rlv=0xc019f2dc (netbsd:star_intr_dispatch+0x134)
        rsp=0xc03d8f08 rfp=0xc03d8f34
        r10=0xfffffbff r9=0xc03015e8
        r8=0x00000400 r7=0x00000100 r6=0xc1114fe0 r5=0xc03d8f38
        r4=0xa00000d3
netbsd:star_intr_dispatch+0x10
        scp=0xc019f1b8 rlv=0xc00c6770 (netbsd:irq_entry+0x70)
        rsp=0xc03d8f38 rfp=0xc03d8f9c
        r10=0xc03015e8 r9=0x000368b8
        r8=0x00000000 r7=0x000368b8 r6=0x00000000 r5=0x00000002
        r4=0xc03015e8
netbsd:cpu_configure+0x10
        scp=0xc000c3fc rlv=0xc00a9b9c (netbsd:main+0x180)
        rsp=0xc03d8fa0 rfp=0xc03d8fec
        r4=0x20008134
netbsd:main+0x10
        scp=0xc00a9a2c rlv=0xc0008220 (netbsd:kernel_text+0x3c)
        rsp=0xc03d8ff0 rfp=0xc03d8ffc
        r10=0x00000000 r9=0x000368b8
        r8=0x00000000 r7=0x000368b8 r6=0x0003661c r5=0x00000002
        r4=0x20008134
netbsd:kernel_text+0x3c
        scp=0xc0008220 rlv=0xc019fc14 (netbsd:initarm+0x794)
        rsp=0xc03d9000 rfp=0x00000000
db> 

ral0 を attach した直後で止まった。PCIの割り込みまわりっぽいな。

2009-10-11 STR9105その5


稀にメモリがぶっ壊れるのはどうもドライバのバグとかではなくて、そもそもTWR-350自体が不安定っぽい。 というのは、evbarm/gemini/gemini_machdep.c がやっているように、pmap_map_chunk(〜, VM_PROT_READ|VM_PROT_EXECUTE, 〜) で kernel text 領域を read only にしたのだが、それでもたまに化けることがあるのだ。write protect が機能しているのは確認済み。 DMA のせいかと思っていろいろ試してみたが、DMAを全く使っていない状態でもメモリが壊れることがあったので、やはりDMAでもないだろう。 と言っても最初から入っているLinuxはバカスカ落ちる訳でもなく安定して動いているので、やっぱりNetBSDが何かおかしいんだろうなぁ。 STR8100/9100はパワーマネージメントレジスタで各種クロックやレギュレータの電圧までソフトでコントロールできるので、そのへんの設定が足りないのではなかろうか。 とりあえずいろいろいじって今はそこそこ安定してるので後回し。

というわけで、いろいろ手間取っているがPCIを動かすのである。とりあえず pci config が読めるまで動いた。まだ mapping とか書いてないので pci device の attach が失敗してるけど。
とりあえず dmesg。あいかわらず PCI Vendor ID がふざけた値。

NetBSD/evbarm STR8100/9100
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 5.99.20 (STR91xx) #469: Sun Oct 11 04:25:29 JST 2009
        ryo@falsie:/src/cvs/NetBSD/sys/arch/evbarm/compile/STR91xx
total memory = 32768 KB
avail memory = 27588 KB
mainbus0 (root)
cpu0 at mainbus0: FA526 rev 1 (ARMv4 core)
cpu0: DC enabled IC enabled WB enabled LABT
cpu0: 16KB/16B 2-way Instruction cache
cpu0: 16KB/16B 2-way write-back-locking-B Data cache
star0 at mainbus0: Star Orion Family SoC: STR9100, 200MHz
starclk0 at star0 addr 0x79000000-0x79000047 irq 0: Programmable Timer
com0 at star0 addr 0x78000000-0x7800001f irq 10: ns16550a, working fifo
com0: console
ohci0 at star0 addr 0xc4000000-0xc400005b irq 23: USB1.1 Host Controller
ohci0:  OHCI version 1.0, legacy support
usb0 at ohci0: USB revision 1.0
ehci0 at star0 addr 0xcc000000-0xcc00006b irq 24: USB2.0 Host Controller
ehci0: ohci or uhci probably not configured
usb1 at ehci0: USB revision 2.0
starrtc0 at star0 addr 0x7b000000-0x7b000037 irq 14: Real-time Clock
starwdog0 at star0 addr 0x7a000000-0x7a00001b irq 3: Watch Dog Timer
stargpio0 at star0 addr 0x7c000000-0x7c000047 irq 4: GPIO
gpio0 at stargpio0: 32 pins
gsec0 at star0 addr 0x70000000-0x7000029b irq 18: Gigabit Switch Engine
gse0 at gsec0 port0
gse0: Ethernet address 00:08:a1:c0:45:7e
ukphy0 at gse0 phy 0: OUI 0x0009c3, model 0x0005, rev. 4
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
gse1 at gsec0 port1
gse1: Ethernet address 00:08:a1:c0:45:7f
ukphy1 at gse1 phy 1: OUI 0x0009c3, model 0x0005, rev. 4
ukphy1: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
starpci0 at star0 addr 0xa0000000-0xa0000003 irq 8: PCI Host Bridge
pci0 at starpci0
unknown vendor 0xeeee product 0x0000 (miscellaneous prehistoric) at pci0 dev 0 function 0: PCI configuration registers:
  Common header:
    0x00: 0x0000eeee 0xf0000000 0x00000000 0x00000000

    Vendor ID: 0xeeee
    Device ID: 0x0000
    Command register: 0x0000
      I/O space accesses: off
      Memory space accesses: off
      Bus mastering: off
      Special cycles: off
      MWI transactions: off
      Palette snooping: off
      Parity error checking: off
      Address/data stepping: off
      System error (SERR): off
      Fast back-to-back transactions: off
      Interrupt disable: off
    Status register: 0xf000
      Capability List support: off
      66 MHz capable: off
      User Definable Features (UDF) support: off
      Fast back-to-back capable: off
      Data parity error detected: off
      DEVSEL timing: fast (0x0)
      Slave signaled Target Abort: off
      Master received Target Abort: on
      Master received Master Abort: on
      Asserted System Error (SERR): on
      Parity error detected: on
    Class Name: prehistoric (0x00)
    Subclass Name: miscellaneous (0x00)
    Interface: 0x00
    Revision ID: 0x00
    BIST: 0x00
    Header Type: 0x00 (0x00)
    Latency Timer: 0x00
    Cache Line Size: 0x00

  Type 0 ("normal" device) header:
    0x10: 0x00000000 0x00000000 0x00000000 0x00000000
    0x20: 0x00000000 0x00000000 0x00000000 0x00000000
    0x30: 0x00000000 0x00000000 0x00000000 0x00000000

    Base address register at 0x10
      not implemented(?)
    Base address register at 0x14
      not implemented(?)
    Base address register at 0x18
      not implemented(?)
    Base address register at 0x1c
      not implemented(?)
    Base address register at 0x20
      not implemented(?)
    Base address register at 0x24
      not implemented(?)
    Cardbus CIS Pointer: 0x00000000
    Subsystem vendor ID: 0x0000
    Subsystem ID: 0x0000
    Expansion ROM Base Address: 0x00000000
    Reserved @ 0x34: 0x00000000
    Reserved @ 0x38: 0x00000000
    Maximum Latency: 0x00
    Minimum Grant: 0x00
    Interrupt pin: 0x00 (none)
    Interrupt line: 0x00

  Device-dependent header:
    0x40: 0x0000eeee 0xf0000000 0x00000000 0x00000000
    0x50: 0x00000000 0x00000000 0x00000000 0x00000000
    0x60: 0x00000000 0x00000000 0x00000000 0x00000000
    0x70: 0x00000000 0x00000000 0x00000000 0x00000000
    0x80: 0x0000eeee 0xf0000000 0x00000000 0x00000000
    0x90: 0x00000000 0x00000000 0x00000000 0x00000000
    0xa0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xb0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xc0: 0x0000eeee 0xf0000000 0x00000000 0x00000000
    0xd0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xe0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xf0: 0x00000000 0x00000000 0x00000000 0x00000000

    Don't know how to pretty-print device-dependent header.

unknown vendor 0xeeee product 0x0000 (miscellaneous prehistoric) at pci0 dev 0 function 0 (intrswiz 0, intrpin 0, i/o off, mem off, no quirks) not configured
ral0 at pci0 dev 2 function 0: PCI configuration registers:
  Common header:
    0x00: 0x03021814 0xffff8000 0x00000000 0x00000000

    Vendor Name: Ralink Technologies (0x1814)
    Device Name: RT2561 802.11b/g (0x0302)
    Command register: 0x8000
      I/O space accesses: off
      Memory space accesses: off
      Bus mastering: off
      Special cycles: off
      MWI transactions: off
      Palette snooping: off
      Parity error checking: off
      Address/data stepping: off
      System error (SERR): off
      Fast back-to-back transactions: off
      Interrupt disable: off
    Status register: 0xffff
      Capability List support: on
      66 MHz capable: on
      User Definable Features (UDF) support: on
      Fast back-to-back capable: on
      Data parity error detected: on
      DEVSEL timing: unknown/reserved (0x3)
      Slave signaled Target Abort: on
      Master received Target Abort: on
      Master received Master Abort: on
      Asserted System Error (SERR): on
      Parity error detected: on
    Class Name: prehistoric (0x00)
    Subclass Name: miscellaneous (0x00)
    Interface: 0x00
    Revision ID: 0x00
    BIST: 0x00
    Header Type: 0x00 (0x00)
    Latency Timer: 0x00
    Cache Line Size: 0x00

  Type 0 ("normal" device) header:
    0x10: 0x00020001 0x00000000 0x00000000 0x00000000
    0x20: 0x00000000 0x00000000 0x00000000 0x00000000
    0x30: 0x00000000 0x00000000 0x00000000 0x00000000

    Base address register at 0x10
      type: 32-bit i/o
      base: 0x00020000, size: 0x00020000
    Base address register at 0x14
      not implemented(?)
    Base address register at 0x18
      not implemented(?)
    Base address register at 0x1c
      not implemented(?)
    Base address register at 0x20
      not implemented(?)
    Base address register at 0x24
      not implemented(?)
    Cardbus CIS Pointer: 0x00000000
    Subsystem vendor ID: 0x0000
    Subsystem ID: 0x0000
    Expansion ROM Base Address: 0x00000000
    Capability list pointer: 0x00
    Reserved @ 0x38: 0x00000000
    Maximum Latency: 0x00
    Minimum Grant: 0x00
    Interrupt pin: 0x00 (none)
    Interrupt line: 0x00


  Device-dependent header:
    0x40: 0x03021814 0xffff8000 0x00000000 0x00000000
    0x50: 0x00020001 0x00000000 0x00000000 0x00000000
    0x60: 0x00000000 0x00000000 0x00000000 0x00000000
    0x70: 0x00000000 0x00000000 0x00000000 0x00000000
    0x80: 0x03021814 0xffff8000 0x00000000 0x00000000
    0x90: 0x00020001 0x00000000 0x00000000 0x00000000
    0xa0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xb0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xc0: 0x03021814 0xffff8000 0x00000000 0x00000000
    0xd0: 0x00020001 0x00000000 0x00000000 0x00000000
    0xe0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xf0: 0x00000000 0x00000000 0x00000000 0x00000000

    Don't know how to pretty-print device-dependent header.

Ralink Technologies RT2561 802.11b/g (miscellaneous prehistoric) at ? dev 2 function 0 (intrswiz 0, intrpin 0, i/o off, mem off, no quirks): Ralink Technologies RT2561 802.11b/g (rev. 0x00)
pci_mem_find: expected type mem, found i/o
: could not map memory space
uhub0 at usb0: Star OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub1 at usb1: Star EHCI root hub, class 9/0, rev 2.00/1.00, addr 1
umass0 at uhub1 port 2 configuration 1 interface 0
umass0: BUFFALO USB Flash Disk, rev 2.00/1.10, addr 2
scsibus0 at umass0: 2 targets, 1 lun per target
sd0 at scsibus0 target 0 lun 0: <BUFFALO, USB Flash Disk, 3.10> disk removable
sd0: 7648 MB, 15296 cyl, 32 head, 32 sec, 512 bytes/sect x 15663104 sectors
boot device: <unknown>


どうでもいいが STR8100/9100 のデバイスの I/O アドレスへのマッピングは大名チックで、

A0000000 PCI Config Data Reg
A4000000 PCI Config Address Reg

みたいなメモリマップなのである。PCI Config Data Reg も PCI Config Address Reg も 4byte の I/O レジスタが1つあるだけだ。
これをそれぞれ仮想アドレスにmappingするので、TLBのエントリが無駄になってしょうがない。どうしてくれよう。
しかも I/O アドレスが離れているので kernel config に書く時も不便で、現状は

# On-chip PCI Interface
starpci0	at star? addr1 0xa0000000 irq 8
pci0		at starpci0

として starpci_attach で address + 0x04000000 を PCI config address と見倣しているのだが、気分的には

# On-chip PCI Interface
starpci0	at star? addr1 0xa0000000 addr2 0xa4000000 irq 8
pci0		at starpci0

こう書きたい所だ。しかしこれはこれでどうもなぁ。

つーか SoC なデバイスを kernel config file にずらずらとアドレスやIRQを書くのが間違ってる。 SoC なんだから CPU 側で持ってるデバイスを config_found() すべきだ。 そもそも evbarm/*/*_machdep.c の initarm() で pmap_devmap_register() する時に、全デバイスの I/O アドレスを知ってるんだから。

…と思うんだけど、他のarchはそうしてないんだよね。チキンだから周りに習ってしまいました。
やっぱりそのうち SoC のバスを attach する時に各デバイスを config_found() するように書き換えよう…

2009-10-02 STR9105その4

シリアルが刺さる問題は、割込みモードの設定の不備だった。UART割り込みをレベルトリガからエッジトリガにしたら正常に動くようになった。
しかもエッジトリガにしろ、ってのはよく見たらpdfに書いてあった…

その後いろいろ調べてたら9100用のイーサがぜんぜんダメなことに気がついたので、書きなおす。
かなり安定するようになる。が、CPU datacache enableだとたまに落ちる。しかも落ちる場所が icmp6_input とか ffs_balloc とかだ…。
なんでかなと思いつつ ddb でいろいろ見てたら、icmp6_input のコードがぶっ壊されてることが判明。メモリぶっこわしですか…イーサドライバのキャッシュというかDMAまわりがまだ変なのか。
netbsd.map をよく見たら icmp6.o と ffs_vnops.o はアドレス近くだったのでこのあたりの領域が壊されているのだろう。

週末はこのへんデバッグしつつPCIだな。

2009-09-24 STR9105その3


どうも不安定なのはキャッシュまわりと思ったら、違うようだ。キャッシュも怪しいけど。
コンソールから何度も dmesg してると、たまにピタっと止まってしまう。一度この状態になるとBREAK信号も受けつけない。
イーサのドライバに仕込んでおいた特殊パケット受信でDebugger()を呼ぶ機能を使って ddb に落としてから c すると、何故か復活する。うーん。。。

どうも割込みまわりか、UARTの挙動が怪しい。

幸いこの状態になってもEtherやその他諸々はは生きていてpingにも答えるし、sshdを上げておけばリモートログインできるので、リモートで入って観測。

# gdb --write /netbsd
(gdb) target kvm
(gdb) p/x star_intr_enabled
$1 = 0x19c041b
(gdb) p/x star_intr_pending
$2 = 0x0

0x19c041b = 0000_0001_1001_1100_0000_0100_0001_1011 (b) で、UART は IRQ10 なのでちゃんと enable になっている。
にもかかわらず star_intr_pending も 0 ってことはそもそも割込みが入ってきてない感じ。
UARTもSTR8100とSTR9100で微妙に制御ビットが追加されたりするので、そのへんの違いか。どちらにせよなんちゃって16550互換なので、また場合分けを入れなきゃならないのか…

いろいろ調べてると、現象が起きた状態で cnputc すると復活することがわかった。ddb に落とすと復活するのはこのせいか。どう考えてもcomだなぁ。
回避方法がわかったので特殊パケット受信でcnputcするように仕組んでおくと、止まりつつも(パケット投げれば)進むようになった。
なんかdev_mkdbが数分かかってて変だけど、とりあえずマルチユーザまで上がった。

NetBSD/evbarm STR8100/9100
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 5.99.18 (STR91xx) #184: Thu Sep 24 04:48:06 JST 2009
        ryo@falsie:/src/cvs/NetBSD/sys/arch/evbarm/compile/STR91xx
total memory = 32768 KB
avail memory = 28164 KB
mainbus0 (root)
cpu0 at mainbus0: FA526 rev 1 (ARMv4 core)
cpu0: DC enabled IC enabled WB enabled LABT
cpu0: 16KB/16B 2-way Instruction cache
cpu0: 16KB/16B 2-way write-back-locking-B Data cache
star0 at mainbus0: Star Orion Family SoC: STR9100, 200MHz
starclk0 at star0 addr 0x79000000-0x79000047 irq 0: Programmable Timer
com0 at star0 addr 0x78000000-0x7800001f irq 10: ns16550a, working fifo
com0: console
ohci0 at star0 addr 0xc4000000-0xc400005b irq 23: USB1.1 Host Controller
ohci0:  OHCI version 1.0, legacy support
usb0 at ohci0: USB revision 1.0
ehci0 at star0 addr 0xcc000000-0xcc00006b irq 24: USB2.0 Host Controller
ehci0: ohci or uhci probably not configured
usb1 at ehci0: USB revision 2.0
starrtc0 at star0 addr 0x7b000000-0x7b000037 irq 14: Real-time Clock
starwdog0 at star0 addr 0x7a000000-0x7a00001b irq 3: Watch Dog Timer
stargpio0 at star0 addr 0x7c000000-0x7c000047 irq 4: GPIO
gpio0 at stargpio0: 32 pins
gsec0 at star0 addr 0x70000000-0x7000029b irq 18: Gigabit Switch Engine
gse0 at gsec0 port0
gse0: Ethernet address 00:08:a1:c0:45:7e
ukphy0 at gse0 phy 0: OUI 0x0009c3, model 0x0005, rev. 4
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
gse1 at gsec0 port1
gse1: Ethernet address 00:08:a1:c0:45:7f
ukphy1 at gse1 phy 1: OUI 0x0009c3, model 0x0005, rev. 4
ukphy1: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
uhub0 at usb0: Star OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub1 at usb1: Star EHCI root hub, class 9/0, rev 2.00/1.00, addr 1
boot device: <unknown>
root on gse0
nfs_boot: trying static
nfs_boot: client_addr=192.168.185.87
nfs_boot: gateway=192.168.185.65
nfs_boot: netmask=255.255.254.0
nfs_boot: server=192.168.185.65
nfs_boot: root=192.168.185.65:/src/boot/str9100
root on 192.168.185.65:/src/boot/str9100
WARNING: preposterous TOD clock time
WARNING: using filesystem time
WARNING: CHECK AND RESET THE DATE!
WARNING: negative runtime; monotonic clock has gone backwards
Thu Sep 24 05:13:54 JST 2009
Not checking /: nfs mounted
Starting file system checks:
Setting tty flags.
Setting sysctl variables:
Starting network.
Hostname: str9100
IPv6 mode: host
Configuring network interfaces:.
Adding interface aliases:.
Building databases: dev, utmp, utmpx done
Starting syslogd.
Setting date via ntp.
Checking for core dump...
savecore - - - no core dump (no dumpdev)
Starting rpcbind.
Mounting all filesystems...
Clearing temporary files.
Creating a.out runtime link editor directory cache.
Starting statd.
Starting lockd.
swapctl: adding /var/swapfile as swap device at priority 0
Starting virecover.
Starting local daemons:.
Updating motd.
Starting ntpd.
Starting sshd.
Starting inetd.
Starting cron.
Thu Sep 24 05:22:09 JST 2009

NetBSD/evbarm (str9100) (console)

login: 

NetBSD/evbarm (str9100) (console)

login: 

NetBSD/evbarm (str9100) (console)

login: root
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 5.99.18 (STR91xx) #184: Thu Sep 24 04:48:06 JST 2009

                        STR9105

Terminal type is vt100.                                                 
We recommend that you create a non-root account and use su(1) for root access.
str9100# ifconfig -a
gse0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        address: 00:08:a1:c0:45:7e
        media: Ethernet autoselect (100baseTX full-duplex)
        status: active
        inet 192.168.185.87 netmask 0xfffffe00 broadcast 192.168.185.255
        inet6 fe80::208:a1ff:fec0:457e%gse0 prefixlen 64 scopeid 0x1
gse1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
        address: 00:08:a1:c0:45:7f
        media: Ethernet autoselect (none)
        status: no carrier
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33192
        inet 127.0.0.1 netmask 0xff000000
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
str9100# uname -a
NetBSD str9100 5.99.18 NetBSD 5.99.18 (STR91xx) #184: Thu Sep 24 04:48:06 JST 2009  ryo@falsie:/src/cvs/NetBSD/sys/arch/evbarm/compile/STR91xx evbarm
str9100# df
Filesystem                       1K-blocks       Used      Avail %Cap Mounted on
192.168.185.65:/src/boot/str9100  479777102  144965034  310823214  31% /
mfs:150                                7647          0       7265   0% /tmp
procfs                                    4          4          0 100% /proc
kernfs                                    1          1          0 100% /kern
192.168.185.65:/home              479777102  144965034  310823214  31% /home
192.168.185.65:/src               479777102  144965034  310823214  31% /src
str9100# 

遅いのはたぶんEtherが適当だからな気がする。もっとちゃんと作らなきゃダメだな。
あとはUARTの非互換部分を調べて止まらないようにしなければ。

STR9100対応程度サクサクできると思ったらそうもいかないな。
arm/starは終わらせて早くimx515をいじりたいものだ…

2009-09-23 STR9105その2


STR9100用のイーサはいわゆる2口イーサで、コントローラ1つでPHYが2つあるタイプ。
PHYの代わりにMIIBUS経由でスイッチなんかも繋げられる(MZK-W04Gがこのタイプ)なのだが、とりあえずややこしいのでリファレンス実装に近いTWR-350で動くようにする。

最初コントローラ1つで複数のPHYを持つドライバの書き方がよくわからなくて、いろいろ試行錯誤したのだが、 NetBSD の msk(4) のようにコントローラ用のドライバ上のバスに、PHY用のドライバが存在するように書けば良いようだ。
具体的にはこのようにする。

gsec0	at star? addr 0x70000000 irq 18	# STR9100 Gigabit Switch Engine Controller
gse*	at gsec?
ukphy*	at mii? phy ?			# generic unknown PHYs

これで gsec0 の attach の時に gse0 と gse1 をconfig_found() してやれば、ifconfig -a で gse0 と gse1 が見えるようになる。
ハードウェアリングバッファなんかは gse0 と gse1 共通で1つしか持ってないので、結構色々裏で辻褄合わせをしなければならずめんどくさい。


            §            §            §


というわけで、イーサのドライバをざっくりと書いてnfsboot。

NetBSD/evbarm STR8100/9100
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 5.99.18 (STR91xx) #134: Sun Sep 20 03:52:42 JST 2009
        ryo@falsie:/src/cvs/NetBSD/sys/arch/evbarm/compile/STR91xx
total memory = 32768 KB
avail memory = 28612 KB
mainbus0 (root)
cpu0 at mainbus0: FA526 rev 1 (ARMv4 core)
cpu0: DC enabled IC enabled WB enabled LABT
cpu0: 16KB/16B 2-way Instruction cache
cpu0: 16KB/16B 2-way write-back-locking-B Data cache
star0 at mainbus0: Star Orion Family SoC: STR9100, 200MHz
starclk0 at star0 addr 0x79000000-0x79000047 irq 0: Programmable Timer
com0 at star0 addr 0x78000000-0x7800001f irq 9: ns16550a, working fifo
com0: console
gsec0 at star0 addr 0x70000000-0x7000029b irq 18: Gigabit Switch Engine
gse0 at gsec0 port0
gse0: Ethernet address 00:08:a1:c0:45:7e
ukphy0 at gse0 phy 0: OUI 0x0009c3, model 0x0005, rev. 4
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
gse1 at gsec0 port1
gse1: Ethernet address 00:08:a1:c0:45:7f
ukphy1 at gse1 phy 1: OUI 0x0009c3, model 0x0005, rev. 4
ukphy1: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
boot device: <unknown>
root on gse0
nfs_boot: trying static
nfs_boot: client_addr=192.168.185.87
nfs_boot: gateway=192.168.185.65
nfs_boot: netmask=255.255.254.0
nfs_boot: server=192.168.185.65
nfs_boot: root=192.168.185.65:/src/boot/str9100
root on 192.168.185.65:/src/boot/str9100
WARNING: no TOD clock present
WARNING: using filesystem time
WARNING: CHECK AND RESET THE DATE!
WARNING: negative runtime; monotonic clock has gone backwards
Sun Sep 20 04:08

ここで固まった。完全に固まっているかというとそうでもなく、ping には答えるという…うーん?

一番最後の "Sun Sep 20 04:08" は /etc/rc の中の date コマンドの出力なのだが、全部出力し切れてない。
Context Switch でおかしくなってるのかなあと思って割込みまわりをざっと見直したり書き直したりするも、変化なし。

結局数日悩む。


            §            §            §


デバッガに落とそうとBREAK信号を送ってもデバッガに落ちない(ここで気づけば良かった)ので、タイマ割込みいじって起動後60秒後に Debugger() を呼んで強制的にデバッガに落とすようにする。

    :
root on gse0
nfs_boot: trying static
nfs_boot: client_addr=192.168.185.87
nfs_boot: gateway=192.168.185.65
nfs_boot: netmask=255.255.254.0
nfs_boot: server=192.168.185.65
nfs_boot: root=192.168.185.65:/src/boot/str9100
<1><2><3>root on 192.168.185.65:/src/boot/str9100
WARNING: no TOD clock present
WARNING: using filesystem time
WARNING: CHECK AND RESET THE DATE!
Wed Sep 23 05:26Stopped in pid 0.2 (system) at  netbsd:cpu_Debugger+0x4:        mov     r15, r14
db> bt
netbsd:star_timer1_intr+0x10
        scp=0xc00ed81c rlv=0xc00ec4b4 (netbsd:star_intr_dispatch+0x138)
        rsp=0xc1ff7f08 rfp=0xc1ff7f34
        r6=0xc1116d60 r5=0xc0298178
        r4=0xa0000093
netbsd:star_intr_dispatch+0x10
        scp=0xc00ec38c rlv=0xc006f7b0 (netbsd:irq_entry+0x70)
        rsp=0xc1ff7f38 rfp=0xc1ff7f94
        r10=0x00000000 r9=0x00000000
        r8=0x00000000 r7=0x00000000 r6=0x00000000 r5=0xc1c2fc80
        r4=0xc01f0f3c
netbsd:cpu_idle+0x10
        scp=0xc004f1d4 rlv=0xc007d0c4 (netbsd:idle_loop+0x14c)
        rsp=0xc1ff7f98 rfp=0xc1ff7fb0
        r4=0xc01f0f3c
netbsd:idle_loop+0x10
        scp=0xc007cf88 rlv=0xc001bb68 (netbsd:lwp_trampoline+0x14)
        rsp=0xc1ff7fb4 rfp=0x00000000
        r6=0x00000000 r5=0xc1c2fc80
        r4=0xc007cf78
db> show all procs
PID    LID S CPU     FLAGS       STRUCT LWP *               NAME WAIT
2        1 3   0        84           c28f2d00                 sh ttyout
1        1 3   0        84           c1c3ace0               init wait
0       32 3   0       204           c1c3a060        vmem_rehash vmem_rehash
0       31 3   0       204           c1c3a2e0           aiodoned aiodoned
0       30 3   0       204           c1c3a560            ioflush syncer
0       29 3   0       204           c1c3a7e0           pgdaemon pgdaemon
0       28 3   0       204           c1c39cc0              nfsio nfsiod
0       27 3   0       204           c1c39a40              nfsio nfsiod
0       26 3   0       204           c1c397c0              nfsio nfsiod
0       25 3   0       204           c1c39540              nfsio nfsiod
0       24 3   0       204           c1c392c0           swdmover swdmvr
0       23 3   0       204           c1c39040          cryptoret crypto_wait
0       22 3   0       204           c1c3aa60              unpgc unpgc
0       13 3   0       204           c1c32020         pmfsuspend pmfsuspend
0       12 3   0       204           c1c322a0           pmfevent pmfevent
0       11 3   0       204           c1c32520           nfssilly nfssilly
0       10 3   0       204           c1c327a0            cachegc cachegc
0        9 3   0       204           c1c32a20              vrele vrele
0        8 3   0       204           c1c32ca0          modunload modunload
0        7 3   0       204           c1c2f000            xcall/0 xcall
0        6 1   0       204           c1c2f280          softser/0
0        5 1   0       204           c1c2f500          softclk/0
0        4 1   0       204           c1c2f780          softbio/0
0        3 1   0       204           c1c2fa00          softnet/0
0    >   2 7   0       205           c1c2fc80             idle/0
0        1 3   0       204           c0261c60            swapper schedule
db> show callout
hardclock_ticks now: 1901
    ticks  wheel               arg  func
        0 -1/-256                0  sched_pstats
        0 -1/-256         c1c32a20  sleepq_timeout
        0 -1/-256         c1c327a0  sleepq_timeout
        1  0/110                 0  if_slowtimo
       13  0/122                 0  rt_timer_timer
       18  0/127                 0  pffasttimo
       19  0/128          c1c3a560  sleepq_timeout
       48  0/157                 0  pfslowtimo
      419  1/265                 0  vmem_rehash_all_kick
    28217  1/373                 0  arptimer
db> show sched_qs
Run-queue (CPU = 0):
 pid.lid = 0.2, r_count = 0, r_avgcount = 0, maxpri = 0, mlwp = 0x0
 bitmap[6] => [ 0 (0x0) ]
 bitmap[5] => [ 0 (0x0) ]
 bitmap[4] => [ 0 (0x0) ]
 bitmap[3] => [ 0 (0x0) ]
 bitmap[2] => [ 0 (0x0) ]
 bitmap[1] => [ 0 (0x0) ]
 bitmap[0] => [ 0 (0x0) ]
     LID  PRI EPRI         FL  ST                LWP  CPU  TCI LRTICKS
 /- 2 (sh)
 |     1   43   85 0x00000084  SQ         0xc28f2d00    0   -1 1394
 /- 1 (init)
 |     1   43   85 0x00000084  SQ         0xc1c3ace0    0   -1 1444
 /- 0 (system)
 |    32  125  125 0x00000204  SQ         0xc1c3a060    0   -1 581
 |    31  125  125 0x00000204  SQ         0xc1c3a2e0    0   -1 1581
 |    30  124  124 0x00000204  SQ         0xc1c3a560    0   -1 81
 |    29  126  126 0x00000204  SQ         0xc1c3a7e0    0   -1 1581
 |    28   96   96 0x00000204  SQ         0xc1c39cc0    0   -1 1582
 |    27   96   96 0x00000204  SQ         0xc1c39a40    0   -1 1582
 |    26   96   96 0x00000204  SQ         0xc1c397c0    0   -1 1582
 |    25   96   96 0x00000204  SQ         0xc1c39540    0   -1 1582
 |    24   96   96 0x00000204  SQ         0xc1c392c0    0   -1 1883
 |    23   96   96 0x00000204  SQ         0xc1c39040    0   -1 1883
 |    22   96   96 0x00000204  SQ         0xc1c3aa60    0   -1 1883
 |    13   96   96 0x00000204  SQ         0xc1c32020    0   -1 1900
 |    12   96   96 0x00000204  SQ         0xc1c322a0    0   -1 1900
 |    11   96   96 0x00000204  SQ         0xc1c32520    0   -1 1900
 |    10  125  125 0x00000204  SQ         0xc1c327a0    0   -1 100
 |     9  125  125 0x00000204  SQ         0xc1c32a20    0   -1 100
 |     8  125  125 0x00000204  SQ         0xc1c32ca0    0   -1 1900
 |     7  127  127 0x00000204  SQ         0xc1c2f000    0   -1 1887
 |     6  223  223 0x00000204   -         0xc1c2f280    0   -1 1900
 |     5  220  220 0x00000204   -         0xc1c2f500    0   -1 1900
 |     4  221  221 0x00000204   -         0xc1c2f780    0   -1 1900
 |     3  222  222 0x00000204   -         0xc1c2fa00    0   -1 1900
 |     2    0    0 0x00000205   -         0xc1c2fc80    0   -1 1901
 |     1  125  125 0x00000204  SQ         0xc0261c60    0   -1 500

うーんと悩みつつよく見たら、sh が ttyout で止まっている。
もしやと思ってPDFをよく見直すと

UART の IRQ が間違ってた。

ガーン。というか、これは STR8100 と STR9100 が悪いだろ…

STR8100はUARTを2つ持っていて

UART0 0x78000000 IRQ 9
UART1 0x78800000 IRQ 10

という構成である。一方STR9100はUARTが1つで、I/OアドレスはSTR8100のUART0と同じ0x78000000なのだが、

UART0 0x78000000 IRQ 10

…IRQは10なのだ。なんて罠だ。

というわけで、confを書き直したらあっさりbootした。

STR9100>go 0x21000000
## Starting application at 0x21000000 ...

NetBSD/evbarm STR8100/9100
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 5.99.18 (STR91xx) #164: Wed Sep 23 05:14:29 JST 2009
        ryo@falsie:/src/cvs/NetBSD/sys/arch/evbarm/compile/STR91xx
total memory = 32768 KB
avail memory = 28612 KB
mainbus0 (root)
cpu0 at mainbus0: FA526 rev 1 (ARMv4 core)
cpu0: DC enabled IC enabled WB enabled LABT
cpu0: 16KB/16B 2-way Instruction cache
cpu0: 16KB/16B 2-way write-back-locking-B Data cache
star0 at mainbus0: Star Orion Family SoC: STR9100, 200MHz
starclk0 at star0 addr 0x79000000-0x79000047 irq 0: Programmable Timer
com0 at star0 addr 0x78000000-0x7800001f irq 10: ns16550a, working fifo
com0: console
gsec0 at star0 addr 0x70000000-0x7000029b irq 18: Gigabit Switch Engine
gse0 at gsec0 port0
gse0: Ethernet address 00:08:a1:c0:45:7e
ukphy0 at gse0 phy 0: OUI 0x0009c3, model 0x0005, rev. 4
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
gse1 at gsec0 port1
gse1: Ethernet address 00:08:a1:c0:45:7f
ukphy1 at gse1 phy 1: OUI 0x0009c3, model 0x0005, rev. 4
ukphy1: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
boot device: <unknown>
root on gse0
nfs_boot: trying static
nfs_boot: client_addr=192.168.185.87
nfs_boot: gateway=192.168.185.65
nfs_boot: netmask=255.255.254.0
nfs_boot: server=192.168.185.65
nfs_boot: root=192.168.185.65:/src/boot/str9100
root on 192.168.185.65:/src/boot/str9100
WARNING: no TOD clock present
WARNING: using filesystem time
WARNING: CHECK AND RESET THE DATE!
WARNING: negative runtime; monotonic clock has gone backwards
/etc/rc.conf is not configured.  Multiuser boot aborted.
Enter pathname of shell or RETURN for /bin/sh: 
Terminal type is vt100.                                                 
We recommend that you create a non-root account and use su(1) for root access.
# df
Filesystem                       1K-blocks       Used      Avail %Cap Mounted on
192.168.185.65:/src/boot/str9100  479777102  144934380  310853868  31% /
# ifconfig -a
gse0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        address: 00:08:a1:c0:45:7e
        media: Ethernet autoselect (100baseTX full-duplex)
        status: active
        inet 192.168.185.87 netmask 0xfffffe00 broadcast 192.168.185.255
gse1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
        address: 00:08:a1:c0:45:7f
        media: Ethernet autoselect (none)
        status: no carrier
lo0: flags=8048<LOOPBACK,RUNNING,MULTICAST> mtu 33192
# uname -a
NetBSD  5.99.18 NetBSD 5.99.18 (STR91xx) #164: Wed Sep 23 05:14:29 JST 2009  ryo@falsie:/src/cvs/NetBSD/sys/arch/evbarm/compile/STR91xx evbarm
# 

マルチユーザにするとdev_mkdbが帰ってこなかったり変な個所で落ちたりする。
またCPUキャッシュっぽいなぁ。

でもまぁ、少しずつ進んでいるので良しとしよう。

2009-09-22 i.MX memo


2009-09-16 MZK-W04G


PLANEX DIRECTのガレージセールでMZK-W04Gが安かったので、先日ついIYHしてしまったものが届いた。当然STR91xxなCPUボード目当てです。

空けてみた。例によって当然電源入れる前です。ほとんどStar-Semiconductor(現Cavium)のリファレンス通りの作り。
しかもご丁寧にUARTのシルク印刷まであった。これは遊んでくれと言っているようなものだ(そうか?)

いつものように秋月のADM3202でシリアルケーブル作って38400bpsで接続。
ARMboot 1.1.0 (Sep 13 2007 - 14:41:53)

Star maintain version 0.15.100000000
ARMboot code: 00000000 -> 0001b684

STR9100 CPU Clock: 250 Mhz

1.8V Regulator Regulated vdd Output : b101

2.5V Regulator Regulated vdd Output : b100

DDR Bank #0: 00000000 64 MB
DDR Controller Data Bus Width: 32 bits
flash type: EON_EN29LV640HL

Flash Bank #1: 8 MB

*** Using my specific environment

Hit any key to stop autoboot:  0 
STR9100>
STR9100>
STR9100>help
go      - start application at address 'addr'
run     - run commands in an environment variable
bootm   - boot application image from memory
bootp   - boot image via network using BootP/TFTP protocol
tftpboot- boot image via network using TFTP protocol
               and env variables ipaddr and serverip
rarpboot- boot image via network using RARP/TFTP protocol
bootd   - boot default, i.e., run 'bootcmd'
loads   - load S-Record file over serial line
loadb   - load binary file over serial line (kermit mode)
autoscr - run script from memory
md      - memory display
mm      - memory modify (auto-incrementing)
nm      - memory modify (constant address)
mw      - memory write (fill)
cp      - memory copy
cmp     - memory compare
crc32   - checksum calculation
base    - print or set address offset
printenv- print environment variables
setenv  - set environment variables
saveenv - save environment variables to persistent storage
protect - enable or disable FLASH write protection
erase   - erase FLASH memory
flinfo  - print FLASH memory information
bdinfo  - print Board Info structure
iminfo  - print header information for application image
loop    - infinite loop on address range
mtest   - simple RAM test
reset   - Perform RESET of the CPU
echo    - echo args to console
sleep   - delay execution for some time
version - print monitor version
help    - print online help
?       - alias for 'help'
adjust regulator
STR9100>printenv
bootcmd=go 10040000
bootdelay=2
baudrate=38400
ipaddr=192.168.1.254
serverip=192.168.1.230
netmask=255.255.255.0
ethaddr=00:90:cc:f3:ab:06

Environment size: 139/32764 bytes

U-Boot(ARMBoot)がsaveenvも対応していた。
LAN EVOLUTIONはsaveenvできたがCMR-350はsaveenvできなかったので不便だったのだ。
デフォルトでtftpbootにできる分、CMR-350よりこっちで開発したほうが楽っぽいな。

STR9100>boot
## Starting application at 0x10040000 ...
Uncompressing Linux............................................................................................. done, booting the kernel.
Linux version 2.6.16-star (root@localhost.localdomain) (gcc version 3.4.6) #25 Fri Jan 23 20:41:34 JST 2009
CPU: FA526id(wb) [66015261] revision 1 (ARMv4)
Machine: STAR STR9100
Memory policy: ECC disabled, Data cache writeback
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 2, 16 byte lines, 512 sets
CPU0: D cache: 16384 bytes, associativity 2, 16 byte lines, 512 sets
CPU clock at 250MHz
AHB clock at 125MHz
APB clock at 62MHz
Enable I-ScratchPad Address Start : c0025000 
Built 1 zonelists
Kernel command line: root=/dev/ram0
PID hash table entries: 512 (order: 9, 8192 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 64MB = 64MB total
Memory: 55936KB available (2356K code, 564K data, 116K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
checking if image is initramfs...it isn't (no cpio magic); looks like an initrd
Freeing initrd memory: 5852K
NET: Registered protocol family 16
PCI clock at 33M
PCI: bus0: Fast back to back transfers disabled
PCI Bridge found
PCI: enabling device 0000:00:00.0 (0140 -> 0142)
PCI map irq: 00:00.00 slot 0, pin 1, irq: 0
PCI map irq: 00:01.00 slot 1, pin 1, irq: 5
SCSI subsystem initialized
usbcore: registered new driver usbfs
usbcore: registered new driver hub
JFFS2 version 2.2. (NAND) (C) 2001-2003 Red Hat, Inc.
Initializing Cryptographic API
io scheduler noop registered
io scheduler deadline registered (default)
GPIO interrupt handler install ok. 
STR9100 Real Time Clock Driver v2.0.0
Serial: 8250/16550 driver $Revision: 1.61 $ 1 ports, IRQ sharing disabled
serial8250: ttyS0 at MMIO 0x78000000 (irq = 10) is a 16550A
RAMDISK driver initialized: 4 RAM disks of 18432K size 1024 blocksize
Star GSW Driver(for Linux Kernel 2.6) - Star Semiconductor
mac addr: 00:90:cc:f3:ab:06
mac len: 17
flash mac : 0:90:cc:f3:ab:6
VLAN0_VLAN_TAG: 1

configure VSC7385
Check MAC/PHY 0 Link Status : DOWN!
INIT VSC8601
VSC8601: AN Completed.
PPP generic driver version 2.4.2
PPP Deflate Compression module registered
PPP BSD Compression module registered
NET: Registered protocol family 24
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
STR9100 NOR Flash: Found 1 x16 devices at 0x0 in 16-bit bank
 Amd/Fujitsu Extended Query Table at 0x0040
STR9100 NOR Flash: CFI does not contain boot bank location. Assuming top.
number of CFI chips: 1
cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
Creating 3 MTD partitions on "STR9100 NOR Flash":
0x00000000-0x00040000 : "ARMBOOT"
0x00040000-0x007e0000 : "Linux Kernel"
0x007e0000-0x00800000 : "Config"
str9100-ehci str9100-ehci: str9100-ehci
str9100-ehci str9100-ehci: new USB bus registered, assigned bus number 1
str9100-ehci str9100-ehci: irq 24, io mem 0xcc000000
str9100-ehci str9100-ehci: USB 0.0 started, EHCI 1.00, driver 10 Dec 2004
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
ohci_hcd: 2005 April 22 USB 1.1 'Open' Host Controller (OHCI) Driver (STR9100)
str9100-ohci str9100-ohci: str9100-ohci
str9100-ohci str9100-ohci: new USB bus registered, assigned bus number 2
str9100-ohci str9100-ohci: irq 23, io mem 0xc4000000
usb usb2: configuration #1 chosen from 1 choice
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 2 ports detected
Netfilter messages via NETLINK v0.30.
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
ip_conntrack version 2.4 (512 buckets, 4096 max) - 240 bytes per conntrack
ip_tables: (C) 2000-2006 Netfilter Core Team
TCP bic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
NET: Registered protocol family 15
ieee80211: 802.11 data/management/control stack, git-1.1.7
ieee80211: Copyright (C) 2004-2005 Intel Corporation <jketreno@linux.intel.com>
RAMDISK: Compressed image found at block 0
VFS: Mounted root (ext2 filesystem) readonly.
Freeing init memory: 116K
Mounting root fs rw ...
open mac port 0
port 0 already open
Init router config ...
str9100_shnat: module license 'Proprietary' taints kernel.
[RLDBG] init_func_ptr: HOOK POINT INIT OK 
STAR9100 Software HNAT Driver Initialized
star_ioctl: Unsupport command
device eth0 entered promiscuous mode
star_ioctl: Unsupport command
br0: port 1(eth0) entering learning state
br0: topology change detected, propagating
br0: port 1(eth0) entering forwarding state
PCI: enabling device 0000:00:01.0 (0140 -> 0142)


=== pAd = c5081000, size = 486108 ===

<-- RTMPAllocAdapterBlock, Status=0
Initializing USB Mass Storage driver...
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
# RX DESC ffc30000  size = 2048
<-- RTMPAllocTxRxRingMemory, Status=0
WPAPSK_KEY, key len (should be 8~64) incorrect!!!, your key len = 0
I/F(ra0) Key1Str is Invalid key length! KeyLen = 0!
1. Phy Mode = 0
2. Phy Mode = 0
RTMPSetPhyMode: channel is out of range, use first channel=0 
3. Phy Mode = 0
RTMPSetPhyMode: channel is out of range, use first channel=0 
MCS Set = 00 00 00 00 00
SYNC - BBP R4 to 20MHz.l
Main bssid = 00:90:cc:f3:5d:12
The UUID Hex string is:bc329e001dd811b286010090ccf35d12
The UUID ASCII string is:bc329e00-1dd8-11b2-8601-0090ccf35d12!
<==== RTMPInitialize, Status=0
0x1300 = 00064220
device ra0 entered promiscuous mode
br0: port 2(ra0) entering learning state
br0: topology change detected, propagating
br0: port 2(ra0) entering forwarding state
Open Orion Fast Path Tunnel Device 

# ?
/bin/sh: ?: not found
# ps auxw
  PID  Uid     VmSize Stat Command
    1 root        344 S   init       
    2 root            SWN [ksoftirqd/0]
    3 root            SW< [events/0]
    4 root            SW< [khelper]
    5 root            SW< [kthread]
   12 root            SW< [kblockd/0]
   15 root            SW< [khubd]
   49 root            SW  [pdflush]
   50 root            SW  [pdflush]
   52 root            SW< [aio/0]
   51 root            SW  [kswapd0]
  570 root            SW< [cqueue/0]
  590 root            SW  [mtdblockd]
  636 root        912 S   /usr/local/sbin/router_config 
  666 root        440 S   /usr/local/sbin/thttpd -C /etc/thttpd.conf 
  667 root        244 S   /usr/local/sbin/wd 
  670 root        288 S   /sbin/klogd 
  674 root            SW  [rtmpWscHandle]
  676 root        300 S   /sbin/syslogd -C 16 
  681 root        404 S   /bin/sh 
  796 root        268 S   udhcpd 
  805 root        256 S   /usr/local/sbin/miniupnpd -f /var/miniupnpd.conf 
  808 root        324 R   ps auxw 
# df
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/root                17845     14122      3723  79% /
# ls -la /
drwxr-xr-x   15 root     root         1024 Jan 23  2009 .
drwxr-xr-x   15 root     root         1024 Jan 23  2009 ..
drwxr-xr-x    2 1000     1000         1024 Oct  7  2008 bin
drwxrwxrwx    6 root     root         1024 Jan  1 09:00 dev
drwxr-xr-x    7 1000     1000         1024 Jan  1 09:00 etc
drwxr-xr-x    4 1000     1000         2048 Jan 23  2009 lib
lrwxrwxrwx    1 root     root           11 Jan 23  2009 linuxrc -> bin/busybox
drwx------    2 root     root        12288 Jan 23  2009 lost+found
drwxr-xr-x    3 1000     1000         1024 Jun  7  2007 man
drwxr-xr-x    5 1000     1000         1024 Sep  7  2007 mnt
dr-xr-xr-x   36 root     root            0 Jan  1 09:00 proc
drwxr-xr-x    2 1000     1000         1024 Oct  1  2008 root
drwxr-xr-x    2 1000     1000         1024 Oct  4  2007 sbin
drwxr-xr-x    2 1000     1000         1024 Jan  1 09:00 tmp
drwxr-xr-x    7 1000     1000         1024 Jun 12  2007 usr
drwxr-xr-x    6 1000     1000         1024 Jan  1 09:00 var
# cat /proc/cpuinfo
Processor       : FA526id(wb) rev 1 (v4l)
BogoMIPS        : 191.69
Features        : swp half 
CPU implementer : 0x66
CPU architecture: 4
CPU variant     : 0x0
CPU part        : 0x526
CPU revision    : 1
Cache type      : write-back
Cache clean     : cp15 c7 ops
Cache lockdown  : format B
Cache format    : Harvard
I size          : 16384
I assoc         : 2
I line length   : 16
I sets          : 512
D size          : 16384
D assoc         : 2
D line length   : 16
D sets          : 512

Hardware        : STAR STR9100
Revision        : 0000
Serial          : 0000000000000000
# 

おいおい。デフォルトでshellが上がってるよ。すげー。


CPUとクロックが判明したので表を更新

AREA LAN EVOLUTION STR8132 250MHz LAN,USB
CNET CWR-635M(※) STR9105 200MHz LAN,USB,mini-pci(WiFi)
COREGA CG-BARPROG STR9102 200MHz LAN
PLANEX MZK-W04G STR9102 250MHz LAN,USB,mini-pci(WiFi)
NetIndex クティオ STR91?? ?MHz LAN,USB,WiFi,CF

2009-09-11 STR9105その1


以前買っておいたCMR-350でも動かしてみる。
STR9100でも動くようにいろいろ仕掛けをしておいたおかげで、ほとんど修正なしに動いた。
忘れてた所は、evbarm/star/star_start.S の中でSTR9100デバイス用のL2テーブルの登録個所くらいだったので、STR9100用のエントリも登録。
star_start.S で登録する MMU のテーブルは仮のものでちゃんとした L2 table は evbarm/star/star_machdep.c の中で登録されるので適当で問題なし。

CPU Clockがめちゃくちゃだな。I/Oレジスタ間違えたか。

NetBSD/evbarm STR8100/9100
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 5.99.16 (STR91xx) #37: Fri Sep 11 02:16:53 JST 2009
        ryo@falsie:/src/cvs/NetBSD/sys/arch/evbarm/compile/STR91xx
total memory = 32768 KB
avail memory = 28164 KB
mainbus0 (root)
cpu0 at mainbus0: FA526 rev 1 (ARMv4 core)
cpu0: DC enabled IC enabled WB enabled LABT
cpu0: 16KB/16B 2-way Instruction cache
cpu0: 16KB/16B 2-way write-back-locking-B Data cache
star0 at mainbus0: Star Orion Family SoC: STR9100, 1775MHz
starclk0 at star0 addr 0x79000000-0x79000047 irq 0: Programmable Timer
com0 at star0 addr 0x78000000-0x7800001f irq 9: ns16550a, working fifo
com0: console
ohci0 at star0 addr 0xc4000000-0xc400005b irq 23: USB1.1 Host Controller
ohci0:  OHCI version 1.0, legacy support
usb0 at ohci0: USB revision 1.0
ehci0 at star0 addr 0xcc000000-0xcc00006b irq 24: USB2.0 Host Controller
ehci0: ohci or uhci probably not configured
usb1 at ehci0: USB revision 2.0
starrtc0 at star0 addr 0x7b000000-0x7b000037 irq 14: Real-time Clock
starwdog0 at star0 addr 0x7a000000-0x7a00001b irq 3: Watch Dog Timer
stargpio0 at star0 addr 0x7c000000-0x7c000047 irq 4: GPIO
gpio0 at stargpio0: 32 pins
uhub0 at usb0: Star OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub1 at usb1: Star EHCI root hub, class 9/0, rev 2.00/1.00, addr 1
boot device: <unknown>

uvm_fault(0xc0306084, 0, 1) -> e
Fatal kernel mode data abort: 'Translation Fault (S)'
trapframe: 0xc0338db8
FSR=00000005, FAR=00000000, spsr=60000053
r0 =00000000, r1 =00000000, r2 =c0309ad0, r3 =ffffffff
r4 =c025af28, r5 =00000000, r6 =00000000, r7 =c02d6ac0
r8 =00000000, r9 =c0309ac0, r10=c02615f8, r11=c0338f9c
r12=00000000, ssp=c0338e04, slr=c00bdbe8, pc =c0133758

Stopped in pid 0.1 (system) at  netbsd:device_class:    ldr     r0, [r0]
db> bt
netbsd:setroot+0x10
        scp=0xc00bd3c4 rlv=0xc0079854 (netbsd:main+0x274)
        rsp=0xc0338fa0 rfp=0xc0338fec
        r10=0xc02615f8 r9=0xc0309ac0
        r8=0xc030364c r7=0x00000000 r6=0xc0303648 r5=0x00000000
        r4=0x00000001
netbsd:main+0x10
        scp=0xc00795f0 rlv=0xc0008228 (netbsd:kernel_text+0x3c)
        rsp=0xc0338ff0 rfp=0xc0338ffc
        r10=0x00000001 r9=0x000368b8
        r8=0x00000000 r7=0x000368b8 r6=0x0003661c r5=0x00000002
        r4=0x2000813c
netbsd:kernel_text+0x3c
        scp=0xc0008228 rlv=0xc0130314 (netbsd:initarm+0x7cc)
        rsp=0xc0339000 rfp=0x00000000
db>

STR9100のetherドライバを書く仕事が始まるお…

2009-08-30 STR8132その9 - GPIO と watchdog


GPIOとwatchdogを書いて、これでNetBSD/str8100のデバイス対応はほぼ終了
作業はじめてから数えて二ヶ月半もかかったなぁ。


            §            §            §


STR8100のGPIOは割り込み設定とかもできるんだけど、NetBSDのgpioフレームワークはそこまで高機能ではないので未サポート。 気がむいたらddbボタンかsoft poweroffボタンくらいには割り当てられるかもしれない。
watchdogもこれといって特に癖もなく普通だった。

記念にデバイス全部入りのdmesgを。
spiはなぜか動かず、twiは何も繋がってないのでテストできておらず(たぶん動かない)、RTCはリセットでクリアされてしまうのでまるで激しく意味がない。

Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 5.99.15 (STR81xx) #1419: Mon Aug 31 05:04:40 JST 2009
        ryo@falsie:/src/cvs/NetBSD/sys/arch/evbarm/compile/STR81xx
total memory = 32768 KB
avail memory = 28136 KB
timecounter: Timecounters tick every 10.000 msec
mainbus0 (root)
cpu0 at mainbus0: FA526 rev 1 (ARMv4 core)
cpu0: DC enabled IC enabled WB enabled LABT
cpu0: 8KB/16B 2-way Instruction cache
cpu0: 8KB/16B 2-way write-back-locking-B Data cache
star0 at mainbus0: Star Equuleus Family SoC: STR8100, 250MHz
starclk0 at star0 addr 0x79000000-0x79000047 irq 0: Programmable Timer
com0 at star0 addr 0x78000000-0x7800001f irq 9: ns16550a, working fifo
com0: console
ohci0 at star0 addr 0xc4000000-0xc400005b irq 23: USB1.1 Host Controller
ohci0: OHCI version 1.0, legacy support
usb0 at ohci0: USB revision 1.0
ehci0 at star0 addr 0xcc000000-0xcc00006b irq 24: USB2.0 Host Controller
ehci0: EHCI version 1.0
ehci0: wrong number of companions (1 != 0)
ehci0: ohci or uhci probably not configured
usb1 at ehci0: USB revision 2.0
starrtc0 at star0 addr 0x7b000000-0x7b000037 irq 14: Real-time Clock
starwdog0 at star0 addr 0x7a000000-0x7a00001b irq 3: Watch Dog Timer
stargpio0 at star0 addr 0x7c000000-0x7c000047 irq 4: GPIOA
gpio0 at stargpio0: 32 pins
stargpio1 at star0 addr 0x7c800000-0x7c800047 irq 4: GPIOB
gpio1 at stargpio1: 32 pins
starspi0 at star0 addr 0x71000040-0x7100005f irq 26: Serial Peripheral Interface
spi0 at starspi0: SPI bus
m25p0 at spi0 slave 0: unknown or unsupported device
startwi0 at star0 addr 0x71000020-0x7100003f irq 27: Two-Wire Serial Interface
iic0 at startwi0: I2C bus
gec0 at star0 addr 0x70000000-0x70000133 irq 18: Gigabit Ethernet Controller
gec0: Ethernet address 00:aa:bb:cc:dd:10
ukphy0 at gec0 phy 0: OUI 0x000e4e, model 0x0025, rev. 1
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
timecounter: Timecounter "clockinterrupt" frequency 100 Hz quality 0
timecounter: Timecounter "starclk" frequency 62500000 Hz quality 100
uhub0 at usb0: Star OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
uhub1 at usb1: Star EHCI root hub, class 9/0, rev 2.00/1.00, addr 1
uhub1: 2 ports with 2 removable, self powered
ehci0: strange port
uhidev0 at uhub0 port 1 configuration 1 interface 0
uhidev0: Dell Dell USB Optical Mouse, rev 2.00/43.01, addr 2, iclass 3/1
ums0 at uhidev0: 3 buttons and Z dir.
wsmouse0 at ums0 (mux ignored)
umass0 at uhub1 port 2 configuration 1 interface 0: silicon -power, rev 2.00/1.10, addr 2
umass0: using SCSI over Bulk-Only
scsibus0 at umass0: 2 targets, 1 lun per target
sd0 at scsibus0 target 0 lun 0: <silicon, -power, 0.00> disk removable
sd0: 1911 MB, 7644 cyl, 16 head, 32 sec, 512 bytes/sect x 3913728 sectors
boot device: <unknown>
root on gec0
nfs_boot: trying static
nfs_boot: client_addr=192.168.185.87
nfs_boot: gateway=192.168.185.65
nfs_boot: netmask=255.255.254.0
nfs_boot: server=192.168.185.65
nfs_boot: root=192.168.185.65:/src/boot/str8132
root on 192.168.185.65:/src/boot/str8132
WARNING: preposterous TOD clock time
WARNING: using filesystem time
WARNING: CHECK AND RESET THE DATE!
WARNING: negative runtime; monotonic clock has gone backwards
star# uname -a
NetBSD star 5.99.15 NetBSD 5.99.15 (STR81xx) #1419: Mon Aug 31 05:04:40 JST 2009  ryo@falsie:/src/cvs/NetBSD/sys/arch/evbarm/compile/STR81xx evbarm
star#

USBメモリが普通に使えたので、EHCIも問題ないっぽい。他のUSBデバイスも使えると思われ。wrong number of companions とか strange port とか何か変なメッセージ出てるけど。
そういえばetherのmulticast対応を忘れてた…暇なとき書こう。

WARNING: negative runtime; monotonic clock has gone backwards だけひっかかる。
ps の出力が微妙に変なのはこのせいかなぁ。timerまわりが不完全?

2009-08-25 STR8132その8 - mac address と flash と SPI


flash の +0x0003ffe0 から 6byte に書いてあった。

	:
3003ffd0: 31 32 33 34 35 36 37 38 39 2d 31 32 2d 34 37 33    123456789-12-473
3003ffe0: 00 22 ec 02 00 f3 00 00 00 00 00 00 00 00 00 00    ."..............
3003fff0: 01 01 00 00 02 02 00 00 73 75 70 65 72 63 6f 6d    ........supercom
	:

LU2BOX の Linux を立ち上げた時の mac address は 00:22:ec:02:00:f3 なので、3003ffe0 から 6byte が mac address だろう。
"123456789-12-473" と "supercom" が謎だ。OEM元の名前じゃないな。OEM元はsondyo台湾の http://www.sondyo.com/ot_sld2u.htm だし。

その他はずっとSPIのドライバを書いてたけど一向にflashが読めません。割り込みも動くし loopback モードじゃちゃんと動いてるっぽいので、
石の叩き方は間違ってないと思うんだけどなぁ。M25P64 は 64Mbit serial flash なので CPU とは間違いなく SPI で繋がってるはずなのだが。

TWI(I2C) もドライバ書いたけど何もデバイスつながってなくてテストできない状態なので、SPI と TWI は放置して GPIO と WatchDog を書いてしまって、さっさと STR9105 始めよう。

2009-08-21 STR8132その7 - RTC


一日1デバイス。今日はRTC。
STR8100/9100 の RTC は電池も付けられないダメダメ超シンプルなRTCで、そのシンプルさは 電源ONになるとひたすら秒分時日の各レジスタがカウントアップし続ける機能しかない。(普通にALARMによる割り込み機能とかはあるけど)
年や月レジスタは存在しない。日レジスタが16bit分あるので65536日=180年分カウントできるので困らない。
何のために存在するかというと、おそらくSuspend/Resumeのためなんだろう。unix的にはどうでもいいデバイス度90%くらい。 でもまぁSoCだし、こんなものかと思ってチンタラとデバドラを書いてたのだが、

「秒分時日の設定もできない」

ことがわかった。おいおい。

で、どうするかというと、32bitのスクラッチ的なレジスタ(RTC_RECORDレジスタ)があって、ここに好きな値を書き込んでおくことができる。
好きな値とは、現在の実時刻とRTCの示す時刻との差分である。

読み出す時は、RTCの「秒+分*60+時*3600+日*86400」に、上で書き込んだ値を差分として(プログラムで)足して解釈する。
設定する時は、RTCの「秒+分*60+時*3600+日*86400」と現在時刻との差分をRTC_RECORDレジスタに保存しておくのだ。

なんという
なんという
なんという…

2009-08-19 STR8132その6


softintr の動作が変な件。
arch/arm/star/star_intr.c の割り込みの __HAVE_FAST_SOFTINTS 部分は、sys/arch/arm/xscale/ixp425_intr.[ch] あたりを参考にしていたのだが、 そもそも xscale を HAVE_FAST_SOFTINT で使っているものは存在しなかった。つまり腐ってやがる。早すぎたんですよ。

というわけで std.star からも __HAVE_FAST_SOFTINTS を削って、softintr 問題は解決。
USBはwrapperだけだから簡単だと思ってちゃっちゃと star_ohci と star_ehci を書く。

NetBSD 5.99.15 (STR81xx) #1138: Wed Aug 19 02:20:22 JST 2009
        ryo@falsie:/src/cvs/NetBSD/sys/arch/evbarm/compile/STR81xx
total memory = 32768 KB
avail memory = 28156 KB
mainbus0 (root)
cpu0 at mainbus0: FA526 rev 1 (ARMv4 core)
cpu0: DC enabled IC enabled WB enabled LABT
cpu0: 8KB/16B 2-way Instruction cache
cpu0: 8KB/16B 2-way write-back-locking-B Data cache
star0 at mainbus0: Star Equuleus Family SoC: STR8100, 250MHz
starclk0 at star0 addr 0x79000000-0x79000047 irq 0: Programmable Timer
com0 at star0 addr 0x78000000-0x7800001f irq 9: ns16550a, working fifo
com0: console
ohci0 at star0 addr 0xc4000000-0xc400005b irq 23: USB1.1 Host Controller
ohci0: OHCI version 1.0, legacy support
usb0 at ohci0: USB revision 1.0
ehci0 at star0 addr 0xcc000000-0xcc00006b irq 24: USB2.0 Host Controller
ehci0: ohci or uhci probably not configured
usb1 at ehci0: USB revision 2.0
gec0 at star0 addr 0x70000000-0x70000133 irq 18: Gigabit Ethernet Controller
gec0: Ethernet address 00:aa:bb:cc:dd:10
ukphy0 at gec0 phy 0: Generic IEEE 802.3u media interface
ukphy0: OUI 0x000e4e, model 0x0025, rev. 1
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
gec0: status=00040114
uhub0 at usb0: Star OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub1 at usb1: Star EHCI root hub, class 9/0, rev 2.00/1.00, addr 1
ehci0: strange port
boot device: <unknown>
root on gec0
〜
uhidev0 at uhub0 port 2 configuration 1 interface 0
uhidev0: Dell Dell USB Optical Mouse, rev 2.00/43.01, addr 2, iclass 3/1
ums0 at uhidev0: 3 buttons and Z dir.
wsmouse0 at ums0 (mux ignored)

近くに落ちてたDELLのマウスを挿したら、一応ちゃんと見えているので動いているようだ。
でも ehci0: strange port とか言われてる。何か変? テストに適当なUSB2.0 なデバイス何か無いかな。


そして ether の hardware checksum も support。何故か ip4csum-tx だけ動かない。ip4csum-rx および tcp4csum と udp4csum はちゃんと動く。謎。
速度のほうは、
TX=2.50MB/s, RX=2.85MB/s (FAST_SOFTINT, software checksum)だったのが、
TX=2.65MB/s, RX=2.98MB/s (no FAST_SOFTINT, hardware checksum)くらいになった。ちなみに FAST_SOFTINTS 状態だと
TX=2.75MB/s, RX=3.05MB/s (FAST_SOFTINT, hardware checksum) だけど、腐ってるので封印。

2009-08-15 STR8132その5


イーサをデバッグしたりチューニングしたりリファインしたりして、とりあえず安定動作するようになった。
ring buffer が stall したりするのも回避コードを入れて、かなりロバストになった。
CPU data cache を on にすると動かないのはいつの間にか修ってた。関連しそうな所をいじった覚え無いんだがなぁ。どこかおかしかったんだろう。気にしないことにする。
ftp すると TX=2.50MB/s, RX=2.85MB/s 程度は出る。XScale 266MHz の NSLU2 が RX=1.5MB/s TX=3.2MB/s 程度なので、250MHz にしてはそこそこか。

現在のステータスは

・com, timer, ether が完了
・nfsboot で multiuser までほぼ安定動作。sshd 等も動いて remote login 可能。
・DIAGNOSTIC を付けていると、
 panic: kernel diagnostic assertion "si->si_active" failed: file "../../../../kern/kern_softint.c", line 506
 で落ちる。たぶん割込みまわりで __HAVE_FAST_SOFTINTS なのに softint のダミーの IRQ でマスクとかしてないからだろう。

世界で数人しか必要でないだろうがとってもαなコードを置いてみる

2009-08-13 Sheeva Plug Serial


シリアルは基板上にあるんだけど、ピッチが狭すぎて普通にコンタクト差すだけじゃ隣のピンとショートしてしまう。 いろいろ調べて、ヒロセのDF13のコネクタがほぼ同じ大きさであることがわかったので、西川電子で買ってきて、さらにカッターで加工して、やっとシリアルコネクタを取り付けられた…。 めんどくさいので空中配線 :-P

115200bps。

         __  __                      _ _
        |  \/  | __ _ _ ____   _____| | |
        | |\/| |/ _` | '__\ \ / / _ \ | |
        | |  | | (_| | |   \ V /  __/ | |
        |_|  |_|\__,_|_|    \_/ \___|_|_|
 _   _     ____              _
| | | |   | __ )  ___   ___ | |_
| | | |___|  _ \ / _ \ / _ \| __|
| |_| |___| |_) | (_) | (_) | |_
 \___/    |____/ \___/ \___/ \__|
 ** MARVELL BOARD: SHEEVA PLUG LE

U-Boot 1.1.4 (Mar 19 2009 - 16:06:59) Marvell version: 3.4.16

U-Boot code: 00600000 -> 0067FFF0  BSS: -> 006CEE80

Soc: 88F6281 A0 (DDR2)
CPU running @ 1200Mhz L2 running @ 400Mhz
SysClock = 400Mhz , TClock = 200Mhz

DRAM CAS Latency = 5 tRP = 5 tRAS = 18 tRCD=6
DRAM CS[0] base 0x00000000   size 256MB
DRAM CS[1] base 0x10000000   size 256MB
DRAM Total size 512MB  16bit width
Flash:  0 kB
Addresses 8M - 0M are saved for the U-Boot usage.
Mem malloc Initialization (8M - 7M): Done
NAND:512 MB

CPU : Marvell Feroceon (Rev 1)

Streaming disabled
Write allocate disabled


USB 0: host mode
PEX 0: interface detected no Link.
Net:   egiga0 [PRIME], egiga1
Hit any key to stop autoboot:  0

NAND read: device 0 offset 0x100000, size 0x400000

Reading data from 0x4ff800 -- 100% complete.
 4194304 bytes read: OK
## Booting image at 00800000 ...
   Image Name:   Linux-2.6.22.18
   Created:      2009-03-19   9:18:16 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2106696 Bytes =  2 MB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
OK

Starting kernel ...

Uncompressing Linux.................................................................................................................................... done, booting the kernel.
Linux version 2.6.22.18 (dhaval@devbox) (gcc version 4.2.1) #1 Thu Mar 19 14:46:22 IST 2009
CPU: ARM926EJ-S [56251311] revision 1 (ARMv5TE), cr=00053177
Machine: Feroceon-KW
Using UBoot passing parameters structure
Memory policy: ECC disabled, Data cache writeback
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 4, 32 byte lines, 128 sets
CPU0: D cache: 16384 bytes, associativity 4, 32 byte lines, 128 sets
Built 1 zonelists.  Total pages: 130048
Kernel command line: console=ttyS0,115200 mtdparts=nand_mtd:0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs) rw root=/dev/mtdblock1 rw ip=10.4.50.4:10.4.50.5:10.4.50.5:255.255.255.0:DB88FXX81:eth0:none
PID hash table entries: 2048 (order: 11, 8192 bytes)
Console: colour dummy device 80x30
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 256MB 256MB 0MB 0MB = 512MB total
Memory: 515456KB available (3864K code, 257K data, 104K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16

CPU Interface
-------------
SDRAM_CS0 ....base 00000000, size 256MB
SDRAM_CS1 ....base 10000000, size 256MB
SDRAM_CS2 ....disable
SDRAM_CS3 ....disable
PEX0_MEM ....base e8000000, size 128MB
PEX0_IO ....base f2000000, size   1MB
INTER_REGS ....base f1000000, size   1MB
NFLASH_CS ....base fa000000, size   2MB
SPI_CS ....base f4000000, size  16MB
BOOT_ROM_CS ....no such
DEV_BOOTCS ....no such
CRYPT_ENG ....base f0000000, size   2MB

  Marvell Development Board (LSP Version KW_LSP_4.2.7_patch2)-- SHEEVA PLUG  Soc: 88F6281 A0 LE

 Detected Tclk 200000000 and SysClk 400000000
MV Buttons Device Load
Marvell USB EHCI Host controller #0: c08b8600
PEX0 interface detected no Link.
PCI: bus0: Fast back to back transfers enabled
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
Time: kw_clocksource clocksource has been installed.
IP route cache hash table entries: 16384 (order: 4, 65536 bytes)
TCP established hash table entries: 65536 (order: 7, 524288 bytes)
TCP bind hash table entries: 65536 (order: 6, 262144 bytes)
TCP: Hash tables configured (established 65536 bind 65536)
TCP reno registered
RTC registered
Use the XOR engines (acceleration) for enhancing the following functions:
  o RAID 5 Xor calculation
  o kernel memcpy
  o kenrel memzero
Number of XOR engines to use: 4
cesadev_init(c000c894)
mvCesaInit: sessions=640, queue=64, pSram=f0000000
Warning: TS unit is powered off.
MV Buttons Driver Load
NTFS driver 2.1.28 [Flags: R/O].
JFFS2 version 2.2. (NAND) 息 2001-2006 Red Hat, Inc.
io scheduler noop registered
io scheduler anticipatory registered (default)
Serial: 8250/16550 driver $Revision: 1.61 $ 4 ports, IRQ sharing disabled
serial8250.0: ttyS0 at MMIO 0xf1012000 (irq = 33) is a 16550A
serial8250.0: ttyS1 at MMIO 0xf1012100 (irq = 34) is a 16550A
Loading Marvell Ethernet Driver:
  o Cached descriptors in DRAM
  o DRAM SW cache-coherency
  o Single RX Queue support - ETH_DEF_RXQ=0
  o Single TX Queue support - ETH_DEF_TXQ=0
  o TCP segmentation offload enabled
  o Receive checksum offload enabled
  o Transmit checksum offload enabled
  o Network Fast Processing (Routing) supported
  o Driver ERROR statistics enabled
  o Driver INFO statistics enabled
  o Proc tool API enabled
  o Rx descripors: q0=128
  o Tx descripors: q0=532
  o Loading network interface(s):
    o eth0, ifindex = 1, GbE port = 0
    o eth1, ifindex = 2, GbE port = 1

mvFpRuleDb (dfd00000): 16384 entries, 65536 bytes
Intel(R) PRO/1000 Network Driver - version 7.3.20-k2-NAPI
Copyright (c) 1999-2006 Intel Corporation.
e100: Intel(R) PRO/100 Network Driver, 3.5.17-k4-NAPI
e100: Copyright(c) 1999-2006 Intel Corporation

Warning Sata is Powered Off
NFTL driver: nftlcore.c $Revision: 1.61 $, nftlmount.c $Revision: 1.61 $
NAND device: Manufacturer ID: 0xad, Chip ID: 0xdc (Hynix NAND 512MiB 3,3V 8-bit)
Scanning device for bad blocks
2 cmdlinepart partitions found on MTD device nand_mtd
Using command line partition definition
Creating 2 MTD partitions on "nand_mtd":
0x00100000-0x00500000 : "uImage"
0x00500000-0x20000000 : "rootfs"
ehci_marvell ehci_marvell.70059: Marvell Orion EHCI
ehci_marvell ehci_marvell.70059: new USB bus registered, assigned bus number 1
ehci_marvell ehci_marvell.70059: irq 19, io base 0xf1050100
ehci_marvell ehci_marvell.70059: USB 2.0 started, EHCI 1.00, driver 10 Dec 2004
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
USB Universal Host Controller Interface driver v3.0
usbcore: registered new interface driver usblp
drivers/usb/class/usblp.c: v0.13: USB Printer Device Class driver
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
i2c /dev entries driver
Linux telephony interface: v1.00
Marvell Telephony Driver:
mvBoardVoiceAssembleModeGet: TDM not supported(boardId=0x9)
assembly=-1,irq=-1
mp_check_config: Error, invalid voice assembley mode
md: linear personality registered for level -1
md: raid0 personality registered for level 0
md: raid1 personality registered for level 1
raid6: int32x1     97 MB/s
raid6: int32x2    114 MB/s
raid6: int32x4    122 MB/s
raid6: int32x8    110 MB/s
raid6: using algorithm int32x4 (122 MB/s)
md: raid6 personality registered for level 6
md: raid5 personality registered for level 5
md: raid4 personality registered for level 4
raid5: measuring checksumming speed
   arm4regs  :  1083.600 MB/sec
   8regs     :   754.800 MB/sec
   32regs    :   899.600 MB/sec
raid5: using function: arm4regs (1083.600 MB/sec)
device-mapper: ioctl: 4.11.0-ioctl (2006-10-12) initialised: dm-devel@redhat.com
dm_crypt using the OCF package.
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
mvsdmmc: irq =28 start f1090000
mvsdmmc: no IRQ detect
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).
mvCLAudioCodecRegGet: Error while reading register!
mvCLAudioCodecInit: Error - Invalid Cirrus Logic chip/rev ID!
Error - Cannot initialize audio decoder.at address =0xff<6>ALSA device list:
#0: Marvell mv88fx_snd ALSA driver
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
eth0: started
IP-Config: Complete:
      device=eth0, addr=10.4.50.4, mask=255.255.255.0, gw=10.4.50.5,
     host=DB88FXX81, domain=, nis-domain=(none),
     bootserver=10.4.50.5, rootserver=10.4.50.5, rootpath=
md: Autodetecting RAID arrays.
md: autorun ...
md: ... autorun DONE.
Empty flash at 0x087dd338 ends at 0x087dd800
VFS: Mounted root (jffs2 filesystem).
Freeing init memory: 104K
 * Setting preliminary keymap...                                         [ OK ]
 * Setting the system clock
 * Starting basic networking...                                          [ OK ]
 * Starting kernel event manager...                                      [ OK ]
 * Loading hardware drivers...                                           [ OK ]
 * Setting the system clock
 * Loading kernel modules...                                             [ OK ]  * Loading manual drivers...
 * Setting kernel variables (/etc/sysctl.conf)...                        [ OK ]
 * Setting kernel variables (/etc/sysctl.d/10-console-messages.conf)...  [ OK ]
 * Setting kernel variables (/etc/sysctl.d/10-network-security.conf)...  [ OK ]
 * Setting kernel variables (/etc/sysctl.d/10-process-security.conf)...         error: "vm.mmap_min_addr" is an unknown key
                                                                         [fail]
 * Setting kernel variables (/etc/sysctl.d/10-tcp-timestamps-workaround.c[ OK ]
 * Activating swap...                                                    [ OK ]
FATAL: Could not load /lib/modules/2.6.22.18/modules.dep: No such file or directory
FATAL: Could not load /lib/modules/2.6.22.18/modules.dep: No such file or directory
 * Starting early crypto disks...                                        [ OK ]
FATAL: Could not load /lib/modules/2.6.22.18/modules.dep: No such file or directory
FATAL: Could not load /lib/modules/2.6.22.18/modules.dep: No such file or directory
 * Starting remaining crypto disks...                                    [ OK ]
 * Checking file systems...                                                     fsck 1.41.3 (12-Oct-2008)
                                                                         [ OK ]
 * Mounting local filesystems...                                         [ OK ]
 * Activating swapfile swap...                                           [ OK ]
 * Configuring network interfaces...                                     [ OK ]
 * Setting up console font and keymap...                                 [ OK ]
 * Starting system log daemon...
Ubuntu jaunty (development branch) debian ttyS0

debian login:                                                            [ OK ]
                                                                         [ OK ] * Starting kernel log daemon...
                                                                         [ OK ] * Starting OpenBSD Secure Shell server sshd
                                                                         [ OK ] * Starting periodic command scheduler crond
                                                                               fat: exports duplicate symbol fat_add_entries (owned by kernel)
insmod: error inserting '/boot/fat.ko': -1 Invalid module format

Ubuntu jaunty (development branch) debian ttyS0

debian login:


u-boot

Marvell>> help
?       - alias for 'help'
base    - print or set address offset
boot    - boot default, i.e., run 'bootcmd'
bootd   - boot default, i.e., run 'bootcmd'
bootext2    dev:boot_part1,boot_part2 addr boot_image linux_dev_name
bootm   - boot application image from memory
bootp   - boot image via network using BootP/TFTP protocol
bubt    - Burn an image on the Boot Nand Flash.
chpart  - change active partition
cmp     - memory compare
cmpm    - Compare Memory
cp      - memory copy
cpumap - Display CPU memory mapping settings.
crc32   - checksum calculation
date    - get/set/reset date & time
dclk    - Display the MV device CLKs.
dhcp    - invoke DHCP client to obtain IP/boot params
diskboot- boot from IDE device
echo    - echo args to console
eeprom  - EEPROM sub-system
erase   - erase FLASH memory
ext2load- load binary file from a Ext2 filesystem
ext2ls  - list files in a directory (default /)
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls   - list files in a directory (default /)
fi      - Find value in the memory.
flinfo  - print FLASH memory information
fsinfo  - print information about filesystems
fsload  - load binary file from a filesystem image
g       - start application at cached address 'addr'(default addr 0x40000)
go      - start application at address 'addr'
help    - print online help
icrc32  - checksum calculation
ide     - IDE sub-system
iloop   - infinite loop on address range
imd     - i2c memory display
imm[.b, .s, .w, .l]     - i2c memory modify (auto-incrementing)
imw     - memory write (fill)
inm     - memory modify (constant address)
iprobe  - probe to discover valid I2C chip addresses
ir      - reading and changing MV internal register values.
loop    - infinite loop on address range
ls      - list files in a directory (default /)
map     - Diasplay address decode windows
md      - memory display
me      - PCI master enable
mm      - memory modify (auto-incrementing)
mp      - map PCI BAR
mtdparts- define flash/nand partitions
mtest   - simple RAM test
mv_diag - perform board diagnostics
mv_diag
        - display all available tests
mv_diag all
        - run all available tests
mv_diag test1
        - run specified test
mw      - memory write (fill)
nand                   - NAND sub-system
nboot   - boot from NAND device
nbubt   - Burn a boot loader image on the Boot Nand Flash.
nm      - memory modify (constant address)
pci     - list and access PCI Configuration Space
phyRead - Read PCI-E Phy register
pciePhyWrite    - Write PCI-E Phy register
phyRead - Read Phy register
phyWrite        - Write Phy register
ping    - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
protect - enable or disable FLASH write protection
rarpboot- boot image via network using RARP/TFTP protocol
rcvr    - Satrt recovery process (Distress Beacon with TFTP server)
reset   - Perform RESET of the CPU
resetenv        - Return all environment variable to default.
run     - run commands in an environment variable
saveenv - save environment variables to persistent storage
se      - PCI Slave enable
setenv  - set environment variables
sflash  - read, write or erase the external SPI Flash.
sg      - scanning the PHYs status
sp      - Scan PCI bus.
tftpboot- boot image via network using TFTP protocol
usb     - USB sub-system
usbboot - boot from USB device
version - print monitor version
Marvell>>
Marvell>> printenv
baudrate=115200
loads_echo=0
rootpath=/mnt/ARM_FS/
netmask=255.255.0.0
console=console=ttyS0,115200
CASset=min
MALLOC_len=1
ethprime=egiga0
bootargs_root=root=/dev/mtdblock2 ro
ethmtu=1500
usb0Mode=host
nandEcc=1bit
ethact=egiga0
serverip=10.10.0.2
ipaddr=10.10.0.1
cesvcid=ULULULULULULPPULULULULULDA
bootargs_end=:::DB88FXX81:eth0:none
image_name=uImage
standalone=fsload 0x2000000 $(image_name);setenv bootargs $(console) root=/dev/mtdblock0 rw ip=$(ipaddr):$(serverip)$(bootargs_end) $(mvPhoneConfig); bootm 0x2000000;
mvPhoneConfig=mv_phone_config=dev0:fxs,dev1:fxs
mvNetConfig=mv_net_config=(00:11:88:0f:62:81,0:1:2:3),mtu=1500
yuk_ethaddr=00:00:00:EE:51:81
netretry=no
rcvrip=169.254.100.100
loadaddr=0x02000000
autoload=no
ethaddr=00:50:43:01:D1:EE
run_diag=no
bootargs=console=ttyS0,115200 mtdparts=nand_mtd:0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs) rw root=/dev/mtdblock1 rw ip=10.4.50.4:10.4.50.5:10.4.50.5:255.255.255.0:DB88FXX81:eth0:none
bootcmd=nand read.e 0x800000 0x100000 0x400000; bootm 0x800000
stdin=serial
stdout=serial
stderr=serial
mainlineLinux=no
enaMonExt=no
enaCpuStream=no
enaWrAllo=no
pexMode=RC
disL2Cache=no
setL2CacheWT=yes
disL2Prefetch=yes
enaICPref=yes
enaDCPref=yes
sata_dma_mode=yes
netbsd_en=no
vxworks_en=no
bootdelay=3
disaMvPnp=no
enaAutoRecovery=yes

2009-08-11 Sheeva Plug


msaitoh氏に相乗りしてたSheeva Plugが来たのでとりあえず分解
この大きさと値段で1.2GHzはパフォーマンスいいよなぁ。

部品点数多め。LAN EVOLUTION や CWR-635M とは比較にならないくらいしっかりした作りである。
電源部分は小さい。完全にモジュール。

作り置きのTTLレベルシリアルケーブルが無いので現在作成中。

2009-08-02 STR8100/STR9100デバイスまとめ


これと同じようにNetBSDが動かせると思わしきデバイス。STR9100のコードはまだ書いてないけど、今の所STR8100と違う所は割り込みとEther部分だけだからやりだせばすぐだろう。

AREA LAN EVOLUTION STR8132 250MHz LAN,USB
CNET CWR-635M(※) STR9105 200MHz LAN,USB,mini-pci(WiFi)
COREGA CG-BARPROG STR9102 ?MHz LAN
PLANEX MZK-W04G STR91?? ?MHz LAN,USB,WiFi
NetIndex クティオ STR91?? ?MHz LAN,USB,WiFi,CF

CG-BARPROGはETHERしかないのでかなりどうでもいいけど、MZK-W04Gは欲しい。実質8kくらいか。中古で落ちてないかなあ。
クティオは高い…。あとはCMR-250のCPUが気になる。これも高いけど。

※TRIPLET GATEのTWR-350 or COVENTIVEのCMR-350のOEM

2009-08-01 Eye-Fi


というわけで、超いまさらですが先日EyeFiを買いました。持ってるデジカメが古くてSDHC使えないのでEyeFi Share 2Gです。 いきなし初期不良で涙目だったけど、サポートの対応が結構素早くて、1〜2日で交換完了。

初期登録にはWindows/Macが必要なんだけど、プロトコルはある程度hackされていたのでいろいろ試してみた。

EyeFiManager (on Windows) の動作は

https://api.eye.fi/ へ接続して EyeFiManager の Private Address を登録する (?)
・TCP Port 59748 で Listen して、EyeFi カードからの接続を待ち受ける。
・EyeFi カードから接続されると、SOAP を喋って EyeFiカードから画像を受信する。 その時ついでにサムネイル等を作ってEyeFiサーバへ情報をうpする

EyeFiカード側の動作は

・SSIDをscanする
・scanして接続すべきSSIDがあれば接続、dhcpでアドレスをもらう
https://api.eye.fi/ へ接続して何やら喋る。EyeFiManager の Private Address を教えてもらう
・教えてもらった EyeFiManager の Private Address へ接続する
・接続できなければ、dhcp でもらった subnet 内にあるIPアドレスの存在をarpで調べて、 arp に答えたら片っ端から TCP Port 59748 に接続を試す(ひでえ!)
・EyeFiManager の TCP Port 59748 に接続できたら、SOAP を喋って EyeFiManager へ画像を送信する

EyeFiManager のアドレスを http://api.eye.fi/ に登録する所は SSL なので解析できてないみたいだけど、 EyeFiカードとEyeFiManager間のプロトコルは平文のSOAPなので余裕で解析されていて、 Eye Fi Standalone Server を使えば Windows の EyeFiManager は必要なくなったのでした。めでたしめでたし。


他にもEyeFiカードが直接EyeFiのサーバへ画像をアップロードする設定とかもあるようだ。
この場合、後から起動された EyeFiManager が EyeFi サーバへ接続して画像を取りにいくのかな。
この部分のプロトコルもまだ解析されていないみたい (たぶんhttpsなんでめんどくさいんだろう)


EyeFiカードとおしゃべりするには、EyeFi SDカード内のファイルシステム上に特殊なファイルがあるので、そのファイルに対してread/writeしてやれば良いようだ。
でもこれもまだあまり解析されてないっぽい。

2009-07-30 00:aa:bb:cc:dd:10


糞エアリアの LAN EVOLUTION の firmware として最初から入ってる Linux を立ち上げて、(初めて)WEB画面にアクセスして確認してみたら、mac adderss は 00:22:ec:02:00:f3 になってた。
今使ってる 00:aa:bb:cc:dd:10 は、LAN EVOLUTION の U-Boot の flash の環境変数領域に設定されていた値で、U-Boot の tftpboot はこのふざけた mac address で boot しやがるのですが、 やっぱりどっかにちゃんとした mac address が書かれているんだなぁ。どこだろう。まぁ 00:aa:bb:cc:dd:10 のままでもいいんですが。

というわけで、イーサの続きを書く。

受信時のCRCを含めるか含めないかのビット操作に気づかなくて少しハマったものの、一応 nfsboot でシングルユーザまで動いた。
たまに boot 中に RX FIFO FULL でドライバが止まったりするけど。

パフォーマンス出てないっぽい。CPU のデータキャッシュが disable なままだったり、ドライバがまだヘボヘボチューニングなのもあるけど、根本的に遅いのは RX ring buffer の充填を auto polling にしてるのが悪いんじゃなかろうか。
自前でDMAをハンドリングするように変えてみよう…

NetBSD/evbarm STR81xx/91xx
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 5.99.15 (STR81xx) #868: Thu Jul 30 03:44:56 JST 2009
        ryo@falsie:/src/cvs/NetBSD/sys/arch/evbarm/compile/STR81xx
total memory = 32768 KB
avail memory = 28288 KB
mainbus0 (root)
cpu0 at mainbus0: FA526 rev 1 (ARMv4 core)
cpu0: DC disabled IC enabled WB enabled LABT
cpu0: 8KB/16B 2-way Instruction cache
cpu0: 8KB/16B 2-way write-back-locking-B Data cache
star0 at mainbus0: Star STR8100 Equuleus Family SoC (0x8131eeee)
starclk0 at star0 addr 0x79000000-0x79000047 irq 0: Programmable Timer
com0 at star0 addr 0x78000000-0x7800001f irq 9: ns16550a, working fifo
com0: console
com1 at star0 addr 0x78800000-0x7880001f irq 10: ns16550a, working fifo
gec0 at star0 addr 0x70000000-0x70000133 irq 18: Gigabit Ethernet Controller
gec0: Ethernet address 00:aa:bb:cc:dd:10
ukphy0 at gec0 phy 0: Generic IEEE 802.3u media interface
ukphy0: OUI 0x000e4e, model 0x0025, rev. 1
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
gec_mib_intr:390: sc=0xc4098000, status=0x4<PORT_STATUS_CHG>
boot device: <unknown>
root device: gec_mib_intr:390: sc=0xc4098000, status=0x4<PORT_STATUS_CHG>
gec0
dump device: 
file system (default generic): 
root on gec0
nfs_boot: trying static
nfs_boot: client_addr=172.31.185.8
nfs_boot: gateway=172.31.185.65
nfs_boot: netmask=255.255.254.0
nfs_boot: server=172.31.185.65
nfs_boot: root=172.31.185.65:/src/boot/str8132
gec_init:707: ifp=0xc4099858
gec_stop:809: ifp=0xc4099858
gec_reset:1064
gec_miibus_statchg:1053: status=>00040114
gec_mib_intr:390: sc=0xc4098000, status=0x4<PORT_STATUS_CHG>
root on 172.31.185.65:/src/boot/str8132
root file system type: nfs
WARNING: no TOD clock present
WARNING: using filesystem time
WARNING: CHECK AND RESET THE DATE!
init path (default /sbin/init): 
init: trying /sbin/init
Thu Jul 30 03:48:37 UTC 2009
eval: cannot open /etc/fstab: no such file
mount: Cannot open `/etc/fstab': No such file or directory
mount: Cannot open `/etc/fstab': No such file or directory
mount: Cannot open `/etc/fstab': No such file or directory
mount: Cannot open `/etc/fstab': No such file or directory
mount: /: unknown special file or file system.
swapctl: Cannot open `/etc/fstab': No such file or directory
Starting file system checks:
fsck: Cannot open `/etc/fstab': No such file or directory
fsck: Can't open checklist file: /etc/fstab
Automatic file system check failed; help!
ERROR: ABORTING BOOT (sending SIGTERM to parent)!
1 2009-07-30T03:55:47.998088+00:Enter pathname of shell or RETURN for /bin/sh: 
Terminal type is vt100.                                                 
We recommend that you create a non-root account and use su(1) for root access.
# 
# uname -a
NetBSD  5.99.15 NetBSD 5.99.15 (STR81xx) #868: Thu Jul 30 03:44:56 JST 2009  ryo@falsie:/src/cvs/NetBSD/sys/arch/evbarm/compile/STR81xx evbarm
# cd /etc
# cat > fstab
172.31.185.65:/src/boot/str8132 / nfs rw
^D
# mount /
# df
Filesystem                      1K-blocks       Used      Avail %Cap Mounted on
172.31.185.65:/src/boot/str8132  479777102  130617864  325170384  28% /
# ifconfig -a
gec0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        address: 00:aa:bb:cc:dd:10
        media: Ethernet autoselect (100baseTX full-duplex)
        status: active
        inet 172.31.185.8 netmask 0xfffffe00 broadcast 172.31.185.255
        inet6 fe80::2aa:bbff:fecc:dd10%gec0 prefixlen 64 scopeid 0x1
lo0: flags=8048<LOOPBACK,RUNNING,MULTICAST> mtu 33192
# 

調子にのってマルチユーザにしたら落ちた。

# ^DThu Jul 30 03:51:19 UTC 2009
Not checking /: nfs mounted
Starting file system checks:
Setting tty flags.
Setting sysctl variables:
ddb.onpanic: 1 -> 0
Starting network.
/etc/rc: WARNING: $hostname not set.
IPv6 mode: host
Configuring network interfaces:.
Adding interface aliases:.
Building databases: dev, utmp, utmpx, servicespanic: kernel diagnostic assertion "si->si_active" failed: file "../../../../kern/kern_softint.c", line 506
cpu0: Begin traceback...
0xc3ffdf70
        scp=0xc3ffdf70 rlv=0xc3ffdf54 (0xc3ffdf54)
        rsp=0xc3ffdf44 rfp=0xc0131960
Bad frame pointer: 0xc0131960
cpu0: End traceback...
rebooting...

kern_softintってまたイヤそうな所だな…

2009-07-28 ICMP6


PHY見えたーーーーーーーー。

なぜか U-Boot が起動時に (しかもご丁寧に tftp でカーネルをロードした直後に) Power Management Register (0x77000000〜) の PHY のソフトリセットビットを操作してやがった。なぜそんなことを…リンクダウンさせるため? にしては強引すぎるだろ常考
しかもETHERコントローラのレジスタではなくリセットビット…さらにリセットしっぱなしで寝かせたビットを起こさずに…。理解不能。

というわけで、無事にukphy0が見えた。

NetBSD 5.99.15 (STR81xx) #788: Tue Jul 28 00:33:30 JST 2009
        ryo@falsie:/src/cvs/NetBSD/sys/arch/evbarm/compile/STR81xx
total memory = 32768 KB
avail memory = 28288 KB
mainbus0 (root)
cpu0 at mainbus0: FA526 rev 1 (ARMv4 core)
cpu0: DC disabled IC enabled WB enabled LABT
cpu0: 8KB/16B 2-way Instruction cache
cpu0: 8KB/16B 2-way write-back-locking-B Data cache
star0 at mainbus0: Star STR8100 Equuleus Family SoC (0x8131eeee)
starclk0 at star0 addr 0x79000000-0x79000047 irq 0: Programmable Timer
com0 at star0 addr 0x78000000-0x7800001f irq 9: ns16550a, working fifo
com0: console
com1 at star0 addr 0x78800000-0x7880001f irq 10: ns16550a, working fifo
gec0 at star0 addr 0x70000000-0x70000133 irq 18: Gigabit Ethernet Controller
gec0: Ethernet address 00:aa:bb:cc:dd:10
ukphy0 at gec0 phy 0: Generic IEEE 802.3u media interface
ukphy0: OUI 0x000e4e, model 0x0025, rev. 1
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
boot device: <unknown>
root device: 


            §            §            §


リンクアップさえすれば送信も余裕で動くだろうと思いつつ実行するが…全然ダメだった。うーむ。
しかし、どうも壊れてるっぽい変なパケットを観測。リングバッファのアドレスがおかしい…じゃなくて、キャッシュか? bus_dmamap_syncをきちんと挿入して再度チャレンジすると、違うパケットが出た。

00:34:06.984958 00:aa:bb:cc:dd:10 > 33:33:ff:cc:dd:10, ethertype IPv6 (0x86dd), length 86: :: > ff02::1:ffcc:dd10: HBH ICMP6, multicast listener reportmax resp delay: 0 addr: ff02::1:ffcc:dd10, length 24
        0x0000:  6000 0000 0020 0001 0000 0000 0000 0000  `...............
        0x0010:  0000 0000 0000 0000 ff02 0000 0000 0000  ................
        0x0020:  0000 0001 ffcc dd10 3a00 0100 0502 0000  ........:.......
        0x0030:  8300 c4e9 0000 0000 ff02 0000 0000 0000  ................
        0x0040:  0000 0001 ffcc dd10                      ........

なぜにIPv6…

INET6 な kernel なので、インターフェイスが UP した瞬間にリンクローカルアドレスが付いて NDP を喋ってるからだ。
いやそれはわかるんだけど、nfsboot が出力しているはずの ARP パケットはなぜ出力されないのだろう。


            §            §            §


気分転換していたら気がついた。IPv6のNDPだけ出て、ARPが出ないのはパケット長のせいだった。
調べてみると、CRC含む64byte未満のセグメントは、リングバッファからDMA転送されて送信完了割り込みが来てMIBカウンタまで更新するものの、実際はパケットを出力していなかった。
padding 用のセグメントを bus_dmamem_alloc しておいて、足りないパケットにはパディングセグメントを付け足してやる。

ついでにいろいろ綺麗に書き直す。bus_dmamap_t は物理アドレスだけでなく論理アドレスもMIで保存してくれればいいのに。

来週は受信。

2009-07-26 Embedded PHY


STR81xxのpdfに Gigabit Ethernet Contoller (GEC) と書いてあるので if_gec.c にする。
安直なので後で困りそう。Gigabitと名前が付いてる割に、Embedded な PHY は 10/100M しか対応してない。1G は外付け PHY で実装した時のみだ。

ちなみにSTR91xxの方は
・Embedded Switch Controller (including HNAT and MAC)
・Embedded 4-port Gigabit Switch Engine
とかいう表記があるので if_esc とか if_gse にするか。いまいちパッとしないなぁ。


            §            §            §


送信パケットなmbufをNICのring bufferに展開する所を書いて、ついでに確認のためmbufの中身をprintfしたりするデバッグコードを入れて、送信してみる。試行錯誤しながら、なんとなく動くようになった。
gec_start() で ring bufferを充填して、DMA転送開始。送信完了割り込みも問題なく入る。うはw余裕www送信キター…と思ったら、してくれない。PHYが見えないのだ。
内蔵PHYなのでmiibus経由でアクセスするのじゃなくて、レジスタ直接叩くのかなぁ、とか思っていろいろ試すが、反応しない。MII経由でPHYをread/writeしても0xffffしか読めない。というかそもそもリンクアップさえしてないよ? うーん…

pdfには、STR8132はMIIBUSを持っていないように読み取れるので、そもそもMIIはアクセスできないのだろうと思って各種レジスタを叩きまくるが、やっぱりリンクアップしない。
うーーーーーーーむ。

土日の間、丸二日悩みつつ、やっぱりわからないのでカルドセプトDSをしつつフテ寝する。

2009-07-22 gcc -fno-delete-null-pointer-checks


http://slashdot.jp/linux/article.pl?sid=09/07/22/0121226 http://isc.sans.org/diary.html?storyid=6820 http://tamo.tdiary.net/20090718.html
知らなかった。恐いなぁ。

テスト。

#include <stdio.h>

struct xxx {
	struct xxx *xxx;
};

void
test(struct xxx *p)
{
	struct xxx *pp = p->xxx;

	if (p == NULL)
		return;

	printf("HERE pp=%p\n", pp);
}

# cc -fdelete-null-pointer-checks -O -S test.c

	.file	"test.c"
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string "HERE pp=%p\n"
	.text
.globl test
	.type	test, @function
test:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$16, %esp
	movl	8(%ebp), %eax
	pushl	(%eax)			// pp = p->xxx
	pushl	$.LC0
	call	printf			// printf(...)
	addl	$16, %esp
	leave
	ret
	.size	test, .-test
	.ident	"GCC: (GNU) 4.1.3 20080704 prerelease (NetBSD nb2 20081120)"

無条件にprintfが呼ばれてる。まじか…

# cc -fno-delete-null-pointer-checks -O -S test.c

	.file	"test.c"
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string "HERE pp=%p\n"
	.text
.globl test
	.type	test, @function
test:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$8, %esp
	movl	8(%ebp), %eax
	movl	(%eax), %edx		// pp = p->xxx
	testl	%eax, %eax		// if (p == NULL)
	je	.L4			//	return;
	subl	$8, %esp
	pushl	%edx
	pushl	$.LC0
	call	printf			// printf(...)
	addl	$16, %esp
.L4:
	leave
	ret
	.size	test, .-test
	.ident	"GCC: (GNU) 4.1.3 20080704 prerelease (NetBSD nb2 20081120)"

このように -fno-delete-null-pointer-checks を付けると大丈夫なのだが、-fdelete-null-pointer-checks は -O2 で enable になるので、
zero page触ってfaultしないkernelとか組込みでは -fno-delete-null-pointer-checks 付けとくのが無難。
つーかそれよりも zero page 触ると panic するようにしとくのが一番いい。

2009-07-21 cpu_initclocks


mountrootまで動いたのはいいのだが、main() → configure2() → initclocks() → cpu_initclocks() でタイマが intr_establish された直後から割り込みがかかりっぱなしになる。
dispatcher で interrupt status をクリアしても消えませんよ? なんじゃらほい? と悩んでいた訳なのだが、単に制御レジスタの叩き方がまずいだけだった。
割り込みコントローラに Software Interrupt Register ってのがあるのだが、swi のことか? と思って何も考えず 1 を書いてしまっていたのである。
これは ARM の swi とは全然関係なくて(よく考えりゃあたりまえだ)、IRQをソフト的に発生させる、というレジスタで、そんなものとりあえず使わないので 0x00000000 書いて終了。

これで割り込みは問題なく動くようになった。

次、com_attach_subr() が固まる問題。

実は固まっているのではなく、ものすごく時間がかかっていただけで、偶然気付いたのだが数分放置していたら mountroot まで来ていた。
となると怪しい個所は何かの timeout 待ちか delay くらいしか思いつかず、すぐに判明。
タイマ関連の割り込み設定やレジスタ初期化は cpu_initclocks() で行うようにしているが、com_attach_subr() は cpu_initclocks() よりも先に呼ばれるためタイマが初期化できておらず、delay()が正常に動作していなかったのだった。
timer attach の中で初期化するようにして終わり。

というわけで、VM、割り込み、および timer と com の attach までクリア

Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 5.99.15 (STR81xx) #507: Tue Jul 21 01:35:53 JST 2009
        ryo@falsie:/src/cvs/NetBSD/sys/arch/evbarm/compile/STR81xx
total memory = 32768 KB
avail memory = 28576 KB
mainbus0 (root)
cpu0 at mainbus0: FA526 rev 1 (ARMv4 core)
cpu0: DC disabled IC enabled WB enabled LABT
cpu0: 8KB/16B 2-way Instruction cache
cpu0: 8KB/16B 2-way write-back-locking-B Data cache
star0 at mainbus0: Star STR8100 Equuleus Family SoC (0x8131eeee)
starclk0 at star0 addr 0x79000000-0x79000047: SoC Timer
com0 at star0 addr 0x78000000-0x7800001f irq 9: ns16550a, working fifo
com0: console
boot device: <unknown>
root device: ?
use one of: md0[a-h] ddb halt reboot
root device: ddb
Stopped in pid 0.1 (system) at  netbsd:cpu_Debugger+0x4:        mov     r15, r14

db> show event
evcnt type 1: cpu int 0 = 115
evcnt type 1: cpu int 1 = 75
evcnt type 1: cpu int 9 = 5
evcnt type 0: softint clk/0 = 5
evcnt type 0: callout late/0 = 3
evcnt type 0: crosscall unicast = 2
evcnt type 0: namecache under scan target = 1
db> c
use one of: md0[a-h] ddb halt reboot
root device: halt
syncing disks... done
unmounting file systems... done

The operating system has halted.
Please press any key to reboot.
rebooting...

USBはともかく、GPIOとかRTCとかWatchDogとか軽めのやつもいろいろ残ってるけど、次は当然Etherで。memory diskとかめんどくさいことせずに一気にnfsbootしちゃおう。

2009-07-16 TWR-350


じゃんぱら2号店にTWR-350が8.8kであった。微妙に悩んだものの、無線付いて安いSTR9105デバイスということと、mountrootまで来た記念に買ってきた。いわゆるイーモバ用アクセスポイントルータ。OEMはCWR-635M
いつものように電源入れてみる前に分解。

Mini PCI bus に Ralink の RT2561 が刺さってる。ホットボンドで固定してあったけどパリっと綺麗に取れたので好きなカード刺し放題でなんにでも使えそう。

シリアルっぽいピンにMAX232Cを繋ぐ。(電源入れる前)


TXとRXはどちらかわからないので、一度継いでから電源入れつつシリアルのスピードを9600〜115200まで変えてみて、
ダメだったらTXとRX入れ変えて再度スピード特定。

スピードは38400bps、ピン配置は、外側から順に、RX、VCC、TX、GNDの順でした。(※初出ピンの順序間違えてたので修正しました)
中身は ARMBoot + Linux。


ARMboot 1.1.0 (Dec 20 2005 - 16:07:00)

PEK maintain version 1.3.100000000
ARMboot code: 00000000 -> 00016900

DDR SDRAM Configuration with DDRC Data Bus Width x16:
DDR Bank #0: 00000000 32 MB

*** Using default environment
init pgtable
ttb is at: 40000
pgtconf...
ttbSet
ttbSet OK...

Hit any key to stop autoboot:  0 
done.
## Starting application at 0x0cf00000 ...
Uncompressing Linux............................................................................. done, booting the kernel.
paging_init()....OK
request_standard_resources()....OK
Linux version 2.4.27-uc0-pek3 (stone@user-desktop) (gcc version 3.3.6) #6 篋 9 26 13:58:46 CST 2008
CPU: Faraday FA526id(wb) revision 1
ICache:16KB enabled, DCache:16KB enabled, BTB support
Machine: STAR_STR9100
alloc_bootmem_low
memtable_init
On node 0 totalpages: 8192
zone(0): 8192 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: root=/dev/ram0 mem=32M panic=1
IRQ Timer1 at interrupt number 0x0 and clock 100000000(Hz)
Calibrating delay loop... 153.60 BogoMIPS
Memory: 32MB = 32MB total
Memory: 25460KB available (1905K code, 536K data, 64K init)
Dentry cache hash table entries: 4096 (order: 3, 32768 bytes)
Inode cache hash table entries: 2048 (order: 2, 16384 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 8192 (order: 3, 32768 bytes)
POSIX conformance testing by UNIFIX
PCI: bus0: Fast back to back transfers disabled
pci bridge found 
AHB to bridge interrupt status : 24200000
pci_enable: bus: 0 devfn: 0
pci_enable: bus: 0 devfn: 10
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Journalled Block Device driver loaded
i2c-core.o: i2c core module version 2.6.1 (20010830)
i2c-dev.o: i2c /dev entries driver module version 2.6.1 (20010830)
i2c-proc.o version 2.6.1 (20010830)
Str9100 Serial Driver version 5.05c (2001-07-08) with no serial options enabled
ttyS00 at 0xf7800000 (irq = 10) is a Star_UART
STAR star9100 Driver, v1.9pek-d20cm (11/03/2005) - by PEK & Star Semi.
RAMDISK driver initialized: 16 RAM disks of 14336K size 1024 blocksize
PPP generic driver version 2.4.2
PPP MPPE compression module registered
PPP Deflate Compression module registered
SCSI subsystem driver Revision: 1.00
kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno = 2
kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno = 2
physmap flash device: 800000 at 10000000
phys_mapped_flash: Found 1 x16 devices at 0x0 in 16-bit bank
 Amd/Fujitsu Extended Query Table at 0x0040
phys_mapped_flash: Swapping erase regions for broken CFI table.
number of CFI chips: 1
cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
kmod: failed to exec /sbin/modprobe -s -k cmdlinepart, errno = 2
cmdlinepart partition parsing not available
kmod: failed to exec /sbin/modprobe -s -k RedBoot, errno = 2
RedBoot partition parsing not available
Using physmap partition definition
Creating 3 MTD partitions on "phys_mapped_flash":
0x00000000-0x00040000 : "bootROM"
0x00040000-0x007c0000 : "bootpImage"
0x007c0000-0x00800000 : "User FS"
Linux Kernel Card Services 3.1.22
  options:  [pci] [cardbus]
usb.c: registered new driver usbdevfs
usb.c: registered new driver hub
hcd.c: ehci_hcd @ EHCI, EHCI_HCdriver
hcd.c: irq 24, pci mem c3005000
usb.c: new USB bus registered, assigned bus number 1
USB f.c enabled, EHCI 1.00, driver 2003-Dec-29/2.4
hub.c: USB hub found
hub.c: 2 ports detected
host/usb-ohci_STR.c: USB OHCI at membase 0xc700c000, IRQ 23
host/usb-ohci_STR.c: usb-OHCI, OHCI_HCdriver
usb.c: new USB bus registered, assigned bus number 2
hub.c: USB hub found
hub.c: 2 ports detected
usb.c: registered new driver acm
acm.c: v0.21:USB Abstract Control Model driver for USB modems and ISDN adapters
usb.c: registered new driver usblp
printer.c: v0.13: USB Printer Device Class driver
Initializing USB Mass Storage driver...
usb.c: registered new driver usb-storage
USB Mass Storage support registered.
Linux video capture interface: v1.00
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP, IGMP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 2048 bind 4096)
ip_conntrack version 2.1 (256 buckets, 2048 max) - 328 bytes per conntrack
ip_conntrack_pptp version $Revision: 1.61 $ loaded
ip_nat_pptp version $Revision: 1.61 $ loaded
ip_tables: (C) 2000-2002 Netfilter core team
ipt_recent v0.3.1: Stephen Frost <sfrost@snowman.net>.  http://snowman.net/projects/ipt_recent/
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
Ebtables v2.0 registered
NET4: Ethernet Bridge 008 for NET4.0
Bridge firewalling registered
802.1Q VLAN Support v1.8 Ben Greear <greearb@candelatech.com>
Other stuff added by David S. Miller <davem@redhat.com>
NetWinder Floating Point Emulator V0.97 (double precision)
ds: no socket drivers loaded!
RAMDISK: Compressed image found at block 0
Freeing initrd memory: 4349K
VFS: Mounted root (ext2 filesystem) readonly.
Freeing init memory: 64K
UART IRQ_ports = c0264e18
UART IRQ at interrupt number 0xa
e2fsck 1.25 (20-Sep-2001)
/dev/mtdblock3: clean, 12/32 files, 26/256 blocks
e2fsck 1.25 (20-Sep-2001)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mtdblock3: 12/32 files (0.0% non-contiguous), 26/256 blocks
mount: Mounting /dev/mtdblock3 on /mount failed: Device or resource busy
cp: /mount/nasmac: No such file or directory
cp: `/mount/..' and `/cfg/..' are the same file
crc_sum[fbdd567e]
crc_x[fbdd567e]
cmd[ifconfig eth0 hw ether 0008a1c0457e0008a1c0457f]
SIOCSIFHWADDR: Success
cmd[ifconfig eth1 hw ether 0008a1c0457f]
SIOCSIFHWADDR: Success
check switch mode start
SW_PW
cp: /home/httpd/cgi-bin/welcome_router.html: No such file or directory
check switch mode end
enter SW_MID SW_PW
Using /bin/ovcamchip.o
ovcamchip_core.c: v2.28 : OV camera chip I2C driver
Using /bin/ov511.o
usb.c: registered new driver ov511
ov511_core.c: v2.28 : ov511 USB Camera Driver
Using /bin/pwc.o
pwc Philips webcam module version 9.0.2 loaded.
pwc Supports Philips PCA645/646, PCVC675/680/690, PCVC720[40]/730/740/750 & PCVC830/840.
pwc Also supports the Askey VC010, various Logitech Quickcams, Samsung MPC-C10 and MPC-C30,
pwc the Creative WebCam 5 & Pro Ex, SOTEC Afina Eye and Visionite VCS-UC300 and VCS-UM100.
usb.c: registered new driver Philips webcam
Using /bin/pwcx.o
Warning: loading pwcx will taint the kernel: non-GPL license - Proprietary. See http:pwc Philips webcam decompressor routines version 9.0-BETA-2
//pwc Supports all cameras supported by the main module (pwc).
www.smcc.demon.nl/webcam/tainting.html
  See http://www.tux.org/lkml/#export-tainted for information about tainted modules
Using /bin/spca5xx.o
usb.c: registered new driver spca5xx
spca5xxx.c: spca5xx driver 00.60.01 registered
Using /bin/rt61ap.o
Warning: loading rt61ap will taint the kernel: no license
  See http://www.tux.org/lkml/#export-tainted for information about tainted modules
we are now in Router mode!
device eth0 entered promiscuous mode
device ra0 entered promiscuous mode
killall: pekcmd: no process killed
bre0: port 2(ra0) entering learning state
bre0: port 1(eth0) entering learning state
killall: rt61apd: no process killed
bre0: port 2(ra0) entering disabled state
bre0: port 2(ra0) entering disabled state
device ra0 left promiscuous mode
Using /bin/rt61ap.o
Warning: loading rt61ap will taint the kernel: no license
  See http://www.tux.org/lkml/#export-tainted for information about tainted modules
AuthMode:AuthMode=OPEN
Key1Str=2004012677
Key2Str=2004012677
Key3Str=2004012677
Key4Str=2004012677
DefaultKeyID=1
device ra0 entered promiscuous mode
bre0: port 2(ra0) entering learning state
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
switch_mode=[router]
55555------rmmod usbserial-----
rmmod: usbserial: No such file or directory
USB device changed!
debug FTP: looks like FTP server already DISABLED.
cp: `/cfg/..' and `/mount/..' are the same file

Welcome to
 _____    ____  ___   __
|  __ \  / ___| | |  / /
| | | | | |     | | / /
| | | | | |__   | |/ /
| |_| | |  __|  |    \     Linux (Router with NAS)
|  ___/ | |     |  /\ \
| |     | |___  | |  \ \_
|_|     \_____| |_|   \ _\

STAR(R) STR910x

USB device changed!
dnsmasq: started, version 2.22 cachesize 150
dnsmasq: cleared cache
dnsmasq: reading /etc/resolv.conf

pek>info, udhcpd (v0.9.9-pre) started
error, max_leases value (254) not sane, setting to 251 instead
error, Unable to open /etc/udhcpd.leases.bre0 for reading
bre0: port 1(eth0) entering forwarding state
bre0: topology change detected, propagating
bre0: port 2(ra0) entering forwarding state
bre0: topology change detected, propagating

2009-07-15 mountroot


CFATTACH_DECL_NEW ではなく CFATTACH_DECL を使っていたという比較的つまらないポカだった。修正しつついろいろ試行錯誤して、mountrootまで来た。
試行錯誤と言っても com0 を attach したら止まったので、無理矢理 com attach を return させると以下まで来たのだった。
たぶん割り込みがいいかげんなせいだろう。

Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 5.99.15 (STR81xx) #347: Wed Jul 15 22:22:22 JST 2009
        ryo@falsie:/src/cvs/NetBSD/sys/arch/evbarm/compile/STR81xx
total memory = 32768 KB
avail memory = 28576 KB
mainbus0 (root)
cpu0 at mainbus0: FA526 rev 1 (ARMv4 core)
cpu0: DC disabled IC enabled WB enabled LABT
cpu0: 8KB/16B 2-way Instruction cache
cpu0: 8KB/16B 2-way write-back-locking-B Data cache
star0 at mainbus0: Star Semiconductor, STR8100/STR9100 Network Access Processor
startmr0 at star0 addr 0x79000000-0x79000047: SoC Timer
com0 at star0 addr 0x78000000-0x7800001f irq 9: XXX
boot device: <unknown>
root device: ?
use one of: md0[a-h] ddb halt reboot
root device: ddb
Stopped in pid 0.1 (system) at  netbsd:cpu_Debugger+0x4:        mov     r15, r14

db> bt
netbsd:getdisk+0x10
        scp=0xc00accec rlv=0xc00ad128 (netbsd:setroot+0xf4)
        rsp=0xc02c4e08 rfp=0xc02c4fa0
        r10=0x00e6dcf2 r9=0x00e6de06
        r8=0x00000000 r7=0xc02c4ee8 r6=0x00000001 r5=0xc02c4f70
        r4=0x00000002
netbsd:setroot+0x10
        scp=0xc00ad044 rlv=0xc0068edc (netbsd:main+0x25c)
        rsp=0xc02c4fa4 rfp=0xc02c4fec
        r10=0x00e6dcf2 r9=0x00e6de06
        r8=0xc0210e6c r7=0xc02884dc r6=0x00000002 r5=0x00e6dca4
        r4=0x00000000
netbsd:main+0x10
        scp=0xc0068c90 rlv=0xc00081f0 (netbsd:kernel_text+0x3c)
        rsp=0xc02c4ff0 rfp=0xc02c4ffc
        r10=0x00e6dcf2 r8=0x00e6ffdc
        r7=0x00e6de06 r6=0x00000002 r5=0x00e6dca4 r4=0x20008104
netbsd:kernel_text+0x3c
        scp=0xc00081f0 rlv=0xc010e628 (netbsd:initarm+0x8b4)
        rsp=0xc02c5000 rfp=0x00000000
db> 

rebootもできるようにした。

db> reboot
syncing disks... done
unmounting file systems... done
rebooting...

U-Boot 1.1.4 (Nov 27 2007 - 09:29:18)

U-Boot code: 00000000 -> 0001AF80  BSS: -> 0001FEF4
IRQ Stack: 00e6ff7c
FIQ Stack: 00e6ef7c
RAM Configuration:
Bank #0: 00000000 32 MB
Flash Manufacturer: ST
Flash:  8 MB
In:    serial
Out:   serial
Err:   serial
PLL clock at 250MHz
CPU clock at 250MHz
AHB clock at 125MHz
APB clock at 62MHz

Hit any key to stop autoboot:  0 
Star Equuleus # 

資料見つけてから一ヶ月。思ったより時間かかるなぁ。

2009-07-14 copyright

キタ━━━━━━

## Starting application at 0x21000000 ...

NetBSD/evbarm STR81xx/91xx
physmemory: 8192 pages at 0x00000000 -> 0x01ffffff
freestart = 0x002a2000, free_pages = 7518 (0x00001d5e)
Allocating page tables
initarm: kernel_l1pt: 0xc02a4000:0x2a4000
initarm: kernel_pt_table:
        0xc02a2000:0x2a2000
        0xc02a3000:0x2a3000
        0xc02a8000:0x2a8000
        0xc02a9000:0x2a9000
        0xc02aa000:0x2aa000
        0xc02ab000:0x2ab000
        0xc02ac000:0x2ac000
        0xc02ad000:0x2ad000
        0xc02ae000:0x2ae000
        0xc02af000:0x2af000
        0xc02b0000:0x2b0000
        0xc02b1000:0x2b1000
        0xc02b2000:0x2b2000
        0xc02b3000:0x2b3000
        0xc02b4000:0x2b4000
FIQ stack: p0x002b6000 v0xc02b6000
IRQ stack: p0x002b7000 v0xc02b7000
ABT stack: p0x002b8000 v0xc02b8000
UND stack: p0x002b9000 v0xc02b9000
SVC stack: p0x002ba000 v0xc02ba000
Creating L1 page table at 0x002a4000
Mapping kernel
Constructing L2 page tables
Mapping the vector page
switching to new L1 page table  @0x2a4000...done.
init subsystems: stacks vectors undefined page pmap irq done.
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 5.99.15 (STR81xx) #305: Tue Jul 14 21:19:27 JST 2009
        ryo@falsie:/src/cvs/NetBSD/sys/arch/evbarm/compile/STR81xx
total memory = 32768 KB
avail memory = 28612 KB
mainbus0 (root)
cpu0 at mainbus0: FA526 rev 1 (ARMv4 core)
cpu0: DC disabled IC enabled WB enabled LABT
cpu0: 8KB/16B 2-way Instruction cache
cpu0: 8KB/16B 2-way write-back-locking-B Data cache
panic: config_devalloc: star
Stopped in pid 0.1 (system) at  netbsd:cpu_Debugger+0x4:        mov     r15, r14

db> 
db> 
db> reboot

The operating system has halted.
Please press any key to reboot.

rebooting...

CPUのデータキャッシュ(CPU_CONTROL_DC_ENABLE)をOFFにしたら動いた。
そもそもNetBSDのFA526サポートはちゃんと動いてるのか疑惑ががが

ちなみにdata cache enableのままだと、vmをallocした個所を触ってfaultしてdata_abort_handler内でpmapがTLB埋めてreturnした後、再度同じアドレスでfault、という風にループしてた。
TLB設定した後にcache invalidateしてやればcache enableでも動くんじゃなかろうか。まぁいいや。些末な問題っぽいので後にしよ。
…というか動かなかったのオレジャネーーーーーーーーーーーーーー!!!!!!!

panic: config_devalloc: star は何かポカしてるだけだろう。
さて、これでやっと割り込みで遊べるお。

2009-07-09 pmap


serialがうまく動かなかったのは単に bus_space_tag が違っただけだった。8bit I/O を 32bit に map するべく a4x_space を使えば ok。comのクロックの設定の所だけ com.c の中で微妙に場合分け。
しかし arm の bus_space まわりも同じファイルがいろいろコピペされてるなぁ。bus幅変換はbus_spaceの基本機能として汎用的に作れそうな気がするのだが。

そして

panic: pmap_map_entry: no L2 table for VA 0xffff0000

は、「0xffff0000 に対応する L2 table entry が L1 table に無い」ということだった。
それくらい自動でやってよ pmap! とも思ったけど l2 table 領域の確保とかもあるからそうもいかないのか。

ちなみに STR81xx/91xx は 0x00080000 または 0x001000000 バイト毎に I/O が広く分布していてなかなか大変で、
star/star_machdep.c では pmap_devmap[] 以下のぶんだけ30エントリほど並べて書いている。
L1 table のサイズは 0x00100000 なので、ほぼ1デバイスで1エントリ分L1 tableを消費してしまう。

                                        PA         VA
--------------------------------------- ---------- -----------
STR8100_FLASH_SRAM_MEMORY_BANK0         0x10000000 0xE1000000
STR8100_FLASH_SRAM_MEMORY_BANK1         0x11000000 0xE1100000
STR8100_FLASH_SRAM_MEMORY_BANK2         0x12000000 0xE1200000
STR8100_FLASH_SRAM_MEMORY_BANK3         0x13000000 0xE1300000
STR8100_IDE_DEVICE_REGISTER_SPACE       0x18000000 0xE1800000
STR8100_SPI_SERIAL_FLASH_MEMORY         0x30000000 0xE3000000
STRx100_GENERIC_DMA_REGISTER            0x60000000 0xE6000000
STR8100_NIC_REGISTER                    0x70000000 0xE7000000
STR8100_SPI_PCM_TWI_IS_REGISTER         0x71000000 0xE7100000
STR8100_SDR_DDR_SDRAM_CONTROL_REGISTER  0x72000000 0xE7200000
STR8100_STATIC_MEMORY_CONTROL_REGISTER  0x73000000 0xE7300000
STR8100_IDE_CONTROL_REGISTER            0x74000000 0xE7400000
STRx100_MISC_REGISTER                   0x76000000 0xE7600000
STRx100_POWER_MANAGEMENT_REGISTER       0x77000000 0xE7700000
STRx100_UART0_REGISTER                  0x78000000 0xE7800000
STR8100_UART1_REGISTER                  0x78800000 0xE7880000
STRx100_TIMER_REGISTER                  0x79000000 0xE7900000
STRx100_WATCH_DOG_TIMER_REGISTER        0x7A000000 0xE7A00000
STRx100_REAL_TIME_CLOCK_REGISTER        0x7B000000 0xE7B00000
STRx100_GPIOA_REGISTER                  0x7C000000 0xE7C00000
STR8100_GPIOB_REGISTER                  0x7C800000 0xE7C80000
STRx100_PCI_CONFIGURATION_DATA_REGISTER 0xA0000000 0xEA000000
STRx100_PCI_CONFIGURATION_ADDR_REGISTER 0xA4000000 0xEA400000
STRx100_PCI_IO_SPACE                    0xA8000000 0xEA800000
STRx100_PCI_MEMORY_SPACE                0xB0000000 0xEB000000
STRx100_USB11_CONFIGURATION_REGISTER    0xC0000000 0xEC000000
STRx100_USB11_OPERATION_REGISTER        0xC4000000 0xEC400000
STRx100_USB20_CONFIGURATION_REGISTER    0xC8000000 0xEC800000
STRx100_USB20_OPERATION_REGISTER        0xCC000000 0xECC00000
STR8100_USB11_20_DEVICE_REGISTER        0xD0000000 0xED000000
STR8100_INTERRUPT_CONTROL_REGISTER      0xFFFFF000 0xEFFFF000

たくさんあるとTLBのパフォーマンスにも影響しそうな気が。それともcacheするのはpage単位だからそうでもない?
FlashとPCI(STR8132には無いけど)はともかく、その他のデバイスは1MByteも領域要らないので、もっと小さな領域にまとめてL1 tableのエントリ2〜3個で済ましたほうがいいのかな。

さて、おかしかった所を修正して実行。

## Starting application at 0x21000000 ...

NetBSD/evbarm STR81xx/91xx
kerneldatasize=2835336
physmemory: 8192 pages at 0x20000000 -> 0x21ffffff
freestart = 0x202b5000, free_pages = 7499 (0x00001d4b)
Allocating page tables
FIQ stack: p0x202e2000 v0xc02e2000
IRQ stack: p0x202e3000 v0xc02e3000
ABT stack: p0x202e4000 v0xc02e4000
UND stack: p0x202e5000 v0xc02e5000
SVC stack: p0x202e6000 v0xc02e6000
Creating L1 page table at 0x202b8000
Mapping kernel
Constructing L2 page tables
Mapping the vector page
devmap_bootstrap
switching to new L1 page table  @0x202b8000...done.
init subsystems: stacks vectors undefined page pmap irq done.


…の後固まった。むーん。
printfで調べてみると、どうも initarm() → main() → cpu_startup() まではちゃんと来ていて、
cpu_startup() からさらに pmap_postinit() の中で pool_grow した後の pool_item を触る所で固まっている。
これは fault が起こるべきなのに起きていないということか?
ARM_VECTORS_HI も ARM_VECTORS_LOW も試したのだがダメだった。arch/evbarm/star/star_machdep.c にはもうおかしな個所は無いはずだ。
何故だろう。arch/arm の方も読んでいかないとダメか…。

pdfともにらめっこ。

2009-06-30 panic

evbarm で KERNEL_BASE_PHYS が $xx200000 になってて前半2MbyteがMOTTAINAIのは、l1table や stack に使われてるのでMOTTAINAくないんじゃないかとymdさんに教えてもらった。
なるほど、確かにl1tableとstackに使っている。…が、l1tableは16kbyteあればいいし、stackも仮設定で sys/arch/arm/arm32/locore.S の中で svcstk としてちゃんと確保されなおすので、やっぱり 2Mbyte は取りすぎのような気がする。evbarm/orion_nas は 32kbyte だった。これくらいなら納得だ。

メモリレイアウトをどうしようかダラダラ考えていてあまり進んでなかったのだが、kernel を flash に置いたまま実行というのもしたいなぁ、と思って各領域を細かく l1table に登録することも少し考えてみたが、data セクションとかは結局 copy しなきゃならないし ldscript を別にしなきゃいけないしでめんどくさそうなので日和る。

案1。kernelがメモリに置かれた場合(0x21000000)は、0x20000000-0x21FFFFFF および kernel の後ろを VM にする。
とてもめんどくさそう。

RAM	0x20000000 (U-Boot)		→ VM
RAM	0x20F00000			→ VM
RAM	0x21000000 (kernel)		→ KERNEL(0xC0000000) + VM + msgbuf
RAM end	0x22000000

案2。起動直後に 0x21000000 (または任意の場所) にロードされた自分自身を 0x20000000 にコピーする。
0x20000000〜 は U-Boot の領域とバッティングするが、割り禁にすればたぶん問題ない。

RAM	0x20000000 (U-Boot)		→ KERNEL(0xC0000000) + VM
RAM	0x20F00000			→ VM
RAM	0x21000000 (kernel→copy)	→ VM + msgbuf
RAM end	0x22000000

案3。kernelをflash(ROM)に置いたまま。
起動時に data section を FLASH から RAM へコピーしなければならない。ldscript で text と data の位置を考えて指定する必要がある。
とてもめんどくさそう。やるとしても後から考えよう。

FLASH	0x10000000 (kernel on flash)	→ KERNEL(0xC0000000)
RAM	0x20000000 (U-Boot)		→ DATA
RAM	0x20F00000			→ VM
RAM	0x21000000			→ VM + msgbuf
RAM end	0x22000000

というわけで素直に案2にする。


            §            §            §


star_start.S と star_machdep.c をガリガリ書いて、デバッグ用のシリアル直書き関数を携えて実行。
再配置のための自分自身のコピーもMMU Enableもできたようだ。デバッグ用のUART直叩きputc関数により、0xC0000000の仮想アドレスで実行できていることは確認。ヮーィ

しかし copyright は未だ表示されない。どうも consinit() で止まっているようだ。
どうやらこのUARTもなんちゃって16C550互換な様子。com.c に場合分けが必要。
でもこのせいではない。どうも bus_space_map が変っぽいなぁ…

とりあえず無理矢理comcnattachを通してやるとpanic()が動いた。

Load address: 0x21000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################
done
Bytes transferred = 2578976 (275a20 hex)
## Starting application at 0x21000000 ...
0xc010c06c
HELLO
consinit:start
iobase:0x78000000	# 注: このへんは生々しいprintf debugの跡
iot:0xc027b9bc
ioh:0xf7800000
consinit:done
Hello?

NetBSD/evbarm STR81xx/91xx
panic: No support for this CPU type (66015260) in kernel


なにそれこわい


            §            §            §


よく見たら options CPU_FA526 の入れ忘れだった。
気をとり直しして再度ビルドして実行。

NetBSD/evbarm STR81xx/91xx
physmemory: 8192 pages at 0x20000000 -> 0x21ffffff
freestart = 0x202b4000, free_pages = 7500 (0x00001d4c)
Allocating page tables
pv_pa = 202b4000, L1_TABLE_SIZE=16384
IRQ stack: p0x202c2000 v0xc02c2000
ABT stack: p0x202c3000 v0xc02c3000
UND stack: p0x202c4000 v0xc02c4000
SVC stack: p0x202c5000 v0xc02c5000
Creating L1 page table at 0x202b4000
Mapping kernel
pmap_map_chunk: pa=0x20000000 va=0xc0000000 size=0x20c000 resid=0x20c000 prot=0x3 cache=1
SSPPPPPPPPPPPP
pmap_map_chunk: pa=0x2020c000 va=0xc020c000 size=0xa8000 resid=0xa8000 prot=0x3 cache=1
PPPPLLLLLLLLLLPPPP
Constructing L2 page tables
pmap_map_chunk: pa=0x202c2000 va=0xc02c2000 size=0x1000 resid=0x1000 prot=0x3 cache=1
P
pmap_map_chunk: pa=0x202c3000 va=0xc02c3000 size=0x1000 resid=0x1000 prot=0x3 cache=1
P
pmap_map_chunk: pa=0x202c4000 va=0xc02c4000 size=0x1000 resid=0x1000 prot=0x3 cache=1
P
pmap_map_chunk: pa=0x202c5000 va=0xc02c5000 size=0x2000 resid=0x2000 prot=0x3 cache=1
PP
pmap_map_chunk: pa=0x202b4000 va=0xc02b4000 size=0x4000 resid=0x4000 prot=0x3 cache=2
PPPP
pmap_map_chunk: pa=0x202b8000 va=0xc02b8000 size=0x1000 resid=0x1000 prot=0x3 cache=2
P
pmap_map_chunk: pa=0x202b9000 va=0xc02b9000 size=0x1000 resid=0x1000 prot=0x3 cache=2
P
pmap_map_chunk: pa=0x202ba000 va=0xc02ba000 size=0x1000 resid=0x1000 prot=0x3 cache=2
P
pmap_map_chunk: pa=0x202bb000 va=0xc02bb000 size=0x1000 resid=0x1000 prot=0x3 cache=2
P
pmap_map_chunk: pa=0x202bc000 va=0xc02bc000 size=0x1000 resid=0x1000 prot=0x3 cache=2
P
pmap_map_chunk: pa=0x202bd000 va=0xc02bd000 size=0x1000 resid=0x1000 prot=0x3 cache=2
P
pmap_map_chunk: pa=0x202be000 va=0xc02be000 size=0x1000 resid=0x1000 prot=0x3 cache=2
P
pmap_map_chunk: pa=0x202bf000 va=0xc02bf000 size=0x1000 resid=0x1000 prot=0x3 cache=2
P
pmap_map_chunk: pa=0x202c0000 va=0xc02c0000 size=0x1000 resid=0x1000 prot=0x3 cache=2
P
panic: pmap_map_entry: no L2 table for VA 0xffff0000

むー。star_machdep.c が適当だからっぽいなぁ。もうちょっとちゃんと読もう。

2009-06-25 STR8132その4

割り込みまわりとcomとtimer入りのkernelはビルドできるようになった。まだ動かないけど。

めんどくさいからとりあえずメモリ32Mあるうちの16Mbyte目、0x21000000 にロードして VA=PA でマッピングして
go すりゃいいやと思ってたら、

kernel text	0xC0000000 〜 0xC1FFFFFF
kernel vm	0xC1000000 〜 0xCFFFFFFF
I/O, SoC regs	0xF0000000 〜 0xFFFFFFFF

みたいにしないとだめっぽいなあ。特にI/Oアドレス空間。
少くともSTR81xx/STR91xx みたいにメモリ空間の大半を占有してしまうようなレイアウトを、もっと狭くマッピングしなおしてやらないとダメっぽ。

そういえば最初に見た linux のパッチもそんなことしてたような、と思って見てみたら、確かに

#define IO_BASE              0xF0000000
#define IO_ADDRESS(x)        (((x >> 4) & 0xffff0000) + (x & 0xffff) + IO_BASE)

として 0x12345678 を 0xf1235678 にマッピングしなおしていた。こいつかー。


            §            §            §


メインメモリ32Mbyteのうち、メモリの頭(0x20000000)から15Mbyte(!)をU-Bootが使っていて、
ここにloadしてしまうとloadした瞬間にU-Bootが落ちてしまう。
netbsd.bin を 0x21000000 にロードして、こんな感じにすればいいのかな。

	Physical Addr
------- -----------------------
FLASH	0x10000000		→ mapped I/O (0xF1000000〜? 空間足りる?)
SoC reg	0x18000000		→ mapped I/O (0xF1800000〜)

RAM	0x20000000 (U-Boot)	→ VM
RAM	0x20F00000		→ VM
RAM	0x21000000		→ KERNEL_TEXT(0xC0000000) + VM + msgbuf
RAM end	0x22000000		

SoC reg	0x30000000		→ mapped I/O (0xF3000000〜)
SoC reg	     :			→ mapped I/O (0xFx000000〜)
SoC reg	0xFFFFFFFF		→ mapped I/O (0xFF000000〜)

0x21000000あるいは任意の場所にロードした後、割り禁にして自分自身を0x20000000にコピーして0x20000000から実行、のほうがレイアウト的には綺麗だしcopyしてjumpまでをrelocatableに書いとけばどこにロードしても動くので汎用性がありそうだが…。
つーか evbarm で KERNEL_BASE_PHYS が $xx200000 になってるやつがいくつかあるけど、前半2Mbyteは放置してるんだろうか、それとも使ってはいけない領域だから触ってないだけなんだろうか。2MbyteもMOTTAINAI!
ちゃんと使い切ってるようには見えないが…

次は evbarm/star/star_machdep.c と evbarm/star/star_starup.S あたりを。

2009-06-19 STR8132 その3

IPLのコマンドでメモリいじってあそぶ。
GPIOA (0x7c000000) に 0x00000000/0xFFFFFFFF を書いたら LED が明滅した。
System clock control register (0x7700000c) の RTC_Sel を 1 (25MHzソース) にしたら、RTC (0x7b000000) が動き出した。

というわけで、がんばってずらずら書いた。う〜ん、作業チック。めんどくさい度up。
STR81xx と STR91xx は割り込みレジスタの設定がぜんぜん違うのでbusも別にしようと思ったけど、configが綺麗じゃないなぁ。
ifdefか動的に切り分ければいいや。というわけで

# STR81xx(Equuleus Family), STR91xx(Orion Family) System-on-chip
star0 at mainbus?

# On-board UARTs
com0		at star? addr 0x78000000 irq 9	# UART0

にする。来週は star_intr.[ch] あたりを。

ところで糞エアリア以外でSTR81xx/STR91xxな安いデバイスは他に無いもんか。

STR9105 - TWR-350 (CWR-635M)
http://su-u.jp/juju/%CA%AC%B2%F2%A4%B7%A4%C6%A4%DF%A4%E8%A4%A6/TWR-350.html http://www.cnet.com.tw/product/cwr-635m.html
STR9102 - CG-BARPROG
http://bb.watch.impress.co.jp/cda/review/10671.html
STR910? - MZK-W04G
http://www.planex.co.jp/product/router/mzk-w04g/

2009-06-17 STR8132 その2


これまでのあらすじ123


エアリアにGPLだからソースくれくれメールを出したものの、ずっと放置され続けてかなりどーでもよくなってた今日この頃ですが、
ふと思ってgoogle先生じゃなくてbing先生に聞いたら色々資料が見つかった。googleもうだめぽ。

そして「少々お時間を頂けますでしょうか」の返事のあと、メールに一切反応しなくなった株式会社エアリアは死ね。


            §            §            §


http://www.cnusers.org/ から辿ってこれのようだ。
うひょー。メモリマップ載ってるぅ。

というわけで、serialは0x78000000?

linuxのSTR9100 用のパッチも見てみると、やっぱりデバイスまわりはSTR9100とあまり違わなかったっぽい。

#define APB_DEVICES_UART_BASE_OFFSET               (0x08000000)
#define SYS_APB_DEVICES_BASE_ADDR              (0x70000000)
#define SYS_MEM_MAP_ADDR(region_name)    (SYS_##region_name##_ADDR)
#define APB_DEVICES_BASE_ADDR                          SYS_MEM_MAP_ADDR(APB_DEVICES_BASE)
#define APB_DEVICES_MEM_MAP_ADDR(regname)   (APB_DEVICES_BASE_ADDR + APB_DEVICES_##regname##_OFFSET)
#define UART_BASE_ADDR       APB_DEVICES_MEM_MAP_ADDR(UART_BASE)

STR9100も0x78000000だ。
というわけで、実機にて

Star Equuleus # coninfo
List of available devices:
serial   80000003 SIO stdin stdout stderr
Star Equuleus # help mw
mw [.b, .w, .l] address value [count]
    - write memory

Star Equuleus # mw.b 0x78000001 0x40
@Star Equuleus #

とすると "@" が一文字出力できていることを確認。やふー。

つーか、tinyhackの中の人はSTR9104でFreeBSD multiuserまでできてるよ。

しかしどうもARMは種類が多すぎて何が同じで何が違うのかわけがわからんな…
Marvel OrionとStar Orionはぜんぜん別物なのか。まぎらわしい。

2009-05-25 AIR BONE ZT-351


ブレーキレバーが物故割れたのでサイクルベースあさひでブレーキを注文したついでに AIR BONE ZT-351 も買ってみた。ちょっと面白いかも。
デジカメ付けて試し撮りしたら、振動のためかSDカードアクセスエラーで止まりまくりだったが、カードスロットの遊びをテープで適当に補強すればエラーが出なくなった。
家から会社まで20分弱、全工程録画成功!

下はその一部。タシーロ通り中古ロード前あたりから中央通りまで。横断歩道を渡りましょう(ぉ


揺れるのはあとからソフトで補正できないもんか。

2009-05-21 NetBSD src/usr.sbin/inetd


この 変更

@@ -649,6 +649,7 @@
 	char buf[NI_MAXSERV];
 	struct servtab *s;
 #ifdef LIBWRAP
+	char abuf[BUFSIZ];
 	struct request_info req;
 	int denied;
 	char *service = NULL;	/* XXX gcc */
@@ -672,17 +673,19 @@
 				    ntohs(sep->se_ctrladdr_in.sin_port));
 			}
 			service = buf;
+			sockaddr_snprintf(abuf, sizeof(abuf), "%a",
+			    &sep->se_ctrladdr);
 		}
 		if (denied) {
 			syslog(deny_severity,
-			    "refused connection from %.500s, service %s (%s)",
-			    eval_client(&req), service, sep->se_proto);
+			    "refused connection from %.500s(%s), service %s (%s)",
+			    eval_client(&req), abuf, service, sep->se_proto);
 			goto reject;
 		}
 		if (lflag) {
 			syslog(allow_severity,
-			    "connection from %.500s, service %s (%s)",
-			    eval_client(&req), service, sep->se_proto);
+			    "connection from %.500s(%s), service %s (%s)",
+			    eval_client(&req), abuf, service, sep->se_proto);
 		}
 	}
 #endif /* LIBWRAP */

…の本来の意図は、↓のように

@@ -672,7 +672,7 @@
 			}
 			service = buf;
 			sockaddr_snprintf(abuf, sizeof(abuf), "%a",
-			    &sep->se_ctrladdr);
+			    req.client->sin);
 		}
 		if (denied) {
 			syslog(deny_severity,

こうしたかったのではなかろうか。

bindしてるアドレスを表示したいんじゃなくて、クライアントのアドレスを表示したいんだよなぁ。どう考えても。
どうPRすればいいんだろう? :-P 誰か(ry
追記:

ちゃんと元のPRまで追って見たらやっぱりその意図だった。http://mail-index.netbsd.org/netbsd-bugs/2009/01/07/msg008213.html というか何で誰も気(r
誰か(

追記(2):

がんばってメールした。

2009-05-18 simple twitter client

simple twitter client with Net::Twitter (perl)
friend timelineの表示、指定idのtimelineの表示、public timelineの表示、およびポストができる。
特徴としては、一度取得したメッセージは ~/.twitter/cache/<id>.yaml にひたすらキャッシュする。

2009-05-18 /usr/bin/top: show full commandline patch

/usr/bin/top で argv をぜんぶ表示する。
m_netbsd.c-netbsd-5-diff(for NetBSD-5.0)
m_netbsd.c.diff(for NetBSD current)

2009-04-20 Hashed and Hierarchical Timing Wheels

これは "Hashed and Hierarchical Timing Wheels: Efficient Data Structures for Implementing a Timer Facility" by George Varghese and Tony Lauck. というアルゴリズムとほぼ同じということを、sys/kern/kern_timeout.c を読んで知った。
再発明ですかそうですか。

2009-04-04 canvasで遊ぶ

cgiでrrdtoolとかの結果をjson形式にして返して、AJAXでグラフをクライアント側でヌルヌルと好きなように描画させるようなものを作るべく、
Canvasチュートリアルを見ながら色々いじってたのだが、DrawText()は今の所mozillaにしか実装されてないのね…
このへんの人も、divで文字を置いてcanvasの上に配置してるなあ。でもdivだとtranslateとかrotateとか使えないし。

というわけで、フォントデータを内部に用意して自前で文字描画するものを作った。グラフの目盛りはこれで描こう。


※ちなみにフォントは昔某ポケステ同人ゲーム用に自作したものなのでcopyrightに問題ありません。

※canvasの無いIEでは当然動きません。ExplorerCanvasでもdrawImage()がちゃんと実装されていないらしく動きません

2009-03-12 timetable queue

花粉激し杉。花の粉パランのおつとめソングを聴きながら花粉日和を過ごしている今日この頃です。

さて、設定された時刻でtimeoutする必要のある大量のオブジェクトがあって、これらに自動expire機能を持たせる場合、
普通は全オブジェクトをリストにしておいて定期的に一部または全部を辿ってtimeoutしていたらdestroy、のような処理をする訳ですが、
くしゃみをしながら効率の良い実装を思いついたので基幹部分を作ってみました。

X1, X2, ..., Xn のオブジェクトがあって、timeoutメンバに生存限界時刻が格納されているとする。
X(t) が timeout=t を表すとしよう。

ここで時間別のタイムアウトテーブルを用意する。

現在時刻 = 123000

timeout[9] X98(123010) X99(123010) ...          ※あと10秒
timeout[8] X97(123009) ...                      ※あと9秒
       :
timeout[1] X4(123002) X5(123002) ...            ※あと2秒
timeout[0] X1(123001) X2(123001) X3(123001) ... ※あと1秒

こんな感じで各timeout毎にグループを作ってリストにしておく。expire のチェックは1秒間隔で行えばいいとして、次の expire チェックでは timeout[0] のリストだけをチェックすれば十分である。
その後はこのテーブルをシフトさせて、

現在時刻 = 123001

timeout[9]                                     ※あと10秒
timeout[8] X98(123010) X99(123010) ...         ※あと9秒
timeout[7] X97(123009) ...                     ※あと8秒
       :
timeout[0] X4(123002) X5(123002) ...           ※あと1秒

とさせて、以下同様にくり返せばok。

さて、任意のオブジェクトは、必要であれば timeout を延長することができる。
上の状態から X4 の timeout を5秒後に再設定する場合は、X4 を timeout[0] のリストからの削除して、timeout[4] のリストへ追加すればいい。

現在時刻 = 123001

timeout[9]                                     ※あと10秒
timeout[8] X98(123010) X99(123010) ...         ※あと9秒
timeout[7] X97(123009) ...                     ※あと8秒
       :
timeout[4] X4(123006)                          ※あと5秒
       :
timeout[0] X5(123002) ...                      ※あと1秒

ところで、timeout[] 配列は有限であり、今回は長さ10の配列で、timeout[9] が末尾となる。
X4 の timeout を今度は5秒ではなく15秒後に設定したい場合は、timeout[15] に設定したい所だが存在しないので、末尾の timeout[9] に入れなおす。

現在時刻 = 123001

timeout[9] X4(123016)                          ※あと10秒(以上)
timeout[8] X98(123010) X99(123010) ...         ※あと9秒
timeout[7] X97(123009) ...                     ※あと8秒
       :
timeout[0] X5(123002) ...                      ※あと1秒

この状態で8秒経つと8回expireチェックが走り、以下のような状態となる。

現在時刻 = 123009

timeout[9]                                 ※あと10秒
       :
timeout[1] X4(123016)                      ※あと2秒(以上)
timeout[0] X98(123010) X99(123010) ...     ※あと1秒

X98, X99 はテーブル通りの残り時間なのでいいとして、X4の寿命はまだ残り7秒ある(15秒に設定してから8秒しか経っていないので)。
さらに1秒経つと以下のようになる。

現在時刻 = 123010

timeout[9]                     ※あと10秒
timeout[8]                     ※あと9秒
       :
timeout[1]                     ※あと2秒
timeout[0] X4(123016)          ※あと1秒(以上)

よってtimeout[0]に所属するオブジェクトは、残り時間1秒であるという仮定は成り立たないため、
expireチェックでもちゃんと残り秒数を調べてからtimeout処理をしなければならない。
残り秒数が1以下でないオブジェクトは、再度残り時間に対応するtimeoutテーブルに登録することにする。

現在時刻 = 123011

timeout[9]                     ※あと10秒以上
       :
timeout[4] X4(123016)          ※あと5秒以上
       :
timeout[0]                     ※あと1秒以上

このようにexpireチェック時にtimeout[0]のオブジェクトの残り秒数を調べ、必要であればdestroyまたは再配置を行うのであれば、
timeoutを大きくする方向で設定する場合は、いちいちリストからの削除追加しなくても良くなる。(別にやってもいい)
逆にtimeoutを小さくする場合は、リストの削除追加は *必須* になる。

というわけで、上記構造を簡単に実現するためのマクロを作った
使い方は sys/queue.h とほぼ同じインターフェイス。サンプル

そのうち時期を見てSEILのNATとfilterのステートで使ってみるテスト。
ちなみにpfもこういう工夫はしてなかった。その代わり、毎回全ステートを調べるのではなく一定数ずつ調べることで重くなるのを防いでいた。


EOF