I’ve been trying to get the CWLITEARM up and running on my arm based mac, but I’m having issues with the firmware building and uploading process. When I run
%%bash
cd …/hardware/victims/firmware/simpleserial-base/
gmake PLATFORM=CWLITEARM CRYPTO_TARGET=NONE
(using gmake instead of make because of the way brew installs make 4 on macos)
I get the following output:
SS_VER set to SS_VER_1_1
SS_VER set to SS_VER_1_1
SS_VER set to SS_VER_1_1
SS_VER set to SS_VER_1_1
gmake[1]: ‘.dep’ is up to date.
SS_VER set to SS_VER_1_1
SS_VER set to SS_VER_1_1
.
Welcome to another exciting ChipWhisperer target build!!
arm-none-eabi-gcc (Arm GNU Toolchain 12.3.Rel1 (Build arm-12.35)) 12.3.1 20230626
Copyright (C) 2022 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:
-en simpleserial-base.c …
-e Done!
.
Compiling:
-en …/./simpleserial/simpleserial.c …
-e Done!
.
Compiling:
-en …/./hal/stm32f3/stm32f3_hal.c …
-e Done!
.
Compiling:
-en …/./hal/stm32f3/stm32f3_hal_lowlevel.c …
-e Done!
.
Compiling:
-en …/./hal/stm32f3/stm32f3_sysmem.c …
-e Done!
.
Assembling: …/./hal/stm32f3/stm32f3_startup.S
arm-none-eabi-gcc -c -mcpu=cortex-m4 -I. -x assembler-with-cpp -mthumb -mfloat-abi=soft -fmessage-length=0 -ffunction-sections -DF_CPU=7372800 -Wa,-gstabs,-adhlns=objdir-CWLITEARM/stm32f3_startup.lst -I…/./simpleserial/ -I…/./simpleserial/ -I…/./hal -I…/./hal/stm32f3 -I…/./hal/stm32f3/CMSIS -I…/./hal/stm32f3/CMSIS/core -I…/./hal/stm32f3/CMSIS/device -I…/./hal/stm32f4/Legacy -I…/./crypto/ …/./hal/stm32f3/stm32f3_startup.S -o objdir-CWLITEARM/stm32f3_startup.o
.
LINKING:
-en simpleserial-base-CWLITEARM.elf …
/Applications/ArmGNUToolchain/12.3.rel1/arm-none-eabi/bin/…/lib/gcc/arm-none-eabi/12.3.1/…/…/…/…/arm-none-eabi/bin/ld: /Applications/ArmGNUToolchain/12.3.rel1/arm-none-eabi/bin/…/lib/gcc/arm-none-eabi/12.3.1/…/…/…/…/arm-none-eabi/lib/thumb/v7e-m/nofp/libg_nano.a(libc_a-closer.o): in function _close_r': closer.c:(.text._close_r+0xc): warning: _close is not implemented and will always fail /Applications/ArmGNUToolchain/12.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: /Applications/ArmGNUToolchain/12.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp/libg_nano.a(libc_a-lseekr.o): in function
_lseek_r’:
lseekr.c:(.text._lseek_r+0x10): warning: _lseek is not implemented and will always fail
/Applications/ArmGNUToolchain/12.3.rel1/arm-none-eabi/bin/…/lib/gcc/arm-none-eabi/12.3.1/…/…/…/…/arm-none-eabi/bin/ld: /Applications/ArmGNUToolchain/12.3.rel1/arm-none-eabi/bin/…/lib/gcc/arm-none-eabi/12.3.1/…/…/…/…/arm-none-eabi/lib/thumb/v7e-m/nofp/libg_nano.a(libc_a-readr.o): in function _read_r': readr.c:(.text._read_r+0x10): warning: _read is not implemented and will always fail /Applications/ArmGNUToolchain/12.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: /Applications/ArmGNUToolchain/12.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp/libg_nano.a(libc_a-writer.o): in function
_write_r’:
writer.c:(.text._write_r+0x10): warning: _write is not implemented and will always fail
/Applications/ArmGNUToolchain/12.3.rel1/arm-none-eabi/bin/…/lib/gcc/arm-none-eabi/12.3.1/…/…/…/…/arm-none-eabi/bin/ld: warning: simpleserial-base-CWLITEARM.elf has a LOAD segment with RWX permissions
-e Done!
.
Creating load file for Flash: simpleserial-base-CWLITEARM.hex
arm-none-eabi-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature simpleserial-base-CWLITEARM.elf simpleserial-base-CWLITEARM.hex
.
Creating load file for Flash: simpleserial-base-CWLITEARM.bin
arm-none-eabi-objcopy -O binary -R .eeprom -R .fuse -R .lock -R .signature simpleserial-base-CWLITEARM.elf simpleserial-base-CWLITEARM.bin
.
Creating load file for EEPROM: simpleserial-base-CWLITEARM.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-CWLITEARM.elf simpleserial-base-CWLITEARM.eep || exit 0
.
Creating Extended Listing: simpleserial-base-CWLITEARM.lss
arm-none-eabi-objdump -h -S -z simpleserial-base-CWLITEARM.elf > simpleserial-base-CWLITEARM.lss
.
Creating Symbol Table: simpleserial-base-CWLITEARM.sym
arm-none-eabi-nm -n simpleserial-base-CWLITEARM.elf > simpleserial-base-CWLITEARM.sym
SS_VER set to SS_VER_1_1
SS_VER set to SS_VER_1_1
Size after:
text data bss dec hex filename
4864 8 1432 6304 18a0 simpleserial-base-CWLITEARM.elf
±-------------------------------------------------------
- Default target does full rebuild each time.
- Specify buildtarget == allquick == to avoid full rebuild
±-------------------------------------------------------
±------------------------------------------------------- - Built for platform CW-Lite Arm (STM32F3) with:
- CRYPTO_TARGET = NONE
- CRYPTO_OPTIONS = AES128C
±-------------------------------------------------------
Then, when I run
cw.program_target(scope, cw.programmers.STM32FProgrammer, “…/hardware/victims/firmware/simpleserial-base/simpleserial-base-CWLITEARM.elf”)
I get the following output:
UnicodeDecodeError Traceback (most recent call last)
Cell In[8], line 2
1 #cw.program_target(scope, cw.programmers.XMEGAProgrammer, “path/to/firmware.hex”)
----> 2 cw.program_target(scope, cw.programmers.STM32FProgrammer, “…/hardware/victims/firmware/simpleserial-base/simpleserial-base-CWLITEARM.elf”)
3 #cw.program_target(scope, cw.programmers.AVRProgrammer, “path/to/firmware.hex”)
4 #cw.program_target(scope, cw.programmers.SAM4SProgrammer, “path/to/firmware.hex”)
File ~/.pyenv/versions/3.9.5/lib/python3.9/site-packages/chipwhisperer/init.py:178, in program_target(scope, prog_type, fw_path, **kwargs)
176 prog.find()
177 prog.erase()
→ 178 prog.program(fw_path, memtype=“flash”, verify=True)
179 prog.close()
180 except:
File ~/.pyenv/versions/3.9.5/lib/python3.9/site-packages/chipwhisperer/capture/api/programmers.py:128, in save_and_restore_pins..func_wrapper(self, *args, **kwargs)
125 target_logger.debug(‘Changing {} pin configuration’.format(pin_setup))
127 try:
→ 128 val = func(self, *args, **kwargs)
129 finally:
130 target_logger.debug(‘Restoring {} pin configuration’.format(pin_setup))
File ~/.pyenv/versions/3.9.5/lib/python3.9/site-packages/chipwhisperer/capture/api/programmers.py:406, in STM32FProgrammer.program(self, filename, memtype, verify)
404 stm32f = self.stm32prog()
405 stm32f.scope = self.scope
→ 406 stm32f.program(filename, memtype, verify)
File ~/.pyenv/versions/3.9.5/lib/python3.9/site-packages/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py:38, in close_on_fail..func_wrapper(self, *args, **kwargs)
35 @wraps(func)
36 def func_wrapper(self, *args, **kwargs):
37 try:
—> 38 return func(self, *args, **kwargs)
39 except:
40 self.close_port()
File ~/.pyenv/versions/3.9.5/lib/python3.9/site-packages/chipwhisperer/hardware/naeusb/programmer_stm32fserial.py:198, in STM32FSerial.program(self, filename, memtype, verify, logfunc, waitfunc)
195 “”“Programs memory type, dealing with opening filename as either .hex or .bin file”“”
196 self.lastFlashedFile = filename
→ 198 f = IntelHex(filename)
200 fsize = f.maxaddr() - f.minaddr()
201 fdata = f.tobinarray(start=f.minaddr())
File ~/.pyenv/versions/3.9.5/lib/python3.9/site-packages/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 ~/.pyenv/versions/3.9.5/lib/python3.9/site-packages/chipwhisperer/capture/utils/IntelHex.py:219, in IntelHex.loadhex(self, fobj)
217 decode = self._decode_record
218 try:
→ 219 for s in fobj:
220 line += 1
221 decode(s, line)
File ~/.pyenv/versions/3.9.5/lib/python3.9/codecs.py:322, in BufferedIncrementalDecoder.decode(self, input, final)
319 def decode(self, input, final=False):
320 # decode input (taking the buffer into account)
321 data = self.buffer + input
→ 322 (result, consumed) = self._buffer_decode(data, self.errors, final)
323 # keep undecoded input until the next call
324 self.buffer = data[consumed:]
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xec in position 32: invalid continuation byte
Any help would be greatly appreciated.