Boot / No Boot

Today while cleaning I found an old stm32 board carrying an STM32F030F4P6.

Turns out that PlatformIO supports it so just for fun I tried to blink some lights.

I couldn’t find my stlink at home but openocd can use a buspirate as a programmer.

It took a while to upload but after that I was able to launch gdb.

And the light was dead.

Strangely enough poking at the memory showed that the code indeed was there. After a long pause to think I noticed that the boot 0 jumper was misplaced.

The lights flashed and there was much rejoicing.

Hey, I wrote an assembler.

(It was about time I interrupted a never ending pile of drafts with something)

So, for a bit more than a month I’ve been attending a seminar on VHDL microcontroller design.

One of the workshops involved doing some simple exercises on eval boards. While the overall instruction set is small (fits on less than a page) the idea of programming and then assembling the sources using pencil and paper wasn’t very appealing at the moment.

It sure is a fun way to keep the mind fresh but given time constraints I couldn’t cope with such a long debugging cycle.

And… The obvious path was to build a tool.

I reused parts of python-lx200 because smart data structures and dumb code are nice. Most of this could be implemented with M4 too, perhaps for another code golf session.

A couple of years ago I’d probably tried to use Bison and Flex but doubt that I could manage something like this in just a handful of hours during the weekend.

There are some rough edges but as it is it supports labels, variable definitions and emits a valid IHEX file. I made a couple of dumb mistakes but they were really evident when looking at what Quartus made of the output file.

I’m quite proud of the result, I don’t know when was the last time I had so much fun doing a one off project, even if it wouldn’t be used anymore after the seminar.

The source code lives here: https://github.com/pardo-bsso/islyd-asm

Wisdom

Quite a while ago (in the last century nonetheless) my idea of a productive day entailed writing a lot of code, measured by size in any suitable metric.

Lately I’ve been writing less in volume but I realize that I spend a greater time thinking about the problem at hand as a whole and that it happens mostly in the background while I’m doing something else. By the time I’m again at the workstation everything falls into place.

Also, when stepping aside and contemplating whatever I engineered I can’t help to feel anything but pride. Perhaps except for the documentation I build things from the get go thinking of what I would like to have were I a library user, on terms of building blocks.

