Desenvolvimento embarcado no Debian Linux com LaunchPad Tiva C Series e MSP430 | Embedded development on Debian Linux with LaunchPad Tiva C Series and MSP430

English bellow.

Aproveitando a oportunidade com o início das aulas do curso Embedded Systems – Shape the World na plataforma edX.org, ministrado pelos professores Jonathan Valvano e Ramesh Yerraballi da University of Texas at Austin, publiquei no embarcados.com.br um tutorial que tem por objetivo oferecer aos interessados alternativas para configuração de um ambiente desenvolvimento para as plataformas LaunchPad Tiva C TM4C123G e MSP430, ambas da Texas Instruments.


Hitching a ride at the start of classes of Embedded Systems – Shape the World course at edX.org, taught by professors Jonathan Valvano and Ramesh Yerraballi of University of Texas at Austin, the main objective of this tutorial is to offer an alternative setup for a development environment for LaunchPad Tiva C TM4C123G e MSP430, both from Texas Instruments.

These kits are a great low coast alternative for study and project development, the TM4C123G is based on ARM Cortex M4F microcontroller and MSP-EXP430G2, on the low power comsumption microcontroller MSP430.

At the course, Embedded Systems – Shape the World, users can use both the TM4C123G as the LM4F120 kit and the initial goal of this tutorial was to allow the students to uses the Linux along the classes, however, for that the students receive their grades, it’s necessary to integrate the development tool Keil uVision, with a DLL developed by professor Valvano, called TExaS. This library integrates the lab exercises with the edX platform. More informations here.

Despite that, as some users have as development platform the Linux system, the search for alternative tools as hardware compatibility is constant. Some manufactures offers partial support to your platforms and few of then offers full support, at Texas website is possible to see that the MSP430 for example, doesn’t have full Linux support through the Code Composer Studio IDE.

So, basically the Linux users have two choices: become sad for not use your preferred operating system or come out and fight. Happily the community of users and developers is here to help us, and sometimes is really surprising all the support that already exists developed by the open source community.

We need basically of a text editor, compiler, debugger and a tool to send the code to the board, this set of tools is also called toolchain.

The text editor is definitively the easier part, can be simpler as Vi or a integrated development environment (IDE) that, as the name, integrates many other tools and even simmulation tools. Keil uVision and Code Composer Studio are two examples of these tools.

Using Debian Linux 8 (codename Jessie), and most likely any other Debian based distributions as Ubuntu and Linux Mint, we can configure a basic development environment for the platforms LaunchPad Tiva C TM4C123G and MSP430. All the installation is based on softwares available on Debian Linux repository and is needed root or sudo permissions.

For the LaunchPad TM4C123G, we’ll install the following packages (and its respective dependencies):

$ sudo apt-get install gcc-arm-none-eabi gdb-arm-none-eabi lm4flash lmicdiusb unzip make

We need to adjust some permissions for the current user and after this, login the system again:

$ sudo adduser $USER dialout

After the packages install it’s possible to plug the TM4C123G on the USB and see the system recognition:

$ sudo dmesg

The output will be something like this:

[ 5104.297091] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3          
[ 5104.297094] usb 2-2: Product: In-Circuit Debug Interface                     
[ 5104.297096] usb 2-2: Manufacturer: Texas Instruments                         
[ 5104.297098] usb 2-2: SerialNumber: 0E2195C8                                  
[ 5104.297789] cdc_acm 2-2:1.0: This device cannot do calls on its own. It is not a modem.
[ 5104.297817] cdc_acm 2-2:1.0: ttyACM0: USB ACM device

It’s possible to see that the system recognizes the LaunchPad board, and that is available at /dev/ttyACM0. Otherwise, we can also check:

$ lsusb | grep -i luminary
Bus 002 Device 012: ID 1cbe:00fd Luminary Micro Inc. In-Circuit Debug Interface
      
$ ls -l /dev/ttyACM0
crw-rw---- 1 root dialout 166, 0 Jan 31 19:03 /dev/ttyACM0

