fc2ブログ

Debian wheezy ノートにFriio+epgrec+mediatombで、Vierraから快適に録画(その4)。

Pitagora.jpg

さて、4回目。。。。

まぁBSとCSを録画して家庭内に配信するとしても、ロースペックなPCである事は明白なんですが。。
それにしても、次から次へと、色々問題が発生するもんです。

↓カーネルの再構築・・
--------------------

ここまで来て、録画が時折コケる事が判明。
とにかく、USB周りにエラーがやたら出る。。

そもそも、Kernel_2.6.32以降、この手のUSBリセットエラーが、あまりにも出ているんだが。。。

www kernel: [ 165.724137] usb 1-2.3: reset high-speed USB device number 6 using ehci_hcd
www kernel: [ 167.372216] usb 1-2.3: reset high-speed USB device number 6 using ehci_hcd
www kernel: [ 169.024172] usb 1-2.3: reset high-speed USB device number 6 using ehci_hcd
www kernel: [ 170.676131] usb 1-2.3: reset high-speed USB device number 6 using ehci_hcd
www kernel: [ 172.324209] usb 1-2.3: reset high-speed USB device number 6 using ehci_hcd

とにかく、syslogにはエラーを出力しまくりだし・・・その都度、デバイスをリセットしているんじゃあ、まともに録画もできないんじゃなかろうか??
なにはともあれ、このエラーを止めないと先に進まない。。

という訳で、カーネルを弄る事になる。。

1. まず必要なパッケージをインストール
# aptitude install bin86 module-assistant dpkg-dev
# aptitude install kernel-package
# aptitude install fakeroot
# aptitude install libncurses-dev libncurses5-dev


2.kernel sourceを検索
# apt-cache search linux-source
linux-source-3.2 - Linux kernel source for version 3.2 with Debian patches
linux-source - Linux kernel source (meta-package)
linux-source-2.6 - Linux カーネルソース (ダミーパッケージ)

3. 使用しているkernelのソースをインストール
# aptitude install linux-source-3.2

4. ソースの展開とコンパイルの準備
# cd /usr/src/
# tar xjfv linux-source-3.2.tar.bz2
# ln -s linux-source-3.2 linux
# cd linux
# bzcat ../linux-patch-3.2-rt.patch.bz2 | patch -p1

ここで、USB関係のソースをコチョコチョ・・・なのだが・・
グーグル先生に聞いても、有用なpatchの情報もなければ・・・
海外のLinuxユーザーフォーラムなんかでは、

「USB2.0でehci_hcdを使うとエラーが出るから、blacklistに上げてしまえば、エラーは出なくなるよ~」
などという・・・まことしやかなコメントを上げて、[Solved]なんてアホな事を言ってる奴も居る始末・・・・・

※usb_ehci_hcdを/etc/modprobe.d/のblacklistに上げて、ロードしないようにする・・
という事は、単純にUSB2.0のデバイスをUSB1.1モードで動かすという事なので、
今どき・・・・USB1.1じゃあ録画なんて出来るはずもない。。。

と・・言うわけで、2ちゃん辺りの少ない情報を頼りに・・・
結局、ソースを「手」で弄る事になる・・・・・・orz..

#cd /drivers/usb/core/

------drivers/usb/core/quirks.cを編集-----------

/* BUILDWIN Photo Frame */
{ USB_DEVICE(0x1908, 0x1315), .driver_info =
USB_QUIRK_HONOR_BNUMINTERFACES },
+ /* Friio */ <---この行を追加:
+ { USB_DEVICE(0x7a69, 0x0001), .driver_info = USB_QUIRK_RESET_RESUME },<---この行を追加:

/* INTEL VALUE SSD */
{ USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME },

-------------------

要は以下の2行を追加する:

154行目 /* Friio */
155行目 { USB_DEVICE(0x7a69, 0x0001), .driver_info = USB_QUIRK_RESET_RESUME },


-------------------

お次は、drivers/usb/core/hub.cの編集。
この辺りは、Kernel_2.6.30辺りでpatchが出ていたので、その辺を参考にして、
やっぱり、「手(vim)」で編集ねん。

------------------/usr/src/linux/drivers/usb/core/hub.c--------------------
行番号:

