Strikes Again



Pulseaudio & Jack on Ubuntu/Mint

What is Jack? Well its a pretty useful program if you have a lot of audio input devices (musicians) or several output devices (audiophiles). It also has a nice cross connect setup where you can map each speaker to a source on the system and you can merge them as well. This actually solved one of my *nix issues I had that Pulse was not detecting that I had 5.1 setup and I was only using my front speakers but now with Jack everything is working great!

I have written a very simple shell script that will stop your current pulse audio output module and use the jack module instead. The script also provides a way back to your original setup so you do not need to doanything on the command line when you want to use Jack for any application. This script has several “sleep 10s” commands as Pulse does take a few seconds to die and start up. If you want some extra few seconds you can modify these values or be more patient.

 #! /bin/sh USER_PULSEFILE=~/.pulse/ case "$1" in start) echo "Killing current Pulse Audio process..." pkill pulseaudio sleep 10s echo "Restart Pulse Audio process as a daemon..." pulseaudio -nDF $USER_PULSEFILE echo "Wait for the daemon to start..." sleep 10s ;;  modules) echo "Killing current Pulse Audio process..." pkill pulseaudio sleep 10s echo "Restart Pulse Audio process as a daemon..." pulseaudio -D echo "Wait for the daemon to start..." sleep 10s echo "Loading the Jack modules..." pacmd load-module module-jack-sink channels=2 pacmd load-module module-jack-source channels=1 ;;  stop) echo "Killing current Pulse Audio process..." pkill pulseaudio sleep 10s echo "Restart Pulse Audio process..." pulseaudio -D ;;    *) echo "Usage: pulsejack {start|modules|stop}" >&2 exit 1 ;;esac exit 0

save this script via your favorite text editor to your .pulse directory and call it pulsejack. 

eg. Copy the above script and open a terminal and type:

cat > ~/.pulse/pulsejack << "EOF"  *ENTER**Right click > paste*EOF  *ENTER* 


Then you will need to make a copy of the default script and remove the udev module as it gets in the way with static modules.

cp /etc/pulse/ ~/.pulse/


Open in your favorite editor and comment out the module-udev-detect and if statements like below. Also add the module-jack-sink and source.



While you are in ~/.pulse/ make a client.conf file and put autospan = no in it or type whats below. This will make sure Pulse does not automatically restart when we run our script.

echo "autospawn = no" > ~/.pulse/client.conf


Next you need to actually install Jack and its related parts. A simple apt-get will do what we want. qjackctl is the Jack control panel and does a fantastic job and allows you to do the source/output patching like I mentioned above.

sudo apt-get install jackd pulseaudio-module-jack qjackctl


This next step may be optional but I read that it helps out Jack if you have a lot of data moving around the audio system. YMMV but I recommended you do these commands just to be safe. The limits.conf file is used by a hardware management daemon that kills apps when they hog to many resources.

sudo addgroup <username> audiosudo su -c 'echo @audio - rtprio 99 >> /etc/security/limits.conf'sudo su -c 'echo @audio - nice -10 >> /etc/security/limits.conf'sudo su -c 'echo @audio - memlock unlimited >> /etc/security/limits.conf'



Thats it! You could not run everything by hand if you wanted or you can setup qjackctl to handle the shell stuff for you. To do that open qjackctl and goto “Setup > Options” and set the run and stop scripts up like I have below



Now push the start button and your audio manager will show Jack as the default output device!



Audio Spectrum Analysis Tools

Well I was poking around the linux repos looking for a program that I can use as a tone generator for some of my electronics projects when I stumbled upon this wonderful program:




This little program not only has a tone generator with noise and sweep capabilities but its a handy little tool to do fourier analysis and general spectral analysis. The program is currently only avalible for *nix based machines but the source is provided so I am sure a windows compile can be done (provided the sound API is standard…)

Check out this interesting screenshot:




