If you like BoxMatrix then please contribute Supportdata, Supportdata2, Firmware and/or Hardware (get in touch).
My metamonk@yahoo.com is not reachable by me since years. Please use hippie2000@webnmail.de instead.

Supportdata2

From BoxMatrix

BoxMatrix >> Development >> Supportdata2 @ BoxMatrix   -   IRC-Chat   -   Translate: de es fr it nl pl
News Selectors Models Accessories Components Environment Config Commands System Webif Software Develop Lexicon Community Project Media

Tarballs GPL-Browser FW-Probes FW-History FW-News Supportdata Hardware SVN Trac Freetz-News Freetz-Timeline Freetz-Releases Freetz-Mirror OpenWRT Research

Supportdata2[edit]

Introduction[edit]

supportdata is intended for the AVM support and already is a valuable source of information.
The biggest advantage of supportdata is that it can be created by everyone on unmodified firmware.
And that is very important to have correct scan results about plain FRITZ!OS for this Wiki.

But BoxMatrix is hungry for more than what is extractable from Supportdata-Probes.
Stuff which is of no interest to the AVM support but will help to fill some empty sections:

So far these lists are extracted from Supportdata2 probes, each entry with a per model reference:

Usage[edit]

The script sd2 is provided collecting all the wanted additional info.
It could be run in a telnet or ssh session on original or modified firmware with access to the internet.
If a box is offline you can put sd2 on an USB-Stick. Maybe you need to copy it to /var/tmp to execute it.

Since the wget command of busybox (no HTTPS) is present on every box sd2 is hosted accessible by HTTP.
The usage is simple for the helper, one single command line, and you can always peek the source code:

cd /var/tmp       # only on original firmware - freetz cd is /var/mod/root

rm -f sd2 && wget boxmatrix.info/sd2 && chmod +x sd2 && ./sd2

Add -t <server> to TFTP, -m to Mail, -l to List and / or -d to Delete the created file at the end of the bold line above.
Alternatively send the created file as an Email attachment to hippie2000@webnmail.de.
If the -r option is passed sd2 is refetched before it's executed, either from BoxMatrix or from a specified TFTP server.

tftp -g -r sd2 192.168.178.20 && chmod +x sd2 && ./sd2 -r -t 192.168.178.20

Output[edit]

The filename of the sd2 generated output identifies a model, its firmware and its branding, easy to parse by my scanner.

#!/bin/sh

# sd2 - (C) 2022++ Ralf Steines aka Hippie2000 - <hippie2000@webnmail.de> - PROPRIETARY!
# Collects information for boxmatrix.info which is not present in supportdata.
# Docs and latest version can be found at https://boxmatrix.info/wiki/Supportdata2

version="09b"
hippie="hippie2000@webnmail.de"
dstamp=$(date +"%s") 2>/dev/null

args=$@
while [ $# -gt 0 ]; do
    case $1 in
        -r) refetch="1";;
        -i) refetch="";;
        -s) stdout="1";;
        -l) list="1";;
        -n) nogzip="1";;
        -t) shift && tftpserver="$1" || exit 1;;
        -m) mail="1";;
        -d) delete="1";;
        -T) test="1";;
        -b) benchmark="1";;
        -B) benchmark="1";;
        -N) netperf="1";;
        -u) urlader="1";;
    esac
    shift
done

if [ "${refetch}" != "" ] ; then
    if [ "${tftpserver}" != "" ] ; then
        echo "Refetching sd2 from tftp server '${tftpserver}'..."
        mv -f sd2 sd2.old 2>/dev/null
        tftp -g -r sd2 "${tftpserver}" || exit 1
        chmod +x sd2
        exec ./sd2 $args -i
    else
        echo "Refetching sd2 from BoxMatrix server..."
        mv -f sd2 sd2.old 2>/dev/null
        wget -q boxmatrix.info/sd2 || exit 1
        chmod +x sd2
        exec ./sd2 $args -i
    fi      
fi

product="${CONFIG_PRODUKT_NAME}"
[ -x /bin/sed ] && product=$(echo -n "${CONFIG_PRODUKT_NAME}" | sed "s/ /_/g")

subver="${CONFIG_SUBVERSION}"
[ "${subver}" != "" ] || subver="-0"

base="sd2-${version}-${product}-${HWRevision}-${HWSubRevision}-"
base="${base}${CONFIG_VERSION_MAJOR}-${CONFIG_VERSION}${subver}-"
base="${base}${OEM}-${ANNEX}-${Country}-${Language}-${dstamp}.txt"
file="${base}.txt"
blob="${base}.bin"

[ -x /bin/nice ] && nice="nice -n 19"
[ -x /bin/sleep ] && sleep=">&2 echo '  Pause 3 for the watchdog...' && sleep 3"

if [ "${stdout}" != "" ] ; then
    exec 2> /dev/null
else
    exec > "${file}"
fi

>&2 echo "Creating BocMatrix Supportdata2"

echo "##### BEGIN SD2 ${version} '${file}'"

Normally sd2 will log stdout (echo) to filenames like the following, output to stderr (>&2 echo) will be printed:

sd2-02-FRITZ!Box 6490 Cable-213-0-141-07.29-0-avm-Kabel-049-en-1653475087.txt
sd2-02-FRITZ!Box 7520-247-2-175-07.29-0-avm-B-049-de-1653475087.txt

