Skip to content

Commit

Permalink
combine C/C++ and MicroPython downloads; add README
Browse files Browse the repository at this point in the history
  • Loading branch information
znmeb committed Oct 27, 2023
1 parent a719283 commit a3ffced
Show file tree
Hide file tree
Showing 14 changed files with 168 additions and 23,202 deletions.
3 changes: 0 additions & 3 deletions PicoVision-Python-dev/.gitignore

This file was deleted.

41 changes: 0 additions & 41 deletions PicoVision-Python-dev/downloads.sh

This file was deleted.

22,832 changes: 0 additions & 22,832 deletions PicoVision-SDK-setup/3build-examples.log

This file was deleted.

326 changes: 0 additions & 326 deletions PicoVision-SDK-setup/list-uf2-files.log

This file was deleted.

2 changes: 2 additions & 0 deletions PicoVision-dev-setup/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pdf
*.uf2
72 changes: 72 additions & 0 deletions PicoVision-dev-setup/0mambaforge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#! /bin/bash

set -e

export MAMBAFORGE_HOME="$HOME/mambaforge"

if [ ! -d "$MAMBAFORGE_HOME" ]
then
echo "$MAMBAFORGE_HOME doesn't exist"
echo "Installing mambaforge"

export ARCH=`uname -m`
echo "ARCH: $ARCH"
if [ $ARCH == "armv7l" ]
then
echo "Sorry - no Mambaforge release exists for $ARCH"
exit
fi

pushd /tmp

echo "Downloading latest Mambaforge installer"
rm -fr Mambaforge*
wget -q \
https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-$ARCH.sh
chmod +x Mambaforge-Linux-$ARCH.sh

echo "Installing Mambaforge to '$MAMBAFORGE_HOME' ..."
./Mambaforge-Linux-$ARCH.sh -b -p $MAMBAFORGE_HOME

popd
fi

echo "Enabling 'conda' and 'mamba'"
source $MAMBAFORGE_HOME/etc/profile.d/conda.sh
source $MAMBAFORGE_HOME/etc/profile.d/mamba.sh

echo "Activating 'base'"
mamba activate base

echo "Disabling auto-activation of 'base' environment"
conda config --set auto_activate_base false

echo "Setting default threads to number of processors"
conda config --set default_threads `nproc`

echo "Updating base packages"
mamba update --name base --all --yes --quiet

echo "Setting up bash command line"
conda init bash
mamba init bash
echo "export MAMBAFORGE_HOME=$MAMBAFORGE_HOME" >> ~/.bash_aliases

if [ -e $HOME/.zshrc ]
then
echo "Setting up zsh command line"
conda init zsh
mamba init zsh
echo "export MAMBAFORGE_HOME=$MAMBAFORGE_HOME" >> ~/.zshrc
fi

echo "Creating fresh Mamba environment 'PicoVision' with 'mpremote'"
. "$MAMBAFORGE_HOME/etc/profile.d/conda.sh"
. "$MAMBAFORGE_HOME/etc/profile.d/mamba.sh"
mamba create --force --yes --quiet --name PicoVision \
python \
pip
mamba activate PicoVision
pip install --quiet --upgrade mpremote

echo "Finished!"
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ popd
echo "Copying picoprobe udev rules"
sudo cp 99-pico.rules /etc/udev/rules.d/99-pico.rules

echo "Downloading pinout diagram"
curl -sL \
"https://cdn.shopify.com/s/files/1/0174/1800/files/picovision_diagram.pdf?v=1696414342" > picovision_diagram.pdf

echo "Finished!"
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions PicoVision-dev-setup/4MicroPython.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /bin/bash

set -e

source set_pico_envars

echo "Downloading MicroPython release $PICOVISION_VERSION"
curl -sOL \
"https://github.com/pimoroni/picovision/releases/download/v$PICOVISION_VERSION/pimoroni-picovision-v$PICOVISION_VERSION-micropython.uf2"
curl -sOL \
"https://github.com/pimoroni/picovision/releases/download/v$PICOVISION_VERSION/pimoroni-picovision-widescreen-v$PICOVISION_VERSION-micropython.uf2"

