Unable to flash py32f002b
I accidentally erased the entire flash on my microcontroller, wiping out the bootloader. While i can use SWD, i can't actually seem to flash anything as things keep hardfaulting.
When i use pyocd, i get the following error:
0000554 E IPSR should be 0 but is 0x3 [flash]
0000554 E Stack pointer should be 0x20000940 but is 0x20000910 [flash]
0000554 E PC should be 0x20000a4c but is 0xfffffffe [flash]
When i use J-Link, i get this:
'loadfile': Performing implicit reset & halt of MCU.
Reset type: NORMAL (https://wiki.segger.com/J-Link_Reset_Strategies)
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.
Downloading file [full.bin]...
****** Error: PC of target system has unexpected value after erasing sectors. (PC = 0xFFFFFFFE)!
---------------------------------------------------------------------- Registers -------------------------------------------------------------------------------------
PC = FFFFFFFE
Current: R0 = 08000000, R1 = 40022000, R2 = 000000FF, R3 = 00000001
R4 = 00000800, R5 = 01000000, R6 = 200003A0, R7 = 000FF420
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Failed to erase sectors.
Unspecified error -1
J-Link>
Any ideas on how one could flash a board that has no firmware or bootloader like this?
Oddly, i also don't seem to be able to read from flash either, though is that just because its already erased?
pyocd> read32 0x08000000
Transfer failed: Memory transfer fault (Unspecified error.) @ 0x08000000-0x08000003
Whether all other pins are disconnected and the SWD port is not connected to other peripherals? A successful SWD connection means the interface itself is working, the failure was likely due to interference during the command communication.
It's really odd since I can do literally anything else, just not read or write to flash, and I'm not sure what would cause that.
Can you read its option bytes? It is in sector 6 address from 0x1FFF 0080 - 0x1FFF 00FF
Yeah, I can read the option bytes, and with much effort I can write them
What is the value of Flash WRP (address: 0x1FFF 008C)? how do they compare to the default values (should be 0xFFC0 003F?) in the manual?