Last active
May 10, 2022 20:11
-
-
Save ozgurgulsuna/7edcca71f41612145fcde83c4643bcc5 to your computer and use it in GitHub Desktop.
Raspberry Pi Pico C/C++ Programming on Manjaro/Arch Linux Setup and No-Boot-Button Guide
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Start with installing dependencies | |
# Manual insallation might be required for some refer to https://dev.to/nabbisen/installing-aur-packages-bdf | |
sudo pacman -Sy minicom openocd cmake arm-none-eabi-gcc arm-none-eabi-newlib gcc | |
# clone all the base repos in a dependency folder | |
git clone https://github.com/raspberrypi/pico-sdk.git | |
git clone https://github.com/raspberrypi/pico-examples.git | |
git clone https://github.com/raspberrypi/pico-extras.git | |
git clone https://github.com/raspberrypi/pico-playground.git | |
# Update these paths to match where you've checked out the repos | |
echo 'export PICO_SDK_PATH=/home/jamon/code/pico/pico-sdk' >> ~/.bashrc | |
echo 'export PICO_EXTRAS_PATH=/home/jamon/code/pico/pico-extras' >> ~/.bashrc | |
# read in the env variables we just set | |
source ~/.bashrc | |
# pull in the git submodule dependencies in the pico-sdk and pico-extras projects | |
cd pico-sdk | |
git submodule update --init | |
cd .. | |
cd ../pico-extras | |
git submodule update --init | |
cd .. | |
# clone/build picotool that enables the no-boot-button fix | |
git clone https://github.com/raspberrypi/picotool.git | |
cd picotool | |
mkdir build | |
cd build | |
cmake .. | |
make | |
# now we can run picotool using ./picotool in /picotool/build/ | |
# do not forget to create symbolic link | |
sudo ln -s ~/picotool/build/picotool /usr/local/bin/picotool | |
# Adding alias for ease of use | |
nano ~/.bashrc | |
# add followig | |
alias sudo='sudo ' | |
alias picotool='/..../picotool/build/picotool' | |
# source again | |
source ~/.bashrc | |
# example for how to build from command prompt: | |
cd pico_examples | |
mkdir build | |
cd build | |
cmake ../ -DCMAKE_BUILD_TYPE=Debug | |
cd blink | |
make -j4 # you can update this 4 to be how many CPU cores you want to build on | |
# IMPORTANT NOTE # | |
# It is needed to edit CMakeLists.txt in order to enable stdio_usb_init() function as explained below | |
# if (TARGET tinyusb_device) | |
# add_executable(hello_usb | |
# hello_usb.c | |
# ) | |
# | |
# # pull in common dependencies | |
# target_link_libraries(hello_usb pico_stdlib) | |
# | |
# # enable usb output, disable uart output | |
# pico_enable_stdio_usb(hello_usb 1) | |
# pico_enable_stdio_uart(hello_usb 0) | |
# | |
# # create map/bin/hex/uf2 file etc. | |
# pico_add_extra_outputs(hello_usb) | |
# | |
# # add url via pico_set_program_url | |
# example_auto_set_url(hello_usb) | |
# elseif(PICO_ON_DEVICE) | |
# message(WARNING "not building hello_usb because TinyUSB submodule is not initialized in the SDK") | |
# endif() | |
# As well as | |
# #include <stdio.h> // stdio library is needed for function below | |
# stdio_init_all(); // This function in the compiled C/C++ code enables stdio_usb_init() which is required in | |
# // no boot button fix | |
# After compilation of project there exist output file named PROJECT.uf2 inside build directory which is used with | |
# picotools to be initialized on the controller. | |
# [ozgur@ozgur blink]$ sudo picotool load -f blink.uf2 | |
# [sudo] password for ozgur: | |
# The device was asked to reboot into BOOTSEL mode so the command can be executed. | |
# | |
# Loading into Flash: [==============================] 100% | |
# | |
# The device was asked to reboot back into application mode. | |
# Important Links / Resources | |
# https://forums.raspberrypi.com/viewtopic.php?t=328795 | |
# https://github.com/raspberrypi/picotool | |
# https://forums.raspberrypi.com/viewtopic.php?t=327923 | |
# https://raspberrypi.github.io/pico-sdk-doxygen/group__pico__stdio__usb.html#gab87bcfa3f24e5a3fe92a944f9eecc460 | |
# https://www.reddit.com/r/raspberrypipico/comments/l5pc97/manjaroarch_cc_setup_guide/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment