### Individual Tutorial Test Setup Source: https://github.com/newaetech/chipwhisperer/blob/develop/contributing.md Example Python code snippets demonstrating how to set up variables for running individual tutorial tests within a Jupyter notebook. Select the appropriate block for your hardware and the notebook to test. ```python testscope = 'OPENADC' testplat = 'CWLITEARM' crypt = 'TINYAES128C' ``` -------------------------------- ### Build hello_world Example Source: https://github.com/newaetech/chipwhisperer/blob/develop/firmware/mcu/intel_quark/qmsi/README.rst Build the 'hello_world' example application. This command can be run from the top-level directory using the -C option, or from within the example's directory. By default, it builds in release mode. ```bash make –C examples/hello_world ``` -------------------------------- ### Install Documentation Build Requirements Source: https://github.com/newaetech/chipwhisperer/blob/develop/contributing.md Use pip to install the necessary dependencies for building the documentation. ```bash python -m pip install -r chipwhisperer/docs/requirements.txt ``` -------------------------------- ### Flash Blinky Example Source: https://github.com/newaetech/chipwhisperer/blob/develop/firmware/mcu/intel_quark/boot_rom/doc/fw-manager-user-guide.rst Directly flash the blinky example to the device using make. ```bash make -C examples/blinky flash SOC=quark_se TARGET=x86 SERIAL_PORT=/dev/tty0 ``` ```bash make -C examples/blinky flash SOC=quark_se TARGET=x86 USB_DEVICE=8086:48FC ``` -------------------------------- ### Build and Flash Blinky Example Step-by-Step Source: https://github.com/newaetech/chipwhisperer/blob/develop/firmware/mcu/intel_quark/boot_rom/doc/fw-manager-user-guide.rst Complete workflow for building and flashing the blinky example for the Quark SE C1000 x86 core. ```bash cd $QMSI_SRC_DIR ``` ```bash make -C examples/blinky SOC=quark_se TARGET=x86 ``` ```bash python ./tools/sysupdate/qm_make_dfu.py -v examples/blinky/release/quark_se/x86/bin/blinky.bin -p 1 ``` ```bash qm_make_dfu.py: QFU-Header and DFU-Suffix content: Partition: 1 Vendor ID: 0 Product ID: 0 Version: 0 Block Size: 2048 Blocks: 2 DFU CRC: 0x8741e6e7 qm_make_dfu.py: blinky.dfu written ``` ```bash dfu-util-qda -D examples/blinky/release/quark_se/x86/bin/blinky.bin.dfu -p /dev/tty0 -R -a 1 ``` ```bash dfu-util -D examples/blinky/release/quark_se/x86/bin/blinky.bin.dfu -d 8086:48FC -R -a 1 ``` -------------------------------- ### Activate ChipWhisperer Environment and Launch Jupyter Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/linux-install.rst Use these commands to verify the installation by activating the virtual environment and starting the notebook server. ```bash source ~/.cwvenv/bin/activate jupyter notebook ``` -------------------------------- ### Clone ChipWhisperer Repository and Setup Virtual Environment (Bash) Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/linux-install.rst Clones the ChipWhisperer repository from GitHub into the home directory, initializes submodules for Jupyter notebooks, creates a Python virtual environment named '.cwvenv', and activates it. This is a key part of the quick installation. ```bash cd ~/ git clone https://github.com/newaetech/chipwhisperer cd chipwhisperer python3 -m venv ~/.cwvenv source ~/.cwvenv/bin/activate ``` -------------------------------- ### Build Firmware for SimpleSerial Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/simpleserial.rst Example command to build firmware for a specific SimpleSerial version. ```bash make PLATFORM=CW308_STM32F3 SS_VER=SS_VER_2_1 ``` -------------------------------- ### Flash example app via USB Source: https://github.com/newaetech/chipwhisperer/blob/develop/firmware/mcu/intel_quark/boot_rom/doc/fw-manager-user-guide.rst Compiles, uploads, and runs an example application using the 'make flash' command for USB connections. Requires specifying the USB device Vendor and Product ID. ```bash make -C flash SOC= TARGET= USB_DEVICE= ``` -------------------------------- ### Run Generic Setup Script Source: https://github.com/newaetech/chipwhisperer/blob/develop/tests/HuskySADStressTest.ipynb Executes a generic setup script for the ChipWhisperer environment. This script typically handles common initializations and configurations. ```python %run ../jupyter/Setup_Scripts/Setup_Generic.ipynb ``` -------------------------------- ### Setup Clock Parameters Source: https://github.com/newaetech/chipwhisperer/blob/develop/tests/husky_adc_phase_part1.ipynb Sets up the clock frequency, multiplier, and oversampling rate. ```python setup(FREQ, MUL, INPUT_PHASE) set_oversamp(OVERSAMP) ``` -------------------------------- ### Start OpenOCD for SE C1000 Source: https://github.com/newaetech/chipwhisperer/blob/develop/firmware/mcu/intel_quark/boot_rom/README.rst Use this command to start OpenOCD for the Quark SE C1000 board. Ensure you are in the correct directory. ```bash ./bin/openocd -f scripts/board/quark_se_onboard.cfg ``` -------------------------------- ### SAM3X Reprogramming Output Example Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/Targets/CW340 Luna Board.md This is an example of the expected output when the SAM3X firmware reprogramming is successful. Look for 'Upgrade successful' at the end. ```text Found /dev/ttyACM0 Loading cwluna firmware... Opened! Connecting... Connected! Erasing... Erased! Programming file cwluna/mcufw.bin... Programmed! Verifying... Verify OK! Resetting... Upgrade successful ``` -------------------------------- ### Install qmfmlib Python Package Source: https://github.com/newaetech/chipwhisperer/blob/develop/firmware/mcu/intel_quark/boot_rom/tools/sysupdate/README.rst Use this command to install the qmfmlib library to your local Python packages. Add the `--user` option if you do not have root access. ```bash python setup.py install ``` -------------------------------- ### Start OpenOCD for Quark D2000 Source: https://github.com/newaetech/chipwhisperer/blob/develop/firmware/mcu/intel_quark/qmsi/README.rst Initializes OpenOCD using the D2000 onboard configuration. ```bash ./bin/openocd -f scripts/board/quark_d2000_onboard.cfg ``` -------------------------------- ### OpenOCD Configuration File Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/debugging.rst Example of a .cfg file content equivalent to the command line arguments. ```text source [/path/to/cw_openocd.cfg] transport select swd ftdi vid_pid 0x2b3e 0xace2 source [target/stm32f3x.cfg] ``` -------------------------------- ### simpleserial_get: Initialization and Loop Start Source: https://github.com/newaetech/chipwhisperer/blob/develop/firmware/mcu/87c51/87c51/ss_aes/build/simpleserial.rst Assembly code initializing registers r4, r3, and r2, and setting up the start of a 'while(1)' loop. This prepares for character input and state management. ```assembly ; simpleserial.c:63: unsigned char ascii_pos = 0; 000DFF E4 [12] 639 clr a 000E00 FC [12] 640 mov r4,a 000E01 FB [12] 641 mov r3,a 000E02 E5 08 [12] 642 mov a,_bp 000E04 24 04 [12] 643 add a,#0x04 000E06 FA [12] 644 mov r2,a 000E07 645 00127$: ``` -------------------------------- ### Flash example app via UART Source: https://github.com/newaetech/chipwhisperer/blob/develop/firmware/mcu/intel_quark/boot_rom/doc/fw-manager-user-guide.rst Compiles, uploads, and runs an example application using the 'make flash' command for UART connections. Requires setting the serial port. ```bash make -C flash SOC= TARGET= SERIAL_PORT= ``` -------------------------------- ### Use Sub Commands Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/simpleserial.rst Example callback function signature utilizing the scmd field. ```c uint8_t get_pt(uint8_t cmd, uint8_t scmd, uint8_t dlen, uint8_t *buf) { ``` -------------------------------- ### Interrupt Vector Setup Source: https://github.com/newaetech/chipwhisperer/blob/develop/firmware/mcu/87c51/87c51/glitch_loop/build/main.rst Configures the interrupt vector to jump to the startup initialization routine. ```assembly __interrupt_vect: ljmp __sdcc_gsinit_startup ``` -------------------------------- ### Apply Default Scope Setup Source: https://github.com/newaetech/chipwhisperer/blob/develop/tests/HuskySADStressTest.ipynb Applies the default configuration to the ChipWhisperer scope. This ensures a known starting state for subsequent operations. ```python scope.default_setup() ``` -------------------------------- ### Create Project Directory Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/custom-firmware.rst Initialize a new project folder within the firmware directory. ```bash # Assume your in the firmware directory mkdir simpleserial-xor ``` -------------------------------- ### Find ChipWhisperer Installation Directory Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/updating.rst Use this Python snippet to locate the installation path of the ChipWhisperer library if you are unsure where it is installed. ```python import chipwhisperer as cw; print(cw.__file__) ``` -------------------------------- ### Build Firmware with Make Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/Targets/CW303 XMEGA.md Navigate to the project directory and execute the make command with the appropriate platform and crypto target flags. ```bash cd c:\chipwhisperer\firmware\mcu\ make PLATFORM=CW303 CRYPTO_TARGET=AVRCRYPTOLIB ``` -------------------------------- ### Install libusb using Homebrew Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/mac-install.rst Installs the libusb library, which is required for ChipWhisperer software to communicate with the board. Use this command after installing Homebrew. ```bash brew install libusb ``` -------------------------------- ### Install pyenv and Python 3.9.5 Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/mac-install.rst Installs pyenv for managing Python versions and then installs and sets Python 3.9.5 as the global version. Ensure to restart your terminal after running these commands. ```bash brew install pyenv ``` ```bash pyenv install 3.9.5 ``` ```bash pyenv global 3.9.5 ``` ```bash echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.zshrc ``` -------------------------------- ### Install ChipWhisperer Python Package (Bash) Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/linux-install.rst Installs ChipWhisperer in editable mode using pip and installs the requirements for the Jupyter notebooks. Ensure your virtual environment is activated before running these commands. ```bash python -m pip install -e . python -m pip install -r jupyter/requirements.txt ``` -------------------------------- ### Build and Package QMSI Project Source: https://github.com/newaetech/chipwhisperer/blob/develop/firmware/mcu/intel_quark/boot_rom/doc/fw-manager-user-guide.rst Standard commands to navigate to the source, build the binary, and generate a DFU image. ```bash cd $QMSI_SRC_DIR ``` ```bash cd ``` ```bash make -C SOC= TARGET= ``` ```bash python ./tools/sysupdate/qm_make_dfu.py -v -p ``` -------------------------------- ### Build Documentation Locally Source: https://github.com/newaetech/chipwhisperer/blob/develop/contributing.md Execute the build command within the documentation directory to generate the HTML site. ```bash jb build source ``` -------------------------------- ### Install dfu-util on Fedora Source: https://github.com/newaetech/chipwhisperer/blob/develop/firmware/mcu/intel_quark/boot_rom/doc/fw-manager-user-guide.rst Installs the dfu-util package on Fedora systems for USB firmware management. ```bash sudo dnf install dfu-util ``` -------------------------------- ### Run ChipWhisperer Tutorial Tests Source: https://github.com/newaetech/chipwhisperer/blob/develop/contributing.md Command to execute the tutorial test system from the specified directory. This will run all configured tutorials and report results. ```bash cd chipwhisperer/jupyter/tests/ python tutorials.py ``` -------------------------------- ### Build libqmsi Library Source: https://github.com/newaetech/chipwhisperer/blob/develop/firmware/mcu/intel_quark/qmsi/README.rst Build the main QMSI library archive containing all QMSI drivers for the selected SoC. The output is placed in the 'build' directory. ```bash make libqmsi ``` -------------------------------- ### Install ChipWhisperer Dependencies (Bash) Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/linux-install.rst Installs essential packages required for ChipWhisperer, including build tools, AVR and ARM toolchains, USB development libraries, and Python development tools. This is part of the quick installation process. ```bash sudo apt install make git avr-libc gcc-avr \ gcc-arm-none-eabi libusb-1.0-0-dev usbutils python3 python3-venv python3-dev ``` -------------------------------- ### Initialize Bokeh Visualization Source: https://github.com/newaetech/chipwhisperer/blob/develop/tests/husky_adc_phase_part1.ipynb Sets up the notebook environment for Bokeh plotting. ```python from bokeh.plotting import figure, show from bokeh.resources import INLINE from bokeh.io import output_notebook import numpy as np output_notebook(INLINE) #output_notebook() ``` -------------------------------- ### Install dfu-util on Debian/Ubuntu Source: https://github.com/newaetech/chipwhisperer/blob/develop/firmware/mcu/intel_quark/boot_rom/doc/fw-manager-user-guide.rst Installs the dfu-util package on Debian and Ubuntu systems for USB firmware management. ```bash sudo apt-get install dfu-util ``` -------------------------------- ### Install Required Python Packages for Firmware Building (Bash) Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/linux-install.rst Installs prerequisite packages for building firmware for target devices, including development libraries for USB and essential build tools like make and git. This is part of the manual installation process. ```bash sudo apt install libusb-dev make git avr-libc gcc-avr \ gcc-arm-none-eabi libusb-1.0-0-dev usbutils ``` -------------------------------- ### Finish MPSSE Setup Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/debugging.rst If `enable_MPSSE` raises an exception, use this code to manually complete the MPSSE setup and disconnect the scope. ```python scope = cw.scope() scope.finish_mpsse_setup() scope.dis() ``` -------------------------------- ### Main Function Setup Source: https://github.com/newaetech/chipwhisperer/blob/develop/firmware/mcu/87c51/87c51/ss_tea/build/main.rst Sets up the stack frame for the main function by pushing the base pointer and adjusting the stack pointer. This is standard procedure for function entry in this architecture. ```assembly push _bp mov a,sp mov _bp,a add a,#0x1b mov sp,a ``` -------------------------------- ### Navigate to ChipWhisperer Directory Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/starting.rst Change to the ChipWhisperer installation directory using the 'cd' command. Replace '/home/user/chipwhisperer' with your actual installation path. ```bash cd /home/user/chipwhisperer ``` -------------------------------- ### Initialize and Print Welcome Message Source: https://github.com/newaetech/chipwhisperer/blob/develop/firmware/mcu/87c51/87c51/pass_check/build/pass_check.rst This snippet initializes the system by triggering a low signal and then prints a welcome message using printf_small. It involves pushing string arguments onto the stack before the function call. ```assembly anl _P1,#0xfe mov a,#___str_0 push acc mov a,#(___str_0 >> 8) push acc mov a,#0x80 push acc lcall _printf_small dec sp dec sp dec sp ``` -------------------------------- ### Initialize SimpleSerial in C Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/simpleserial.rst Required hardware and UART initialization steps for target firmware. ```c // required for hardware setup platform_init(); init_uart(); // always required simpleserial_init(); ``` -------------------------------- ### Install and Load FTDI Drivers Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/Targets/CW340 Luna Board.md Commands to install the necessary Linux kernel modules and load the FTDI driver for serial communication. ```bash sudo apt install linux-modules-extra-`uname -r` # install driver sudo modprobe ftdi_sio # load driver ``` -------------------------------- ### reStructuredText Section Link Example Source: https://github.com/newaetech/chipwhisperer/blob/develop/contributing.md An example of creating an internal section link in reStructuredText. This is useful for navigating within the generated documentation. ```rst .. info-additional_information: ********************** Additional Information ********************** ``` -------------------------------- ### AES Encryption Function Setup Source: https://github.com/newaetech/chipwhisperer/blob/develop/firmware/mcu/87c51/87c51/ss_tea/build/aes.rst Assembly code for the setup of the aes_encrypt function, including stack frame creation and saving of registers. ```assembly _aes_encrypt: push _bp mov _bp,sp push dpl push dph push b mov a,sp add a,#0x10 mov sp,a ``` -------------------------------- ### Build SAM3U Firmware Source: https://github.com/newaetech/chipwhisperer/blob/develop/docs/source/Targets/CW305 Artix FPGA.md Navigate to the firmware source directory and use 'make clean' followed by 'make' to build the SAM3U firmware. ```bash cd fw/sam3u/CW305_SAM3U_FW/src make clean make ```