4153 usb_set_device_state(udev, USB_STATE_CONFIGURED);
4154
4155 /* Put interfaces back into the same altsettings as before.
4156 * Don't bother to send the Set-Interface request for interfaces
4157 * that were already in altsetting 0; besides being unnecessary,
4158 * many devices can't handle it. Instead just reset the host-side
4159 * endpoint state.
4160 */
4161 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
4162 struct usb_host_config *config = udev->actconfig;
4163 struct usb_interface *intf = config->interface[i];
4164 struct usb_interface_descriptor *desc;
4165
4166 desc = &intf->cur_altsetting->desc;
4167 if (desc->bAlternateSetting == 0) {
4168 usb_disable_interface(udev, intf, true);
4169 usb_enable_interface(udev, intf, true);
4170 ret = 0;
4171 } else {
4172 /* Let the bandwidth allocation function know that this
4173 * device has been reset, and it will have to use
4174 * alternate setting 0 as the current alternate setting.
4175 */
4176 intf->resetting_device = 1;
4177 ret = usb_set_interface(udev, desc->bInterfaceNumber,
4178 desc->bAlternateSetting);
4179 intf->resetting_device = 0;
4180 }
4181 if (ret < 0) {
4182 dev_err(&udev->dev, "failed to restore interface %d "
4183 "altsetting %d (error=%d)\n",
4184 desc->bInterfaceNumber,
4185 desc->bAlternateSetting,
4186 ret);
4187 goto re_enumerate;
4188 }

---------------------------------------------------------------------


------------/usr/src/linux/drivers/usb/core/hub.c(編集後)--------------

4153 usb_set_device_state(udev, USB_STATE_CONFIGURED);
4154
4155 /* Put interfaces back into the same altsettings as before.
4156 * Don't bother to send the Set-Interface request for interfaces
4157 * that were already in altsetting 0; besides being unnecessary,
4158 * many devices can't handle it. Instead just reset the host-side
4159 * endpoint state.
4160 */
4161 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
4162 /* struct usb_interface *intf = config->interface[i]; <----ここから。
4163 struct usb_interface_descriptor *desc; */ <---ここまで、コメントアウト。
4164 struct usb_interface *intf = udev->actconfig->interface[i];
4165 struct usb_interface_descriptor *desc;
4166
4167 desc = &intf->cur_altsetting->desc;
4168 /* if (desc->bAlternateSetting == 0) { <----ここから。
4169 usb_disable_interface(udev, intf, true); |
4170 usb_enable_interface(udev, intf, true); |
4171 ret = 0; |
4172 } else { |
4173 */ /* Let the bandwidth allocation function know that this |
4174 * device has been reset, and it will have to use |
4175 * alternate setting 0 as the current alternate setting. |
4176 */ <----ここまで、コメントアウト。
4177 ret = usb_set_interface(udev, desc->bInterfaceNumber,
4178 desc->bAlternateSetting);
4179 /* } <----ここから。
4180 if (ret < 0) { |
4181 dev_err(&udev->dev, "failed to restore interface %d " |
4182 "altsetting %d (error=%d)\n", |
4183 desc->bInterfaceNumber, |
4184 desc->bAlternateSetting, |
4185 ret); |
4186 goto re_enumerate; |
4187 } */ <----ここまで、コメントアウト。
4188 }

---------------------------------------------------------------------

------------/usr/src/linux/drivers/usb/core/hub.c(要はこういう事)--------------

4153 usb_set_device_state(udev, USB_STATE_CONFIGURED);
4154
4155
4156 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
4157 struct usb_interface *intf = udev->actconfig->interface[i];
4158 struct usb_interface_descriptor *desc;
4159
4160 desc = &intf->cur_altsetting->desc;
4161 ret = usb_set_interface(udev, desc->bInterfaceNumber,
4162 desc->bAlternateSetting);
4163
4164 }

---------------------------------------------------------------------

まぁ・・・この際、diffでも上げておけば、同じ悩みを抱える人の助けになるかも知れない。。。

*** hub.c_orig 2014-12-24 00:09:52.523422934 +0900
--- hub.c 2014-12-24 00:12:40.690073549 +0900
***************
*** 4152,4193 ****
mutex_unlock(hcd->bandwidth_mutex);
usb_set_device_state(udev, USB_STATE_CONFIGURED);