Thats one crazy complex signal to create the matrix scrolling letters effect! Those HAM radio events can get crazy. To step it up a notch somebody put out a QR-Code (A 3D UPC) over the radio waves:




Anyways Baudline is a great program so far however their is a few issues to note. If you are using a standard distro such as Mint or Ubuntu then you will not be running the required Jack audio daemon that baudline requires to have access to the sound hardware. Their are how-to’s on the web but they all require much more work than a simple little init script can provide and they do not require system changes! I will post my script in the next post. Once you get things up and running one thing to note is that you can not play back anything with stdout in the output devices window or you will crash. You also can not record from Jack unless you actually have an input source or baudline will crash. Their are still some bugs but their easy enough to work around.


Basic usage info:

To run Baudline you need to start it via the command line or else you will not have any input or output devices in the selection windows. To run with all options enabled like I do run this command

./baudline_jack -stdin -stdout

That simple command will let you pipe files in from the command line (such as from an audio recording) this is also mandatory if you wish to use the tone generator as by default it can not output directly to the Jack output device. You must first select stdout in the tone generator window and then record the signal then play it back via Jack. Its not actually a big deal as 99% of the time you want to make sure what signal you’r going to output is correct first.

Here is a screenshot of my setup:


CMSIS & FWLib Template V1.1.0 Released

Hello everybody! It’s a good week of production so far and I am happy to announce the release of the fully working CMSIS & FWLib KEIL ARM-MDK project template.


Upon the rival of my STM32 Mini I have been struggling to get CMSIS to play nicely with ST’s firmware libraries which provide a standardized function set to using their on board peripherals. Using the firmware library is important to me because this is not a simple AVR or PIC microcontroler here, their can be a dozen 32bit registers for a periphearal and when you start dealing with DMA and the NVIC working at the register level becomes very tedious and error prone. Those who have used Procyon AvrLibC know that having a standard function set for each peripheral can cut down development time substantialy. ST’s firmware library is quire similar to Procyon’s in the fact they are an assortment of source and header files that you can selectively include yourself or use their global configuration file. The major difference between ST’s version and other micro libraries I have seen is it is MUCH simpler to compile in piece meal form; you can simply select the SPI library for example and you only need to include a few other files to provide lower level functions and your ready to go.


I have created a simple project standard that has all the include paths and folder structures arranged in a clear manner with the files you should not be modifying set with the appropriate read only file permissions. The KEIL uVision IDE provides the bulk of the setup through their project configuration menu as I assume if you are using KEIL your not going to be using just the command line compiler. If their is interest in using the KEIL command line tools I might add a makefile to the project at a later date.


The relevant files to you, the user who is starting a new project are these:


  • Library_configuration_section
  • Use the peripherals drivers
  • External High Speed oscillator (HSE)
  • (HSE) Startup Timeout value

These options may be set by modifying the header file or by adding the defines to the project via Project Options -> C/C++ -> Defines. I perfer to leave the header untouched and just use the defines as that way you can leave a clean firmware library that you never need to worry about their being an error in. After all the who point of portability is to never modify the middleware.

My template includes these defines: 

  • STM32F10X_MD

As simple as that. I have never needed to modify the HSE settings as you will use an 8MHz crystal on any of the STM32 chips except the connectivity line and ST has taken care of modifying the HSE values automatically when you select STM32F10X_CL as your chip type.

To include specific library componets such as GPIO, SPI, RTC etc their is a handy file called FWLib_INCstm32f10x_conf.h with this file you simply comment out the features you do not wish to use and the compiler will automatically include them in the project for you. Their is nothing else you need to do to get off the ground with CMSIS & FWLib. 

One thing I should mention is their is a rule in the STM32 documentation that the first 15 interrupts in the negative range must have prototypes even if they are empty. I’m not sure why this is so but as its their standard we must do as we are told. In the FWLib_SRC folder their is a file called stm32f10x_it.c that handles all this for you and if you wish to add a delay function via SysTick this is where the SysTick_Handler() ISR resides. You will notice that all the other files in the FWLib_SRC folder have little gold keys next to them and the stm32f10x_it.c file is the only one without one; this is because it is the only source file in the firmware library you should ever have the need to modify.


