![deltocode](/img/default-banner.jpg)
- Видео 2
- Просмотров 7 506
deltocode
Добавлен 30 июн 2023
Never unplug your Raspberry Pi Pico again
NOTE: If you get "No accessible RP2040 devices in BOOTSEL mode were found." make sure that your program initializes the USB code via a call to "stdio_init_all()".
In this tutorial we explore how we can update the binary on our Pico without unplugging and re-plugging it all the time. No special equipment required!
Example CMakeLists.txt: gist.github.com/eldelto/0740e8f5259ab528702cef74fa96622e
Custom Makefile for even more automation: github.com/eldelto/project-ikaros/blob/main/Makefile#L60
In this tutorial we explore how we can update the binary on our Pico without unplugging and re-plugging it all the time. No special equipment required!
Example CMakeLists.txt: gist.github.com/eldelto/0740e8f5259ab528702cef74fa96622e
Custom Makefile for even more automation: github.com/eldelto/project-ikaros/blob/main/Makefile#L60
Просмотров: 1 679
Видео
Raspberry Pi Pico - C/C++ SDK Setup [macOS]
Просмотров 6 тыс.Год назад
In this tutorial I will show you how to setup your own project using the Raspberry Pi Pico C\C SDK. Leave your questions/feedback in the comments. Example CMake file: gist.github.com/eldelto/0740e8f5259ab528702cef74fa96622e
Hello, I got to 3:26 where you entered git submodule update --init, but got this message: fatal: not a git repository (or any of the parent directories): .git. What should I do? Great video though, you're a lifesaver for making this! 🔥
I'm starting to use the command line C compiler to develop software with R Pico. I use a Mac Silicon M1 and I followed all the steps in this video very carefully, after all it is very well prepared. I think I need to study more, however, I would like you to help me solve an error generated in the last step of the blink.c example (make command) (I use the basic Pico): .../build/_dps/picotool-src/errors/errors.cpp:1:10: Fatal Error 'cstdarg' file not found.
Hi, puh that's hard to say from a distance. Maybe you can give removing and reinstalling the cross-compilation toolchain a try. Some people reported that they had some different versions laying around from other projects that interfered. Also, removing the whole "build" directory again might resolve some transient errors. Hope that helps and good luck!
@@deltocode, many thanks. I have re-installed everything carefully and resulted in the same error (~pico/blink/build/_deps/picotool-src/errors/errors.cpp:1:10: fatal error: 'cstdarg' file not found) and I was tragic, I commented the #include <cstdarg> line and works fine. I do not know why this file was not found, since the file is on paths. Thanks for your attention. 1 | #include <cstdarg>
got trouble after vim the script :/
Thanks for the video! I just have one question I’m trying to view the debugger in my blink.c file but it is not showing any of my prinf(), got any ideas?
Thanks a lot man! I was going insane with other tutorials and documentation
Glad it helped!
Very detailed explanation, thanks a lot.❤
Worked perfect!
Hi thank you for your tutorial! I am a newbie. I get an error while "make". arm-none-eabi-gcc: fatal error: cannot read spec file 'nosys.specs': No such file or directory. Can you help me?
make[2]: *** [pico-sdk/src/rp2_common/boot_stage2/bs2_default.elf] Error 1 make[1]: *** [pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/all] Error 2 make: *** [all] Error 2
@@aviationodyssey1892 Hello! There is another user that ran into a similar problem. Silasstokes then pointed out how to resolve the issue. I'll just quote them here: I had this issue and it was because I had installed gcc from a brew tap while following instructions from another tutorial. In my case I just removed that package e.g `brew uninstall arm-none-eabi-gcc`, then I had to untap the cask `brew untap armmbed/formulae` and finally reinstall with the command from this tut: `brew install gcc-arm-embedded`, then I was able to run make without any issue. If that solves it for you, give their comment a like :)
If only this actually worked :( EDIT: it randomly started working a while after i applied the changes you suggested? wtf lol
Does it now reliably work for you? Apparently some people run into problems and I would like to figure out the root cause.
It seems to work reliably? Although if I don't have an infinite loop in my main function (i.e. if main exits), then it does not work.@@eldelto
Yeah I think that is unavoidable. As long as some program is running, the usb code should be able to do its job and respond to the picotool commands though. Thanks for pointing that out!
I got the same error, "No accessible RP2040 devices in BOOTSEL mode were found" and since other people with the problem didn't answer, I'll mention that I did add "pico_enable_stdio_usb(blink 1)" in ../CMakeLists.txt, reran "cmake ..", changed ../blink.c to make sure it re-compiled, ran make, got a bigger executable (about 17k instead of 16k; note: I also see pico_stdio_usb in the .map file), manually copied it to the pico first (in BOOTSEL mode using Finder), it was flashing in a new pattern so I knew it had the new executable running. Then I tried "picotool load -f blink.uf2" (with the path of my compiled picotool of course) but got that error. Then if I put it into BOOTSEL mode (holding down the button while unplugging / re-plugging the USB cable) I can run any of the picotool commands (picotool info, picotool load -f, picotool reboot). After reboot I can no longer run any of them without getting that error.
Hello, that still sounds like the binary doesn't include the usb lib stack, even though from your description everything sounds correct. Did you already try cleaning out the build/ directory and running the cmake step again? If that doesn't work out would you like to share your project? I would love to figure out what the culprit is. Also maybe checkout www.eldelto.net/articles/raspberry-pi-pico-no-hands-flashing which is the writeup of this whole procedure. It also links to an example CMake file and to another project where I use this hack. Hope any of can be of help.
@@deltocodemy replies keep disappearing. Not sure if they’re in an approval queue or something. I’ll try describing the location without a link: I put my source, and cmake related files on GitHub. My username is the same as on RUclips, and the project name should be obvious, pico-blink
@@drivers99 I checked it out today and it looks like you're missing a call to stdio_init_all() at the beginning of your main function. I only own the Pico board with the WIfi chip and there it was already present in the blink example. Didn't realize it wasn't present in the example of the regular board. I hope that solves it now! :)
@@deltocode woohoo! That's what it was! Thank you. That was above and beyond.
I’ll have to give this a shot. I wonder why the pdf of Getting Started with Raspberry Pi Pico has different dependencies (in section 9.1) but they don’t work for me (I was getting errors in vscode, and the compiler they said to choose wasn't listed) so I’ll try your way. I also ran into an error at one point following your tutorial because brew install gcc-arm-embedded had not actually succeeded (and I ignored it at first), because there was another binary already at /opt/homebrew/bin/arm-none-eabi-as (and all the other arm-... executables there). I saw it was symlinked to ../Cellar/arm-none-eabi-binutils/... so I did: brew uninstall arm-none-eabi-binutils and then I could do: brew install gcc-arm-embedded After that, make worked! Edit: Everything worked! We have blink.
Thanks for sharing the problems you ran into! I'm glad you got it to work :)
Thank you so much.
Glad it was helpful!
Thank you so much.
Thanks for these tutorials. I found them incredibly helpful. Hopefully you have more down the pipeline!
Glad you liked them! I'll hope to get around doing videos more regularly in the new year. But there will be more for sure :)
Does this work for Macs with the M1 chip?
Hi, yes this works both with Intel and Apple Silicone chips. Have fun programming!
Hi, thanks for the video. I have the same problem than some other people in the comments. I've added adding pico_enable_stdio_usb(main 1) line in the cmakefile but when i run the picotool load command i get this error: No accessible RP2040 devices in BOOTSEL mode were found. If you can help me figure out what is the issue it would be very helpfull. The only difference I had with your video is this warning when running the "make" command in the picotool build folder : make [ 25%] Building CXX object CMakeFiles/picotool.dir/main.cpp.o /home/paulf/Documents/picotool/main.cpp: In member function ‘virtual void file_memory_access::read(uint32_t, uint8_t*, uint32_t, bool)’: /home/paulf/Documents/picotool/main.cpp:869:22: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 869 | fread(buffer, this_size, 1, file); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ 50%] Building CXX object CMakeFiles/picotool.dir/picoboot_connection/picoboot_connection_cxx.cpp.o [ 75%] Building C object CMakeFiles/picotool.dir/picoboot_connection/picoboot_connection.c.o [100%] Linking CXX executable picotool [100%] Built target picotool
You'' need to run 'brew install pkgconfig' - after your prior tutorial, as it's required for this one (otherwise you'll get some libusb not found error)
Excellent catch, thanks for sharing!
Thank you! I ran into that exact problem.
Hello! thanks for this amazing tutorial, however i got stuck on the cmake part, i'm getting this masage " CMake Error at pico_sdk_import.cmake:68 (message): Directory '/Users/janvierkaliza' does not appear to contain the Raspberry Pi Pico SDK Call Stack (most recent call first): CMakeLists.txt:3 (include)" is there a way to fix this, thanks
Thanks for the nice words :) It looks like your PICO_SDK_PATH environment variable doesn't point the the actual pico-sdk folder. It should look something like this (depending where the sdk is located on your system of course): export PICO_SDK_PATH=/Users/eldelto/pico/pico-sdk/ I hope this can resolve your issue.
Amazing tutorial mate, I look forward to seeing more of your tutorials. I'd love to see one on how you set up your terminal with the colours and suggestions!
Thanks a lot! Well, the shell is almost 100% vanilla fish shell (fishshell.com). I believe I only updated the prompt coloring (gist.github.com/eldelto/709af84dc77049f11e6192badcaa0e9c), completions come out of the box :)
I guess usb stack on pico is very heavy and not always suitable for some projects.
Absolutely! But I think it is a neat trick when not pushing the code size limits :)
hi thank you for this video, however at 9:51 when you use make i have an error :arm-none-eabi-gcc: fatal error: cannot read spec file 'nosys.specs': No such file or directory Do you know why? need help ^^
Hello, you can try running "arm-none-eabi-gcc --version" to see if the cross-compiler has been installed. If that works give deleting the whole build directory a try. I also encountered this issue once and that fixed it for me. Let me know if that solves the issue :)
I had this issue and it was because I had installed gcc from a brew tap while following instructions from another tutorial. In my case I just removed that package e.g `brew uninstall arm-none-eabi-gcc`, then I had to untap the cask `brew untap armmbed/formulae` and finally reinstall with the command from this tut: `brew install gcc-arm-embedded`, then I was able to run make without any issue.
@@Silasstokes thanks for sharing how you solved it!
When running the "../../pico/picotool/build/picotool load -f blink.uf2" command i get this: No accessible RP2040 devices in BOOTSEL mode were found. It is like the -f doesn't work. I checked the picotool github page but i got nothing. Even when i do it while in bootsel mode it doesnt even upload the uf2 file.
Hello! Did you manually flash your board with a program that has stdio via USB enabled (adding pico_enable_stdio_usb(blink 1) in your CMakeLists.txt) before using the picotool command?
@@deltocode Yes i did. This is the CMakeLists.txt file in the my-project directory: cmake_minimum_required(VERSION 3.13) include(pico_sdk_import.cmake) project(test_project C CXX ASM) set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 17) pico_sdk_init() add_executable(blink blink.c ) target_include_directories(blink PRIVATE ${CMAKE_CURRENT_LIST_DIR} ) # Uncomment if you want to flash your board via picotool. pico_enable_stdio_usb(blink 1) pico_add_extra_outputs(blink) target_link_libraries(blink pico_stdlib # Uncomment when using Pico W # pico_cyw43_arch_none ) target_link_libraries(pico_stdlib) And i am using the non-wifi chip
Hey boss what is those two "||" looking things u typoed in when making the pico folder. What do I type for that?
Hello! Not 100% sure what you mean. Creating the directory is done by executing "mkdir pico". Otherwise this guide also exists as a written version, maybe that clears it up: www.eldelto.net/articles/raspberry-pi-pico-setup-for-macos Cheers!
I had an error when i wrote the make command. I didn't get the same messages that you got. Can you help me? % make [ 1%] Building ASM object pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.obj [ 2%] Linking ASM executable bs2_default.elf arm-none-eabi-gcc: fatal error: cannot read spec file 'nosys.specs': No such file or directory compilation terminated. make[2]: *** [pico-sdk/src/rp2_common/boot_stage2/bs2_default.elf] Error 1 make[1]: *** [pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/all] Error 2 make: *** [all] Error 2
Can you run 'arm-none-eabi-gcc --version' in a terminal and verify that the arm-gcc cross-compiler is installed? Sometimes it also helps to remove the whole 'build' directory and regenerate it if it is just a transitive error. Feel free to reach out if the error persists.
@@deltocode I ended up reinstalling everything but it ended up working fine so thank you cool video
@@gurk_studios glad you got it to work!
Performed same steps but got "No accessible RP2040 devices in BOOTSEL mode were found.". What might be wrong?
At the very end when trying to flash via picotool? Maybe try manually flashing a program with pico_enable_stdio_usb in the Makefile.
Your videos are criminally underrated. Such good quality tutorials should have thousands (or even hundreds of thousands) of views. Please continue doing what you're doing! Edit: Subscribed, liked and "belled"
Thanks for the lovely praise :)
Could you also make a tutorial on how to setup debugging env?
Yeah, I can give it a look.
This is amazing tutorial. Thanks a lot!
Thanks for the kind words :)
You saved my life. Thank you!
That's amazing to hear! Glad it helped :)
Thanks for this info ! Great tutorial
Glad you liked it :)