! /* Put interfaces back into the same altsettings as before.
! * Don't bother to send the Set-Interface request for interfaces
! * that were already in altsetting 0; besides being unnecessary,
! * many devices can't handle it. Instead just reset the host-side
! * endpoint state.
! */
! for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
! struct usb_host_config *config = udev->actconfig;
! struct usb_interface *intf = config->interface[i];
! struct usb_interface_descriptor *desc;
!
desc = &intf->cur_altsetting->desc;
! if (desc->bAlternateSetting == 0) {
! usb_disable_interface(udev, intf, true);
! usb_enable_interface(udev, intf, true);
! ret = 0;
! } else {
! /* Let the bandwidth allocation function know that this
! * device has been reset, and it will have to use
! * alternate setting 0 as the current alternate setting.
! */
! intf->resetting_device = 1;
ret = usb_set_interface(udev, desc->bInterfaceNumber,
desc->bAlternateSetting);
- intf->resetting_device = 0;
- }
- if (ret < 0) {
- dev_err(&udev->dev, "failed to restore interface %d "
- "altsetting %d (error=%d)\n",
- desc->bInterfaceNumber,
- desc->bAlternateSetting,
- ret);
- goto re_enumerate;
- }
}
!
done:
return 0;

--- 4152,4167 ----
mutex_unlock(hcd->bandwidth_mutex);
usb_set_device_state(udev, USB_STATE_CONFIGURED);

! for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
! struct usb_interface *intf = udev->actconfig->interface[i];
! struct usb_interface_descriptor *desc;
!
desc = &intf->cur_altsetting->desc;
! } else {
ret = usb_set_interface(udev, desc->bInterfaceNumber,
desc->bAlternateSetting);
}
!
done:
return 0;

---------------------------------------------------------------------
当て終わったら。

# make-kpkg clean
# cp /boot/config-3.2.0-4-686-pae .config

まぁ、各種設定は、もともとあった通りで良しとして・・楽します。
# make localmodconfig

並列コンパイルは "なし" で試す。
# export CONCURRENCY_LEVEL=1

5. コンパイル
# make-kpkg --rootcmd fakeroot --initrd --append-to-version fb kernel-image

結果、約5時間かかりました。

早速、kernelをインストール。
#dpkg -i /usr/src/linux-image-3.2.63fb-rt87_3.2.63fb-rt87-10.00.Custom_i386.deb

再起動すると、ちゃんとkernel module読み込まれてます!

# uname -r
3.2.63fb-rt87

-------------------

再起動すると、嘘のようにエラーが消えてる。。。とっても綺麗なdmesg....

という訳で、動作確認。

OUTPUT=ディスカバリーTEST.ts CHANNEL=CS6 DURATION=30 TUNER=0 MODE=1 TYPE=CS SID=340 /var/www/epgrec/do-record.sh

で・・録画できてたら。

そのまま、epgrecで予約録画してみる。

atで予約の確認。

# atq
30 Fri Dec 26 05:57:00 2014 a www-data
27 Tue Dec 23 05:57:00 2014 a www-data
28 Wed Dec 24 05:57:00 2014 a www-data
26 Mon Dec 22 05:57:00 2014 a www-data
29 Thu Dec 25 05:57:00 2014 a www-data

# at -c 30

#!/bin/sh
# atrun uid=33 gid=33
# mail www-data 0
umask 22
MODE=1; export MODE
OUTPUT=/var/www/epgrec/video/\ほにゃらら~ほにゃ\軆 __#3CS221226_BCS.ts; export OUTPUT
THUMB=/var/www/epgrec/thumbs/\ほにゃらら~ほにゃ\軆 __#3CS221226_BCS.ts.jpg; export THUMB
CHANNEL=CS22; export CHANNEL
FORMER=20; export FORMER
DURATION=1820; export DURATION
TUNER=0; export TUNER
TYPE=CS; export TYPE
SID=297; export SID
PWD=/media/HDD2T/new; export PWD
FFMPEG=/usr/bin/ffmpeg; export FFMPEG
cd /media/HDD2T/new || {
echo 'Execution directory inaccessible' >&2
exit 1
}
/var/www/epgrec/recorder.php 21

ほぉ・・・・・これで、録画環境は概ねOKか。。。

次回からは、視聴環境の構築ねん。

-------------------

スポンサーサイト



コメント

非公開コメント

プロフィール

管理人

Author:管理人
機械・電気・空・自然・・・

蝌蚪工房:車両部では機械関係のうんちくタレてます。

最新記事
最新コメント
最新トラックバック
月別アーカイブ
カテゴリ
検索フォーム
リンク
QRコード
QRコード