Error in cw.program_target(scope, cw.programmers.STM32FProgrammer,

Using
%%bash
cd …/hardware/victims/firmware/simpleserial-base/
make PLATFORM=CWNANO CRYPTO_TARGET=NONE
I have created files

SS_VER set to SS_VER_1_1
make clean_objs .dep
make[1]: Entering directory ‘/home/vagrant/work/projects/chipwhisperer/hardware/victims/firmware/simpleserial-base’
SS_VER set to SS_VER_1_1
rm -f – simpleserial-base-CWNANO.hex
rm -f – simpleserial-base-CWNANO.eep
rm -f – simpleserial-base-CWNANO.cof
rm -f – simpleserial-base-CWNANO.elf
rm -f – simpleserial-base-CWNANO.map
rm -f – simpleserial-base-CWNANO.sym
rm -f – simpleserial-base-CWNANO.lss
rm -f – objdir-CWNANO/.o
rm -f – objdir-CWNANO/
.lst
rm -f – simpleserial-base.s simpleserial.s stm32f0_hal_nano.s stm32f0_hal_lowlevel.s
rm -f – simpleserial-base.d simpleserial.d stm32f0_hal_nano.d stm32f0_hal_lowlevel.d
rm -f – simpleserial-base.i simpleserial.i stm32f0_hal_nano.i stm32f0_hal_lowlevel.i
make[1]: ‘.dep’ is up to date.
make[1]: Leaving directory ‘/home/vagrant/work/projects/chipwhisperer/hardware/victims/firmware/simpleserial-base’
make begin gccversion build sizeafter fastnote end
make[1]: Entering directory ‘/home/vagrant/work/projects/chipwhisperer/hardware/victims/firmware/simpleserial-base’
SS_VER set to SS_VER_1_1
.
Welcome to another exciting ChipWhisperer target build!!
arm-none-eabi-gcc (15:8-2019-q3-1+b1) 8.3.1 20190703 (release) [gcc-8-branch revision 273027]
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

.
Compiling C: simpleserial-base.c
arm-none-eabi-gcc -c -mcpu=cortex-m0 -I. -mthumb -mfloat-abi=soft -ffunction-sections -gdwarf-2 -DSS_VER=SS_VER_1_1 -DSTM32F030x6 -DSTM32F0 -DSTM32 -DDEBUG -DHAL_TYPE=HAL_stm32f0_nano -DPLATFORM=CWNANO -DF_CPU=7372800UL -DSS_VER_2_0=2 -DSS_VER_2_1=3 -DSS_VER_1_1=1 -DSS_VER_1_0=0 -Os -funsigned-char -funsigned-bitfields -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=objdir-CWNANO/simpleserial-base.lst -I…/./simpleserial/ -I…/./hal -I…/./hal/stm32f0 -I…/./hal/stm32f0/CMSIS -I…/./hal/stm32f0/CMSIS/core -I…/./hal/stm32f0/CMSIS/device -I…/./hal/stm32f0/Legacy -I…/./crypto/ -std=gnu99 -MMD -MP -MF .dep/simpleserial-base.o.d simpleserial-base.c -o objdir-CWNANO/simpleserial-base.o
.
Compiling C: …/./simpleserial/simpleserial.c
arm-none-eabi-gcc -c -mcpu=cortex-m0 -I. -mthumb -mfloat-abi=soft -ffunction-sections -gdwarf-2 -DSS_VER=SS_VER_1_1 -DSTM32F030x6 -DSTM32F0 -DSTM32 -DDEBUG -DHAL_TYPE=HAL_stm32f0_nano -DPLATFORM=CWNANO -DF_CPU=7372800UL -DSS_VER_2_0=2 -DSS_VER_2_1=3 -DSS_VER_1_1=1 -DSS_VER_1_0=0 -Os -funsigned-char -funsigned-bitfields -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=objdir-CWNANO/simpleserial.lst -I…/./simpleserial/ -I…/./hal -I…/./hal/stm32f0 -I…/./hal/stm32f0/CMSIS -I…/./hal/stm32f0/CMSIS/core -I…/./hal/stm32f0/CMSIS/device -I…/./hal/stm32f0/Legacy -I…/./crypto/ -std=gnu99 -MMD -MP -MF .dep/simpleserial.o.d …/./simpleserial/simpleserial.c -o objdir-CWNANO/simpleserial.o
.
Compiling C: …/./hal/stm32f0_nano/stm32f0_hal_nano.c
arm-none-eabi-gcc -c -mcpu=cortex-m0 -I. -mthumb -mfloat-abi=soft -ffunction-sections -gdwarf-2 -DSS_VER=SS_VER_1_1 -DSTM32F030x6 -DSTM32F0 -DSTM32 -DDEBUG -DHAL_TYPE=HAL_stm32f0_nano -DPLATFORM=CWNANO -DF_CPU=7372800UL -DSS_VER_2_0=2 -DSS_VER_2_1=3 -DSS_VER_1_1=1 -DSS_VER_1_0=0 -Os -funsigned-char -funsigned-bitfields -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=objdir-CWNANO/stm32f0_hal_nano.lst -I…/./simpleserial/ -I…/./hal -I…/./hal/stm32f0 -I…/./hal/stm32f0/CMSIS -I…/./hal/stm32f0/CMSIS/core -I…/./hal/stm32f0/CMSIS/device -I…/./hal/stm32f0/Legacy -I…/./crypto/ -std=gnu99 -MMD -MP -MF .dep/stm32f0_hal_nano.o.d …/./hal/stm32f0_nano/stm32f0_hal_nano.c -o objdir-CWNANO/stm32f0_hal_nano.o
.
Compiling C: …/./hal/stm32f0/stm32f0_hal_lowlevel.c
arm-none-eabi-gcc -c -mcpu=cortex-m0 -I. -mthumb -mfloat-abi=soft -ffunction-sections -gdwarf-2 -DSS_VER=SS_VER_1_1 -DSTM32F030x6 -DSTM32F0 -DSTM32 -DDEBUG -DHAL_TYPE=HAL_stm32f0_nano -DPLATFORM=CWNANO -DF_CPU=7372800UL -DSS_VER_2_0=2 -DSS_VER_2_1=3 -DSS_VER_1_1=1 -DSS_VER_1_0=0 -Os -funsigned-char -funsigned-bitfields -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=objdir-CWNANO/stm32f0_hal_lowlevel.lst -I…/./simpleserial/ -I…/./hal -I…/./hal/stm32f0 -I…/./hal/stm32f0/CMSIS -I…/./hal/stm32f0/CMSIS/core -I…/./hal/stm32f0/CMSIS/device -I…/./hal/stm32f0/Legacy -I…/./crypto/ -std=gnu99 -MMD -MP -MF .dep/stm32f0_hal_lowlevel.o.d …/./hal/stm32f0/stm32f0_hal_lowlevel.c -o objdir-CWNANO/stm32f0_hal_lowlevel.o
.
Assembling: …/./hal/stm32f0/stm32f0_startup.S
arm-none-eabi-gcc -c -mcpu=cortex-m0 -I. -x assembler-with-cpp -mthumb -mfloat-abi=soft -ffunction-sections -DF_CPU=7372800 -Wa,-gstabs,-adhlns=objdir-CWNANO/stm32f0_startup.lst -I…/./simpleserial/ -I…/./hal -I…/./hal/stm32f0 -I…/./hal/stm32f0/CMSIS -I…/./hal/stm32f0/CMSIS/core -I…/./hal/stm32f0/CMSIS/device -I…/./hal/stm32f0/Legacy -I…/./crypto/ …/./hal/stm32f0/stm32f0_startup.S -o objdir-CWNANO/stm32f0_startup.o
.
Linking: simpleserial-base-CWNANO.elf
arm-none-eabi-gcc -mcpu=cortex-m0 -I. -mthumb -mfloat-abi=soft -ffunction-sections -gdwarf-2 -DSS_VER=SS_VER_1_1 -DSTM32F030x6 -DSTM32F0 -DSTM32 -DDEBUG -DHAL_TYPE=HAL_stm32f0_nano -DPLATFORM=CWNANO -DF_CPU=7372800UL -DSS_VER_2_0=2 -DSS_VER_2_1=3 -DSS_VER_1_1=1 -DSS_VER_1_0=0 -Os -funsigned-char -funsigned-bitfields -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=objdir-CWNANO/simpleserial-base.o -I…/./simpleserial/ -I…/./hal -I…/./hal/stm32f0 -I…/./hal/stm32f0/CMSIS -I…/./hal/stm32f0/CMSIS/core -I…/./hal/stm32f0/CMSIS/device -I…/./hal/stm32f0/Legacy -I…/./crypto/ -std=gnu99 -MMD -MP -MF .dep/simpleserial-base-CWNANO.elf.d objdir-CWNANO/simpleserial-base.o objdir-CWNANO/simpleserial.o objdir-CWNANO/stm32f0_hal_nano.o objdir-CWNANO/stm32f0_hal_lowlevel.o objdir-CWNANO/stm32f0_startup.o --output simpleserial-base-CWNANO.elf --specs=nano.specs --specs=nosys.specs -T …/./hal/stm32f0_nano/LinkerScript.ld -Wl,–gc-sections -lm -mthumb -mcpu=cortex-m0 -Wl,-Map=simpleserial-base-CWNANO.map,–cref -lm
.
Creating load file for Flash: simpleserial-base-CWNANO.hex
arm-none-eabi-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature simpleserial-base-CWNANO.elf simpleserial-base-CWNANO.hex
.
Creating load file for Flash: simpleserial-base-CWNANO.bin
arm-none-eabi-objcopy -O binary -R .eeprom -R .fuse -R .lock -R .signature simpleserial-base-CWNANO.elf simpleserial-base-CWNANO.bin
.
Creating load file for EEPROM: simpleserial-base-CWNANO.eep
arm-none-eabi-objcopy -j .eeprom --set-section-flags=.eeprom=“alloc,load”
–change-section-lma .eeprom=0 --no-change-warnings -O ihex simpleserial-base-CWNANO.elf simpleserial-base-CWNANO.eep || exit 0
.
Creating Extended Listing: simpleserial-base-CWNANO.lss
arm-none-eabi-objdump -h -S -z simpleserial-base-CWNANO.elf > simpleserial-base-CWNANO.lss
.
Creating Symbol Table: simpleserial-base-CWNANO.sym
arm-none-eabi-nm -n simpleserial-base-CWNANO.elf > simpleserial-base-CWNANO.sym
Size after:
text data bss dec hex filename
4736 12 1428 6176 1820 simpleserial-base-CWNANO.elf
±-------------------------------------------------------

  • Default target does full rebuild each time.
  • Specify buildtarget == allquick == to avoid full rebuild
    ±-------------------------------------------------------
    ±-------------------------------------------------------
  • Built for platform CWNANO Built-in Target (STM32F030) with:
  • CRYPTO_TARGET = NONE
  • CRYPTO_OPTIONS = AES128C
    ±-------------------------------------------------------
    make[1]: Leaving directory ‘/home/vagrant/work/projects/chipwhisperer/hardware/victims/firmware/simpleserial-base’

    As the location of file simpleserial-base-CWNANO.hex is
    /home/vagrant/work/projects/chipwhisperer/hardware/victims/firmware/simpleserial-base/simpleserial-base-CWNANO.hex
    so I have used this location in the next line as

cw.program_target(scope, cw.programmers.STM32FProgrammer, “/home/vagrant/work/projects/chipwhisperer/hardware/victims/firmware/simpleserial-base/simpleserial-base-CWNANO.hex”)

But for my surprise i am getting some error as follows


AttributeError Traceback (most recent call last)
Input In [92], in <cell line: 2>()
1 #cw.program_target(scope, cw.programmers.XMEGAProgrammer, “/home/vagrant/work/projects/chipwhisperer/hardware/victims/firmware/simpleserial-base/simpleserial-base-CWNANO.hex”) #“path/to/firmware.hex”)
----> 2 cw.program_target(scope, cw.programmers.STM32FProgrammer, “/home/vagrant/work/projects/chipwhisperer/hardware/victims/firmware/simpleserial-base/simpleserial-base-CWNANO.hex”)

File ~/work/projects/chipwhisperer/software/chipwhisperer/init.py:125, in program_target(scope, prog_type, fw_path, **kwargs)
123 prog.scope = scope
124 prog._logging = None
→ 125 prog.open()
126 prog.find()
127 prog.erase()

File ~/work/projects/chipwhisperer/software/chipwhisperer/capture/api/programmers.py:115, in save_and_restore_pins..func_wrapper(self, *args, **kwargs)
113 target_logger.debug(‘Changing pdic, pdid, and nrst pin configuration’)
114 if pin_setup[‘pdic’] != ‘high_z’:
→ 115 self.scope.io.pdic = ‘high_z’
116 if pin_setup[‘pdid’] != ‘high_z’:
117 self.scope.io.pdid = ‘high_z’

File ~/work/projects/chipwhisperer/software/chipwhisperer/common/utils/util.py:367, in DisableNewAttr.setattr(self, name, value)
365 if name in self._read_only_attrs:
366 raise AttributeError(“Attribute {} is read-only!”.format(name))
→ 367 super(DisableNewAttr, self).setattr(name, value)

File ~/work/projects/chipwhisperer/software/chipwhisperer/capture/scopes/cwnano.py:379, in GPIOSettings.pdic(self, state)
376 @pdic.setter
377 def pdic(self, state):
378 state = self._gpio_name_to_state(state)
→ 379 self.gpio_generic_set(self.USB_PDIC_MASK, state)

File ~/work/projects/chipwhisperer/software/chipwhisperer/capture/scopes/cwnano.py:446, in GPIOSettings.gpio_generic_set(self, gpiomask, state, setdir)
444 def gpio_generic_set(self, gpiomask, state, setdir=True):
445 if state is None:
→ 446 self.usb.sendCtrl(self.USB_GPIO_SET, self.USB_MODE_IN, [gpiomask, 0])
448 elif isinstance(state, int):
449 #If binary/int, check true/false
450 if state:

File ~/work/projects/chipwhisperer/software/chipwhisperer/hardware/naeusb/naeusb.py:728, in NAEUSB.sendCtrl(self, cmd, value, data)
724 “”"
725 Send data over control endpoint
726 “”"
727 # Vendor-specific, OUT, interface control transfer
→ 728 self.usbserializer.sendCtrl(cmd, value, data)

File ~/work/projects/chipwhisperer/software/chipwhisperer/hardware/naeusb/naeusb.py:473, in NAEUSB_Backend.sendCtrl(self, cmd, value, data)
469 # Vendor-specific, OUT, interface control transfer
470 naeusb_logger.debug(“WRITE_CTRL: bmRequestType: {:02X},
471 bRequest: {:02X}, wValue: {:04X}, wIndex: {:04X}, data: {}”.format(0x41, cmd,
472 value, 0, data))
→ 473 self.handle.controlWrite(0x41, cmd, value, 0, data, timeout=self._timeout)

AttributeError: ‘NoneType’ object has no attribute ‘controlWrite’

If anyone knows how to solve this … I will really appreciate —Thanks in advance

Hi,

Did you connect your scope before trying to program the target?

Alex

Yes indeed …But still I got that problem…

The error you got indicates that there’s no USB connection object. Try rerunning the connection step.

Alex