| 1 | = !BeagleBone Black Serialx4 BOXを使ったMAR-782用IOC = |
| 2 | |
| 3 | [wiki:epics/bbb/seralx4_cape BeagleBone Black Serialx4 Cape]に[wiki:epics/bbb/epics EPICS]をインストールし、その上でIOCを実行したときのメモ。 |
| 4 | |
| 5 | == 環境整備 == |
| 6 | |
| 7 | 当初、BBBに内蔵されたeMMCに環境を作ってそこでIOCを起動しようとしたが、Serialx4 CapeをつけてBBBを起動するとなぜか追加したSerialが認識されない。調べてみると、Serialx4 CapeをつけるとeMMCのデバイスドライバ(?)と当たってしまい、弾かれてしまうようだった。 |
| 8 | |
| 9 | {{{ |
| 10 | [ 0.249779] bone-capemgr bone_capemgr.8: Baseboard: 'A335BNLT,0A5C,2713BBBK6962' |
| 11 | [ 0.249820] bone-capemgr bone_capemgr.8: compatible-baseboard=ti,beaglebone-black |
| 12 | [ 0.280807] bone-capemgr bone_capemgr.8: slot #0: No cape found |
| 13 | [ 0.317915] bone-capemgr bone_capemgr.8: slot #1: No cape found |
| 14 | [ 0.355023] bone-capemgr bone_capemgr.8: slot #2: No cape found |
| 15 | [ 0.385285] bone-capemgr bone_capemgr.8: slot #3: 'RS232C x4 Cape,00A0,KEK cERL CTRL,cape-bone-uartx4' |
| 16 | [ 0.385455] bone-capemgr bone_capemgr.8: slot #4: specific override |
| 17 | [ 0.385496] bone-capemgr bone_capemgr.8: bone: Using override eeprom data at slot 4 |
| 18 | [ 0.385525] bone-capemgr bone_capemgr.8: slot #4: 'Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G' |
| 19 | [ 0.385656] bone-capemgr bone_capemgr.8: slot #5: specific override |
| 20 | [ 0.385691] bone-capemgr bone_capemgr.8: bone: Using override eeprom data at slot 5 |
| 21 | [ 0.385719] bone-capemgr bone_capemgr.8: slot #5: 'Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI' |
| 22 | [ 0.385867] bone-capemgr bone_capemgr.8: slot #6: specific override |
| 23 | [ 0.385903] bone-capemgr bone_capemgr.8: bone: Using override eeprom data at slot 6 |
| 24 | [ 0.385931] bone-capemgr bone_capemgr.8: slot #6: 'Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN' |
| 25 | [ 0.386482] bone-capemgr bone_capemgr.8: loader: before slot-3 cape-bone-uartx4:00A0 (prio 0) |
| 26 | [ 0.386511] bone-capemgr bone_capemgr.8: loader: check slot-3 cape-bone-uartx4:00A0 (prio 0) |
| 27 | [ 0.386647] bone-capemgr bone_capemgr.8: loader: before slot-4 BB-BONE-EMMC-2G:00A0 (prio 1) |
| 28 | [ 0.386673] bone-capemgr bone_capemgr.8: loader: check slot-4 BB-BONE-EMMC-2G:00A0 (prio 1) |
| 29 | [ 0.386797] bone-capemgr bone_capemgr.8: loader: before slot-5 BB-BONELT-HDMI:00A0 (prio 1) |
| 30 | [ 0.386822] bone-capemgr bone_capemgr.8: loader: check slot-5 BB-BONELT-HDMI:00A0 (prio 1) |
| 31 | [ 0.386884] bone-capemgr bone_capemgr.8: initialized OK. |
| 32 | [ 0.388874] OneNAND driver initializing |
| 33 | [ 0.390228] bone-capemgr bone_capemgr.8: loader: after slot-3 cape-bone-uartx4:00A0 (prio 0) |
| 34 | [ 0.390263] bone-capemgr bone_capemgr.8: slot #3: Requesting part number/version based 'cape-bone-uartx4-00A0.dtbo |
| 35 | [ 0.390293] bone-capemgr bone_capemgr.8: slot #3: Requesting firmware 'cape-bone-uartx4-00A0.dtbo' for board-name 'RS232C x4 Cape', version '00A0' |
| 36 | [ 0.390696] bone-capemgr bone_capemgr.8: loader: check slot-4 BB-BONE-EMMC-2G:00A0 (prio 1) |
| 37 | [ 0.390737] bone-capemgr bone_capemgr.8: loader: check slot-5 BB-BONELT-HDMI:00A0 (prio 1) |
| 38 | [ 0.390775] bone-capemgr bone_capemgr.8: loader: before slot-6 BB-BONELT-HDMIN:00A0 (prio 2) |
| 39 | [ 0.390798] bone-capemgr bone_capemgr.8: loader: check slot-6 BB-BONELT-HDMIN:00A0 (prio 2) |
| 40 | [ 0.390823] bone-capemgr bone_capemgr.8: loader: check slot-6 BB-BONELT-HDMIN:00A0 (prio 2) |
| 41 | }}} |
| 42 | |
| 43 | ここまでは認識してるのに、 |
| 44 | |
| 45 | {{{ |
| 46 | [ 0.528866] davinci_mdio 4a101000.mdio: davinci mdio revision 1.6 |
| 47 | [ 0.528890] davinci_mdio 4a101000.mdio: detected phy mask fffffffe |
| 48 | [ 0.529890] libphy: 4a101000.mdio: probed |
| 49 | [ 0.529920] davinci_mdio 4a101000.mdio: phy[0]: device 4a101000.mdio:00, driver SMSC LAN8710/LAN8720 |
| 50 | [ 0.530135] Detected MACID = 90:59:af:56:ae:c8 |
| 51 | [ 0.530248] cpsw 4a100000.ethernet: NAPI disabled |
| 52 | [ 0.531798] omap_rtc 44e3e000.rtc: setting system clock to 2000-01-01 00:03:34 UTC (946685014) |
| 53 | [ 0.539102] ALSA device list: |
| 54 | [ 0.539124] No soundcards found. |
| 55 | [ 0.539756] Waiting for root device /dev/mmcblk0p2... |
| 56 | [ 60.501673] bone-capemgr bone_capemgr.8: failed to load firmware 'cape-bone-uartx4-00A0.dtbo' |
| 57 | [ 60.510609] bone-capemgr bone_capemgr.8: loader: failed to load slot-3 cape-bone-uartx4:00A0 (prio 0) |
| 58 | [ 60.520282] bone-capemgr bone_capemgr.8: loader: check slot-6 BB-BONELT-HDMIN:00A0 (prio 2) |
| 59 | [ 60.520310] bone-capemgr bone_capemgr.8: loader: check slot-5 BB-BONELT-HDMI:00A0 (prio 1) |
| 60 | [ 60.520327] bone-capemgr bone_capemgr.8: loader: after slot-5 BB-BONELT-HDMI:00A0 (prio 1) |
| 61 | [ 60.520354] bone-capemgr bone_capemgr.8: slot #5: Requesting firmware 'cape-boneblack-hdmi-00A0.dtbo' for board-name 'Bone-Black-HDMI', version '00A0' |
| 62 | [ 60.520378] bone-capemgr bone_capemgr.8: slot #5: dtbo 'cape-boneblack-hdmi-00A0.dtbo' loaded; converting to live tree |
| 63 | [ 60.520736] bone-capemgr bone_capemgr.8: slot #5: #4 overlays |
| 64 | [ 60.521835] bone-capemgr bone_capemgr.8: loader: check slot-4 BB-BONE-EMMC-2G:00A0 (prio 1) |
| 65 | [ 60.521856] bone-capemgr bone_capemgr.8: loader: after slot-4 BB-BONE-EMMC-2G:00A0 (prio 1) |
| 66 | [ 60.521878] bone-capemgr bone_capemgr.8: slot #4: Requesting firmware 'cape-bone-2g-emmc1.dtbo' for board-name 'Bone-LT-eMMC-2G', version '00A0' |
| 67 | [ 60.521896] bone-capemgr bone_capemgr.8: slot #4: dtbo 'cape-bone-2g-emmc1.dtbo' loaded; converting to live tree |
| 68 | [ 60.522475] bone-capemgr bone_capemgr.8: slot #4: #2 overlays |
| 69 | [ 60.523096] of_get_named_gpio_flags: can't parse gpios property |
| 70 | [ 60.523110] of_get_named_gpio_flags: can't parse gpios property |
| 71 | [ 60.523120] of_get_named_gpio_flags: can't parse gpios property |
| 72 | [ 60.523152] gpio-rctrl rstctl.3: gpio_rctrl_request eMMC_RSTn |
| 73 | [ 60.523186] omap_hsmmc mmc.11: Got rstctl (gpio:#0 name eMMC_RSTn) label:eMMC_RSTn |
| 74 | [ 60.523198] gpio-rctrl rstctl.3: gpio_rctrl_deassert eMMC_RSTn |
| 75 | [ 60.523456] edma-dma-engine edma-dma-engine.0: allocated channel for 0:3 |
| 76 | [ 60.523503] edma-dma-engine edma-dma-engine.0: allocated channel for 0:2 |
| 77 | }}} |
| 78 | |
| 79 | 1分待ってエラーになってる。'''orz'''[[br]] |
| 80 | 今までは、開発用と考えてmicroSDカード上で開発していたので気付かなかった。[[br]] |
| 81 | 対応策が思いつかないので、今回はeMMCは諦め、microSDカードに環境を作ることにしたら、今まで通り問題なくSerialを認識して動作した。 |
| 82 | |
| 83 | === nfs client === |
| 84 | |
| 85 | IOCファイルはローカルに置かずにnfs server上に置いておいて、起動時に nfs mount したファイルを実行するようにした。[[br]] |
| 86 | デフォルトではnfs clientが入っていないので、パッケージをインストール。 |
| 87 | |
| 88 | {{{ |
| 89 | root@beaglebone:~# opkg install nfs-utils-client |
| 90 | }}} |
| 91 | |
| 92 | パッケージインストール後、fstabにnfs mountする箇所を記述。 |
| 93 | |
| 94 | {{{ |
| 95 | root@beaglebone:~# more /etc/fstab |
| 96 | rootfs / auto defaults 1 1 |
| 97 | proc /proc proc defaults 0 0 |
| 98 | devpts /dev/pts devpts mode=0620,gid=5 0 0 |
| 99 | tmpfs /tmp tmpfs defaults 0 0 |
| 100 | 172.28.64.115:/raid0/data/_NAS_NFS_Exports_/cerl /cerl nfs defaults,nolock 0 0 |
| 101 | }}} |
| 102 | |
| 103 | 実際にmountできるか実験。 |
| 104 | |
| 105 | {{{ |
| 106 | root@beaglebone:~# mount -a |
| 107 | root@beaglebone:~# df |
| 108 | Filesystem 1K-blocks Used Available Use% Mounted on |
| 109 | rootfs 3369444 1728320 1466636 55% / |
| 110 | /dev/root 3369444 1728320 1466636 55% / |
| 111 | devtmpfs 255148 0 255148 0% /dev |
| 112 | tmpfs 255280 0 255280 0% /dev/shm |
| 113 | tmpfs 255280 232 255048 1% /run |
| 114 | tmpfs 255280 0 255280 0% /sys/fs/cgroup |
| 115 | tmpfs 255280 232 255048 1% /etc/machine-id |
| 116 | tmpfs 255280 0 255280 0% /tmp |
| 117 | 172.28.64.115:/raid0/data/_NAS_NFS_Exports_/cerl 11707011072 1452805120 10254205952 13% /cerl |
| 118 | }}} |
| 119 | |
| 120 | mount できた。 |
| 121 | |
| 122 | == IOC == |
| 123 | |
| 124 | IOCは[wiki:epics/streamdevice/Aloka_MAR_783/ioc 以前使っていたもの]をBBB上の環境でコンパイルしたら、そのまま動作した。 |
| 125 | |
| 126 | |
| 127 | == IOC の自動起動 == |
| 128 | |
| 129 | BBB Serialx4 BOXが起動したら自動的にIOCが立ち上がってくれないと面倒なので、その設定を行う。[[br]] |
| 130 | RedHatやcentosなどは、/etc/rc*に設定すると自動的に立ち上がってくれるが、BBBのdefault OSである Angstrom Linux はちょっと特殊で、systemctlというコマンドでシャットダウンやserviceの追加削除等を行うらしい。でも、設定ファイル自体は、/etc/init.dに書けば自動的に追加されるのでそこに記述。 |
| 131 | |
| 132 | {{{ |
| 133 | #! /bin/sh |
| 134 | # |
| 135 | # epics |
| 136 | |
| 137 | cERLNFSMountFlag=`/bin/df | /bin/grep cerl | /usr/bin/wc -l` |
| 138 | |
| 139 | cERLmount(){ |
| 140 | if [ $cERLNFSMountFlag -eq 0 ]; then |
| 141 | echo -n "Mount cERL NFS disk:" |
| 142 | /bin/mount -a |
| 143 | echo "done" |
| 144 | else |
| 145 | echo "Already cERL NFS disk mountd." |
| 146 | fi |
| 147 | } |
| 148 | startioc(){ |
| 149 | echo -n "Starting ioc: " |
| 150 | if [ -e /home/root/ioc_start.sh ]; then |
| 151 | /home/root/ioc_start.sh |
| 152 | fi |
| 153 | echo "done" |
| 154 | } |
| 155 | stopioc(){ |
| 156 | echo -n "Stopping ioc: " |
| 157 | if [ -e /home/root/ioc_stop.sh ]; then |
| 158 | /home/root/ioc_stop.sh |
| 159 | fi |
| 160 | echo "done" |
| 161 | } |
| 162 | |
| 163 | case "$1" in |
| 164 | start) |
| 165 | cERLmount |
| 166 | startioc |
| 167 | ;; |
| 168 | stop) |
| 169 | stopioc |
| 170 | ;; |
| 171 | restart) |
| 172 | stopioc |
| 173 | cERLmount |
| 174 | startioc |
| 175 | ;; |
| 176 | reload) |
| 177 | stopioc |
| 178 | cERLmount |
| 179 | startioc |
| 180 | ;; |
| 181 | *) |
| 182 | echo "Usage: epics { start | stop | restart | reload }" >&2 |
| 183 | exit 1 |
| 184 | ;; |
| 185 | esac |
| 186 | |
| 187 | exit 0 |
| 188 | |
| 189 | }}} |
| 190 | |
| 191 | もう一つの問題としては、通常/etc/fstabにnfs mountする記述があれば自動的にnfs mountされるはずだが、なぜかmountされないので同じスクリプトに入れておいた。 |
| 192 | |
| 193 | {{{ |
| 194 | [ 0.552787] EXT4-fs (mmcblk0p2): INFO: recovery required on readonly filesystem |
| 195 | [ 0.552804] EXT4-fs (mmcblk0p2): write access will be enabled during recovery |
| 196 | [ 2.339425] EXT4-fs (mmcblk0p2): recovery complete |
| 197 | [ 2.343749] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null) |
| 198 | [ 2.343820] VFS: Mounted root (ext4 filesystem) readonly on device 179:2. |
| 199 | [ 2.352313] devtmpfs: mounted |
| 200 | [ 2.352594] Freeing init memory: 264K |
| 201 | [ 2.585729] systemd[1]: systemd 196 running in system mode. (+PAM -LIBWRAP -AUDIT -SELINUX +IMA +SYSVINIT -LIBCRYPTSETUP +GCRYPT +ACL +XZ; angstrom) |
| 202 | [ 2.633741] systemd[1]: Inserted module 'autofs4' |
| 203 | [ 2.635073] systemd[1]: Set hostname to <beaglebone>. |
| 204 | [ 2.637823] systemd[1]: Initializing machine ID from random generator. |
| 205 | [ 2.638123] systemd[1]: Installed transient /etc/machine-id file. |
| 206 | [ 2.880724] systemd[1]: Cannot add dependency job for unit nfs_client.service, ignoring: Unit nfs_client.service failed to load: No such file or directory. See system logs and 'systemctl status nfs_client.service' for details. |
| 207 | [ 2.881977] systemd[1]: Starting Forward Password Requests to Wall Directory Watch. |
| 208 | [ 2.882440] systemd[1]: Started Forward Password Requests to Wall Directory Watch. |
| 209 | [ 2.882552] systemd[1]: Expecting device dev-ttyO0.device... |
| 210 | }}} |
| 211 | |
| 212 | この起動スクリプトも実行はされているけどなぜかmountされていないので、しつこくcronに起動時のみ実行するように記述。 |
| 213 | |
| 214 | {{{ |
| 215 | @reboot (/bin/sleep 20; /bin/systemctl restart epics.service) |
| 216 | }}} |
| 217 | |
| 218 | これでやっと起動時にnfs mountされるようになった。[[br]] |
| 219 | ちなみに、epicsの起動スクリプトは、 |
| 220 | |
| 221 | {{{ |
| 222 | #!/bin/sh -x |
| 223 | |
| 224 | EPICS_EMBED_DIR="/cerl/epics/embed/BeagleBoneBlack" |
| 225 | EPICS_EMBED_ENV=$EPICS_EMBED_DIR/etc/setenvR314.12.3-linux-arm-bbb.sh |
| 226 | # set Boot IOC st.cmd |
| 227 | IOC_ST_CMD_PATH=$EPICS_EMBED_DIR/app/radmon/iocBoot/iocAloka_MAR783 |
| 228 | IOC_ST_CMD1=st1.cmd |
| 229 | IOC_ST_CMD2=st2.cmd |
| 230 | SCR_NAME1=radmon1 |
| 231 | SCR_NAME2=radmon2 |
| 232 | |
| 233 | # set epics environment |
| 234 | if [ -e $EPICS_EMBED_ENV ]; then |
| 235 | . $EPICS_EMBED_ENV |
| 236 | fi |
| 237 | |
| 238 | PWD = `pwd` |
| 239 | cd $IOC_ST_CMD_PATH |
| 240 | |
| 241 | if [ -e $IOC_ST_CMD_PATH/$IOC_ST_CMD1 ]; then |
| 242 | screen -AmdS $SCR_NAME1 ./$IOC_ST_CMD1 |
| 243 | sleep 2 |
| 244 | fi |
| 245 | |
| 246 | if [ -e $IOC_ST_CMD_PATH/$IOC_ST_CMD2 ]; then |
| 247 | screen -AmdS $SCR_NAME2 ./$IOC_ST_CMD2 |
| 248 | fi |
| 249 | |
| 250 | cd $PWD |
| 251 | |
| 252 | }}} |
| 253 | |
| 254 | これで、BBB Serialx4 BOXが起動すると自動的にIOCが起動するようになった。 |