diff --git a/source/baremetal.rst b/source/baremetal.rst new file mode 100644 index 0000000..7a5143d --- /dev/null +++ b/source/baremetal.rst @@ -0,0 +1,47 @@ +BareMetal Application +===================== + +This example provides a minimal bare metal demo app that demonstrates how to easily create a bare metal C application +and load it/run it on the riscv soc from RaspberryPi `RP2350 `_. + +Here, we will focus on a printing simple string over serial console for simplicity and clarity. + +Setting up the environment +-------------------------- + +Please remember to set up pico-sdk and picotool alongwith and riscv toolchain first. +The sdk and tools for rp2350 are installed in ~/.pico-sdk/ with `VSCode Plugin `_. +It can also be installed with prebuilt binaries present at `pico-sdk-tools `_. +To use the tools and sdk installed to another location set the following : + +.. literalinclude:: scripts/baremetal.sh + :start-after: # set up env + :end-before: # /set up env + +Getting the sources +------------------- + +Clone the baremetal application repository. + +.. literalinclude:: scripts/baremetal.sh + :start-after: # clone + :end-before: # /clone + +Building the baremetal application +---------------------------------- + +Execute the below commands: + +.. literalinclude:: scripts/baremetal.sh + :start-after: # build + :end-before: # /build + +.. note:: The resulting binaries (``print.uf2``) will be written in the ``build`` folder. Transfer this binary file to the Pico board with a micro USB cable and holding down the BOOTSEL button. + +Running the baremetal application +--------------------------------- + +To run baremetal application, connect a bi-directional logic level converter set at 3.3V between development machine and Pico with TX, RX and GND. + +**RISC-V from RPI** should be seen on ttyUSB serial terminal. + diff --git a/source/index.rst b/source/index.rst index 020ef7a..0aee641 100644 --- a/source/index.rst +++ b/source/index.rst @@ -8,6 +8,12 @@ introduction +.. toctree:: + :caption: BareMetal + :maxdepth: 1 + + baremetal + .. toctree:: :caption: Zephyr :maxdepth: 2 diff --git a/source/scripts/baremetal.sh b/source/scripts/baremetal.sh new file mode 100644 index 0000000..1af3ba4 --- /dev/null +++ b/source/scripts/baremetal.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +set -e + +# get prerequisites +wget https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-2/pico-sdk-tools-2.0.0-x86_64-lin.tar.gz +wget https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-2/riscv-toolchain-14-x86_64-lin.tar.gz +wget https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-2/picotool-2.0.0-x86_64-lin.tar.gz +# /get prerequisites + +# set up env +export PICO_SDK_PATH=~/example_sdk/sdk/2.0.0/ +export PICO_TOOLCHAIN_PATH=~/example_sdk/toolchain/13_2_Rel1 +export picotool_DIR=~/example_sdk/picotool/2.0.0/picotool +# /set up env + +# clone +git clone https://github.com/disdi/bare-metal-riscv +cd bare-metal-riscv +# /clone + +# build +make PICO_BOARD=sparkfun_promicro_rp2350 PICO_SDK_PATH=~/.pico-sdk/ build +make flash +# /build + +