README-raspberrypi.txt
changeset 7806 03e6aaea8347
parent 7778 a571a9947869
child 7808 627f256b0e56
     1.1 --- a/README-raspberrypi.txt	Fri Oct 11 10:58:05 2013 -0400
     1.2 +++ b/README-raspberrypi.txt	Sat Oct 12 11:35:47 2013 -0300
     1.3 @@ -28,6 +28,65 @@
     1.4  sudo apt-get install libraspberrypi0 libraspberrypi-bin libraspberrypi-dev
     1.5  
     1.6  ================================================================================
     1.7 + Cross compiling from x86 Linux
     1.8 +================================================================================
     1.9 +
    1.10 +To cross compile SDL for Raspbian from your desktop machine, you'll need a
    1.11 +Raspbian system root and the cross compilation tools. We'll assume these tools
    1.12 +will be placed in /opt/rpi-tools
    1.13 +
    1.14 +    sudo git clone --depth 1 https://github.com/raspberrypi/tools /opt/rpi-tools
    1.15 +
    1.16 +You'll also need a Rasbian binary image.
    1.17 +Get it from: http://downloads.raspberrypi.org/raspbian_latest 
    1.18 +After unzipping, you'll get file with a name like: <date>-wheezy-raspbian.img
    1.19 +Let's assume the sysroot will be built in /opt/rpi-sysroot.
    1.20 +
    1.21 +    export SYSROOT=/opt/rpi-sysroot
    1.22 +    sudo kpartx -a -v <path_to_raspbian_image>.img
    1.23 +    sudo mount -o loop /dev/mapper/loop0p2 /mnt
    1.24 +    sudo cp -r /mnt $SYSROOT
    1.25 +    sudo apt-get install qemu binfmt-support qemu-user-static
    1.26 +    sudo cp /usr/bin/qemu-arm-static $SYSROOT/usr/bin
    1.27 +    sudo mount --bind /dev $SYSROOT/dev
    1.28 +    sudo mount --bind /proc $SYSROOT/proc
    1.29 +    sudo mount --bind /sys $SYSROOT/sys
    1.30 +
    1.31 +Now, before chrooting into the ARM sysroot, you'll need to apply a workaround,
    1.32 +edit $SYSROOT/etc/ld.so.preload and comment out all lines in it.
    1.33 +
    1.34 +    sudo chroot $SYSROOT
    1.35 +    apt-get install libudev-dev libasound2-dev libdbus-1-dev libraspberrypi0 libraspberrypi-bin libraspberrypi-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev libxss-dev
    1.36 +    exit
    1.37 +    sudo umount $SYSROOT/dev
    1.38 +    sudo umount $SYSROOT/proc
    1.39 +    sudo umount $SYSROOT/sys
    1.40 +    sudo umount /mnt
    1.41 +
    1.42 +The final step is compiling SDL itself.
    1.43 +
    1.44 +    export CC="/opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc --sysroot=$SYSROOT -I$SYSROOT/opt/vc/include -I$SYSROOT/usr/include -I$SYSROOT/opt/vc/include/interface/vcos/pthreads -I$SYSROOT/opt/vc/include/interface/vmcs_host/linux"
    1.45 +    cd <SDL SOURCE>
    1.46 +    mkdir -p build;cd build
    1.47 +    ../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd
    1.48 +
    1.49 +================================================================================
    1.50 + Apps don't work or poor video/audio performance
    1.51 +================================================================================
    1.52 +
    1.53 +If you get sound problems, buffer underruns, etc, run "sudo rpi-update" to 
    1.54 +update the RPi's firmware. Note that doing so will fix these problems, but it
    1.55 +will also render the CMA - Dynamic Memory Split functionality useless.
    1.56 +
    1.57 +Also, by default the Raspbian distro configures the GPU RAM at 64MB, this is too
    1.58 +low in general, specially if a 1080p TV is hooked up.
    1.59 +
    1.60 +See here how to configure this setting: http://elinux.org/RPiconfig
    1.61 +
    1.62 +Using a fixed gpu_mem=128 is the best option (specially if you updated the 
    1.63 +firmware, using CMA probably won't work, at least it's the current case).
    1.64 +
    1.65 +================================================================================
    1.66   No input
    1.67  ================================================================================
    1.68  
    1.69 @@ -83,5 +142,5 @@
    1.70   Notes
    1.71  ================================================================================
    1.72  
    1.73 -* Building has only been tested natively (i.e. not cross compiled). Cross
    1.74 -  compilation might work though, feedback is welcome!
    1.75 +* Input events from the keyboard leak through to the console
    1.76 +