We can notice that access permission to the device /dev/ttyACM0 is for user root and group dialout, thats the reason for we included the current user on this group.

However, it’s not possible to directly access the device as normal users before write a specific rule to the udev system, or libusb will return us a error:

$ echo 'ATTRS{idVendor}=="1cbe", ATTRS{idProduct}=="00fd", GROUP="dialout", MODE="0660"' | sudo tee /etc/udev/rules.d/99-stellaris-launchpad.rules

$ sudo chmod 0644 /etc/udev/rules.d/99-stellaris-launchpad.rules

It’s interesting to reboot the system after these changes to reload the udev rules.

Now we can test the device. The test consists in download the Texas Instruments library here, the download is free but you need to register before.

We can now extract the downloaded exe file (it’s a zip file indeed), access the created directory and simply run:

$ make

After this we’ll access the path examples/boards/ek-tm4c123gxl/blinky/sourcerygxx, where the file blinky.bin is, a already compiled program (we can also explore the source code on the same folder). So we can now send the program to the board using:

$ lm4flash blinky.bin

That returns something like:

Found ICDI device with serial: 0E2195C8
ICDI version: 9270

After this, the board will restart and execute the program that will blink the LED. If you got the following error:

Unable to open USB device: LIBUSB_ERROR_ACCESS
Unable to find any ICDI devices

It’s the udev problem mentioned above and you can confirm running as root:

$ sudo lm4flash blinky.bin

If works as root, please check the 99-stellaris-launchpad.rules content and restart the system. Now we have the TM4C123G working, let’s configure the support for the MSP430, starting again for the packages installation:

$ sudo apt-get install gcc-msp430 gdb-msp430 mspdebug

Again we need to add the current user to the groups, loging again on the system:

$ sudo adduser $USER plugdev

Now it’s possible to plug the board on the USB and check the system:

$ sudo dmesg

We must see something like:

[ 4789.736733] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 4789.736736] usb 2-2: Product: Texas Instruments MSP-FET430UIF                
[ 4789.736737] usb 2-2: Manufacturer: Texas Instruments                         
[ 4789.736739] usb 2-2: SerialNumber: B2FF467AF9CB5035                          
[ 4789.736890] usb 2-2: ep 0x82 - rounding interval to 1024 microframes, ep desc says 2040 microframes
[ 4789.742783] cdc_acm 2-2:1.0: This device cannot do calls on its own. It is not a modem.
[ 4789.742789] cdc_acm 2-2:1.0: No union descriptor, testing for castrated device
[ 4789.742807] cdc_acm 2-2:1.0: ttyACM0: USB ACM device

Again the system recognizes the LaunchPad, making him available at /dev/ttyACM0. We can also check:

$ lsusb | grep -i z430
Bus 002 Device 010: ID 0451:f432 Texas Instruments, Inc. eZ430 Development Tool
                                                                                     
$ ls -l /dev/ttyACM0
crw-rw---- 1 root plugdev 166, 0 Jan 31 18:58 /dev/ttyACM0

At this time the access permissions on /dev/ttyACM0 are to the user root and group plugdev. We’ll not have problems if our user are already at this group.

Let’s test the board using the mspdebug tool, if everything is alright must work as normal user:

$ mspdebug --usb-list

Returning something like:

Devices on bus 002:
    002:008 0451:f432 eZ430-RF2500

Now that we have all the environment ok, let’s test compiling a simple code and running at MSP430 board. So we can type at our favorite text editor:

/* MSP430 blink example */
#include

/** Delay function. **/
delay(unsigned int d) {
  int i;
  for (i = 0; i<d; i++) {
    nop();
  }
}

int main(void) {
  WDTCTL = WDTPW | WDTHOLD;
  P1DIR = 0xFF;
  P1OUT = 0x01;

  for (;;) {
    P1OUT = ~P1OUT;
    //delay(0x4fff); /* We can try to change this delay value */
    delay(0x1fff);
  }
}

We will same the source and compile with:

$ msp430-gcc -Os -mmcu=msp430g2231 -o blink.elf blink.c

