Sunday, June 19, 2016

PC Engines' APU 2C4 - Installing CentOS 7 to the SD Card from the Mac

I purchased a little device from PC Engines called the APU 2C4.  It's a small, "embedded" system running an AMD GX-412TC (1 Ghz Jaguar quad core, 4Gb of RAM, 3 Gigabit ethernet ports).  It has no graphics card, and ONLY works with a serial console.

That means you have to use a null modem cable.  Make SURE it's a null modem cable, not a null modem cable with a null modem adapter.  I fought with that thinking it was a problem with the board for WEEKS, until I checked what I thought was a standard DB9 cable and found out it was a null modem cable.  That check came AFTER I ordered another one thinking I had a bad one.  But when the second one did the same thing - I knew something was wrong with the way I was doing it, and that's why I checked my cable.

Here is my installation :
  1. Download the PC Engines Tinycore Linux .bz file.
  2. Create a partition and mark it active in disk :

      fdisk /dev/sdg

    The type will be "e" when you change the type.
  3. Format a flash drive with fat 16 :

      mkfs.msdos -F 16 /dev/sdg1

    This will wipe out anything, and create the file system.
  4. Install syslinux :

      syslinux /dev/sdg1

    This will place the right configs into position.  If the USB disk does not boot, you may need to run a "dd bs=440 if=/usr/share/grub2/mbr.img of=/dev/sdg" to reset the master boot record.  Check the mbr filename - that came from memory that is days old.
  5. Download the Firmware update (the default firmware does not support booting from the SD card).
  6. Add the firmware to the boot disk for the tinycorelinux from PC Engines.
  7. Connect the console/serial null modem cable.
  8. Connect the USB tiny core flash drive to the device
  9. Power on the APU.
  10. At the prompt, change directories into /media/usbhd-sda1 .
  11. Update the flash :

      root@box:/media/usbhd-sda1# flashrom -w apu2_160311.rom -p internal
      flashrom v0.9.8-r1888 on Linux 3.16.6-tinycore (i686)
      flashrom is free software, get the source code at
      Calibrating delay loop... OK.
      coreboot table found at 0xdffae000.
      Found chipset "AMD FCH".
      Enabling flash write... OK.
      Found Winbond flash chip "W25Q64.V" (8192 kB, SPI) mapped at physical address 0xff800000.
      Reading old flash chip contents... done.
      Erasing and writing flash chip... Erase/write done.
      Verifying flash... VERIFIED.

    This will allow you to boot from the internal SD card.  Now we can proceed to install CentOS.
  12. Download the ISO for CentOS 7, 64 bit.
  13. Create a USB boot disk for CentOS 7 64 Bit.  Make sure you have your USB device properly identified, as if you point it to the wrong device, you can easily destroy your system!

      dd if=CentOS-7-x86_64-bin-DVD1.iso of=/dev/sdg

    Again, make absolute sure you point that of= parameter to the correct device!
  14. Assemble the board, SD card, and case combination.
  15. Plug in the USB disk.
  16. Connect the null modem cable between your serial port (or functional USB serial port adapter).
  17. Start "screen" using the correct device, mine is a USB serial adapter device :

      screen /dev/tty.usbserial-A5001As7 115200 8N1

    That should immediately allow for the 11520 8n1 communication used by default.
  18. Power on the device.
  19. Boot the device to the USB stick.
  20. On the boot menu, highlight the option for installing CentOS, and then press the TAB key.
  21. Append to that line the following text :

      text console=ttyS0,115200n8 quiet

    This should give you the non-graphical, serial based installation options you need.
  22. Install CentOS the way you want to.
  23. Wait for the installation to complete.
  24. Change to the tiny core USB device and power cycle the device.
  25. Update the device firmware.
  26. Reboot (power cycle) the device.
  27. At the boot menu for the OS, select the "Troubleshooting", then the "rescue" option, and hit tab.
  28. Again, add :

      text console=ttyS0,115200n8 quiet

     Hit enter and allow it to boot.  You will be told your system is mounted under "/mnt/sysimage".
  29. Highlight the "Ok" button, and press enter.  You should have a root command prompt.
  30. Enter a chromed environment :

      chroot /mnt/sysimage

    This will put you at a root prompt in "/", which should be your systems root directory.
  31. Back up the initramfs :

      cp -p /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak

    I know, we don't need one that is missing the requisite modules for boot, but it's always better to be in the habit of backing things up.
  32. Add the sdhci components to the initramfs :

      dracut -f --add-drivers "mmc_core mmc_block sdhci sdhci-pci"

    This will rewrite your initramfs.
  33. Reboot (may need to exit a couple of times to trigger this).
  34. Allow the system to fully boot.
  35. Once the system has booted, edit "/etc/dracut.conf".  Ensure:

      add_drivers+=" mmc_core mmc_block sdhci sdhci-pci "

    This should force future updates to install the kernel modules to the initramfs that you need.
Now, you should be able to do what you want with it!

No comments:

Post a Comment