Can't flash an STM32F3 chipwhisperer board

Hello,
I have a Chipwhisperer Lite, and I have two different boards the F4 and the F3. I pulled the last cw version from the Github repository, and installed it.
Now I tried to flash the F3 board, using a simple example of the tutorial the simpleserial-base.

When I execute this line:

cw.program_target(scope, cw.programmers.STM32FProgrammer, "../hardware/victims/firmware/simpleserial-base/simpleserial-base-CW308_STM32F3.hex", baud=9600)

I have the following error:

Detected known STMF32: STM32F302xB(C)/303xB(C)
Extended erase (0x44), this can take ten seconds or more
Attempting to program 8719 bytes at 0x8000000
STM32F Programming flash…


CmdException Traceback (most recent call last)
~/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py in writeMemory(self, addr, data, smallblocks)
695 try:
→ 696 self.cmdWriteMemory(addr, data[offs:offs + block_size])
697 except CmdException:

~/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py in cmdWriteMemory(self, addr, data)
438 assert (0 < len(data) <= 256)
→ 439 if self.cmdGeneric(0x31):
440 target_logger.debug("*** Write memory command")

~/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py in cmdGeneric(self, cmd)
364 self.sp.write(chr(cmd ^ 0xFF)) # Control byte
→ 365 return self._wait_for_ask(hex(cmd))
366

~/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py in _wait_for_ask(self, info)
331 # Unknown response
→ 332 raise CmdException("Unknown response. " + info + ": " + hex(ask))
333

CmdException: Unknown response. 0x31: 0x59

During handling of the above exception, another exception occurred:

IndexError Traceback (most recent call last)
~/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py in _wait_for_ask(self, info)
318 try:
→ 319 ask = self.sp.read(1)[0]
320 except:

IndexError: list index out of range

During handling of the above exception, another exception occurred:

CmdException Traceback (most recent call last)
/tmp/ipykernel_16451/3024290679.py in
----> 1 cw.program_target(scope, cw.programmers.STM32FProgrammer, “…/hardware/victims/firmware/simpleserial-base/simpleserial-base-CW308_STM32F3.hex”, baud=9600)

~/Documents/chipwhisperer-develop/software/chipwhisperer/init.py in program_target(scope, prog_type, fw_path, **kwargs)
127 prog.find()
128 prog.erase()
→ 129 prog.program(fw_path, memtype=“flash”, verify=True)
130 prog.close()
131 except:

~/Documents/chipwhisperer-develop/software/chipwhisperer/capture/api/programmers.py in func_wrapper(self, *args, **kwargs)
119 self.scope.io.nrst = ‘high_z’
120 try:
→ 121 val = func(self, *args, **kwargs)
122 finally:
123 target_logger.debug(‘Restoring pdic, pdid, and nrst pin configuration’)

~/Documents/chipwhisperer-develop/software/chipwhisperer/capture/api/programmers.py in program(self, filename, memtype, verify)
323 stm32f = self.stm32prog()
324 stm32f.scope = self.scope
→ 325 stm32f.program(filename, memtype, verify)
326
327 @save_and_restore_pins

~/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py in func_wrapper(self, *args, **kwargs)
36 def func_wrapper(self, *args, **kwargs):
37 try:
—> 38 return func(self, *args, **kwargs)
39 except:
40 self.close_port()

~/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py in program(self, filename, memtype, verify, logfunc, waitfunc)
208 logfunc(“STM32F Programming %s…” % memtype)
209 if waitfunc: waitfunc()
→ 210 self.writeMemory(startaddr, fdata) # , erasePage=True
211 #self.write_verify(startaddr, fdata)
212

~/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py in func_wrapper(self, *args, **kwargs)
36 def func_wrapper(self, *args, **kwargs):
37 try:
—> 38 return func(self, *args, **kwargs)
39 except:
40 self.close_port()

~/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py in writeMemory(self, addr, data, smallblocks)
699 block_size = 64
700 target_logger.debug(“Write with block size 256 failed, retrying with block size of 64”)
→ 701 self.cmdWriteMemory(addr, data[offs:offs + block_size])
702
703 if self.slow_speed:

~/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py in cmdWriteMemory(self, addr, data)
437 data += [0xff, 0xff, 0xff, 0xff][padding:]
438 assert (0 < len(data) <= 256)
→ 439 if self.cmdGeneric(0x31):
440 target_logger.debug("*** Write memory command")
441 self.sp.write(self._encode_addr(addr))

~/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py in cmdGeneric(self, cmd)
363 self.sp.write(chr(cmd))
364 self.sp.write(chr(cmd ^ 0xFF)) # Control byte
→ 365 return self._wait_for_ask(hex(cmd))
366
367 def cmdGet(self):

~/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py in _wait_for_ask(self, info)
319 ask = self.sp.read(1)[0]
320 except:
→ 321 raise CmdException(“Can’t read port or timeout (%s). Target didn’t respond when an ack was expected.” % traceback.format_exc())
322 else:
323 if ask == 0x79:

CmdException: Can’t read port or timeout (Traceback (most recent call last):
File “/home/sou/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py”, line 696, in writeMemory
self.cmdWriteMemory(addr, data[offs:offs + block_size])
File “/home/sou/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py”, line 439, in cmdWriteMemory
if self.cmdGeneric(0x31):
File “/home/sou/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py”, line 365, in cmdGeneric
return self._wait_for_ask(hex(cmd))
File “/home/sou/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py”, line 332, in _wait_for_ask
raise CmdException("Unknown response. " + info + ": " + hex(ask))
chipwhisperer.hardware.naeusb.programmer_stm32fserial.CmdException: Unknown response. 0x31: 0x59

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/sou/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py”, line 319, in _wait_for_ask
ask = self.sp.read(1)[0]
IndexError: list index out of range
). Target didn’t respond when an ack was expected.