If the -s option is passed (stdout mode) no file is created and stderr is muted.

Listings[edit]

Here step by step listings created by sd2 and how they are gathered will be added.

Modding[edit]

To analyze how the firmware was modified some details about freetz or possible other mods are collected, if present.
This must remain the first section so the scanner can detect sections which do not represent FRITZ!OS in a single pass:

if [ -e /etc/freetz_info.cfg ] ; then

    >&2 echo "Listing freetz info"
    echo "##### SECTION freetz_info"
    echo

    cat /etc/freetz_info.cfg
    echo

fi

if [ -e /etc/packages.lst ] ; then

    >&2 echo "Listing freetz packages"
    echo "##### SECTION freetz_packages"
    echo

    cat /etc/packages.lst
    echo

fi

if [ -e /etc/.config ] ; then

    >&2 echo "Listing freetz build config"
    echo "##### SECTION freetz_config"
    echo

    cat /etc/.config        
    echo

fi

if [ -e /var/flash/freetz ] ; then

    >&2 echo "Listing freetz tffs config"
    echo "##### SECTION freetz_tffs"
    echo

    cat /var/flash/freetz | tar tvf - 2>/dev/null
    echo

fi

if [ -d /var/mod ] ; then

    >&2 echo "Listing freetz temp files"
    echo "##### SECTION freetz_temp"
    echo

    ls -lRa /var/mod
    echo

fi

Versions[edit]

There are several places in FRITZ!OS to gather version info.
This must remain the second section so the scanner can use this info for all subsequent data in a single pass:

>&2 echo "Listing local versions"
echo "##### SECTION versions_local"
echo

echo "# version:"
cat /proc/version
echo

echo "# uname:"
uname -a
echo

echo "# tainted:"
cat /proc/sys/kernel/tainted 2>/dev/null
echo

echo "# gcc:"
grep GCC /bin/allcfgconv 2>/dev/null
echo

echo "# uptime:"
cat /proc/uptime
echo

echo "# developers:"
cat /proc/avalanche/developers 2>/dev/null
echo

echo "# boardinfo:"
cat /proc/boardinfo 2>/dev/null
echo

if [ -x /usr/bin/rpc ] ; then

    >&2 echo "Listing remote versions"
    echo "##### SECTION versions_remote"
    echo
 
    echo "# version:"
    rpc cat /proc/version
    echo

    echo "# uname:"
    rpc uname -a
    echo

    echo "# tainted:"
    rpc cat /proc/sys/kernel/tainted
    echo

    echo "# gcc:"
    rpc grep GCC /bin/allcfgconv 2>/dev/null
    echo

    echo "# uptime:"
    rpc cat /proc/uptime
    echo

    echo "# developers:"
    rpc cat /proc/avalanche/developers
    echo

 fi

The uptime may be useful to detect if a boot was finished.

CPUinfo[edit]

cpuinfo is an important helper to gather runtime information about the builtin CPUs to be collected in the Codenames section.
If rpc exists we are on a Puma6 or Puma7 model and also list the remote cpuinfo.

>&2 echo "Listing local cpuinfo"
echo "##### SECTION cpuinfo_local"
echo

echo "# cpuinfo:"
cat /proc/cpuinfo
echo

echo "# clocks:"
cat /proc/clocks 2>/dev/null
echo

echo "# smtc:"
cat /proc/smtc 2>/dev/null
echo

echo "# psp_version:"
cat /proc/avalanche/psp_version 2>/dev/null
cat /proc/avalanche/base_psp_version 2>/dev/null
echo
 
if [ -x /usr/bin/rpc ] ; then

    >&2 echo "Listing remote cpuinfo"
    echo "##### SECTION cpuinfo_remote"
    echo

    echo "# cpuinfo:"
    rpc cat /proc/cpuinfo
    echo

    echo "# psp_version:"
    rpc cat /proc/avalanche/base_psp_version
    echo

fi

Benchmarks[edit]

Benchmarks are also a topic on BoxMatrix to compare models. They are collected in the new Benchmark-Results section.
If rpc exists we are on a Puma6 or Puma7 model and also list the remote Benchmarks.
The MemBench code is ugly, but it's at differing locations.

