| Version 6 (modified by , 8 years ago) ( diff ) |
|---|
RS232C x1 cape
以前作成したSerialx4 Boxの1ポート版。
以前基板は作ったけど、安く作成するためのケースが決まらなかったのと、Debian7になって独自に作成したcapeを自動で認識しなくなってしまったので放置してた。
Debian8になって、cape周りが改善された(?)ようなので再開することにした。
ちなみに、使用したケースはadafruitのプラスチックケースを加工して、RS232Cコネクタが出るようにした。
cape
以前作っておいたcapeのEEPROMに書き込んでおいたものがあったので、起動時に認識されているかを見てみた。
[ 2.343774] bone_capemgr bone_capemgr: Baseboard: 'A335BNLT,00C0,3115BBBK0805'
[ 2.343809] bone_capemgr bone_capemgr: compatible-baseboard=ti,beaglebone-black - #slots=4
[ 2.382159] bone_capemgr bone_capemgr: slot #0: 'RS232C Tiny Cape,00A0,KEK cERL CTRL,cape-uart-tiny'
[ 2.422019] bone_capemgr bone_capemgr: slot #1: No cape found
[ 2.462015] bone_capemgr bone_capemgr: slot #2: No cape found
[ 2.502015] bone_capemgr bone_capemgr: slot #3: No cape found
[ 2.502280] bone_capemgr bone_capemgr: initialized OK.
[ 2.504321] PM: bootloader does not support rtc-only!
[ 2.505368] omap_rtc 44e3e000.rtc: setting system clock to 2000-01-01 00:00:00 UTC (946684800)
[ 2.505400] of_cfs_init
[ 2.505523] of_cfs_init: OK
[ 2.511353] PM: Hibernation image not present or could not be loaded.
:
[ 3.514385] bone_capemgr bone_capemgr: loader: failed to load slot-0 cape-uart-tiny:00A0 (prio 0)
まだ、firmwareを入れてないので、認識はするけどその後エラーになっている。ここまでは以前と同じ。
firmwareをインストールして再度起動してみたけど、やはりダメだった。
firmwareの内容は以前とちょっと変わったので、修正してある。
/*
* Copyright (C) 2013-2017 Tetsuya Michikawa <hig-mchi@post.kek.jp>
*
* BeagleBone Black UART 1,2 used RS232c cape
*/
/dts-v1/;
/plugin/;
/ {
compatible = "ti,beaglebone", "ti,beaglebone-black", "ti,beaglebone-green";
/* identification */
/*part-number = "cape-bone-uart-tiny";*/
part-number = "cape-uart-tiny";
version = "00A0";
/* state the resources this cape uses */
exclusive-use =
/* the pin header uses */
"P9.24", /* uart1_txd */
"P9.26", /* uart1_rxd */
"P9.21", /* uart2_txd */
"P9.22", /* uart2_rxd */
/* the hardware ip uses */
"uart1",
"uart2";
fragment@0 {
target = <&am33xx_pinmux>;
__overlay__ {
bb_uart1_pins: pinmux_bb_uart1_pins {
pinctrl-single,pins = <
/*0x180 0x20*/ /* P9.26 uart1_rxd.uart1_rxd INPUT */
/*0x184 0x20*/ /* P9.24 uart1_txd.uart1_txd OUTPUT */
0x184 0 // uart1_txd.uart1_txd
0x180 (1<<8) // uart1_rxd.uart1_rxd
>;
};
bb_uart2_pins: pinmux_bb_uart2_pins {
pinctrl-single,pins = <
/*0x150 0x21*/ /* P9.22 spi0_sclk.uart2_rxd | MODE1 */
/*0x154 0x01*/ /* P9.21 spi0_d0.uart2_txd | MODE1 */
0x154 1 // spi0_d0.uart2_txd
0x150 ((1<<8) | 1) // spi0_sclk.uart2_rxd
>;
};
};
};
fragment@1 {
target = <&uart1>;
__overlay__ {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&bb_uart1_pins>;
};
};
fragment@2 {
target = <&uart2>;
__overlay__ {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&bb_uart2_pins>;
};
};
};
起動後に手動でbone-capemgrに登録すれば認識はされるので、firmwareが間違っているわけでもなさそう。
root@beaglebone:~# echo cape-uart-tiny > /sys/devices/platform/bone_capemgr/slots
root@beaglebone:~# cat /sys/devices/platform/bone_capemgr/slots
0: P----- -1 RS232C Tiny Cape,00A0,KEK cERL CTRL,cape-uart-tiny
1: PF---- -1
2: PF---- -1
3: PF---- -1
4: P-O-L- 0 Override Board Name,00A0,Override Manuf,cape-uart-tiny
root@beaglebone:~# dmesg
:
[ 224.894311] bone_capemgr bone_capemgr: part_number 'cape-uart-tiny', version 'N/A'
[ 224.894397] bone_capemgr bone_capemgr: slot #4: override
[ 224.894439] bone_capemgr bone_capemgr: Using override eeprom data at slot 4
[ 224.894488] bone_capemgr bone_capemgr: slot #4: 'Override Board Name,00A0,Override Manuf,cape-uart-tiny'
[ 224.931576] 48022000.serial: ttyS1 at MMIO 0x48022000 (irq = 199, base_baud = 3000000) is a 8250
[ 224.946064] 48024000.serial: ttyS2 at MMIO 0x48024000 (irq = 200, base_baud = 3000000) is a 8250
[ 224.956129] bone_capemgr bone_capemgr: slot #4: dtbo 'cape-uart-tiny-00A0.dtbo' loaded; overlay id #0
以前は、ttyO1,ttyO2だったが、ttyS1,ttyS2に変わったみたい。
/boot/uEnv.txtを修正しても、結果は同じだった。
#enable_uboot_overlays=1 enable_uboot_overlays=1 #uboot_overlay_addr0=/lib/firmware/<file0>.dtbo uboot_overlay_addr0=/lib/firmware/cape-uart-tiny-00A0.dtbo ###Custom Cape dtb_overlay=/lib/firmware/cape-uart-tiny-00A0.dtbo #disable_uboot_overlay_emmc=1 disable_uboot_overlay_video=1 #cmdline=coherent_pool=1M net.ifnames=0 quiet cape_universal=enable cmdline=coherent_pool=1M net.ifnames=0 quiet cape_universal=disable
色々とググってみると、My custom cape's devicetree fails to load at boot, but can be loaded manuallyというページがあり、その中に2つの解決方法が記載されていた。
1つは、EEPROMでのロードは諦めて、ブート後にソフトウェア的に/etc/default/capemgrに記述されたfirmwareをロードするというものだった。
何かこれじゃない感がするけど実際にやってみると、ロードされているようだった。
root@beaglebone:~# dmesg
:
[ 2.343437] bone_capemgr bone_capemgr: Baseboard: 'A335BNLT,00C0,3115BBBK0805'
[ 2.343471] bone_capemgr bone_capemgr: compatible-baseboard=ti,beaglebone-black - #slots=4
[ 2.382144] bone_capemgr bone_capemgr: slot #0: 'RS232C Tiny Cape,00A0,KEK cERL CTRL,cape-uart-tiny'
[ 2.422052] bone_capemgr bone_capemgr: slot #1: No cape found
[ 2.462047] bone_capemgr bone_capemgr: slot #2: No cape found
[ 2.502045] bone_capemgr bone_capemgr: slot #3: No cape found
[ 2.502315] bone_capemgr bone_capemgr: initialized OK.
:
[ 3.514427] bone_capemgr bone_capemgr: loader: failed to load slot-0 cape-uart-tiny:00A0 (prio 0)
:
[ 18.411708] bone_capemgr bone_capemgr: part_number 'cape-uart-tiny', version 'N/A'
[ 18.411745] bone_capemgr bone_capemgr: slot #4: override
[ 18.411762] bone_capemgr bone_capemgr: Using override eeprom data at slot 4
[ 18.411779] bone_capemgr bone_capemgr: slot #4: 'Override Board Name,00A0,Override Manuf,cape-uart-tiny'
[ 18.472173] 48022000.serial: ttyS1 at MMIO 0x48022000 (irq = 199, base_baud = 3000000) is a 8250
[ 18.493383] 48024000.serial: ttyS2 at MMIO 0x48024000 (irq = 200, base_baud = 3000000) is a 8250
[ 18.510449] bone_capemgr bone_capemgr: slot #4: dtbo 'cape-uart-tiny-00A0.dtbo' loaded; overlay id #0
:
root@beaglebone:~# cat /sys/devices/platform/bone_capemgr/slots
0: P----- -1 RS232C Tiny Cape,00A0,KEK cERL CTRL,cape-uart-tiny
1: PF---- -1
2: PF---- -1
3: PF---- -1
4: P-O-L- 0 Override Board Name,00A0,Override Manuf,cape-uart-tiny
2つ目が、どうやら本当の解決法らしいが色々と面倒そう。
言いたいこととしては、initrdが起動してinitramfs上に展開されるが、その時点で展開されているファイル内にfirmwareファイルが入っていないからこの問題が起きるということのようだ。
実際にfirmwareファイルが入っているのは、eMMCやSDカード内で、その領域がマウントされるのがinitrd内のcapemgrが認識した後だから当たり前といえば当たり前の話。
serialを1portしか使わないなら、始めから入っているADAFRUIT-UART1-00A0.dtboやBB-UART1-00A0.dtboを呼び出すようなEEPROM設定を作れば一応目的は達成できるが、今回は、EEPROM+initramfsではなく、/etc/default/capemgrに設定する方法で対処した。
network 設定
debian8になって、ネットワーク設定は、connmanを使うのがデフォルトになっていたので、それで設定する。
始めに、設定するネットワークインターフェースの識別子を取得。
root@beaglebone:~# connmanctl services *AO Wired ethernet_xxxxxx6f10xxxx_cable
表示されたethernet_~_cableというのが、ネットワークインターフェイスに自動的に設定される識別子。複数のネットワークに接続されている(wifiとか)時には複数出るらしい。USBoverIP接続は表示されない。
この識別子に対して設定するということらしい。
設定は以下のように。
root@beaglebone:~# connmanctl config ethernet_xxxxxx6f10xxxx_cable --ipv4 manual 172.xxx.xxx.xxx 255.255.xxx.0 172.xxx.xxx.xxx nameservers 172.xxx.xxx.xxx
ホスト名の設定も同じように設定する。
root@beaglebone:~# hostnamectl set-hostname xxxxxx01.xxxx.kek.jp
IOC
IOCはNAS上でもいいかと思ったが、開発/実行共に自己完結できるのでローカルに置いておいて、NASにはコピーを置いておくことにした。
以前、サーバーで動作していたIOCを持ってくる際には、何か所か変更点があるので、記載しておく。
- configure/RELEASE
SNCSEQ=$(EPICS_BASE)/../modules/soft/seq/2.2.4 ASYN=$(EPICS_BASE)/../modules/soft/asyn/4-31 STREAM=$(EPICS_BASE)/../modules/soft/stream/2.7.7 EPICS_BASE=/opt/epics/R315.5/base
- iocBoot/iocXXXX/Makefile
ARCH = linux-x86_64
↓
ARCH = linux-arm
- iocBoot/iocXXXX/st.cmd
#!../../bin/linux-x86_64/XXXX
↓
#!../../bin/linux-arm/XXXX
RS232Cを使う場合には、asynの設定を変更
drvAsynIPPortConfigure ("PS1", "172.xxx.xxx.xxx:4001")
↓
drvAsynSerialPortConfigure ("PS1","/dev/ttyS1")
接続するシリアル機器に合わせて修正する。
asynSetOption("$(DEV)", -1, "baud", "19200")
asynSetOption("$(DEV)", -1, "parity", "none")
asynSetOption("$(DEV)", -1, "bits", "8")
asynSetOption("$(DEV)", -1, "stop", "1")
asynSetOption("$(DEV)", -1, "clocal", "Y")
asynSetOption("$(DEV)", -1, "crtscts", "N")
- XXXXApp/src/XXXXInclude.dbd
asynPortDriverを使っている場合には、dbdファイルにも設定を追加。
root@bbbserialbox01:/opt/epics/app/XXXX/XXXXXApp/src# emacs -nw XXXXInclude.dbd
include "base.dbd"
include "asyn.dbd"
registrar("drvXXXXRegister")
registrar("drvAsynIPPortRegisterCommands")
registrar("drvAsynSerialPortRegisterCommands") <-- 追加
- XXXXApp/src/Makefile
DBD設定を変更。
XXXX_DBD += drvAsynIPPort.dbd
↓
XXXX_DBD += drvAsynSerialPort.dbd
変更後に、make distclean;make
IOC自動起動設定
BBB起動時にIOCが起動するように設定し、rootで実行する。
起動用のシェルスクリプトを作成して、crontabの@rebootで起動時に実行するようにする。
#!/bin/sh TOP=/opt/epics IOC_DIR=$TOP/app/xxxxxx/iocBoot/iocxxxxx PROCSERV=$TOP/R315.5/extensions/bin/linux-arm/procServ PORT=20200 . $TOP/R315.5/etc/setenv_R315_5.sh $PROCSERV -P $PORT -c $IOC_DIR $IOC_DIR/st.cmd
参照HP
My custom cape's devicetree fails to load at boot, but can be loaded manually
Debian Jessie での固定IP設定方法 Debian Jessieで固定IPアドレスを設定する
Attachments (2)
- IMG_0215.JPG (789.6 KB ) - added by 8 years ago.
- IMG_0214.JPG (815.0 KB ) - added by 8 years ago.
Download all attachments as: .zip
