### Initializing ChipWhisperer Scope and Target (Python) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_STM32F/README.md This snippet initializes the ChipWhisperer scope and target objects, then executes a default setup. This is a crucial first step for any interaction with the target device, ensuring proper clock and serial line configurations are established. ```Python import chipwhisperer as cw scope = cw.scope target = cw.target(scope) scope.default_setup() ``` -------------------------------- ### Launching OpenOCD for Intel Quark D2000 Flashing (Windows Batch) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_D2000/README.md This batch script initializes the Intel ISSM environment and then launches OpenOCD, specifying two configuration files: one for the JTAG interface ('olimex-arm-usb-ocd-h.cfg') and another for the D2000 board ('quark_d2000_ufo.cfg'). This command starts the OpenOCD server, which will then wait for further commands to flash the board. ```Batch C:\IntelSWTools\ISSM_2016.2.097\issm_env.bat cd %ISSM_DEBUGGER_ROOT%\openocd bin\openocd.exe -f scripts\interface\ftdi\olimex-arm-usb-ocd-h.cfg -f scripts\board\quark_d2000_ufo.cfg ``` -------------------------------- ### Setting Up ChipWhisperer for STM32F Rev 02 Boards (Python) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_STM32F/README.md This snippet initializes the ChipWhisperer scope and target, performing a default setup specifically as the first step for programming STM32F Rev 02 boards. This ensures the basic communication infrastructure is ready before further steps. ```Python scope = cw.scope() target = cw.target(scope) scope.default_setup() ``` -------------------------------- ### Example Output of OpenOCD Programming Commands Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_D2000/README.md This snippet shows the expected console output when executing the OpenOCD commands via Telnet. It confirms successful JTAG connection, target halting, configuration changes, mass erase operation, JTAG speed adjustment, and the progress of firmware image loading, indicating successful interaction with the target. ```OpenOCD Output > reset halt JTAG tap: quark_d2000.cltap tap/device found: 0x0e786013 (mfg: 0x009, part: 0xe786, ver: 0x0) Enabling lmt core tap JTAG tap: quark_d2000.lmt enabled target state: halted target halted due to debug-request at 0x0000ffff in real mode target state: halted target halted due to debug-request at 0x0000fff0 in real mode > set QUARK_D2000_OTPC_DATA_WRITE_ENABLED 1 1 > mass_erase Deleting OTPC, OTPD and FLASH regions 0xb0100014: 00000001 > clk32M 100 adapter speed: 3 kHz adapter speed: 100 kHz JTAG tap: quark_d2000.cltap tap/device found: 0x0e786013 (mfg: 0x009, part: 0xe786, ver: 0x0) Enabling lmt core tap JTAG tap: quark_d2000.lmt enabled target state: halted target halted due to debug-request at 0x0000fff0 in real mode > load_image C:\\chipwhisperer\\firmware\\mcu\\intel_quark\\quark_d2000_rom.bin 0x0 ....8192 bytes written at address 0x00000000 downloaded 8192 bytes in 66.997505s (0.119 KiB/s) > load_image C:\\chipwhisperer\\firmware\\mcu\\intel_quark\\simpleserial_example\\release\\quark_d2000\\x8 .2872 bytes written at address 0x00180000 downloaded 2872 bytes in 42.280869s (0.066 KiB/s) ``` -------------------------------- ### Programming STM32F Rev 02 Boards (Python) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_STM32F/README.md This snippet programs STM32F devices on Rev 02 boards using the ChipWhisperer's built-in STM32FProgrammer. This step follows the required physical jumper setup and takes the path to the firmware hex file. ```Python prog = cw.programmers.STM32FProgrammer cw.program_target(scope, prog, "") ``` -------------------------------- ### Building ChipWhisperer Projects for TC233LP (Makefile) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_AURIX/README.md This command is used to build standard ChipWhisperer projects specifically for the CW308_AURIX platform, which targets the Infineon TC233LP microcontroller. It configures the build process to utilize the TINYAES128C cryptographic target. Successful execution requires the HighTec's Tricore Tool Chain to be installed and its path added to the system's environment variables. ```Makefile make PLATFORM=CW308_AURIX CRYPTO_TARGET=TINYAES128C ``` -------------------------------- ### Configuring Platform in ChipWhisperer Jupyter Notebook (Python) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_STM32F/README.md This Python snippet from a Jupyter Notebook configures the ChipWhisperer scope type and target platform. It sets `SCOPETYPE` to 'OPENADC' and `PLATFORM` to 'CW308_STM32F4' for an STM32F4 target, overriding the default 'CWLITEARM'. This adjustment is crucial for running tutorials with different hardware setups. ```Python SCOPETYPE = "OPENADC" PLATFORM = "CW308_STM32F4" #For STM32F4 target, was originally "CWLITEARM" ``` -------------------------------- ### SDCC C Variable Declaration Syntax Example Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_87C51/README.md This C code snippet demonstrates a specific syntax limitation of the SDCC (Small Device C Compiler) where variable declarations cannot be intermingled with executable code. It highlights that while initial declarations and operations are valid, subsequent declarations after code execution will result in a syntax error due to SDCC's partial non-compliance with ISO C99/C11 standards. ```C void func() { int x = 1; // OK x += 2; // OK int y = x; // syntax error: token -> 'int' } ``` -------------------------------- ### Launching GDB for Intel Quark D2000 Debugging (Windows Batch) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_D2000/README.md This batch script initializes the Intel ISSM environment and then launches the GDB debugger. This prepares the environment for connecting to the OpenOCD server, which should be running in a separate command prompt, to facilitate debugging and programming of the Intel Quark D2000 board. ```Batch C:\IntelSWTools\ISSM_2016.0.027\issm_env.bat gdb ``` -------------------------------- ### Programming Intel Quark D2000 with GDB and OpenOCD Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_D2000/README.md These GDB console commands connect to the OpenOCD server, set the JTAG clock frequency, and load firmware images onto the Intel Quark D2000 board. The first 'load_image' command is for the ROM image (to be done once), and the second is for the application binary, which can be reloaded as needed. The 'monitor' prefix indicates commands passed directly to OpenOCD. ```GDB target remote :3333 monitor clk32M 125 monitor load_image C:\\chipwhisperer\\\\firmware\\mcu\\intel_quark\\quark_d2000_rom.bin 0x0 monitor load_image C:\\chipwhisperer\\\\firmware\\mcu\\intel_quark\\simpleserial_example\\release\\quark_d2000\\x86\\bin\\simpleserial_aes.bin 0x00180000 ``` -------------------------------- ### Programming NEORV32 with Custom Bitstream (Python) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW312T_ICE40UP/README.md This snippet demonstrates how to program the neorv32 soft-core while also specifying a custom bitstream file (`bsfile`). After opening the programming port, it calls `neorv.program`, providing both the executable binary (`neorv32_exe.bin`) and the newly built FPGA bitstream (`neorv32_iCE40CW312_MinimalBoot.bit`). This allows loading a custom FPGA configuration along with the software. ```Python neorv.open_port() neorv.program("neorv32_exe.bin", bsfile="neorv32_iCE40CW312_MinimalBoot.bit") neorv.close_port() ``` -------------------------------- ### Building ChipWhisperer Firmware for CC2538 Target (Makefile) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_CC2538/README.md This command initiates the build process for ChipWhisperer firmware specifically tailored for the CW308T-CC2538 target. It configures the build system to use the specified platform and integrates the TinyAES128C cryptographic target. This command is executed from the command line within the ChipWhisperer firmware directory. ```Makefile make PLATFORM=CW308_CC2538 CRYPTO_TARGET=TINYAES128C ``` -------------------------------- ### Fixing Makefile for Windows Firmware Build (Makefile) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_D2000/README.md This Makefile snippet provides a fix for common 'No such file or directory' errors encountered when building D2000 firmware on Windows. It replaces the default 'md' and 'copy' commands with 'mkdir -p' and 'cp' respectively, ensuring compatibility with standard Unix-like utilities often available in Git Bash or Cygwin environments. ```Makefile # Any other version of Windows mkdir = @mkdir -p $(1) || exit 0 copy = @cp $(1) $(2) || exit 0 ``` -------------------------------- ### Building SimpleSerial-AES Firmware for STM32 (Make) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_STM32F/README.md This `make` command builds the `simpleserial-aes` firmware for a specified STM32 platform. It sets the `PLATFORM` variable to `CW308_STM32F0` and the `CRYPTO_TARGET` to `TINYAES128C`, enabling the use of a software AES implementation. This command is executed from the firmware's build directory. ```Make make PLATFORM=CW308_STM32F0 CRYPTO_TARGET=TINYAES128C ``` -------------------------------- ### Configuring Windows Batch Environment for MSP430 GCC Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_MSP430/README.md This Windows batch file snippet modifies the system's PATH environment variable to include the directories for MSP430 GCC binaries and the MSP430 Flasher program. Running this batch file opens a command prompt with these tools readily accessible, avoiding permanent system path modifications. ```Batch set PATH=%PATH%;C:\ti\msp430_gcc\bin;C:\ti\MSPFlasher_1.3.10 cmd ``` -------------------------------- ### Programming SiFive FE310 with OpenOCD via ChipWhisperer MPSSE (Shell) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_FE310-G002/README.md This command demonstrates how to program the SiFive FE310 microcontroller using ChipWhisperer's MPSSE mode and OpenOCD. It executes the `run_openocd.sh` script, specifying the firmware ELF file, the 'husky' programmer, JTAG interface, and the `fe310.cfg` configuration file for the target. This method requires ChipWhisperer 5.6.2 or later. ```sh chipwhisperer/openocd/run_openocd.sh -p /path/to/fw.elf husky jtag -- -f "fe310.cfg" ``` -------------------------------- ### Programming CW312T FPGA with ChipWhisperer-Husky in Python Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW312T_XC7A35T/README.md This Python snippet demonstrates how to program the CW312T FPGA using the ChipWhisperer-Husky. It initializes the ChipWhisperer scope, imports the specific FPGA programmer class for the CW312T_XC7A35T, and then calls the `program` method. The method requires the path to the bitfile and optionally accepts an SCK speed for the programming operation. This functionality relies on the `chipwhisperer` library. ```Python import chipwhiserer as cw scope = cw.scope() from chipwhisperer.hardware.naeusb.programmer_targetfpga import CW312T_XC7A35T fpga = CW312T_XC7A35T(scope) fpga.program(, sck_speed=10e6) ``` -------------------------------- ### Rebuilding NEORV32 Soft-Core for CW312iCE40 (Makefile) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW312T_ICE40UP/README.md This command is used to rebuild the neorv32 soft-core specifically for the CW312iCE40 target board. It invokes the `make` utility, setting the `BOARD` variable to `CW312iCE40` and specifying the `MinimalBoot` target, which compiles the core with a minimal bootloader configuration. ```Makefile make BOARD=CW312iCE40 MinimalBoot ``` -------------------------------- ### Transcoding .GBP File for CW308T Panel Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_S6LX9/altium_src/PANEL_ORDER/Transcode Report.txt This snippet details the remapping of designator IDs during the transcoding of the .GBP (Gerber Bottom Paste) file for the CW308T target board panel. It shows how original component designators are mapped to new, standardized IDs. ```Log Output D13 --> D183 D37 --> D184 ``` -------------------------------- ### Styling HTML Elements with CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_Si4010/altium_src/CW308T_Si4010.PcbDoc.htm This CSS snippet defines the visual presentation for various HTML elements within the documentation. It sets font styles, colors, backgrounds, padding, and layout properties for headings, body text, tables, and links, ensuring consistent branding and readability. ```CSS h1, h2, h3, h4, h5, h6 { font-family : 'segoe-ui',arial,sans-serif; font-size:15pt; font-weight:normal; line-height:40px; color : #000; background-color : #dedede; padding: 0.3em; } body { font-family : verdana; background: #f1f1f1; font-size:13px; } td, th { padding: 0.5em; text-align : left; width: auto; border:1px solid #DEDEDE; } th { background-color : #DEDEDE; } th.column1, td.column1 { text-align: left; width : 18%; } table { width : 100%; border-collapse: collapse; font-size:13px; } .front_matter, .front_matter_column1, .front_matter_column2, .front_matter_column3 { padding-top : 0.1em; padding-bottom : 0.1em; border : 0px solid black; width : auto; vertical-align: top } .front_matter_column1 { text-align : right; } .total_column1, .total_column { font-weight : bold; } .total_column1 { text-align : right; } .front_matter_column2 { text-align : center; } .front_matter_column3 { text-align : left; } .warning, .error { color : red; font-weight : bold; } tr.onmouseout_odd { /*background-color : #EEEEE0 */ } tr.onmouseout_even { /*background-color : #F3F3E3 */ } tr.onmouseover_odd, tr.onmouseover_even { background-color : #FFF; } a:link, a:visited, .q a:link,.q a:active,.q { color: #21489e; } a:link.callback, a:visited.callback { color: #008000 } a:link.customize, a:visited.customize { position: absolute; right: 16px; top: 30px; font-family:'segoe ui',arial,tahoma,sans-serif; text-decoration:underline; font-size:11px; color:#0066cc; } p.contents_level1 { font-weight : bold; font-size : 110%; margin : 0.5em; } p.contents_level2 { position : relative; left : 20px; margin : 0.5em; } HR{ border-collapse:collapse; border:none; border-top:1px solid #dedede; } body{ background:#fff; } a:link.customize{ display:none; } table,th,td,hr{ border-color:#999; background:#fff; } ``` -------------------------------- ### Transcoding .GBL File for CW308T Panel Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_S6LX9/altium_src/PANEL_ORDER/Transcode Report.txt This snippet details the remapping of designator IDs during the transcoding of the .GBL (Gerber Bottom Layer) file for the CW308T target board panel. It shows how original component designators are mapped to new, standardized IDs. ```Log Output D13 --> D166 D19 --> D167 D20 --> D168 D22 --> D169 D24 --> D170 D25 --> D171 D26 --> D172 D27 --> D173 D28 --> D174 D29 --> D175 D37 --> D176 ``` -------------------------------- ### Lower-Level Programming Interface for NEORV32 (Python) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW312T_ICE40UP/README.md This code shows how to program the neorv32 soft-core using a more direct, lower-level interface. It imports the `Neorv32Programmer`, initializes a ChipWhisperer scope, opens the programming port, programs the `neorv32_exe.bin` file, and then closes the port. This method provides finer control over the programming process. ```Python import chipwhisperer as cw from chipwhisperer.hardware.naeusb.programmer_neorv32 import Neorv32Programmer cw = cw.scope() cw.default_setup() neorv = cw.programmers.Neorv32Programmer() neorv.open_port() neorv.program("neorv32_exe.bin") neorv.close_port() ``` -------------------------------- ### Initializing Hardware AES with Countermeasures on SAM4L (C) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_ATSAM4L/README.md This C function `aes_init` initializes the hardware AES module on the Atmel SAM4L microcontroller. It enables the AES peripheral clock, configures the AES module for encryption, and optionally enables all available hardware countermeasures by setting `AESA_MODE_CTYPE(0x0F)`. It also sets a random seed for the countermeasures. This function is part of the SimpleSerial-AES program and demonstrates how to configure the SAM4L's built-in security features. ```C void aes_init(void) { periclk_aesa_init(); SCIF->SCIF_GCCTRL[AESA_GCLK_NUM].SCIF_GCCTRL = SCIF_GCCTRL_OSCSEL(GENCLK_SRC_CLK_CPU) | SCIF_GCCTRL_CEN; /* AES Enable */ AESA->AESA_CTRL = AESA_CTRL_ENABLE | AESA_CTRL_NEWMSG; /* Enable, auto-accept new messages */ //Use with debugger to check PARAMETER register value //volatile uint32_t param = AESA->AESA_PARAMETER; /* AES Mode */ AESA->AESA_MODE = AESA_MODE_ENCRYPT | (AESA_MODE_CTYPE(0x0F)); /* Encrypt Mode, with all countermeasures */ //AESA->AESA_MODE = AESA_MODE_ENCRYPT; /* Encrypt Mode, without countermeasures */ /* Setup random seed for countermeasures to work */ AESA->AESA_DRNGSEED = 0xDEADBEEF; //A very random number } ``` -------------------------------- ### Programming Intel Quark D2000 via OpenOCD Telnet Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_D2000/README.md These OpenOCD commands are executed via the Telnet monitor to reset, configure, mass erase, set JTAG clock speed, and load firmware images onto an Intel Quark D2000 target. This sequence is crucial for recovering the device and flashing new binaries, including the ROM and application firmware. ```OpenOCD reset halt set QUARK_D2000_OTPC_DATA_WRITE_ENABLED 1 mass_erase clk32M 100 load_image C:\\chipwhisperer\\firmware\\mcu\\intel_quark\\quark_d2000_rom.bin 0x0 load_image C:\\chipwhisperer\\firmware\\mcu\\intel_quark\\simpleserial_example\\release\\quark_d2000\\x86\\bin\\simpleserial_aes.bin 0x00180000 ``` -------------------------------- ### Transcoding .GBO File for CW308T Panel Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_S6LX9/altium_src/PANEL_ORDER/Transcode Report.txt This snippet details the remapping of designator IDs during the transcoding of the .GBO (Gerber Bottom Overlay) file for the CW308T target board panel. It shows how original component designators are mapped to new, standardized IDs. ```Log Output D23 --> D185 D38 --> D186 D39 --> D187 D41 --> D188 ``` -------------------------------- ### Styling Tables in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This CSS snippet defines general styles for all table elements, setting their width to 100%, collapsing borders, and specifying a font size of 13px. It ensures tables span the full content width and have a compact appearance. ```CSS table { width : 100%; border-collapse: collapse; font-size:13px; } ``` -------------------------------- ### Transcoding .GTP File for CW308T Panel Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_S6LX9/altium_src/PANEL_ORDER/Transcode Report.txt This snippet details the remapping of designator IDs during the transcoding of the .GTP (Gerber Top Paste) file for the CW308T target board panel. It shows how original component designators are mapped to new, standardized IDs. ```Log Output D11 --> D108 D12 --> D109 D13 --> D110 D14 --> D111 D15 --> D112 D16 --> D113 D44 --> D114 D45 --> D115 D46 --> D116 ``` -------------------------------- ### Transcoding .GTL File for CW308T Panel Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_S6LX9/altium_src/PANEL_ORDER/Transcode Report.txt This snippet details the remapping of designator IDs during the transcoding of the .GTL (Gerber Top Layer) file for the CW308T target board panel. It shows how original component designators are mapped to new, standardized IDs. ```Log Output D10 --> D132 D11 --> D133 D12 --> D134 D13 --> D135 D14 --> D136 D15 --> D137 D16 --> D138 D17 --> D139 D18 --> D140 D19 --> D141 D20 --> D142 D21 --> D143 D22 --> D144 D23 --> D145 D24 --> D146 D25 --> D147 D26 --> D148 D27 --> D149 D28 --> D150 D29 --> D151 ``` -------------------------------- ### Programming STM32F Rev 03+ Boards (Python) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_STM32F/README.md This snippet programs STM32F devices on Rev 03 or later boards using the ChipWhisperer's built-in STM32FProgrammer. It requires the full path to the firmware hex file to be provided for successful flashing. ```Python prog = cw.programmers.STM32FProgrammer cw.program_target(scope, prog, "") ``` -------------------------------- ### Programming STM32 via JTAG with OpenOCD (Shell) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_STM32F/README.md This command sequence uses OpenOCD to program an STM32 device via JTAG. It initializes the JTAG interface, targets the device, halts execution, flashes a firmware image (erasing first), verifies the flash, resets and runs the device, and then shuts down OpenOCD. Requires `cw308.cfg` and the firmware `.hex` file. ```Shell openocd -f path/to/board/files/cw308.cfg -c init -c targets -c "halt" -c "flash write_image erase path/to/firmware.hex" -c "verify_image path/to/firmware.hex" -c "reset run" -c shutdown ``` -------------------------------- ### Transcoding .GTO File for CW308T Panel Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_S6LX9/altium_src/PANEL_ORDER/Transcode Report.txt This snippet details the remapping of designator IDs during the transcoding of the .GTO (Gerber Top Overlay) file for the CW308T target board panel. It shows how original component designators are mapped to new, standardized IDs. ```Log Output D20 --> D100 D23 --> D101 D38 --> D102 D39 --> D103 D40 --> D104 D41 --> D105 D42 --> D106 D43 --> D107 ``` -------------------------------- ### Transcoding .GP1 File for CW308T Panel Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_S6LX9/altium_src/PANEL_ORDER/Transcode Report.txt This snippet details the remapping of designator IDs during the transcoding of the .GP1 (Gerber Panel Layer 1) file for the CW308T target board panel. It shows how original component designators are mapped to new, standardized IDs. ```Log Output D30 --> D152 D31 --> D153 D32 --> D154 D33 --> D155 D34 --> D156 D35 --> D157 D36 --> D158 ``` -------------------------------- ### Styling Body Element in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This CSS rule sets the default font family, background color, and font size for the entire document body. It establishes the base visual theme for the page content. ```CSS body { font-family : verdana; background: #f1f1f1; font-size:13px; } ``` -------------------------------- ### Transcoding .GP2 File for CW308T Panel Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_S6LX9/altium_src/PANEL_ORDER/Transcode Report.txt This snippet details the remapping of designator IDs during the transcoding of the .GP2 (Gerber Panel Layer 2) file for the CW308T target board panel. It shows how original component designators are mapped to new, standardized IDs. ```Log Output D30 --> D159 D31 --> D160 D32 --> D161 D33 --> D162 D34 --> D163 D35 --> D164 D36 --> D165 ``` -------------------------------- ### Configuring ChipWhisperer for Intel D2000 Target (Python) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_D2000/README.md This Python script configures the ChipWhisperer scope and target for use with the Intel D2000 board. It sets ADC samples, clock source to external (extclk_x4), trigger, and adjusts the serial baud rate dynamically based on the measured external clock frequency from the D2000, addressing specific clock and serial caveats. ```Python scope.gain.gain = 45 scope.adc.samples = 25000 scope.adc.offset = 0 scope.adc.basic_mode = "rising_edge" scope.clock.clkgen_freq = 7370000 scope.clock.adc_src = "extclk_x4" scope.trigger.triggers = "tio4" #TX/RX backwards from XMEGA scope.io.tio1 = "serial_tx" scope.io.tio2 = "serial_rx" scope.io.hs2 = None # Sample delay - you may need to increase this! # Gives time for frequency measurement to occur in hardware. time.sleep(0.5) ext_freq = scope.clock.freq_ctr if ext_freq > 10: baud = (115200 / 32E6) * ext_freq print "Based on extclk of %d Hz, setting baud to %d" % (ext_freq, baud) target.baud = baud else: raise IOError("Did not detect external clock from D2000.\n Confirm jumpers and rerun, or increase delay before sample.") ``` -------------------------------- ### Styling Warning and Error Messages in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This snippet defines styles for elements with 'warning' or 'error' classes, setting their text color to red and making the font bold. This ensures that important messages are visually prominent. ```CSS .warning, .error { color : red; font-weight : bold; } ``` -------------------------------- ### Transcoding .NCDRILL File for CW308T Panel Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_S6LX9/altium_src/PANEL_ORDER/Transcode Report.txt This snippet details the remapping of tool IDs during the transcoding of the .NCDRILL (NC Drill) file for the CW308T target board panel. It shows how original drill tool IDs are mapped to new, standardized IDs. ```Log Output T3 --> T4 T4 --> T5 ``` -------------------------------- ### Capturing Trace with SimpleSerial v1.0 in Python Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_S6LX9/README.md This Python command demonstrates how to capture a trace using the ChipWhisperer API when the target supports SimpleSerial v1.0 and does not send an acknowledgment (ACK). The 'ack=False' parameter is crucial for proper communication in this scenario, ensuring the capture process proceeds without waiting for an ACK signal from the target. ```Python cw.capture_trace(scope, target, text, key, ack=False) ``` -------------------------------- ### Styling Headings (H1-H6) in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This CSS snippet defines the styles for all heading elements (H1 through H6), setting their font family, size, weight, line height, color, background color, and padding. It ensures a consistent visual appearance for section titles. ```CSS h1, h2, h3, h4, h5, h6 { font-family : 'segoe-ui',arial,sans-serif; font-size:15pt; font-weight:normal; line-height:40px; color : #000; background-color : #dedede; padding: 0.3em; } ``` -------------------------------- ### Styling Front Matter Elements in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This rule applies minimal vertical padding, no border, automatic width, and top vertical alignment to elements associated with 'front_matter' classes. It's used for layout of introductory or metadata sections. ```CSS .front_matter, .front_matter_column1, .front_matter_column2, .front_matter_column3 { padding-top : 0.1em; padding-bottom : 0.1em; border : 0px solid black; width : auto; vertical-align: top } ``` -------------------------------- ### Transcoding .GBS File for CW308T Panel Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_S6LX9/altium_src/PANEL_ORDER/Transcode Report.txt This snippet details the remapping of designator IDs during the transcoding of the .GBS (Gerber Bottom Solder Mask) file for the CW308T target board panel. It shows how original component designators are mapped to new, standardized IDs. ```Log Output D51 --> D177 D57 --> D178 D58 --> D179 D59 --> D180 D60 --> D181 D61 --> D182 ``` -------------------------------- ### Programming Target with Standard ChipWhisperer Interface (Python) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW312T_ICE40UP/README.md This snippet demonstrates how to program the target device using the high-level ChipWhisperer API. It utilizes `cw.program_target` with a scope, a programmer object (`prog`), and the path to the binary file (`simpleserial-aes-CW308_NEORV32.bin`). The `prog` object is typically set to `cw.programmers.NEORV32Programmer`. ```Python cw.program_target(scope, prog, "simpleserial-aes-CW308_NEORV32.bin") ``` -------------------------------- ### Calculating Displayed Byte with 87C51 Encryption Table (Pseudocode) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_87C51/README.md This pseudocode demonstrates how a byte of code memory is processed when read from the 87C51's EPROM, considering the optional 64-byte encryption table. The read data byte is XNORed with a corresponding byte from the encryption table, determined by the address modulo 64. This mechanism acts as an anti-piracy measure if the encryption table is loaded with secret values. ```Pseudocode displayed_byte = ~(data[address] ^ enc_table[address % 64]); ``` -------------------------------- ### Connecting to OpenOCD Monitor via Telnet Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_D2000/README.md This command establishes a Telnet connection to the OpenOCD monitor interface, typically running on port 4444. This allows direct interaction with the JTAG debugger to issue commands for target control and programming, especially useful for recovery or advanced operations. ```Telnet telnet localhost 4444 ``` -------------------------------- ### Styling Customize Links in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This rule positions 'customize' links absolutely, 16px from the right and 30px from the top, applying a specific font, underline text decoration, smaller font size, and a distinct blue color. It's used for a specific UI element. ```CSS a:link.customize, a:visited.customize { position: absolute; right: 16px; top: 30px; font-family:'segoe ui',arial,tahoma,sans-serif; text-decoration:underline; font-size:11px; color:#0066cc; } ``` -------------------------------- ### OpenOCD Configuration for CW308 Board (OpenOCD Config) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_STM32F/README.md This configuration file (`cw308.cfg`) for OpenOCD specifies the JTAG interface (Olimex ARM-USB-OCD-H) and the target microcontroller (STM32F4x). It also configures the reset behavior to use only SRST (System Reset). This file is used in conjunction with the OpenOCD programming command. ```OpenOCD Config source [find interface/olimex-arm-usb-ocd-h.cfg] source [find target/stm32f4x.cfg] reset_config srst_only ``` -------------------------------- ### Styling Table Cells (TD, TH) in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This snippet applies padding, left text alignment, automatic width, and a light grey border to all table data (td) and table header (th) cells. It provides a clean, structured look for table content. ```CSS td, th { padding: 0.5em; text-align : left; width: auto; border:1px solid #DEDEDE; } ``` -------------------------------- ### Styling Total Columns in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This snippet sets the font weight to bold for elements with classes 'total_column1' and 'total_column'. It's used to highlight summary or total values in tables or lists. ```CSS .total_column1, .total_column { font-weight : bold; } ``` -------------------------------- ### Transcoding .GTS File for CW308T Panel Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_S6LX9/altium_src/PANEL_ORDER/Transcode Report.txt This snippet details the remapping of designator IDs during the transcoding of the .GTS (Gerber Top Solder Mask) file for the CW308T target board panel. It shows how original component designators are mapped to new, standardized IDs. ```Log Output D47 --> D117 D48 --> D118 D49 --> D119 D50 --> D120 D51 --> D121 D52 --> D122 D53 --> D123 D54 --> D124 D55 --> D125 D56 --> D126 D57 --> D127 D58 --> D128 D59 --> D129 D60 --> D130 D61 --> D131 ``` -------------------------------- ### Styling General Links in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This snippet defines the default color for unvisited and visited hyperlinks, as well as links within elements having the class 'q'. It ensures a consistent blue color for general navigation links. ```CSS a:link, a:visited, .q a:link,.q a:active,.q { color: #21489e; } ``` -------------------------------- ### Setting GCC Include Path in Makefile Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_MSP430/README.md This Makefile snippet defines the INC_PATH variable, which specifies the directory where MSP430 GCC header files are located. This is crucial for the compiler to find necessary header files during the build process, especially since the provided GCC might not add them by default. ```Makefile INC_PATH = C:/ti/msp430_gcc/include/ ``` -------------------------------- ### Configuring OpenOCD JTAG Speed for Intel Quark D2000 Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_D2000/README.md This snippet shows how to modify the 'adapter_khz' setting in the OpenOCD board configuration file ('quark_d2000.cfg') to reduce the JTAG clock speed from 1000 kHz to 125 kHz. This adjustment is recommended for stability, especially when programming the ROM image, and the modified file should be saved as 'quark_d2000_ufo.cfg'. ```OpenOCD Config #default frequency but this can be adjusted at runtime adapter_khz 125 ``` -------------------------------- ### Converting Coordinates to Mils in JavaScript Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW312T_RP2350/altium_src/RPi_CWHUSKY_Target.html This function takes a raw coordinate value, divides it by 10000 to convert it to mils, and then formats the number to three decimal places before appending 'mil' as a unit string. It ensures consistent formatting for display. ```JavaScript function coordToMils(coord) { var number = coord / 10000; if (number != number.toFixed(3)) number = number.toFixed(3); return number + 'mil' } ``` -------------------------------- ### Programming STM32F Rev 03+ with Lower Baud Rate (Python) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_STM32F/README.md To address programming errors, this snippet retries flashing STM32F Rev 03 or later boards using a reduced baud rate of 38400. A lower baud rate can improve programming stability over unreliable connections. ```Python prog = cw.programmers.STM32FProgrammer cw.program_target(scope, prog, "", baud=38400) ``` -------------------------------- ### Styling Contents Level 1 Paragraphs in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This snippet styles paragraphs with the class 'contents_level1', making their text bold, increasing their font size by 10%, and applying a 0.5em margin. It's used for top-level entries in a table of contents. ```CSS p.contents_level1 { font-weight : bold; font-size : 110%; margin : 0.5em; } ``` -------------------------------- ### Styling First Column (column1) in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This rule targets table header and data cells with the class 'column1', aligning their text to the left and setting their width to 18%. It's used for specific column formatting. ```CSS th.column1, td.column1 { text-align: left; width : 18%; } ``` -------------------------------- ### Aligning Front Matter Column 2 in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This CSS rule centers the text content for elements with the class 'front_matter_column2'. It's useful for central alignment of specific data points in the front matter section. ```CSS .front_matter_column2 { text-align : center; } ``` -------------------------------- ### Overriding Table, Cell, and HR Borders/Backgrounds in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This snippet applies a darker grey border color (#999) and a white background (#fff) to tables, table headers, table data cells, and horizontal rules. This provides a consistent border and background theme for these elements. ```CSS table,th,td,hr{ border-color:#999; background:#fff; } ``` -------------------------------- ### Converting Coordinates to Millimeters in JavaScript Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW312T_RP2350/altium_src/RPi_CWHUSKY_Target.html This function converts a raw coordinate value to millimeters by applying a conversion factor (0.0254 mm per mil). It then formats the resulting number to four decimal places and appends 'mm' as the unit string, ensuring precise metric representation. ```JavaScript function coordToMM(coord) { var number = 0.0254 * coord / 10000; if (number != number.toFixed(4)) number = number.toFixed(4); return number + 'mm' } ``` -------------------------------- ### Aligning Front Matter Column 1 in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This CSS rule specifically aligns the text content of elements with the class 'front_matter_column1' to the right. This is typically used for labels or values in a key-value pair layout. ```CSS .front_matter_column1 { text-align : right; } ``` -------------------------------- ### Styling Callback Links in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This CSS rule specifically sets the color of unvisited and visited links with the class 'callback' to green. This is used to visually distinguish links that trigger specific callback functions. ```CSS a:link.callback, a:visited.callback { color: #008000 } ``` -------------------------------- ### Styling Contents Level 2 Paragraphs in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This rule styles paragraphs with the class 'contents_level2', relatively positioning them 20px from the left and applying a 0.5em margin. This creates an indentation for sub-level entries in a table of contents. ```CSS p.contents_level2 { position : relative; left : 20px; margin : 0.5em; } ``` -------------------------------- ### Aligning Front Matter Column 3 in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This rule aligns the text content for elements with the class 'front_matter_column3' to the left. This provides standard left alignment for data in the front matter section. ```CSS .front_matter_column3 { text-align : left; } ``` -------------------------------- ### Toggling Target Power for STM32F Rev 02 Boards (Python) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_STM32F/README.md This code snippet cycles the target device's power, turning it off for one second and then back on. This action serves as a software-controlled reset mechanism for STM32F Rev 02 boards, useful when a physical reset button is unavailable. ```Python import time scope.io.target_pwr = False time.sleep(1) scope.io.target_pwr = True ``` -------------------------------- ### Styling Table Rows On Mouse Over in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This CSS rule sets the background color of both odd and even table rows to white when the mouse cursor hovers over them. This provides visual feedback to the user, indicating the active row. ```CSS tr.onmouseover_odd, tr.onmouseover_even { background-color : #FFF; } ``` -------------------------------- ### Aligning Total Column 1 in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This rule aligns the text content of elements with the class 'total_column1' to the right. This is often used in conjunction with bold text to format numerical totals. ```CSS .total_column1 { text-align : right; } ``` -------------------------------- ### Updating Coordinate Display in JavaScript Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW312T_RP2350/altium_src/RPi_CWHUSKY_Target.html This function dynamically updates the text content of a given HTML element ('coordNode') to display a coordinate value in either millimeters or mils. It first clears existing child nodes, then retrieves the 'value' attribute, and uses 'coordToMM' or 'coordToMils' to format and append the new text node. ```JavaScript function convertCoord(coordNode, units) { for (var i = 0; i < coordNode.childNodes.length; i++) { coordNode.removeChild(coordNode.childNodes[i]); } var coord = coordNode.getAttribute('value'); if (coord != null) { if (units == 'mm') { textNode = document.createTextNode(coordToMM(coord)); coordNode.appendChild(textNode); } else if (units == 'mil') { textNode = document.createTextNode(coordToMils(coord)); coordNode.appendChild(textNode); } } } ``` -------------------------------- ### Styling Horizontal Rules (HR) in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This CSS snippet styles horizontal rule (HR) elements, collapsing their borders, removing all borders except for a 1px solid light grey top border. This creates a subtle separator line. ```CSS HR{ border-collapse:collapse; border:none; border-top:1px solid #dedede; } ``` -------------------------------- ### Disassembling SREC File with S32DS objdump Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_MPC5Y/README.md This command line demonstrates how to disassemble a memory segment from an SREC file (.s19) using the powerpc-eabivle-objdump.exe tool, which is part of the S32DS PowerPC cross-tools. It outputs the disassembled code to a text file. This process is particularly useful for debugging and analyzing compiled firmware. ```Shell E:\nxp\S32DS_Power_v2017.R1\Cross_Tools\powerpc-eabivle-4_9\bin>powerpc-eabivle-objdump.exe -mpowerpc -Me200z4 -D -b srec -EB MPC5748G.s19 > MPC5748G.txt ``` -------------------------------- ### Disassembling PowerPC SREC File using objdump (Command Line) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_MPC57/README.md This command line snippet demonstrates how to disassemble a memory segment from an SREC file (.s19) using the powerpc-eabivle-objdump.exe tool, which is part of the S32DS Power tools. It targets the PowerPC e200z4 architecture, outputs the disassembly to a text file, and is useful for debugging embedded systems. ```Shell E:\nxp\S32DS_Power_v2017.R1\Cross_Tools\powerpc-eabivle-4_9\bin>powerpc-eabivle-objdump.exe -mpowerpc -Me200z4 -D -b srec -EB MPC5748G.s19 > MPC5748G.txt ``` -------------------------------- ### Hiding Customize Links in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This CSS rule sets the 'display' property of 'customize' links to 'none', effectively hiding them from the page. This is used to remove a specific UI element from view. ```CSS a:link.customize{ display:none; } ``` -------------------------------- ### Global Unit Conversion Handler in JavaScript Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW312T_RP2350/altium_src/RPi_CWHUSKY_Target.html This function serves as the primary handler for changing display units across the entire document. When a radio input is checked, it iterates through all elements named 'coordinate' and 'units', applying the 'convertCoord' and 'convertUnits' functions respectively to update their displayed values and labels to the newly selected unit. ```JavaScript function changeUnits(radio_input, units) { if (radio_input.checked) { var elements = document.getElementsByName('coordinate'); if (elements) { for (var i = 0; i < elements.length; i++) { convertCoord(elements[i], units); } } var elements = document.getElementsByName('units'); if (elements) { for (var i = 0; i < elements.length; i++) { convertUnits(elements[i], units); } } } } ``` -------------------------------- ### Overriding Body Background Color in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This rule explicitly sets the background color of the document body to white (#fff). This might override a previous background definition, ensuring a clean white page background. ```CSS body{ background:#fff; } ``` -------------------------------- ### Adjusting Clock for STM32F1 Bootloader (Python) Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_STM32F/README.md This code temporarily sets the ChipWhisperer clock generator frequency to 8MHz, a requirement for the STM32F1 bootloader. After programming, the frequency is reset to the standard 7.37MHz (F_CPU) for normal device operation. ```Python scope.default_setup() scope.clock.clkgen_freq = 8E6 #program target... scope.clock.clkgen_freq = 7.37E6 #reset and run as usual ``` -------------------------------- ### Styling Even Table Rows On Mouse Out (Commented) in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm Similar to the odd rows, this commented-out CSS rule was designed to apply a slightly different light grey background to even-numbered table rows when the mouse is not hovering. It complements the alternating row style. ```CSS tr.onmouseout_even { /*background-color : #F3F3E3 */ } ``` -------------------------------- ### Styling Table Headers (TH) Background in CSS Source: https://github.com/newaetech/chipwhisperer-target-cw308t/blob/main/CW308T_PIC24FJ/altium_src/newae_pcbtemplate.PcbDoc.htm This CSS rule specifically sets the background color of table header (th) cells to a light grey. This helps visually distinguish headers from regular table data. ```CSS th { background-color : #DEDEDE; } ```