# prints tag name or short revision
git name-rev --tags --name-only --no-undefined --always $(git rev-parse HEAD)
Tuesday, March 17, 2015
Print the current tag OR commit in git
Monday, March 16, 2015
Multiple test programs, one makefile
Friday, November 14, 2014
git lsd – For when you don't want to use gitk --all
git log --graph --boundary '--format=%C(yellow)%h%Creset%C(bold cyan)%d%Creset %s %C(dim normal)(%ar)%Creset' --allThis will output something like this (depending on your terminal color settings):
* 4b22a90 (HEAD, master) erases chip before programming (2 days ago) * ee107af Merge branch 'sysclk' (2 days ago) |\ | * e9df6f6 removes clk config to use defaults (2 days ago) | * 66a1ea3 fixes clkout pin timing (2 days ago) | * bcdda54 enables PLL @ 16MHz (internal 2MHz x 8) (2 days ago) | * cd22bab enables the 32KHz rc for system clock (2 days ago) | * cee8efd enables the internal 32MHz rc for sysclk (2 days ago) | * aa10b4d enables 2MHz internal rc osc for sysclk (2 days ago) | * 80cbade re-defines F_CPU (2 days ago) |/ * 0644c9d Merge branch 'diagnostics' (3 days ago) |\ | * b9e155d adds SYSCLK/10000 on pin A0 (3 days ago) | * 57807ab adds blinky led (3 days ago) |/ * 5cfc996 basic skeleton (3 days ago)Of course you can mess with the format and colors, but this is how I like it. Once you have it set the way you like it, alias it for later use!
git config --global alias.lsd "log --graph --boundary '--format=%C(yellow)%h%Creset%C(bold cyan)%d%Creset %s %C(dim normal)(%ar)%Creset' --all"Now you can just type git lsd and have a quick overview of your commits.
Wednesday, October 15, 2014
Xmega DFU Programming in Linux
I'm using elementary OS 0.2 and have an MT-DB-X4 development board from MattairTech with an ATxmega32A4U — so you may need to adjust the following commands to suit your particular setup.
Install dfu-programmer
First we need to install some prerequisites:
$> sudo aptitude install libusb-1.0-0 libusb-1.0-0-dev
Then, download and extract the source:
$> wget -qO- "http://sourceforge.net/projects/dfu-programmer/files/dfu-programmer/0.7.0/dfu-programmer-0.7.0.tar.gz/download" | tar xvzNow configure, make, make install:
#!/bin/bash cd dfu-programmer-0.7.0 ./configure --prefix=$HOME/.local # This will install to your home make # Compile make install # Install
Now we can test it out. Plug in your device and run the following (change the device to match your chip):
$> sudo ~/.local/bin/dfu-programmer atxmega32a4u get Bootloader Version: 0x04 (4)
Finally, we need to add ~/.local/bin to our PATH so we can just type dfu-programmer:
#!/bin/bash
# check to see if it's already in PATH
echo $PATH | grep -v "$HOME/\.local/bin" > /dev/null &&
cat << EOF >>~/.profile
# set PATH so it includes user's private .local/bin if it exists
if [ -d "\$HOME/.local/bin" ] ; then
PATH="\$HOME/.local/bin:\$PATH"
fi
EOF
Remember, you need to logout and back in before the changes to your groups and .profile take effect.
Setup udev rules and permissions
When you first plug the device in, udev will only allow access to the root user by default. To change this we need to let udev know that we want to give access to the device to users in a certain group — plugdev in this case.
To start, check to see if you're already in the plugdev group:
$> groupsIf not, you'll need to add yourself:
$> sudo usermod -a -G plugdev $USER
Next, we need to add a rules file to tell udev which group to add the device to. To get the device info, run lsusp to get the vendor and product IDs:
$> lsusb | grep AtmelThis should output something like the following:
Bus 005 Device 003: ID 03eb:2fe4 Atmel Corp.Note the first and second parts of the ID
Now that we have the IDs, we can make the udev rule file and restart udev:
#!/bin/bash
sudo bash -c 'cat << EOF >/lib/udev/rules.d/12-atmel.rules
# atxmega32a4u with DFU Bootloader
SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2fe4", GROUP="plugdev"
EOF
service udev restart'
Now just unplug and replug your device and you should be able to access it without root:
$> dfu-programmer atxmega32a4u get Bootloader Version: 0x04 (4)
Wednesday, October 1, 2014
Setting Up the AVR Toolchain for Linux for AVR Development
- Download the Atmel AVR Toolchain 3.4.x for Linux
- Extract it to either
/usr/local/avror~/local/avr#!/bin/bash mkdir -p ~/local/avr cd ~/local/avr tar zxvf ~/Downloads/avr8-gnu-toolchain-*.tar.gz mv avr8-gnu-toolchain-* avr
- Add the path to your
~/.profile:# add avr toolchain to path (search ~/local/avr then /usr/local/avr) if [ -d "$HOME/local/avr/bin" ] ; then PATH="$HOME/local/avr/bin:$PATH" fi if [ -d "/usr/local/avr/bin" ] ; then PATH="/usr/local/avr/bin:$PATH" fiThis will look for avr commands in your home first and then in/usr/local/avr, and only if they exist. - Now logout, login and then check to see if its working:
$ which avr-gcc
This should output/home/$USER/local/avr/bin/avr-gcc, or wherever you put it.