Cornell University ECE4760
Programming the chip from VSCode

Pi Pico RP2040

You can always put the rp2040 into program-load mode by cycling the power while holding down the program button.
This gets tedious, is hard on connectors, and when you build the Pico into a device may not even be possible.
After you have set up VScode according to Hunter's directions, there are at least two ways to program the chip:

  1. The first is an easy fix for cycling the power which requires minimal software and hardware additions.
    After you do this, you can compile in VScode, double-click the program button you will install, then click
    run in VScode to download the prodgram.
    See also the Runtime Infrastructure section of the SDK docs.

    Software:
    Add the line:
    pico_bootsel_via_double_reset
    to the target_link_libraries list in every cmakelists.txt file
    That's all!

    Hardware:
    Refer to the Pi Pico pinout diagram and identify pin 30, the RUN signal. Note that pin 28 is ground.
    The button you will add shorts the RUN pin to ground when you push it. The official Pi page uses more
    wires and a bigger button.
    -- Straighten the leads on the switch using small pliers so that they make better contact
    in the solderless board and to make the lead spacing closer to 0.2 inch (2 rows apart on board).

    -- Connect button leads to pins 28 and 30. (click image to expand).
    I find it easier to hold the button with pliers when pushing it into the solderless board.

    Using the button:
    -- Use power cycling programming once to insert the new loader code you just added to cmakelist.txt
    -- Push the button once to reset the program to re-start.
    --Push the button twice, quickly (within 0.5 second), to enter program mode, then click run in VScode.
    No more power cycling or unplugging!

  2. The second method uses openOCD (which should have been intalled during the VScode download) to push
    the elf file through the debug port. You do not have to touch the Pico, or push any buttons!
    The debug probe must be connected!  Bruce has tested this only on a Windows machine.
    You should be able to program by
    You can find out more about openOCD here.

Copyright Cornell University February 1, 2025