Open MarkoSagadin opened 3 months ago
Not sure about this, if docker selects the correct platform correctly when building, but just to be sure add --platform linux/arm64
flag to the docker build
command in the build scripts.
I have performed the test, observations and results:
16.02 E: Package 'gcc-multilib' has no installation candidate
)Files:
In regards to USB pass-through issues on MacOS:
@vid553
Please change this line in the Dockerfile
:
wget https://developer.nordicsemi.com/.pc-tools/nrfutil/x64-linux/nrfutil \
to this:
wget https://developer.nordicsemi.com/.pc-tools/nrfutil/universal-osx/nrfutil \
and rebuild.
So, with your help we managed to get it to run on MacOS. I have succesfully build fw for our project that runs on NCS v2.6.1. The build task however is VERY slow (which is kinda expected due to the fact that docker runs containers inside Linux VM on Mac OS). So containers are built and running as amd64 arch.
I have commited the changes we did into feature/mac-os-support
branch.
Additional links (maybe useful):
@vid553 please try another thing: with your current setup on the feature/mac-os-support
branch add back gcc-multilib app package (at the top of the Docker file) and try running ./build_ci.sh
.
The correct --platform
might have fixed this.
You are correct, both build scripts now succeed. I can build fw for the above mentioned NCS.
❯ ./build_ci.sh
[+] Building 87.1s (7/7) FINISHED docker:desktop-linux
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 3.83kB 0.0s
=> [internal] load metadata for docker.io/library/ubuntu:22.04 0.5s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [ci 1/3] FROM docker.io/library/ubuntu:22.04@sha256:340d9b015b194dc6e2a13938944e0d016e57b9679963fdeb9ce021daac430221 0.0s
=> CACHED [ci 2/3] RUN apt-get -y update && apt-get -y upgrade && apt-get -y install --no-install-recommends wget curl unzip lcov gcc-multilib make libffi7 ca-certificates && apt-get clean && rm -rf / 0.0s
=> [ci 3/3] RUN wget https://developer.nordicsemi.com/.pc-tools/nrfutil/x64-linux/nrfutil && ls -al && chmod +x nrfutil && mv nrfutil /usr/bin && nrfutil self-upgrade --to-version 7.11.1 && nrfutil i 78.5s
=> exporting to image 7.8s
=> => exporting layers 7.8s
=> => writing image sha256:240b0a38dbb302507b6f4e8d73979fc5fcbaca36683ff3f96095a319459b4cfb 0.0s
=> => naming to docker.io/irnas/ncs-zephyr-v2.6.1-ci:latest 0.0s
What's next:
View a summary of image vulnerabilities and recommendations → docker scout quickview
@vid553 Nice! That is great to know. Please commit this.
I have an another test for you:
docker run
command in the run.sh
to the below one and run ./run.sh
.docker run -it --rm \
--privileged \
--volume "${HOME}":"${HOME}" \
--volume "${1}":"${HOME}"/workdir \
--volume /dev:/dev \
--workdir "${HOME}"/workdir \
--volume "/etc/group:/etc/group:ro" \
--volume "/etc/passwd:/etc/passwd:ro" \
--volume "/etc/shadow:/etc/shadow:ro" \
--user "$(id -u):$(id -g)" \
--device-cgroup-rule='c 166:* rmw' \
irnas/ncs-zephyr-v2.6.1-dev:latest
There shouldn't be any errors at this point and you should be logged in the container with your host user, so running whoami
outside and inside the container should return the same result.
Nevermind my last comment, that command is not ok. Mounting the entire home folder is not a good idea.
I am giving up on arm64 support for now.
The main issue is that the UID and GID that are declared in the Dockerfile must match those of the host user, otherwise we get into the permission problems, where files that are created by the container user are not writable by the host user.
So, the UID and GID must be modified to match the ones of the host.
I know that this is possible in two ways:
./build_dev.sh
add the following flags: --build-arg UID=${id -u} --build-arg GID=${id -g}
to the docker build
command. (If building on ARM MacOS also add --platform linux/amd64
). With that you should be able to run the image on the MacOs. However, this means that user needs to build the image locally and not use the defacto image provided by the project. I don't like that.Just to highlight one thing: this is not MacOS specific problem. Any Linux distro that creates a user with UID and GID set to something else than 1000:1000 will have this problem.
Required changes to make it work manually are in branch feature/mac-os-support
. Besides them, the only thing that needs to be changed are the UID and GID numbers in Dockerfile as described in the last comment above.
Context
I have created a NCS docker image, however for the first release I will disable support for the arm64 architecture, since some of the packages that I expected to install (gcc-multilib) are not available there.
Since I expect more quirks with this setup I would appreciate some help from an engineer with MacOS laptop.
@vid553 @NejcKle can one of you help me testing this?
Test steps
ncs-zephyr
folder.gcc-multilib
from the list of the installed apt packages inDockerfile
(found at the top).build_ci.sh
andbuild_dev.sh
scripts../run.sh <path to west top dir of the ncs repo>
to enter docker environment.Ok, probably anything related to the device access won't work, USB pass-through Docker support in MacOS is a long standing issue.
Tell me how this goes and what needs to be changed.