Setting up the Snapdragon DragonBoard 410c for headless server operation

All projects must start somewhere, and most of the time when working with electronics or embedded programming, you're going to have to deal with a controller board of some kind.  Controller boards can range in capabilities, so we usually look for a balance in capacity of processing and cost requirement in terms of resources.  If you want to work with the Internet of Things (IOT), then you're probably looking at making some object that needs logic.  Just as most projects need something to control them with logic and a Central Processing Unit (CPU), it's probably good to establish how to use one of the better controller boards available for the money.

The DragonBoard 410c comes with Android installed.  As cool as that is, it's not so useful for an IOT (Internet Of Things) object that doesn't use touch to interact. Android does not support running a server on it that can be controlled from other computers.  Android is a very "user facing" operating system in that it is meant to be used by an end user directly.  End users will have a screen in front of their eyes and can interact with it with their fingers on a touch screen.  If your project does not feature a design involving that "user facing" characteristic, then you probably want to work in what's called a "headless mode."  In headless mode, your project loses any correlation with having any requirements of a screen at all or input devices.  All that is required is that the headless mode logic board be given power and it will run happily servicing its purpose dependent only upon what design you give it for input and output (usually a separate computer talking to it over the local network).

Another motivation for replacing Android with something able to work in headless mode is we might want to use some low level functions to give us capabilities like computer vision without a lot of overhead from the dalvik runtime environment (a constraint Android places on the operating system to gain security and stability at the cost of restricting what a program can do on the operating system).  Android gives a great security capability to everything running in its own sandbox so each application running on android is unable to affect other parts of the system or applications.  That security feature is wonderful unless you have need of directly accessing the system which is often a desire when building an IOT object.  This limitation means that we must first flash the operating system to one that isn't quite so "user facing."

As luck would have it, Qualcomm supplies a Debian (Linux) version of the OS.  Ensure you download a version that is more recent than 40 to avoid a bug with the WiFi driver that makes it difficult to use the device as a headless server.  Download the latest version of the OS here.  You want to get the one named "Dragonboard410c_sdcard_install_debian_XX.zip" where XX is the latest version number (55 is the latest one as of this writing).  Once you download the zip file, unzip it and then place the microSD card in the writer.

For Windows, you need to download some special software.
1.) Download Win32DiskImager utility, install it and run it as an administrator.
2.) Now select the image file (.img) from the OS downloaded earlier.
3.) Select the drive letter of the SD card (be certain it is your SD card as this operation can destroy the data on your hard disk if you get it wrong).
4.) Click write and then wait for it to finish.
5.) Finally exit the imager and eject the SD card prior to removing it from the writer.

For OSX, and Linux, you don't need any extra software.  First OSX:
1.) Open the command prompt and run "diskutil list"
2.) Identify the disk (not partition) of your SDCard (i.e. disk3 and not disk3s1)
3.) Unmount your sdcard:  "diskutil unmountDist /dev/disk3"
4.) Copy the data to your SD card: sudo dd bs=4m if=image.img of=/dev/rdisk3
     - sudo is substitute user to the admin user and do the command that follows it as that admin user.
     - dd is a direct data copier.  This is about as no nonsense as a data copier gets.  DD will write any image to the file directly.
     - bs=4m is the blocksize for the input and output.  This means that it will read and write in 4meg block sizes.  Note that if you get an error saying 'invalid number 4m' then you should try bs=4M as you have GNU coreutils installed.
     - if=image.img This is the option where you specify the Input File (if).
     - of=/dev/rdisk3 This is the option where you specify the Output File (of).  In Unix operating systems, which OSX being based upon BSD qualifies, all physical devices are communicated with as if they were files.  You can effectively treat the devices as if they were input and output files directly.  However, it's far better and easier to use drivers that are written for such things.  dd is a program that handles the bit for bit copy very well so it is safe to use in this manner.
     - Note that you can hit ctrl-t to send SIGINFO to the dd process and it will give a progress of the transfer.

For Linux do this: (This is VERY similar to OSX)
1.) Run df -h from the command prompt.
     - This lists what devices are currently mounted make note of which is the SD card.  If you can't tell which is the SD card, then remove the SD card, run df -h and then reinsert the sd card and rerun it, the new device is the SD card.  It will look something like /dev/mmcblk0p1 or /dev/sdd1 (note that the p1 and the 1 are the partition numbers.  We want to write to the whole thing and not just one partition so we'll be omitting that from our dd command later.  Thus our target will be /dev/mmcblk0 and /dev/sdd respectively.
2.) unmount the sd card with umount /dev/sdd1
    - Note that we do have to include the partition table here.  This will be over written later, which is why it'll be gone later.  For now, just unmount it as that's what the partition table has reported so how we must address it.  Also note that you must unmount ALL partitions related to the sd card if there are more (get a blank Micro SD card to begin with and save a lot of confusion here).
3.) As in the OSX instructions, do a dd command: dd bs=4M if=image.img of=/dev/sdd
    - Again, please note that the partition number is missing above as we want to target the whole device and not just the partition.
    - If 4M has trouble, try using 1M  Although it will take much longer.


Now no matter your Operating System, take it out of the writer and place it into the DragonBoard 410c.  On the back of the 410c you will see a set of 4 switches.  As we're flashing the internal disk, we need to tell the system to boot from the SD card.  Flip the SD card switch to ON which is the second from the bottom right corner of the board.  Now plug in your monitor, keyboard, mouse and finally power.
The board can take a minute or so to boot into the boot menu.  When you see the boot menu, hit I on the keyboard to start the flash or hit the "Install" button in the GUI.
When prompted, remove the sdcard and hit okay or enter key to let the system reboot.

Here you'll have to wait about a minute or two for the new OS to boot on the 410c.  When Debian is finished booting, you will see a Debian Gnome desktop.  Click the network settings and connect it to your wifi network.  I prefer to use my normal computer and operate the 410c in headless mode while I get things setup so I use ssh to connect to the device.
As it ships, the 410c uses the linaro user and the password for that user is linaro.  As you might guess the fact that I can place this on a webpage, means you should change the password as a first step.  So let's do that.
First determine the ip address of the 410c by asking your home wireless router what the IP address is.  If you can't find it, then using the 410c's keyboard, go to the command prompt, XTerm, then type in /sbin/ifconfig  This will display lo first then wlan.  wlan will show what the ip address is.
From your main computer
1.) ssh linaro@<ip address of the 410c>
2.) linaro is the password
3.) Now change the password for linaro by typing in passwd

It is usually fine to stop here if you are not worried about security nor about upgrades.  But for those willing to plow ahead, let's configure automatic upgrades:

1.) sudo apt-get install unattended-upgrades
2.) sudo vim /etc/apt/apt.conf.d/50unattended-upgrades <-- you can use any text editor you prefer here.  Just set all the configurations to be something you can live with for your project.
3.) sudo dpkg-reconfigure -plow unattended-upgrades

Now you have automatic upgrades and thus a fairly stable system.  Security is a large topic area, and the default settings are usually secure enough for most IOT uses.  If you're worried about it, then try out Bastille or harden from Debian's main tool line.  I will be posting an article on how to do home lan security using these systems in the near future.  However, leaving everything behind your router firewall is a good practice.

Congratulations, you now are ready to use your new headless debian server for an IOT project.  I will reference this post frequently as I'll be using it as my starting point for several projects on this blog.  Please follow along!

Comments

Popular posts from this blog

Drone VR Software Architecture

Build Snapdragon Flight Drone

Soldering new connectors for the drone