Skip to content

Commit 1942d05

Browse files
Merge branch 'upstream/main' (from adafruit/circuitpython) into main
2 parents 193f700 + 0a53eb8 commit 1942d05

File tree

5,607 files changed

+96812
-98207
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,607 files changed

+96812
-98207
lines changed

.codespell/exclude-file.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ USB_PRODUCT = "BLOK"
55
print(binascii.b2a_base64(b"fo"))
66
# again, neither will "there" or "wither", since they have "the"
77
i1Qb$TE"rl
8+
ZEN = "the zen of python beautiful is better than ugly explicit is better than implicit simple is better than complex complex is better than complicated flat is better than nested sparse is better than dense readability counts special cases arent special enough to break the rules although practicality beats purity errors should never pass silently unless explicitly silenced in the face of ambiguity refuse the temptation to guess there should be one and preferably only one obvious way to do it although that way may not be obvious at first unless youre dutch now is better than never although never is often better than right now if the implementation is hard to explain its a bad idea if the implementation is easy to explain it may be a good idea namespaces are one honking great idea lets do more of those"
9+
"arent",
10+
"youre",

.devcontainer/Readme.md

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,46 @@
1-
Build CircuitPython in a Github-Devcontainer
2-
============================================
1+
Build CircuitPython in a Github-Codespace
2+
=========================================
33

4-
To build CircuitPython within a Github-Devcontainer, you need to perform
4+
To build CircuitPython within a Github codespace, you need to perform
55
the following steps.
66

7-
1. checkout the code to a devcontainer
8-
9-
- click on the green "<> Code"-button
10-
- select the Codespaces-tab
11-
- choose "+ new with options..." from the "..."-menu
12-
- in the following screen select the branch and then
13-
- select ".devcontainer/cortex-m/devcontainer.json" instead
14-
of "Default Codespaces configuration"
15-
- update region as necessary
16-
- finally, click on the green "Create codespace" button
17-
18-
2. Your codespace is created. Cloning the images is quite fast, but
19-
preparing it for CircuitPython-development takes about 10 minutes.
20-
Note that this is a one-time task.
7+
1. checkout the code to a codespace
8+
9+
- click on the green "<> Code"-button
10+
- select the Codespaces-tab
11+
- choose "+ new with options..." from the "..."-menu
12+
- in the following screen select the branch and then
13+
- select the port instead of "Default project configuration"
14+
(unsupported: ports not using cortex-m or esp-idf)\
15+
![](./codespace_options.png)
16+
- update region as necessary
17+
- finally, click on the green "Create codespace" button
18+
19+
2. Your codespace is created. Cloning the image and the repo is quite fast,
20+
but preparing it for CircuitPython-development takes about 10 minutes.
21+
But this is a one-time task: once created, your codespace exists
22+
until you explicitly delete it or until it times out (default: 30 days).\
23+
(Technical note: due to a bug in codespace creation, the setup is
24+
triggered from `$HOME/.bashrc` and runs in the background).
2125

2226
3. During creation, you can run the command
23-
`tail -f /workspaces/.codespaces/.persistedshare/creation.log`
24-
to see what is going on.
27+
`tail -f /workspaces/install_build_env.log.active`
28+
to see what is going on. Once finished the log file is available
29+
as `/workspaces/install_build_env.log`.
2530

26-
4. To actually build CircuitPython, run
31+
4. To actually build CircuitPython, open a new terminal and run e.g.
2732

2833
cd ports/raspberrypi
2934
make -j $(nproc) BOARD=whatever TRANSLATION=xx_XX
3035

31-
This takes about 2m40s.
36+
This takes about 2m40s. The new terminal is necessary since the
37+
setup of the build environment also changes `$HOME/.bashrc` and
38+
sets important environment variables in that file.
39+
40+
As a normal user, you have 120 CPU-hours and 15GB per month free. Since
41+
the smallest machine has two CPUs, you effectively have 60 hours active
42+
time available.
43+
44+
All scripts are in `circuitpython/.devcontainer` and can also be executed
45+
manually which should usually not be necessary. With small changes, they
46+
should also work on a Linux-PC or laptop.

