Friday, January 31, 2014

Recovering the root password on a BeagleBone Black

I recently went to use a BeagleBone Black board on which I'd never booted from the eMMC before (that I could recall) and had been instead booting off of a microSD card. To the best of my knowledge, the root password on this board should never, ever have been changed from the default (blank password), but apparently it was. None of the passwords that I had ever used for any of my BeagleBone Blacks was working, which created a problem: I needed to recover the root password to this BeagleBone Black so that I could use it for my projects again. I was in luck. The BeagleBone Black has the tools that I needed to do it. I'm writing this blog post (like many other posts in the blog) so that I can have a reference to come back to if I ever need it in the future.

To recover the root password of a BeagleBone Black, you'll need the following items:

  • A 5V, minimum 1 A dedicated power source (you shouldn't really be powering the board off of the micro USB port)
  • An SD card (and reader, of course)
  • An FTDI USB-to-serial cable for accessing the debug serial port of the BeagleBone Black.
Once you've acquired all of the required items above, perform the following steps:

  1. Flash the SD card with an image that you can obtain from BeagleBone.org/GettingStarted.
  2. Insert the SD card into the *unpowered* BeagleBone Black.
  3. Apply power.
  4. The BeagleBone Black should boot from the SD card (assuming that you've flashed the correct image)
  5. Connect the FTDI serial cable to the board and your compter, and open your serial client of choice to connect to the board.
  6. Hit enter once or twice, and a command prompt should come up, assuming you've used the correct settings:
    1. 115200
    2. 8N1
  7. Log in using root and a blank password (should be the default on the SD card image that you downloaded from the BeagleBoard.org website.)
You're now logged into the image running on the SD card. However, we can't change the root password now because that will only change it for the root user on the SD card image. We need to change it for the permanent image stored on the BeagleBone Black's embedded eMMC flash. Being logged in as you are, perform the following steps to mount the eMMC image and change the password for that image's root user:

  1. Mount the eMMC flash:  mount /dev/mmcblk1p2 /media/card
  2. Change the root of the file system to be the partition on the eMMC flash which you just mounted: chroot /media/card
  3. Change the password of the root user to something you know: passwd root
  4. Exit out of the changed root: exit
  5. Shutdown the BeagleBone Black : shutdown -h now
  6. Disconnect the power from the board
  7. Eject the microSD card.
  8. Reconnect the power to the board
  9. Watch the board boot up, and log in as root. You should be able to log in with the password that you just set.

Implicit rules with Makefile

In my ongoing quest to make my builds less complex and faster, I've been going through my Makefiles and trying to learn as much as possible to simplify it and leverage Make as much as I can. To that end, I discovered something incredibly useful today that I suppose I would have known had I taken the time to read the man page for Make:

make -p


This command will list all of the implicit rules for make, which you can then use to optimize the living crap out of your Makefile.

Thursday, January 02, 2014

Installing NTP on an Ubuntu server

NTP is used to synchronized time between machines. You can read the Ubuntu HOWTO here.

Installing a TFTP server using xinetd on Ubuntu

I recently had need to redo an old server that had been running an ancient Gentoo installation for which there was no longer a software upgrade path, so I chose to install Ubuntu on it. Part of the requirements of the server were that it runs a TFTP server for hosting files for configuring embedded devices. I had previously found an article on how to setup TFTP through inetd, but I could find it, so I'm cobbling this tutorial together from various sources.

  1. # apt-get install xinetd tftpd
  2. Ensure that the following lines are in the /etc/services file:
    1. tftp     69/tcp
    2. tftp     69/udp
  3. Open the /etc/xinetd.d/tftp file (create it if it doesn't exist) and ensure that it contains the following:
    # default: off
    # description: The tftp server serves files using the Trivial File Transfer \
    #    Protocol.  The tftp protocol is often used to boot diskless \
    #    workstations, download configuration files to network-aware printers, \
    #    and to start the installation process for some operating systems.
    service tftp
    {
        socket_type     = dgram
        protocol        = udp
        wait            = yes
        user            = root
        server          = /usr/sbin/in.tftpd
        server_args     = -s /tftpboot
        disable         = no
    }
    
  4. # /etc/init.d/xinetd restart
  5. Test the server:# tftp localhost
    tftp> get hello.txt
    Received 23 bytes in 0.1 seconds
    tftp> quit 
You should now be good to go. The (abridged) instructions for this were retrieved from this article.