View previous topic :: View next topic |
Author |
Message |
pa4wdh l33t
Joined: 16 Dec 2005 Posts: 877
|
Posted: Wed Aug 03, 2022 3:04 pm Post subject: Using the Raspberry Pi Pico in Gentoo |
|
|
Hi All,
I recently got myself a Raspberry Pi Pico and i found that there is no documentation on how to use the Pico with Gentoo yet so i decided to share my notes with you.
What is the Raspberry Pi Pico?
In short: It's a microcontroller. It can't run linux but you can program it with linux, and thus with Gentoo.
For more info see this page: https://www.raspberrypi.com/products/raspberry-pi-pico/
This writeup may work for other rp2040 based microcontrollers too, i have only tested with the Pi Pico.
Software Development Kit
The Pico can be programmed with C (other options are available) and if you like to do so there is an SDK available: https://github.com/raspberrypi/pico-sdk
To be able to use the SDK to compile programs you also need a toolchain, of course in Gentoo we have crossdev for that. The target you need is called "arm-none-eabi".
The best thing for now is to let crossdev make the necessary files but not let it compile (yet). You can do this with: crossdev -t arm-none-eabi --init-target
The reason not to let it compile just yet is because we need to change the use flags. On my system crossdev disabled the cxx flag but the SDK needs it.
Check /etc/portage/package.use/cross-arm-none-eabi. On my system the single line generated by crossdev contained cxx and -cxx, don't let it fool you .
To ease the installation of the SDK i made a little overlay which you can find here: https://code.pa4wdh.nl.eu.org/gentoo/rpi-pico/about
When you've installed the overlay you can emerge pico-sdk which will pull in the toolchain as dependencies.
The pico-sdk will be installed in /opt/pico-sdk-<version> and a symlink called /opt/pico-sdk and has a few useflags:
cyw43: Includes the cyw43 driver (required for the Pico W wireless hardware)
examples: Includes the examples under /opt/pico-sdk/examples
lwip: Includes the lwip IP Stack
tinyusb: Installs tinyusb USB Stack which you need when you want to use USB in your program
Your own project
Some documentation on starting your first project can be found here: https://github.com/raspberrypi/pico-sdk#quick-start-your-own-project
The SDK documentation can be found here: https://raspberrypi.github.io/pico-sdk-doxygen/
When compiling your own project you'll need to point it to the SDK location. You can either set PICO_SDK_PATH to /opt/pico-sdk or use
Code: | include(/opt/pico-sdk/pico_sdk_init.cmake) |
in your CMakeLists.txt.
Bootsel
When no program is loaded or you press the BOOTSEL button while plugging the pico into to the USB port will bring it into BOOTSEL mode. In this mode it behaves like a USB storage device. You can copy a UF2 file to the device and
it will reset on unmount and will start running your program.
I guess handling USB storage devices does not need any extra explanation these days. Be sure to have support for the vfat filesystem.
USB Serial output
By default the stdio of the program running on the pico goes to it's serial port located at pins 1 and 2. If you'd like to have the output over a USB serial connection there are a few things you should do.
First, emerge the SDK with the tinyusb useflag. Second, in the CMakeLists.txt of your project add:
Code: | pico_enable_stdio_usb(<project name> 1)
pico_enable_stdio_uart(<project name> 0)
|
Substitute <project name> for the name of your project and recompile.
The USB serial port will require the CONFIG_USB_ACM kernel driver on the host side.
Successful detection will look like this:
Code: | usb 1-1.3.2: new full-speed USB device number 7 using xhci_hcd
usb 1-1.3.2: New USB device found, idVendor=2e8a, idProduct=000a, bcdDevice= 1.00
usb 1-1.3.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.3.2: Product: Pico
usb 1-1.3.2: Manufacturer: Raspberry Pi
usb 1-1.3.2: SerialNumber: E6614C311B826523
cdc_acm 1-1.3.2:1.0: ttyACM0: USB ACM device
|
You can open the serial port with you favorite terminal emulator, in my case that's minicom: minicom -D /dev/ttyACM0
Other USB stuff
Thanks to the tinyusb stack the pico can be programmed to be a lot of different USB devices, including audio, network, hid and video devices. They usually require the class drivers in the kernel to work. _________________ The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world
My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54553 Location: 56N 3W
|
Posted: Wed Aug 03, 2022 5:53 pm Post subject: |
|
|
pa4wdh,
This would be better on the Wiki. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
pa4wdh l33t
Joined: 16 Dec 2005 Posts: 877
|
Posted: Thu Aug 04, 2022 3:47 pm Post subject: |
|
|
I agree.
So far I never actually contributed to the wiki, is there anything special i should do to get an account? _________________ The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world
My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54553 Location: 56N 3W
|
Posted: Thu Aug 04, 2022 4:07 pm Post subject: |
|
|
pa4wdh,
Just go the the Wiki and create an account.
You can develop pages in your namespace, so on you can make changes and move them to the main wiki later.
Other users can add to the talk pages in your namespace bu you have control over the developing page. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|