if [ "${benchmark}" != "" ] ; then

    >&2 echo "Listing local benchmarks"
    echo "##### SECTION benchmarks_local"
    echo
 
    if [ -e /proc/avm/benchmark/do_read_pipe -o -e /proc/avm/do_read_pipe ] ; then
 
        >&2 echo "  MemBench benchmark..."
 
        echo "# read_pipe:"
        cat /proc/avm/benchmark/do_read_pipe 2>/dev/null || \
          cat /proc/avm/do_read_pipe 2>/dev/null
        echo
 
        echo "# read_extreme:"
        cat /proc/avm/benchmark/do_read_extreme  2>/dev/null || \
          cat /proc/avm/do_read_extreme  2>/dev/null
        echo
 
        echo "# read_write:"
        cat /proc/avm/benchmark/do_read_write  2>/dev/null || \
          cat /proc/avm/do_read_write  2>/dev/null
        echo
 
        echo "# write:"
        cat /proc/avm/benchmark/do_write 2>/dev/null || \
          cat /proc/avm/do_write 2>/dev/null
        echo
 
        echo "# writeburst:"
        cat /proc/avm/benchmark/do_writeburst 2>/dev/null
        echo
 
        eval "${sleep}"

        if [ -e /proc/avm/do_dettmer_read -o -e /proc/avm/benchmark/do_dettmer_read ] ; then
 
            echo "# dettmer_read:"
            echo AVM_PRINTK > /dev/debug
            cat /proc/avm/benchmark/do_dettmer_read 2>/dev/null || \
              cat /proc/avm/do_dettmer_read 2>/dev/null
            echo
            echo AVMDBG_EOF 1+ >/dev/debug
            tail /dev/debug 2>/dev/null | grep -e MHz -e MB -e msec
            echo AVMDBG_EOF 0 >/dev/debug
            dmesg | tail | grep -e MHz -e MB -e msec
            echo
 
            echo "# dettmer_write:"
            echo AVM_PRINTK > /dev/debug
            cat /proc/avm/benchmark/do_dettmer_write 2>/dev/null || \
              [[cat}} /proc/avm/do_dettmer_write 2>/dev/null
            echo
            echo AVMDBG_EOF 1+ >/dev/debug
            tail /dev/debug 2>/dev/null | grep -e MHz -e MB -e msec
            echo AVMDBG_EOF 0 >/dev/debug
            dmesg | tail | grep -e MHz -e MB -e msec
            echo
 
        fi
 
    fi
 
    if [ -e /proc/avm/benchmark/performance_index -o -e /proc/avm/performance_index ] ; then
 
        >&2 echo "  Performance-Index benchmark..."
 
        echo "# performance_index:"
        cat /proc/avm/benchmark/performance_index 2>/dev/null || \
          cat /proc/avm/performance_index 2>/dev/null
        echo
 
        eval "${sleep}"

    fi
 
    if [ -x /usr/bin/dhrystone ] ; then
 
        >&2 echo "  Dhrystone benchmark..."
 
        echo "# dhrystone:"
        dhrystone 10000000
        echo
 
        eval "${sleep}"

    fi

    if [ -x /usr/bin/rpc ] ; then
 
        >&2 echo "Listing remote benchmarks"
        echo "##### SECTION benchmarks_remote"
        echo
 
        >&2 echo "  MemBench benchmark..."
 
        echo "# read_pipe:"
        rpc cat /proc/avm/benchmark/do_read_pipe
        echo
 
        echo "# read_extreme:"
        rpc cat /proc/avm/benchmark/do_read_extreme
        echo
 
        echo "# read_write:"
        rpc cat /proc/avm/benchmark/do_read_write
        echo
 
        echo "# write:"
        rpc cat /proc/avm/benchmark/do_write
        echo
 
        echo "# writeburst:"
        rpc cat /proc/avm/benchmark/do_writeburst
        echo
 
        eval "${sleep}"

        >&2 echo "  Performance-Index benchmark..."
 
        echo "# performance_index:"
        rpc cat /proc/avm/benchmark/performance_index
        echo
 
        eval "${sleep}"

        >&2 echo "  Dhrystone benchmark..."
 
        echo "# dhrystone:"
        rpc dhrystone 10000000
        echo
 
        eval "${sleep}"

    fi

fi

Meminfo[edit]

The Memory-Info section already covers the meminfo, but only starting with fw 4,52.
If rpc exists we are on a Puma6 or Puma7 model and also list the remote meminfo.

>&2 echo "Listing local meminfo"
echo "##### SECTION meminfo_local"
echo

echo "# meminfo:"
cat /proc/meminfo
echo

echo "# iomem:"
cat /proc/iomem
echo

echo "# ioports:"
cat /proc/ioports
echo

echo "# swaps:"
cat /proc/swaps 2>/dev/null
echo

echo "# buddyinfo:"
cat /proc/buddyinfo 2>/dev/null
echo

echo "# vmstat:"
cat /proc/vmstat 2>/dev/null
echo

echo "# zoneinfo:"
cat /proc/zoneinfo 2>/dev/null
echo

if [ -x /usr/bin/rpc ] ; then

    >&2 echo "Listing remote meminfo"
    echo "##### SECTION meminfo_remote"
    echo

    echo "# meminfo:"
    rpc cat /proc/meminfo
    echo

    echo "# iomem:"
    rpc cat /proc/iomem
    echo

    echo "# ioports:"
    rpc cat /proc/ioports
    echo

    echo "# swaps:"
    rpc cat /proc/swaps
    echo

    echo "# buddyinfo:"
    rpc cat /proc/buddyinfo
    echo

    echo "# vmstat:"
    rpc cat /proc/vmstat
    echo

    echo "# zoneinfo:"
    rpc cat /proc/zoneinfo
    echo

fi

Interrupts[edit]

Interrupts are not covered in supportdata at all, so this will fill the gaps.
If rpc exists we are on a Puma6 or Puma7 model and also list the remote interrupts.

>&2 echo "Listing local interrupts"
echo "##### SECTION interrupts_local"
echo

echo "# interrupts:"
cat /proc/interrupts
echo

echo "# softirqs:"
cat /proc/softirqs 2>/dev/null
echo

echo "# fastinterrupts:"
cat /proc/fastinterrupts 2>/dev/null
echo

