STM32 not running code when not connected to PC?

Hi

I want to drive an LCD (ST7920, SPI) with the blue pill, but it acts weird.

I am just running the graphicstest sketch of the u8g2 library, and it is working, but only when my board is connected to the PC via USB.
If I disconnect the board from the PC and using an external power supply, the stm32 wont do anything.
Any idea what causing this behaviour?

edit: So I checked once more, and it seems I was wrong.
After I program it, it works, but if I disconnect the power, the code wont run till reupload. The green led keeps flashing and nothing happens.

Check your power supply and cabling. Forgot a Gnd wire somewhere?

Have you got the boot jumpers in the correct place or using the pins there connected to for the display and forcing bootloader start?

Are you uploading sketch to RAM instead of flash so it wipes after power cycle?