Raspberry Raspbian ubuntu cross-compiler setup

development rpi raspberry ubuntu

Here are some direction to setup a developement environement for the raspberrypi pi3 device on Ubuntu 18.04. I do use a raspbian lite image (without X) for grabbing the rpi sysroot, as i don't want/need X window management system. You may replace the image with the non-lite one, the directions still apply.

  • Download official raspberrypi toolchains and export paths
    sudo git clone git://github.com/raspberrypi/tools.git /opt/rpi
    sudo chown -R $USER:$USER /opt/rpi
    echo "export RPI_SDK=/opt/rpi/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian" >> ~/.bashrc
    echo "export PATH=$PATH:/opt/rpi/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin" >> ~/.bashrc
    source ~/.bashrc
  • Download and extract rpi rootfs from raspbian image (may use rsync from device...)
    wget http://director.downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2019-04-09/2019-04-08-raspbian-stretch-lite.zip
    unzip 2019-04-08-raspbian-stretch-lite.zip
    sudo apt-get install kpartx
    sudo kpartx -av 2019-04-08-raspbian-stretch-lite.img
    sudo mount /dev/mapper/loop7p2 /mnt
    cp -rf /mnt/lib $RPI_SDK
    cp -rf /mnt/usr $RPI_SDK
    sudo umount /mnt
    sudo kpartx -d 2019-04-08-raspbian-stretch-lite.img
  • Compile SDL2
    
    git clone https://github.com/SDL-mirror/SDL.git 
    cd SDL
    ./configure --prefix=$RPI_SDK --host=arm-linux-gnueabihf
    make -j7 && make install
    cd test

Previous Post Next Post