dxld@darkboxed.org ~ $ tail -f /var/log/sysblog

Debian, Exim4: Sending only University Mail Through a Smarthost while Rewriting the Sender

Turns out some lecturers at my university filter mail based on whether it's from the @students.example.org domain. Normal people would probably just add the university mail account to their mail client and try to remember to send it form the right account those few times they have to email someone at the university, but since I'm not a normal person and I know I would never remember and then important stuff is going to get lost in lecturer's spam filter I'm going to have my mail server do it!

Since the University's mail servers know they are the proper origin for the @students.example.org domain they won't just let me send an unauthenticated mail with the sender in that domain from the outside. So I'll have to get out some Exim magic.

Fist some assumptions:

--Wed Nov 27 21:51:19 CET 2013

There are three things we need to do:

So let's dive right in.

Router Configuration

In Exim outgoing and incoming mail gets routed by routers (crazy, right?), to catch mail to @example.org before it's sent the usual way we have to add a router that executes before the default 200_exim4-config_primary router for outgoing mail. So we create a new file called 100_university_router:


  debug_print = "R: university_router for $domain"
  driver = manualroute
  route_list = *.example.org smtp.example.org ; example.org smtp.example.org
  transport = university_smtp

Here we use the manualroute router-driver which allows us to redirect mail to an arbitrary transport, in our case an SMTP server.

route_list defines which domains get redirected to which server. There doesn't seem to be a way to match all subdomains including a base domain with one pattern so we list *.example.org and example.org seperately.

transport defines how to talk to the server we set in route_list. We'll define the university_smtp transport in the next step.

Transport Configuration

