※上記の広告は60日以上更新のないWIKIに表示されています。更新することで広告が下部へ移動します。

ファームウェアの組み込み

debian化した玄箱PROにNANDフラッシュブート時・標準HDDブート時に使用できていたマイコンやファンや電源などを使用可能にするために玄箱PRO仕様のdebianへカスタマイズします。これは山下氏の玄箱をハックしようを参考にさせてもらいました。

sushi-k氏のhddrootfs.tar.gzで展開したものを玄箱PRO仕様にアップグレードする

  • ファームウェアを吸い出す
KUROBOX-PRO:~# mkdir /tmp/mtd2
KUROBOX-PRO:~# mount /dev/mtd2 /tmp/mtd2
Empty flash at 0x00df85f8 ends at 0x00df8800
KUROBOX-PRO:~# mkdir /usr/local/buffalo
KUROBOX-PRO:~# (cd /tmp/mtd2; tar cf - .)|( cd /usr/local/buffalo; tar xvf -)
KUROBOX-PRO:~# umount /tmp/mtd2

  • 吸い出してファームウェアのバージョンを確認
KUROBOX-PRO:~# cat /usr/local/buffalo/etc/kurobox_release
VERSION=1.02
SUBVERSION=HDD 0.08
PRODUCTID=0x00001003

  • /etc/init.d/miconaplを作成
KUROBOX-PRO:~# vi /etc/init.d/miconapl
#!/bin/sh

case $1 in
	start)
		chroot /usr/local/buffalo mount -t proc proc /proc
		chroot /usr/local/buffalo /etc/init.d/checkroot.sh start
		chroot /usr/local/buffalo /usr/local/sbin/miconapl -b -a boot_end
		chroot /usr/local/buffalo /etc/init.d/FanController.sh start
		;;
	stop)
		chroot /usr/local/buffalo /etc/init.d/FanController.sh stop
		chroot /usr/local/buffalo umount /proc
		;;
	*)
		echo "Usage: $0 {start|stop}"
		exit 1
esac

exit 0
KUROBOX-PRO:~# chmod +x /etc/init.d/miconapl
KUROBOX-PRO:~# ln -s ../init.d/miconapl /etc/rc0.d/K10miconapl
KUROBOX-PRO:~# ln -s ../init.d/miconapl /etc/rc6.d/K10miconapl
KUROBOX-PRO:~# ln -s ../init.d/miconapl /etc/rcS.d/S80miconapl
KUROBOX-PRO:~# find /etc/ -name *miconapl -print
/etc/init.d/miconapl
/etc/rc0.d/K10miconapl
/etc/rc6.d/K10miconapl
/etc/rcS.d/S80miconapl
KUROBOX-PRO:~# echo 'chroot /usr/local/buffalo /usr/local/sbin/miconapl $*' \
> /usr/local/sbin/miconapl
KUROBOX-PRO:~# chmod +x /usr/local/sbin/miconapl

  • ファン制御の修正
KUROBOX-PRO:~# vi /usr/local/buffalo/etc/init.d/FanController.sh
start(){
if [ -x /usr/local/sbin/Fand ] ; then
	/usr/local/sbin/Fand &
	~~~~~~~~~~~~~~~~
fi
}
KUROBOX-PRO:~# vi /usr/local/buffalo/usr/local/sbin/Fand
5箇所のmiconaplに/usr/local/sbin/を追加して/usr/local/sbin/miconaplとする

  • 電源ボタン
KUROBOX-PRO:~# cp /usr/local/buffalo/etc/init.d/Kevent.sh /etc/init.d/Kevent.sh
KUROBOX-PRO:~# vi /etc/init.d/Kevent.sh
start(){
if [ -x /usr/local/sbin/Keventd ] ; then
	/usr/local/sbin/Keventd &
	~~~~~~~~~~~~~~~~
fi
}