if [ -x /usr/bin/rpc ] ; then

    >&2 echo "Listing remote interrupts"
    echo "##### SECTION interrupts_remote"
    echo

    echo "# interrupts:"
    rpc cat /proc/interrupts
    echo

    echo "# softirqs:"
    rpc cat /proc/softirqs
    echo

    echo "# fastinterrupts:"
    rpc cat /proc/fastinterrupts
    echo

fi

GPIO[edit]

GPIO is work in progress.
If rpc exists we are on a Puma6 or Puma7 model and also list the remote GPIO.

>&2 echo "Listing local gpio"
echo "##### SECTION gpio_local"
echo

echo "# iogpio:"
cat /proc/iogpio 2>/dev/null
echo

echo "# gpio:"
cat /proc/gpio 2>/dev/null
echo

if [ -x /usr/bin/gpioinfo ] ; then

   echo "# gpioinfo:"
   gpioinfo
   echo

fi

echo "# consoles:"
cat /proc/consoles 2>/dev/null
echo

echo "# list:"
cat /proc/avm/gpio/list 2>/dev/null
echo

echo "# gpio2:"
cat /sys/kernel/debug/gpio 2>/dev/null
echo

if [ -x /usr/bin/rpc ] ; then

    >&2 echo "Listing remote gpio"
    echo "##### SECTION gpio_remote"
    echo

    echo "# iogpio:"
    rpc cat /proc/iogpio
    echo

    echo "# gpio:"
    rpc cat /proc/gpio
    echo

    echo "# consoles:"
    rpc cat /proc/consoles
    echo

fi

Symlinks[edit]

Symlinks are already scanned from Firmware-Probes but it may be helpful for debugging modified firmware to list them.
If rpc exists we are on a Puma6 or Puma7 model and also list the remote symlinks
This section must be grabbed before the BusyBox section to avoid the need of a 2-path sd2 listing parser.

if [ -x /usr/bin/find ] ; then

    >&2 echo "Listing local symlinks"
    echo "##### SECTION symlinks_local"
    echo

    find /bin /sbin /usr/bin /usr/sbin -type l 2>/dev/null
    echo
 
    if [ -x /usr/bin/rpc ] ; then

        >&2 echo "Listing remote symlinks"
        echo "##### SECTION symlinks_remote"
        echo

        rpc find /bin /sbin /usr/bin /usr/sbin -type l | sort 2>/dev/null
        echo
 
    fi

fi

BusyBox[edit]

BusyBox-Commands are already scanned from Firmware-Probes but it may be helpful for debugging modified fw to list them.
Since the --list option is not present in older busybox we have to call busybox without arguments for compatibility.
If rpc exists we are on a Puma6 or Puma7 model and also list the remote busybox.

>&2 echo "Listing local busybox applets"
echo "##### SECTION busybox_local"
echo

busybox 2>&1
echo

if [ -x /usr/bin/rpc ] ; then

    >&2 echo "Listing remote busybox applets"
    echo "##### SECTION busybox_remote"
    echo

    rpc busybox 2>&1
    echo

fi

Processes[edit]

Linux-Processes are already present in supportdata but to map them to Netlink data they need to be grabbed at the same time.
If rpc exists we are on a Puma6 or Puma7 model and also list the remote processes.
This section must be grabbed before the Netlink section to avoid the need of a 2-path sd2 listing parser.

>&2 echo "Listing local processes"
echo "##### SECTION processes_local"
echo

ps -l 2>/dev/null
if [ $? -ne 0 ] ; then
    ps -w 2>/dev/null
fi
echo

if [ -x /usr/bin/rpc ] ; then

    >&2 echo "Listing remote processes"
    echo "##### SECTION processes_remote"
    echo

    rpc ps -l
    echo

fi

The -T option was removed since older ps fails on it. Option -l also fails on older systems in which case -w is used.

Netperf[edit]

Network-Performance comparison is still a missing feature on BoxMatrix.
Step by step tesing methods will be added here

if [ "${benchmark}" != "" ] ; then

    >&2 echo "Listing local net performance"
    echo "##### SECTION netperf_local"
    echo

fi

Sockets[edit]

Linux-Sockets are already present in supportdata but to map them to AVMIPC data they need to be grabbed at the same time.
If rpc exists we are on a Puma6 or Puma7 model and also list the remote sockets.
This section must be grabbed before the AVMIPC section to avoid the need of a 2-path sd2 listing parser.

>&2 echo "Listing local sockets"
echo "##### SECTION sockets_local"
echo

netstat -xlpen 2>/dev/null
if [ $? -ne 0 ] ; then
    netstat -xlen 2>/dev/null
fi
echo

netstat -xpen 2>/dev/null
if [ $? -ne 0 ] ; then
    netstat -xen 2>/dev/null
fi
echo

if [ -x /usr/bin/rpc ] ; then

    >&2 echo "Listing remote sockets"
    echo "##### SECTION sockets_remote"
    echo

    rpc netstat -xlpen
    echo

    rpc netstat -xpen
    echo

fi

Option netstat -p is missing on older models, in which case it retries without.

Genetlink[edit]

Genetlink sockets are the NETLINK_GENERIC family of Netlink-Sockets, maintained by libewnwlinux.so in FRITZ!OS.
They could be listed from aicmd listeners which call the genetlink_ functions in libewnwlinux.so.
So far these are only l2tpv3d, nltest and active users of libavmpcp.so and no remote daemon so far.
For maximum independency of the mode a box is using we query ctlmgr, dsld, multid, l2tpv3d.
This section must be grabbed before the Netlink section to avoid the need of a 2-path sd2 listing parser.

if [ -x /bin/aicmd ] ; then

    >&2 echo "Listing local genetlink sockets"
    echo "##### SECTION genetlink_local"
    echo

    for daemon in ctlmgr dsld multid l2tpv3d; do

        aicmd $daemon ewnwlinux show genetlink 2>/dev/null

    done
    echo

fi

Netlink[edit]

Netlink-Sockets are similar to Linux-Sockets just they are not files in the filesystem so they don't appear in supportdata.
We list them from the procfs. If rpc exists we are on a Puma6 or Puma7 model and also list the remote netlink sockets.

>&2 echo "Listing local netlink sockets"
echo "##### SECTION netlink_local"
echo

cat /proc/net/netlink
echo

if [ -x /usr/bin/rpc ] ; then

    >&2 echo "Listing remote netlink sockets"
    echo "##### SECTION netlink_remote"
    echo

    rpc cat /proc/net/netlink
    echo

fi

AVMIPC[edit]

The AVMIPC-Datastore is pretty new, the aicmd command to show it even newer (6.54), we must check if it exists.
If rpc exists we are on a Puma6 or Puma7 model and also list the remote datastore.
Older avmipcd has a differing syntax to list the datastore, and aicmd does not set an error rerturn code on failure.
So we run new and old syntax silently after each others, one will (hopefully) succeed. Tested with fw 7.01 - 7.39.
In fw 6.88 aicmd exists but could not list the datastore since avmipcd was no aicmd listener yet. This also fails silently.

if [ -x /bin/aicmd ] ; then

    >&2 echo "Listing local avmipcd datastore"
    echo "##### SECTION avmipcd_local"
    echo

    echo "# aicmd:"
    aicmd avmipcd datastore show full 2>/dev/null
    aicmd avmipcd show data_store full 2>/dev/null
    echo
 
    if [ -x /bin/avmipcshow ] ; then

        echo "# avmipcshow:"
        avmipcshow -O raw 2>/dev/null
        echo

    fi

    if [ -x /usr/bin/rpc ] ; then

        >&2 echo "Listing remote avmipcd datastore"
        echo "##### SECTION avmipcd_remote"
        echo

        echo "# aicmd:"
        rpc aicmd avmipcd datastore show full 2>/dev/null
        rpc aicmd avmipcd show data_store full 2>/dev/null
        echo
 
        echo "# avmipcshow:"
        rpc avmipcshow -O raw 2>/dev/null
        echo

    fi

fi

Filesystems[edit]

The Linux-Filesystems only cover filesystems which are reported by mount, so they are listed here to fill the gaps.
If rpc exists we are on a Puma6 or Puma7 model and also list the remote filesystems.

>&2 echo "Listing local filesystems"
echo "##### SECTION filesystems_local"
echo

echo "filesystems:"
cat /proc/filesystems
echo

echo "mounts:"
cat /proc/mounts
echo

if [ -x /usr/bin/rpc ] ; then

    >&2 echo "Listing remote filesystems"
    echo "##### SECTION filesystems_remote"
    echo

    echo "filesystems:"
    rpc cat /proc/filesystems
    echo

    echo "mounts:"
    cat /proc/mounts
    echo

fi

Partitions[edit]

The Linux-Partitions are rarely listed in Supportdata-Probes, so they are listed here to fill the gaps.
If rpc exists we are on a Puma6 or Puma7 model and also list the remote partitions.

>&2 echo "Listing local partitions"

echo "##### SECTION partitions_local"
echo

echo "# mtd:"
cat /proc/mtd 2>/dev/null && echo

echo "# partitions:"
cat /proc/partitions
echo

echo "# tffs:"
cat /proc/tffs
echo

echo "# urlader:"
grep -e mtd -e flashsize -e memsize /proc/sys/urlader/environment 2>/dev/null
grep -e mtd -e flashsize -e memsize /proc/avalanche/env 2>/dev/null
echo

echo "# avm_partitions:"
cat /proc/avm_partitions 2>/dev/null
echo

echo "# mtd_bbt:"
cat /proc/avm/mtd_bbt 2>/dev/null
echo

if [ -x /usr/bin/rpc ] ; then

    >&2 echo "Listing remote partitions"

    echo "##### SECTION partitions_remote"
    echo

    echo "# mtd:"
    rpc cat /proc/mtd
    echo

    echo "# partitions:"
    rpc cat /proc/partitions
    echo

    echo "# tffs:"
    rpc cat /proc/tffs
    echo

    echo "# urlader:"
    rpc grep -e mtd -e flashsize -e memsize /proc/sys/urlader/environment 
    echo

    echo "# avm_partitions:"
    rpc cat /proc/avm_partitions
    echo

fi

UBInfo[edit]

The Linux-Partitions never cover UBI volumes in Supportdata-Probes, so they are listed here to fill the gaps.

if [ -x /usr/sbin/ubinfo ] ; then

    >&2 echo "Listing local UBI info"

    echo "##### SECTION ubinfo_local"
    echo

    ubinfo --all
    echo

fi