During the last two weeks I built a library to parse a protocol called LX200 used to control telescopes and I can’t be happier with the result (for now it’s at https://github.com/telescopio-montemayor/python-lx200 ). The first one was a roller coaster, due to some other issues I went back to a night owl schedule and I can’t remember when was the last time I had such prolonged and intense periods of flow. I also taught myself asyncio.

It’s terse, concise, and (mostly) well structured. My former self would’ve made a mess of a state machine tied together with pages of if statements that worked, for sure, but was a pain to extend or correct. Of course looking down the path and leveraging years of experience this things seem obvious now.

Coincidentally, the other day Eric wrote about the advantage of declarative/table driven approaches.

Sharing is caring.

Some contributions to open source projects that got merged. It’s a pity that most of the work I do has to be private but that’s going to change soon.

https://github.com/voxmedia/autotune/pull/391
https://github.com/voxmedia/autotune/pull/396
https://github.com/LimeSurvey/LimeSurvey/pull/793
https://github.com/LimeSurvey/LimeSurvey/pull/795
https://github.com/indilib/indi/pull/337

The folks at LimeSurvey are really nice and the process was super smooth.
The last one was very tricky, just a misplaced paren that completely changed the meaning of an error check.

PyConAR 2016 Days 1, 2 and 3

The first day we were quite busy handling the admission and all that stuff at Club Emprendedores Bahía Blanca, so no pictures (at least from me, there are others from the official photographer)

The following days were at Complejo Palihue. It’s a lovely campus at the outside of the city within very wealthy neighborhoods.

The lecture rooms and amphitheaters are ample and well stocked and the view is lovely:

I also spent a while at our booth

And attended to a couple of talks. This one is about MicroPython running on the EDU-CIAA

A small detour on my way to PyConAR 2016

It’s that time of the year (again) when I rent a car and hit the route.

This time I’m heading to Bahía Blanca in order to help a bit and attend to PyConAR.

At the side of Ruta 51 on Coronel Pringles, a bit after the crossing with Ruta 72 there’s a wonderful lake.
Even if there were about 60 kms left I had to stop to enjoy the day and stretch a bit my legs.

Why do I even bother…

I tell you it’s for your own good people but no, you keep doing the same horrible things.

While bisecting a nasty bug I land into a monster commit:


$ git show --stat THE_COMMIT_HASH
commit 123456789A04a0d558749337badc0de9deadbeef
Author: root
Date: Tue Aug 4 09:10:16 2015 -0300

THE PROJECT NAME.-THE AUTHOR HANDLE
(files changed...)
38 files changed, 865 insertions(+), 657 deletions(-)

And this is one of the smaller ones. It updates vendor libraries, adds middlewares to our api, changes the authentication scheme and does some touch ups to the web frontend. I couldn’t care less that it was committed as root but the log message is murder to my eyes.

How hard is to understand that doing this is bad for everyone? It’s very easy to do this instead of making a couple of extra commits but when things break you come crying asking me to fix them and instead of being a simple task I have to sift through mountains of unrelated stuff.

You are more than welcome.

A statistical insight

I’ve been working during the weekends on an instrumentation frontend to precisely measure the resistance of an RTD sensor using a ratiometric approach.

After building it and waiting a prudential time to let it warm I saved an hour of samples (3600) and fired Octave.

The mean and standard deviation looked ok and while a plot showed a bit of noise it was well within reasonable limits.

Just for the sake of it I did a histogram and, oh the horror:

This is clearly not OK. It should be more like a Gaussian (the real formula is quite daunting but still retains symmetry) and that looks a lot like a bimodal distribution. Changing the number of bins does not help.

The ADC I used does not have a reference input so I make two differential reads and then take the quotient (I know… but it was the only one available when started).

Perhaps the input multiplexer is at fault? (the unused channels are grounded, so I discarded that as a cause). I repeated the experiment but this time doing a full run on each channel instead of switching them and this is the result:

Well, both are skewed so there’s something else going on.

Scoping at the inputs shows what seems to be AM at around 70MHz even without power applied (that’s on the tv broadcast band here) and it kind of makes sense because I didn’t use a shield. Head bangs on the desk.

Anyways, using a quick digital filter makes everything look nicer but I’ll still have to shield this:

The transient at the beginning is not going to be an issue, as in real life I don’t expect such a step change (from 0 to ~3k) and in any case the antialias filter will get rid of it.

On a second thought, those chunks skewed up are really interesting and I should spotted that as a failure symptom earlier.

How to make an awesome Android dashboard for your embedded widget

– Use a standard protocol. We chose Firmata.

– Play with nice things. We used Ionic, Apache Cordoba and the wonderful BluetoothSerial plugin.

– Remember to either modify the Firmata firmware to use the default 9600 bps speed of our HC06 adapter or change it to work at 57600.

Browserify a Node implementation of the protocol and make a port-like object so it talks over Bluetooth.

– The bluetooth plugin doesn’t like to work with binary data so we improve it.

After writing some glue code you end up with a nice and working control panel. I only got the working part but there are a ton of cool reusable widgets out there (like NexusUI or KievII)

New life for an old tv tuner.

A long long time ago I bought a cheap pci tuner card to listen to the radio. I was able to watch tv with it out of the box but the radio didn’t work. So I patched the driver and it made it into mainline.

Fast forward today, I don’t have a machine with a pci slot anymore but still wanted to listen to airwaves again as my other stereo broke. So I took out the tuner (a tnf 9835) and cooked a simple pygtk app to control it. I looks just like what you can expect from being born from such a quick hack. After trying for a while to make the hardware i2c interface work I settled for a pure software implementation. (also, pull-ups are not optional) I got all the bit masking ops right the first time (but on the other hand that was just copy pasted from drivers/media/tuners with some small edits). It is basically a nice interface around the SN761677.

Compared with my phone the sensitivity is rather poor as it needs quite a bit of an aerial but the sound quality feels better. Alas, the latter is totally subjective.

 

Things are looking different today…

Clearly I’m a glutton for punishment.

Today I decided that I can’t have enough and it was time to upgrade my distro so I can play with newer things (and also because google was nagging me to use an updated browser).

I did a dist-upgrade and that not only completed without a hitch but I also had a bit more of free space afterwards. Previously I hammered the thing and then just gave up all hope.

I’m starting to like this new future were things work like they should.

Now that I jinxed it I went full steam with a do-release-upgrade. It is downloading 3277 files at the blazing speed of 20 kB/s.

Let’s see if I still have a working machine by monday.