Restarting Cinnamon after freeze without losing session information

Whoo! For some reason, cinnamon freezes extremely often (multiple times a day) on my desktop, and I had been resorting to “ctrl-alt-f1” to get to a terminal and running “killall cinnamon-session”, which brings me back to login screen. Fortunately, there is a better solution, aka “ctrl-alt-esc”.

Here’s the relevant excerpt from the Cinnamon blog (http://segfault.linuxmint.com/2015/06/cinnamon-2-6/):

Desktop freezes

In case of a freeze or if you need to restart Cinnamon for any reason, you can now do so via a keyboard shortcut. The default key combination is Ctrl+Alt+Escape. Pressing this combination of keys restarts nemo and cinnamon-settings-daemon in case they had crashed, and launches a brand new instance of the Cinnamon desktop. Unlike Ctrl+Alt+Backspace which terminates your session and brings you back to the login screen, Ctrl+Alt+Escape simply restarts Cinnamon itself, which means your session is exactly as it was, you don’t lose any work and all your windows and applications remain open.

 

NRF51-DK and Ubuntu 14.04: pt2, UART BLE Loopback with Android 4.4.4

NRF Toolbox UART log showing sent and received messages
NRF Toolbox UART log showing sent and received messages

In the previous post I described three quick steps (well… sometimes mbed is pretty slow) to get started with NRF51-DK on Ubuntu 14.04.

Yesterday I was able to get the NRF51-DK to talk to my phone, which was pretty exciting.

In short

For NRF51-DK:

  • Open mbed compiler
  • Import > Click on “programs” tab instead of “libraries”
  • Search for “BLE_LoopbackUART” > Import
    Note: Do NOT check “update libraries”, unlike what this Evothings post suggests, checking “update libraries” actually threw errors and failed to compile in the next step, whereas if I went back and re-imported checking “update libraries”, it compiled fine
  • Compile and save file
  • Copy to JLINK to upload.
    Note: Make the NRF51-DK is turned ON and connected to laptop

On Android:

  • Using Google Play, install NRF Toolbox from Nordic
  • Open and click on UART
  • Click Connect (say “yes” to turning on bluetooth if you haven’t already)
  • Click the “…” > Show log
  • Write “hello” > SEND
  • Click “↵” on your android phone or scroll to the bottom of the log
  • You should see it say “hey” sent and “hey received” 🙂

In Long (with screenshots)

  • Open mbed compiler
  • Import > Click on “programs” tab instead of “libraries”
  • Search for “BLE_LoopbackUART” > Import
    Note: Do NOT check “update libraries”, unlike what this Evothings post suggests, checking “update libraries” actually threw errors and failed to compile in the next step, whereas if I went back and re-imported checking “update libraries”, it compiled fine
    Screenshot from 2015-08-27 11:39:13
  • Compile and save file
  • Copy to JLINK to upload.
    Note: Make the NRF51-DK is turned ON and connected to laptop

On Android:

  • Using Google Play, install NRF Toolbox from Nordic
    Screenshot_2015-08-27-11-25-04
  • Open and click on UART
    Screenshot_2015-08-27-11-25-58
  • Click Connect (say “yes” to turning on bluetooth if you haven’t already) and select the “BLE UART” device near you
    Screenshot_2015-08-27-11-26-44
  • Click the “…” > Show log
    Screenshot_2015-08-27-11-27-02
  • Write “hello” > SEND
  • Click “↵” on your android phone or scroll to the bottom of the log
  • You should see it say “hey” sent and “hey received” 🙂

    NRF Toolbox UART log showing sent and received messages
    NRF Toolbox UART log showing sent and received messages

Tada! That’s it.

Next, servos and robots! Then, many hours of porting code from Arduino to ARM.

NRF51-DK and Ubuntu 14.04 in five minutes (Getting started with Nordic NRF51822 Bluetooth Low Energy Development Kit)

nrf51-2
Glorious new nails + NRF51-DK, which is Arduino-Due-shield-compatible.

Short Story

  1. Go to https://developer.mbed.org/platforms/, add the NRF51-DK platform, open the compiler, import the “mbed_blinky” example, hit compile, and download the *.hex file
  2. Plug-in the NRF51-DK with a microUSB cable and turn the switch to “on”.
  3. Copy or drag-and-drop the .hex file to the “JLink” drive, which should auto-mount and appear under “devices” in your file manager
  4. Voila! Light should now be blinking.

Background

Recently after a bit of head-scratching, I found out that it’s very easy to program ARMs on Ubuntu 14.04, or at least the ARM chip on the system-on-a-chip NRF51822, an integrated circuit made by Nordic Semi that has both a bluetooth low-energy module [1] and a 32-bit ARM® Cortex™ M0 CPU with 256kB flash + 16kB RAM.

I’m exploring this chip because the atmega328p chip by itself is around $2.5 in quantity, and this chip has both an ARM microcontroller (mcu) and ble built-in for $2.5.

[1] (2.4Ghz transceiver, so actually supports NRF24L01+ protocol as well, for which you can find transceiver breakouts on ebay for $2)

nrf24l01+
nrf24l01+ breakout

I bought the NRF51-DK recently on semiconductorstore.com for $70 plus shipping. This is the main page: https://www.nordicsemi.com/eng/Products/nRF51-DK .

Yea, not much of a “get started here” anywhere on the page. The PDF tells you to download NRFgo studio and is obviously on windows.

So here’s my getting started guide. Note: I followed https://evothings.com/getting-started-with-mbed-arms-new-iot-platform-and-the-nordic_semiconductor-nrf51-dk/ for the most part.

Overview

  1. We will use the mbed compiler to turn our code from “DigitalOutput(LED1)”-esque code into .hex files for our chip, the NRF51-DK.
    mbed is a browser-based compiler, so you hit “compile” and get a file to download. I believe it’s developed directly by ARM.
    mbed has a Microsoft XP look, which is quite strange-looking inside the browser, but it works.
  2. We will “program” our chip by copying the .hex file to the “JLink” drive that shows up in our windows manager, similar to how a USB drive or other external drive shows up.

mbed

  1. Create an mbed account
  2. Go to “Platforms” and search for NRF51-DK, then click “Add to my compiler.”
  3. Click on “open mbed compiler”Screenshot from 2015-08-26 13:26:00
  4. The mbed compiler takes a while (minutes) to load. Grab a cup of coffee.
  5. Click “import” then search for “mbed_blinky” by the Author “team mbed”.  Click on it and hit enter, and the program will be imported
    Screenshot from 2015-08-26 13:30:18
  6. Open the program and click on “main.cpp” in the root folder. No changes are needed. The url should be something like: https://developer.mbed.org/compiler/#nav:/mbed_blinky/main.cpp;
    Screenshot from 2015-08-26 13:30:50
    T
    he code is:

    #include "mbed.h"
    
    DigitalOut myled(LED1);
    
    int main() {
        while(1) {
            myled = 1;
            wait(0.2);
            myled = 0;
            wait(0.2);
        }
    }
    
  7. Hit “compile” and save the file that you are prompted to download.
    Screenshot from 2015-08-26 14:15:43
  8. All done with this step! Optional: Change the wait time to 0.2 seconds and download another .hex file.

J-Link Programming

For me, I just plugged in the dev board using a micro-usb cable, turned the switch on the board to “on”,  and it showed up (ubuntu 14.04) and auto-mounted and showed up under “Devices” in nautilus file manager.

I’m not certain if I installed drivers along the way, but if so it must have been something sudo apt-get installable, because I don’t remember it.

Screenshot from 2015-08-26 14:12:15
output of dmesg | tail after plugging in device
  1. Drag and drop the .hex file to the JLink drive (or otherwise copy it over). Warning: drag-and-drop in nautilus pastes the .hex file over, and it’s not preserved after the chip programs itself, so use ctrl-c ctrl-v (or otherwise copy instead of cut) if you want to keep it!
  2. The JLink “drive” will disappear and after a few seconds reappear. This is it programming itself and rebooting itself.

    Screenshot from 2015-08-26 14:11:53
    Drag-and-drop
  3. Your LED1 should now be blinking! Yay!
    You can double-check that there’s no “fail.txt” in the JLink drive.

    Screenshot from 2015-08-26 14:13:48
    No “fail.txt”1 Yay

That’s it! Whoo!

Congratulations, you’ve now programmed the NRF51-DK on Ubuntu 14.04 to do the “hello world” blink example!