I tried to change the baudrate, it did not help.
Any suggestions please?

Best,
Sou

Hi,

  1. Is this a new issue, or has programming the F3 never worked?
  2. Does the F4 still work, or do you get errors when programming that as well?
  3. Which baud rates have you tried?

Alex

Hi Alex,
The F3 has never worked for me, I even tried different f3 boards.
F4, and XMEGA both work.
I tried different baudrate starting from 9600. My chipwhisperer version is 5.6

Best,

Which higher baud rates have you tried? I’ve found that baud rates that are too slow also don’t work.

Another method you could try is the new JTAG/SWD programming support: Debugging with ChipWhisperer — ChipWhisperer 5.6.1 documentation

Alex

The maximum I used is 38400

Can you try the default of 115200 as well? Also, can you try running cw.target_logger.setLevel(cw.logging.DEBUG) before programming and sending me the output?

Hi Alex,
This is the output I had.

DEBUG:ChipWhisperer Target:Saving pdic, pdid, and nrst pin configuration
DEBUG:ChipWhisperer Target:Changing pdic, pdid, and nrst pin configuration
INFO:ChipWhisperer Target:Serial baud rate = 115200
DEBUG:ChipWhisperer Target:Restoring pdic, pdid, and nrst pin configuration
DEBUG:ChipWhisperer Target:Saving pdic, pdid, and nrst pin configuration
DEBUG:ChipWhisperer Target:Changing pdic, pdid, and nrst pin configuration
INFO:ChipWhisperer Target:Assuming appropriate BOOT pins set HIGH on STM32F Hardware now
INFO:ChipWhisperer Target:*** Get command
INFO:ChipWhisperer Target: Bootloader version: 0x31
INFO:ChipWhisperer Target: Available commands: 0x0, 0x1, 0x2, 0x11, 0x21, 0x31, 0x44, 0x63, 0x73, 0x82, 0x92
DEBUG:ChipWhisperer Target:*** GetID command
DEBUG:ChipWhisperer Target:Restoring pdic, pdid, and nrst pin configuration
DEBUG:ChipWhisperer Target:Saving pdic, pdid, and nrst pin configuration
DEBUG:ChipWhisperer Target:Changing pdic, pdid, and nrst pin configuration
INFO:ChipWhisperer Target:Erasing Chip
DEBUG:ChipWhisperer Target:Restoring pdic, pdid, and nrst pin configuration

Detected known STMF32: STM32F302xB(C)/303xB(C)


CmdException Traceback (most recent call last)
/tmp/ipykernel_19099/4243823925.py in
----> 1 cw.program_target(scope, cw.programmers.STM32FProgrammer, “…/hardware/victims/firmware/simpleserial-base/simpleserial-base-CW308_STM32F3.hex”)

~/Documents/chipwhisperer-develop/software/chipwhisperer/init.py in program_target(scope, prog_type, fw_path, **kwargs)
126 prog.open()
127 prog.find()
→ 128 prog.erase()
129 prog.program(fw_path, memtype=“flash”, verify=True)
130 prog.close()

~/Documents/chipwhisperer-develop/software/chipwhisperer/capture/api/programmers.py in func_wrapper(self, *args, **kwargs)
119 self.scope.io.nrst = ‘high_z’
120 try:
→ 121 val = func(self, *args, **kwargs)
122 finally:
123 target_logger.debug(‘Restoring pdic, pdid, and nrst pin configuration’)

~/Documents/chipwhisperer-develop/software/chipwhisperer/capture/api/programmers.py in erase(self)
335 self.log(“Erasing Chip”)
336 stm32f = self.stm32prog()
→ 337 stm32f.cmdEraseMemory()
338
339 @save_and_restore_pins

~/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py in cmdEraseMemory(self, sectors)
459 def cmdEraseMemory(self, sectors=None):
460 if self.extended_erase:
→ 461 return self.cmdExtendedEraseMemory()
462
463 if self.cmdGeneric(0x43):

~/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py in cmdExtendedEraseMemory(self)
481
482 def cmdExtendedEraseMemory(self):
→ 483 if self.cmdGeneric(0x44):
484 target_logger.debug("*** Extended Erase memory command")
485 # Global mass erase

~/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py in cmdGeneric(self, cmd)
363 self.sp.write(chr(cmd))
364 self.sp.write(chr(cmd ^ 0xFF)) # Control byte
→ 365 return self._wait_for_ask(hex(cmd))
366
367 def cmdGet(self):

~/Documents/chipwhisperer-develop/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py in _wait_for_ask(self, info)
330 else:
331 # Unknown response
→ 332 raise CmdException("Unknown response. " + info + ": " + hex(ask))
333
334 @close_on_fail

CmdException: Unknown response. 0x44: 0xff

Best,
Sou

Try modifying the timeout on line 487 of chipwhisperer/software/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py to be 1000000 instead of 30000

Alex

I still get the same issue :frowning:

I’m not too sure then, since everything should basically be the same between the F3 and F4. Maybe try shorting the SHUNTH and SHUNTL pins just to make sure the voltage isn’t dropping too low on the F3.

Alex