And now upload to the board with the mspdebug, using prog blink.elf and run:

$ msgdebug rf2500

Type "help" for more information.
Use the "opt" command ("help opt") to set options.                              
Press Ctrl+D to quit.

(mspdebug)

prog blink.elf
run

And now we have our program running at MSP430.

The main goal of this tutorial was to provide a minimal development environment to the LaunchPad Tiva C TM4C123G and MSP430 platforms, at Debian Linux operating system.

There are other tools available, but not even with full support and it’s interesting to count with this support via the system software repository.

Starting with this minimal setup, it’s possible to use an IDE like Eclipse, mapping the compiler, linker and debugger into this IDE.

A partir de uma configuração mínima como a apresentada, é possível utilizar por exemplo um ambiente de desenvolvimento integrado (IDE) como o Eclipse, mapeando o compilador, linker, depurador e ferramenta de gravação dentro do IDE, centralizando seu ambiente de desenvolvimento.

All trademarks and products mentioned are the property of their respective owners.

References:

http://www.ti.com/tool/ek-tm4c123gxl
http://www.ti.com/tool/ccstudio-tm4x
http://www.ti.com/tool/msp-exp430g2
http://www.ti.com/tool/ccstudio-msp
http://www.ti.com/tool/msp430-gcc-opensource
http://energia.nu/guide/guide_linux/
http://energia.nu/pin-maps/guide_tm4c123launchpad/
http://energia.nu/pin-maps/guide_msp430g2launchpad/

Desktop leve e rápido com Ubuntu Linux e Enlightenment | Lightweight and fast desktop with Ubuntu Linux and Enlightenment

English bellow.

Já tendo utilizado várias distribuições Linux como servidor ou desktop há anos, além de sistemas BSD (FreeBSD, OpenBSD, DesktopBSD), sempre optei por um sistema com o mínimo necessário, onde menos é mais.

Entretanto não se pode negar as diversas facilidades que economizam horas de trabalho para configurar o suporte ao hardware. Venho me surpreendendo em como alguns dispositivos funcionam com pouco ou nenhum esforço, tornando o Linux realmente um sistema acessível para usuários no dia a dia.

Como tudo tem um preço, alguns usuários mais experientes e/ou exigentes podem ficar insatisfeitos ao notar eventual queda de performance por conta de tantos recursos sendo consumidos com essas facilidades oferecidas já que não existe almoço grátis. Observo isso em distribuições como Ubuntu Desktop, que ainda sim tem feito ótimo trabalho na popularização do Linux para usuários.

Pela boa frequência de atualizações das versões, grande oferta de softwares disponíveis em seus repositórios e facilidade de manter o sistema atualizado, venho utilizando o Ubuntu Linux como desktop na sua versão de suporte estendido (LTS, Long Term Support). Mas como acho seu ambiente desktop muito pesado, optei por uma instalação limpa e mais leve para ter somente as ferramentas que necessito. Ainda lembro como era ter pouco processamento, memória e espaço em disco para tentar compilar e rodar um Slackware 4 ou Red Hat 5.

Para realizar uma instalação enxuta do Ubuntu Linux com objetivo de deixar meu ambiente mais rápido utilizei a versão servidor 14.04 LTS, e não a desktop. Após finalizar todo processo de instalação e configuração do sistema operacional, o que temos na verdade é um sistema voltado para servidor instalado na máquina.

O objetivo é transformar esse sistema em um desktop com suporte ao ambiente gráfico e alguns softwares para escritório, áudio e vídeo, Internet e até alguma diversão.

A base do ambiente gráfico é o Xorg e escolhi o Enlightenment como gerenciador de janelas na sua versão E19. O Enlightenment é um gerenciador bem antigo e que consegue entregar grandes efeitos visuais com boa estabilidade e consumindo poucos recursos. É interessante sair um pouco daquele visual tradicional do desktop que estamos acostumados.

