Showing posts with label manjaro. Show all posts
Showing posts with label manjaro. Show all posts

Saturday, October 24, 2015

One minute tutorial: Getting started with a fresh NodeMCU ESP8266 (direct from eBay)

The NodeMCU / ESP8266 is a ridiculously cheap ($2) micro-controller that can talk to an 802.11N wireless network. This device is the herald of the "Internet of Things."

If you buy one on eBay, chances are it will NOT be flashed with NodeMCU firmware (it speaks Lua). This understandably confused the crap out of me. So, this serves as a guide to those running Manjaro (Arch) Linux:

  1. Download NodeMCU firmware
    "integer" versions will NOT understand floating point arithmetic, but save on system resources.
  2. Install minicom
    pacman -Ss minicom
  3. Install esptool from the AUR:
    yaourt esptool-git
  4. Make sure your Linux box recognizes the device
    tail -f /var/log/messages.log
  5. Plug in the NodeMCU device. You should see:
    kernel: usb whatever: ch341-uart converter now attached to ttyUSBX

    ch341-uart converter detected

    If this didn't happen, you cannot proceed and must troubleshoot.
  6. Flash the firmware. Make sure you have permission to read and write to the device in the command below. When in doubt, run as root:
    esptool.py --port /dev/ttyUSBX write_flash 0x00000 nodemcu_whatever.bin
    where:
    X corresponds to the device from the log file above, and
    nodemcu_whatever.bin corresponds to the firmware file in step 1.
  7. Unplug the USB cable after the flash command from the previous step is completed, and plug it back in.
  8. Fire up minicom, and talk to the board at 9600 baud:
    minicom -D /dev/ttyUSBX -b 9600
  9. Press the "enter" key a few times. In response, you should see:
    >
    >
  10. Try "hello world":
    > print ("hello world")
    hello world
    >

  11. Now you can configure wireless:
    > wifi.setmode(wifi.STATION)

    > wifi.sta.config("SSID", "PASSWORD")

    > ip, nm, gw=wifi.sta.getip()

    > print (ip, nm, gw)
    this   is   amazing
  12. Do some interesting things!

Saturday, September 26, 2015

Making old machines run a modern Linux distribution surprisingly well (using Zswap)

In between study sessions, I've been experimenting with some old hardware that I want to get rid of on eBay. I happen to have managed to get an old IBM A31 with 384 MB of RAM up and browsing the Web while using a modern operating system, namely: Manjaro Linux 0.8.13 (LXDE), kernel version 4.2.

The challenges here are plenty: low RAM, extremely slow and old rotational hard drive (20 GB), and the ever-increasing presence of complex multimedia and Javascript on the modern Web.

The key to my success has been the use of Zswap. In a nutshell, Zswap compresses pages that would be normally swapped out of RAM (and onto disk) into a separate storage area (in RAM) that is first compressed before being queued for swapping. This effectively increases the RAM of the computer in exchange for CPU time. With a system that is heavily I/O constrained, this is a very reasonable trade-off to make.

In order to make the default installation of Manjaro XFCE functional under such constraints:
  1. Edit /etc/default/grub and configure zswap to use the more space-efficient deflate compressor:
    1. Append "zswap.enabled=1 zswap.compressor=deflate zswap.max_pool_percent=90" to GRUB_CMDLINE_LINUX_DEFAULT
    2. update-grub
  2. Add the deflate module to the initial ramdisk by editing /etc/mkinitcpio.conf:
    1. Append "deflate" to MODULES
    2. Look inside of /etc/mkinitcpio.d/ to determine what profile to specify for rebuilding the ramdisk. If you are using the Linux 4.2 kernel (recommended):
      mkinitcpio -p linux42
  3. Uninstall the resource-hungry pulseaudio subsystem:
    1. pacman -R pulseaudio pulseaudio-ctl pulseaudio-alsa
  4. Install and use QupZilla as the default web browser
    1. pacman -Sy qupzilla
  5. For even better performance, change QupZilla's User-Agent string to an Android Webkit-based mobile device:
    1. Edit -> Preferences -> Other -> Change browser identification / User Agent Manager -> Change global User Agent

      I suggest:
      Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; HTC Sensation Build/IML74K) AppleWebKit/538.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/538.1
Remarkably, these changes allow a full Web experience. Even Youtube videos seem to function.

On such a machine -- and in order to reduce slow disk I/O -- it might be advantageous to use a btrfs root filesystem mounted with gzip compression.

Tuesday, March 17, 2015

Rid thyself of that pesky PulseAudio daemon in Arch / Manjaro Linux

I have a very lightweight system -- a laptop from 2008 -- that usually works quite well until PulseAudio gets in the way of things.

Here are some tricks to disable PulseAudio:

  1. Edit /etc/pulse/client.conf and add the line:
    autospawn = no
  2. If you want to go "the whole nine yards" and uninstall PulseAudio entirely, you can build a Gnome package that does not depend on PulseAudio:
    yaourt -S gnome-settings-daemon-nopulse
  3. Next, you can entirely remove packages that depend on PulseAudio:
    pacman -R pulseaudio pulseaudio-alsa lib32-libcanberra-pulse lib32-libpulse manjaro-pulse xfce4-volumed-pulse skype
    Note that Skype 4.3 requires PulseAudio. Therefore, you have little choice but to remove it.