Month: January 2015

Flashing NuttX on my Dog Feeder board powered by STM32F107

This is the way I’m flashing NuttX on my board (called “GreenBone”) using the current (as of 20150129) OpenOCD:

This is my openocd.cfg :

# STM32F107 Target

# Using stlink as SWD programmer
source [find interface/stlink-v2.cfg]

# SWD as transport
transport select hla_swd

# Use STM32F1X target
set WORKAREASIZE 0x4000
source [find target/stm32f1x.cfg]

Then I execute OpenOCD this way:

$ sudo openocd -f openocd.cfg 

Open On-Chip Debugger 0.9.0-dev-00251-g1fa4c72 (2015-01-28-20:08)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
none separate
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v17 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.145571
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : accepting 'telnet' connection on tcp/4444

Finally I connect to its telnet server and flash nuttx.bin:

$ telnet 127.0.0.1 4444
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Open On-Chip Debugger
> reset halt
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x200001e0 msp: 0x20005000
> flash write_image erase nuttx.bin 0x08000000
auto erase enabled
device id = 0x10016418
flash size = 256kbytes
target state: halted
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x2000003a msp: 0x20005000
wrote 69632 bytes from file nuttx.bin in 3.056594s (22.247 KiB/s)
> reset run
> exit

Installing CyanogenMOD 11 on Samsung S4 Mini Dual SIM (i9192)

This is the way I got CyanogenMOD 11 running on Samsung Galaxy S4-Mini (i9192) AKA “serranodsxx”.

First, download these files:

– philz_touch_6.41.6-serranodsxx.tar.gz
– CM11_I9192_stable_by_sekil.zip
– 5-31_gapps_minimal_4.4.2_signed.zip

Copy CM11_I9192_stable_by_sekil.zip and 5-31_gapps_minimal_4.4.2_signed.zip to S4-Mini’s SDCard.

Download and install the “heimdall” program, that will be used to flash the recovery.img into the phone.

Decompress the philz_touch_6.41.6-serranodsxx.tar.gz file to get the recovery.img.

Reboot the phone in recovery mode (turn-off the phone and press/hold HOME + VOL_DOWN + POWER)

Plug the USB cable then press the VOL_UP to start the recovery download.

Execute this command to flash the new recovery:

$ sudo heimdall flash --RECOVERY recovery.img

Wipe Data/Factory/Cache then mount /system /cache /data and format these partitions.

Finally select install zip from SDCard and choose CM11_I9192_stable_by_sekil.zip and repeat it to install 5-31_gapps_minimal_4.4.2_signed.zip

How to decode a HTML page that uses hexa code for obfuscation

I was trying to read the source code of a html page, but the author decided to make it hard to read:

<HtMl> <hEAD> & #x20;& #x20;<MetA chaRSet="utf-8"> & #x20;& #x20;& #x20;<MetA NAmE="v& #x69;ew& #x70;& #x6f;rt" coNTeNt="width=device-width, height=device-height, user-scalable=no,

Then I decided to decode it. I got the ASCII->HTML Hexa code here:
http://webdesign.about.com/od/localization/l/blhtmlcodes-ascii.htm

Save two files ascii.txt and hexa.txt.
This is the header of ascii file:

 
 
 
!
"
#
$
%
&
'

and this is the header of hexa.txt:

& #x09;
& #x10;
& #x20;
& #x21;
& #x22;
& #x23;
& #x24;
& #x25;
& #x26;
& #x27;

Then used this shell script from Linux terminal:

$ while read -r -u3 html; read -r -u4 ascii; do sed -i s/"$html"/"$ascii"/g encoded_file.html ; done 3<hexa.txt 4<ascii.txt

Note that letters in the hexa code file (hexa.txt) are upper case, then we also need to convert it lowercase and repeat the above shell script:

$ sed -i s/A/a/g hexa.txt
$ sed -i s/B/b/g hexa.txt
$ sed -i s/C/c/g hexa.txt
$ sed -i s/D/d/g hexa.txt
$ sed -i s/E/e/g hexa.txt
$ sed -i s/F/f/g hexa.txt
$ while read -r -u3 html; read -r -u4 ascii; do sed -i s/"$html"/"$ascii"/g encoded_file.html ; done 3<hexa.txt 4<ascii.txt

Great, now encoded_file.html is easy to read! I think there are some easier solution using python or some tool, but I didn’t find it. Suggestion???

O que vamos fazer sem esta tal liberdade?

