A trick to show Debug messages only in the current file

This trick can be used to avoid showing annoying debug message from all drivers and subsystems supported by NuttX:

#include <nuttx/config.h>

/* Trick to get DEBUG messages only in this file */
#define CONFIG_DEBUG 1
#define CONFIG_DEBUG_VERBOSE 1
#define CONFIG_DEBUG_I2C 1

#include <debug.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <errno.h>

It is very important to put the “defines CONFIG_DEBUG*” only AFTER the include nuttx/config.h and BEFORE the include debug.h.

Thanks Greg Nutt for this nice tip!

Debugging NuttX on Atmel SAM L21 microcontroller with J-Link programmer

Run JLink GDB server this way:

$ JLinkGDBServer -device ATSAML21J18 -if SWD

Execute GDB passing the ELF file:

$ arm-none-eabi-gdb nuttx

Connect to GDB server:

(gdb) target remote localhost:2331
Remote debugging using localhost:2331
0xfffffffe in ?? ()

Reset, load, add breakpoint and continue:

(gdb) monitor reset
Resetting target

(gdb) load nuttx
Loading section .text, size 0xc758 lma 0x0
Loading section .ARM.exidx, size 0x8 lma 0xc758
Loading section .data, size 0x70 lma 0xc760
Start address 0xa4, load size 51152
Transfer rate: 12488 KB/sec, 3410 bytes/write.

(gdb) b os_start
Breakpoint 1 at 0x3130: file init/os_start.c, line 260.

(gdb) c
Continuing.

(gdb) step

Fix the Ubuntu blinking mouse cursor

If you just installed Ubuntu 14.4 LTS and you get annoyed by mouse cursor blinking all the time, then you get fix it disabling the “Unknown Display”.

Open the Unity Control Center clicking in the gear icon at application bar or executing the command “unity-control-center –overview”.

Then click in the “Displays” icon and in the new screen click on “Unknown Display” and change it from “ON” to “OFF” to disable it.

Finally click on Apply and the cursor will stop to blink.

Using the Nintendo Wii Nunchuk Joystick in the STM32F4Discovery running NuttX

I created a simple NuttX sensor driver (I will implement a joystick driver and send to NuttX mainline) to use Nunchuk Joystick with STM32F4Discovery running NuttX.

We have two options to see the NuttX serial console on STM32F4Discovery board: 1) Connect a USB/Serial dongle to UART pins or 2) Use the “usbnsh” configuration to get the serial console in the MicroUSB port (CN5).

I opted to use the UART pins because I have many USB/Serial dongle here.

The NuttX serial console for STM32F4Discovery board is on UART2:

PIN   |   FUNCTION
------------------
PA2   |    TX
PA3   |    RX

Then all I need to do is to connect the dongle GND signal to board GND, RX signal to PA2 pin (TX) and TX signal to PA3 pin (RX).

After getting the NuttX running in the board I connected a Nunchuk receptacle connector (I cut it from a Wii Mote damaged board) to STM32F4Discovery.

I’m using I2C 1 in the pins PB7 and PB8:

/* I2C config to use with Nunchuk PB7-PB8 */

#define GPIO_I2C1_SCL  GPIO_I2C1_SCL_2
#define GPIO_I2C1_SDA  GPIO_I2C1_SDA_1

This is the Nunchuk to STM32F4Discovery wiring connection:

---------------------------------
  Nunchuk  |   STM32F4Discovery
-----------|---------------------
     1     |       PB7
     2     |       NC
     3     |       3V
     4     |       PB8
     5     |       NC
     6     |       GND

This is the Nunchuk pinout:
nunchuk_pinout

The Nunchuk can be detected at I2C address 0x52. And to initialize it you need to write “0x40 0x00″ (write 0x00 in the register 0x40).

This is the command used to debug the reading of data:

nsh> dd if=/dev/nunchuk0 of=/dev/null bs=6 count=1 
 X: 114 | Y: 126 | Buttons: 3 
nsh> 

More than one thousands words:
nunchuk_connection

Listing of projects devoted to IoT

There are many open-source “Deus-ex” solution for IoT (a flashion name), then I decided to list some of these projects here:

AllJoyn (an AllSeen Alliance framework):
https://allseenalliance.org/developers/download

Arduino – the King of hobbyist IoT (without Internet) :
http://www.arduino.cc

Contiki – The Open Source OS for the Internet of Things (they are biased):
http://www.contiki-os.org

Freeboard – A Web Dashboard for IoT visualization:
http://freeboard.io

IoTSyS – Internet of Things integration middleware:
https://code.google.com/p/iotsys

LiteOS – It appears Huawei is using it for their 10Kb RTOS:
http://www.liteos.net

Mbed OS (from ARM):
http://mbed.org

MicroCoAP:
https://github.com/1248/microcoap

Mosquitto MQTT Brokwer:
http://mosquitto.org

NuttX – The best RTOS for IoT (sorry I’m biased) :
http://nuttx.org

Particle – Open Software/Hardware for IoT:
https://www.particle.io

Qeo communication framework:
http://www.qeo.org

Node-Red A visual tool for wiring the Internet of Things:
http://nodered.org

RIOT-OS – The friendly OS for IoT:
https://github.com/RIOT-OS

Soletta Project is a framework for making (Linux)IoT devices:
https://github.com/solettaproject/soletta

The Thing System:
thethingsystem.com

Tinq is a software framework for device data exchange (based on Qeo) :
https://github.com/brunodebus/tinq-core

I am sure it is missing more some thousand of open-source projects. Give me a hint!

More info: http://www.datamation.com/open-source/35-open-source-tools-for-the-internet-of-things-1.html

Listing of Open Source Ladder editors

I am looking for open-source ladder editors:

ClassicLadder is a Ladder/Grafcet editor for Linux/Windows in C:
http://sourceforge.net/projects/classicladder/

Soapbox is a Ladder editor in C#:
http://soapboxautomation.com/products/soapbox-snap/

Waltech LadderMaker editor in Python:
http://www.waltech.com/open-source-designs/

LDmicro Ladder Editor/Compiler for PIC and AVR (Windows only) :
http://cq.cx/ladder.pl

OpenPLC Ladder Editor in C++ (code based on LDmicro) :
https://github.com/thiagoralves/OpenPLC-Ladder-Editor

Other projects related to it:

Beremiz is complete automation solution based on MatPLC, PLCopen Editor, CanFestival, etc :
http://www.beremiz.org

Open Hardware for Industrial Automation:
http://www.industrialshields.com/index.php?route=common/home

Using OLinuxino in an automation solution:
http://leachy.homeip.net/olinuxino/classic_ladder.html

MBLogic is automation solution developed in Python:
http://mblogic.sourceforge.net/software/software.html