You may be wondering why you would want to do this, I looked into how to do this when the question was posted on a Discord community server. They had several Pico’s that they wanted to use with various demo files on and didn’t like the prospect of doing them one by one.
I did this from WSL on Windows, another Pi or Linux Distro should work fine also, although I haven’t tested it.
The first thing to do is to get all the bits installed.
apt-get install git
apt-get install gcc-arm-none-eabi libstdc++-arm-none-eabi-newlib libnewlib-arm-none-eabi
apt-get install build-essential
apt-get install cmake
apt-get install python3
Now clone micropython and update it with the mbedtl library
git clone https://github.com/micropython/micropython.git
git submodule update --init lib/mbedtl
Now enter the micropyton folder and make
make -C mpy-cross
Now copy your files (main.py, etc) from your PC to the following folder
make BOARD=PICO_W submodules
make BOARD=PICO_W clean
Once it’s completed building you should have
firmware.u2f file in the folder
ports/rp2/build-PICO depending on which your targets.
Now you can use the
firmware.u2f file as normal. Press the BOOTSEL button on the PICO W and drag the
firmware.u2f``` file over and it will flash as normal, reboot and you should see your code run.