.devcontainer/add_kitware_archive.sh

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#!/bin/sh
2+
# -----------------------------------------------------------------------------
3+
# This script is from: https://apt.kitware.com/kitware-archive.sh
4+
#
5+
# It installs key and repo for the kitware CMAKE-archive.
6+
#
7+
# Author: Bernhard Bablok
8+
#
9+
# -----------------------------------------------------------------------------
10+
11+
set -eu
12+
13+
help() {
14+
echo "Usage: $0 [--release <ubuntu-release>] [--rc]" > /dev/stderr
15+
}
16+
17+
doing=
18+
rc=
19+
release=
20+
help=
21+
for opt in "$@"
22+
do
23+
case "${doing}" in
24+
release)
25+
release="${opt}"
26+
doing=
27+
;;
28+
"")
29+
case "${opt}" in
30+
--rc)
31+
rc=1
32+
;;
33+
--release)
34+
doing=release
35+
;;
36+
--help)
37+
help=1
38+
;;
39+
esac
40+
;;
41+
esac
42+
done
43+
44+
if [ -n "${doing}" ]
45+
then
46+
echo "--${doing} option given no argument." > /dev/stderr
47+
echo > /dev/stderr
48+
help
49+
exit 1
50+
fi
51+
52+
if [ -n "${help}" ]
53+
then
54+
help
55+
exit
56+
fi
57+
58+
if [ -z "${release}" ]
59+
then
60+
unset UBUNTU_CODENAME
61+
. /etc/os-release
62+
63+
if [ -z "${UBUNTU_CODENAME+x}" ]
64+
then
65+
echo "This is not an Ubuntu system. Aborting." > /dev/stderr
66+
exit 1
67+
fi
68+
69+
release="${UBUNTU_CODENAME}"
70+
fi
71+
72+
case "${release}" in
73+
noble|jammy|focal)
74+
packages=
75+
keyring_packages="ca-certificates gpg wget"
76+
;;
77+
*)
78+
echo "Only Ubuntu Noble (24.04), Jammy (22.04), and Focal (20.04) are supported. Aborting." > /dev/stderr
79+
exit 1
80+
;;
81+
esac
82+
83+
get_keyring=
84+
if [ ! -f /usr/share/doc/kitware-archive-keyring/copyright ]
85+
then
86+
packages="${packages} ${keyring_packages}"
87+
get_keyring=1
88+
fi
89+
90+
# Start the real work
91+
set -x
92+
93+
apt-get update
94+
# shellcheck disable=SC2086
95+
apt-get install -y ${packages}
96+
97+
test -n "${get_keyring}" && (wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - > /usr/share/keyrings/kitware-archive-keyring.gpg)
98+
99+
echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ ${release} main" > /etc/apt/sources.list.d/kitware.list
100+
if [ -n "${rc}" ]
101+
then
102+
echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ ${release}-rc main" >> /etc/apt/sources.list.d/kitware.list
103+
fi
104+
105+
apt-get update
106+
test -n "${get_keyring}" && rm /usr/share/keyrings/kitware-archive-keyring.gpg
107+
apt-get install -y kitware-archive-keyring
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/universal
3+
{
4+
"name": "atmel-samd",
5+
"image": "mcr.microsoft.com/devcontainers/universal:2",
6+
"postCreateCommand": ".devcontainer/post_create.sh",
7+
"remoteEnv": { "CP_TOOLCHAIN": "cortex-m",
8+
"CP_PORT": "atmel-samd" }
9+
10+
// Features to add to the dev container. More info: https://containers.dev/features.
11+
// "features": {},
12+
13+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
14+
// "forwardPorts": [],
15+
16+
// Use 'postCreateCommand' to run commands after the container is created.
17+
// "postCreateCommand": "uname -a",
18+
19+
// Configure tool-specific properties.
20+
// "customizations": {},
21+
22+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
23+
// "remoteUser": "root"
24+
}

.devcontainer/codespace_options.png

76.2 KB
Loading