Devices[edit]

The Linux-Devices currently only list devices which are hardcoded in the firmware, which is not used in recent firmware.
It always lacked the numerous devices which are dynamically created at runtime (today all). This listing will fill these gaps.
If rpc exists we are on a Puma6 or Puma7 model and also list the remote devices.

>&2 echo "Listing local devices"

echo "##### SECTION devices_local"
echo

echo "# devices:"
cat /proc/devices
echo

echo "# misc:"
cat /proc/misc
echo

ls -lRa /dev
echo

if [ -x /usr/bin/rpc ] ; then

    >&2 echo "Listing remote devices"

    echo "##### SECTION devices_remote"
    echo

    echo "# devices:"
    rpc cat /proc/devices
    echo

    echo "# misc:"
    rpc cat /proc/misc
    echo

    rpc ls -lRa /dev
    echo

fi

Procfs[edit]

The procfs is huge, especially its numerical directories with the pid of each process.
Besides this the processes come and go so a ls -lR would just be bloat for redundant useeless info.
Thats why it has to be listed step by step. First we list all non directories in /proc main directory :

>&2 echo "Listing procfs"

echo "##### SECTION procfs_local"
echo

echo "/proc:"
ls -la /proc | grep -v '^d'

To have a sample we list the pid 1 process which should not disappear

echo
${nice} ls -lRa /proc/1 2>/dev/null

Then we list all non numerical subdirectories of /proc recursively

for obj in /proc/*
do

    [ -d "$obj" ] || continue

    dir=$(basename "$obj")
    [ "$dir" -eq "$dir" ] 2> /dev/null
    [ $? -ne 0 ] || continue 

    echo
    ${nice} ls -lRa "$obj"

done
echo

The first continue filters out all non directories, the second continue filters out all numerical dirs.
If rpc exists we are on a Puma6 or Puma7 model and also list the remote procfs.

if [ -x /usr/bin/rpc ] ; then

    >&2 echo "Listing remote procfs"

    echo "##### SECTION procfs_remote"
    echo

    echo "/proc:"
    rpc ls -la /proc | grep -v '^d'
    echo
    rpc ls -la /proc | grep '^d'
    echo

    rpc ${nice} ls -lRa /proc/1 2>/dev/null
    echo

    dirs="P-UNIT avalanche avm bus capi cppi cpu docint driver fs irq sys sysvipc tty"
    for dir in  ${dirs} ; do

        rpc ${nice} ls -lRa "/proc/${dir}"
        echo

    done

fi

Sysfs[edit]

The sysfs is also huge, but unlike the procfs it does not need to be filtered but can be listed recursively

if [ -e /sys ] ; then

    >&2 echo "Listing local sysfs"

    echo "##### SECTION sysfs_local"
    echo

    ${nice} ls -lRa /sys
    echo

fi

If rpc exists we are on a Puma6 or Puma7 model and also list the remote sysfs.

if [ -x /usr/bin/rpc ] ; then

    >&2 echo "Listing remote sysfs"

    echo "##### SECTION sysfs_remote"
    echo

    rpc ${nice} ls -lRa /sys
    echo

fi

Tempfiles[edit]

The Temp-Files just cover stuff AVM lists, they lack locks, pidfiles etc.

>&2 echo "Listing local tempfiles"

echo "##### SECTION tempfiles_local"
echo

${nice} ls -lRa /var
echo

If rpc exists we are on a Puma6 or Puma7 model and also list the remote tempfiles.

if [ -x /usr/bin/rpc ] ; then

    >&2 echo "Listing remote tempfiles"

    echo "##### SECTION tempfiles_remote"
    echo

    rpc ${nice} ls -lRa /var
    echo

fi

Urlader[edit]

If the -u option is passed the Urlader is dumped. It is very valuable for research.
If rpc exists we are on a Puma6 or Puma7 model and also dump the remote urlader.

if [ "${urlader}" != "" -a -x /bin/sed -a -x /bin/dd ] ; then

    dev=$(grep -e bootloader -e '"urlader"' /proc/mtd | sed 's/:.*//' | sed 's/^mtd//')
    if [ "${dev}" != "" -a -e "/dev/mtdblock${dev}" ] ; then

        >&2 echo "Dumping local urlader"

        echo "##### SECTION urlader_local"
        echo

        echo "# urlader"
        blob1="${blob}"
        dd if="/dev/mtdblock${dev}" of="${blob1}" bs=256 2>/dev/null
        echo

        ls -l "${blob1}"
        echo

    fi

    if [ -x /usr/bin/rpc ] ; then

        dev=$(rpc grep -e bootloader -e '"urlader"' /proc/mtd | sed 's/:.*//' | sed 's/^mtd//')
        if [ "${dev}" != "" -a $(rpc ls "/dev/mtdblock${dev}")  != "" ] ; then

            >&2 echo "Dumping remote urlader"

            echo "##### SECTION urlader_remote"
            echo

            echo "# urlader"
            blob2="${blob}2"
            rpc dd if="/dev/mtdblock${dev}" bs=256 >"${blob2}"
            echo

            ls -l "${blob2}"
            echo

        fi

    fi

fi

EOF[edit]

The end marker is important to detect truncated files:

echo "##### END SD2"

if [ "${stdout}" != "" ] ; then
    exit 0
fi

