最近はもっぱらラズパイで有名なBroadcomですが、昔はMIPSのSOCを作っていました。
この頃のブートローダーはCFEをいう独自のものでした。
CFEはu-bootと同じようにtftpが使えるのですが、今いじっているターゲットにはEthernetの口がありません。
幸いSPI Flashを取り外し可能にしたので、flashromでfirmwareを焼いてみます。
まずflashromでオリジナルのfirmwareを読み出します。
$ flashrom --programmer ch341a_spi -r original.bin
これからCFEの部分を抜き出します。
$ dd if=original.bin of=boot_only.bin bs=64k count=4
CFEのサイズはオリジナルの起動ログなので確認できます。
CFEは設定をFlashの最後のほうに保存しているので、これも抜きます。
$ dd if=originl.bin of=nvram.bin bs=64k skip=31
最後の64Kを保存してますが、実際は最後の32Kに設定が保存されていました。
これと新しくビルドしたfirmwareを引っ付けてflashのイメージを作ります。
$ cat boot_only.bin main.trx > tmp1.bin
$ dd if=tmp1.bin of=tmp2.bin ibs=1984k conv=sync
$ cat tmp2.bin nvram.bin > 2m.bin
これをflashromで焼いて出来上がりです。
$ flashrom --programmer ch341a_spi -w 2m.bin
ターゲットに焼上がったFlashをつけて無事起動した。
CFE version 1.0.37 for BCM947XX (32bit,SP,LE)
Build Date: Tue Aug 9 14:39:48 IDT 2005 (igor@linuxbox.fotonation.local)
Copyright (C) 2000,2001,2002,2003 Broadcom Corporation.
Initializing Arena
Initializing Devices.
et0: Broadcom BCM47xx 10/100 Mbps Ethernet Controller 1.0.1.0
rndis0: Broadcom USB RNDIS Network Adapter (P-t-P)
CPU type 0x29007: 200MHz
Total memory: 8192 KBytes
Total memory used by CFE: 0x80300000 - 0x803A5830 (677936)
Initialized Data: 0x8033B840 - 0x8033E080 (10304)
BSS Area: 0x8033E080 - 0x8033F830 (6064)
Local Heap: 0x8033F830 - 0x803A3830 (409600)
Stack Area: 0x803A3830 - 0x803A5830 (8192)
Text (code) segment: 0x80300000 - 0x8033B840 (243776)
Boot area (physical): 0x003A6000 - 0x003E6000
Relocation Factor: I:00000000 - D:00000000
Device eth0: hwaddr 00-90-4C-68-00-40, ipaddr 192.168.0.206, mask 255.255.255.0
gateway not set, nameserver not set
Reading :: Failed.: Timeout occured
Loader:raw Filesys:raw Dev:flash0.os File: Options:(null)
Loading: .... 776328 bytes read
Entry at 0x80001000
Closing network.
Starting program at 0x80001000
bcmbm-mruby e312bc1(master) Fri Sep 29 16:30:57 JST 2023
mruby 771b56c79(master)
Mem : 800000
BOOT_CONSOLE : uart0
Clock : 200000000
MRB SIZE 686
MRB SHA256 3e609014
ORG DIR: 0 CTL: 0
0: 1010101010
1: 1010101010
2: 1010101010
3: 1010101010
0: 1010101010
1: 1010101010
2: 1010101010