Dr. Lawlor's Code, Robots, & Things

November 11, 2018

UAF Hackathon 2018 Results

Filed under: Random Thoughts — Dr. Lawlor @ 8:22 pm

I wrote up the results from the excellent 2018 UAF Hackathon, a one-weekend build session that combines computer code, embedded hardware, and awesomeness!

Advertisements

October 19, 2018

Free up RAM on a Raspberry Pi by stopping X

Filed under: Linux, Programming, RaspberryPi — Dr. Lawlor @ 1:56 pm

There’s a very simple trick to free up several hundred megs of RAM on a Raspberry Pi: switch to a text console (ctrl-alt-F1), log in, and shut down the graphical user interface:

sudo service lightdm stop

This liberates over 150 megabytes of RAM, allowing huge programs to compile without hitting swap (although all of OpenCV still takes about 2 hours to compile from scratch).  If you need more terminals, ctrl-alt-F2 (through F6) are available.

To get back to the graphical interface, just:

sudo service lightdm start

Press ctrl-alt-F7 to see the GUI again once it’s running.

September 13, 2018

Observational x86 Instruction Usage in 32 and 64 bit code

Filed under: Programming — Dr. Lawlor @ 3:23 pm

Several years ago I wrote a tiny script to measure the frequencies of x86 instructions used by actual programs.  The big surprise for me was that in 32-bit programs, the most common instructions are just doing data movement and control flow:

42.4% mov instructions (data movement)
5.0% lea instructions (quick arithmetic)
4.9% cmp instructions
4.7% call instructions
4.5% je instructions
4.4% add instructions
4.3% test instructions
4.3% nop instructions (for alignment)
3.7% jmp instructions
2.9% jne instructions

Today, in 64-bit mode,  the overall pattern is the same, with a slight drop in mov probably due to more registers being available:

33.6% mov instructions
6.9% cmp instructions
5.3% call instructions
5.1% je instructions
4.7% jmp instructions
4.4% nop instructions
4.4% lea instructions
4.1% test instructions
3.9% add instructions
3.9% push instructions

Script to measure instruction frequencies and register usage on a 64 bit executable:

#!/bin/sh

file=”$1″
d=”dis.txt”
objdump -drC -M intel “$file” | \
awk -F: ‘{print substr($2,24);}’ | \
grep -v “^$” > “$d”
tot=`wc -l $d | awk ‘{print $1}’`
echo “$tot instructions total”

echo “Instruction usage breakdown:”
awk ‘{print $1}’ $d | sort | awk ‘{
if ($1==last) {count++;}
else {print count, last; count=0; last=$1;}
}’ | \
sort -n -r | \
awk ‘{printf(” %.1f%% %s instructions\n”,$1*100.0/’$tot’,$2);}’ \
> dis_instructions.txt
head -15 dis_instructions.txt