Now that we've Matched on the domain we need to Rewrite the sender address so the SPAM filters won't reject the mail, at least that's what happened with my university's setup. The priority number for this config file isn't important, I just picked 11.


  debug_print = "T: university_smtp for $local_part@$domain"
  driver = smtp
  tls_dh_min_bits = 512
  hosts_try_auth = <; ${if exists{CONFDIR/passwd.client} \
        {} \
  headers_rewrite = me@localdomain.local me@students.example.org

hosts_try_auth evaluates that unwieldy expression to get the username and password for the SMTP login to the university server. We'll create the passwd.clinet file in the next step.

headers_rewrite changes me@localdomain.local to me@students.example.org in all mail headers.

Now all that's left to do is to Tell Exim how to authenticate to the university's SMTP server.


*.example.org:my-user-name:my super secret password

Each line in this file matches the hostname of the SMTP server and defined the username and password to use for authentication. Because we used nwildlsearch in the above snippet we can use wildcards in the hostname field.

So there you have it, that wasn't that bad.

--Fri, 03 Jul 2015 02:48:02 +0200


Ok, ok ... I give up. There is no reasonably easy way to test a BIOS on the Bifferboard without a JTAG. So I bought the proprietary software crap thingy the other day. Funny thing, it was actually delivered on a physical DVD (4.7G for a ~40k tar file -.- ) instead of me being able to download it or something but whatever. So this was some ages ago. Never got around to actually doing anything with it. Well I did test it with the Wiggler paralell port JTAG adapter I built on a breadboard using the schematics provided but it didn't really work, for a multitude of reasons. Firstly I had to test it on another computer, over ssh obviously, because my desktop has no paralell port and BiffJTAG does not support add in paralell port PCI cards because it is hardcoded to bang bits to the paralell port I/O address.

--Tue Nov 22 17:45:24 CET 2011

Now to the interresting stuff: reverse engineering BiffJTAG. So there are two or maybe three things I'm trying to do right now. My primary goal is of course to have a Bifferboard run with only Free Software. In order to do that I need to replace the proprietary BIOS which is sort of already in the works. (see #dxboot) But in order to develop and most importantly test the Free BIOS I need to test it on device and for that I need a JTAG. While I was trying to do it without the need for the proprietary JTAG software I realized that it is just way too much pain without. Now I have the software but it doesn't work the way I'd like it to, say with a USB JTAG adapter. Sooo what I am doing now is bending BiffJTAG to read and write from somewhere other than the default paralell port.

--Tue Nov 22 17:59:14 CET 2011

Damn, so I never finished this. Since then a bunch of more attractive embedded boards have appeared so this got kind of boring. Turns out someone did add support to Coreboot I never did get around to trying that though. It doesn't really matter anyways since that board has long since stopped being produced, thank Jibbers..

--Fri, 03 Jul 2015 01:06:40 +0200


After playing with the SA612 chip and RF in general for some time I decided: I need an Oscilloscope. Now I already had a cheap portable USB-Oscilloscope (Syscompdesign CGR-101) it was actually quite nice for what it was. Very useful for AVR development and debugging of timers and interrupts. Also the PC software is Free Software which very much influenced my decision to buy it. However the scope is completely unusable for RF work because of it's 2Mhz bandwidth and only 20MS/s sample rate. For the longest time I actually used this thing to debug my 3.563Mhz Oscillator but i was only able to observe some seriously spiky signals (due to lack of sampling frequency) but the FFT was still usable and I was able to check that the mixer actually worked. Beyond that it was pretty ugly tough.

So I set out to find a new Oscilloscope. After lots of searching I found this post at the EEVBlog forums: Hantek - Tekway - DSO hack - get 200MHz bw for free. After reading the thread I found out that all the Tekway/Hantek DSOs actually run a custom DSO GUI on top of a Linux kernel which runs on a well known Samsung ARM SoC. Because of this and the fact that it actually seemed to be the best quality, low cost scope around I bought my very own TEKWAY DST1102B (100Mhz, 1GS/s) at PinSonne-Elektronik. The purchase went very smoothly I got the scope within one week or so.

Now I am proud owner of a very nice mid-range Digital Storage oscilloscope :D

--Wed Aug 17 01:49:40 CEST 2011

SA612 -- Double-balanced mixer and oscillator

Lately I've been in the mood to do some electronics hacking. I was having a pretty nice E-Mail conversation with a teacher/friend of mine, xh (aka. ixh, aka. Christoph) who's a passionate ham radio operator doing CW at 3.563Mhz. I figured why not try to build a receiver that can listen to what he's broadcasting.

Not too long ago we did a collective order of electronics components and he asked me to order some SA612s for him and after I figured out how awesome these chips are I added some for myself and now, finally I get to use them.

So the SA612 basically is everything you need for doing some very basic radio communication. It has an integrated oscillator driver that just needs some external capacitors and inductors or a crystal and some caps to get going. As well as an integrated Frequency Mixer that mixes the input signal with that produced by the Local-Oscillator thus producing f_LO - f_mix and f_LO + f_mix.


The internal circuit of the SA612's oscillator driver looks like this:

         +-----o---- > Vcc
         |     |
         L     |
        | |    |
     18k| |    |
        |_|    |
+---+    |   |/
| 6 |----o---|------ > to Mixer
+---+        |\!
+---+          |
| 7 |----------o
+---+          |
              | |
           25k| |
              _|_ gnd

I tried long and hard to get this oscillator working with LC tank circuits but it just wouldn't oscillate how i wanted it to. So in the end i decided to get a crystal that has approximately the frequency of xh's broadcasts and shift the frequency somehow or use whatever i get after the mixer. It's CW after all, so i should be able to get something.

This is a working Colpitt configuration for the oscillator. The one from the datasheet just wouldn't work properly. (didn't have a proper oscilloscope to inspect what was going on at the time)

       +-----------| 6 |
       |           +---+
      ---  C3
    |     |
    |    --- C1
    |    ---
    C     |       +---+
 L1 C     o-------| 7 |
    C     |       +---+
    |    --- C2
    |    ---
    |     |
      _|_ gnd

C3 ~ 1µ
C2 ~ 0.1 * C1

C1 and L1 depend on your oscillation frequency. Use good 'ol f_r = 1/sqrt(LC) to find some values.

--Mon Jul 25 06:59:26 CEST 2011
--Wed Aug 17 01:23:57 CEST 2011

TODO: Crystal circuits. Performance evaluation, comparison to LC.

dxboot pt2

Hehe, I think I just found the answer to most of my problems. For some reason Prochip (never heard of them before) has an open ftp server with documents consigning the RDC R8610 CPU and their demo board. Now I knew that for quite some time but never realized that the .doc files buried in the directory structure actually contained assembler code and explanations on how to initialize the CPU! To my complete surprise they show how to initialize the exact same SDRAM as that in the Bifferboard so I don't even have to go trough the chip's datasheet :D. They also show how to reset the CPU -- nice!

--Tue Jul 12 16:06:48 CEST 2011

Prochip's RDC Support stuff: ftp://ftp.prochip.ru/Support/RDC/R8610/

The documents I'm talking about: Here and Here

dxboot -- my journey through implementing a BIOS

