2011年9月19日月曜日

obs600-12 DIPSW1_OFFの_cf_boot

いままで、DIPSW1_ONでPROMPTで停止し、手入力でbootmコマンドで起動させていました。もっといい方法があるような気もしますが、以下のようにしてbootm f8000000 を組み入れています。良く無い例かもしれません。が、メモとして残します。(1)〜(6)は事前調査です。
(1)bootcmd は _boot_sel
bootcmd=echo;echo Run Boot Selection Script;echo;run _boot_sel;

(2)_boot_sel は run _phase_1
_boot_sel=run _phase_1

(3)DIPSW1_OFF で _phase_2_1
_phase_1=if get_dip 1;then echo *** SW 1 IS OFF ***;echo;run _phase_2_1;else echo *** SW 1 IS ON ***;echo;
run _phase_2_2;fi

(4)_phase_2_1 DIPSW2_OFF で _phase_3
_phase_2_1=if get_dip 2;then echo *** SW 2 IS OFF ***;echo;run _phase_3;else echo *** SW 2 IS ON, DOWNLOAD
 STANDARD OS ***;echo;run os_load_prog;fi

(5)_phase_3 DIPSW3_ON で _cf_boot
_phase_3=run _initsw_sel;if get_dip 3;then echo *** SW 3 IS OFF, Standard Boot ***;echo;run ${_std_script};
else echo *** SW 3 IS ON, Boot from CF ***;echo;run _cf_boot;fi

(6)_cf_boot はこのように定義されている
_cf_boot=usb start;echo;echo Loading ...;${cf_fs}load usb ${usbdev} ${_kernel_addr_r} ${_cf_bootfile};
if test x$filesize = x ; then ${cf_fs}load usb ${usbdev} ${_kernel_addr_r} ${_cf_bootfile_alt}; fi;usb stop;
 run _cfargs _addtty _show_bootargs;bootm ${_kernel_addr_r}

(6)’_cf_boot を以下の一行に書き換える
_cf_boot=echo;echo NKBMobile_20110919 Booting...;echo; bootm ${_kernel_addr}

-------------------------------------------------------------------------
# 本当はU-Bootプロンプトで以下のように書き換えたかったのですが、
# 変数名_cf_bootのように'_'で始まると、どうもsetenvできませんでした。
=> setenv _cf_boot "bootm f8000000"
## Error: illegal character '_' in variable name head "_cf_boot"
=>
-------------------------------------------------------------------------

(7)タイムスタンプ2011/08/28 のflashcfgを使う
 #2011/03/09版では、-E,-Lオプションが使用できませんでした。
root@squeeze:Plathome# ls -l /usr/sbin/flashcfg.old /usr/sbin/flashcfg    
-r-xr-xr-x 1 root    root  22664 Aug 28 05:15 /usr/sbin/flashcfg
-r-xr-xr-x 1 root    root  6047 Mar  9  2011 /usr/sbin/flashcfg.old

(8)flashcfg -hの表示
root@squeeze:Plathome# /usr/sbin/flashcfg -h     [7] (11-09-19 Mon 21:07:14 PM)
usage: flashcfg                 Show this.
flashcfg -b              Show current boot setting
flashcfg -c rootdev      Change root file system [initrd|cf|sda-sdd[1-8]]
initrd       - Boot from FlashROM, / on Ramdisk
sda-sdd[1-8] - Boot from FlashROM, / on CF
cf           - Boot from CF,       / on CF
flashcfg -f boot_image   Load boot image to flash
flashcfg -s list_file    Save files to Parameter area
flashcfg -S list_file    Save files to User area
flashcfg -x              Restore files from Parameter area
flashcfg -X              Restore files from User area
flashcfg -d              Delete saved files from Parameter area
flashcfg -D              Delete saved files from User area
flashcfg -E env_file     Save params to U-Boot Environment area
flashcfg -L env_file     Load params from U-Boot Environment area
flashcfg -h              Show this.
root@squeeze:Plathome# 

(9)現在のU-Bootパラメータを読みこむ
root@squeeze:Plathome# /usr/sbin/flashcfg -L env_file
root@squeeze:Plathome#                          [10] (11-09-19 Mon 21:09:54 PM)
root@squeeze:Plathome# cp env_file env_file_20110919

(10) 前項(6)の値に57行目を置き替える
root@squeeze:Plathome# vi env_file_20110919     [11] (11-09-19 Mon 21:11:15 PM)
root@squeeze:Plathome# diff env_file env_file_20110919
57c57
< _cf_boot=usb start;echo;echo Loading ...;${cf_fs}load usb ${usbdev} ${_kernel_addr_r} ${_cf_bootfile};
if test x$filesize = x ; then ${cf_fs}load usb ${usbdev} ${_kernel_addr_r} ${_cf_bootfile_alt}; fi;usb stop;
 run _cfargs _addtty _show_bootargs;bootm ${_kernel_addr_r}
---
> _cf_boot=echo;echo NKBMobile_20110919 Booting...;echo; bootm ${_kernel_addr}
root@squeeze:Plathome#                     [ERROR:1] (11-09-19 Mon 21:13:02 PM)

(11) 置き換えた_cf_bootの内容を書き込む
root@squeeze:Plathome# /usr/sbin/flashcfg -E env_file_20110919
Change 1st U-Boot environment area
Change 2nd U-Boot environment area
root@squeeze:Plathome#                          [14] (11-09-19 Mon 21:14:06 PM)

(12) 正しく書き込めていることをベリファイする
root@squeeze:Plathome# mv env_file env_file_old
root@squeeze:Plathome# /usr/sbin/flashcfg -L env_file
root@squeeze:Plathome# diff env_file env_file_20110919
root@squeeze:Plathome# sed -n 57p env_file      [16] (11-09-19 Mon 21:17:23 PM)
_cf_boot=echo;echo NKBMobile_20110919 Booting...;echo; bootm ${_kernel_addr}
root@squeeze:Plathome#                          [17] (11-09-19 Mon 21:27:47 PM)

<<<<<<<<< DIPSW1 ON → OFF にして起動を確認します >>>>>>>>>
他DIPSWは、DIPSW2_OFF,DIPSW3_ON,DIPSW4_OFF になっています。

● DIPSW1_ON のときPROMPTで停止

Run Boot Selection Script

*** SW 1 IS ON ***

*** SW 2 IS OFF, ENTER COMMAND PROMPT ***

=> printenv _cf_boot
_cf_boot=echo;echo NKBMobile_20110919 Booting...;echo; bootm ${_kernel_addr}
=>

● DIPSW1_OFF のときPROMPTで停止せずBootする

Run Boot Selection Script

*** SW 1 IS OFF ***

*** SW 2 IS OFF ***

*** SW 3 IS ON, Boot from CF ***


NKBMobile_20110919 Booting...

## Booting kernel from Legacy Image at f8000000 ...
Image Name:   20110620_1941-sda1
Created:      2011-06-20  10:41:40 UTC
Image Type:   PowerPC Linux Multi-File Image (gzip compressed)
Data Size:    2617598 Bytes =  2.5 MB
Load Address: 00000000
Entry Point:  00000000
Contents:
Image 0: 2192626 Bytes =  2.1 MB
Image 1: 417113 Bytes = 407.3 kB
Image 2: 7838 Bytes =  7.7 kB
Verifying Checksum ... OK
## Loading init Ramdisk from multi component Legacy Image at f8000000 ...
## Flattened Device Tree from multi component Image at F8000000
Booting using the fdt at 0xf827d2a0
(以降省略)
--