<sub>2024-03-18 @14:25</sub> #digital-garden # About I anticipate some differences in software development transitioning from my Linux setup to macOS, but research suggests that Yocto development is achievable with a docker project called [CROPS (CROss PlatformS)](https://docs.yoctoproject.org/dev-manual/start.html#setting-up-to-use-cross-platforms-crops). I'll give this a try. # Prerequsites Install [Docker Desktop on Mac w/ Apple Silicon](https://docs.docker.com/desktop/install/mac-install/). Following installation, go into settings >> resources and adjust as needed. On my M3 MAX I have the following set. After that go grab the CROPS source. | Resources | Allocation | | --------- | ---------- | | CPU | 16 | | Memory | 16GB | | Disk | 128GB | | Swap | 1GB | > [!WARNING] > Adjusting the `Memory` and `Disk` resources may be required in order to get a successful build. If I receive errors that mention OOM (out of memory) or indicates a task being killed this is a good indication I don't have enough resources. > > I'm also noticing that my build fails when fetching `rpi-bootfiles`. It's terrible slow. I'm thinking my parents wifi back here in Kansas is just too slow (25Mbps) and it's causing the build to fail? I'll have to confirm that when I'm back on a 1G connection. # Fetching & Building I need two docker repos the CROPS source and then a [fork by Esa Jaaskela](https://github.com/ejaaskel/yocto-dockerfiles) that addresses issues like replacing a few GNU commands w/ BSD compatible commands for some build scripts. > [!NOTE] > Not quite understanding this process but it's important to note that I can't use the intended image from `poky-container` because it's AMD64 and we want ARM64. ```bash # CROPS ❯ git clone https://github.com/crops/poky-container.git ``` ```bash # Esa's Fork ❯ git clone [email protected]:ejaaskel/yocto-dockerfiles.git ❯ cd yocto-dockerfiles ❯ export REPO=ejaaskel/yocto ❯ export DISTRO_TO_BUILD=ubuntu-22.04 ❯ ./build_container ❯ cd .. ``` Modify the `poky-container` docker file. Then build the poky image. I'll continue as if i'm following the official [CROPS Mac Guide](https://github.com/crops/docker-win-mac-docs/wiki/Mac-Instructions) but I can easily go back and reference those steps. ```bash # Modify Dockerfile, comment out two lines, add two new ones ❯ cd poky-container && vim Dockerfile # ARG BASE_DISTRO=SPECIFY_ME # FROM crops/yocto:$BASE_DISTRO-base ARG BASE_DISTRO=ubuntu-22.04 FROM ejaaskel/yocto:$BASE_DISTRO-base # Build poky ❯ docker build . -t crops/poky:selfbuilt ❯ cd .. ``` # Volume Creation & Startup Now I need to create a volume first and then start a container to do our yocto work. The CROPS guide talks about the file server called samba but if I use `docker cp` it completely removes the need for a file server. ```bash # Create volume, start container to do work ❯ docker volume create --name myvolume ❯ docker run -it --rm -v myvolume:/workdir busybox chown -R 1000:1000 /workdir ❯ docker run --rm -it -v myvolume:/workdir crops/poky:selfbuilt --workdir=/workdir ``` This will drop me in a shell and now I can follow my normal yocto workflow with pulling down poky and other meta layers then building w/ `bitbake`. A couple useful commands to remember. ```bash # Drop yourself into the docker container as root ❯ docker exec -it --user=root <container-id> bash # Copy files over (e.g. images) ❯ docker cp <containerId>:workdir/<file> . ``` > [!NOTE] > The poky container should contain all necessary dependencies called out under the official yocto user guide. If additional packages are needed I can use that `docker exec` command above to get in as root and install them. > [!NOTE] > Still getting the fetch failure for `rpi-bootfiles` recipe. It is taking forever to check out those sources. I'm thinking it just times out? I noticed I get a bit further when I run the command `bitbake target --runall=fetch`. I think it's my wifi being 25Mbps that is causing the fetch to timeout. Need to confirm this later on my home network.