emacs operate in dired=!

git revert one file

git checkout filename

set gdb to record history

as .gdbinit:

set history save

:set history filename ~/.gdb_history

for RADIUS various ping/scapy/dataradio

octave gaussian noise


scapy STDIN to ping

import sys
from scapy.all import sr1,IP,ICMP

    print (str(p.payload))

subtracting on track from another in audacity

  • invert one track
  • Tracks -> Mix and render

minimodem RTTY

cat bellman | minimodem -t rtty -f test.wav

simple GIT branching so that remote is tracked with push

git checkout -b towers
git add testcode.c
git push --all -u
git checkout master

to switch back to main branch

data radio

resolving no such process

with dhclient: SIOCADDRT: No such process

dhclient -r -x          

core dumping

always set ulimit before starting application!

ulimit -c unlimited
kill -3 PID


gcore in gdb,

using qemu and gdb

qemu-system-i386 linux-0.2.img -s -singlestep -net none

and then attach with:

gdb -x gdbtest --batc

where gdbtest has lines:

target remote localhost:1234 
set architecture i8086
set disassemble-next-line on
while 1

note that -S option with qemu seems cause problems, and attempt to interact with monitor crashes…

arduino mega pin maps

running stack dump

while true
   for pid in $(ps aux | awk '{print $2 }'); do
      /usr/bin/pstack $pid

dump code from avrdude

-U flash:r:flashdump.hex:i

python/gnuplot with lines error

replace call with:

g('set style lines 1')

earthboot simulation shell

while [ 1 = 1 ]; do /root/collect2011/code_ref/c/rand > test.com ; dosemu test.com; done

extract all images from pdf

for I in *pdf ; do pdfimages -j $I $I ; done

move tracks from front to back layers in KiCad

XXXX.brd in emacs: Search and replace De 15 with De 0 in Tracks section.

upload hexfile to arduino

with avrdude.conf from: http://www.scs.ryerson.ca/mfiala/my\_utils/arduino\_uno\_programming.html

 avrdude -C/root/avrdude.conf -F -V -c arduino -p ATMEGA328P -P /dev/ttyACM0 -b 115200 -U flash:w:lineccd.hex

convert MTS (AVCHD) to playable AVI

ffmpeg -i 00019.MTS -f avi -b 16000k -ab 192k -s 1024x768 00019.AVI

and as shell:

for file in `ls *.MTS`
new=`basename $file .MTS`
ffmpeg -i $file -f avi -b 16000k -ab 192k -s 1024x768 ${new}.avi

change width of multiple tracks in KiCad

  • set up net classes for nets in design rules (power 0.3mm signals 0.25mm)
  • select track
  • select global tracks and vias edition
  • set all tracks to their net class value

Note: power lines: 0.3mm (0.4 for 500mA), signals 0.25mm (10 mil)

sox and alsa

export AUDIODEV=plughw:UA25


custom tagger for certain words used as backup for POS tags…

