Hi Pawel,
Could I check what actual hardware you have?
Also - depending on your hardware, are you ONLY cycling the target power, not the power to the BDM. With some hardware this is difficult to do especially if the BDM in integrated into a board with the target hardware.
You should also make sure that the delay after removing the power is sufficient for the target Vdd to drop to a very low level to ensure a power-on-reset of the target. With some low-power devices this can be quite a while.
Note: you would also get a similar error if there is anything incorrect about the connection between the BDM and target. You could check this. In particular check that the BKGD pin has initial activity when trying to connect and then is held low when the power-cycle dialogue appears.
Finally, you could try an external BDM such as P&E multilink or USBDM.
bye