.devcontainer/common_tools.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
# -----------------------------------------------------------------------------
3+
# common_tools.sh: install tools and requirements for CircuitPython
4+
#
5+
# This script installs tools common to all builds.
6+
#
7+
# Author: Bernhard Bablok
8+
#
9+
# -----------------------------------------------------------------------------
10+
11+
REPO_ROOT="/workspaces/circuitpython"
12+
13+
echo -e "[common_tools.sh] starting install"
14+
cd "$REPO_ROOT"
15+
16+
# --- repositories and tools ------------------------------------------------
17+
18+
echo -e "[common_tools.sh] adding kitware-archive (for current CMAKE)"
19+
sudo .devcontainer/add_kitware_archive.sh
20+
echo -e "[common_tools.sh] installing current version of CMAKE"
21+
sudo apt-get -y install cmake
22+
23+
echo -e "[common_tools.sh] adding pybricks/ppa"
24+
sudo add-apt-repository -y ppa:pybricks/ppa
25+
echo -e "[common_tools.sh] installing uncrustify and mtools"
26+
sudo apt-get -y install uncrustify mtools
27+
28+
# dosfstools >= 4.2 needed, standard repo only has 4.1
29+
echo -e "[common_tools.sh] downloading and installing dosfstools"
30+
wget https://github.com/dosfstools/dosfstools/releases/download/v4.2/dosfstools-4.2.tar.gz
31+
tar -xzf dosfstools-4.2.tar.gz
32+
(cd dosfstools-4.2/
33+
./configure
34+
make -j $(nproc)
35+
sudo make install
36+
)
37+
rm -fr dosfstools-4.2 dosfstools-4.2.tar.gz
38+
39+
# --- circuitpython setup --------------------------------------------------
40+
41+
# additional python requirements
42+
echo -e "[common_tools.sh] pip-installing requirements"
43+
pip install --upgrade -r requirements-dev.txt
44+
pip install --upgrade -r requirements-doc.txt
45+
46+
# add pre-commit
47+
echo -e "[common_tools.sh] installing pre-commit"
48+
pre-commit install

.devcontainer/cortex-m-toolchain.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# -----------------------------------------------------------------------------
3+
# cortex-m-toolchain.sh: install toolchain for CircuitPython
4+
#
5+
# Author: Bernhard Bablok
6+
#
7+
# -----------------------------------------------------------------------------
8+
9+
echo -e "[cortex-m-toolchain.sh] starting install"
10+
11+
# --- tooling --------------------------------------------------------------
12+
13+
echo -e "[cortex-m-toolchain.sh] downloading and installing gcc-arm-non-eabi toolchain"
14+
cd /workspaces
15+
16+
wget -qO gcc-arm-none-eabi.tar.xz \
17+
https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz
18+
19+
tar -xJf gcc-arm-none-eabi.tar.xz
20+
ln -s arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi gcc-arm-none-eabi
21+
rm -f gcc-arm-none-eabi.tar.xz
22+
23+
echo -e "[cortex-m-toolchain.sh] update PATH in environment"
24+
echo -e "\nexport PATH=/workspaces/gcc-arm-none-eabi/bin:$PATH" >> $HOME/.bashrc

.devcontainer/cortex-m/devcontainer.json

Lines changed: 0 additions & 23 deletions
This file was deleted.

.devcontainer/cortex-m/on-create.sh

Lines changed: 0 additions & 59 deletions
This file was deleted.

.devcontainer/cxd56/devcontainer.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/universal
3+
{
4+
"name": "cxd56",
5+
"image": "mcr.microsoft.com/devcontainers/universal:2",
6+
"postCreateCommand": ".devcontainer/post_create.sh",
7+
"remoteEnv": { "CP_TOOLCHAIN": "cortex-m",
8+
"CP_PORT": "cxd56" }
9+
10+
// Features to add to the dev container. More info: https://containers.dev/features.
11+
// "features": {},
12+
13+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
14+
// "forwardPorts": [],
15+
16+
// Use 'postCreateCommand' to run commands after the container is created.
17+
// "postCreateCommand": "uname -a",
18+
19+
// Configure tool-specific properties.
20+
// "customizations": {},
21+
22+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
23+
// "remoteUser": "root"
24+
}

0 commit comments

Comments
 (0)