I have flashed a dfu bootloader from https://github.com/davidgfnet/stm32-dfu-bootloader onto a fresh stm32f103c8t6 and it was working fine. After I uploaded my binary with dfu-util the device would no longer show up in usb dmesg so it seems like the bootloader was erased, although the program (a simple blinker) always ran for a few seconds after powerup and then stopped.
The problem is that from now on if I connect the device via stlink it reports a correct size of sram but 0 bytes of flash. I tried flashing with st-flash --flash=64k write ... but it didn't work. Only other thing that comes to mind is to do some kind of a reset so I tried st-flash --flash=64k erase, it looked like it worked but the device still reports 0 bytes flash memory.
What could be the cause of this? Did the bootloader remove some stm firmware required for flashing the chip? How come only flash size is reported as 0 but not sram? Is there a way to reflash the required firmware or is it bricked? I'm lucky to have bought two but still I'd like to rescue the first one if possible.