Estamos vivendo um momento único onde a tecnologia 3D permite criar coisas maravilhosas, mas ao mesmo tempo a “velha política” continua apertando o cerco contra a nossa liberdade. Vejamos…

Após tirar várias fotos de uma réplica em bronze da estátua Moisés de Michelangelo, existente no campus do Augustana College (Sioux Falls, South Dakota), Jerry Fisher usou um software para reconstruir o modelo 3D da estátua ((semelhante ao que usei p/ tentar recriar o Mário) e publicou no site de compartilhamento 3D Thingiverse.

Não demorou muito para ser contatado pelas “autoridades” da cidade e obrigado a remover o modelo da estátua do site.

Ao que tudo indica há uma má interpretação da lei, a estátua é de domínio público e foi criada há exatos 5 séculos. Jerry está recorrendo à justiça para lutar por seu direito de publicar o modelo da estátua. A matéria completa pode ser lida em inglês neste site: http://www.3ders.org/articles/20150122-man-accused-of-copyright-infringement-after-3d-scanning-a-michelangelo-statue.html

Um caso recente relacionado a este tema é o do Mickey Mouse, ele deveria ser de domínio público há muito tempo, mas os “proprietários” dele conseguiram estender o tempo de direito sobre ele:
http://www.washingtonpost.com/blogs/the-switch/wp/2013/10/25/15-years-ago-congress-kept-mickey-mouse-out-of-the-public-domain-will-they-do-it-again/

A discussão deste tema é importante, devemos lutar por nossa liberdade enquanto ainda temos alguma…

Inverting the 7-seg display in software

I decided to put a 2 digits 7-seg display module inverted to simplify routing, but then it needs to be inverted in software, it is not complicated, but a little bit boring to test:

Dig1:

e d c   b a f g        b a f   e d c g
0 0 0   0 0 0 1        0 0 0   0 0 0 1
1 1 0   0 1 1 1        0 1 1   1 1 0 1
0 0 1   0 0 1 0        0 0 1   0 0 1 0
1 0 0   0 0 1 0        0 0 1   1 0 0 0
1 1 0   0 1 0 0        0 1 0   1 1 0 0
1 0 0   1 0 0 0        1 0 0   1 0 0 0
0 0 0   1 0 0 0        1 0 0   0 0 0 0
1 1 0   0 0 1 1        0 0 1   1 1 0 1
0 0 0   0 0 0 0        0 0 0   0 0 0 0
1 0 0   0 0 0 0        0 0 0   1 0 0 0

Dig2:

f g a b   c d e dp       c g d e   f a b dp
0 1 0 0   0 0 0 1        0 1 0 0   0 0 0 1
1 1 1 0   0 1 1 1        0 1 1 1   1 1 0 1
1 0 0 0   1 0 0 1        1 0 0 0   1 0 0 1
1 0 0 0   0 0 1 1        0 0 0 1   1 0 0 1
0 0 1 0   0 1 1 1        0 0 1 1   0 1 0 1
0 0 0 1   0 0 1 1        0 0 0 1   0 0 1 1
0 0 0 1   0 0 0 1        0 0 0 0   0 0 1 1
1 1 0 0   0 1 1 1        0 1 1 1   1 0 0 1
0 0 0 0   0 0 0 1        0 0 0 0   0 0 0 1
0 0 0 0   0 0 1 1        0 0 0 1   0 0 0 1

As novas placas do alimentador de cachorro chegaram

Como os meus amigos sabem, estou desenvolvendo desde o ano passado um projeto de um alimentador de cachorro em parceria com uma empresa aqui de Belo Horizonte.

Hoje ao chegar em casa encontro um pacote com as 10 placas que havia solicitado para serem fabricadas na Griffus (note o GFF de Griffus e a data 51-14 nas imagens abaixo), ao custo total de ~R$ 500,00.

Na segunda imagem resolvi colocar o conector de ethernet (Mag45) para ver se estava tudo correto, tudo certo! Como se trata de um projeto comercial não posso dar muitos detalhes, apenas posso dizer que o projeto usa um uC STM32 rodando NuttX e que a placa foi totalmente projetada usando software livre (KiCAD).

placas

placa_mag45

NuttX driver to control a single LED

This is a simple LED driver for NuttX.

You can control the LED over /dev/led using these commands:

nsh> echo "1" > /dev/led
nsh> dd if=/dev/led of=/dev/console bs=2 count=1
1
nsh> echo "0" > /dev/led
nsh> dd if=/dev/led of=/dev/console bs=2 count=1
0
nsh>

This is the whole driver:

#include 
#include 

#include 
#include 
#include 
#include 

#include "stm32_gpio.h"
#include "mikroe-stm32f4-internal.h"

/****************************************************************************
 * HW access
 ****************************************************************************/

/****************************************************************************
 * LEDs: Fileops Prototypes and Structures
 ****************************************************************************/

typedef FAR struct file		file_t;

static int     leds_open(file_t *filep);
static int     leds_close(file_t *filep);
static ssize_t leds_read(file_t *filep, FAR char *buffer, size_t buflen);
static ssize_t leds_write(file_t *filep, FAR const char *buf, size_t buflen);

static const struct file_operations leds_ops = {
	leds_open,		/* open */
	leds_close,		/* close */
	leds_read,		/* read */
	leds_write,		/* write */
	0,			/* seek */
	0,			/* ioctl */
};

/****************************************************************************
 * LEDs: Fileops
 ****************************************************************************/

static int leds_open(file_t *filep)
{
	/* Nothing to do here, maybe I should increase a counter like for Linux driver? */

	return OK;
}

static int leds_close(file_t *filep)
{
	/* Nothing to do here, maybe I should decrease a counter like for Linux driver?*/

	return OK;
}

static ssize_t leds_read(file_t *filep, FAR char *buf, size_t buflen)
{
	register uint8_t reg;

	if(buf == NULL || buflen < 1)
		/* Well... nothing to do */
		return -EINVAL;

	/* These LEDs are actived by low signal (common anode), then invert signal we read*/
	reg = stm32_gpioread(GPIO_LED1);

	buf[0] = (char) (reg + '0');
        buf[1] = '\n';

	return 2;
}

static ssize_t leds_write(file_t *filep, FAR const char *buf, size_t buflen)
{
	register uint8_t reg;

	if(buf == NULL || buflen < 1)
		/* Well... nothing to do */
		return -EINVAL;

	reg = (uint8_t) *buf;

        if (reg != '0' && reg != '1')
            return 1;

	stm32_gpiowrite(GPIO_LED1, (reg - '0'));

	return 1;
}


/****************************************************************************
 * Initialize device, add /dev/... nodes
 ****************************************************************************/

void up_leds(void)
{
	int ret;

	stm32_configgpio(GPIO_LED1);

	ret = register_driver("/dev/led", &leds_ops, 0444, NULL);
        if (ret < 0)
        {
           dbg("Failed to register driver: %d\n", ret);
        }
}

Note: you need to enable Arch Init (CONFIG_NSH_ARCHINIT=y) and call “up_leds();” from nsh_archinitialize() function normally in up_nsh.c.

Dirt test to prove NuttX works on Cerbuino Bee

Today I decided to test NuttX on “FEZ Cerbuino Bee Rev 1.3”. Because this board uses the STM32F405RG chip I started adapting the olimex-stm32-h405 board config.

At configs/olimex-stm32-h405/include/board.h modified the crystal (XTAL) from 8MHz to 12MHz:

#define STM32_BOARD_XTAL         12000000ul

Unfortunately it didn’t work. The usbnsh was not starting.

Then I decided to test other board config, I selected mikroe-stm32f4 this time and just modified the XTAL config from 8MHz to 12MHz and flashed it using dfu-util (to enter on DFU mode just hold the LDR button and plug the USB cable (X4 connector) to computer) :

$ sudo dfu-util -d 0483:df11 -a 0 -s 0x08000000 -D nuttx.bin

This time usbnsh configuration worked fine and I got “nsh>” prompt from USB (/dev/ttyACM0).

Configurando os atalhos de teclado no LXQt

Há praticamente 3 meses instalei o ambiente LXQt no meu notebook e estou gostando muito da interface dele. Simples e leve.

Hoje pressionei a tecla W (janela) + E e apareceu a mensagem de erro dizendo que não encontrou o programa kfmclient (Konqueror), então resolvi procurar como configurar atalhos de teclado.

Para configurar os atalhos basta editar o arquivo /etc/xdg/openbox/rc.xml e colocar a configuração de teclas desejada. No meu caso configurei o Nautilus p/ ser executado ao invés do Konqueror que não está instalado.

Programming a nRF24LU1+

The nRF24L01+ chip is not reprogrammable, but there is an alternative chip nRF24LU1+ that you can program/reprogram. There is not much information about this chip and how to program it.

But there is a guy that created a project using SDCC to be flashed on nRF24LU1+:
http://carsonmorrow.com/nrf24lu1p.php

It would be great if nRF24LU1 modules were as easy to find (and low cost) was nRF24L01+.