Month: June 2015

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_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

(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:

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 (SDA) and PB8 (SCL) */

#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:

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 

More than one thousands words:

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):

Arduino – the King of hobbyist IoT (without Internet) :

Blynk – to create Android and iOS User Interfaces:

Contiki – The Open Source OS for the Internet of Things (they are biased):

Freeboard – A Web Dashboard for IoT visualization:

IoTSyS – Internet of Things integration middleware:

JerryScript – It is a JavaScript engine for IoT:

LiteOS – It appears Huawei is using it for their 10Kb RTOS:

Mbed OS (from ARM):


Mosquitto MQTT Brokwer:

NuttX – The best RTOS for IoT (sorry I’m biased) :

Particle – Open Software/Hardware for IoT:

PushOver for notification:

Qeo communication framework:

Node-Red A visual tool for wiring the Internet of Things:

RIOT-OS – The friendly OS for IoT:

Soletta Project is a framework for making (Linux)IoT devices:

Splunk – Visualize servers and device log data

ThingSpeak – A open and free platform to store and visualize sensor data online:

The Thing System:

Tinq is a software framework for device data exchange (based on Qeo) :

V7 is a JavaScript engine for microcontrollers:

VIPER – Python for IoT:

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

More info:

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:

Soapbox is a Ladder editor in C#:

Waltech LadderMaker editor in Python:

LDmicro Ladder Editor/Compiler for PIC and AVR (Windows only) :

OpenPLC Ladder Editor in C++ (code based on LDmicro) :

Other projects related to it:

Beremiz is complete automation solution based on MatPLC, PLCopen Editor, CanFestival, etc :

Open Hardware for Industrial Automation:

Using OLinuxino in an automation solution:

MBLogic is automation solution developed in Python: