SimpleSerial 2.0 - target build error

Hi,

I get an error when I try to build the target for ‘Fault 1_4 - Authenticated AES Bootloader’. How do I resolve this?

This is what I run:

SCOPETYPE = ‘OPENADC’
PLATFORM = ‘CW308_STM32F0’
SS_VER = ‘SS_VER_2_0’

%%bash -s “$PLATFORM” “$SS_VER”
cd …/…/…/hardware/victims/firmware/simpleserial-aes-bootloader
make PLATFORM=$1 CRYPTO_TARGET=TINYAES128C SS_VER=$2

The output:

SS_VER set to SS_VER_2_0
rm -f – simpleserial-bootloader-CW308_STM32F0.hex
rm -f – simpleserial-bootloader-CW308_STM32F0.eep
rm -f – simpleserial-bootloader-CW308_STM32F0.cof
rm -f – simpleserial-bootloader-CW308_STM32F0.elf
rm -f – simpleserial-bootloader-CW308_STM32F0.map
rm -f – simpleserial-bootloader-CW308_STM32F0.sym
rm -f – simpleserial-bootloader-CW308_STM32F0.lss
rm -f – objdir/.o
rm -f – objdir/
.lst
rm -f – bootloader.s simpleserial.s stm32f0_hal.s stm32f0_hal_lowlevel.s aes.s aes-independant.s
rm -f – bootloader.d simpleserial.d stm32f0_hal.d stm32f0_hal_lowlevel.d aes.d aes-independant.d
rm -f – bootloader.i simpleserial.i stm32f0_hal.i stm32f0_hal_lowlevel.i aes.i aes-independant.i
.
Welcome to another exciting ChipWhisperer target build!!
arm-none-eabi-gcc (15:9-2019-q4-0ubuntu1) 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]
Copyright (C) 2019 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: bootloader.c
arm-none-eabi-gcc -c -mcpu=cortex-m0 -I. -mthumb -mfloat-abi=soft -ffunction-sections -gdwarf-2 -DSS_VER=SS_VER_2_0 -DSTM32F071xB -DSTM32F071RBTX -DSTM32F0 -DSTM32 -DDEBUG -DHAL_TYPE=HAL_stm32f0 -DPLATFORM=CW308_STM32F0 -DTINYAES128C -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/bootloader.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/ -I…/./crypto/tiny-AES128-C -std=gnu99 -MMD -MP -MF .dep/bootloader.o.d bootloader.c -o objdir/bootloader.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_2_0 -DSTM32F071xB -DSTM32F071RBTX -DSTM32F0 -DSTM32 -DDEBUG -DHAL_TYPE=HAL_stm32f0 -DPLATFORM=CW308_STM32F0 -DTINYAES128C -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/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/ -I…/./crypto/tiny-AES128-C -std=gnu99 -MMD -MP -MF .dep/simpleserial.o.d …/./simpleserial/simpleserial.c -o objdir/simpleserial.o

bootloader.c: In function ‘main’:
bootloader.c:132:37: warning: passing argument 3 of ‘simpleserial_addcmd’ from incompatible pointer type [-Wincompatible-pointer-types]
132 | simpleserial_addcmd(0x00, 0x10, init_bootloader);
| ^~~~~~~~~~~~~~~
| |
| uint8_t (*)(uint8_t, uint8_t, uint8_t, uint8_t ) {aka unsigned char ()(unsigned char, unsigned char, unsigned char, unsigned char )}
In file included from bootloader.c:21:
…/./simpleserial/simpleserial.h:44:61: note: expected 'uint8_t (
)(uint8_t , uint8_t)’ {aka 'unsigned char ()(unsigned char , unsigned char)'} but argument is of type 'uint8_t ()(uint8_t, uint8_t, uint8_t, uint8_t )’ {aka 'unsigned char ()(unsigned char, unsigned char, unsigned char, unsigned char )'}
44 | int simpleserial_addcmd(char c, unsigned int len, uint8_t (fp)(uint8_t, uint8_t));
| ^~~~~~~~~~~~
bootloader.c:133:37: warning: passing argument 3 of ‘simpleserial_addcmd’ from incompatible pointer type [-Wincompatible-pointer-types]
133 | simpleserial_addcmd(0x01, 0x11, bootloader_recv);
| ^~~~~~~~~~~~~~~
| |
| uint8_t (
)(uint8_t, uint8_t, uint8_t, uint8_t ) {aka unsigned char ()(unsigned char, unsigned char, unsigned char, unsigned char )}
In file included from bootloader.c:21:
…/./simpleserial/simpleserial.h:44:61: note: expected 'uint8_t (
)(uint8_t , uint8_t)’ {aka 'unsigned char ()(unsigned char , unsigned char)'} but argument is of type 'uint8_t ()(uint8_t, uint8_t, uint8_t, uint8_t )’ {aka 'unsigned char ()(unsigned char, unsigned char, unsigned char, unsigned char )'}
44 | int simpleserial_addcmd(char c, unsigned int len, uint8_t (fp)(uint8_t, uint8_t));
| ^~~~~~~~~~~~
bootloader.c:134:37: warning: passing argument 3 of ‘simpleserial_addcmd’ from incompatible pointer type [-Wincompatible-pointer-types]
134 | simpleserial_addcmd(0x02, 0x04, set_addr);
| ^~~~~~~~
| |
| uint8_t (
)(uint8_t, uint8_t, uint8_t, uint8_t ) {aka unsigned char ()(unsigned char, unsigned char, unsigned char, unsigned char )}
In file included from bootloader.c:21:
…/./simpleserial/simpleserial.h:44:61: note: expected 'uint8_t (
)(uint8_t , uint8_t)’ {aka 'unsigned char ()(unsigned char , unsigned char)'} but argument is of type 'uint8_t ()(uint8_t, uint8_t, uint8_t, uint8_t )’ {aka 'unsigned char ()(unsigned char, unsigned char, unsigned char, unsigned char )'}
44 | int simpleserial_addcmd(char c, unsigned int len, uint8_t (fp)(uint8_t, uint8_t));
| ^~~~~~~~~~~~
bootloader.c:135:37: warning: passing argument 3 of ‘simpleserial_addcmd’ from incompatible pointer type [-Wincompatible-pointer-types]
135 | simpleserial_addcmd(0x03, 0x01, read_mem);
| ^~~~~~~~
| |
| uint8_t (
)(uint8_t, uint8_t, uint8_t, uint8_t ) {aka unsigned char ()(unsigned char, unsigned char, unsigned char, unsigned char )}
In file included from bootloader.c:21:
…/./simpleserial/simpleserial.h:44:61: note: expected 'uint8_t (
)(uint8_t , uint8_t)’ {aka 'unsigned char ()(unsigned char , unsigned char)'} but argument is of type 'uint8_t ()(uint8_t, uint8_t, uint8_t, uint8_t )’ {aka 'unsigned char ()(unsigned char, unsigned char, unsigned char, unsigned char *)'}
44 | int simpleserial_addcmd(char c, unsigned int len, uint8_t (fp)(uint8_t, uint8_t));
| ^~~~~~~~~~~~
…/./simpleserial/simpleserial.c:38:2: error: #error “SS_VER_2_0 is deprecated! Use SS_VER_2_1 instead.”
38 | #error “SS_VER_2_0 is deprecated! Use SS_VER_2_1 instead.”
| ^~~~~
…/./simpleserial/simpleserial.c:9:12: warning: ‘num_commands’ defined but not used [-Wunused-variable]
9 | static int num_commands = 0;
| ^~~~~~~~~~~~
make: *** […/./Makefile.inc:469: objdir/simpleserial.o] Error 1


CalledProcessError Traceback (most recent call last)
/tmp/ipykernel_30517/2295133393.py in
----> 1 get_ipython().run_cell_magic(‘bash’, ‘-s “$PLATFORM” “$SS_VER”’, ‘cd …/…/…/hardware/victims/firmware/simpleserial-aes-bootloader\nmake PLATFORM=$1 CRYPTO_TARGET=TINYAES128C SS_VER=$2\n’)

~/.local/lib/python3.8/site-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
2404 with self.builtin_trap:
2405 args = (magic_arg_s, cell)
→ 2406 result = fn(*args, **kwargs)
2407 return result
2408

~/.local/lib/python3.8/site-packages/IPython/core/magics/script.py in named_script_magic(line, cell)
140 else:
141 line = script
→ 142 return self.shebang(line, cell)
143
144 # write a basic docstring:

in shebang(self, line, cell)

~/.local/lib/python3.8/site-packages/IPython/core/magic.py in (f, *a, **k)
185 # but it’s overkill for just that one bit of state.
186 def magic_deco(arg):
→ 187 call = lambda f, *a, **k: f(*a, **k)
188
189 if callable(arg):

~/.local/lib/python3.8/site-packages/IPython/core/magics/script.py in shebang(self, line, cell)
243 sys.stderr.flush()
244 if args.raise_error and p.returncode!=0:
→ 245 raise CalledProcessError(p.returncode, cell, output=out, stderr=err)
246
247 def _run_script(self, p, cell, to_close):

CalledProcessError: Command ‘b’cd …/…/…/hardware/victims/firmware/simpleserial-aes-bootloader\nmake PLATFORM=$1 CRYPTO_TARGET=TINYAES128C SS_VER=$2\n’’ returned non-zero exit status 2.

Hi,

Use SS_VER = ‘SS_VER_2_1’. SSV2 used an incorrect CRC, so it’s been deprecated.

Alex

Good to know. I already tried using the next version. Then I get errors later on in the notebook when I run:

target.simpleserial_write(0x00, bytearray(range(16)))
target.simpleserial_wait_ack()

This gives me the following output:

Unexpected frame byte in CWbytearray(b’e0 e0 00’)
Device did not ack

I noticed that the bytearray seen in the output changes with the target.baud value.

Oh sorry, looks like that firmware doesn’t support SSV2 at the moment. I’ll get that fixed up.

Alex

1 Like

Great!

Thank you for the help.

1 Like

Is there a way to complete the tutorial without using any simpleserial class, like we did in the bootloader - AES 256 for the sca201 tutorials, since one cannot use the SimpleSerial instances as expected, due to the firmware not supporting the SSV2. Also if we use plain target.write(), target.read() methods what kind of response is anticipated from the SimpleSerial-aes-bootloader?

For me at least SimpleSerial class ver 2_1(using the TINYAES128C as the CRYPTO_TARGET, AVRCRYPTOLIB is possibly not supported by AVRCRYPTOLIB) works well with the simpleserial-aes-bootloader firmware, and I was able to get the correct responds from the target (XMEGA)

Hello,

I have a very basic doubt regarding the following syntax:
simpleserial_addcmd(0x01, 16, aes)

What does 0x01 mean? In the tutorials, I could find a very brief explanation and nothing related to characters other than k, r, p were mentioned.

0x01 is the command. In SSV1, this would have been 'p'/'k', etc. All AES functionality has been combined into one function, utilizing the subcommand field to distinguish between setting text, key, etc.

Alex

Hello Alex,

I am new to ChipWhisperer and Thank you so much for this information. How to capture the traces if I am running a function other than AES ?

Also could you please let me know if my below understanding about trigger_high() function is correct or not?
Capturing of traces is only possible after trigger_high() command in C file. Is this correct?

It’s the same as with AES:

  1. Arm the scope (scope.arm())
  2. Trigger the operation you want
  3. Capture the trace (scope.capture())
  4. Read the trace data (scope.get_last_trace())

Setting the trigger high is what causes the trace to be captured after calling scope.arm(). This is similar to the “single” function on an oscilloscope.

Alex

Thanks alot for the information @Alex_Dewar :slight_smile:

This is the error I have been getting and that is why I asked about trigger_high() function.

In the C code, I haven’t used any simpleserial related functions because, I wanted to monitor the traces of a simple loop whose input was already provided by me as an initialized value ( similar to SCA101 Lab2 1_A).

You need to call scope.arm() before the trigger goes high. If your target is doing an operating after resetting, you need to call scope.arm() before resetting. However, I don’t recommend trying to trigger as you’re doing as you might run into issues with the reset affecting the trigger line. If you don’t want to change your firmware, triggering on the nrst line should work better.

Alex