>&2 echo "Created '${file}'"

If the -s option was passed (stdout mode) sd2 will terminate here since there's no file to process further.

Options[edit]

List[edit]

sd2 can optionally list the created file (using less) if it's passed the -l option.
This is especially useful during development to not have to copy paste the unpredictable filename.

if [ "${list}" != "" ] ; then

    >&2  echo "Listing created file..."

    if [ -x /usr/bin/less ] ; then
        1>&2 less "${file}"
    else
        1>&2 more "${file}"
    fi

fi

Gzip[edit]

sd2 will automatically compress the created file if gzip could be found, unless the -n option (no gzip) is passed.
A sd2 file is approx. 1 MB, with remote listings 2 MB (6490). Compressed these are both ~100 kB!

if [ "${nogzip}" = "" -a -x /bin/gzip ] ; then

    >&2 echo "Compressing files with gzip..."

    gzip "${file}"
    if [ $? -eq 0 ] ; then
        >&2 echo "  Gzipped ${file}" 
        file="${file}.gz"
    else
        >&2 echo "  *** FAILED to gzip ${file} ***" 
    fi

    if [ "${blob1}" != "" ] ; then

        gzip "${blob1}"
        if [ $? -eq 0 ] ; then
            >&2 echo "  Gzipped ${blob1}" 
            blob1="${blob1}.gz"
        else
            >&2 echo "  *** FAILED to gzip ${blob1} ***" 
        fi
 
    fi

    if [ "${blob2}" != "" ] ; then
 
        gzip "${blob2}"
        if [ $? -eq 0 ] ; then
            >&2 echo "  Gzipped ${blob2}" 
            blob2="${blob2}.gz"
        else
            >&2 echo "  *** FAILED to gzip ${blob2} ***" 
        fi

    fi

fi

TFTP[edit]

sd2 can optionally send the created file to a tftp server if it is passed the -t <server> option.
Every box has the tftp command installed, a slow and old protocol but the only way to upload a file from original firmware.
This is especially useful to grab Supportdata2 from models without USB-Host like repeaters. sd2 supports tftp upload.

if [ "${tftpserver}" != "" ] ; then

    >&2  echo "Sending files to tftp server '${tftpserver}'..."
 
    for item in "${file}" "${blob1}" "${blob2}"; do
        [ "${item}" = "" ] && continue

        tftp -p -l "${item}" -r "${item}" "${tftpserver}"

        if [ $? -eq 0 ] ; then
            >&2 echo "  Uploaded ${item}" 
        else
            >&2 echo "  *** FAILED to tftp ${item} ***" 
        fi

    done

fi

A tftpd server must be running on the passed <server>. This fails with the tftp server of dnsmasq since it is read only.
You need to adapt your freetz build to enable the Busybox applets >> Networking Utilities >> tftpd applet.
And finaly you just need to put this line in Inetd >> User defined in the freetz webinterface:

69 dgram udp nowait root /bin/busybox tftpd -l -c /var/media/ftp/tftp

Make sure dnsmarq tftp server is swiched off and the target directory exists. For me this is the Internal-Storage of my 6490.

Mail[edit]

sd2 can optionally Email the created file to me if it is passed the -m option.
This only works if your box knows the Email credentials you entered for using Push-Mail.

if [ "${mail}" != "" ] ; then

    >&2  echo "Mailing files to hippie2000..."

    for item in "${file}" "${blob1}" "${blob2}"; do
        [ "${item}" = "" ] && continue

        mailer -t "${hippie}" -s "${item}" -d "${item}"

        if [ $? -eq 0 ] ; then
            >&2 echo "  Mailed ${item}" 
        else
            >&2 echo "  *** FAILED to mail ${item} ***" 
        fi

    done

fi

Delete[edit]

sd2 can optionally delete the created file after uploading / mailing / listing if it's passed the -d option.
This prevents from filling the RAM during development.

if [ "${delete}" != "" ] ; then

    >&2  echo "Deleting created files..."

    rm -f "${file}" "${blob1}" "${blob2}"

fi

Project[edit]

Feedback[edit]

For bugreports or feature requests please get in touch, use our IRC-Channels or use this forum thread:

History[edit]

Read the changes bottom up.

sd2 xx - future

TODO: Benchark with openssl_req
TODO: Network performance tests with udpst, ...
TODO: List Calib members

sd2-xx - work in progress - fw 7.90 support

Added: AVMIPC now supports avmipcshow

sd2-10 - 2023-01-01 - milestone 10 - numerous new functions and sections

Added: GPIO now also lists gpioinfo, consoles, list, gpio2
Added: Partitions now also lists mtd_bbt
Added: Versions now also lists boardinfo
Fixed: missing Puma6 ARM dhrystone
Fixed: Bootloader dump now skips the nand-urlader (7272)
Changed: Bumped version to 09b
Changed: gzip, mail, tftp and delete now also cover possible bootloaders
Added: Urlader option -u now dumps local and remote bootloader
Changed: Benchmarks now are default off unless -b is passed
Changed: Listing of procfs, sysfs, temp now runs nice 19
Added: Versions now covers kernel tainted state and gcc version of avm commands
Added: Interlaced the Benchmarks with sleep to calm down the watchdog
Changed: Bumped version to 09a
Added: Partitions now list mtd, flashsize and memsize from environment
Added: Benchmarks section doing MemBench, Performance-Index, Dhrystone
Added: Filename generation for a blob,bin
Fixed: CPUinfo psp_version now also supports Puma5
Changed: refetch -r now renames instead of deleting so sd2 doesn't get lost if transfer fails
Added: CPUinfo now lists smtc 
Added: Meminfo now lists swaps 
Added: Versions now lists the uptime to detect unfinished boots

