From 604bbdbd023336bef2af776a8cd98f529bec0704 Mon Sep 17 00:00:00 2001 From: Matthew Mets Date: Wed, 8 Mar 2023 17:28:58 +0100 Subject: [PATCH] Add Pico SDK to docker image, for building tp1 firmware --- contrib/Dockerfile | 11 +++++------ doc/toolchain_setup.md | 11 +++++++++++ hw/boards/tp1/firmware/README.md | 27 +++++++-------------------- hw/boards/tp1/firmware/build.sh | 4 ++++ 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/contrib/Dockerfile b/contrib/Dockerfile index e6d018d..dcd19ad 100644 --- a/contrib/Dockerfile +++ b/contrib/Dockerfile @@ -43,7 +43,7 @@ RUN apt-get -qq update -y \ cmake \ gcc-arm-none-eabi \ libnewlib-arm-none-eabi \ - libstdc++-arm-none-eabi-newlib + libstdc++-arm-none-eabi-newlib \ && rm -rf /var/lib/apt/lists/* @@ -59,7 +59,7 @@ WORKDIR / RUN rm -rf /src # Custom iceprog for the RPi 2040-based programmer (will be upstreamed). -RUN git clone -b raw_usb --depth=1 https://github.com/tillitis/icestorm /src +RUN git clone -b interfaces --depth=1 https://github.com/tillitis/icestorm /src WORKDIR /src/iceprog RUN make -j$(nproc --ignore=2) \ && make PROGRAM_PREFIX=tillitis- install @@ -89,10 +89,9 @@ RUN git >/usr/local/repo-commit-nextpnr describe --tags --always --dirty WORKDIR / RUN rm -rf /src -RUN git clone https://github.com/raspberrypi/pico-sdk.git /usr/local/picosdk -WORKDIR /usr/local/picosdk -RUN git checkout 1.5.0 \ - && git submodule-update --init +RUN git clone --branch 1.5.0 --depth 1 https://github.com/raspberrypi/pico-sdk.git /usr/local/pico-sdk +WORKDIR /usr/local/pico-sdk +RUN git submodule update --init RUN git >/usr/local/repo-commit-picosdk describe --tags --always --dirty WORKDIR / diff --git a/doc/toolchain_setup.md b/doc/toolchain_setup.md index 49a9c53..75971ae 100644 --- a/doc/toolchain_setup.md +++ b/doc/toolchain_setup.md @@ -165,6 +165,17 @@ The programmer will update its firmware with the file and restart itself. After reboot the storage device will automatically be disconnected. +The firmware requires the Raspberry Pi Pico SDK: + + cd ~ + git clone --branch 1.5.0 https://github.com/raspberrypi/pico-sdk.git + cd pico-sdk + git submodule update --init + +Note that the Docker image places the pico-sdk directory in +/usr/local. For normal development, it is usually left in the +users home directory. + ## CH552 USB to Serial firmware diff --git a/hw/boards/tp1/firmware/README.md b/hw/boards/tp1/firmware/README.md index 9c8e64b..838eeef 100644 --- a/hw/boards/tp1/firmware/README.md +++ b/hw/boards/tp1/firmware/README.md @@ -3,7 +3,7 @@ This firmware allows a Raspberry Pi Pico (or any RP2040) to work as a programmer for the lattice ice40 parts. It has been integrated into icestorm: -https://github.com/Blinkinlabs/icestorm/commits/interfaces +https://github.com/tillitis/icestorm/commits/interfaces Advantages: * Cheap: RPi Pico boards are currently EUR4, FT232H boards are closer to EUR15 @@ -150,7 +150,7 @@ Data packet format: -### Read ADCs xxx +### Read ADCs This command is used to read the analog value of analog input pins 0-2. Each value is returned as a uint32_t value representing the reading in microvolts. @@ -168,23 +168,10 @@ This command is used to put the device in bootloader mode. No data is sent durin ## Building the firmware -First, install the [Rasberry Pi Pico SDK](https://github.com/raspberrypi/pico-sdk.git): +First, follow the details in the toolchain setup document to install +the Raspberry Pi Pico SDK. Then, the firmware can be built by running +the build script: - sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib - cd ~ - git clone https://github.com/raspberrypi/pico-sdk.git - cd pico-sdk - git submodule update --init + ./build.sh -Then, clone and build this repository: - - cd ~ - git clone https://github.com/Blinkinlabs/ice40_flasher - cd ice40_flasher - export PICO_SDK_PATH=~/pico-sdk - mkdir build - cd build - cmake .. - make - -Finally, load the firmware onto the Pico using the instructions in the [usage](https://github.com/Blinkinlabs/ice40_flasher#usage) section. +Once complete, the output binary is located in build/main.uf2 diff --git a/hw/boards/tp1/firmware/build.sh b/hw/boards/tp1/firmware/build.sh index d23e145..3e8e5bf 100755 --- a/hw/boards/tp1/firmware/build.sh +++ b/hw/boards/tp1/firmware/build.sh @@ -1,7 +1,11 @@ #!/usr/bin/bash set -e +if [ -d "/usr/local/pico-sdk" ]; then +export PICO_SDK_PATH=/usr/local/pico-sdk +else export PICO_SDK_PATH=~/pico-sdk +fi BUILD_DIR=build