KUROBOX-PRO:~# chmod +x /etc/init.d/Kevent.sh
KUROBOX-PRO:~# ln -s ../init.d/Kevent.sh /etc/rc0.d/K10Kevent.sh
KUROBOX-PRO:~# ln -s ../init.d/Kevent.sh /etc/rc6.d/K10Kevent.sh
KUROBOX-PRO:~# ln -s ../init.d/Kevent.sh /etc/rcS.d/S81Kevent.sh
KUROBOX-PRO:~# find /etc/ -name *Kevent.sh -print
/etc/init.d/Kevent.sh
/etc/rc0.d/K10Kevent.sh
/etc/rc6.d/K10Kevent.sh
/etc/rcS.d/S81Kevent.sh
KUROBOX-PRO:~# cp /usr/local/buffalo/usr/local/sbin/Keventd /usr/local/sbin/Keventd
KUROBOX-PRO:~# vi /usr/local/sbin/Keventd
#. /usr/local/bin/kuro_lib
KERNEL_EVENT_TAIL=/proc/buffalo/kernevnt

KUROBOX-PRO:~# vi /usr/local/bin/KeventHandller.sh
#!/bin/sh

case $1 in
	micon_interrupts)
		INT_DETAIL=`/usr/local/sbin/miconapl -a int_get_switch_status ||\
sed -n -e "s/int=//p"`
		case ${INT_DETAIL} in
			power_sw)
				/usr/local/sbin/miconapl -a bz_on button
				echo "shutdown..."
				shutdown -h now
				;;
			esac
			;;
esac
KUROBOX-PRO:~# chmod +x /usr/local/bin/KeventHandller.sh

  • killall導入
KUROBOX-PRO:~# apt-get install psmisc

  • 一度リブートする
KUROBOX-PRO:~# reboot
Orion1   CPU =  Low

=== KURO U-Boot. ===
 ** LOADER **
 ** KUROBOX BOARD: KURO_BOX  LE (CFG_ENV_ADDR=fffff000)


U-Boot 1.1.1 (Apr 10 2007 - 18:10:08) Marvell version: 1.12.1 - TINY

DRAM CS[0] base 0x00000000   size 128MB
DRAM Total size 128MB
[256kB@fffc0000] Flash: 256 kB
Addresses 20M - 0M are saved for the U-Boot usage.
Mem malloc Initialization (20M - 16M): Done
NAND: 256 MB

Soc: 88F5182 A2
CPU: ARM926 (Rev 0) running @ 500Mhz
Orion 1 streaming disabled
SysClock = 250Mhz , TClock = 166Mhz


USB 0: host mode
USB 1: host mode
PCI 0: PCI Express Root Complex Interface
PCI 1: Conventional PCI, speed = 33000000
Net:   egiga0 [PRIME]
Using 88E1118 phy
hit any key to switch tftp boot.
Hit any key to stop autoboot:  0
<<system_bootend>>
Hit any key to stop autoboot:  0

Reset IDE:
Marvell Serial ATA Adapter
Integrated Sata device found
  Device 0: OK
Model: Hitachi HDT725050VLA360                  Firm: V56OA52A Ser#:      
 VFB400R4C28DDA
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 476940.0 MB = 465.7 GB (976773168 x 512)

Using device ide0, partition 1

Loading from block device ide device 0, partition 1: Name: hda1
  Type: U-Boot  File:/uImage.buffalo

1717540 bytes read
<<stop_sound>>
## Booting image at 00100000 ...
   Image Name:   Linux-2.6.12.6-mda1
   Created:      2007-04-22   7:17:43 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1717476 Bytes =  1.6 MB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
OK

Starting kernel ...

arg:console=ttyS0,115200 root=/dev/sda2 rw panic=5 BOOTVER=1.09
CONFIG_KUROBOX_PLATFORM CONFIG_KUROBOX_KUROBOX ---
Uncompressing Linux.......................................................
........................................................ done, booting the
 kernel.
