Adding mythbackend to minimyth

Help with using MiniMyth's build system

Moderator: Pablo

Adding mythbackend to minimyth

Postby pleeke » Mon Jun 23, 2008 7:49 am

Hi,

Been messing around with adding mythbackend & mythtv-setup to minimyth to enable minimyth to run as a slave backend (I'd like to be able to add a dvb card to locally minimyth and have it used for live tv).


I've had to add this patch to mythtv as the minimyth ps utility doesn't support the same syntax as a normal distro;

Code: Select all
diff -Naur mythtv-0.21-old/libs/libmyth/mythcontext.cpp mythtv-0.21-new/libs/libmyth/mythcontext.cpp
--- mythtv-0.21-old/libs/libmyth/mythcontext.cpp        2008-05-11 18:56:13.000000000 +0100
+++ mythtv-0.21-new/libs/libmyth/mythcontext.cpp        2008-06-21 22:14:49.000000000 +0100
@@ -1810,7 +1810,7 @@
#if defined(CONFIG_DARWIN) || (__FreeBSD__) || defined(__OpenBSD__)
     char *command = "ps -ax | grep -i mythbackend | grep -v grep > /dev/null";
#else
-    char *command = "ps -ae | grep mythbackend > /dev/null";
+    char *command = "ps | grep mythbackend | grep -v grep > /dev/null";
#endif
     bool res = myth_system(command,
                            MYTH_SYSTEM_DONT_BLOCK_LIRC |


Obviously also had to build mythtv with --enable-dvb set in the Makefile & a proper dvb-path setting. Also had to use a custom kernel cfg that enables all dvb & video related options (probably way too many modules built but doesn't seem to increase the image much in size and works for now).


Adding mythbackend & mythtv-setup adds ~1MB to the final nfs tarball. Adding most/all dvb drivers appears to add another ~2.5MB to final tarball (mostly compiled as modules and just including all libs in modules/*/kernel/media/ to be included in minimyth. I'm sure the kernel module size increase can be reduced if only the relevant drivers are installed, but as I use nfs mounted root system it doesn't seem that important (yet).


I can now start the backend daemon & run mythtv-setup and the dvb card drivers are loaded!!

I'm not really suggesting that this becomes part of the default minimyth build (though that would be great ;-)) - as thats bound to bring loads of capture card issues/requests.




Now I have one issue that has been driving me mad (and stops myth from finding the local dvb card), the dvb nodes are created in /dev with the following (wrong) names;

/dev/dvb0.demux0
/dev/dvb0.dvr0
/dev/dvb0.frontend0
/dev/dvb0.net0


This appears to be udev rules missing from minimyth (unsurprisingly), and I've been googling loads but just can't get it to work properly. Current udev rules in /etc/udev/rules.d/04-minimyth-detect-dvb.rules that I'm trying are;


Code: Select all
ACTION=="add|remove", KERNEL=="dvb[0-9]*", GOTO="begin"
GOTO="end"
LABEL="begin"

# Import mm_detect_id.
IMPORT{program}="/lib/udev/mm_detect_id"

KERNEL="dvb[0-9].dvr*", NAME="dvb/adapter%n/dvr%n"
KERNEL="dvb[0-9].demux*", NAME="dvb/adapter%n/demux%n"
KERNEL="dvb[0-9].frontend*", NAME="dvb/adapter%n/frontend%n"
KERNEL="dvb[0-9].audio*", NAME="dvb/adapter%n/audio%n"
KERNEL="dvb[0-9].ca*", NAME="dvb/adapter%n/ca%n"
KERNEL="dvb[0-9].osd*", NAME="dvb/adapter%n/osd%n"
KERNEL="dvb[0-9].net*", NAME="dvb/adapter%n/net%n"
KERNEL="dvb[0-9].video*", NAME="dvb/adapter%n/video%n"

LABEL="end"



But nothing changes in the device names. I'm not really sure how to debug udev so any pointers would be very helpful.

I know this isn't really part of minimyth, but any ideas? It seems so close to actually working and doesn't seem to add 'much' to overall size.


Thanks
Peter[/code]
pleeke
Contributor
 
Posts: 187
Joined: Thu Jun 30, 2005 9:25 pm

Postby Pablo » Mon Jun 23, 2008 4:01 pm

pleeke wrote:I've had to add this patch to mythtv as the minimyth ps utility doesn't support the same syntax as a normal distro;

Code: Select all
diff -Naur mythtv-0.21-old/libs/libmyth/mythcontext.cpp mythtv-0.21-new/libs/libmyth/mythcontext.cpp
--- mythtv-0.21-old/libs/libmyth/mythcontext.cpp        2008-05-11 18:56:13.000000000 +0100
+++ mythtv-0.21-new/libs/libmyth/mythcontext.cpp        2008-06-21 22:14:49.000000000 +0100
@@ -1810,7 +1810,7 @@
#if defined(CONFIG_DARWIN) || (__FreeBSD__) || defined(__OpenBSD__)
     char *command = "ps -ax | grep -i mythbackend | grep -v grep > /dev/null";
#else
-    char *command = "ps -ae | grep mythbackend > /dev/null";
+    char *command = "ps | grep mythbackend | grep -v grep > /dev/null";
#endif
     bool res = myth_system(command,
                            MYTH_SYSTEM_DONT_BLOCK_LIRC |

I have added the patch.
Obviously also had to build mythtv with --enable-dvb set in the Makefile & a proper dvb-path setting.

I have enabled DVB support in the myth-*/mythtv packages.
Also had to use a custom kernel cfg that enables all dvb & video related options (probably way too many modules built but doesn't seem to increase the image much in size and works for now).

Once everything is working, if you could post the list of modules that are loaded, then I can add them to the kernel config script.
Adding mythbackend & mythtv-setup adds ~1MB to the final nfs tarball. Adding most/all dvb drivers appears to add another ~2.5MB to final tarball (mostly compiled as modules and just including all libs in modules/*/kernel/media/ to be included in minimyth. I'm sure the kernel module size increase can be reduced if only the relevant drivers are installed, but as I use nfs mounted root system it doesn't seem that important (yet).

I can now start the backend daemon & run mythtv-setup and the dvb card drivers are loaded!!

Do you have an init script that you are using to do this? If so, could you post it?
I'm not really suggesting that this becomes part of the default minimyth build (though that would be great ;-)) - as thats bound to bring loads of capture card issues/requests.

At a minimum, I think that it would simplify things for you were the build system to include an mm_SOFTWARE value that includes the backend related software when it is used.
Now I have one issue that has been driving me mad (and stops myth from finding the local dvb card), the dvb nodes are created in /dev with the following (wrong) names;

/dev/dvb0.demux0
/dev/dvb0.dvr0
/dev/dvb0.frontend0
/dev/dvb0.net0


This appears to be udev rules missing from minimyth (unsurprisingly), and I've been googling loads but just can't get it to work properly. Current udev rules in /etc/udev/rules.d/04-minimyth-detect-dvb.rules that I'm trying are;


Code: Select all
ACTION=="add|remove", KERNEL=="dvb[0-9]*", GOTO="begin"
GOTO="end"
LABEL="begin"

# Import mm_detect_id.
IMPORT{program}="/lib/udev/mm_detect_id"

KERNEL="dvb[0-9].dvr*", NAME="dvb/adapter%n/dvr%n"
KERNEL="dvb[0-9].demux*", NAME="dvb/adapter%n/demux%n"
KERNEL="dvb[0-9].frontend*", NAME="dvb/adapter%n/frontend%n"
KERNEL="dvb[0-9].audio*", NAME="dvb/adapter%n/audio%n"
KERNEL="dvb[0-9].ca*", NAME="dvb/adapter%n/ca%n"
KERNEL="dvb[0-9].osd*", NAME="dvb/adapter%n/osd%n"
KERNEL="dvb[0-9].net*", NAME="dvb/adapter%n/net%n"
KERNEL="dvb[0-9].video*", NAME="dvb/adapter%n/video%n"

LABEL="end"



But nothing changes in the device names. I'm not really sure how to debug udev so any pointers would be very helpful.

You can find examples of how other distributions implement udev rules in the system/udev package (script/system/udev/work/main.d/udev-*/etc/udev). The slackware solution uses
Code: Select all
SUBSYSTEM=="dvb", PROGRAM="/bin/sh -c 'X=%k; X=$${X#dvb}; A=$${X%%%%.*}; D=$${X#*.}; echo dvb/adapter$$A/$$D'", NAME="%c"

I would suggest you create a rules file with just the one line above. If it works for you, then I will add it to the 02-minimyth-dev.rules.
I know this isn't really part of minimyth, but any ideas? It seems so close to actually working and doesn't seem to add 'much' to overall size.


Thanks
Peter[/code]
MiniMyth running on an ASUS M3N78-VM and an Acer ApireRevo 3610. Find out more at my MythTV page.
Pablo
Site Admin
 
Posts: 3699
Joined: Tue Dec 14, 2004 1:13 am
Location: La Jolla

Postby pleeke » Tue Jun 24, 2008 10:29 am

Hi,

Adding the line you suggested works! Spent ages trying examples from ubuntu, gentoo and the like but not really sure what I was doing.
Code: Select all
SUBSYSTEM=="dvb", PROGRAM="/bin/sh -c 'X=%k; X=$${X#dvb}; A=$${X%%%%.*}; D=$${X#*.}; echo dvb/adapter$$A/$$D'", NAME="%c"



The list of modules loaded related to dvb & video with a Nova-T (model 909 dvb-t card) are;
root@intel:/dev/dvb/adapter0 # lsmod | grep dvb || video
dvb_pll 9188 1
cx88_dvb 11268 0
cx88_vp3054_i2c 2400 1 cx88_dvb
video_buf_dvb 4484 1 cx88_dvb
dvb_core 64808 1 video_buf_dvb
cx8802 13796 1 cx88_dvb
cx88xx 56388 3 cx88_dvb,cx8800,cx8802
video_buf 18756 5 cx88_dvb,video_buf_dvb,cx8800,cx8802,cx88xx
i2c_core 17760 7 dvb_pll,cx22702,cx88_vp3054_i2c,cx88xx,i2c_algo_bit,tveeprom,i2c_i801

Not sure which kernel modules this actually requires


Do you have an init script that you are using to do this? If so, could you post it?


No init script, (somehow) the card is detected and modules loaded automagically (I was a little surprised as I expected a few tweeks might be needed at this stage). Dmesg shows the all important frontend loading message;
root@intel:/dev/dvb/adapter0 # dmesg | grep front
DVB: registering frontend 0 (Conexant CX22702 DVB-T)...


Just for the record I've added the following cfg to my ~/.minimyth/minimyth.mk file;
mm_USER_BIN_LIST ?= mythbackend mythtv-setup
mm_USER_LIB_LIST ?= modules/*/kernel/drivers/media/dvb/ modules/*/kernel/drivers/media/video/



Question, does the minimyth.script get actioned after kernel modules are loaded? I ask because I need an automatic way of starting mythbackend and am not sure whether the dvb drivers will be loaded before mythbackend if using the minimyth.script.


Thanks
Peter
pleeke
Contributor
 
Posts: 187
Joined: Thu Jun 30, 2005 9:25 pm

Postby Pablo » Tue Jun 24, 2008 10:58 pm

pleeke wrote:Hi,

Adding the line you suggested works! Spent ages trying examples from ubuntu, gentoo and the like but not really sure what I was doing.
Code: Select all
SUBSYSTEM=="dvb", PROGRAM="/bin/sh -c 'X=%k; X=$${X#dvb}; A=$${X%%%%.*}; D=$${X#*.}; echo dvb/adapter$$A/$$D'", NAME="%c"

I am glad that this worked. I have added it to the MiniMyth udev rules and I have checked in the changes.
The list of modules loaded related to dvb & video with a Nova-T (model 909 dvb-t card) are;
[
root@intel:/dev/dvb/adapter0 # lsmod | grep dvb || video
dvb_pll 9188 1
cx88_dvb 11268 0
cx88_vp3054_i2c 2400 1 cx88_dvb
video_buf_dvb 4484 1 cx88_dvb
dvb_core 64808 1 video_buf_dvb
cx8802 13796 1 cx88_dvb
cx88xx 56388 3 cx88_dvb,cx8800,cx8802
video_buf 18756 5 cx88_dvb,video_buf_dvb,cx8800,cx8802,cx88xx
i2c_core 17760 7 dvb_pll,cx22702,cx88_vp3054_i2c,cx88xx,i2c_algo_bit,tveeprom,i2c_i801

Not sure which kernel modules this actually requires

I have enabled the above modules in the MiniMyth kernel and I have checked in the changes. I hope that I enabled all the appropriate kernel modules.
Do you have an init script that you are using to do this? If so, could you post it?


No init script, (somehow) the card is detected and modules loaded automagically (I was a little surprised as I expected a few tweeks might be needed at this stage). Dmesg shows the all important frontend loading message;
root@intel:/dev/dvb/adapter0 # dmesg | grep front
DVB: registering frontend 0 (Conexant CX22702 DVB-T)...

Oops, I was not very clear. I did not think that the init scripts would need to load the kernel modules. This should be handled by udev automatically. I was more curious about how you were starting mythbackend.
Just for the record I've added the following cfg to my ~/.minimyth/minimyth.mk file;
mm_USER_BIN_LIST ?= mythbackend mythtv-setup
mm_USER_LIB_LIST ?= modules/*/kernel/drivers/media/dvb/ modules/*/kernel/drivers/media/video/

I have added the mm_SOFTWARE value 'backend' that causes the MiniMyth build system to include 'mythbackend', 'mythtv-setup' and the above listed kernel modules. I have checked in these changes.
Question, does the minimyth.script get actioned after kernel modules are loaded? I ask because I need an automatic way of starting mythbackend and am not sure whether the dvb drivers will be loaded before mythbackend if using the minimyth.script.

My goal is for MiniMyth retrieve and process minimyth.script as early as possible. The earlier that minimyth.script is retrieved, the more that minimyth.script can modify.

At this time, kernel modules are loaded before minimyth.script is processed. However, this may change in the future. Therefore, when your minimyth.script needs kernel modules loaded, then it should run
Code: Select all
/etc/rc.d/init.d/modules_automatic start


Having said that, I have added the init script /etc/rc.d/init.d/backend and the init configure script /etc/rc.d/init.d/conf.d/MM_BACKEND along with the udev script /etc/rules.d/04-minimyth-detect-backend.script.disabled. The udev script detects whether or not the MythTV backend should be started based on detected tuner cards. This udev script, in combination with the backend and MM_BACKEND scripts, should start the MythTV backend.

These changes have been checked in.
MiniMyth running on an ASUS M3N78-VM and an Acer ApireRevo 3610. Find out more at my MythTV page.
Pablo
Site Admin
 
Posts: 3699
Joined: Tue Dec 14, 2004 1:13 am
Location: La Jolla

Postby Pablo » Wed Jun 25, 2008 4:44 am

The latest test build (56b3) contains the changes. If you get a chance, then could you test whether or not everything required is included in the build and whether or not the mythbackend daemon starts correctly?
MiniMyth running on an ASUS M3N78-VM and an Acer ApireRevo 3610. Find out more at my MythTV page.
Pablo
Site Admin
 
Posts: 3699
Joined: Tue Dec 14, 2004 1:13 am
Location: La Jolla

Postby pleeke » Wed Jun 25, 2008 12:14 pm

Pablo,


Currently building 56b3 to check all is ok.

Just one thing - previously using my own builds I had to delete /root/.mythtv/mysql.txt (as it contained incorrect db username/passwords) and add;

Code: Select all
ln -s /home/minimyth/.mythtv/config.xml /root/.mythtv/config.xml


otherwise mythbackend wouldn't start successfully (unless mythtv-setup had been run).

Thanks
Peter
pleeke
Contributor
 
Posts: 187
Joined: Thu Jun 30, 2005 9:25 pm

Postby pleeke » Thu Jun 26, 2008 6:37 pm

Pablo,

Just tried a build based on 56b3 and mythbackend doesn't attempt to start. I'm guessing that this isn't the expected result

root@intel:/tmp # set | grep BACKEND
MM_BACKEND_ENABLED=''


Shouldn't the above setting have ='yes' for the backend service to attmept to start?

Thanks
Peter
pleeke
Contributor
 
Posts: 187
Joined: Thu Jun 30, 2005 9:25 pm

Postby Pablo » Thu Jun 26, 2008 6:49 pm

pleeke wrote:Pablo,

Just tried a build based on 56b3 and mythbackend doesn't attempt to start. I'm guessing that this isn't the expected result

root@intel:/tmp # set | grep BACKEND
MM_BACKEND_ENABLED=''


Shouldn't the above setting have ='yes' for the backend service to attmept to start?

Thanks
Peter

Oops. There are at least two bugs.

In meta/minimyth/dirs/etc/rc.d/init.d/conf.d/MM_BACKEND, could you change
Code: Select all
MM_BACKEND_ENABLED'auto'

so that it reads
Code: Select all
MM_BACKEND_ENABLED='auto'

and
Code: Select all
if /usrb/bin/test "${MM_BACKEND_ENABLED}" = "auto" ; then

so that it reads
Code: Select all
if /usr/bin/test "${MM_BACKEND_ENABLED}" = "auto" ; then

After that you can rebuild the image without rebuilding all the code by running 'make clean ; make build' in directory 'meta/minimyth'.
MiniMyth running on an ASUS M3N78-VM and an Acer ApireRevo 3610. Find out more at my MythTV page.
Pablo
Site Admin
 
Posts: 3699
Joined: Tue Dec 14, 2004 1:13 am
Location: La Jolla

Postby pleeke » Thu Jun 26, 2008 8:55 pm

Pablo,

Now i get

minimyth@intel:/etc/rc.d/init.d/conf.d $ set | grep BACKEND
MM_BACKEND_ENABLED='no'


Something wrong with this line
if `mm_detect_state_get 'backend' | /bin/grep -c '^yes,'` -gt 0 ; then
MM_BACKEND_ENABLED="yes"

in MM_BACKEND?


Thanks
Peter
pleeke
Contributor
 
Posts: 187
Joined: Thu Jun 30, 2005 9:25 pm

Postby Pablo » Fri Jun 27, 2008 3:29 am

Could you replace it with
Code: Select all
if mm_detect_state_get 'backend' | /bin/grep -q ',yes$' ; then

and try again?
MiniMyth running on an ASUS M3N78-VM and an Acer ApireRevo 3610. Find out more at my MythTV page.
Pablo
Site Admin
 
Posts: 3699
Joined: Tue Dec 14, 2004 1:13 am
Location: La Jolla

Postby pleeke » Fri Jun 27, 2008 2:54 pm

Pablo,

Still no good I'm afraid.

The output of

mm_detect_state_get 'backend'


appears to be

yes yes yes yes


So I just changed the ',yes$' to 'yes$' and that seems to work fine.

Thanks
Peter
pleeke
Contributor
 
Posts: 187
Joined: Thu Jun 30, 2005 9:25 pm

Postby Pablo » Fri Jun 27, 2008 8:01 pm

Thanks. I will clean it up.

Do you mount a television recordings store directory? I just added MM_MEDIA_TV_URL and MM_MEDIA_TV_MOUNTPOINT to minimyth.conf for mounting the television recordings store directory.

Also, I have changed the init script so that it runs mythbackend as the user 'minimyth' rather than as the user 'root'.
MiniMyth running on an ASUS M3N78-VM and an Acer ApireRevo 3610. Find out more at my MythTV page.
Pablo
Site Admin
 
Posts: 3699
Joined: Tue Dec 14, 2004 1:13 am
Location: La Jolla

Postby pleeke » Fri Jun 27, 2008 8:49 pm

Pablo,

Thanks.

I've been mounting all my music/video/recording directories using the minimyth script. I've just looked at the music & video URL/ MOUNTPOINT settings you've added, looks good and I'm just re-cfg'ing things to use them.

For the MEDIA_TV ones and chance of changing them to MEDIA_TV1 & MEDIA_TV2 etc? That way they align with the storage groups idea (I've got a /data & /data2 recording directory to mount).


Thanks
Peter
pleeke
Contributor
 
Posts: 187
Joined: Thu Jun 30, 2005 9:25 pm

Postby Pablo » Sat Jun 28, 2008 2:20 am

pleeke wrote:For the MEDIA_TV ones and chance of changing them to MEDIA_TV1 & MEDIA_TV2 etc? That way they align with the storage groups idea (I've got a /data & /data2 recording directory to mount).

Are you saying that you have the the different stores under different directory trees? My groups, even with multiple drives, they are all mounted under the same directory tree. As a result, only one directory tree needs to be shared.
MiniMyth running on an ASUS M3N78-VM and an Acer ApireRevo 3610. Find out more at my MythTV page.
Pablo
Site Admin
 
Posts: 3699
Joined: Tue Dec 14, 2004 1:13 am
Location: La Jolla

Postby pleeke » Sat Jun 28, 2008 6:51 am

Ahh, good point. I'll change my directory layout to only require one share.

Thanks
Peter
pleeke
Contributor
 
Posts: 187
Joined: Thu Jun 30, 2005 9:25 pm

Next

Return to Build System

Who is online

Users browsing this forum: No registered users and 0 guests