Fedora on pcDuino3 Nano

When I got my pcDuino3 Nano, I found that there were no instructions on how to get it to boot into Fedora. I’m writing this so that not only can others know how to do it, but others can hopefully make it easier.

UPDATE – December 21, 2015

Due to alot of effort of many people, PCDuino3 Nano is now supported in the main uboot and kernel.  Because of that, it is now supported, out of the box on Fedora 23

These new instructions have also been tested on the new PCDuino3 Nano Lite

NEW INSTRUCTIONS

You can now follow the generic Fedora instructions. If you are doing the installation manually (which I recommend) you should follow the instructions for AllWinner A20.

Because I don’t like just putting links in, here are the instructions.

Choose a disk image.

http://download.fedoraproject.org/pub/fedora/linux/releases/23/Images/armhfp/

Write the image to your media

TYPE=  # options include KDE, LXDE, XFCE, SoaS, Mate and Minimal
MEDIA= #/dev/<location-of-your-media>
       # for example /dev/sdc, /dev/sdg, ...
       # read /var/log/messages to learn which device was assigned to your media
xzcat Fedora-$TYPE-armhfp-23-10-sda.raw.xz | sudo dd of=$MEDIA; sync

After writing the image, read the new partition table and mount the root partition

partprobe $MEDIA
PART=  #/dev/<location-of-your-media><partition-number>
       # this needs to be the root partition on the written media
       # for example /dev/sdc3, /dev/sdg3, /dev/mmcblk0p3, ...
mkdir /tmp/root; sudo mount $PART /tmp/root

Follow theses steps to write the appropriate U-Boot for your Hardware.

TARGET= # Linksprite_pcDuino3_Nano
        # Use the same target for normal or lite
MEDIA= #/dev/<location-of-your-media>
       # for example /dev/sdc, /dev/sdg, ...
       # read /var/log/messages to learn which device was assigned to your media
sudo dd if=/tmp/root/usr/share/uboot/$TARGET/u-boot-sunxi-with-spl.bin of=$MEDIA bs=1024 seek=8 conv=fsync,notrunc

Media should now be ready to boot, insert into the device and boot.

OLD INSTRUCTIONS

Section 1 – Setup to boot off the micro-sd card

The pcDuino3 Nano is very picky about booting off the micro-sd card.

Required:

  • 4Gig or more, micro-sd card

Steps:

  • Boot in factory installed ubuntu, with micro-sd card in micro-sd card slot.
  • Partway through the boot, it will say to hit F8 to go into machine setup.
    • If you miss this, then get a console window and type “board-config.sh” to bring up the menu.
  • Select “make_mmc_boot”
    • This will take everything that is on the inner 4Gig flash drive and move it onto your SD card.  The SD card will be formated with two partitions.  Partition 1 will have critical boot image on it.  Partition 2 will have the operating system on it.
  • After it is done, you can boot off that sd-card.

Section 2 – Setup to run Fedora on pcDuino

These instructions might seem complicated.  But they are really much simpler than the first few times I did this.  All of these instructions will work on Fedora, RHEL6+, or Scientific Linux 6+.

Required:

  • 4Gig or more, micro-sd card that pcDuino will boot off.  From Section 1
  • USB micro-sd card converter
  • Linux machine

