[Miniproject] Raspberry Pi 2 B - pocket dev environment

Discussion in 'The Common Room' started by Elf, May 18, 2015.

  1. Elf

    Elf Immortal Staff Member

    Messages:
    105
    Likes Received:
    6
    Location:
    Clark County, WA
    I came across the CHIP project recently; a small Single Board Computer (SBC) at an extremely low price point. Looks interesting, but not released yet. It made me think about setting up a small "pocket computer" development environment and I saw that the Raspberry Pi 2/B had been released earlier this year, with a quad core 900MHz processor and 1Gbyte of RAM. Enough for a desktop environment running an IDE? We'll see!

    I have ordered the Raspberry Pi 2/B starter bundle from Jameco (my preferred electronics store), and a 32 Gbyte mini-SDHC card. The plan is to run Ubuntu MATE on it and to try and get a reasonably performing Java 8 JDK and NetBeans installed -- the most demanding of my development environments. The idea is to have a portable computer that can serve as a development desktop for code editing or secure terminal sessions only, to be accessed either by a physical keyboard/mouse/monitor or via Remote Desktop (xrdp). The heavy lifting for compiling, unit testing, etc. can be done by a CI server remotely when code gets pushed back to a repository. I would like to be able to comfortably develop C, Java, Erlang, and Python projects with it.

    Once it is built, you can drop it in your pocket and go, access it from your office, home, laptop, etc. and maintain a consistent environment with checkouts of your code. All without the network connectivity and expense that a remote desktop VM would require. It is also handy work-wise because I can easily hook it up to a projector or TV for demos.

    That is the plan, anyways! I will detail what I have done from out of the box to, hopefully, a working environment, in this thread.
     
    Last edited: May 23, 2015
  2. m0unds

    m0unds High Priest Staff Member

    Messages:
    9
    Likes Received:
    2
    awesome. i have three rpis (b-model, not rpi2 though) - one manages my fermenter for homebrewing, one does SDR w/ADS-B for monitoring aircraft transponders, and the other handles running crashplan backups for my NAS since i can't shoehorn the client directly on the NAS itself. they're pretty capable little things, and the faster chipset in the new models is supposed to be a significant upgrade.

    a competing company makes a little rpi-clone called bananapi, and that one even has a single sata2 port. neat stuff.
     
    Elf likes this.
  3. Elf

    Elf Immortal Staff Member

    Messages:
    105
    Likes Received:
    6
    Location:
    Clark County, WA
    Nice; I remember those projects but didn't realize that you had so many. Have you tried running X Windows GUI stuff on them, and if so how did you find it?

    Just looked at that, cool stuff, seems comparable to the 2/B except with Gig Ethernet and SATA. Looks like a lot of people are starting to use those "Allwinner" CPUs. ARM clones I guess.
     
  4. Elf

    Elf Immortal Staff Member

    Messages:
    105
    Likes Received:
    6
    Location:
    Clark County, WA
    For those looking for something more powerful than the Raspberry Pi 2/B but still small and cheap-ish, take a look at the Intel NUC.

    Not quite pocket sized, but with Core i5 processors, SSD support, and up to 16 GByte of RAM, some of these could be quite competitive as desktop systems running Windows 8.1 / 10.
     
  5. Elf

    Elf Immortal Staff Member

    Messages:
    105
    Likes Received:
    6
    Location:
    Clark County, WA
    The Raspberry Pi (and accessories) arrived today. I downloaded both "NOOBS" and "Ubuntu MATE" to my work desktop, but need to wait until Friday to pick up the images due to expensive bandwidth at home.


    As you can see I have added some inexpensive heatsinks to the main chips (ARM SoC and... network?) as running NetBeans will probably stress it, if anything will.

    Meanwhile I have started setting up a CI box with a Mercurial repository system and Jenkins CI to do the heavy lifting for code written on the Pi.
     
    Last edited: May 24, 2015
    m0unds likes this.
  6. Elf

    Elf Immortal Staff Member

    Messages:
    105
    Likes Received:
    6
    Location:
    Clark County, WA
    So!

    On Thursday I set up Jenkins CI and redid my Mercurial repository. Jenkins CI was quite easy to deal with except for authentication. I couldn't get the built-in Jenkins user database to work (it kept locking me out without giving me a chance to create a user, and users I created under no-auth never worked for login) so I just pushed it up a level to Apache and HTTP Basic auth.

    I retrieved the Ubuntu MATE image at work and used win32diskimager to write the raw image to the 32 Gbyte SD card. Previously I was puzzled that the HDMI port did not activate when booting the Pi on a blank or empty SD card slot. Booting Ubuntu enabled the HDMI port with nice graphical output rather quickly, so I guess it is Linux that does that and not whatever SoC BIOS there is.

    Ubuntu MATE was a very easy click-through install. The little WiFi stub adapter was recognized and worked the first time. I was happy to see that Linux now has a mostly pain-free wireless GUI. WiFi under Linux used to be atrocious. The only thing of note was that it comes as a 4 Gbyte filesystem image, which is rather tight after you do an "apt-get dist-upgrade." To correct this, you delete and recreate the root partition. This does not destroy the filesystem table.

    Code:
    fdisk /dev/mmcblk0
    d 2
    n 2 p <Use defaults>
    w
    <Reboot>
    resize2fs /dev/mmcblk0p2
    

    After that you will want to reboot and do an "apt-get update; apt-get dist-upgrade", and reboot again.

    To support development, I did an "apt-get install mercurial zsh openjdk-8-jre openjdk-8-jdk". (See later post about openjdk)

    So interestingly X Windows with MATE on this is fairly responsive. When in the shell executing commands you can tell it isn't quite a modern computer, but moving windows around and such there is no noticeable lag.

    It was a good thing I added the heat sinks. Using it for desktop purposes does seem to put quite a load on it, and the heatsinks get toasty.

    The real test came with NetBeans, which I installed using the generic shell based installer under root. After installation, the NetBeans icon slips nicely into the MATE Applications menu.

    Launching NetBeans and browsing around yielded... unfortunate results. I think the JRE might be hitting things on the ARM SoC that are not quite optimal operations, because even simple things like opening menus or changing options settings can sometimes take over a minute. The NetBeans UI is on the whole completely unusable. NetBeans on the Raspberry Pi is a huge slow pig and I expect Eclipse is even worse if performance on a PC is any indicator.

    (u7:boar)

    So NetBeans is out the window but I have not given up yet. I think I will look for a native compiled application that features a good editing UI and code syntax awareness / code completion for my favorite languages. Native UI apps on the Pi do perform decently, and even Firefox works okay on websites that are low on Javascript.
     
    Last edited: May 23, 2015
  7. m0unds

    m0unds High Priest Staff Member

    Messages:
    9
    Likes Received:
    2
    nope, haven't tried any xwindows stuff at all. crashplan stuff is all cli and java8 (oracle, not openjdk because it's awfully slow); brewpi is a php webapp and python scripts that manage an arduino dingus and the sdr stuff is also cli.

    the sata part of the bananapi is what interests me. in the case of the crashplan stuff, it'd be nice to have the local database (sqlite i think) on something other than an sdcard, but it's not a big deal.

    i like the case + heatsinks on that rpi board. looks snazzy.
     
    Elf likes this.
  8. Elf

    Elf Immortal Staff Member

    Messages:
    105
    Likes Received:
    6
    Location:
    Clark County, WA
    Ah, maybe that is my problem. I should try some different JREs.
     
  9. Elf

    Elf Immortal Staff Member

    Messages:
    105
    Likes Received:
    6
    Location:
    Clark County, WA
    After taking the hint and installing the Oracle ARM hard-float JDK 8 (which unfortunately does not come in package manager form) and removing the openjdk packages, I started up NetBeans again and found it to be basically usable! It is still a little sluggish as one would expect from a Pi, but nowhere near what it was before.

    Swing and AWT (the Java GUI toolkits) were always very float heavy and I suspect that the distro-supplied JDK was not compiled for hard float support. Furthermore looking through the apt repositories I could not find an alternative JDK or JRE that was, so definitely a mark down for Ubuntu MATE there.

    I have also gone through NetBeans and disabled the following plugins in an attempt to save on memory and execution time:
    • Hudson UI
    • Subversion
    • Spellchecker English Dictionary
    • Hudson
    • Git
    • Bugzilla
    • Spellchecker
    • NetBeans Plugin Development
    • JavaFX 2 Support
    • JavaFX 2 Scene Builder
    • Spring Beans
    • Java Profiler
    I will try to use it for some upcoming development projects and respond back about how usable the setup actually is. For code entry only, of course! The expectation is still that building and testing will be done by the CI server, and profiling and other functionality will be done on a full desktop.

    I may still look for other native editors that offer language aware code completion and syntax highlighting.
     
    Last edited: May 23, 2015
  10. Elf

    Elf Immortal Staff Member

    Messages:
    105
    Likes Received:
    6
    Location:
    Clark County, WA
    I managed to completely hose Ubuntu MATE in a weird way: by installing FirewallD. At the time I thought it was odd that FirewallD was not installed by default, as it is on most systemd distros. Now I know why.

    FirewallD added ebtables as a dependency and loading this as a kernel module seems to have really broken something. The system as a whole becomes slow and unresponsive to the point where logging in or even soft rebooting it becomes impossible, which persists after a hard reboot. I will just re-image the flash card and begin again.
     
    Last edited: May 23, 2015
  11. Elf

    Elf Immortal Staff Member

    Messages:
    105
    Likes Received:
    6
    Location:
    Clark County, WA
    Flashed a fresh image of Ubuntu MATE and re-did all of the updates/installs, skipping openjdk and going straight to hardware FP Oracle JDK 8 this time.

    I also installed xrdp (apt-get install xrdp), which is sort of a hack that provides a Windows Remote Desktop server. It is a hack because it does it via a VNC intermediate (yuck), meaning it is likely sending over full image frames instead of window paint/control information like native RDP. This is borne out in it being generally somewhat laggy and unresponsive (as well as using a lot of CPU on the Pi as it is continually compressing images), but just good enough for use. VNC is a piece of junk. At least the traffic is only local...


    I will live with it for now as it is useful in situations where I don't want to attach keyboard/video/mouse directly. I might see about hooking up a small LCD to display the Pi's IP addresses for making remote connections easier.
     
  12. Elf

    Elf Immortal Staff Member

    Messages:
    105
    Likes Received:
    6
    Location:
    Clark County, WA
    Small sidenote: Mono (C#) applications seem to be awful on the Raspberry Pi. Tried to install Keepass2 to access my usual password database. It is in the APT repository and is not what one would consider a very demanding application.

    It takes forever to start (even worse than NetBeans on OpenJDK) and then crashes. Another mark down for Ubuntu MATE repository applications on the Pi. It seems that just because it is in the official repository does not mean that it will be at all functional.

    KeepassX (a native X-windows fork of Keepass) provided a suitable alternative, but unfortunately does not open Keepass2 databases.
     
  13. Elf

    Elf Immortal Staff Member

    Messages:
    105
    Likes Received:
    6
    Location:
    Clark County, WA
  14. Elf

    Elf Immortal Staff Member

    Messages:
    105
    Likes Received:
    6
    Location:
    Clark County, WA
    [​IMG]
    [Image of Display-O-Tron 3000 (not mine)]

    Added a Display-O-Tron 3000 to automatically display IP addresses when connected to DHCP networks (so I can easily xrdp in). Fun little thing. However...
    1. To put it outside of the case you will need a stacking riser for the header, and you will need to notch out the plastic of the case to let it poke through. You may also want to add rubber feet to the bottom of the DOT3k to let it rest nicely on the case without being pushed downwards. (Or you can just use a different case that accommodates it)
    2. More frustratingly, deep in the guts of the libraries doing pin IO to the DOT3k, it will just throw a Segmentation Fault / core dump.
    I spent a little time poking around to solve problem #2. Thankfully it wasn't too bad. After looking with GDB, I noticed that the RPi.GPIO library was trying to read from a completely bogus address. Following that further it turns out the problem results from Ubuntu MATE not enabling the Linux Device Tree by default, which the Python RPi.GPIO module relies on to accurately set a raw memory address used for I/O to GPIO pins on the Pi board (which are connected up to the LCD via the pin header).

    In the absence of a working read from the device tree, it assumes an offset for the Broadcom 2708 SoC. However, the Pi 2/B uses a Broadcom 2836 SoC which has a different offset, as noted in this bug report, submitted two months ago but still not fixed in the current code.

    So, to fix it one can fetch down the RPi.GPIO source and modify c_gpio.c:
    Code:
    int setup(void){ [...] uint32_t peri_base = 0x3F000000; [...] }
    Recompile/install (python setup.py install), and of course now everything works. Somewhat hackish, but I am more interested in getting a working display than figuring out how to differentiate between SoCs and modifying the library to autodetect nicely.
     
    Last edited: May 30, 2015
  15. Elf

    Elf Immortal Staff Member

    Messages:
    105
    Likes Received:
    6
    Location:
    Clark County, WA
    I wrote the code for the Display-O-Tron 3000 to show resource usage and interface IPs while the system is running. Here is what it does:
    • Displays memory usage on the LCD as a percentage
    • Adjusts the display backlight gradient (across the three independent RGB backlight LEDs) from blue-green to red-orange in proportion to the amount of memory used
    • Displays CPU usage on the LCD as a percentage (0-400%, due to 4 cores)
    • Adjusts the bargraph number of lights and intensity in proportion to the amount of CPU used, so it will go from no bars and dim to full bars and bright
    • Enumerates the interfaces on the system and their IPv4 addresses (borrowed code) and will display up to two of these on the bottom two lines of the LCD
    • Started by systemd on boot (systemd service file included)
    The only oddity of the day was that trying to set the bargraph LED intensity to less than 148 (out of 255) caused the given LED to turn off completely. I am guessing whatever is behind it ended up putting out a voltage below the LED's minimum Vf.