How to lock STM32F0 using OpenOCD (readout protection)

openocd -f interface/stlink-v2.cfg -f target/stm32f0x.cfg -c "init" -c "halt" -c "stm32f1x lock 0" -c "reset halt" -c "exit"

This will activate flash readout protection level 1 which means you won’t be able to readout or re-write the flash. You can still perform a chip erase which will clear the readout protection – for example to flash a new firmware.