patterns = [
    ('injur*', 'INJ'),
    ('crash*', 'CHR'),
    ('collision*', 'COL')

tag1= nltk.data.load(nltk.tag._POS_TAGGER)
regexp_tagger = nltk.RegexpTagger(patterns,backoff=tag1)


4th entry eg. 15r

firefox-b 2982        root   15r     FIFO        0,8       0t0       9770 pipe

is /proc/2982/fd/15

eagle to kicad

kicad libraries

ptraces and gdb scripting

gdb attach 2106 -x gdbtest --batch >test.log

now seems to be:

gdb /bin/binarytoattachto pid -x gdbtest --batch >test.log

gdb script in gdbtest:

display /1i $pc
attach <pid>
while 1

replacing non-ascii characters in emacs

C-M-s [^[:ascii:]]

to check for them


M-| (shell command on region) RET iconv -t ascii//translit RET

(from: https://groups.google.com/forum/?fromgroups#!topic/gnu.emacs.help/Kq7LPcGvOkU )

emacs and twittering mode

Post a tweet

‘u’, ‘C-c C-s’ Post a tweet. (‘twittering-update-status-interactive’) ‘C-m’, ‘Enter’ Post a reply to the tweet pointed by the cursor. If the cursor points a URI, invoke ‘browse-url’ for the URI. (‘twittering-enter’) ‘C-c C-m’, ‘C-c Enter’ Post a non-official (organic) retweet for the tweet pointed by the cursor. (‘twittering-retweet’) ‘C-u C-c C-m’, ‘C-u C-c Enter’ Post a official (native) retweet for the tweet pointed by the cursor. (‘twittering-retweet’)

ascii gnuplot and split for dot matrix

in gnuplot:

set terminal dumb 1000 1000

(for 1000x1000 character)

set output "~/testfile"
plot "201112071844.results.log" w lines

(for example)

and to split into 80 char wide:

python split2.py 80 1000 1000


import sys, os 

lines = open(filename, 'r').readlines()

# split text file into width x of total width z, full height(y)

x = sys.argv[1]
y = sys.argv[2]
z = sys.argv[3]

print chunksize

for xx in range(chunksize):
    for i in range(0, int(y)):
        words += lines[i][startx:startx+int(x)] #across
#    print ''.join(words)
        f=open(filename, 'w')

example as file:../plotzz.zip

gst-launch/gstreamer video to audio!

gst-launch-0.10 v4l2src device=/dev/video0 ! videoscale ! video/x-raw-yuv,width=441,height=10,framerate=10/1 ! ffmpegcolorspace ! video/x-raw-gray,bpp=8 ! ffmpegcolorspace ! audioparse ! audioconvert ! audio/x-raw-int,rate=44100,channels=1,depth=8 ! alsasink

home-made arduino

Based on ATmega168 // 16MHz, FUSES:

avrdude -c usbasp -p m168 -U lfuse:w:0xff:m -U hfuse:w:0xdd:m
avrdude -c usbasp -p m168 -U flash:w:ATmegaBOOT_168_diecimila.hex

And for ATmega8 // 16 MHz, FUSES:

avrdude -c usbasp -p m8 -U lfuse:w:0xdf:m -U hfuse:w:0xca:m
avrdude -c usbasp -p m8 -U flash:w:ATmegaBOOT.hex

for diff work:


diffy=/storeddiffs/diff_`date +%b-%d-%y`.log
#diff -ar --exclude="/diff/*" --exclude="/storeddiffs/*" --exclude="/dev/*" --exclude="/proc/*" / /diff > $diffy # runs out of memory

rsync --write-batch=$diffy -av --delete --exclude /sys --exclude /dev --exclude /proc --exclude /diff --exclude /storeddiffs / /dif

and we copy this as diffy to /etc/cron/daily

for jekyll:

  • bash to remove and add leading zeroes (after re-calculate to match frames:

for file in `ls ../*.jpg`
new=`basename $file .jpg`

vz="$(echo $new | sed 's/0*//')"
x=`expr $new - 96` 
zz=`printf "%08d" $x`
convert $file ../ital/${zz}.jpg -compose difference -composite test${new}.jpg
  • now we do it like this:

new=46 # start frame for english

while [ 1 = 1 ]
    yy=`printf "%08d" $new`
    x=`expr $new + 864` # whatever difference is...
    zz=`printf "%08d" $x`
# and scaling??
    convert -resize 720x576 ../jek-image-dutch/${zz}.jpg ${yy}.jpg -compose difference -composite ../diffdutchuk1/${zz}.jpg
    new=`expr $new + 1` 
  • jpgs to avi
    mencoder "mf://*.jpg" -mf w=800:h=600:fps=25:type=jpg -ovc lavc \
       -lavcopts vcodec=mpeg4:mbd=2:trell -audiofile test.wav -oac copy -o output.avi
  • and to VCD (700MB)


mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xvcd -vf \
   scale=352:288,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
vbitrate=1152:vrc_maxrate=1152:acodec=mp2:abitrate=224:aspect=16/9 -ofps 25 \
   -o jekylldiff1.mpg diffdutchuk1.avi

then to make vcd:

vcdimager jekylldiff1.mpg

and burn with:

cdrdao write --driver generic-mmc-raw videocd.cue

to avoid error message: Drive does not accept any cue sheet variant

numerical data to wav


saveaudio("testt",xx,"mu",16) (16 bit mu-law)

commandline misc

  • remove all files from .tar.gz
    tar tf <file.tar.gz> | sort -r | while read file; do if [ -d "$file" ]; then rmdir "$file"; else rm -f "$file"; fi; done

[from: http://www.commandlinefu.com/commands/view/2573/remove-all-files-previously-extracted-from-a-tar.gz-file. ]

  • imagemagick diff images
     convert p1090152.jpg p1090153.jpg -compose difference -composite test.jpg
  • and scale
    convert -resize 720x544 00000093.jpg 00000093.jpg
  • mencoder jpegs to avi (in zsh):
    mencoder "mf://*.jpg" -mf w=800:h=600:fps=25:type=jpg -ovc lavc \
       -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o output.avi

(and to add audio (xored?): -audiofile filename)

  • find
    find . -newerct '1 minute ago' -print 
    find / -mmin -10
  • ifconfig mac address
    ifconfig wlan0 hw ether 00:19:d2:29:ae:7e
  • gdb
    attach <process id>
    x 0x8049180

step one byte at a time through memory

[not /dev/mem seems otherwise to this access]

  • search man pages:
    man -k stderr
  • echo to an xterm

in the xterm:


then eg.:

echo "llllllllll" > /dev/pts/3

or to interpret commands:

echo $(whoami) > /dev/pts/4

but this uses command substitution and dumps output to the /dev/pts

  • resize lots of images with imagemagick
    for i in `ls *.JPG`; do convert -resize 50% -quality 80 $i conv_$i; done
  • from camera to b/w scan:
for img in `ls *.jpg`
 convert -resize 50% -quality 80 -rotate -180 -colorspace gray $img -contrast -contrast -contrast -contrast rr$img

  • backup imap with offlineimap:
accounts = Test
[Account Test]
localrepository = LocalExample
remoterepository = RemoteExample
[Repository LocalExample]
type = Maildir
localfolders = ~/Test
[Repository RemoteExample]
type = IMAP
remotehost = xxxxx.co.uk
ssl = yes
remoteuser = xxxxx@xxxxx.co.uk
  • beep
    beep mute is in alsamixer
  • WPA
    wpa_passphrase essid passphrase > /etc/wpa_supplicant.conf 
    wpa_supplicant -B -c/etc/wpa_supplicant.conf -iwlan0
  • text to pdf
    e2ps -nh diana.txt > diana.ps
    ps2pdf diana.ps

and for diff in june:

first strings eg.

cat diff_Jun-12-11.log | strings -n 12 > diff_Jun-12-11.log.strings

replace line break with space

 tr '\n' ' ' < diff_Jun-12-11.log.strings > jun12-strings12sansbreaks
e2ps -af Helvetica -p -nh -size 6 -line 120 diffjune03strings > diffjune03strings.ps

very small, landscape:

e2ps -nh -l -size 1 diana.txt > diana.ps
  • grep in binary file (treat binary as ascii)
    grep -a purl 
  • and show offset in bytes of the match
    grep -aob test
  • most recent// and head
    ls -t Wiki/images | head
  • use of watch as in:
    watch --no-title --interval=5 "curl -Is slashdot.org | egrep '^X-(F|B)' | cut -d - -f 2"
    watch tail /var/log/messages
  • redirection of STDERR = 2> :
    ./stego -e -t ~/projects/steganographia/island.txt ~/projects/steganographia/island.txt testout 2> tttt
  • stderr to less
    ./bbn_80211b_tx.py 2>&1 | less
     for file in `ls *`; do cat $file | text2wave -o $file ; done  
    wget -c // to resume
    gpsbabel -t -i garmin -f /dev/ttyUSB0 -o gpx -F gpsfile.gpx
     rsync -av --delete /root/ /media/rsync
  • git:

create repo on github, then in empty directory:

git clone git@github.com:microresearch/byron.git

then copy in code and…

git add codedir
git commit
git push

other commands…

git pull
git checkout -f master ;; to overwrite all local changes
git diff
./readrng -d /dev/ttyUSB0 -q 512  :: to fill entropy buffer for /dev/random
gocr cuc1.png > cucumber_screen6   OCR
modprobe snd-pcm-oss
lsof -r 1 -i :22 // who is there?
xawtv-remote snap jpeg 320x240 xxx.jpeg
echo "sensor_fps:30" > /proc/cpia/video0

network/data forensics

kismet -c wlan0
tcpdump -s 0 -A
  • tcpreplay and driftnet
    airdecap-ng Kismet-Sep-25-2009-12.pcapdump                                                                                     
    tcpreplay -t -i lo Kismet-Sep-25-2009-12.pcapdump-dec
    driftnet -i lo                                                                                                                 
  • raw sniff in scapy
    pkts = sniff(prn=lambda x:sys.stdout.write(str(x)))
    tcpdump -s 0 -w - | devdisplay 240 100 1 // raw packets
    tcpdump -s 0 -w - | tee pipe > /dev/dsp & ; cat pipe | devdisplay 240 240 2

which could equally well be:

tcpdump -s 0 -w - | tee /dev/dsp | devdisplay 240 240 2
tcpflow -i eth0  // dumps reconstruction/tcpfollowed also with -C or -cg


  • zsh number substitution
     scp images_2/p10508{06..14}.*  katier@
  • sort in numerical:
    ls xyz*([0-9]*).jpg | nawk -F'xyz' '{print $NF, $0}' | sort -n | cut -d ' ' -f2-
  • one liner:
    for file in `ls *.jpeg`; do gocr $file done > ghost_out
  • fix for space/new lines:
for file in `ls *.mp3`
new=`basename $file .wav`
sox $file ${new}.wav
  • one-liner
    while true; do mplayer /root/dump/test.wav -ao jack
  • rawify
for file in `ls *.wav`
new=`basename $file .wav`
sox $file -r 8000 -u -b -c 1 ${new}.raw
  • shuffle
for file in `ls`
mv $file $new
  • and to use to cutup audio:
    ./rawify.sh // convert to raw (8000 samples p/s)
    split -a 4 -d -b 8000 ../full_exq.raw // split into 1 second fragments pref in new dir
    ./shuffle.sh // shuffle these
    cat * > fulllll // cat these
    sox -t raw -r 8000 -u -b 8 -c 1 fulllll full.wav // back to wav
  • evp-shell

// evp to from windowsize overlapon/off

for file in `ls *.wav`
new=`basename $file .wav`
sox $file -r 44100 -u -b 8 -c 1 trans${new}.raw
cat trans${new}.raw | evp 8 32 400000 0 > evp${new}.raw
sox -r 44100 -u -b 8 -c 1 -v 0.5 evp${new}.raw evp${new}.wav
rm *.raw
  • speaks files from list

cat test_sed2 |
while read line
flite $line

  • rotate all images:
for img in `ls *.jpg`
  convert -rotate -90 $img rr$img
  • concatenate wav files
    sox *.wav (or list) concat.wav


  • adding up wordcounts:
    awk '{sum+=$1} END{printf("%d\n",sum)}' testwc

GPS track and waypoint editing

using viking

  • seems to be the preferred way. Notes:

1] Acquire GPS works for Garmin (/dev/ttyUSB0)

2] Once acquired expand the Acquired left item and waypoints. Right click on an expanded waypoint and select GOTO

3] Maps - Add new map layer. Openstreetmap seems to work best. Make sure is moved down below our gps layer. Right click always to change options.

4] Crtl - + for zoom out and in.

