### Installing Depthcharge from GitHub (Latest Changes) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/introduction.rst This snippet outlines the process to install the latest development version of Depthcharge from the `next` branch of its GitHub repository. It clones the repository, navigates to the Python directory, sets up a virtual environment, and installs the package. ```Shell $ git clone -b next https://github.com/nccgroup/depthcharge $ cd depthcharge/python $ python3 -m venv ./venv $ source ./venv/bin/activate $ python3 -m pip install . ``` -------------------------------- ### Installing Depthcharge via PyPi Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/introduction.rst This snippet demonstrates how to install the latest stable release of Depthcharge from the Python Package Index (PyPi) into a new Python virtual environment. It creates a `venv`, activates it, and then installs the `depthcharge` package using pip. ```Shell $ python3 -m venv depthcharge-venv $ source ./depthcharge-venv/bin/activate $ python3 -m pip install depthcharge ``` -------------------------------- ### Installing Documentation Dependencies with Pip (Bash) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/README.md This command installs the necessary Python packages, Sphinx and `sphinx_rtd_theme`, required to build the Depthcharge documentation. It's crucial to install these within a virtual environment if one is being used for Depthcharge development to ensure `sphinx-build` can locate the `depthcharge` module. ```bash pip install sphinx sphinx_rtd_theme ``` -------------------------------- ### Example: Searching U-Boot Command Tables (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-find-cmd.txt This command demonstrates how to use `depthcharge-find-cmd` to search for U-Boot command tables. It targets an ARM architecture, specifies a base address of `0x8780000`, uses `dump.bin` as the input file, and requests detailed output. This is useful for analyzing firmware dumps. ```Shell depthcharge-find-cmd --arch arm -a 0x8780000 -f dump.bin --details ``` -------------------------------- ### Setting up Depthcharge for Development Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/introduction.rst This snippet shows how to install Depthcharge in editable mode with documentation dependencies, suitable for developers planning to contribute changes to the code or documentation. It assumes a virtual environment is already active. ```Shell $ python3 -m pip install -e .[docs] ``` -------------------------------- ### Printing Multiple Information Items with depthcharge-print (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-print.txt This example demonstrates two equivalent ways to print multiple specific information items (architecture, U-Boot version, and expanded environment variables) from a device configuration. Items can be comma-separated or specified with multiple `-i` flags. ```Shell depthcharge-print -c dev.cfg -i arch,version,env=expand ``` ```Shell depthcharge-print -c dev.cfg -i arch -i version -i env=expand ``` -------------------------------- ### Example: Writing File Contents to Memory Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-write-mem.txt This example demonstrates writing the entire content of `data.bin` to memory address `0x87f00000` using the `depthcharge-write-mem` utility, specifying the device configuration `dev.cfg`. ```Shell depthcharge-write-mem -c dev.cfg -a 0x87f00000 -f data.bin ``` -------------------------------- ### Example: Writing Data with Stratagem Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-write-mem.txt This example illustrates writing data to memory address `0x87f01400` by leveraging a stratagem defined in `stratagem.json` with `depthcharge.memory.CRC32MemoryWriter` via `depthcharge-write-mem` and `dev.cfg`. ```Shell depthcharge-write-mem -c dev.cfg -a 0x87f01400 -s stratagem.json ``` -------------------------------- ### Initializing Depthcharge Companion Firmware (Teensy 3.6) - C++ Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/companion_fw.rst This C++ (Arduino) snippet demonstrates the basic setup and main loop for the Depthcharge Companion Firmware on a Teensy 3.6 board. It initializes the USB serial interface, instantiates and configures the Depthcharge::Companion object with Serial, Wire (I2C), and an LED, and continuously processes events in the main loop. It requires the Arduino environment, Teensyduino add-ons, and the Depthcharge library. ```cpp #include #include // Required for I2C communication #include // The Depthcharge library // Instantiate the Depthcharge::Companion object Depthcharge::Companion companion; void setup() { // 1. Initialize the (USB) serial interface for host communication Serial.begin(115200); // Standard baud rate for USB serial // 3. Attach the desired Serial, Wire (I2C), and LED instances to the Companion companion.attachSerial(Serial); companion.attachWire(Wire); // Attach the default Wire (I2C) instance // Assuming an LED is used for status, e.g., built-in LED on pin 13 pinMode(LED_BUILTIN, OUTPUT); companion.attachLED(LED_BUILTIN); // Initialize I2C as a slave device (if the companion acts as a peripheral) // The address (e.g., 0x08) would be specific to the application. Wire.begin(0x08); // Example I2C slave address } void loop() { // 5. Call Depthcharge::Companion::processEvents() in the main loop // This function handles incoming commands and processes events. companion.processEvents(); } ``` -------------------------------- ### Creating and Activating Python Virtual Environment Source: https://github.com/nccgroup/depthcharge/blob/main/python/README.md These commands create a new Python virtual environment named 'venv' in the current directory, activate it, and then install the Depthcharge package from the current directory into the activated environment. This isolates project dependencies. ```Shell python3 -m venv ./venv source ./venv/bin/activate python3 -m pip install . ``` -------------------------------- ### Installing Python venv on Debian/Ubuntu Source: https://github.com/nccgroup/depthcharge/blob/main/python/README.md This command installs the `python3-venv` package on Debian-based Linux distributions, which is necessary for creating Python virtual environments. It requires superuser privileges. ```Shell sudo apt install python3-venv ``` -------------------------------- ### Example: Writing Specific Hex Bytes to Memory Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-write-mem.txt This example shows how to write the hexadecimal byte sequence `0100a0e3` (representing `[0x01, 0x00, 0xa0, 0xe3]`) to memory address `0x87f00000` using `depthcharge-write-mem` and `dev.cfg`. ```Shell depthcharge-write-mem -c dev.cfg -a 0x87f00000 -d 0100a0e3 ``` -------------------------------- ### Installing Depthcharge in Editable Mode with Documentation Dependencies Source: https://github.com/nccgroup/depthcharge/blob/main/python/README.md This command installs the Depthcharge package in editable mode, allowing for source code modifications to take effect without reinstallation. It also includes the `[docs]` extra, pulling in dependencies required for building the documentation (Sphinx, sphinx_rtd_theme). ```Shell python3 -m pip install -e .[docs] ``` -------------------------------- ### Example: Requesting Specific MemoryWriter Operation Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-write-mem.txt This example demonstrates how to explicitly request the `depthcharge.memory.LoadbMemoryWriter` operation (using `--op loadb`) to write `data.bin` to address `0x8200_0000`. The `MemoryWriter` suffix is optional and the argument is case-insensitive. ```Shell depthcharge-write-mem -c dev.cfg --op loadb -a 0x8200_0000 -f data.bin ``` -------------------------------- ### Capturing Serial Console Monitor Output (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/troubleshooting.rst This example illustrates how to capture all serial console communication data to a file using Depthcharge's `FileMonitor`. The `depthcharge-inspect` command is used with the `-m file:monitor.txt` option to log all data exchanged with the target device to `monitor.txt`. This is crucial for debugging unexpected failures related to U-Boot version differences. ```Shell depthcharge-inspect -c my_device.cfg -m file:monitor.txt ``` -------------------------------- ### Reading Memory and Displaying Hex Dump (Suffixes) - Shell Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-read-mem.txt This example demonstrates reading memory using supported address and length suffixes. It reads 16 KiB (16K) of data from 2080 MiB (2080M) using 'dev.cfg', producing a hex dump. This command is functionally equivalent to reading 16384 bytes from 0x82000000. ```Shell depthcharge-read-mem -c dev.cfg -a 2080M -l 16K ``` -------------------------------- ### Configuring Hunter Parameters with -X (Shell Argument) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-stratagem.txt This snippet illustrates the usage of the `-X` or `--extra` argument to pass additional, Hunter-specific parameters to the `depthcharge-stratagem` utility. In this example, `revlut_maxlen` is set to 512 and `max_iterations` to 8192, which can help in successfully generating a Stratagem when default settings fail, particularly for Depthcharge's CRC32MemoryWriter. ```Shell -X revlut_maxlen=512,max_iterations=8192 ``` -------------------------------- ### Extracting Only DTS Files with Base Address (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-find-fdt.txt Similar to the previous example, this command extracts FDT instances from `image.bin` with a base address of `0xa000` and an output prefix of 'image_'. However, it uses the `--no-dtb` option to prevent the saving of `.dtb` files, resulting in only `.dts` files being generated. The CPU architecture is 'arm'. ```Shell depthcharge-find-fdt --arch arm -a 0xa000 -f image.bin -o image --no-dtb ``` -------------------------------- ### Printing All Information with depthcharge-print (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-print.txt This command demonstrates how to print all available information from a specified device configuration file (`dev.cfg`) using the `depthcharge-print` utility. The `-c` flag specifies the configuration file, and `-i all` requests all supported information items. ```Shell depthcharge-print -c dev.cfg -i all ``` -------------------------------- ### U-Boot 2013.07 Build Configuration Source: https://github.com/nccgroup/depthcharge/blob/main/python/tests/resources/dotconfig-03.txt This snippet defines the build-time configuration options for U-Boot 2013.07. It includes settings for features like FIT signatures and legacy image format support. Options prefixed with 'CONFIG_' are enabled if set to 'y' and disabled if commented out or explicitly marked 'is not set'. ```Kconfig # # Artisanlly generated file; DO NOT EDIT. # U-Boot 2013.07 Configuration # CONFIG_FOO=y # CONFIG_BAR is not set CONFIG_FIT_SIGNATURE=y CONFIG_BAZ=y CONFIG_LEGACY_IMAGE_FORMAT=y ``` -------------------------------- ### Building HTML Documentation with Make (Bash) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/README.md This command initiates the build process for the Depthcharge documentation using GNU Make. It generates HTML output, which will be saved in the `build/html/` directory, with `index.html` as the main landing page. ```bash make html ``` -------------------------------- ### Creating U-Boot Environment (Non-Redundant) - Shell Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-mkenv.txt This command creates a U-Boot environment binary (`env.bin`) from a text file (`env.txt`). It specifies an environment size of 0x2000 bytes, suitable for targets where U-Boot was not configured with `CONFIG_SYS_REDUNDAND_ENV`. The output file `env.bin` can then be inserted into the target device's NV storage. ```Shell depthcharge-mkenv -S 0x2000 -f env.txt -o env.bin ``` -------------------------------- ### U-Boot 2019.04 Kconfig Options Source: https://github.com/nccgroup/depthcharge/blob/main/python/tests/resources/dotconfig-04.txt This snippet shows a partial configuration for U-Boot 2019.04, enabling features like FIT signatures and SPL EXT4 filesystem support, while explicitly disabling others like 'CONFIG_BAR' and 'CONFIG_LEGACY_IMAGE_FORMAT'. ```Kconfig # # Artisanlly generated file; DO NOT EDIT. # U-Boot 2019.04 Configuration # CONFIG_FOO=y # CONFIG_BAR is not set CONFIG_FIT_SIGNATURE=y CONFIG_BAZ=y # CONFIG_LEGACY_IMAGE_FORMAT=y CONFIG_SPL_FS_EXT4=y ``` -------------------------------- ### Printing All U-Boot Environment Instances (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-find-env.txt This command searches for and prints all U-Boot environment instances found within the specified binary image file, `mtdblock0.bin`. It represents a basic usage to discover all environments without any special processing or output file generation. ```Shell depthcharge-find-env -f mtdblock0.bin ``` -------------------------------- ### Building Arduino Firmware with Makefile and Environment Variable (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/firmware/Arduino/README.md This snippet demonstrates how to build Arduino firmware using a Makefile by first setting the 'ARDUINO_BUILDER' environment variable to the path of the 'arduino-builder' program, and then invoking 'make' for a specific target platform (e.g., 'teensy36'). This method is suitable for automated builds or command-line workflows. ```Shell export ARDUINO_BUILDER=/path/to/arduino-builder make teensy36 ``` -------------------------------- ### Auditing U-Boot Header File with Dummy Header (Bash) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-audit-config.txt This command audits a U-Boot platform configuration header file, specifically `mx53evk.h`, for security risks. It specifies the U-Boot version as 2011.03, includes multiple paths for header resolution, and uses `--dummy-hdr` to provide an empty file for `asm/arch/imx-regs.h` to satisfy a problematic `#include` directive. The results are saved to an HTML file. ```Bash depthcharge-audit-config -V 2011.03 -H ./include/configs/mx53evk.h \ -I ./include -I ./arch/arm/include \ --dummy-hdr 'asm/arch/imx-regs.h' \ -o ~/audit-summary.html ``` -------------------------------- ### Setting U-Boot String and Numeric Values - Kconfig Source: https://github.com/nccgroup/depthcharge/blob/main/python/tests/resources/dotconfig-02.txt This snippet demonstrates how to assign string and numeric values to U-Boot configuration variables. String values can be enclosed in double quotes, while numeric values are assigned directly. These variables often define specific parameters or identifiers used by U-Boot components. ```Kconfig CONFIG_ROYAL_TENENBAUM="Hell of a damn grave. Wish it were mine." CONFIG_MY_VOICE=IS_MY_PASSPORT CONFIG_SPACE_ODYSSEY=2001 ``` -------------------------------- ### Inspecting with Companion Device and I2C Configuration (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-inspect.txt This command inspects an ARM device, allowing reboots and payload deployment, and saves the configuration to `dev.cfg`. It integrates a companion device attached to `/dev/ttyACM1`, configuring it to operate on I2C bus #2 at a speed of 250kHz. The default serial interface settings are used as `-i` is omitted. ```Shell depthcharge-inspect --arch arm -AR -c dev.cfg \ -C /dev/ttyACM1:i2c_bus=2,i2c_speed=250000 ``` -------------------------------- ### Identifying U-Boot Command Tables with Depthcharge (Text Output) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/introduction.rst This snippet presents an abridged output from Depthcharge's `cmd` script, executed with the `--detail` argument. It demonstrates how Depthcharge identifies and extracts detailed information about U-Boot command handler tables, including their memory address, size, entry count, and specific command details like 'nboot', its arguments, and usage string. ```text Command table @ 0x8ff684bc (file offset 0x000684bc) - 308 bytes, 11 entries CONFIG_SYS_LONGHELP=True, CONFIG_AUTO_COMPLETE=True ... [7] @ 0x8ff68580 name: nboot maxargs: 4 cmd_rep: 0x00000001 cmd: 0x8ff6502c complete: 0x00000000 usage: boot from NAND device ``` -------------------------------- ### Inspecting Device with Default Settings (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-inspect.txt This command inspects a device's console environment and saves the results to `dev.cfg`. It uses default serial interface settings (`/dev/ttyUSB0` at 115200 baud), a generic 32-bit little-endian CPU architecture, and avoids operations requiring reboots or payload deployment/execution. ```Shell depthcharge-inspect -c dev.cfg ``` -------------------------------- ### Saving Raw Binary U-Boot Environments with Summary (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-find-env.txt This command extracts and saves the raw binary U-Boot environment instances, including their metadata (like CRC32 and flags), to individual files. It also prints only a summary of the extracted items to the console, suppressing the full environment contents. Files will be named `uboot_env_
.bin`. ```Shell depthcharge-find-env -o uboot_env -S -B -f mtdblock0.bin ``` -------------------------------- ### Writing Memory from File (Usage) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-write-mem.txt This usage pattern demonstrates how to write the contents of a specified file to a target memory address using `depthcharge-write-mem`. It requires a device configuration file, the target address, and the path to the data file. ```Shell depthcharge-write-mem [options] -c -a
-f ``` -------------------------------- ### Building Arduino Firmware with Makefile and Inline Variable (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/firmware/Arduino/README.md This snippet shows an alternative method to build Arduino firmware using a Makefile, where the 'ARDUINO_BUILDER' path is specified directly within the 'make' invocation. This approach is useful for one-off builds or when avoiding persistent environment variable changes. ```Shell make ARDUINO_BUILDER=/path/to/arduino-builder teensy36 ``` -------------------------------- ### Auditing U-Boot .config File (Bash) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-audit-config.txt This command audits a U-Boot Kconfig `.config` file for security risks. It specifies the U-Boot version as 2019.07, provides the path to the `.config` file, and directs the output to a Markdown file named `report.md`. This is generally the simpler and more reliable method for auditing U-Boot configurations. ```Bash depthcharge-audit-config -V 2019.07 -u /path/to/uboot/.config -o report.md ``` -------------------------------- ### Printing Detailed Console Commands with depthcharge-print (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-print.txt This command retrieves and prints detailed help text for all console commands supported by a device, as defined in `dev.cfg`. The `-i commands=details` option ensures that full details, not just a summary, are included. ```Shell depthcharge-print -c dev.cfg -i commands=details ``` -------------------------------- ### Writing Memory with a Stratagem (Usage) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-write-mem.txt This usage pattern illustrates how to write a payload using a specified stratagem file. It requires a device configuration file, the target address, and the path to the stratagem JSON file. ```Shell depthcharge-write-mem [options] -c -a
-s ``` -------------------------------- ### Converting U-Boot Environment (No Header) - Shell Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-mkenv.txt This command converts a 2 KiB environment from `env.txt` to `env.bin`. The `-H` (or `--no-hdr`) option prevents the tool from prepending a CRC32 checksum or a flag word to the output, which is useful for specific U-Boot configurations or debugging scenarios where raw environment data is preferred. ```Shell depthcharge-mkenv -S 2K -H -f env.txt -o env.bin ``` -------------------------------- ### Inspecting with Custom U-Boot Prompt String (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-inspect.txt This command inspects an ARM device, allowing reboots and payload deployment, saving the configuration to `my_config.cfg`. It overrides the default U-Boot prompt detection by explicitly specifying `ACMEcorp >` as the expected prompt string. ```Shell depthcharge-inspect --arch arm -AR --prompt "ACMEcorp >" -c my_config.cfg ``` -------------------------------- ### Inspecting ARM Device with Custom Serial and Permissions (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-inspect.txt This command inspects a 32-bit ARM device, using the serial console at `/dev/ttyUSB2` with a baud rate of 19200. It saves the configuration to `dev.cfg` and explicitly allows operations that require crashing/rebooting the platform (`-R`) as well as payload deployment and execution (`-A`). ```Shell depthcharge-inspect --arch arm -AR -i /dev/ttyUSB2:19200 -c dev.cfg ``` -------------------------------- ### Printing FDT Locations with depthcharge-find-fdt (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-find-fdt.txt This command demonstrates how to use `depthcharge-find-fdt` to scan a binary image for Flattened Device Tree (FDT) instances and print their locations and sizes to standard output. It specifies the CPU architecture as 'arm' and the input image file. ```Shell depthcharge-find-fdt --arch arm -f image.bin ``` -------------------------------- ### Running All Unit Tests for Depthcharge Module (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/python/tests/unit/README.md This command executes all unit tests within the `unit` directory for the `depthcharge` module using Python's `unittest` framework. It's the standard way to run the entire test suite. ```Shell python3 -m unittest unit ``` -------------------------------- ### Expanding and Saving U-Boot Environment Variables (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-find-env.txt This command expands environment variable definitions, resolving all defined variable usages, and saves the processed text output to individual files. The output files will be prefixed with `uboot_env` and include the address and `_exp.txt` suffix, indicating expanded content. ```Shell depthcharge-find-env -E -o uboot_env -f mtdblock0.bin ``` -------------------------------- ### Identifying U-Boot Exported Jump Table Functions (Text Output) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/introduction.rst This text snippet presents an excerpt from a Depthcharge-generated device configuration file. It lists the base address of the U-Boot global data structure, the pointer to its exported jump table, and a comprehensive list of functions available through this table, along with their memory addresses and C-style signatures. This information is vital for reverse engineers to understand U-Boot's internal API and to craft custom standalone programs that can call these functions. ```text Global Data Structure information ================================================================================ Address: 0x8ef55ee8 Jump Table Pointer: 0x8ef81710 Jump Table Entries: 0x8ff73350 unsigned long get_version() 0x8ff79330 int getc() 0x8ff79378 int tstc() 0x8ff792d8 void putc(const char) 0x8ff792a4 void puts(const char *) 0x8ff9ce50 int printf(const char *, va_list) 0x8ff7334c void irq_install_handler(int, void*, void *) 0x8ff7334c void irq_free_handler(int) 0x8ff79b84 void * malloc(size_t) 0x8ff7993c void free(void *) 0x8ff9c158 void udelay(unsigned long) 0x8ff9c0a4 unsigned long get_timer(unsigned long) 0x8ff9ce94 int vprintf(const char *, va_list) 0x8ff68970 int do_reset(void *) 0x8ff7311c char * env_get(const char *) 0x8ff72ce0 int env_set(const char *, const char *) 0x8ff9cff4 unsigned long simple_strtoul(const char *, const char **, unsigned int) 0x8ff9d0ac int strict_strtoul(const char *, const char **, unsigned int, unsigned long *) 0x8ff9d124 long simple_strtol(const char *, const char **, unsigned int) 0x8ff9bc7c int strcmp(const char *, const char *) 0x8ff7334c int i2c_write(unsigned char, unsigned int, int, unsigned char *, int) 0x8ff7334c int i2c_read(unsigned char, unsigned int, int, unsigned char *, int) 0x8ff7334c void * spi_setup_slave(uint, uint, uint, uint) 0x8ff7334c void spi_free_slave(void *) 0x8ff7334c int spi_claim_bus(void *) 0x8ff7334c void spi_release_bus(void *) 0x8ff7334c int spi_xfer(void *) 0x8ff7334c unsigned long ustrtoul(const char *, char **, unsigned int) 0x8ff9d14c unsigned long long ustrtoull(const char *, char **, unsigned int) 0x8ff9d298 char * strcpy(char *, const char *) 0x8ff9bbbc void mdelay(unsigned long) 0x8ff9c188 void * memset(void *, int, size_t) ``` -------------------------------- ### Defining U-Boot Boolean Features - Kconfig Source: https://github.com/nccgroup/depthcharge/blob/main/python/tests/resources/dotconfig-02.txt This snippet illustrates how to enable or disable specific features within the U-Boot configuration. Features set to 'y' are enabled, while commented-out lines with '# is not set' indicate disabled features. These settings directly impact the compiled U-Boot image. ```Kconfig CONFIG_FOO=y # CONFIG_BAR is not set CONFIG_FIT_SIGNATURE=y CONFIG_BAZ=y ``` -------------------------------- ### Creating U-Boot Environment (Redundant) - Shell Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-mkenv.txt This command generates a U-Boot environment binary (`env.bin`) from `env.txt` for targets using `CONFIG_SYS_REDUNDAND_ENV` and an environment size of 0x10000 bytes. The `-F 0x5` option sets the flags byte, which is crucial for redundant environments, requiring its value to be greater than or equal to the active environment's flags. ```Shell depthcharge-mkenv -S 0x10000 -F 0x5 -f env.txt -o env.bin ``` -------------------------------- ### Writing Memory with Hexadecimal Data (Usage) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-write-mem.txt This usage pattern shows how to write raw hexadecimal data directly to a target memory address. It requires a device configuration file, the target address, and the hexadecimal string representing the data. ```Shell depthcharge-write-mem [options] -c -a
-d ``` -------------------------------- ### Printing Expanded Environment Variables with depthcharge-print (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-print.txt This command prints all environment variables from the device configuration, with their definitions fully expanded. The `-i env=expand` option is used to request this expanded view, providing a complete resolution of variable values. ```Shell depthcharge-print -c dev.cfg -i env=expand ``` -------------------------------- ### Searching for Command Tables with CommandTableHunter - Python Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/api/depthcharge.hunter.rst The `find` method of `CommandTableHunter` searches for a command table containing the specified `target` command. If `target` is `None` or empty, it returns the first table found. It supports various keyword arguments like `threshold` for validation, `check_ptrs` to confirm entries, and `longhelp`/`autocomplete` to infer U-Boot configuration states. ```Python def find(target, start=-1, end=-1, **kwargs) -> dict: ``` -------------------------------- ### Setting Debug Log Level for Depthcharge (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/troubleshooting.rst This snippet demonstrates how to set the Depthcharge log level to 'debug' using the `DEPTHCHARGE_LOG_LEVEL` environment variable. It also shows how to redirect the verbose log output to a file named `log.txt` while executing a `depthcharge-read-mem` command. This helps in obtaining detailed traceback information for troubleshooting. ```Shell export DEPTHCHARGE_LOG_LEVEL=debug depthcharge-read-mem -c my_device.cfg -a 0x87f4_0124 -l 128 2> log.txt ``` -------------------------------- ### Extracting FDT Instances with Base Address and Output (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-find-fdt.txt This command extracts FDT instances from `image.bin`, saving them as both `.dtb` and `.dts` files with a prefix of 'image_'. It also specifies a base address of `0xa000` for the image, which affects the reported offsets and output filenames. The CPU architecture is set to 'arm'. ```Shell depthcharge-find-fdt --arch arm -a 0xa000 -f image.bin -o image ``` -------------------------------- ### Reading Memory with Specific Operation - Shell Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-read-mem.txt This command reads 1 MiB of memory from address 0x8200_0000 to 'data.bin' using 'dev.cfg'. It explicitly requests the use of the 'SetexprMemoryReader' implementation via the '--op' argument, demonstrating how to select a specific depthcharge.Operation for memory reading. ```Shell depthcharge-read-mem -c dev.cfg -a 0x8200_0000 -l 1M -f data.bin --op setexpr ``` -------------------------------- ### Creating a CRC32MemoryWriter Stratagem (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-stratagem.txt This command demonstrates how to create a Depthcharge Stratagem file for use with a CRC32MemoryWriter. It specifies the input memory dump file, the desired Stratagem type ('crc32'), the binary payload file, and the output JSON file where the Stratagem will be stored. ```Shell depthcharge-stratagem -f dump.bin -s crc32 -P payload.bin -o stratagem.json ``` -------------------------------- ### Implementing Internal Search Logic in Hunter - Python Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/api/depthcharge.hunter.rst The `_search_at` method is a private, internal method intended for implementation by subclasses of `Hunter`. It performs the actual search for a `target` within a specified `start_offset` and `end_offset` range of the Hunter's data. Implementations should return a dictionary on success, raise `HunterResultNotFound` if the entire range is searched without a match, or return `None` if only the `start_offset` was checked. ```Python def _search_at(target, start_offset: int, end_offset: int, **kwargs) -> dict: ``` -------------------------------- ### Reading Memory and Displaying Hex Dump (Bytes) - Shell Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-read-mem.txt This command reads 16384 bytes from the specified address 0x82000000 using the device configuration file 'dev.cfg'. The memory contents are then displayed as a hexadecimal dump to the console, as no output file is specified. ```Shell depthcharge-read-mem -c dev.cfg -a 0x82000000 -l 16384 ``` -------------------------------- ### Iterating Over Command Tables with CommandTableHunter - Python Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/api/depthcharge.hunter.rst The `finditer` method of `CommandTableHunter` returns an iterator that yields each command table found within the specified search range. It uses the same `target` and keyword arguments as the `find` method, allowing for comprehensive enumeration of all matching command tables. ```Python def finditer(self, target, start=-1, end=-1, **kwargs): ``` -------------------------------- ### Reading Memory to a File - Shell Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/scripts/depthcharge-read-mem.txt This command reads 16 KiB of memory from the address 0x8200_0000 (demonstrating support for Python's underscore syntax for readability) using 'dev.cfg'. The retrieved data is then saved directly to the 'data.bin' file instead of being printed as a hex dump. ```Shell depthcharge-read-mem -c dev.cfg -a 0x8200_0000 -l 16K -f data.bin ``` -------------------------------- ### Iterating Over Constants with ConstantHunter - Python Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/api/depthcharge.hunter.rst The `finditer` method of `ConstantHunter` returns an iterator that provides all occurrences of the `target` constant found within the search range. This allows for discovery of every instance of a constant, rather than just the first. ```Python def finditer(target, start=-1, end=-1, **kwargs) -> dict: ``` -------------------------------- ### Hunter Base Class Definition - Python Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/api/depthcharge.hunter.rst The `Hunter` class serves as the abstract base for all hunter implementations within the `depthcharge` framework. It provides common facilities for searching data, which specialized hunters can leverage by implementing the private `_search_at` method. ```Python class Hunter: ``` -------------------------------- ### CommandTableHunter Class Definition - Python Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/api/depthcharge.hunter.rst The `CommandTableHunter` is a specialized `Hunter` implementation designed to locate command tables within a given data set. It extends the base `Hunter` class to provide specific search capabilities tailored for identifying and parsing command table structures. ```Python class CommandTableHunter: ``` -------------------------------- ### Searching for Constants with ConstantHunter - Python Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/api/depthcharge.hunter.rst The `find` method of `ConstantHunter` searches for a single occurrence of the specified `target` constant within the defined search range. It returns the first constant found, adhering to the standard `Hunter` return format. ```Python def find(target, start=-1, end=-1, **kwargs) -> dict: ``` -------------------------------- ### Adjusting Console Timeout for Depthcharge (Shell) Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/troubleshooting.rst This snippet shows how to reduce the Console timeout for Depthcharge operations by setting the `DEPTHCHARGE_CONSOLE_TIMEOUT` environment variable. A value of `0.015` (15 milliseconds) is set before executing a `depthcharge-readmem` command. This adjustment can help resolve issues where operations are sluggish but not explicitly failing, though setting it too low can cause premature timeouts. ```Shell export DEPTHCHARGE_CONSOLE_TIMEOUT=0.015 depthcharge-readmem -c mydevice.cfg -a 0xa800_6000 -l 1024 ``` -------------------------------- ### EnvironmentHunter Class Definition - Python Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/api/depthcharge.hunter.rst The `EnvironmentHunter` is a specialized `Hunter` implementation designed to locate environment variables or structures within a data set. Its specific search mechanisms are not detailed here, but it extends the base `Hunter` functionality for environment-related data. ```Python class EnvironmentHunter: ``` -------------------------------- ### ConstantHunter Class Definition - Python Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/api/depthcharge.hunter.rst The `ConstantHunter` is a specialized `Hunter` implementation focused on finding specific constant values within a data stream. It provides methods to locate single occurrences or iterate over all instances of a target constant. ```Python class ConstantHunter: ``` -------------------------------- ### CpHunter Class Definition - Python Source: https://github.com/nccgroup/depthcharge/blob/main/doc/src/api/depthcharge.hunter.rst The `CpHunter` is another specialized `Hunter` implementation. Its specific purpose and search criteria are not detailed in the provided text, but it is listed as one of the available hunter types. ```Python class CpHunter: ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.