Many MCUs have an undocumented (but published) bootloader activation – e.g., STM32: USART1 with 0x7F sync byte.
Sometimes software unlock tools fail. For hardware-level recoveries, consider these: writing flash programmer... fail unlock tool
Some unlock tools fail because the HSE (external crystal) is dead or misconfigured. The unlock programmer tries to initialize the PLL, hangs, and times out. Many MCUs have an undocumented (but published) bootloader
Fix: Force the debugger to use HSI (internal RC oscillator). Sometimes software unlock tools fail
If you have tried the above steps and the error persists: