Chipwhisperer lite board hardware setup error

[quote=“Sriram, post:1, topic:3348, full:true”]

How to resolve this error.

Do you have the scope connected in a different notebook? You’ll have to disconnect it from other notebook (scope.dis(), or simply restart the kernel on the other notebook) before you can connect in another notebook.

If that’s not the case and it still fails can you copy and paste the full error message that you get when you run scope = cw.scope().

When executing the command below given in the hardware set up in jupyter notebook, the following error occurs. Previously scope was not detected, after updating the firmware the scope gets detected.
How to resolve this error. Kindly help me fix this. I’ve been spending 2 days on it.
I am using the chipwhisperer through the virtual box currently.

Thank you.

%%bash
cd …/hardware/victims/firmware/simpleserial-base/
make PLATFORM= CRYPTO_TARGET=CWLITEXMEGA

SS_VER set to SS_VER_1_1
…/./hal/Makefile.hal:241: *** Invalid or empty PLATFORM: . Known platforms:
±------------------------------------------------------+
| PLATFORM | DESCRIPTION |
+=======================================================+
| AVR/XMEGA Targets (8-Bit RISC) |
+=======================================================+
±------------------------------------------------------+
| CWLITEXMEGA | CW-Lite XMEGA (Alias for CW303) |
±------------------------------------------------------+
| CW301_AVR | Multi-Target Board, AVR Target |
±------------------------------------------------------+
| CW303 | XMEGA Target (CWLite), Also works |
| | for CW308T-XMEGA |
±------------------------------------------------------+
| CW304 | ATMega328P (NOTDUINO), Also works |
| | for CW308T-AVR |
±------------------------------------------------------+
| CW308_MEGARF | ATMega2564RFR2 Target for CW308T |
±------------------------------------------------------+
+=======================================================+

  • ARM Cortex-M Targets (Generic) |
    +=======================================================+
    ±------------------------------------------------------+
    | CWLITEARM | CW-Lite Arm (Alias for CW308_STM32F3) |
    ±------------------------------------------------------+
    | CWNANO | CW-Lite Nano (STM32F0_NANO) |
    ±------------------------------------------------------+
    | CW308_STM32F0 | CW308T-STM32F0 (ST Micro STM32F0) |
    ±------------------------------------------------------+
    | CW308_STM32F1 | CW308T-STM32F1 (ST Micro STM32F1) |
    ±------------------------------------------------------+
    | CW308_STM32F2 | CW308T-STM32F2 (ST Micro STM32F2) |
    ±------------------------------------------------------+
    | CW308_STM32F3 | CW308T-STM32F3 (ST Micro STM32F3) |
    ±------------------------------------------------------+
    | CW308_STM32F4 | CW308T-STM32F4 (ST Micro STM32F405) |
    ±------------------------------------------------------+
    +=======================================================+
  • ARM Cortex-M Targets (Support CRYPTO_TARGET=HWAES) |
    +=======================================================+
    ±------------------------------------------------------+
    | CW308_CC2538 | CW308T-CC2538 (TI CC2538) |
    ±------------------------------------------------------+
    | CW308_ | CW308T-EFM32GG11 |
    | EFM32GG11 | (Silicon Labs Giant Gecko) |
    ±------------------------------------------------------+
    | CW308_ | CW-Lite EFM32TG11B |
    | EFM32TG11B | (Silicon Labs Tiny Geko) |
    ±------------------------------------------------------+
    | CW308_ | CW308T-EFR32MG21 (A version without |
    | EFR32MG21A | ‘secure vault’) |
    ±------------------------------------------------------+
    | CW308_ | CW308T-IMXRT1062 (iMX RT1062) |
    | IMXRT1062 | NXP “Cross-Over” Microcontroller |
    ±------------------------------------------------------+
    | CW308_K24F | CW308T-K24F (NXP Kinetis K24F) |
    ±------------------------------------------------------+
    | CW308_K82F | CW308T-K82F (NXP Kinetis K82F) |
    ±------------------------------------------------------+
    | CW308_LPC55S6X| CW308T-LPC55S69 (NXP LPC55S69) |
    ±------------------------------------------------------+
    | CW308_NRF52 | CW308T-NRF52840 (Nordic Semi) |
    ±------------------------------------------------------+
    | CW308_PSOC62 | CW308T-PSOC62 (Cypress PSOC 62) |
    ±------------------------------------------------------+
    | CW308_SAM4L | CW308T-SAM4L (Atmel SAM4L) |
    ±------------------------------------------------------+
    | CW308_SAML11 | CW-Lite SAML11 (Atmel SAML11) |
    ±------------------------------------------------------+
    | CW308_STM32F2 | CW308T-STM32F2HWC (ST Micro STM32F215)|
    ±------------------------------------------------------+
    | CW308_STM32F4 | CW308T-STM32F4HWC (ST Micro STM32F415)|
    ±------------------------------------------------------+
    | CW308_STM32L4 | CW308T-STM32L4 (ST Micro STM32L443) |
    ±------------------------------------------------------+
    | CW308_STM32L5 | CW308T-STM32L5HWC (ST Micro STM32L562)|
    ±------------------------------------------------------+
    +=======================================================+
  • Other 32-bit Architecture |
    +=======================================================+
    ±------------------------------------------------------+
    | CW308_AURIX | CW-Lite AURIX (Infineon TC233A) |
    ±------------------------------------------------------+
    | CW308_FE310 | CW308T-FE310-G002 (RISC-V) |
    ±------------------------------------------------------+
    | CW308_ | CW308T-MPC5676R (NXP MPC5676R) |
    | MPC5676R | |
    ±--------------|---------------------------------------+
    | CW308_NEORV32 | CW308/CW312-iCE40 with neorv32 |
    | | (RISC-V) soft-core processor. |
    ±--------------|---------------------------------------+

Options to define platform:
(1) Run make with PLATFORM specified as follows:
make PLATFORM=CW304

(2) Save a file called Makefile. platform with contents:
PLATFORM=CW304
. Stop.

CalledProcessError Traceback (most recent call last)
Input In [30], in <cell line: 1>()
----> 1 get_ipython().run_cell_magic(‘bash’, ‘’, ‘cd …/hardware/victims/firmware/simpleserial-base/\nmake PLATFORM= CRYPTO_TARGET=CWLITEXMEGA\n’)

File ~/.pyenv/versions/3.9.7/envs/cw/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2358, in InteractiveShell.run_cell_magic(self, magic_name, line, cell)
2356 with self.builtin_trap:
2357 args = (magic_arg_s, cell)
→ 2358 result = fn(*args, **kwargs)
2359 return result

File ~/.pyenv/versions/3.9.7/envs/cw/lib/python3.9/site-packages/IPython/core/magics/script.py:153, in ScriptMagics._make_script_magic..named_script_magic(line, cell)
151 else:
152 line = script
→ 153 return self.shebang(line, cell)

File ~/.pyenv/versions/3.9.7/envs/cw/lib/python3.9/site-packages/IPython/core/magics/script.py:305, in ScriptMagics.shebang(self, line, cell)
300 if args.raise_error and p.returncode != 0:
301 # If we get here and p.returncode is still None, we must have
302 # killed it but not yet seen its return code. We don’t wait for it,
303 # in case it’s stuck in uninterruptible sleep. -9 = SIGKILL
304 rc = p.returncode or -9
→ 305 raise CalledProcessError(rc, cell)

CalledProcessError: Command ‘b’cd …/hardware/victims/firmware/simpleserial-base/\nmake PLATFORM= CRYPTO_TARGET=CWLITEXMEGA\n’’ returned non-zero exit status 2.

You’re supposed to pass a valid PLATFORM to the makefile. You seem to be calling it like this:

make PLATFORM= CRYPTO_TARGET=CWLITEXMEGA

You can build that example for the CWLITEXMEGA platform as follows:

make PLATFORM=CWLITEXMEGA CRYPTO_TARGET=NONE

THANK YOU esanfelix. It worked.

After this in the next command I face the following error, could you please tell me how to rectify this error. I’m a beginner in this field which takes time for me to sort out things. Your reply would mean a lot to me.
Thank you!

cw.program_target(scope, cw.programmers.XMEGAProgrammer, “path/to/firmware.hex”)
#cw.program_target(scope, cw.programmers.STM32FProgrammer, “path/to/firmware.hex”)
#cw.program_target(scope, cw.programmers.AVRProgrammer, “path/to/firmware.hex”)

FileNotFoundError Traceback (most recent call last)
Input In [38], in <cell line: 1>()
----> 1 cw.program_target(scope, cw.programmers.XMEGAProgrammer, “path/to/firmware.hex”)

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

File ~/work/projects/chipwhisperer/software/chipwhisperer/capture/api/programmers.py:121, in save_and_restore_pins..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’)

File ~/work/projects/chipwhisperer/software/chipwhisperer/capture/api/programmers.py:269, in XMEGAProgrammer.program(self, filename, memtype, verify)
267 Programmer.lastFlashedFile = filename
268 xmega = self.xmegaprog()
→ 269 xmega.program(filename, memtype, verify)

File ~/work/projects/chipwhisperer/software/chipwhisperer/hardware/naeusb/programmer_xmega.py:268, in XMEGAPDI.program(self, filename, memtype, verify, logfunc, waitfunc)
265 “”“Programs memory type, dealing with opening filename as either .hex or .bin file”""
266 self.lastFlashedFile = filename
→ 268 fdata, fsize = FileReader(filename)
270 startaddr = self._chip.memtypes[memtype][“offset”]
271 maxsize = self._chip.memtypes[memtype][“size”]

File ~/work/projects/chipwhisperer/software/chipwhisperer/capture/utils/programming_files.py:30, in FileReader(filename)
28 def FileReader(filename):
29 if filename.lower().endswith(".hex") or filename.lower().endswith(".ihex"):
—> 30 f = IntelHex(filename)
31 fdata = f.tobinarray(0)
32 fsize = f.maxaddr() - f.minaddr()

File ~/work/projects/chipwhisperer/software/chipwhisperer/capture/utils/IntelHex.py:99, in IntelHex.init(self, source)
96 if source is not None:
97 if isinstance(source, StrType) or getattr(source, “read”, None):
98 # load hex file
—> 99 self.loadhex(source)
100 elif isinstance(source, dict):
101 self.fromdict(source)

File ~/work/projects/chipwhisperer/software/chipwhisperer/capture/utils/IntelHex.py:208, in IntelHex.loadhex(self, fobj)
201 “”“Load hex file into internal buffer. This is not necessary
202 if object was initialized with source set. This will overwrite
203 addresses if object was already initialized.
204
205 @param fobj file name or file-like object
206 “””
207 if getattr(fobj, “read”, None) is None:
→ 208 fobj = open(fobj, “r”)
209 fclose = fobj.close
210 else:

FileNotFoundError: [Errno 2] No such file or directory: ‘path/to/firmware.hex’

path/to/firmware.hex is a placeholder… You need to provide the path to the .hex file that the make command generates.

the following error occurs, where will be that .hex file which needed to be add to the path.

cw.program_target(scope, cw.programmers.XMEGAProgrammer, “C:\Users\MYPC\chipwhisperer-5.6.1.tar\hardware\victims\firmware”)
#cw.program_target(scope, cw.programmers.STM32FProgrammer, “path/to/firmware.hex”)
#cw.program_target(scope, cw.programmers.AVRProgrammer, “path/to/firmware.hex”)

Input In [47]
cw.program_target(scope, cw.programmers.XMEGAProgrammer, “C:\Users\MYPC\chipwhisperer-5.6.1.tar\hardware\victims\firmware”)
^
SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escape

Try adding an r before the "" ie r"C:\...".

what is that path to firmware.hex file. where will it be available in the downloaded source code?

You’ll find the .hex file in the same place where you ran the make command.
If we take Lab 2_1A as an example, this would be
hardware/victims/firmware/simpleserial-base2/*.hex, starting from the root directory of your ChipWhisperer installation.

Dear people, I don’t have a clear picture of how to proceed with the Chipwhisperer target analysis, I have the following doubt

  • For this virtual box chipwhisperer setup, after setting up a hardware example in the


    Jupyter notebook in the local host 8888, how should I communicate with the target?

  • Does separate chipwhisperer software like capture and analyzer needs to be installed?

  • I’m stuck with how to communicate with Atmel Xmega target in the chipwhisperer lite board (NewAE NAE-CW1173-2PART).

  • Also in future I need to communicate with the Esp8266 target, what I need to perform the attack on that target. UFO Target board?

Did you get anything back from the read commands earlier in that notebook? If so, then you’re communicating with the target. Our SimpleSerial protocol communicates with the target using the IO1 and IO2 lines.

No.

Follow our courses to learn. If you can’t figure out the parts that the notebooks ask you to (e.g. where it says “fill in the rest”), then you’ll notice that some (not all) of the course notebooks also have a solution notebook (filename starts with “SOLN”).

We don’t have an ESP8266 target board, but we do have this ESP32 target board. I’m not sure how similar these are and whether it would be useful to start with our ESP32 before attempting a third-party ESP8266. It depends what you aim to do.

Hope this helps,
Jean-Pierre