Steps:

  1.  Get a VFAT Fedora image from the Fedora 20 or Fedora 21 arm download area.  I suggest the minimal version.
  2. decompress the image
    • unxz Fedora-Minimal-VFAT-armhfp-20-1-sda.raw.xz
  3. Insert micro-sd card into linux machine.
  4. If you have auto-mounting turned on, unmount the partitions, but do not “Safely Remove”
  5. Repartition the micro-sd card, I suggest fdisk.
    • Do not touch partition 1
    • Add swap as partition 3, but the blocks must be right after partition 1.  I suggest a 200M swap partition.
    • / must be on partition 2.  The blocks should start right after the swap partition.  Have it fill the rest of the disk.  (If you want more partitions, go ahead, but these instructions won’t work very well.
    • The partitions should look something like this
      Device Start End Blocks Id System
      /dev/sdc1 33 544 16384 83 Linux
      /dev/sdc2 6946 242560 7539680 83 Linux
      /dev/sdc3 545 6945 204832 82 Linux swap / Solaris
  6. Format the new parititions
    • mkswap /dev/sdc3
    • mkfs.ext4 /dev/sdc2
    • (optional) e2label /dev/sdc2 sdroot
  7. mount drives
    • For me, easiest to just remove then put back in sd card, it gets auto-mounted
    • For these instructions, we will say partition 2 is mounted on /media/sdroot
  8. As root, install  libguestfs-tools
    • yum -y install libguestfs-tools
  9. As root, extract the / filesystem from your decompressed download on Step 2, and put it onto partition 2
    • virt-tar-out -a Fedora-Minimal-VFAT-armhfp-20-1-sda.raw / – | (cd
      /media/sdroot/ && tar xvf -)
  10. sync
  11. Fix fstab so that it mounts correctly
    • Hint, find the UUID with “ls -lh /dev/disk/by-uuid/”
    • vi /media/sdroot/etc/fstab
    • Before:
      UUID=cbb10846-9a6d-4fa4-97c0-d313eebe2f8f / ext4 defaults,noatime 0 0
      UUID=DEC2-ACAF /boot/uboot vfat defaults,noatime 0 0
      UUID=194c1589-9624-43e7-8278-41b0d5a9a76e swap swap defaults,noatime 0 0
    • After:
      UUID=600a6d0f-93cb-4a96-b02d-48d36003f0ba / ext4 defaults,noatime 0 0
      UUID=9d676914-2eeb-44da-be8c-3596bcee8fd5 swap swap defaults,noatime 0 0
  12. Setup root account so you can login without a password
    • There is a bug in initial-setup. It crashes when it runs, so you have no way of logging in unless you setup logging in as root with no password.  Just remember to set the root password first thing after logging in.
    • vi /media/sdroot/etc/passwd
      • Remove the ‘x’ from the line beginning with ‘root’
  13. sync
  14. Unmount micro-sd-card partitions again, or select “Safely Remove” and remove from your linux machine.
  15. Put, micro-sd card in your pcDruino, hook up an hdmi monitor to it, and power your pcDruino on.
  16. It should go to the login prompt.
  17. Login as root, with no password, then set the password, first thing.

Section 3 – How to reset to factory settings

I managed to overwrite the build in flash, install fedora onto the built in flash with no way of logging in, and a few other fun things.  Resetting to factory settings isn’t as easy as it sounds, but they do have instructions.  Here is the video that takes you through the steps.

In the future, I hope to be able to do this on a Linux machine.

Required:

  • 2Gig or more, micro-sd card
  • USB micro-sd card converter
  • USB flash drive, normal format (msdos or vfat), with at least 2Gig of free space.
  • Windows Machine

Steps:

  1. Get kernel and ubuntu image from here – http://www.pcduino.com/image-pcduino3-nano/
  2. Install PhoenixCardv309 (From image page) or PhoenixCardv310 (From here).  I found that I had to use version 310 on Windows 7.  (Yes, that’s right, you have to run windows to reset your linux machine. Even worse, they recommend windows xp)
  3. Put 2Gig (or larger) micro-sd card in USB converter (not SD card converter), put it into your windows machine, run PhoenixCard, make sure it’s looking at the right drive, select your downloaded kernel, then select “Burn”.  When it’s done, safely remove your micro-sd card from the computer.
  4. Get a normally formatted usb flash drive, with at least 2Gig of free space.  Extract the ubuntu stuff from the zip file you downloaded in step 1, and put it (both the script, directory, and image file) on the bottom directory of the flash drive.
  5. Put the 2Gig micro-sd card in your pcDuino and power cycle it.  Nothing should come on the screen, but the green lights should slowly blink.  After it is done blinking, let it sit for another 10-30 secionds, just to be sure, then power off the pcDuino and take out the micro-sd card.
  6. Power on the pcDuino, with a monitor hooked up it.  It will set things up, then start asking to put in a USB drive with setup.sh on it.  At that time, put in the USB drive from step 4.  It wil lthen dd the ubuntu image onto the 4th partition of the built in flash drive.  Wait until it is done.
  7. Reboot and enjoy the machine back to the way it was from the factory.

Update 2015-01-12: Added link to Fedora 21 images, update link to pcDuino3 Nano kernel images.