Close

[C] Using picotool to extract an RP2040 backup

A project log for WK-50 Trackball Keyboard

Reverse-engineering a bat-shaped, hot-swappable keyboard with a 38mm trackball and RGB-backlit encoder.

kelvinakelvinA 08/24/2024 at 14:330 Comments
It seemed simple enough.

It took 3 entire hours. I'll just mention the shownotes.

Cloned pico-sdk and then ran:

git submodule update --init lib/mbedtls

I reinstalled MSYS2 so that I had the latest version. Only after did I look on how to update it, and for some reason, pacman wasn't found:

The solution was to add
C:\msys64\usr\bin

to the PATH variable in "Environment Variables". Additionally, I made a new variable for the pico-sdk:

PICO_SDK_PATH: C:\mcu\pico-sdk

Pacman is needed, as seen in the installation commands in the readme:

pacman -S $MINGW_PACKAGE_PREFIX-{toolchain,cmake,libusb}
mkdir build
cd build
MSYS2_ARG_CONV_EXCL=- cmake .. -G"MSYS Makefiles" -DCMAKE_INSTALL_PREFIX=$MINGW_PREFIX
make
make install DESTDIR=/  # optional

Well that was all fine until I got to the 4th line when it said that it couldn't find CMakeLists.txt.

I looked around and discovered a picotool package for MSYS2 and decided to try it. I didn't need to clone the picotool repo because I could use the exe from the package instead.

Tried to see if I got a connection to the WK50 in BOOT and got this error about "appears to be a RP2040 device in BOOTSEL mode" and a suggestion for Zadig

So I downloaded that and I indeed didn't have a driver:

I then used 

picotool save wk50.uf2 -all

because I tried the default but picotool couldn't determine the size of the binary. I got precisely a 4MB file, which was slightly unexpected. I looked it up and found the reason:

I saved again as a .bin and I got a 2MB file. Hopefully this is what I need if I need to restore from backup.

Discussions