Como essa versão do Enlightenment não está disponível na árvore de pacotes do Ubuntu 14.04, utilizei um repositório de terceiros. O Bodhi Linux é uma distribuição baseada no Ubuntu com um ambiente gráfico completo baseado no E19. Utilizo o repositório do Bodhi Linux somente para instalação do E19 pois o objetivo é uma instalação customizada mas sem muito trabalho. Os demais softwares foram todos obtidos a partir da árvore do próprio Ubuntu Linux. Essencialmente foi necessário somente instalar alguns pacotes chave e depois adicionar o repositório do Bodhi Linux para a instalação do E19.

Partindo do arquivo sources.list original do Ubuntu Linux, removemos o comentário dos repositórios ‘partner’ e ‘extras’, deixando-o assim:

deb http://br.archive.ubuntu.com/ubuntu/ trusty main restricted
deb-src http://br.archive.ubuntu.com/ubuntu/ trusty main restricted

deb http://br.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
deb-src http://br.archive.ubuntu.com/ubuntu/ trusty-updates main restricted

deb http://br.archive.ubuntu.com/ubuntu/ trusty universe
deb-src http://br.archive.ubuntu.com/ubuntu/ trusty universe
deb http://br.archive.ubuntu.com/ubuntu/ trusty-updates universe
deb-src http://br.archive.ubuntu.com/ubuntu/ trusty-updates universe

deb http://br.archive.ubuntu.com/ubuntu/ trusty multiverse
deb-src http://br.archive.ubuntu.com/ubuntu/ trusty multiverse
deb http://br.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb-src http://br.archive.ubuntu.com/ubuntu/ trusty-updates multiverse

deb http://br.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://br.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu trusty-security main restricted
deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted
deb http://security.ubuntu.com/ubuntu trusty-security universe
deb-src http://security.ubuntu.com/ubuntu trusty-security universe
deb http://security.ubuntu.com/ubuntu trusty-security multiverse
deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse

deb http://archive.canonical.com/ubuntu trusty partner
deb-src http://archive.canonical.com/ubuntu trusty partner

deb http://extras.ubuntu.com/ubuntu trusty main
deb-src http://extras.ubuntu.com/ubuntu trusty main

É importante atualizar o sistema após o término da sua instalação.

$ sudo apt-get update; sudo apt-get dist-upgrade

Sigo então com a instalação do que será a base do meu sistema, Xorg e seus drivers, algumas fontes e ferramentas diversas. O driver de vídeo escolhido para o Xorg é o Intel mas devemos escolher o adequado a cada máquina através de uma busca com o apt-cache search, pode-se também instalar o driver proprietário, por exemplo os pacotes: nvidia-331 ou nvidia-340.

$ sudo apt-get install build-essential xorg xserver-xorg-video-intel xserver-xorg-input-evdev xserver-xorg-input-mouse xserver-xorg-input-synaptics xfonts-100dpi xfonts-75dpi ttf-ubuntu-font-family unrar unzip zip

Para a instalação de softwares para escritório, áudio e vídeo e Internet que utilizo:

$ sudo apt-get install deluge firefox flashplugin-installer skype libreoffice-calc libreoffice-writer

Feito isso podemos prosseguir com a instalação do E19. Deixo essa etapa para o final pois no repositório do Bodhi Linux existe também uma versão do LibreOffice e é uma preferência minha utilizar as versões disponíveis no repositório do Ubuntu. Adicionamos ao final do arquivo sources.list o repositório do Bodhi Linux:

deb http://packages.bodhilinux.com/bodhi trusty main

Após atualizar a árvore com apt-get update, podemos instalar o E19 e algumas ferramentas como o Pulse Audio para gerenciamento de áudio, Bluez para bluetooth, connman para conexões de rede e a versão do player VLC:

$ sudo apt-get install pulseaudio bluez connman econnman bodhi-desktop bodhi-vlc

Agora com todos os softwares instalados o desktop está pronto para ser utilizado. Observe que também opto por não instalar um gerenciador de login, mantendo o computador com login via terminal. É necessário então criar um arquivo que será utilizado para iniciar o ambiente gráfico, o bom e velho .xinitrc:

