Blink LED in C/C++ on the Raspberry Pi Pico [Linux SDK Setup]
HTML-код
- Опубликовано: 19 авг 2024
- In this video, I'll show you how to set up a build environment for your C/C++ RP2040 projects in Linux. Using CMake and Make, learn how to compile code and upload it to the RP2040 Raspberry Pi Pico. The Raspberry Pi Pico build environment that comes with the pi-pico-sdk makes developing and uploading files to the RP2040 extremely easy.
Today, we're going to talk about the RP2040 SDK, and how to setup and build programs for your RP2040. We'll write the blink LED example in C, and flash it to the RP2040.
Learn how to use the Raspberry Pi Pico SDK to create a custom build environment and do the Blink LED tutorial in C.
Buy the RP2040: amzn.to/3uISUGn
Join us on Discord!: / discord
I am more excited about a blinking light than I probably should be, thanks!
way more haha
this tutorial saved the one of the two brain cells i have left
Cool a very nice and concise guide to getting started with cmake and bcc. Appreciate your hard work.
Glad you liked it
@@LowLevelLearning How can we set this up for Mac M1? Any Advice?
@@XStance7 you can start with looking up for the equivalent brew packages
From where do you get this : set(PICO_EXAMPLES_PATH ${PROJECT_SOURCE_DIR}) ?
and you did not mention installing arm-none-eabi-gcc-cs-c++ ;)
good video relatively easy to follow and understand
Thank you, it was very explained!
Very well explained and pertinent
Great tutorial, clear and professional. Have you done anything with the little OLED displays SSD1306 - I've got a 128x32 and a 128x64 but the few examples I can find for the Pico are all C++ and I would really like to stick to C if possible.
I haven't, but I think theyre controlled over I2C. I plan to do SPI and I2C tutorials soon. Thanks for watching!
Thank you very much!
You're welcome!
First of all, thank you! Great explanation. But, what about Pico C LED blink bare-metal video, just like you did with Arduino? :)
Great suggestion!
awesome tutorial, thank
great tutorial!
Mr LLL, a little ARM ASSEMBLY example in the future ? Currently no videos on Pico just Rpi-board:
$ as
$ ls
$ gdb (or GDB server)
But those for OS-RPI
Thanks :)
Anytime :)
bro how to learn Raspberry Pi Pico programming (c/c++)
How I can mount the raspberry pi pico filesystem without unplug and plug into the USB Port (with holding the BOOTSEL button), like in your video?
i am looking for this too. have you been able to solve it?
What’s the IDE you’re using? Sublime?
Vim
"I'll put this link in the description." *doesn't*
What a chad.
A "little" more complicated... I decided to stick with Python on the Pi and C++ on the Arduino as a result of seeing that "little" extra complication.
it would be nice if you made this video few minutes longer and explain how you connected into the Raspberry Pico and how you connected Pico to the web etc. Otherwise great video.
pico cant connect to the web.What he didnt makeclear was that he was running the commands from either a linux pc or a rasberry pi4 etc.However i did manage to blink an LED from watching this so i think he did ok.
It will be helpful if you could explain connection of hardware
pico -> (usb mini) usb cable with standard usb 2 type A in pc/laptop/raspberrypi
I followed your youtube. I get an error "fatal error # include cstdlib no such file or directory" I have tried using the raspberry pi sdk instructions to run blink and get the same error. Where should I look for this file.
is there a tutorial for c++ and raspberry pi robotics? i really wanna learn
not sure if the software has changed over time but could you explain what you mean when you say to install cmake? anytime I try to put in "sudo snap install cmake" my chromebook just tells me "sudo: snap: command not found" (6:16 in the video)
You need to install cmake. Snap is the way he does that. There are others. For example I typed this command into my terminal(Msys2): pacman -S mingw-w64-x86_64-cmake
Ah that's because you don't have the `snap` installed.
If `cmake` is somewhere in your package repositories. With sudo priviledge, run the command for installing `cmake` using your GNU/Linux distro's package manager. For example `apt install cmake` (on Debian GNU/Linux and derivatives) or `pacman -S cmake` (for arch btw and derivatives).
My 'cmake ..' command did create a lot of things.....makefile not being one of them. Why do you think that is?
is the CMakeLists.txt exactly same as it is shown in the video?
Do you know of a good NRF2401 C ONLY driver and example for the Pico? I have seen C++ versions but really look for a pure C one with a good send/recv example.
Which Linux distro is he using for these tutorials? I’m at a loss.
distro does not matter. he is using ubuntu. it might look different because he is not using any "traditional" desktop environments. its all the same under the hood.
My CMakeList.txt looks nothing like yours when I downloaded the examples. Was this completely re-written by you? I am new to Cmake. Been using Arduino and venturing into Raspberry Pi Pico
I got to the 7:32 mark, the make moment, and the first line looks like in the video, but then after that about 200 errors. The first line says Assembler messages, then next line S89: Error unknown pseudo-op: '.syntax', and then about 199 more of the same. Any ideas? Thanks
Tried again from scratch this time on a newly fresh install of a raspberry pi 4. This time i got only about 70 errors. All goes fine until 93% progress, then it says pico_standard_link/new_delete.cpp.obj and then follow 70 errors of stuff not defined.
I have gone through this over and over what a nightmare. In the end the make fails. I deleted everything several time and went through again. everything works up until make. Then I get a whole bunch of errors when it hits elf2uf2
same, have you figured out how to solve this yet?
@UNOSEEMEk yes, I did but I can't remember what it was. The process for using C or C++ is a joke or at least was 9 months ago. I gave up and started using circuit python and micro python with thonny. It is much easier to get your code built and running on them with that.
arm-none-eabi-newlib
check if anything changes after installing this package.
I am new to code in C. I cannot run "sudo snap install cmake". How to install 'snap' first?
sudo apt install snapd
Its not a C thing. Its a ubuntu thing.
Thanks. Can you make a tutorial with window OS ♥
i think i bricked it :(
:-)
Mmmmm, tasty...
😋
Hi, I'm curious. I really want to know how your CMakeLists.txt is much different from the
one in the git repository. How did you came about to write this ??
Anyways, the one in the git repository didn't work for me but yours worked perfectly
and i made no modifications to my blink.c
I have actually looked up in the Raspberry Pi Pico C/C++ SDK pdf and didn't find any info on how
you set your CMakeLists.txt to be the way it is.
Eventually, i will be writing my own project and i will need to write my own CMakeLists.txt
to suit my codes.
Thanks a lot for your tutorial. It's my first time getting into c/c++ baremetal armeabi.. gcc stuff
and i wouldn't have been able to get this going without this tutorial
Some criticism:
1. Where's the C++ ? This is pure C.
2. Why instruct cmake (CMakeLists.txt) that your project uses C++ and ASM when in fact it only uses C? You don't need to set the C++ standard either if you don't use C.
3. Type safety! Why define GPIO_ON/GPIO_OFF as 1/0 instead of true/false? Match the API signature.
4. Let me post a C++ modification that also gets rid of using the preprocessor for the defines:
#include
namespace { //anonymous namespace, makes variables local to this translation unit. Same as defining them as static.
constexpr bool GPIO_ON = true;
constexpr bool GPIO_OFF = false;
constexpr unsigned int LED_PIN = 25;
}
int main() {
//blah
}
thanks!