Month: February 2016

Using OpenOCD to program a homebrew nRF51822 board

I created a board to test the Bluetooth Low Energy using Nordic nRF51822 chip, see:

I did everything today (schematic, pcb routing, board etching, soldering SMD components and software test).

I used the nrf51-sdk from here:
https://github.com/relayr/nrf51-sdk.git

For flash programming I used OpenOCD with STLink-v2, this is my openocd.cfg:

$ cat openocd.cfg 
# nRF51822 Target

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

# SWD as transport
transport select hla_swd

# Use nRF51 target
set WORKAREASIZE 0x4000
source [find target/nrf51.cfg]

Then I just execute it from terminal:

$ sudo openocd -f openocd.cfg 
[sudo] password for alan: 
Open On-Chip Debugger 0.10.0-dev-00040-gd52070c (2015-11-01-10:42)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/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
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.233751
Info : nrf51.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : accepting 'telnet' connection on tcp/4444
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0xc1000000 pc: 0x00000a40 msp: 0x20004000
auto erase enabled
Info : nRF51822-QFAC(build code: A1) 256kB Flash
Info : Padding image section 0 with 2112 bytes
Warn : using fast async flash loader. This is currently supported
Warn : only with ST-Link and CMSIS-DAP. If you have issues, add
Warn : "set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
target state: halted
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x2000001e msp: 0x20004000
wrote 93184 bytes from file s110_softdevice.hex in 4.252896s (21.397 KiB/s)
auto erase enabled
Warn : using fast async flash loader. This is currently supported
Warn : only with ST-Link and CMSIS-DAP. If you have issues, add
Warn : "set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
target state: halted
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x2000001e msp: 0x20004000
wrote 13312 bytes from file bletest.bin in 0.629010s (20.667 KiB/s)
Info : dropped 'telnet' connection

And in other terminal I execute:

$ telnet localhost 4444
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger

> reset halt
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x00000a40 msp: 0x20004000

> flash write_image erase s110_softdevice.hex 0
auto erase enabled
nRF51822-QFAC(build code: A1) 256kB Flash
Padding image section 0 with 2112 bytes
using fast async flash loader. This is currently supported
only with ST-Link and CMSIS-DAP. If you have issues, add
"set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000001e msp: 0x20004000
wrote 93184 bytes from file s110_softdevice.hex in 4.252896s (21.397 KiB/s)

> flash write_image erase bletest.bin 0x18000
auto erase enabled
using fast async flash loader. This is currently supported
only with ST-Link and CMSIS-DAP. If you have issues, add
"set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000001e msp: 0x20004000
wrote 13312 bytes from file bletest.bin in 0.629010s (20.667 KiB/s)

> exit
Connection closed by foreign host.

 

I connected the OpenOCD to SWD pins as explained here:
https://github.com/RIOT-OS/RIOT/wiki/Board:-yunjia-nrf51822

That’s it!

Advertisements

Tips to use GPG to encrypt file

These are some tips to encrypt a file with the Key ID from a username@domain.com :

Search the user Key ID:

$ gpg --keyserver pgp.mit.edu --search-keys username@domain.com

Let us to suppose the user Key ID is ABCDEF12 then you receive it:

$ gpg --keyserver pgp.mit.edu --recv-keys ABCDEF12

or if you have the public key of destination user:

$ gpg --import userkey.asc

Finally you encrypt the file this way:

$ gpg --output fileencrypted.gpg --encrypt --recipient username@domain.com fileplain.txt

Testing a RGB LED on NuttX with brightness control

In my previous post I explained how to control a RGB LED on NuttX, but at that time it doesn’t have brightness control.

Now I created a new driver that uses three PWM pins to control the LED intensive.

I posted the driver in the NuttX mailing list and Greg incorporated it on NuttX mainline (drivers/leds/rgbled.c).

A video worth more than 1 millions of words:

You can reproduce it just connection a RGB LED to STM32F4Discovery this way: Red pin connected to PE9, Green pin connected to PA1 and Blue pin connected to PB0 and compile NuttX with these commands:

$ cd nuttx
$ cd tools
$ ./configure.sh stm32f4discovery/rgbled
$ cd ..
$ make

Just write the nuttx.bin in your board and the LED fading will start after reset.

Playing the Game for a Longer Life

I read some news about a research that suggest removing the senescent cells from the organism will increase the lifespan in animals about 25% (in mouse at least).

Then I decided to search for it and find out this nice blog about this subject:
http://joshmitteldorf.scienceblog.com/2016/02/08/one-of-the-most-important-aging-discoveries-ever/

Josh Mitteldorf has many research about aging process and many interesting posts.

ailment to improve your health:

casper (alcaparra)
omega-3 oils
turmeric (açafrão-da-terra)
ginger (gengibre)
aspirin (aspirina)
ibuprofen (ibuprofeno, advil)

senescent killer drugs:

mitoq
skq
enzymatically modified isoquercitrin (α-oligoglucosyl isoquercitrin; EMIQ)
navitoclax