pyocd / pyocd/pyOCD

[0.26.1] target kv11z75 FlashEraseFailure: erase_sector(0x400) error

Open
#874 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

flashing target
Dominant language
Python
Stars
1.5k
Forks
560
Avg merge
1h 41m
Merged PRs (30d)
3

Description

Reproduce steps

  • Flash a program(hello_world) to board hvpkv11z75m with GDB.
  • Reprogram any another application to board, the gdb server will raise error FlashEraseFailure: erase_sector(0x400) error: 105

gdb server:
pyocd gdbserver --trust-crc --port 3800 -u A020000028634e4500585002673a003fa101000097969900 -v -t kv11z7 -O connect_mode=under-reset -O allow_no_cores=True

Note

  • This issue happens very regularly in second flash programming.
  • Tested on 0.14, it works fine.
$ pyocd gdbserver --trust-crc --port 3800 -u A020000028634e4500585002673a003fa101000097969900 -v -t kv11z7 -O connect_mode=under-reset -O allow_no_cores=True

0001286:INFO:board:Target type is kv11z7
0001286:DEBUG:dap_access_cmsis_dap:CMSIS-DAP probe A020000028634e4500585002673a003fa101000097969900 firmware version: 1.0
0001302:DEBUG:sequencer:Running task load_svd
0001302:DEBUG:sequencer:Running task pre_connect
0001302:INFO:coresight_target:Asserting reset prior to connect
0001302:DEBUG:sequencer:Running task dp_init
0001302:DEBUG:sequencer:Running task connect
0001318:DEBUG:dap:Default wire protocol selected; using SWD
0001318:DEBUG:swj:Sending deprecated SWJ sequence to select SWD
0001334:INFO:dap:DP IDR = 0x0bc11477 (v1 MINDP rev0)
0001334:DEBUG:sequencer:Running task clear_sticky_err
0001334:DEBUG:sequencer:Running task power_up_debug
0001334:DEBUG:sequencer:Running task create_discoverer
0001334:DEBUG:sequencer:Running task discovery
0001334:DEBUG:sequencer:Running task find_aps
0001348:DEBUG:sequencer:Running task create_aps
0001348:DEBUG:sequencer:Running task create_ap.0
0001348:INFO:ap:AP#0 IDR = 0x04770031 (AHB-AP var3 rev0)
0001348:DEBUG:ap:AP#0 default HPROT=3 HNONSEC=0
0001348:DEBUG:ap:AP#0 implemented HPROT=3 HNONSEC=0
0001365:DEBUG:sequencer:Running task create_ap.1
0001365:INFO:ap:AP#1 IDR = 0x001c0020 (proprietary)
0001365:DEBUG:sequencer:Running task check_mdm_ap_idr
0001365:DEBUG:target_kinetis:MDM-AP version 2
0001365:DEBUG:sequencer:Running task check_flash_security
0001411:INFO:target_kinetis:KV11Z7 not in secure state
0001411:DEBUG:sequencer:Running task find_components
0001411:DEBUG:sequencer:Running task init_ap.0
0001427:INFO:rom_table:AP#0 Class 0x1 ROM table #0 @ 0xf0002000 (designer=00e part=000)
0001443:INFO:rom_table:[0]<f0000000:MTB-M0+ class=9 designer=43b part=932 devtype=31 archid=0a31 devid=0:0:0>
0001443:INFO:rom_table:[1]<f0001000:MTBDWT class=9 designer=00e part=000 devtype=04 archid=0000 devid=0:0:0>
0001459:INFO:rom_table:[2]<e00ff000:ROM class=1 designer=43b part=4c0>
0001459:INFO:rom_table:  AP#0 Class 0x1 ROM table #1 @ 0xe00ff000 (designer=43b part=4c0)
0001459:INFO:rom_table:  [0]<e000e000:SCS-M0+ class=14 designer=43b part=008>
0001473:INFO:rom_table:  [1]<e0001000:DWT-M0+ class=14 designer=43b part=00a>
0001473:INFO:rom_table:  [2]<e0002000:BPU class=14 designer=43b part=00b>
0001473:DEBUG:sequencer:Running task create_cores
0001473:DEBUG:discovery:Creating SCS-M0+ component
0001490:INFO:cortex_m:CPU core #0 is Cortex-M0+ r0p1
0001490:DEBUG:sequencer:Running task create_components
0001490:DEBUG:discovery:Creating DWT-M0+ component
0001490:INFO:dwt:2 hardware watchpoints
0001490:DEBUG:discovery:Creating BPU component
0001490:INFO:fpb:2 hardware breakpoints, 0 literal comparators
0001490:DEBUG:fpb:fpb has been disabled
0001490:DEBUG:sequencer:Running task check_for_cores
0001490:DEBUG:sequencer:Running task halt_on_connect
0001490:INFO:target_kinetis:Configuring MDM-AP to halt when coming out of reset
0001505:DEBUG:sequencer:Running task post_connect
0001505:INFO:target_kinetis:Deasserting reset post connect
0001505:DEBUG:sequencer:Running task post_connect_hook
0001505:DEBUG:sequencer:Running task create_flash
0001505:DEBUG:sequencer:Running task notify
0001521:DEBUG:cortex_m:Setting vector catch to 0x00000001
0001521:INFO:server:Semihost server started on port 4444 (core 0)
0001521:INFO:gdbserver:GDB server started on port 3800 (core 0)
0001521:DEBUG:cortex_m:halting core 0
0002036:DEBUG:packet_io:Starting GDB server packet I/O thread
0002036:INFO:gdbserver:One client connected!
0002051:DEBUG:gdbserver:GDB received query: ['Supported', 'multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+#df']
0002082:DEBUG:gdbserver:GDB general set: StartNoAckMode
0002114:DEBUG:gdbserver:GDB received query: ['Xfer', 'features', 'read', 'target.xml', '0,7fb#4a']
0002114:DEBUG:gdbserver:GDB query read_feature: offset: 0, size: 2043
0002128:DEBUG:gdbserver:GDB general set: NonStop:0
0002144:DEBUG:gdbserver:GDB received query: ['TStatus#49']
0002161:DEBUG:gdbserver:Current thread 0 is no longer valid, switching context to target
0002161:DEBUG:register:no accesses
0002161:DEBUG:register:out of date run token; invalidating cache
0002176:DEBUG:gdbserver:Tresponse=T0507:c00000c0;0d:682f0020;0e:c1130000;0f:68120000;thread:1;
0002192:DEBUG:gdbserver:GDB received query: ['Xfer', 'threads', 'read', '', '0,7fb#d0']
0002192:DEBUG:gdbserver:GDB query threads: offset: 0, size: 2043
0002207:DEBUG:gdbserver:GDB received query: ['Attached#8f']
0002239:DEBUG:gdbserver:GDB received query: ['Xfer', 'threads', 'read', '', '0,7fb#d0']
0002239:DEBUG:gdbserver:GDB query threads: offset: 0, size: 2043
0002253:DEBUG:gdbserver:GDB received query: ['Xfer', 'memory-map', 'read', '', '0,7fb#e9']
0002253:DEBUG:gdbserver:GDB query memory_map: offset: 0, size: 2043
0002269:DEBUG:memory:no reads
0002269:DEBUG:memory:out of date run token; invalidating cache
0002285:DEBUG:context_facade:GDB getting register context
0002301:DEBUG:context_facade:GDB reg: r0 = 0x4006B000
0002301:DEBUG:context_facade:GDB reg: r1 = 0x0
0002301:DEBUG:context_facade:GDB reg: r2 = 0x0
0002301:DEBUG:context_facade:GDB reg: r3 = 0x1660
0002301:DEBUG:context_facade:GDB reg: r4 = 0x4006B000
0002301:DEBUG:context_facade:GDB reg: r5 = 0x0
0002301:DEBUG:context_facade:GDB reg: r6 = 0x3EE
0002301:DEBUG:context_facade:GDB reg: r7 = 0xC00000C0
0002301:DEBUG:context_facade:GDB reg: r8 = 0xE87FF9FF
0002301:DEBUG:context_facade:GDB reg: r9 = 0x2000065C
0002301:DEBUG:context_facade:GDB reg: r10 = 0xFFEFFEFF
0002301:DEBUG:context_facade:GDB reg: r11 = 0x7FDC5F3E
0002301:DEBUG:context_facade:GDB reg: r12 = 0x1
0002301:DEBUG:context_facade:GDB reg: sp = 0x20002F68
0002301:DEBUG:context_facade:GDB reg: lr = 0x13C1
0002301:DEBUG:context_facade:GDB reg: pc = 0x1268
0002301:DEBUG:context_facade:GDB reg: msp = 0x20002F68
0002301:DEBUG:context_facade:GDB reg: psp = 0xEFDCFEDC
0002301:DEBUG:context_facade:GDB reg: primask = 0x0
0002301:DEBUG:context_facade:GDB reg: xpsr = 0x61000000
0002301:DEBUG:context_facade:GDB reg: control = 0x0
0002348:DEBUG:gdbserver:flash op: FlashErase
0002363:DEBUG:gdbserver:flash op: FlashWrite
0002363:DEBUG:gdbserver:flash write addr: 0x0
0002378:DEBUG:gdbserver:flash op: FlashWrite
0002378:DEBUG:gdbserver:flash write addr: 0x7e0
0002394:DEBUG:gdbserver:flash op: FlashWrite
0002394:DEBUG:gdbserver:flash write addr: 0xfa0
0002410:DEBUG:gdbserver:flash op: FlashDone#ea
0002410:DEBUG:cortex_m:halting core 0
0002410:DEBUG:cortex_m:set reset catch, core 0
0002410:DEBUG:cortex_m:halting core 0
0002410:DEBUG:cortex_m:reset, core 0, type=SW_SYSTEM
0002410:DEBUG:gdbserver:Received POST_RESET event
0002426:DEBUG:cortex_m:clear reset catch, core 0
0002473:DEBUG:cortex_m:resuming core 0
0002473:DEBUG:manager:added=[] removed=[]
0002473:DEBUG:manager:bps after flush={}
0002503:DEBUG:cortex_m:resuming core 0
0002503:DEBUG:manager:added=[] removed=[]
0002503:DEBUG:manager:bps after flush={}
0002519:DEBUG:builder:Analyze time: 0.031000
0002519:DEBUG:builder:Using double buffer sector erase program

