There is a pre-built yocto image and toolchain for Raspberry Pi 2 model.
The yocto image can be downloaded from here.
Install the image to a SD card and resize the root partition:
$ sudo dd if=ybpi-rpi2-image-raspberrypi2_2.3.0.rpi-sdimg of=/dev/sdX
$ sudo parted /dev/sdX resizepart 2 1024M
$ sudo resize2fs /dev/sdX2
Connect the Raspberry Pi to the network and start up with the installed yocto image.
Create a data container as the build workspace.
$ docker create --name workspace raphaelmeyer/base:1.3.0
Setup a cmake project, e.g. in /tmp/src
with a CMakeLists.txt
and a main.cc
.
$ cat /tmp/src/CMakeLists.txt
project (HELLO)
add_executable(hello main.cc)
$ cat /tmp/src/main.cc
#include <iostream>
int main() {
std::cout << "hello world\n";
}
Use the ybpi-sdk container to build the hello world application.
$ docker run --rm -t -v /tmp/src:/home/user/src:ro --volumes-from workspace raphaelmeyer/ybpi-sdk:2.3.0 cmake /home/user/src
$ docker run --rm -t -v /tmp/src:/home/user/src:ro --volumes-from workspace raphaelmeyer/ybpi-sdk:2.3.0 make
Get the hello world from the workspace container and copy to the Raspberry Pi.
$ docker cp workspace:/workspace/hello .
$ scp hello root@[ip address]:
ssh to the raspberry and run the hello world application:
$ ssh root@[ip address]
root@raspberrypi2:~# ./hello
An more complete example can be found here.
The containers and the yocto image are built with a Makefile.
Change the Makefile
and e.g. build-ybpi-sdk.sh
in ybpi-yocto for your needs.
- base: The base container for ybpi-sdk and ybpi-yocto. Also used for data containers holding the build workspaces.
- ybpi-yocto: This container is used to build the yocto image and the toolchain (sdk) installer.
- ybpi-sdk The toolchain (sdk) is installed in this container.