CTXz / stm32f1-picopwner

Dump read-out protected STM32F1's with a Pi Pico - A Pi Pico implementation of @JohannesObermaier's, Marc Schink's and Kosma Moczek's Glitch and FPB attack to bypass RDP (read-out protection) level 1 on STM32F1 chips
182 stars 25 forks source link

Bluepill STM32F103 - waiting for Pico... #12

Closed Aveneid closed 9 months ago

Aveneid commented 9 months ago

Hi, I tried to read read-protected Bluepill with Pico Pwner. I got all connections properly set and firmware prepared. After running script i only got this: img

Restaring Pico with RUN pin or reconnecting USB does not work.

I've checked common issues in readme but this one was not there.

Am I doing something wrong?

Images:

Bluepill: https://imgur.com/egfpyQL https://imgur.com/J13AtL2 https://imgur.com/KBCYHS4

Pi Pico: https://imgur.com/1HCmUFY https://imgur.com/vRPP7AO https://imgur.com/qiAk7io

Tried all versions with no luck.

CTXz commented 9 months ago

Hi,

Are you running this in a VM?

After plugging in your pico, can you confirm that /dev/ttyACM0 exists?

Could you post the last 50 or so lines of dmesg after plugging in the pi pico?

Thanks

Aveneid commented 9 months ago

Im running it on physical machine, after plugging Pico ACM0 exists but no communication between PC and board.

I tried to run it under WSL but i had issues with COM port forwarding from Windows 10 machine, maybe this was not the case?

dmesg log: https://pastebin.com/9h06Cxme

CTXz commented 9 months ago

Alright, I recommend you continue working on a native/hardware setup since I have not tested the script under WSL.

Could you run the following python script and post the output:

from serial import Serial

ser = Serial('/dev/ttyACM0', 9600, timeout=0.5)
print(ser)

I suspect that Serial() is throwing an exception related to the issue but it is simply interpreted as a unconnected device due to the rather lazy way the wait_serial_connect() function has been set-up.

Aveneid commented 9 months ago

I tried this script and got error Permission denied. Searched in Google about this error and found post on stackoverflow with solution as so:

https://stackoverflow.com/a/27886201/6369954

  1. Alter the permissions on /dev/ttyACM0 so that world has read and write priviliges (something you may not want to do) - although you may find they reset each time the device is plugged in eg:

sudo chmod 666 /dev/ttyACM0

Tried again with script as You wrote and it worked: https://pastebin.com/ZnusbymU

In my case issue is that /dev/ttyACM0 is set read-write for root user only, other user cannot interact with this device. Fix to this problem is to run script as root or change rules as mentioned in solution from link above.

After setting ACM0 to 666 I've managed to connect to Pico but stuck with Waiting for debug probe to be connected...

CTXz commented 9 months ago

An obvious question but have you connected the debug probe?

What's the output if you run the following command after your debug probe has been connected:

openocd -f interface/stlink.cfg -f target/stm32f1x.cfg

What's your openocd version (run openocd -v)?

Aveneid commented 9 months ago

OpenOCD is in version 0.11.0.

Output of openocd command: https://pastebin.com/ZZ6w1fp4

Am I missing configuration? Sorry if I'm asking dumb questions.

CTXz commented 9 months ago

What kind of debug probe are you using? Can you upload a picture of the probe attached to the bluepill?

Aveneid commented 9 months ago

I forgot about the STLink.. Sorry for bothering you. Now everything is working, need to adjust SRAM entry and should be good to go. Thanks for help!

PS. Im using STLink v2 clone like this one: https://allegro.pl/oferta/st-link-v2-stm32-stm8-stlink-programator-swd-swim-9157100329