I have compiled the documentation for both CMSIS and the Firmware Library from Doxygen in compressed HTML format, also known as  Windows help files and I believe they turned out quite nicely. The stylesheet is quite ugly and I am working on my own version but they give a very clear presentation of the available functions and what the initializing structures contain. I plan on writing a post on how to navigate the documentation to find out what options are available to the initialization structures such as how to find out that GPIO_InitStruct.GPIO_Mode  = GPIO_Mode_Out_PP; also has the GPIO_Mode_AF_PP mode available. 


So what does the future of this project hold? Well my goal is to provide a much more useful firmware lib package than ST has with examples of real world devices such as LCD’s, TFT’s, touch panel controlers and SD cards. To compare the current SPI examples in the firmware library use code that sends on SPI1 and recieves on SPI2 of the same chip, this is great if you want to see if the peripheral even works but when you need to initialize it for the real world and handle NSS pins in software their is no examples to be found. My end goal is to use the STM32 Mini as a template and have each piece of hardware as a separate example and then combined together to make a complete project. In this way I hope to instruct not only myself but anyone else who finds the world of ARM quite daunting.

I do need some input from the community on this project, mostly regarding what compilers and IDE’s I should be developing on. I started with KEIL because of their peripheral view during debugging but after this template was complete that feature is no longer necessary. Should I focus on GCC with a makefile, KEIL command line maybe, or focus on Rowley CrossWorks? I wish to support whichever is more popular.


For version 1.2.0 my goals include compiling the entire CMSIS & FWLib into a library file and only leave the files mentioned above available to the user so as to remove the temptation to modify and to clean up the project inclusions.

Download v1.1.0 now from: SourceForge

Mini STM32 STM32F103RB TFT LCD Board V3

So I bought my first ARM development kit a few months ago and it has been my primary focus since is arrived. The kit contains ST’s STM32F103RB Cortex-M3 processor that can operate up to 72Mhz and has many fun and interesting peripherals on board.


I got my board from an online shop in Taiwan called micro4you and it was a great deal on the surface but let me tell you if you value your time at anything then order from the eBay stores. I made my order for a whole whopping $62 taxes and shipping in so I was extremely happy about that but after week two went by and their online order page still said “Processing” I started to get antsy. I emailed their customer service and then waited another week just to get a horrible English response of something along the lines of its shipped, just wait. After some more waiting my package finally arrived and I was glad it managed to get here in one piece as it took 41 days to reach me. 

With milestone one cleared it was onto the actual act of using this fancy new device to blink some lights! I was trying to save some money and so I did not purchase a JTAG programmer to go with the unit under the understanding that it came stock with ST’s serial flash loader. I plugged the Mini in and the LCD flashed to life with the uCOS II & uC/GUI demo and was quite impressed at the speed that the Mini could draw on that screen. Their is one part of the demo in which their is a windows like window open with a slider and i was able to move everything around as fast as I could without any tearing effects. The micro4you website also provides a more standard LCD demo so I decided that would be a good second test to run. I loaded up ST’s flash loader software and it found the Mini without issues but when I flashed the demo nothing but a white screen was showing and the flash loader no longer would connect. Lesson number two is these demos are not built for just the Mini, and as a result it programmed over the serial bootloader making it impossible to use unless I purchased a JTAG programmer.

With this new information I went on the interwebs looking for a comparison of JTAG programmers and discovered that really their is only 4 options available for under $1000. They are:

