Friday, January 22, 2016

Linux App Pt. 2




Here  I've added a few uGUI elements and optional disabling of the animation and an FPS count.

With the animation turned off (the culling mask of the animation is off in the camera), the draw calls drop to 6, which can be lowered still further to 4 without the toggle button (shown in the screen-shot above), or 3 if the buttons don't have the white backgrounds.  Still with no graphics card and the animation turned off my Mac ran 40 FPS.



Tuesday, January 19, 2016

Linux app

Today I got advice that Linux drivers are not that high in demand, and I'd do better to work on making apps for Linux.

Here's an animation program for fun.





It is big for what it does.  10MB.

All I did was take a previous Unity3D project of mine and built it for Linux (on my Windows machine).  Anyone can get the latest or older versions of Unity for free for Windows, OSX or by now almost certainly for Linux, and build an app for a Linux target.

Builds tend to be bloated (at least that was what I saw with iOS apps compared to similar iOS apps built only with XCode), and the only other tool I've heard of as a standard is Qt, which comes already installed in Linux Mint 17.3.

-------------

Also, it might be interesting to look at libusb.sourceforge.net to build USB access into a Unity3D app.  I found nothing for libusb in the Unity asset store.

For example a use case might be a USB dongle that has to be plugged in to let the app run.


Postscript
On my iMac which is running Linux, I have the GPU disabled due to missing drivers.  So this app runs unbearably slow.  This begs the question if a Unity app with no hardware support would still be okay if it was just comparable to a Qt app - i.e. just UI elements and not much 3D.

Sunday, January 10, 2016

Building the Kernel

Many years ago when I worked for a receipt printer company, I was given the opportunity to write a USB driver for Windows.  It was one of those very fast conversations "anybody want to do this?" and I watched the opportunity pass by as someone else wanted to.  Honestly, it didn't sound very appealing at the time, but ever since then I always wondered what it would take to talk to USB devices.

So I've taken up trying to learn how to do this in a Linux environment.  There are many reasons I believe this is the best use of my time at the moment, not worth going into here.  But the biggest reason is: Stayin Alive.

