Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 8 months ago.
flash.flashBinary fails for KL05Z
I'm trying to flash a binary via pyOCD, which fails:
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-7-e024a89cc49b> in <module>() ----> 1 flash.flashBinary('/Users/farcaller/Downloads/frdm_tsi_slider_KL05Z.bin') /Users/farcaller/temp/pyOCD/pyOCD/flash/flash.pyc in flashBinary(self, path_file) 118 nb_bytes += len(bytes_read) 119 # page download --> 120 self.programPage(flashPtr, bytes_read) 121 """ 122 i = 0 /Users/farcaller/temp/pyOCD/pyOCD/flash/flash.pyc in programPage(self, flashPtr, bytes) 83 84 # first transfer in RAM ---> 85 self.target.writeBlockMemoryUnaligned8(self.begin_data, bytes) 86 87 # update core register to execute the program_page subroutine /Users/farcaller/temp/pyOCD/pyOCD/target/cortex_m.pyc in writeBlockMemoryUnaligned8(self, addr, data) 485 logging.debug("write blocks aligned at 0x%X, size: 0x%X", addr, (size/4)*4) 486 data32 = byte2word(data[idx:idx + (size & ~0x03)]) --> 487 self.writeBlockMemoryAligned32(addr, data32) 488 addr += size & ~0x03 489 idx += size & ~0x03 /Users/farcaller/temp/pyOCD/pyOCD/target/cortex_m.pyc in writeBlockMemoryAligned32(self, addr, data) 517 if size*4 < n: 518 n = (size*4) & 0xfffffffc --> 519 self.transport.writeBlock32(addr, data[:n/4]) 520 data = data[n/4:] 521 size -= n/4 /Users/farcaller/temp/pyOCD/pyOCD/transport/cmsis_dap.pyc in writeBlock32(self, addr, data) 156 self.writeAP(AP_REG['CSW'], CSW_VALUE | CSW_SIZE32) 157 self.writeAP(AP_REG['TAR'], addr) --> 158 dapTransferBlock(self.interface, len(data), WRITE | AP_ACC | AP_REG['DRW'], data) 159 return 160 /Users/farcaller/temp/pyOCD/pyOCD/transport/cmsis_dap_core.pyc in dapTransferBlock(interface, count, request, data, dap_index) 235 tmp = interface.read() 236 if tmp[0] != COMMAND_ID['DAP_TRANSFER_BLOCK'] or tmp[3] != 0x01: --> 237 raise ValueError('DAP_TRANSFER_BLOCK response error') 238 size_transfer = tmp[1] | (tmp[2] << 8) 239 resp.extend(tmp[4:4+size_transfer*4]) ValueError: DAP_TRANSFER_BLOCK response error
The whole I/O dump: https://gist.github.com/farcaller/913745e7695ee9b04512
After this I cannot upload apps via "usb flash" interface as well, the only way to "unbrick" the board is to reflash it to original bootcode and then flash mbed bootcode back.
Any hints?
Hello Vladimir,
how can I replicate this on my KL05Z? Do you use gdb or just a script like provided examples? Can you sahre with me, I can look at it..
Regards,
posted by Martin Kojtal 01 Apr 20140xc0170
Not using gdb, just the python console:
where frdm_tsi_slider_KL05Z.bin is generated from the mbed example code for slider.
I hacked up my ctypes wrapper around IOKit for hid, but exactly the same problem happens on linux with libusb (also, my wrapper works well with lpc1768, so it souldn't be an issue).
posted by Vladimir Pouzanov 01 Apr 2014