echo “Register and feature usage:”
for reg in eax ebx ecx edx esp ebp esi edi \
rax rbx rcx rdx rsp rbp rsi rdi r8 r9 r10 r11 r12 r13 r14 r15 \
xmm ymm zmm \
“0x” “,” “+” “*” “\[” \
“BYTE PTR” “[^D]WORD PTR” “DWORD PTR” “QWORD PTR” “XMMWORD PTR”
do
c=`grep “$reg” “$d” | wc -l | awk ‘{print $1}’`
echo | awk ‘{printf(” %.1f%% \”‘”$reg”‘\” lines\n”,’$c’*100.0/’$tot’);}’
done

August 22, 2018

Screen Sharing to Extron ShareLink from Linux

Filed under: Linux, Sysadmin — Dr. Lawlor @ 5:12 pm

Like many hardware vendors, the network-to-HDMI Extron ShareLink boxes clearly support Windows and Mac, but there’s no sign of how to make them work on Linux.

But they do have a Chrome app called MirrorOp Sender that seems to work in Chrome from my Ubuntu 18.04 machine, and can successfully connect and share your Linux desktop across the network, with a nice easy to use graphical user interface.  It even successfully downscales my 4K display to 1080p for streaming.

Internally, the Chrome app does all the network communication inside a 2.7Mb PNaCl binary.  The network protocol doesn’t look like anything I’ve ever seen: it starts with a connection to TCP port 389 but doesn’t send any data (a port knock?), then opens the control plane channel on TCP 3268 and exchanges a bunch of setup and metadata packets that start with “wppcmd” before settling down to a “wppaliveROCK” / “wppaliveROLL” 3 second keepalive ping cycle, and finally streams the video data in JFIF format over TCP port 8080.  (A vaguely similar protocol is discussed for the Creston Airmedia hardware here.)

August 10, 2018

Navier-Stokes GPU Fluids via Multigrid

Filed under: Graphics, Web — Dr. Lawlor @ 10:23 am

Check out my live demo of GPU fluids via multigrid.  It’s swirly!  I still need to write up the paper describing the multigrid pressure-free update, but here’s a 2015 lecture note describing the general approach.

(I’m reposting some of my old demos so I can show them off during SIGGRAPH 2018)

June 24, 2018

Legit Websites that Track Everything You Do

Filed under: Mass Surveillance, Random Thoughts — Dr. Lawlor @ 9:44 pm

TL;DR Version: many legitimate websites record extremely detailed data about everything you do on the site, including your mouse position and where you scroll, using a tool like ForeSee Replay.  Since there is no global opt-out, you need to install an ad blocker to prevent this kind of bandwidth-wasting privacy intrusion.

This afternoon I opened a few eBay tabs, and I have a vague recollection of seeing one of those standard ForeSee popups asking if I’d like to participate in a survey.  I almost always say “No Thanks”, and I’m 99% sure I did not agree to a survey today.

This evening, I noticed my laptop’s outbound network traffic was heavy, which seriously slows down our rural DSL (4mbit down, 1mbit up).  The more I looked at this, the less I liked it: chrome was sending piles of HTTPS data off to four different AWS-hosted servers that list themselves as “ForeSee Record Status (cxReplayRecorder) v2.4.11” (IP addresses: 52.203.189.90  52.204.75.38  52.206.152.106  52.1.20.34, but they’re load balanced).  I grabbed some of the traffic with Wireshark, but it’s encrypted, so I still have no way of telling what exactly was sent.

I knew the traffic was coming from chrome, but I have a bad habit of keeping about a hundred tabs open (!), so I carefully watched the bandwidth usage as I incrementally closed tabs.  As soon as I closed the ebay tabs, the traffic stopped.  Reopening the tabs didn’t bring the traffic back–it only happens when the tracker code decides it has enough data to be worth sending back out.

ForeSee seems particularly evasive in the way it phrases the ‘survey’: not only will you (maybe) answer questions, the ForeSee® Replay code also tracks every mouse click, mouse *hover*, and scroll that you do on the site.  Their Replay viewer lets them see heat maps showing where people click, or even hover the mouse.  (This is useful data for building the site, but it’s not disclosed that it is part of the ‘survey’.)

The tracking servers dump a pile of metadata, from which I can see:

  • There are about 10 active replay recorder servers right now.
  • Each server is receiving about 1,000 ‘transmits’ per minute.
  • Each ‘transmit’ occupies about 100 kilobytes (on average), which is a lot of bandwidth, and a lot of information captured.
  • A typical server seems to capture over a terabyte per week, from over 10 million users.

To stop this, install an ad blocker like the free Ad Block Plus, and add “/foresee/*” to the filter list.

May 24, 2018

Fusing basalt dust into obsidian glass using sunlight

Filed under: ISRU — Dr. Lawlor @ 7:59 pm

This is a public link to my old Facebook post about melting basalt dust into glass using my solar concentrator.   Plus a short newly released video of the melting process.

3D printed window pane aging well

Filed under: 3D Printing, ISRU — Dr. Lawlor @ 6:22 pm

The three-layer window pane I 3D printed last summer from clear PETG plastic has experienced zero issues so far, after a year of exposure to Fairbanks weather.  It doesn’t get much sunshine, but hasn’t leaked or noticeably frosted up.  And it still looks goofy!

April 14, 2018

Simple Encrypted Drive on Linux

Filed under: Linux, Random Thoughts — Dr. Lawlor @ 11:44 am

Here’s how to create a separate dedicated encrypted filesystem on a modern Linux machine.

  1. Create a large *sparse* file, here 60,000 MB maximum.  Sparse is faster to create and uses less storage, because the underlying file only gets filled in as you write data.  However, this may make the data write pattern visible to a sufficiently dedicated attacker; use “count=60000” from /dev/urandom instead of seek to prefill a dense file.
    • dd if=/dev/zero of=grades.img seek=60000 bs=1024k count=1
  2. Mount the file as an encrypted block device.
    • cryptsetup --cipher aes-xts-plain64 --key-size 256 create grades grades.img
  3. Make the filesystem.
    • mkfs.ext4 -m 0 /dev/mapper/grades
  4. Mount the filesystem to a directory.
    • mount /dev/mapper/grades grades
  5. You can now copy files on and off the encrypted path.  To clean up, unmount:
    • umount grades
  6. Now remove the block device and you’re secure again.
    • cryptsetup remove grades

April 2, 2018

Dissolving & Remelting Silver

Filed under: Chemistry, ISRU, Mining, Space — Dr. Lawlor @ 11:59 pm

My weekend side project these past few months has been doing chemistry on metals. I’ve been watching the Cody’s Lab precious metals refining series on YouTube, and the technology seems interesting and useful to me not only because I like working with metals, and live on a gold mine, but also for space exploration where we need to extract metals from rocks to be able to build things in space.

Yesterday I finished reprocessing a few dollars worth of sterling silver into fine silver, by dissolving the sterling in homemade nitric acid, precipitating out the silver by displacing it with copper, driving off the oxygen and other contaminants in my solar furnace, and finally melting a nice bead in a freshly made graphite crucible.

The full story and photos are on my Facebook post.  (There because it’s easier to post photos on Facebook.)

SAMSUNG CAMERA PICTURES

Older Posts »

Create a free website or blog at WordPress.com.