Linux version 2.6.12.6-mda1 (root@kurobox) (gcc version 4.1.2 20061115 (pr
erelease) (Debian 4.1.1-21)) #2 Sun Apr 22 16:16:39 JST 2007
CPU: ARM926EJ-Sid(wb) [41069260] revision 0 (ARMv5TEJ)
CPU0: D VIVT write-back cache
CPU0: I cache: 32768 bytes, associativity 1, 32 byte lines, 1024 sets
CPU0: D cache: 32768 bytes, associativity 1, 32 byte lines, 1024 sets
Machine: MV-88fxx81
Using UBoot passing parameters structure
Sys Clk = 250000000, Tclk = 166664740
Memory policy: ECC disabled, Data cache writeback
Built 1 zonelists
Kernel command line: console=ttyS0,115200 root=/dev/sda2 rw panic=5 BOOTVE
R=1.09
PID hash table entries: 1024 (order: 10, 16384 bytes)
Console: colour dummy device 80x30
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 128MB 0MB 0MB 0MB = 128MB total
Memory: 126208KB available (2987K code, 421K data, 108K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
serial_initialize_ttyS1 (Debug): ttyS1 is initialized.
 config_device_cs Error : Unknown board

CPU Interface
-------------
SDRAM_CS0 ....base 00000000, size 128MB
SDRAM_CS1 ....disable
SDRAM_CS2 ....disable
SDRAM_CS3 ....disable
PEX0_MEM ....base e0000000, size 128MB
PEX0_IO ....base f2000000, size   1MB
PCI0_MEM ....base e8000000, size 128MB
PCI0_IO ....base f2100000, size   1MB
INTER_REGS ....base f1000000, size   1MB
DEVICE_CS0 ....base fa000000, size   2MB
DEVICE_CS1 ....base f4000000, size  32MB
DEVICE_CS2 ....base fa800000, size   1MB
DEV_BOOCS ....base ff800000, size   8MB
CRYPTO ENG ....no such
Flash bankwidth 1, base ff800000, size 400000
KUROBOX FLASH size 4096[KB]

  Marvell Development Board (LSP Version 1.10.3.patch5_DB_NAS)-- KUROBOX_B
OARD_KUROBOX  Soc: 88F5182 A2

 Detected Tclk 166664740 and SysClk 250000000
Marvell USB EHCI Host controller #0: c04d5b00
Marvell USB EHCI Host controller #1: c04d5a40
pexBarOverlapDetect: winNum 2 overlap current 0
mvPexInit:Warning :Bar 2 size is illigal
it will be disabled
please check Pex and CPU windows configuration
PCI: bus0: Fast back to back transfers enabled
PCI: bus1: Fast back to back transfers enabled
SCSI subsystem initialized
usbcore: registered new driver usbfs
usbcore: registered new driver hub
Use the XOR engines (offloading) for enhancing the following functions:
  o RAID 5 Xor calculation
  o kernel memcpy
  o kenrel memzero
  o copy user to/from kernel buffers
Number of XOR engines to use: 2
cesadev_init(c0012240)
Fast Floating Point Emulator V0.9 (c) Peter Teichmann.
inotify device minor=63
JFFS2 version 2.2. (NAND) (C) 2001-2003 Red Hat, Inc.
SGI XFS with no debug enabled
Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing disabled
ttyS0 at MMIO 0x0 (irq = 3) is a 16550A
ttyS1 at MMIO 0x0 (irq = 4) is a 16550A
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered
RAMDISK driver initialized: 3 RAM disks of 32768K size 1024 blocksize
loop: loaded (max 8 devices)
Marvell Gigabit Ethernet Driver 'egiga':
  o Ethernet descriptors in DRAM
  o DRAM SW cache-coherency
  o Checksum offload enabled
  o Loading network interface ** egiga_init_module (6)
'eth0'
Intergrated Sata device found
scsi0 : Marvell SCSI to SATA adapter
scsi1 : Marvell SCSI to SATA adapter
  Vendor: Hitachi   Model: HDT725050VLA360   Rev: V56O
  Type:   Direct-Access                      ANSI SCSI revision: 03
SCSI device sda: 976773168 512-byte hdwr sectors (500108 MB)
SCSI device sda: drive cache: write back
SCSI device sda: 976773168 512-byte hdwr sectors (500108 MB)
SCSI device sda: drive cache: write back
 sda: sda1 sda2 sda3 sda4
Attached scsi disk sda at scsi0, channel 0, id 0, lun 0
Attached scsi generic sg0 at scsi0, channel 0, id 0, lun 0,  type 0
physmap flash device: 400000 at ff800000
Found: SST 39LF020
phys_mapped_flash: Found 1 x8 devices at 0x0 in 8-bit bank
number of JEDEC chips: 1
cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
RedBoot partition parsing not available
NAND device: Manufacturer ID: 0x20, Chip ID: 0xda (ST Micro NAND 256MiB 3,
3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 854 at 0x06ac0000
Using static partition definition
Creating 3 MTD partitions on "nand_mtd":
0x00000000-0x00400000 : "uImage"
0x00400000-0x04400000 : "rootfs"
0x04400000-0x10000000 : "extra"
usbmon: debugs is not available
ehci_platform ehci_platform.4523: EHCI Host Controller
ehci_platform ehci_platform.4523: new USB bus registered, assigned bus num
ber 1
ehci_platform ehci_platform.4523: irq 17, io mem 0x00000000
ehci_platform ehci_platform.4523: park 0
ehci_platform ehci_platform.4523: USB 0.0 initialized, EHCI 1.00, driver 1
0 Dec 2004
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
ehci_platform ehci_platform.16781: EHCI Host Controller
ehci_platform ehci_platform.16781: new USB bus registered, assigned bus nu
mber 2
ehci_platform ehci_platform.16781: irq 12, io mem 0x00000000
ehci_platform ehci_platform.16781: park 0
ehci_platform ehci_platform.16781: USB 0.0 initialized, EHCI 1.00, driver 
10 Dec 2004
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 1 port detected
USB Universal Host Controller Interface driver v2.2
Initializing USB Mass Storage driver...
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
usbcore: registered new driver usbhid
drivers/usb/input/hid-core.c: v2.01:USB HID core driver
mice: PS/2 mouse device common for all mice
md: raid0 personality registered as nr 2
md: raid1 personality registered as nr 3
md: raid5 personality registered as nr 4
raid5: measuring checksumming speed
   arm4regs  :   309.200 MB/sec
   8regs     :   269.200 MB/sec
   32regs    :   200.000 MB/sec
raid5: using function: arm4regs (309.200 MB/sec)
md: md driver 0.90.1 MAX_MD_DEVS=256, MD_SB_DISKS=27
Buffalo Platform Linux Driver(Light) 0.01 installed.
MICON ctrl (C) BUFFALO INC. V.1.00 installed.
Kernel event proc (C) BUFFALO INC. V.1.00 installed.
MICON V2 (C) BUFFALO INC. V.1.00 installed.
NET: Registered protocol family 2
IP: routing cache hash table of 1024 buckets, 8Kbytes
TCP established hash table entries: 8192 (order: 4, 65536 bytes)
TCP bind hash table entries: 8192 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 8192 bind 8192)
NET: Registered protocol family 1
NET: Registered protocol family 17
md: Autodetecting RAID arrays.
md: autorun ...
md: ... autorun DONE.
kjournald starting.  Commit interval 5 seconds
EXT3 FS on sda2, internal journal
EXT3-fs: mounted filesystem with ordered data mode.
VFS: Mounted root (ext3 filesystem).
Freeing init memory: 108K
INIT: version 2.86 booting
Activating swap...Adding 136544k swap on /dev/sda3.  Priority:-1 extents:1
done.
Checking root file system...fsck 1.40-WIP (14-Nov-2006)
/dev/sda2: clean, 9402/367616 files, 235448/2939892 blocks
done.
EXT3 FS on sda2, internal journal
Setting the system clock..
Cleaning up ifupdown....
Loading device-mapper support.
Checking file systems...fsck 1.40-WIP (14-Nov-2006)
/dev/sda1: clean, 12/7056 files, 6718/56196 blocks
/dev/sda4: clean, 11/60656640 files, 7776081/485251356 blocks
done.
Setting kernel variables...done.
Mounting local filesystems...kjournald starting.  Commit interval 5 second
s
EXT3 FS on sda1, internal journal
EXT3-fs: mounted filesystem with ordered data mode.
kjournald starting.  Commit interval 5 seconds
EXT3 FS on sda4, internal journal
EXT3-fs: mounted filesystem with ordered data mode.
done.
Activating swapfile swap...done.
Setting up networking....
Configuring network interfaces...eth0: link down
done.
eth0: link up<5>, full duplex<5>, speed 100 Mbps<5>
rm: /var/lock/perfmon: is a directory
rm: /var/lock/printing: is a directory
rm: /var/lock/subsys: is a directory
INIT: Entering runlevel: 2
Starting system log daemon: syslogd.
Starting kernel log daemon: klogd.
* Not starting internet superserver: no services enabled.
Starting OpenBSD Secure Shell server: sshd.
Starting periodic command scheduler: crond.

Debian GNU/Linux 4.0 KUROBOX-PRO ttyS0

KUROBOX-PRO login: root
Password:
Last login: Sat May 26 17:40:36 2007 on ttyS0
Linux KUROBOX-PRO 2.6.12.6-mda1 #2 Sun Apr 22 16:16:39 JST 2007 armv5tejl

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
KUROBOX-PRO:~#

  • 電源ボタンを長押ししてみる
KUROBOX-PRO:~# shutdown...

Broadcast message from root@KUROBOX-PRO (Sat May 26 17:54:59 2007):

The system is going down for system halt NOW!
INIT: Sending pStopping a fan ...........
Stopping periodic command scheduler: crond.
Stopping internet superserver: inetd.
Stopping OpenBSD Secure Shell server: sshd.
Saving the system clock..
Stopping kernel log daemon: klogd.
Stopping system log daemon: syslogd.
Asking all remaining processes to terminate...done.
Killing all remaining processes...done.
Deconfiguring network interfaces...done.
Cleaning up ifupdown....
Unmounting temporary filesystems...done.
Deactivating swap...done.
Unmounting local filesystems...done.
Will now halt.
md: stopping all md devices.
md: md0 switched to read-only mode.
Synchronizing SCSI cache for disk sda:
System halted.

次回の初期化簡略化のためのバックアップ

  • NANDフラッシュブートしてここまでのhddrootfs.tar.gzを作成する。
 玄箱PROのファームが組み込んであるため次回からは
1.NANDフラッシュブートの環境でブート
2.~ # /usr/local/bin/DiskDelete.sh実行
3.背面INITスイッチ長押し
 だけでここまでの状態に初期化できる
KUROBOX-PRO:~# reboot
setenv bootargs_root root=/dev/mtdblock2 rw panic=5
setenv bootargs $(bootargs_base) $(bootargs_root) $(buffalo_ver)
setenv bootcmd 'nboot $(default_kernel_addr) 0 $(nand_uImage_offset) ;setenv bootargs $(bootargs_base) > > $(bootargs_root) $(buffalo_ver); bootm $(default_kernel_addr)'
setenv nand_boot yes
boot

mount /dev/sda2 /mnt/rootfs
cd /mnt/rootfs
tar zcvf /mnt/disk1/bk_hddrootfs.tar.gz .

  • \\kurobox-pro\shareからbk_hddrootfs.tar.gzをコピーして保存しておく


最終更新日: 2007-05-28