exec enlightenment_start

Essa única linha é suficiente para iniciar o E19. O arquivo deve ser salvo no diretório do usuário com permissão de leitura e para iniciar o ambiente gráfico após efetuar login via terminal basta digitar:

$ startx

Se tudo ocorreu bem principalmente com a instalação dos drivers de suporte do Xorg, o E19 iniciará em seu modo de configuração. Esse gerenciador de janelas é altamente configurável e vale a pena olhar com calma para deixá-lo de acordo com sua necessidade.

Dessa forma conseguimos a instalação mínima de um sistema desktop para utilização no dia a dia. Claro que outros programas como um gerenciador de login como o LightDM poderão ser instalados juntamente com suas dependências, mas esse básico inicial já ocupa um espaço menor do que um desktop padrão, cerca de 3 Gb a menos de espaço em disco, além de recursos de processamento e memória utilizados pelas dezenas de ferramentas e facilidades que acompanham o Ubuntu Desktop. Nesse caso você tem a liberdade de escolher somente o que realmente necessita.

Uma última dica é o gerenciador de janelas DWM, ele é muito leve e consome pouquíssimo recurso. Claro que também entrega menos facilidades mas com um pouco de tempo pode-se tirar um bom proveito. E para a diversão vale a pena instalar o Freeciv.

Atualização:

É necessário que o usuário seja adicionado ao grupo “audio”, do contrário o módulo pulse mixer não funcionará adequadamente no E19. Faça login novamente após a alteração:

$ sudo adduser ${USER} audio

Referências:

http://www.nuxified.org/article/comparing_window_managers_which_best_you
https://wiki.ubuntu.com/CustomXSession
https://help.ubuntu.com/community/Installation/LowMemorySystems
http://dwm.suckless.org/tutorial
http://www.bodhilinux.com
http://freeciv.wikia.com


I’ve already used several Linux distribuitons as server or desktop for years, as well BSD systems (FreeBSD, OpenBSD, DesktopBSD), and always choose systems with the minimal, where less is more.

However I can’t deny that many facilities that save hours of work to configure and set up hardware support. I’ve been surprised with how some devices work out of the box with little or no effort, making the Linux a system accessible to the users on daily needs.

As everything have a price, some experienced and/or demanding users may become unhappy to notice an eventual performance decrease caused by the resources being consumed with these facilities since there is no free lunch. I see this in distros like Ubuntu Desktop, which has done a great job making Linux more popular to the users.

With a good frequency of releases, great offer of softwares on its repositories and ease to keep the system up to date, I’ve been using the Ubuntu Linux LTS as desktop. But as I think that is a heavyweight desktop, I choose a clean and lightweight install to have only the tools that I really need. I still remember what it was compile and run Slackware 4 or Red Hat 5 with low processing, memory and disk space.

To perform a clean install of Ubundu Linux in order to have a faster environment I used the server edition of 14.04 LTS, not the desktop. After finishing the install and configuration processes, what we have is a server system on the machine.

The goal is to turn this system into a desktop with fully graphical support and some office, audio and video, Internet and even some fun.

The graphical environment core is the Xorg and I choose the Enlightenment as the window manager in its version E19. Enlightenment is a known window manager and delivers great visual effects with great stability demanding fewer resources. It is interesting to have something different of the traditional desktop look and feel.

As this version of Enlightenment is not available in the repositories, I used a third-party repository. Bodhi Linux is a Linux distro based on Ubuntu with full graphical environment based on E19. I used the Bodhi Linux repository only to install the E19 because the main goal is a custom install without much work. The remaining software were all installed from the Ubuntu Linux repositories. Essentially we just need to install some key packages and then add the Bodhi Linux repository to install the E19.

Starting from the original sources.list file, we remove the commentaries from ‘partner’ and ‘extras’ repositories, leaving like this:

deb http://br.archive.ubuntu.com/ubuntu/ trusty main restricted
deb-src http://br.archive.ubuntu.com/ubuntu/ trusty main restricted

