Tutorial : Mplayer on Wombat
Content
We'll see how to get Mplayer ported and working on Wombat. This cover the following two architectures :
- PC99
- gta01 (under qemu-neo)
First part covers what's common :
- Cross compiling Mplayer within the framework.
- Increasing the Linux rootfs size and using the right build command line
Second part covers PC99 specific stuffs :
- Activating Frame buffer in Wombat using Wombat fb drivers and map the correct memmory
Third part covers gta01 specific stuffs :
- Activating Frame buffer in Wombat using vlcd server and the Wombat stub
- Patching Qemu to allow a bigger image not to overlap
And finally how to test that it is working
Notes
This has been done using OKL4 v2.1
Step 1 : Cross compiling Mplayer
Adding Mplayer to the framework
First you need to get some Mplayer sources :
# cd /tmp # wget http://www8.mplayerhq.hu/MPlayer/releases/MPlayer-1.0rc2.tar.bz2 # cd -
Then we put then in the right place within the framework :
# cd linux/apps/ # tar xvjf /tmp/MPlayer-1.0rc2.tar.bz2 # mv Mplayer-1.0rc mplayer
We will also include some little video sample (shouldn't exess 1Mo or so):
# cp [somewhere]/test.mpg linux/apps/mplayer/
This is of course highly optional but pretty useful for testing purpose.
Now we need to write a SConscript witch will make use of Mplayer's Makefile. It will deactivate much options and activate frame buffer output.
# cat linux/apps/mplayer/SConscript
Import("*")
import os
build_dir = Dir(env.builddir + "/mplayer").abspath
inst_dir = Dir(env.builddir + "/install").abspath
def b(file_name):
return os.path.join(build_dir, file_name)
def i(file_name):
return os.path.join(inst_dir, file_name)
env.scons_env["MAKE"] = "make"
conf_options = "--disable-gui --disable-gtk1 --disable-largefiles --disable-linux-devfs --disable-termcap --disable-termios --disable-lirc --disable-lircc --disable-joystick --disable-apple-remote --disable-radio --disable-radio-capture --disable-winsock2 --disable-smb --disable-live --disable-nemesi --disable-menu --disable-fribidi --disable-macosx-finder-support --disable-macosx-bundle --disable-rpath --disable-gif --disable-png --disable-jpeg --disable-libcdio --disable-liblzo --disable-tremor-low --disable-tremor-external --disable-theora --disable-faad-external --disable-faad-fixed --disable-xmms --disable-libdca --disable-gl --disable-dga2 --disable-dga1 --disable-vesa --disable-svga --disable-sdl --disable-aa --disable-caca --disable-ggi --disable-ggiwmh --disable-directx --disable-dxr2 --disable-dxr3 --disable-ivtv --disable-v4l2 --disable-dvb --disable-dvbhead --disable-mga --disable-xmga --disable-xv --disable-xvmc --disable-vm --disable-xinerama --disable-x11 --disable-xshape --disable-mlib --disable-3dfx --disable-tdfxfb --disable-s3fb --disable-directfb --disable-zr --disable-bl --disable-tdfxvid --disable-xvr100 --disable-runtime-cpudetection --disable-static --disable-color-console --disable-mmx --disable-mmxext --disable-3dnow --disable-3dnowext --disable-sse --disable-sse2 --disable-ssse3 --disable-shm --disable-altivec --disable-armv5te --disable-armv6 --disable-iwmmxt --disable-big-endian --disable-profile --disable-crash-debug --disable-dynamic-plugins --disable-mencoder --disable-iconv --disable-langinfo --disable-vm --disable-xf86keysym --disable-radio-v4l2 --disable-radio-bsdbt848 --disable-tv --disable-tv-v4l1 --disable-tv-v4l2 --disable-tv-bsdbt848 --disable-tv-teletext --disable-pvr --disable-rtc --disable-network --disable-dvdnav --disable-dvdread --disable-dvdread-internal --disable-libdvdcss-internal --disable-cdparanoia --disable-cddb --disable-bitmap-font --disable-freetype --disable-fontconfig --disable-unrarlib --disable-sortsub --disable-enca --disable-macosx --disable-maemo --disable-inet6 --disable-gethostbyname2 --disable-ftp --disable-vstream --disable-pthreads --disable-w32threads --disable-ass --disable-win32dll --disable-qtx --disable-xanim --disable-real --disable-xvid --disable-x264 --disable-libnut --disable-tremor-internal --disable-libvorbis --disable-speex --disable-faad-internal --disable-faac --disable-ladspa --disable-libdv --disable-mad --disable-toolame --disable-twolame --disable-mp3lib --disable-liba52 --disable-libmpeg2 --disable-musepack --disable-libamr_nb --disable-libamr_wb --disable-vidix-internal --disable-vidix-external --disable-tga --disable-pnm --disable-md5sum --disable-alsa --disable-ossaudio --disable-arts --disable-esd --disable-polyp --disable-jack --disable-openal --disable-nas --disable-sgiaudio --disable-sunaudio --disable-win32waveout --disable-select --disable-fastmemcpy --disable-sighandler --enable-fbdev --enable-static –enable-cross-compile"
def c(tool_name):
return env.scons_env["TOOLPREFIX"] + tool_name
mplayer = env.Command(b("mplayer"),
[Dir(".")] ,
"cd linux/apps/mplayer/ && ./configure %s --prefix=%s --cc=%s --as=%s --ar=%s --ranlib=%s --host-cc=gcc --target=%s && make && cd ../../.. " %
(conf_options, inst_dir, c("gcc"), c("as"), c("ar"), c("ranlib"), env.scons_env["TOOLPREFIX"]))
mplayer_install = env.Command(i("bin/mplayer"),
mplayer,
"cp linux/apps/mplayer/mplayer %s/bin && cp linux/apps/mplayer/test.mpg %s/" % (inst_dir, inst_dir))
Return("mplayer_install")
Compilation
In order to have Mplayer compiled we need to add it to build.py linux_apps option. We also need to increase the linux root fs size since default doesn't leave us enough space to add it. This is done via the LINUX_ROOTFS_SIZE option.
This give use the following compilation lines :
For PC99 :
# ./tools/build.py machine=ia32_pc99_fb project=iguana wombat=True toolprefix=i686-unknown-linux-gnu- linux_apps=mplayer LINUX_ROOTFS_SIZE=20000
For gta01 :
# ./tools/build.py machine=gta01 project=iguana wombat=True linux_apps=mplayer LINUX_ROOTFS_SIZE=20000
Step 2.a : PC99 Specific stuffs
To have the frame buffer working we'll use the Linux frame buffer drivers and thus create the necessary memory mapping. What will be done is a direct memory mapping alloying the the frame buffer drivers to access the frame buffer memory.
Adding a region
Firstly we'll modify the ia32_pc99_fb target in platform/pc99/tools/machines.py to create a dedicated region and add a linux_fb flag which will come handy latter. This region describe the physical memory our frame buffer use.
# cat platform/pc99/tools/machines.py
[...]
class ia32_pc99_fb(ia32_pc99_vga):
linux_fb = True
memory = ia32_pc99_vga.memory.copy()
memory['fb'] = [Region(0xF0000000L, 0xF2001000L, "dedicated")]This will create after compiling :
# cat build/images/weaver.xml
<?xml version="1.0"?>
<!DOCTYPE image SYSTEM "weaver-1.1.dtd">
<image>
<machine>
[...]
<physical_memory name="fb">
<region base="0xf0000000" size="0x2001000" type="dedicated" />
[...]
Adding a memsection for Wombat
Now we need to map this region to Wombat. This is done in projects/iguana/ SConstruct, in short we check the linux_fb flag and create the memsection :
# cat projects/iguana/SConstruct
[...]
if getattr(linux_env.machine, "linux_fb", False):
addressing = linux_env.WeaverAddressing(physpool='fb', virt_addr = 0xf0000000)
fb_area = linux_env.IguanaMemSection(
name = 'fb',
base = 0xf0000000,
size = 0x2001000,
flags = 0x02, # MEM_USER | MEM_FIXED
cache_policy = "uncached",
addressing = addressing,
zero = False
)
linux_env.weaver(wombat).add_memsection(fb_area)
[...]This will create :
# cat build/images/weaver.xml
<?xml version="1.0"?>
<!DOCTYPE image SYSTEM "weaver-1.1.dtd">
<image>
[...]
<program name="vmlinux" file="/home/grosbill/Stage/v2.1/okl4_2.1/build/iguana/wombat/vmlinux" server="OKL4_VMLINUX" >
[...]
<memsection name="fb" size="0x2001000" virt_addr="0xf0000000" physpool="fb" zero="false" cache_policy="uncached" />
[..]
Step 2.b : gta01 specific stuffs
Activating the frame buffer server
First we tell SCon that Wombat now need vlcd :
$ cat projects/iguana/SConstruct # ig_env.required_vdevs["vmlinux"] = (["vtimer", "vserial"]) ig_env.required_vdevs["vmlinux"] = (["vtimer", "vserial", "vlcd"])
Be aware that this modification is architecture independent and will affect all compilations.
Updating the wombat framebuffer stub
Now that the vlcd server is activated,we need some working stub to use it. The provided drivers still use the old devicecore architecture so we need to do some tweak :
# cat linux/kernel-2.6.23-v2/arch/l4/drivers/ig_fb.c
[...]
static int __init ig_fb_init(void)
{
[...]
/* First, we find the input device */
/* memsection_lookup(env_memsection_base(iguana_getenv("OKL4_CORE_DEVICE_SERVER")), */
/* &server_); */
/* server = thread_l4tid(server_); */
/* ig_fb->dev = device_core_get_vdevice(server, &ig_fb->server, &timer_thread, 8, "lcd", &env); */
ig_fb->server = env_thread_id(iguana_getenv("VLCD_TID"));
ig_fb->dev = env_const(iguana_getenv("VLCD_HANDLE"));
[..]
virtual_lcd_add_memsection(ig_fb->server, ig_fb->dev, ms, 0, 0, &env);
virtual_lcd_set_fb(ig_fb->server, ig_fb->dev, vbase, &env);
[..]
Patching Qemu-neo
During boot process the image is loaded in memory then decoded at a lower position. So if the image is too big it will overlap. In order to avoid that we'll tell qemu to load the image at a higher address.
$ cat qemu-neo1973/hw/neo1973.c [...] /* load_image(s->kernel, phys_ram_base + 0x01000000); */ load_image(s->kernel, phys_ram_base + 0x02000000); [...]
Step 3 : Test
PC99
# qemu -hda build/images/c.img -serial stdio [..]
gta01
# ./arm-softmmu/qemu-system-arm -M gta01 -m 130 -mtdblock openmoko/openmoko-flash.base -serial stdio -kernel /tmp/okl4_2.1/build/images/image.boot [...] GTA01Bv4 # bootelf 32000000 [...]
Comon
Please press Enter to activate this console. BusyBox v1.00 (2008.05.22-14:29+0000) Built-in shell (ash) Enter 'help' for a list of built-in commands. # mplayer test.mpg
We should finally get some video on our frame buffer.