Lost Code After Taking Out Debugger Adapter from Board (STM32F767) - Page 1
Forum section: electronics / general

author: A.Ersoz
author_rank: Regular Contributor
timestamp: December 05, 2018, 09:10:59 pm
content: Hello,I observe my signal after loading to my custom board. When the circuit still has power and taking out the debugger adapter from the board, the code is lost. Interesting thing is that while I keep the debugger adapter connection between PC and board, I do power on and power off; then I can get same signal. Eventually, I lost my signal with disconnection of the debugger adapter. So why is that happen and how can I keep the code in the microprocessor?Thanks,

author: lty1993
author_rank: Unknown
timestamp: December 10, 2018, 10:59:11 am
content: Did you link your code with semihosting flag enabled?

author: A.Ersoz
author_rank: Regular Contributor
timestamp: December 10, 2018, 09:39:15 pm
content: Actually, I don't know the semihosting flag. Is It in options of target menu?

author: abraxa
author_rank: Frequent Contributor
timestamp: December 12, 2018, 09:49:40 pm
content: Maybe you're running your program from RAM instead of storing it in flash and executing it from there. You could check the options of the IDE you're using if there's an option you can set - and if there's none, check the linker file and see where the .text segment goes.

author: nick_d
author_rank: Regular Contributor
timestamp: December 13, 2018, 11:46:50 am
content: I have had the same problem. I believe it occurs because the JTAG or SWD is in the middle of shifting out a command when the connection is interrupted and a garbage command is received. How this manages to corrupt the Flash is a mystery (such JTAG commands are complex and must be sent in a certain sequence to work), but it does for me. I found that replacing the ribbon cable from debugger to target impacted the issue significantly, the one I was using was worn from thousands of insert/remove cycles and felt quite loose on the mini 10 pin header, so perhaps the order of breaking the connections (clock, data, GND etc) matters. Since I am lazy I did not want to power system up and down just to make it safe to remove debugger. So I found a workaround that if debugger is running when disconnected and not stopped at prompt it is OK. Your mileage may vary.cheers, Nick

author: ogden
author_rank: Super Contributor
timestamp: December 13, 2018, 12:16:22 pm
content: Quote from: A.Ersoz on December 05, 2018, 09:10:59 pmDid you try to put your code into flash instead of RAM? If you use flash, then code most likely is still there. Cause could be - debugger does proper reset but board itself w/o debugger does not. Startup code may fail for some reason which usually is - insufficient power rail voltage right after power on while startup code kicks in at full speed causing brownout. Check your reset circuit for errors. At the very beginning of init code *before* setting hi-speed clocks add ~0.1 sec delay and see - it helps or not.Try to power-on your board and after second or so - reset it. Does it run then?

author: ogden
author_rank: Super Contributor
timestamp: December 20, 2018, 01:24:15 pm
content: Did you resolve it? If yes then how? What was cause of the problem?

author: A.Ersoz
author_rank: Regular Contributor
timestamp: February 07, 2019, 04:16:37 pm
content: I found a solution with a power shut-down switch. In my previous case, I didn't use it, and I disconnect the power at power supply end. Now, I placed a shut-down switch (SPST DIP Switch) on the power line on my circuit board. When I am done, firstly, I switch off the power with this switch, then I close the power supply. With this way, I keep my codes.Thank you guys for your responds!