5] Make a new TrackWayPoint layer and cut and paste tracks or waypoints into this and then right click to export this layer.

Viking reference: http://viking.sourceforge.net/mediawiki/index.php/Viking\_Reference\_Manual#Export

using gpsman

(can't run as root: remember on root: xhost +)

extract one gps track from gpx:

1] open in gpsman (running as xxxxx)

2] import gpx

3] got to data/track/export/gpx/select

learning python

own example code:


potential projects -


natural language:

scapy: sniffeur.py

M-; - comment/uncomment region


lunar phases

C-u M-x lunar-phases

nmea to decimal in emacs

(defun nmeatodec()
  (goto-char (point-min))
      (re-search-forward "^[0-9]" nil t)
    ;; find lat, insert dec point, divide 60, insert
    (forward-char 1)
    (insert ".")
    ;; remove next .
    (re-search-forward "\\." nil t)
    (delete-char -1)
    ;; grab region and /60.
    (setq pnt (- (point) 2))
    (re-search-forward "," nil t)
    (setq decstring (buffer-substring pnt (- (match-end 0) 1)))
    (setq dec (/ (string-to-number decstring) 60))
    ;; kill and insert
    (kill-region pnt (- (match-end 0) 1))
    (goto-char pnt)
    (insert (number-to-string dec))
    (re-search-forward "," nil t)
    (forward-char 3)
    (insert ".")
    ;; remove next .
    (re-search-forward "\\." nil t)
    (delete-char -1)  
    ;; same again
    (setq pnt (- (point) 2))
    (re-search-forward "," nil t)
    (setq decstring (buffer-substring pnt (- (match-end 0) 1)))
    (setq dec (/ (string-to-number decstring) 60.0)) ;; now get rid of .
    (kill-region pnt (- (match-end 0) 1))
    (goto-char pnt)
    (insert (number-to-string dec))
    (re-search-backward "\\." nil t)
    (delete-char 1)  
    (forward-line 1)

which we can use with:

gpsbabel -t -i unicsv -f testlog -o gpx -F test.gpx

and then import into, say, viking…

shift whole org-mode tree

M S left/right


  • now using mew instead of gnus:
  • in .emacs
 (autoload 'mew "mew" nil t)
 (autoload 'mew-send "mew" nil t)
 ;; Optional setup (e.g. C-xm for sending a message):
 (autoload 'mew-user-agent-compose "mew" nil t)
 (if (boundp 'mail-user-agent)
     (setq mail-user-agent 'mew-user-agent))
 (if (fboundp 'define-mail-user-agent)

(setq mew-use-master-passwd t)

(autoload 'bbdb-insinuate-mew      "bbdb-mew"   "Hook BBDB into Mew")
(add-hook 'mew-init-hook 'bbdb-insinuate-mew)
(setq bbdb-send-mail-style 'mew)
(setq sc-auto-fill-region-p t)
(setq mew-smtp-user "user@domain")
(setq mew-smtp-server "server")
(setq mew-smtp-auth-list '("LOGIN"))   ; "CRAM-MD5", "PLAIN", and "LOGIN" can be used

and customize mew-field-completion-switch: ("To:" bbdb-complete-name)

  • to send an attachment/ make a multipart message:
    C-c C-a

and then c to copy file in

  • to read an attachment:
    n and then C-c C-e
  • later on attachment seem to disappear.

type . to re-analyse the message!


comment out loading twit.el in .emacs and then run (from ~/buff/hip)

make -f org2hpda


C-x r s reg - copy region to register reg
C-x r i reg - insert region from register reg

also numbers in registers (handy for keyboard macros):

C-u num C-x r n reg - store number in register
C-x r + reg - increment
C-x r g reg - insert


(load "~/buff/twit.el") (twit-show-recent-tweets) (twit-follow-recent-tweets)


C-c C-c on headline to add tags
C-c \
C-c / m 

Create a sparse tree with all headlines matching a tags search. With a C-u prefix argument, ignore headlines that are not a TODO line.

LaTex, org-mode and pdfjam/pdfnup

  • how to prepare a 2x2 A0 PDF using org-mode and pdfnup
    • prepare tex using org-mode:
    # Local Variables:
    # org-export-latex-append-header: "\
    # \\usepackage{geometry}
    # \\geometry{verbose,a2paper}
    # "
    # End:

    is placed at the end of the org-mode file and we use:

    M-x normal-mode

    to re-read the local variables

    then export C-c C-e to PDF as usual.

    • now we have A2 PDF which we can place four sheets on one page with:
      pdfnup island_forpdf.pdf --nup 2x2
    • which gives us an A2 PDF also but with a grid of 2x2 pages on each page.
    • enlarge to A0 using acroread, print to file and custom size

and to embed fonts:

# Local Variables:
# org-export-latex-append-header: "\
# \\usepackage{geometry}
# \\usepackage{times}
# \\usepackage{pslatex}
# \\geometry{verbose,a2paper}
# "
# End:

and see also:



latex embed pdf etc notes

  • how to embed bmp images

    NOT! - convert to pdf/png


    for file in `ls *.bmp`
    new=`basename $file .bmp`
    convert $file ${new}.png
  • how to make page breaks


  • how to embed other pdfs
    #+ATTR_LaTeX: page=4,width=5cm




notes for org-mode and agendas

for use with agenda - C-c a - can have several org-mode files into agenda


C-c . - add date as below and it takes title from:
C-c a n - whole year
  • other commands
    • Shift-arrows to change date elements
      M-S RET - insert TODO item
      C-c C-d - insert deadline
      C-c [ - add file to agenda list
      C-c ] - remove file
      C-c C-t - toggle status of TODO
  • commands
    v - view mode (eg. week, month, year, insert diary entries)
    RET - goto relevant org file

ange-ftp format


jack.el notes

  • fixed and uploaded new jack.el


run also: jack_simple_client as fake and disconnect all

while true; do mplayer /root/dump/test.wav -ao jack:port=simple,name=monk 

to prevent straight connection mplayer (doesn't now seem to work though):

mplayer /root/dump/test.wav -ao jack:name=monk 
(jack-ports "monk")
(jack-get-port-connections "monk" 0) ????
(jack-disconnect "monk" "out_0" "system" "playback_1") 
(insert (format "\n\n%s" (jack-ports "system")))

bibtex, bibliography and org-mode


… is at the end of the document

We also need the following in .emacs:

(defun org-mode-reftex-setup ()
(load-library "reftex")
(and (buffer-file-name)
(file-exists-p (buffer-file-name))
(define-key org-mode-map (kbd "C-c )") 'reftex-citation)

(add-hook 'org-mode-hook 'org-mode-reftex-setup)

(require 'org-exp-bibtex)

(require 'org-latex)
  (setq org-export-latex-classes
        (cons '("article"
                ("\\section{%s}" . "\\section*{%s}")
                ("\\subsection{%s}" . "\\subsection*{%s}")
                ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
                ("\\paragraph{%s}" . "\\paragraph*{%s}")
                ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))

  (setq org-latex-to-pdf-process
        '("pdflatex -interaction nonstopmode %b"
          "bibtex %b"
          "pdflatex -interaction nonstopmode %b"
          "pdflatex -interaction nonstopmode %b"))

An example from notes.bib:

 author = {Pynchon, Thomas},
 title = {The Crying of Lot 49},
 publisher = {Lippincott},
 year = {1966},
 address = {Philadelphia},
 isbn = {0397004184}

which we can cite with: C-c C-)

rest notes

\noindent // at start of line to kill paragraph indentation for that line
#+LaTeX: \setlength\parskip{5mm} // for spacing between paragraphs
C-u 0 C-l - puts line to top of screen
C-x C-f /ftp:newlife@1010.co.uk:/
(make-comint "sniff" "/root/sniffeur.py")
M-x image-dired-dired-display-image
C-x C- - = - smaller and larger fonts
Gnus: T T - turn off threading
C-c C-s C-d - gnus summary sort by date
flush the agent cache M-x gnus-agent-flush-cache RET M-x gnus-agent-expire[-group] RET


avrdude -c usbasp -p m168 -U lfuse:w:0xE2:m -U hfuse:w:0xDF:m -U flash:w:sd-reader.hex 
avrdude -c usbasp -p m128 -U lfuse:w:0xFD:m -U hfuse:w:0x99:m -U efuse:w:0xFF:m -U flash:w:serialtest.hex

set up latest avr-gcc

  • later than avr-libc-1.6.3 has


for the scripts to download and patch:

sudo apt-get install build-essential texinfo texi2html libcwidget-dev tcl8.4-dev tk8.4-dev libncurses5-dev libx11-dev binutils-dev bison flex libusb-0.1-4 libusb-dev libmpfr-dev libexpat1-dev libbfd-dev

and in .zshrc:

# User specific environment and startup programs
export PREFIX

export PATH

avr notes

(0 << [anything]) is always 0. T

The usual way to reset invidual bits in a control register is actually along the lines of:

USBCON &= ~(1 << [bit_name]); 

deeper AVR

compile and linking of assembly to elf

avr-gcc -Os -mmcu=atmega8 -Wa,-gstabs -I/usr/lib/avr/include/avr/ -o test.elf test.S

elf to hex:

avr-objcopy -j .text -j .data -O ihex test.elf test.hex

disassembly (use this to get linked full assembly!):

avr-objdump -S test.elf

(if we compile with -g // debugging // and not -Os (for size optimisation)??)

avr-gcc -g -mmcu=atmega8 -I/usr/lib/avr/include/avr/ memtest.c -o memtest.elf

also to note:

avr-gcc -g -mmcu=atmega8 -Wl,-Map,demo.map -o demo.elf demo.o

__exit->endless loop.

 26c: ff cf           rjmp    .-2             ; 0x26c <__stop_program>

flash/rom sections

  • The .text Section

    The .text section contains the actual machine instructions which make up your program. Includes:

  • The .initN Sections

    init code

    • The .finiN Sections

      exit code

  • The .data Section

    This section contains static data which was defined in your code.

  • The .bss Section

    Uninitialized global or static variables end up in the .bss section. Includes:

    • The .noinit Section
  • The .eeprom Section
  • avr-size

    The avr-size program (part of binutils), coming from a Unix background, doesn't account for the .data initialization space added to the .text section, so in order to know how much flash the final program will consume, one needs to add the values for both, .text and .data (but not .bss), while the amount of pre-allocated SRAM is the sum of .data and .bss.

  • malloc?

    The variables __malloc_heap_start and __malloc_heap_end can be used to restrict the malloc() function to a certain memory region. These variables are statically initialized to point to __heap_start and __heap_end, respectively, where __heap_start is filled in by the linker to point just beyond .bss, and __heap_end is set to 0 which makes malloc() assume the heap is below the stack.

    • what is the heap?

      The standard RAM layout is to place .data variables first, from the beginning of the internal RAM, followed by .bss. The stack is started from the top of internal RAM, growing downwards. The so-called "heap" available for the dynamic memory allocator will be placed beyond the end of .bss.

    • note from scrying makefile:

      EXTERNAL_RAM = -Wl,-Tdata=0x801100,–defsym=__heap_end=0x80ffff

      and we use memory pointer directly from 1100 - how do we avoid writing over variables (in serialtest.c case).

    • TODO test serialtest code in scrying

      in new code - also PORTE is set strangely (for gplog to 0x00 , for main log to 0xff)

      same in noise2.c where we write to 1100+ and don't set PORTE

      possible answer as using:

      avr-size noise2.o

      we see:

         text    data     bss     dec     hex filename
         8336       4      10    8350    209e noise2.o

      how can we see what is in data and bss (-s switch)?

      avr-objdump -sh -S noise2.o


      0000 0ad7233c

      but in the case of serialtest.o we have 621 bytes of data which is all text messages (for help and so on) which we know doesn't get overwritten???

      only conclusion is that data segment is not moved by Makefile (or possibility that as it is stored in ROM/FLASH????)



use serial board with diode bypassed for charging

Remember to delay before we switch Trimble Lassen SQ to NMEA

Ref also: http://www.picbasic.co.uk/forum/archive/index.php/t-1260.html


hg ci - commit
hg clone - clone external repo
  • other commands
    hg diff - show changes
    hg log - show all revisions
    hg diff -r 335 -r 338 - diffs between revisions
    hg export 338 337 336 > exportage - export patch


kernel config
make-kpkg clean
fakeroot make-kpkg --revision=custom.1.0 kernel_image
dpkg -i kernel-image-
update-initramfs -c -k 2.6.30 -t
cd /boot/grub/
uname -r for running kernel version

add latest initrd to menu.lst

uml [user mode linux]

apt-get install user-mode-linux uml-utilities
linux rootfstype=hostfs rw init=/bin/zsh

custom kernel

make mrproper
make mrproper ARCH=um
make defconfig ARCH=um
make menuconfig ARCH=um
make ARCH=um


export ARCH=um


  • kino - capture, export as dvd-video dual pass (dvd video directory)
    mkisofs -dvd-video -o juego.iso juego                

and regular data CD:

mkisofs -r -R -J -l -L -o jek.iso jekyll

test with

mount -t iso9660 -o loop jek.iso /mnt/

burn with

cdrecord dev=0,4,0 -v -overburn --eject speed=4 jek.iso

or better:

growisofs -dvd-compat -Z /dev/cdrw=walker.iso


mencoder input.avi -idx -ovc copy -oac copy -o output.avi // fix broken indexing

or to excerpt:

mencoder -ss 2260 -frames 8000 -ovc copy -oac copy first.avi -o test.avi

seek to 1000 (seconds?) and convert 10 frames:

mplayer -ss 1000 -frames 10 -vo jpeg:outdir=/tmp:quality=75 test.avi -ao null
  • raw:
    gst-launch-0.10 filesrc location=/root/pipe ! videoparse ! xvimagesink
  • or in mplayer:
    mplayer -rawvideo w=720:h=576 -demuxer rawvideo  /dev/sda
    gst-launch-0.10 v4l2src device=/dev/video1 ! queue ! ffmpegcolorspace ! theoraenc quality=1 ! queue ! oggmux name=mux alsasrc ! audio/x-raw-int,rate=8000,channels=1,depth=8 ! queue ! audioconvert ! vorbisenc ! queue ! mux. mux. ! queue ! shout2send ip=giss.tv port=8000 username=source password=ry92b mount=/micro.ogg
    mencoder mf://"@list.txt" -mf w=800:h=600:fps=10:type=jpg -ovc lavc \
       -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o output.avi
    mencoder input.avi -idx -ovc copy -oac copy -o output.avi // fix broken indexing

and to encode raw to avi:

 mencoder /storeddiffs/diff_Jun-21-11.log -ofps 25 -noaspect -demuxer rawvideo -rawvideo fps=25:w=400:h=320:format=i420 -ovc lavc -lavcopts vcodec=mpeg4 -ffourcc divx -o output.avi
gst-launch-0.10 filesrc location=/root/pipe ! videoparse ! xvimagesink
mplayer -rawvideo w=720:h=576 -demuxer rawvideo  /dev/sda
  • record stream:
    mplayer -dumpstream -cache 8000 mms://streaming-26c3-wmv.fem-net.de/saal3
  • simple webcam
    gst-launch-0.10 v4l2src device=/dev/video0 ! xvimagesink

see also own static.py

data carving

  • using foremost to extract:
    foremost -v /dev/sdc1

config file is in: /usr/local/etc/foremost.conf

paper sizes ref

cm //inches

ISO A0 84.09 x 118.92 33.11 x 46.82

ISO A1 59.46 x 84.09 23.41 x 33.11

ISO A2 42.04 x 59.46 16.55 x 23.41

playing with images in octave

rough notes/example code

imshow(0,gray) # to set grayscale???
q = 6 ./ hilb(16) + 26
y = jpeg(x, q); # from jpegtools
imagesc(y, 2);
saveimage ("my_output.ps",y,ps);

myfile = fopen("../diana.txt", "r");
al = fread(myfile,[8,8],'uchar')'; # read as 8x8 matrix

QTx = quant(x, al);

diana = imread('../diana.pgm');

function [Stego, Extracted] = LSBHide(Cover, Hidden, n)
Stego = uint8(bitor(bitand(Cover, bitcmp(2^n - 1, 8)) , bitshift(Hidden, n - 8)));
Extracted = uint8(bitand(255, bitshift(Stego, 8 - n)));

[Stego, Extracted] = LSBHide(xxx, xxxxx, n);

shell scripting with octave

  • for rough image analysis (white vs. black pixels):
  • image_an.m
pkg load image;
img = rgb2gray(xx);
ibw = img;
disp(numel(ibw (ibw < m )))
  • analyse.sh

for file in `ls *.jpg`
octave -qf image_an.m $file

notes for (island2) gallery setup

avoid screen blanking

xset s off

and edit /etc/X11/xorg.conf and restart X:

Section "ServerFlags"
Option "BlankTime" "0"
Option "StandbyTime" "0"
Option "SuspendTime" "0"
Option "OffTime" "0"

startx on boot without any login

  • edit /etc/inittab with:
x:5:once:/bin/su PREFERED_USER -l -c "/bin/bash --login -c /usr/bin/startx >/dev/null 2>&1"


  • .xinitrc example: machine 1
xset s off
xmodmap /root/.Xmodmap
exec awesome &
exec xterm -maximized -exec watch tail /var/log/syslog &
sleep 4s
exec xterm -exec top &
exec xterm -exec /root/test.sh

machine 1 is now running minicom… (usb serial must be plugged in before booting)

  • .xinitrc example: machine 2
killall -9 evilwm
xset s off
exec evilwm &
exec wireshark -i eth5 -f "icmp" -k &
sleep 20s
exec xterm -geometry 80x20+0+0 -exec minicom
  • open an xterm with dmesg showing but not closing - sleep for 1000 days
sleep 1000d
  • edit /etc/rc.local for other post-boot options


  • for dhcp
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface - use DHCP to find our address
auto eth0
iface eth0 inet dhcp
  • for static
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static


with address of switch:

arpspoof -i eth0


tcpdump -s 0 -w - icmp> /dev/dsp

both in /etc/rc.local

wireshark with ringbuffer

wireshark -i eth5 -f "icmp" -k -w test -b files:10 -b duration:10

mini-scry filesystem for SD cards

mkfs.vfat -F 16 /dev/mmcblk0p1

gnuplot tricks

  • multiple plots and colours
    set multiplot
    set style line 1 linecolor rgb "green"
     plot "whitenoise06022010.log" w lines ls 1
  • scaling one data set against another:
    plot "/mnt/monk66" using 3 with lines, "/mnt/monk66" using ($1)/1000 with lines

python and gnuplot (for GPS)

from pylab import *
import csv, os, Gnuplot, Gnuplot.funcutils

g = Gnuplot.Gnuplot(debug=1)
NMI = 1852.0
D2R = pi/180.0

#data = sys.argv[1]
#title = sys.argv[2]

def read_csv_file(filename):
    data = []
    for row in csv.reader(open(filename)):
    return data

def process_gps_data(data):
    latitude    = []
    longitude   = []
    intensity   = []
    gsr         = []
    for row in data:
        latitude.append(float(row[0][0:2]) + \
        longitude.append((float(row[1][0:3]) + \
#        gsr.append(float(row[3]))

#    return (array(latitude), array(longitude), \
#                array(intensity), array(gsr))

    return (array(latitude), array(longitude), \

#(lat, long, intensity, gsr) = process_gps_data(y)
(lat, long, intensity) = process_gps_data(y)
# translate spherical coordinates to Cartesian
py = (lat-min(lat))*NMI*60.0
px = (long-min(long))*NMI*60.0*cos(D2R*lat)
#pack px, py, intensity and gsr into newy
for x,yz,z,zz in zip(px,py,intensity,newgsr):

g('set parametric')
g('set style data line')
g('set surface')
g('unset key')
g('unset contour')
g('set dgrid3d 40,40,10')
g('set xlabel "metres EW"') 
g('set ylabel "metres SN"') 
g('set label "signal intensity"at -100,0,1000') 
g('set view 60,20')
g.title("underwater friday 6th")
g('set term png size 1200,800')
g('set output "/root/projects/summit/logfiles/images/river2.png"')

#g.splot(Gnuplot.Data(newy, using=(1,2,3), with='lines'),Gnuplot.Data(newy, using=(1,2,4), with='lines'))
g.splot(Gnuplot.Data(newy, using=(1,2,3), with='lines'))

fixing a hard drive

with errors

sudo e2fsck -b 32768 /dev/sdb1
sudo mount -t ext3 -o sb=131072 /dev/sdb1 /mnt 

avrdude and efuse on atmega32u4

change avrdude.conf:

memory "efuse"
    size            = 1;
    write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
                      "x x x x  x x x x  i i i i  i i i i";

    read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
                      "x x x x  x x x x  o o o o  o o o o";
    min_write_delay = 9000;
    max_write_delay = 9000;

code rocks

own software:

  • older



    /dev/mem | strings | espeak --stdout | ./i_am 4 2 1 > /dev/dsp
  • more recent


    cat /dev/dsp | ./evp 1 32 8000 1 > ~/pipe
    play -t raw -r 8000 -u -b -c 1 pipe



  • tee:
    tcpdump -s 0 -w - | tee /dev/dsp | devdisplay 240 240 2
  • turn off swap
    swapoff -a
  • play a pipe
    play -t raw -r 44100 -u -b -c 1 pipe

for example from:

nice -n -10 top -d.1 | tee pipe

[for top always use 44100]

top commands:

A,M,N,P,T - alt display, sort by memory, PID, CPU, time

k - prompt to kill a PID

  • espeak:
    cat /dev/mem | strings | espeak --stdout > /dev/dsp

or for correct speech:

cat /dev/mem | strings | espeak --stdout > ~/pipe
play -t raw -r 22050 -u -1 -c 1 pipe

maybe insert evp process in there

  • dev/mem// use of tee for multiple processes
    cat /dev/mem | tee >(devdisplay 240 240 1) | strings | espeak --stdout | ./jekyll 2 3 > /


stty -F /dev/ttyUSB0 115200

set list

START: stty, swapoff, old kernel

swapoff -a
stty -F /dev/ttyUSB0 115200

5 acts:

1- process table and xxxx….sh yyyyy….sh

nice -n -10 top -d.1 | tee pipe
play -t raw -r 44100 -u -b -c 1 pipe

also with: A,M,N,P,T - alt display, sort by memory, PID, CPU, time (and G for group)

2- evp/i_am/speech somehow

cat /dev/mem | strings | espeak --stdout > /dev/dsp
play -t raw -r 44100 -u -b -c 1 pipe

3- self

./self > /dev/dsp

4- code rocks

cat /dev/mem > /dev/ttyUSB0
cat /dev/ttyUSB0 > /dev/dsp

5- rock off:

cat /dev/mem > /dev/ttyUSB0
cat /dev/ttyUSB0 | tee /dev/dsp > /dev/mem


kino error when importing .mov: Insufficient audio data or severe sync problem solved by pre-conversion with:

ffmpeg -i p1120395.mov -target pal-dv test.dv

where gthumb stores deleted files: .local/share/Trash/

ARM STM32F4 notes

makefile etc. fixed

  • wm8371 just seems to output linein (can erase code and doesn't change anything)
  • check wm connections (GND and power all checked out)
  • check it's really programming (do led flash codeDONE but not flashing)
  • how to be sure code is running and if not why not?

bootloader is running (but boot0 is held low), some hardware problem (checked all pins), some software problem with flashing code, programming doesn't really work(but tested on stm discovery itself), led does light from meter so that's OK, memory map/ld or something else is wrong

now with code in ~/stm32_code/stm32-templates/stm32f4-discovery we flash led on our board…

so seems like:

  • problem with makefile
  • startup file
  • other problem

in delay code

using new makefile we can compile and load delay code, led flashes but codec doesn't seem to work and binary is large

now fixed - as -j text and data bit in makefile and also problem with ld file - FIXED

so now delay works but audio is muffly (test with in and out filter - WORKS!)

how to program


connections: 4 pin header on our test board=3.3v, SWCK, GND, SWDIO from left

and on STM board from left (jack to right)=6 pins=

1-VDD 2-SWCLK 3-GND 4-SWDIO 5-NRST 6-reserved

so we use straight 1/2/3/4 (not sure on reset yet)

make burn

from this directory

or if we are in delay code…

make stlink_flash

and then RESTART

see: http://survivalengineer.blogspot.de/2013/01/turning-stm32-evaluation-board-into.html


use STM32F405RGT6 per ebrombaugh schematic

for above see: http://ebrombaugh.studionebula.com/synth/stm32f4\_codec/index.html

we have stm32f4discovery (what is extra hardware on there?)

but why not use onboard DAC (is it faster otherwise?)

  • how do we program without JTAG (over USB?) how to test this?


or use USB bootloader: http://wiki.eluaproject.net/STM32F4DISCOVERY

and: http://leaflabs.com/docs/bootloader.html

seems like we can use discovery board and SWD port as a programmer for other boards:


see also:


Author: root <m@1010.co.uk>

Date: 2014-10-30 22:37:21 GMT

HTML generated by org-mode 6.31trans in emacs 23