To get started, the Linux Device Drivers book is free for download (and there's also apparently a 4th edition).  I'm using the 3rd edition for now:

http://free-electrons.com/doc/books/ldd3.pdf

The book wouldn't let me go any further until I had built my own kernel.  And so here we are.


Hardware

Presumably building the kernel can be done on a virtual machine or an AWS ec2 instance or a raspberry pi, but for now I'm using my old dusty iMac, because it already runs Linux Mint (see Recovering Files From A Crashed Mac), and it will build faster than the rPi.

The only downside with using my iMac was a nagging sense of doubt - that it might not work.  I also noticed the Mint distributions are all odd numbered kernel versions, so I assumed they are heavily modified from the main tree.  But I found I was able to actually build the kernel and switch to it and it actually ran fine on this hardware.

For this I got Mint 17.3 32-bit Cinnamon "Rosa", just to try getting the latest.

The process for building is fortunately spelled out: How to: Compile the latest kernels (Classic Mint & LMDE).  This is an excellent guide, even though I ran into some kinks.


The First Kink
Mint 17.3 32-bit Cinnamon Rosa runs vmlinuz-3.19.0-32-generic.  Just look in /boot, or run uname -r.

So browsing to kernel.org, the closest subsequent version was 4.1.15, so I tried downloading and making this, and the make crashed.

At this point, it really helps to have no sense of dignity or pride, no feeling of "am I wasting my time" or "this is clearly not my fate in life".  It really helps to be sort of... dumb.  You know?

So what would a dumb person do?  Follow the example on the forum verbatim of course!

By following the example to the letter, which uses 3.8.7, everything built fine.  Here's my history output which should be exactly what they posted on the forums.

      Note these aren't included but updating everything can't hurt (run as root):

    3  apt-get update
    4  apt-get upgrade
    5  apt-get dist-upgrade


    8  apt-get install build-essential kernel-package libncurses5-dev fakeroot wget bzip2
    9  apt-get install qt4-designer qt4-dev-tools qt4-doc qt4-linguist-tools qt4-qmake
   10  export CONCURRENCY_LEVEL=2
   12  export CFLAGS="-march=native -O2 -pipe"
   13  export CXXFLAGS="$CFLAGS"
   14  export CHOST="x86-pc-Linux-gnu"



     Note: These I ran as a regular user:

   29  wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.8.7.tar.xz
   30  tar -Jxf linux-3.8.7.tar.xz
   31  cd linux-3.8.7
   32  cp /boot/config-3.19.0-32-generic ./.config
   33  make oldconfig
   34  make xconfig
   35  menuconfig
   36  make menuconfig

   40  fakeroot make-kpkg --initrd --append-to-version=-mint-17.3-x86-32-16-01-09-2246 kernel_image kernel_headers
   41  ls ..
   42  cd ..
   43  sudo dpkg -i linux-image-*.deb linux-headers-*.deb
   44  sudo update-grub


Note: I think xconfig never worked for me, so menuconfig was okay, and I changed nothing in it either.

Also the build process (fakeroot make-kpkg...) took well over an hour.


The Second Kink

After rebooting, running uname -r showed the old kernel was still running.  This is because the grub apparently will run whatever the most up-to-date kernel available is.  To fix this, I ran:

  gksudo gedit /etc/default/grub

and commented out the hidden timeout references so it looked like this:

  GRUB_DEFAULT=0
  #GRUB_HIDDEN_TIMEOUT=0
  #GRUB_HIDDEN_TIMEOUT_QUIET=true
  GRUB_TIMEOUT=10
  GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
  GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
  GRUB_CMDLINE_LINUX=""


This allowed a selection menu to show up at boot.  The "advanced" menu allowed selecting the older kernel I had built.

Display Driver Issues
Lastly, just booting into that kernel didn't work because the iMac's nVidia drivers don't run.  So instead, select the "recover mode" version of the kernel, and after that boots up run the first option (something like "resume") which bypasses hardware video support altogether.  I'm writing this blog post from that build right now.  Note that the forum also explains in the same thread how to run the nVidia driver after first running:

   update-initramfs -k `uname -r`

(note the ` character not ' as the forum says).  I started to try this, didn't know where to get the nvidia driver and more importantly, I don't care.  This is adequate functionality to move forward with the Linux Driver book.

Thanks!


PostScript

Right after posting this, I tried hybernating the machine, which resulted in severe problems with booting up that kernel (even when it had already booted twice).  Specifically, the initrd.img* file for the built kernel is somehow missing.  I was able to fix this by running dpkg and update-grub again (after renaming things dpkg complained about) - but I have no explanation how the initrd.img* file got deleted.   So this whole approach is somewhat unstable for now.


Wifi Drivers


For a Mac, to get Wireless working, try this.  Namely, connect via an Ethernet cable, and run these commands:

 sudo apt-get purge bcmwl-kernel-source broadcom-sta-common broadcom-sta-source
 sudo apt-get install linux-firmware-nonfree b43-fwcutter firmware-b43-installer

and then reboot.

Thursday, January 7, 2016

Unity Versus Sencha for Mobile App Development

This whole discussion is mostly academic for me.  I post it for whoever might have an interest in these tools.


Recently I looked into the Sencha development environment.  It reminds me a lot of Maqetta, specifically the sliding UIs it generates.

I've looked into whether similar UI is available off-the-shelf for Unity (especially for workflow), and so far it looks like it's not.  I wrote a UI from the ground up using uGUI, but this adds extra weight which isn't present in the Sencha UX, and the workflow isn't anywhere close to as streamlined.

All I can say is Unity still thinks of itself as a game engine, rather than a mobile app engine.

It has not yet matured in the direction of rapid UI development.  I have this nagging feeling I want to create a Sencha-like UX in Unity, which only animates going between scenes while not actually using a Unity uGUI scroll-rect to hold them all.  Mostly I want to do this to improve the whole game development workflow, of which UI design can be a good starting point.

But again... this discussion is mostly academic.

Live and learn.  Unity is still more efficient than going through multiple target learning curves (i.e. Xcode for iOS + Android API).

Will I switch to HTML5?  Only if three.js or other tools can bridge the gap.  Push notifications look like they are available at least for Chrome (and possibly exclusively to GAE).

Google may kill Unity altogether eventually.

Thursday, December 31, 2015

A Model for Corporate Power Distribution

In 1997 Geoffrey B. West, James H. Brown and Brian J. Enquist published "A General Model for the Origin of Allometric Scaling Laws in Biology".  I don't have access to the paper, but it is summarized in a youtube video here:


How Fractal Patterns Perpetuate Through a Tree, and then a Forest - Bonzai Permaculture -

In 2009 they also published A general quantitative theory of forest structure and dynamics.

The gist of the studies is that an individual tree's branch distribution (size, distance between branches, and most importantly oxygen production) provides an accurate prediction of the whole forests tree distribution.


I tend to believe these studies provide a basis for company skill level distribution.  Call it "brain power" if you want.  In a power-optimized company, there will be a fractal distribution of people with various capacities and skills.  They won't all be power-players because there is mundane work that also needs to be done - there's a wide distribution of needs addressed by a wide distribution of workers.

The alternative is a farm-model, where the whole undergrowth of a wild forest is stripped away.  This then becomes a question of whether the farm is more efficient than the forest.

Tuesday, December 22, 2015

The Harass-Justify Pattern

I did not even want to write about this.  Then I load youtube to watch a tutorial on Scala, and up pops this ad!

I had already written this article in my head, decided I didn't want to write about it, and then I see exactly the ad I was thinking about, all in a matter of about 1 minute.

Okay!  I'll write about it!  Here's a screenshot of the ad:


Harass

The ad starts out by saying "these are real people".  I.e. they are not actors, other than the guy throwing eggs at them.

As the people go to sit down at the table, the man in the middle throws eggs and the real people jump in surprise.


Justify

If you didn't skip the ad, the middle man explains something about "life is hard to respond to when there are surprises" or something along those lines.  The justification for the harassment of throwing eggs at complete strangers is "I have some insight to share."


The Pattern

Whether or not the insight is valuable is not really interesting to me.  What is interesting is that the 2 behaviors "harass" and "justify" are presented in combination.  Throwing an egg by itself isn't enough.  And justification by itself apparently isn't enough either.  It is a theatrics pattern.

That's all... I'm going to watch about Scala now.


POSTSCRIPT

This is really obsession-compulsion, where "harass" is the compulsive behavior ("I must"), and "justify" is the obsessive thinking.  The justify is like a broken record that keeps playing over and over again.  There's some projection of "if everyone only could see what I'm obsessing about, they would understand my harassing behavior".  Such thinking is fantasy.

I guess the pattern could be generalized into Powerplay-Justify.  It's a "when words are many, sin is not far..." sort of thing.  Something about it doesn't smell right, as opposed to people operating in a natural outflow.

We could ask "what is source of obsessive thinking?"  There is a source.

Wednesday, December 16, 2015

Getting Started with HP's Fabric-Attached Memory Emulator


HP's The Machine

HPE has new hardware coming out soon called "The Machine".

If you want to write software for The Machine, you can start learning about it here:

https://github.com/FabricAttachedMemory/Emulation


I won't claim to be any sort of expert, but I was curious to try.  The point of this post is, don't let anything get in your way.  If you are not a "guru" - just do whatever you need to do and there will be something learned in the process.


Run Debian 8.x

I'm on a Windows Vista PC, and I already have Oracle VirtualBox installed, so it wasn't very difficult to start a virtual machine that runs Debian 8.2.0.  I got my Debian distro here for an i386, but you might need a different target processor if you're running an AMD machine.  It's an iso file, and has to be burned to a boot disk (supported in newer versions of Windows, on my old Vista box it brings up Roxio Easy Media Creator 9 for burning an iso to a disk).  Alternatively you could use real hardware to install Debian, or a VM in AWS et. al. - you might even be able to do this on a raspberry pi (though I doubt it due to version requirements of the package).

NOTE: When setting up the virtual machine, the HD must have at least 19GB free, so I recommend something larger.  After more than 1 attempt, I was able to succeed with a 27GB HD fixed size HD for the VM.  It looks like 22GB would have been enough.

If you are new to Debian, try finding Search and type "terminal" to open a terminal.  My Debian install did not run sudo from the terminal.  That's okay.


Install Git

For now I'll ignore no sudo.  After installing Debian, and logging in as a user, I could log in as root via "su", and then:

$ apt-get update
$ apt-get install git-core


then log out of root and go to the user's ~ home directory and run:

$ git clone https://github.com/FabricAttachedMemory/Emulation.git

This resulted in an Emulation directory and I could run:

$ ./emulation_configure.bash 1

which failed with:

Error: The Following command(s) are needed:
vmdebootstrap virsh sudo qemu-img brctl




Install QEMU, vmdebootstrap and libvirt-bin

From root:

$ apt-get install qemu-kvm

$ apt-get install vmdebootstrap

if you need sudo:

$ apt-get install sudo

and finally:

$ apt-get install libvirt-bin



Run it (still from root):

$ ./emulation_configure.bash 1

It asks:

Change /usr/lib/qemu-bridge-helper to setuid root (yes/no) ?

yes

Error: /tmp has less than 19 G free

At this point I couldn't find any way to extend the HD on the VM.  If needed you might try creating another volume and mounting it - but I started over.

With adequate HD on the VM, it now complains "No proxy setting can be ascertained", then eventually:

Failure trying to run: chroot /tmp/tmpDx8e9z mount -t proc proc /proc

and

Build of /tmp/fabric_template.img failed

Looking into the documentation at https://github.com/FabricAttachedMemory/Emulation.git might give some clues where to go next, but that's as far as I will go today.  Thanks.