Building Circuit Python on your Mac

By | June 29, 2024

First install virtual box from https://www.virtualbox.org/wiki/Downloads

Install ubuntu desktop using this guide

Once ubuntu is set up install vscode.
Then install git for Install sudu apt-get install git
Install sudu apt-get install git

Install git hub desktop for linux. I really like github desktop and is helpful for painless stashing.

sudo sh -c ‘echo “deb [arch=amd64 signed-by=/usr/share/keyrings/mwt-desktop.gpg] https://mirror.mwt.me/shiftkey-desktop/deb/ any main” > /etc/apt/sources.list.d/mwt-desktop.list’

sudo apt update && sudo apt install github-desktop

start building some tool chains stuff with the following installs

Get the following toolchains

sudo apt update
Try running make. If it’s not installed, do:
sudo apt install build-essential

If you don’t have add-apt-repository, do:
sudo apt install software-properties-common

Recommended on Ubuntu 22.04: use the latest stable version of git:
Optional and not necessary on Ubuntu 24.04.
sudo add-apt-repository ppa:git-core/ppa

sudo apt install git git-lfs gettext cmake

https://developer.arm.com/downloads/-/gnu-rm

this particular toolchain https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2?rev=78196d3461ba4c9089a67b5f33edf82a&hash=5631ACEF1F8F237389F14B41566964EC

Exract it in the download folder using the archiver tool and then move it to the opt folder using the following command

sudo cp -r gcc-arm-none-eabi-10.3-2021.10 /opt/

Now that is is there do sym links to that folder using

https://quarto.org/docs/download/tarball.html

export PATH=$PATH:$~/opt/gcc-arm-none-eabi-10.3-2021.10/bin

export PATH=$PATH:$~/opt/gcc-arm-none-eabi-10.3-2021.10/bin

$ export PATH=$PATH:${install_dir}/gcc-arm-none-eabi-10.3-2021.10/bin
$ arm-none-eabi-gcc --version

You should get something like this.

jim@jim-VirtualBox:~$ arm-none-eabi-gcc –version
arm-none-eabi-gcc (15:10.3-2021.07-4) 10.3.1 20210621 (release)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

to see if everything is installed use the following command.

jim@jim-VirtualBox:~$ which arm-none-eabi-gcc
/usr/bin/arm-none-eabi-gcc

next in unbunto 2.0.4 you need to use a virtual python environment. this is for safety reasons so we will do it.

Install if not already installed.
sudo apt install python3-venv

Put the venv (virtual environment) in your home directory.
cd

Create the venv and name it .py (or whatever you’d like).
python3 -mvenv .py

to activate the virtual envionment use the following command.

source .py/bin/activate

to deactivate use deactivate

Now that the tool chain is done let get ready to build circuit python.

Install pip if it is not already installed (Linux only). Try running pip first.

sudo apt install python3-pip

Install needed Python packages from pypi.org.

pip3 install –upgrade -r requirements-dev.txt
pip3 install –upgrade -r requirements-doc.txt

Now build circuit python as follows.

find your board ~/circuitpython/ports/raspberrypi/boards

raspberry_pi_pico_w

cd ports/raspberrypi
make BOARD=raspberry_pi_pico_w

make BOARD=raspberry_pi_pico_w

Mac install

I was not able to get the Linux solution working so decided to try the mac workflow instead. So here it goes.

brew update
brew tap --repair
brew install git git-lfs python3 gettext uncrustify cmake
git lfs install
brew link gettext --force

brew install --cask gcc-arm-embedded

Build a disk image for the mac, since mac is not case sensitive and important for cp build

https://support.apple.com/guide/disk-utility/create-a-disk-image-dskutl11888/mac

I called it Build CP, then install

brew install make

then read to get circuit python, cd into your drive using the following

cd /Volumes/BuildCP