sd2-09 - 2022-11-25 - milestone 09 - old fw support, numerous new functions and sections

Added: GPIO section listing iogpio, gpio
Added: Listings of interrupts, softirqs, fastinterrupts
Added: The -r option now refetches sd2 from boxmatrix if no tftp server is specified
Added: Listings of meminfo, iomem, ioports, iogpio, buddyinfo, vmstat, zoneinfo
Added: The partitions now also list /proc/tffs and /proc/avm_partitions
Added: The devices now also list /proc/misc devices
Added: The -l list option now uses more if less is not installed
Added: cpuinfo now lists /proc/clocks if its present
Added: Listings of filesystems, mounts, tempfiles
Added: Listings of version, uname, developers
Changed: all ls calls now add an -a option (way too late)
Fixed: Busybox section now supports old busybox v1.00-pre3 which outputs help to stderr
Fixed: == operand not supported by older ash
Added: New -r option refetches sd2 from the specified TFTP server before execution
Changed: Argument parser no longer relies on getopts.
Fixed: Local Sysfs is only listed if /sys exists.
Fixed: Sockets now does a fallback if netstat lacks the -p option.
Fixed: Symlinks now does not rely on sort being present on the system any more
Fixed: Symlinks now fails silently if find link exists but busybox lacks the applet
Fixed: Processes listing now also works on older models without ps -l capability.

sd2-08 - 2022-11-01 - milestone 08 - cpuinfo, partitions, mtd, ubinfo

Added: Listings of cpuinfo, partitions, mtd, ubinfo
Added: The devices section now also lists major info from procfs
Changed: genetlink sockets now are listed before netlink sockets to merge both infos 1-path
Changed: Better independency of box mode for the genetlink sockets lister

sd2-07 - 2022-06-26 - milestone 07 - processes, netlink, genetlink

Added: Listings of local genetlink sockets (genetlink_local)
Added: Listings of local and remote netlink sockets (netlink_local, netlink_remote)
Added: Listings of local and remote processes (processes_local, processes_remote)

sd2-06 - 2022-06-13 - milestone 06 - symlinks, busybox, old datastore listing, future proof license

Changed the license form to PROPRIETARY so this project does not end in code raping like FIT-Image.
Added: Listings of local and remote symlinks (symlinks_local, symlinks_remote)
Added: Listings of local and remote busybox applets (busybox_local, busybox_remote)
Added: Support for older aicmd avmipcd datastore syntax (tested 7.01)

sd2-05 - 2022-06-01 - milestone 05 - sockets, no whitespace, embedded filename, stdout, nogzip

Added: Listings of local and remote sockets (sockets_local, sockets_remote)
Added: The -s option now offers a stdout mode for piping the output, ie to gzip
       Useful for models with very small RAM to stream commpress 'sd2 -s | gzip > sd2.gz'
Added: The BEGIN header now contains the filename so sd2 now also works with altered filenames
Added: The name of the created file now replaces white space with "_" if sed is present
       Required on older fw (tested: 4.72) otherwise mailer fails to send the attachement

sd2-04 - 2022-05-28 - milestone 04 - remote dev, procfs, sysfs, mail, ippf - recommended minimum

Added: Commpressing created file with gzip
Added: Listing remote sysfs (sysfs_remote)
Added: Listing remote procfs (procfs_remote)
Added: Listing remote devices (devices_remote)
Added: The -m option now can mail the created file if the box knows your credentials
Added: An IPPF thread introducing the project - see Feedback above

sd2-03 - 2022-05-27 - milestone 03 - copyright, arguments, devices, list, delete

Added: The -d option now can delete the file after sending / listing it
Added: The -l option now can list the created file (using  less)
Added: Procfs recursive listing of pid 1 process
Added: Devices listing (devices)
Changed: The TFTP option is now enabled by -t <server>
Added: Commandline argument parser to be more flexible in future
Added: (C) header, link to this page and license info.

sd2-02 - 2022-05-25 - milestone 02 - ipc remote, freetz info, tftp - minimum for the scanner

Added: The filename now contains the sd2 version, ie sd2-02-, pre 02 files are void
Added: Modding listing (freetz_config, freetz_tffs, freetz_temp)
Added: TFTP upload
Added: AVMIPC remote listing (avmipcd_remote)
Added: Modding listing (freetz_info, freetz_packages)

sd2-01 - 2022-05-24 - milestone 01 - ipc local, sysfs, procfs

Added: AVMIPC listing (avmipcd_local)
Added: Procfs, Sysfs listings (procfs, sysfs)

There are no releases, sd2 is always live development. The versions are milestones for my scanner.
Pre 0.2 data will not be used, since it lacks modding info which may interfer the remaining results

Examples[edit]

My current for freetzed boxes without inet:

tftp -g -r sd2 192.168.178.20 && chmod +x sd2 && ./sd2 -r -b -u -t 192.168.178.20