[---|---|---|---|---|---|---|---|---|----]

[0002519:DEBUG:cortex_m:halting core 0
0002535:DEBUG:cortex_m:resuming core 0
0002535:DEBUG:manager:added=[] removed=[]
0002535:DEBUG:manager:bps after flush={}
0002551:DEBUG:cortex_m:resuming core 0
0002551:DEBUG:manager:added=[] removed=[]
0002551:DEBUG:manager:bps after flush={}
0002582:DEBUG:cortex_m:resuming core 0
0002582:DEBUG:manager:added=[] removed=[]
0002582:DEBUG:manager:bps after flush={}
0002597:ERROR:gdbserver:Unhandled exception in handle_message: erase_sector(0x400) error: 105
Traceback (most recent call last):
  File "c:\python27\lib\site-packages\pyocd\gdbserver\gdbserver.py", line 383, in handle_message
    reply = handler(msg[msgStart:])
  File "c:\python27\lib\site-packages\pyocd\gdbserver\gdbserver.py", line 602, in v_command
    return self.flash_op(data)
  File "c:\python27\lib\site-packages\pyocd\gdbserver\gdbserver.py", line 719, in flash_op
    self.flash_loader.commit()
  File "c:\python27\lib\site-packages\pyocd\flash\loader.py", line 168, in commit
    keep_unwritten=self._keep_unwritten)
  File "c:\python27\lib\site-packages\pyocd\flash\builder.py", line 470, in program
    flash_operation = self._sector_erase_program_double_buffer(progress_cb)
  File "c:\python27\lib\site-packages\pyocd\flash\builder.py", line 867, in _sector_erase_program_double_buffer
    self.flash.erase_sector(sector.addr)
  File "c:\python27\lib\site-packages\pyocd\flash\flash.py", line 353, in erase_sector
    raise FlashEraseFailure('erase_sector(0x%x) error: %i' % (address, result), address, result)
FlashEraseFailure: erase_sector(0x400) error: 105
0002628:INFO:gdbserver:Client detached
0002628:INFO:gdbserver:Client disconnected!
0002628:DEBUG:gdbserver:GDB server cleaning up
0002628:DEBUG:packet_io:GDB packet thread: other side closed connection
0002628:DEBUG:packet_io:GDB packet thread stopping
0003065:INFO:server:Semihost server stopped
0003081:DEBUG:session:uninit session <pyocd.core.session.Session object at 0x02749D50>
0003081:DEBUG:board:uninit board <pyocd.board.mbed_board.MbedBoard object at 0x036ABFD0>
0003081:DEBUG:cortex_m:resuming core 0
0003081:DEBUG:manager:added=[] removed=[]
0003081:DEBUG:manager:bps after flush={}
0003097:DEBUG:pywinusb_backend:closing interface

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the second-programming failure on the KV11Z7 with the documented pyocd gdbserver command. Start in pyocd/flash/builder.py at _sector_erase_program_double_buffer and follow flash/flash.py: erase_sector; the traceback also identifies gdbserver/gdbserver.py as the caller. Done means reprogramming a second application completes without the erase_sector(0x400) error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.