Each have their own strengths but here is my opinion of the selection. Olimex makes quite a range of boards and their adapters are garenteed to work with them so if I ran a lot of olimex kits I would go for this option, however I own nothing Olimex so I passed it over. Paul over at Rowley made me a deal thats hard to pass up, buy their personal licence for $150 and he will toss in their CrossLink Lite for free! while this is a fantastic deal I unfortunately had already settled on KEIL uVision ARM-MDK as my compiler. That left me with Seggers line of devices. The J-Link is a professional quality tool that lets you run flash breakpoints, flash downloads, and their GDB server. The J-Link EDU is the same as its professional counterpart but it removed the flash download support and you must not use it in any commercial project or setting. I am a hobbiest so that does not worry me and for $350 if I was to ever make something I would just buy a new one! The lack of flash download worried me but it turns out that just means you can not use their flasher suite and has nothing to do with programming any devices. Needless to say I am the proud owner of a J-Link EDU now.


Development suits and compilers can be a mess to deal with and I went through it all while waiting for my J-Link to arrive from Digi-Key. WinARM & YAGARTO using Eclipse, Rowley CrossWorks, IAR and KEIL. The first two options where a nightmare to set up properly and had me running through make files and pulling my hair out. Eclipse is a wonderful IDE but if the back end is annoying then forget it! CrossWorks it a fantastic application in every respect, while debugging everything was clearly laid out and easy to understand but what was not clear is how the heck to access registers and definitions as they are all hidden 100 files deep and apparently generated from the datasheets and stored in XML sheets. Sheesh. However its the ONLY professional quality compiler/IDE that is affordable at $150 for a personal licence so in the end I might end up using it after all. IAR is a powerful beast and I felt out of place in its UI, I can not really explain why it just felt weird so I moved on to KEIL. KEIL is where I felt comfortable, its UI is very standard and while debugging you can select a peripheral and see every single register and make simple changes form drop down menus. The simplest and best layout to debugging I have ever seen, its downside is it only remember your window locations about 95% of the time but thats easy to get over. KEIL offers a 32kb code limited version of their suite for free so that is what I decided to use, if you want to know the full licence price its ~$1500 so don’t get your hopes up!

KEIL is a simple install and so is the J-Link software but making them work together is not such a simple task. The dll that KEIL uses to communicate with the J-Link was an old version 4.20a and it did not support SWD mode, to get around this I copied the JLinkARM.dll and jlink.exe files from ‘c:program filessegger4.20c’ into ‘c:keilarmsegger’ and reloaded my project and viola I could see my cortex-m3 device via SWD but now their was this annoying popup. By annoying I don’t mean once, I’m talking popup then select device three times then agree to terms twice every time annoying here so I went out and got some more drivers. I did the same as above with driver version 4.20n and now the popup is only the licence agreement from Segger as it should be but SWD mode does not work! It took me about two hours to find out that I needed the jlink.exe from the stock KEIL install and the 4.20n dll to get the best of both worlds. So if your reading this and are gonna use the same combo I say good luck to you!

Russian VFD: Update

The actual use of these screens is taking shape. I am nearing completion of a working prototype but their are a few issues to iron out before I upload a video to youtube. For now here is a picture of the setup and a description of the project.

1-Wire 16 character 16 segment display. Powered via standard 5V the on board AVR (Tiny25) runs a boost converter via PWM to generate 35V to run the screen at a very bright level. Control is through the 1-Wire protocol but the device is not powered by it like many 1-Wire chips are due to the fact this board will draw ~200mA (maybe less). I wish to setup a control scheme to allow software brightness control and an easy method of sending ascii characters and what digit to display it on.

Issues so far include a pain in the ass Timer1 that refuses to enter its OVF interrupt (needed for multiplexing), I forgot the shift regs had a strobe for latching data so I am one pin short. I originally planned on I2C and have that working (mostly) but with the strobe tied high all of the character segments are lit and its hard to read. I don’ t want to write my own 1-Wire software library, the Tiny25 has a USI but I have never used one so it will be ‘interesting’ to learn.

Hopefully by the end of the week I will have it working and a video to show!


Blog at

Up ↑