echo "Downloading flash_nuke.uf2"
curl -sOL https://datasheets.raspberrypi.com/soft/flash_nuke.uf2

echo "Finished!"
File renamed without changes.
64 changes: 64 additions & 0 deletions PicoVision-dev-setup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Setting up the Development Environment

## Usage
1. Get a PicoVision and a display. As far as I know, most HDMI displays
designed to work with a Raspberry Pi will work with the PicoVision.

2. Edit the environment variables. The file `set_pico_envars` defines
all the environment variables needed for the rest of the scripts.
The scripts all do `source set_pico_envars` to read them.

3. Run the numbered scripts in order:
- 0mambaforge.sh
- 1pico-toolchain.sh
- 2pimoroni-repos.sh
- 3build-examples.log
- 3build-examples.sh
- 4MicroPython.sh

4. Documentation: for C/C++ development, refer to
<https://www.raspberrypi.com/documentation/microcontrollers/c_sdk.html>. The
setup steps have already been done, so you can start at
<https://www.raspberrypi.com/documentation/microcontrollers/c_sdk.html#raspberry-pi-pico-cc-sdk>.

For MicroPython development, start with
<https://www.raspberrypi.com/documentation/microcontrollers/micropython.html>.
Then read the Pimoroni PicoVision documentation at
<https://github.com/pimoroni/picovision>. I strongly recommend using
Mamba virtual environments for all Python development. To get started,
type `mamba activate PicoVision`. From there, you can use the
`mpremote` command line utility to manage your PicoVision board.

## Script details

### Mambaforge
My Python development process heavily depends on the Mamba package and environment
manager (<ihttps://mamba.readthedocs.io/en/latest/index.html>). The script
`0mambaforge.sh` checks to see if Mambaforge is installed. If it isn't,
`0mambaforge.sh` installs it. Once Mambaforge is installed, the script
creates a virtual environment named `PicoVision` which contains `Python`,
`pip` and the MicroPython command line utility `mpremote`. See
<https://docs.micropython.org/en/latest/reference/mpremote.html> for
`mpremote` documentation.

### The Pico toolchain
`1pico-toolchain.sh` installs all the C/C++ SDK tools.

### Pimroni repositories
`2pimoroni-repos.sh` installs the Pimoroni repositories required for CLAMS
development.

### Building the examples
`3build-examples.sh` builds all the Raspberry Pi and Pimoroni examples. This
takes a bit of time, but it's a necessary test of the toolchain, and as a
bonus supplies numerous firmware examples to experiment with!

### MicroPython tools
`4MicroPython.sh` downloads the firmware files for PicoVision MicroPython.
If you want to remove MicroPython and load other firmware, put the PicoVision
in bootloader mode and install `flash_nuke.uf2`. It will erase the flash and
put the PicoVision CPU back in bootloader mode.

### Listing the firmware files in the examples
Once you've built all the examples, `list-uf2-files.sh` will list all of
the firmware files it built!
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# This is the Mambaforge default. If you want, you can change it but
# I don't recommend it.
export MAMBAFORGE_HOME=$HOME/mambaforge

# There's no default for this. You can put this anywhere; if it
# doesn't exist it will be created.
export PICO_HOME=$HOME/Projects
echo "Creating $PICO_HOME if necessary"; mkdir --parents $PICO_HOME

# Don't change any of these!
export PICO_PATH=$HOME/Projects/pico
export PICO_SDK_PATH=$PICO_PATH/pico-sdk
export PICO_EXAMPLES_PATH=$PICO_PATH/pico-examples
Expand All @@ -9,3 +18,4 @@ export PICO_OPENOCD_PATH=$PICO_PATH/openocd
export PICO_PICOTOOL_PATH=$PICO_PATH/picotool
export PICO_PICOVISION_PATH=$PICO_PATH/picovision
export PICO_PICOVISION_PROJECTS_PATH=$PICO_PATH/picovision-projects
export PICOVISION_VERSION="1.0.2"

0 comments on commit a3ffced

Please sign in to comment.