MA-E3xxシリーズでは、NAND Flashメモリベースのファームウェアで起動し、
等を行った状態を “ファームウェア” として作成することが可能です1)。
ここでは、標準では入れていないFTPサーバを組み込んだファームウェアを作る例を紹介します。
まず、実機にて vsftpd パッケージをインストールします。
root@plum:~# apt-get install vsftpd Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: vsftpd 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 100 kB of archives. After this operation, 302 kB of additional disk space will be used. Get:1 http://ports.ubuntu.com/ubuntu-ports/ saucy/main vsftpd armhf 3.0.2-1ubuntu2 [100 kB] Fetched 100 kB in 1s (52.6 kB/s) Preconfiguring packages ... Selecting previously unselected package vsftpd. (Reading database ... 17860 files and directories currently installed.) Unpacking vsftpd (from .../vsftpd_3.0.2-1ubuntu2_armhf.deb) ... Processing triggers for ureadahead ... Setting up vsftpd (3.0.2-1ubuntu2) ... vsftpd start/running, process 1411 Processing triggers for ureadahead ... localepurge: Disk space freed in /usr/share/locale: 0 KiB localepurge: Disk space freed in /usr/share/man: 0 KiB Total disk space freed by localepurge: 0 KiB root@plum:~#
“generate_firm” スクリプトを実行すると、ファームウェアのビルドが始まります。
15分程度かかります。
root@plum:~# generate_firm ## MA-E3xx series firmware generater * creating new rootfs image... Parallel mksquashfs: Using 1 processor Creating 4.0 filesystem on /tmp/.new_firm/rootfs.img, block size 1048576. [=========================================================================================\] 13339/13339 100% Exportable Squashfs 4.0 filesystem, xz compressed, data block size 1048576 compressed data, compressed metadata, compressed fragments, compressed xattrs duplicates are removed Filesystem size 55919.81 Kbytes (54.61 Mbytes) 25.28% of uncompressed filesystem size (221230.86 Kbytes) Inode table size 166498 bytes (162.60 Kbytes) 24.13% of uncompressed inode table size (689933 bytes) Directory table size 161736 bytes (157.95 Kbytes) 41.84% of uncompressed directory table size (386574 bytes) Number of duplicate files found 487 Number of inodes 19004 Number of files 13329 Number of fragments 144 Number of symbolic links 4186 Number of device nodes 0 Number of fifo nodes 0 Number of socket nodes 0 Number of directories 1489 Number of ids (unique uids + gids) 20 Number of uids 9 root (0) user1 (1000) libuuid (100) ntp (104) syslog (101) statd (105) www-data (33) debian-inadyn (107) zabbix (103) Number of gids 18 root (0) dip (30) shadow (42) debian-inadyn (108) user1 (1000) users (100) ftp (109) crontab (102) mail (8) utmp (43) ssh (104) tty (5) staff (50) libuuid (101) zabbix (105) nogroup (65534) ntp (107) adm (4) done. rootfs.img size: 57262080 [bytes] rootfs mtd size: 83994624 [bytes] * Kernel module (kmod) image found. * JRE (opt) image found. * mtd area of 'kernel' found (/dev/mtdblock3) * mtd area of 'initramfs' found (/dev/mtdblock5) * mtd area of 'dtb' found (/dev/mtdblock16) New firmware file: /tmp/new_firmware.img generated, content is... Archive: /tmp/new_firmware.img Length Method Size Cmpr Date Time CRC-32 Name -------- ------ ------- ---- ---------- ----- -------- ---- 4257792 Stored 4257792 0% 2014-03-19 12:05 a4427123 kernel.img 440320 Stored 440320 0% 2014-03-19 12:05 e6eab733 kmod.img 2193408 Stored 2193408 0% 2014-03-19 12:05 cd57f3c6 initramfs.img 57262080 Stored 57262080 0% 2014-03-19 12:05 ebd41c20 rootfs.img 21719040 Stored 21719040 0% 2014-03-19 12:05 0e9b5556 opt.img 131072 Defl:N 8235 94% 2014-03-19 12:05 f4cebbc9 dtb.img -------- ------- --- ------- 86003712 85880875 0% 6 files root@plum:~#
/tmp/new_firmware.img ファイルが作成されました。
別の機器に適用する場合、ネットワークやUSBメモリなどを使用してコピーしてください。
できあがった新しいファームウェアを、さっそく適用してみます。
root@plum:~# firmup /tmp/new_firmware.img ### MA-E3xx series firmware update utility (for 2-area firmware). Updating Area: 0 ... * image file for kernel found. writing "kernel" image to /dev/mtdblock2 ... succeeded. * image file for kmod found. writing "kmod" image to /dev/mtdblock6 ... succeeded. * image file for initramfs found. writing "initramfs" image to /dev/mtdblock4 ... succeeded. * image file for rootfs found. writing "rootfs" image to /dev/mtdblock8 ... succeeded. * opt(JRE) file found. writing "opt" image to /dev/mtdblock10 ... succeeded. * DTB file found. writing "dtb" image to /dev/mtd15 ... succeeded. * updating default firmware area: 0 Succeeded. root@plum:~#
新しいファームウェアで起動してみます。
root@plum:~# shutdown -r now root@plum:~# Broadcast message from root@plum (/dev/pts/0) at 12:43 ... The system is going down for reboot NOW!
ログインしてバージョンを確認してみます。
このスクリプトでファームウェアを作成した場合、もとのバージョン名に “+“ がついたバージョン名となります。
* Starting PCSC Lite resource manager pcscd [ OK ] * Starting NTP server ntpd [ OK ] * Restoring resolver state... [ OK ] * Running local boot scripts (/etc/rc.local) [ OK ] Ubuntu 13.10 plum ttyO0 plum login: root Password: Last login: Wed Mar 19 11:46:31 JST 2014 from 192.168.253.4 on pts/0 root@plum:~# cat /etc/version MA-E320 firmware version 1.0.0alpha16+ (Wed Mar 19 11:52:08 JST 2014) root@plum:~#
追加した vsftpd が動作しているか、確認してみます。
root@plum:~# ps ax PID TTY STAT TIME COMMAND 1 ? Ss 0:07 /sbin/init 2 ? S 0:00 [kthreadd] 3 ? S 0:00 [ksoftirqd/0] 4 ? S 0:00 [kworker/0:0] 5 ? S< 0:00 [kworker/0:0H] 6 ? S 0:00 [kworker/u2:0] 7 ? S 0:00 [rcuc/0] 8 ? S 0:00 [rcub/0] 9 ? S 0:00 [rcu_preempt] 10 ? S 0:00 [rcu_sched] 11 ? S 0:00 [rcu_bh] 12 ? S< 0:00 [khelper] 13 ? S 0:00 [kdevtmpfs] 14 ? S< 0:00 [netns] 15 ? S 0:04 [kworker/0:1] 16 ? S< 0:00 [writeback] 17 ? SN 0:00 [ksmd] 18 ? S< 0:00 [bioset] 19 ? S< 0:00 [kblockd] 20 ? S 0:00 [khubd] 21 ? S< 0:00 [devfreq_wq] 22 ? S< 0:00 [rpciod] 31 ? S 0:00 [kswapd0] 32 ? S 0:00 [fsnotify_mark] 33 ? S< 0:00 [nfsiod] 34 ? S< 0:00 [cifsiod] 35 ? S< 0:00 [crypto] 64 ? S< 0:00 [OMAP UART0] 65 ? S< 0:00 [OMAP UART1] 66 ? S< 0:00 [OMAP UART2] 67 ? S 0:00 [kapmd] 68 ? S 0:00 [spi1] 69 ? S 0:00 [kworker/u2:1] 72 ? S 0:00 [irq/240-mmc0] 75 ? S< 0:00 [deferwq] 76 ? S 0:00 [irq/86-44e0b000] 77 ? S 0:00 [kworker/u2:2] 86 ? S 0:00 [kworker/0:2] 87 ? S 0:00 [ubi_bgt0d] 146 ? S< 0:00 [kworker/0:1H] 167 ? S< 0:00 [loop0] 175 ? S< 0:00 [loop1] 190 ? S 0:00 [ubifs_bgt0_9] 303 ? S 0:00 upstart-udev-bridge --daemon 318 ? Ss 0:00 /lib/systemd/systemd-udevd --daemon 528 ? Ss 0:00 rpc.idmapd 534 ? S 0:00 upstart-file-bridge --daemon 537 ? S 0:00 upstart-socket-bridge --daemon 539 ? Sl 0:00 rsyslogd -c5 561 ? Ss 0:00 rpcbind 628 ? Ss 0:00 rpc.statd -L 645 ? Ss 0:00 /usr/sbin/vsftpd <---------------- 760 ? Ss 0:00 /sbin/dhcpcd-bin -h plum -Y -N -R eth0 903 ? Ss 0:00 cron 907 ? Ss 0:01 /usr/sbin/sshd -D 985 ? S 0:00 /usr/sbin/dnsmasq -x /var/run/dnsmasq/dnsmasq.pid -u 1093 ? Ss 0:00 /usr/sbin/fcgiwrap 1119 ? Ss 0:00 nginx: master process /usr/sbin/nginx 1121 ? S 0:00 nginx: worker process 1122 ? S 0:00 nginx: worker process 1123 ? S 0:00 nginx: worker process 1124 ? S 0:00 nginx: worker process 1147 ? Sl 0:00 /usr/sbin/pcscd 1230 ttyO0 Ss 0:01 /bin/login -- 1256 ? Ss 0:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -c /var/lib/nt 1276 ttyO0 S 0:01 -bash 1299 ttyO0 R+ 0:00 ps ax root@plum:~#
きちんと、vsftpd が動作していることが確認できました。