Some time ago I bought myself a comparatively cheap Embedded system that can run a full blown GNU/Linux system, called the Bifferboard. On first glance it seemed to be a really good deal, 32Mib SDRAM, 8MiB flash, Ethernet, USB and a 150Mh x86 compatible CPU to drive it all. Unfortunately the Bifferborad ships with a proprietary boot loader/BIOS called BiffBoot.

Being the Software Freedom loving person that I am, I just could not accept using something as (comparatively) simple as an embedded system that is locked into needing a non Free boot loader/BIOS. So I started to reverse engineer BiffBOOT to see what it is doing to get the hardware going.

At the time I thought that the first problem I'd have to resolve in order to be able to write a Free replacement boot loader/BIOS for the Bifferboard would be to figure out how to talk to it's JTAG. After some research I concluded that the RDC CPU that drives the Bifferboard does not have any public information about it's JTAG interface available.

Luckily the guys selling the Bifferboard and it's proprietary boot loader/BIOS also sell a proprietary JTAG flashing utility (called BiffJTAG) that runs on GNU/Linux. I didn't like the idea of having to use this proprietary tool in order to replace the proprietary boot loader/BIOS but I did not see any other option at the time.

This has been the first time ever I dove under the High level language layer for anything other than a AVR Microcontroller. Unsurprisingly I had difficulties figuring out how to get going so I soon abandoned the project. Not only because I could not figure out the disassembled code but also because I simply would not use a proprietary tool for developing my Free replacement for BiffBoot and because school was not giving me much time/motivation at the time either.

As the summer holidays were getting ever closer I started to pick up interest in the project again. I started to make progress with disassembling BiffBoot when I finally figured out that the reset vector of modern x86 CPUs is at physical address 0xFFFF_FFF0. Originally I had thought the CPU would just start at 0x0 (relative to the BiffBoot binary I was analyzing) but the code there did not make the slightest bit of sense disassembled as 16 bit real-mode assembly. Using this piece of information however I was able to find the BIOSes real entry point and follow the execution flow from there.

I also had some problems understanding how the whole Port mapped I/O stuff worked, being used to the AVR's memory mapped I/O it seemed rather bizarre to me. But I soon figured out how to talk to the devices on the CPU's internal I/O bus and the PCI config space mostly thanks to my insights from reading the BiffBoot disassembly.

Now at this stage everything was going fine, I was going through the BiffBoot code, tracking its workings using a hacked together qemu and gdb setup (gdb behaves really strange in real-mode which is also one of the reasons i could not make sense of the code earlier) however I soon hit a roadblock when I realized that BiffBoot is writing to PCI devices' config space that don't even exist(neither in the documentation nor on the bus, I checked).

Although I didn't like not understanding parts of the code at first I decided to simply move on in order to keep myself going but there are a lot of references to non existent PCI devices in the BiffBoot code.

Right now I am fighting with getting the RDC R3210's North Bridge to make SDRAM working and getting into protected mode as well as a thousand other things (short listing follows). Anyways I'll keep anybody who reads this posted ;)

Things I am currently fighting with working on

Things that already work

--Mon Jul 11 23:24:26 UTC 2011

Hello World, this is my (B)log

So this appears to be my oh so simple Blog now. I wanted to have one forever but only just now i found the motivation to spit out the few lines of javascript to implement a markdown based blog that does what I want -- being just one file I can edit using Emacs and tramp over ssh that is.

--Mon Jul 11 21:33:51 UTC 2011

So while writing this I discovered a styling bug. I thought I had adjusted my site's width and font-size to get approximately 80 character per line wrapping, but I had assumed wrong. So now I changed the font to 'DejaVu Sans Mono' and corrected the width. It still looks kind of strange for some reason but at least the wrapping is correct now and it looks more like my local Emacs :)

--Mon Jul 11 22:15:30 UTC 2011

This is my personal braindump, its not really supposed to be a blog as in a thing that people actually want to read but rather a log as in a place for me to dump thoughts to and just write down what I'm doing. Anyone is welcome to read this dump though, just don't expect any language that actually makes sense or anything.

The source code for this (b)log is here: http://dxld.at/syslog.md its a pretty neat self contained perl script that uses pandoc to convert the markdown to html. The most awesome feature is that the actual markdown blog source is in the same file as the perl script thanks to perl's __DATA__ token.


dxld@darkboxed.org ~ $ man 8 darkboxed.org

[Not f'd — you won't find me on Facebook]