deb http://br.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
deb-src http://br.archive.ubuntu.com/ubuntu/ trusty-updates main restricted

deb http://br.archive.ubuntu.com/ubuntu/ trusty universe
deb-src http://br.archive.ubuntu.com/ubuntu/ trusty universe
deb http://br.archive.ubuntu.com/ubuntu/ trusty-updates universe
deb-src http://br.archive.ubuntu.com/ubuntu/ trusty-updates universe

deb http://br.archive.ubuntu.com/ubuntu/ trusty multiverse
deb-src http://br.archive.ubuntu.com/ubuntu/ trusty multiverse
deb http://br.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb-src http://br.archive.ubuntu.com/ubuntu/ trusty-updates multiverse

deb http://br.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://br.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu trusty-security main restricted
deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted
deb http://security.ubuntu.com/ubuntu trusty-security universe
deb-src http://security.ubuntu.com/ubuntu trusty-security universe
deb http://security.ubuntu.com/ubuntu trusty-security multiverse
deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse

deb http://archive.canonical.com/ubuntu trusty partner
deb-src http://archive.canonical.com/ubuntu trusty partner

deb http://extras.ubuntu.com/ubuntu trusty main
deb-src http://extras.ubuntu.com/ubuntu trusty main

It is important update the system after finished the installation.

$ sudo apt-get update; sudo apt-get dist-upgrade

Now I can perform the base installation of the system with Xorg and its drivers, some fonts and other tools. The video drive for the Xorg was the Intel but we need to choose the right one for each machine using the apt-cache search, its possible to choose the proprietary driver also, for example the packages: nvidia-331 ou nvidia-340.

$ sudo apt-get install build-essential xorg xserver-xorg-video-intel xserver-xorg-input-evdev xserver-xorg-input-mouse xserver-xorg-input-synaptics xfonts-100dpi xfonts-75dpi ttf-ubuntu-font-family unrar unzip zip

Then to install the office, audio and video and Internet softwares that I need:

$ sudo apt-get install deluge firefox flashplugin-installer skype libreoffice-calc libreoffice-writer

After this we can proceed with the E19 install. I leave this step to the end because on the Bodhi Linux repository there is also a version of LibreOffice and I prefer to keep using the one on Ubuntu repository. We add in the end of sources.list file the Bodhi Linux repository:

deb http://packages.bodhilinux.com/bodhi trusty main

After update the tree with apt-get update we can install the E19 and some tools like Pulse Audio for audio management, Bluez for bluetooth, connman for the network connections and the VLC media player:

$ sudo apt-get install pulseaudio bluez connman econnman bodhi-desktop bodhi-vlc

Now with all the softwares installed the desktop is ready to use. Notice that I also choose not to install a display manager, keeping the computer with login via terminal. So we need to create the file that will call the window manager, the old and good .xinitrc:

exec enlightenment_start

This line is enough to start the E19. The file must be saved on the home user directory with read permission and to start the windows manager after login via terminal just type:

$ startx

If everything runs fine with the Xorg drivers, E19 will start in the configuration mode. This windows manager is highly configurable and is worth take a look to make it according to your need.

Thus we got a minimal desktop system install for daily use. Of course that other softwares as a display manager like LightDM can be installed with its dependencies, but this basic install takes only a portion of a desktop default, about 3 Gb less disk space, and also less resources used by dozen of tools and facilities that come with Ubuntu Desktop. In that case you have the freewill to choose only what you really need.

A last tip is the windows manager DWM, it is very lightweight. Of course it also delivers less functions but with a little of time you can have a great advantage. And for the fun part, it worth install Freeciv.

Update:

You need to add the current user to the “audio” group, otherwise the pulse mixer module will not work in the E19. Login again after change:

$ sudo adduser ${USER} audio

References:

http://www.nuxified.org/article/comparing_window_managers_which_best_you
https://wiki.ubuntu.com/CustomXSession
https://help.ubuntu.com/community/Installation/LowMemorySystems
http://dwm.suckless.org/tutorial
http://www.bodhilinux.com
http://freeciv.wikia.com