Friday, October 23, 2015

Installing Linux .img files on the Orange Pi PC
I had to dig around for this information and I did a little trial and error to figure it out but I got a working version of Linux on the $15 Orange Pi - PC.

The first place you need to look is:   Orange Pi Forums - Thread on Installing .img files

Orange Pi PCThis thread will answer 90% of your questions because forum moderator Loboris knows his stuff.

He has good instructions but I am not the most proficient Linux user in the world, so I needed a little extra help. I hope this helps someone else like me that is not proficient at the command line.

I am going to assume you have a  Linux computer with a GUI like Gnome or KDE, LXDE, Etc.

Step 1.
Create a folder on your PC where you can store some files that you will download. I just put my folder on the desktop. I created a folder called opi

Step 2.
Download any of the available distro images (xz archive) from the Mega or GoogleDrive sites Loboris has listed.

You have lots of options: Debian, Arch, OpenSuse, Ubuntu, Fedora, Etc. I downloaded OrangePI_Lubuntu_Vivid.img.xz

Step 3.
Download scriptbin_kernel.tar.gz, it contains the latest Linux kernel (uImage) and script.bin.

Step 4.
Navigate to the folder you created and unpack, unzip, uncompressed, extract or whatever you want to call it BOTH files you just downloaded. Most modern versions of Linux let you right click on a file and extract it. I used the Engrandpa archive manger that come with the Mate desktop but yours may be called Ark, File Roller, Etc.

Step 5.
Open a terminal program like Xterm so we can get to the command line. The first command we need to run is df -h to see what devices are currently mounted.

Step 6.
If your computer has a slot for SD cards, insert the card. If not, insert the card into an SD card reader, then connect the reader to your computer

Step 7.
Run df -h again. The new device that has appeared is your SD card. The left column gives the device name of your SD card; it will be listed as something like /dev/mmcblk0p1 or /dev/sdd1. The last part (p1 or 1 respectively) is the partition number but you want to write to the whole SD card, not just one partition. Therefore you need to remove that part from the name (getting, for example, /dev/mmcblk0 or /dev/sdd) as the device for the whole SD card. This will be important in step 10.

Step 8.
Now that you've noted what the device name is, you need to unmount the SD card so that files can't be read or written to the SD card while you are copying over the SD image. Run umount /dev/sdd1, replacing sdd1 with whatever your SD card's device name is (including the partition number).

Step 9. - The hard part
In the terminal, write the image to the SD card with the command below, making sure you replace the input file if= argument with the path to your .img file, and the /dev/sdd in the output file of= argument with the right device name. This is very important, as you will lose all data on the hard drive if you provide the wrong device name. Make sure the device name is the name of the whole SD card as described above, not just a partition of it; for example sdd, not sdds1 or sddp1; or mmcblk0, not mmcblk0p1. 

Now for the command:  
sudo dd if=OrangePI_Lubuntu_Vivid.img of=/dev/sdd bs=1M oflag=direct

I ended up using this based on where my files were located and the name of my SD card:

sudo dd if=/home/john/Desktop/opi/OrangePI_Lubuntu_Vivid.img of=/dev/mmcblk0 bs=1M oflag=direct

Go get a cup of tea / coffee and a snack. This could take several minutes.

Step 10. - downhill from here
Run command  sync in the terminal, this will ensure the write cache is flushed and that it is safe to unmount your SD card. You can close the terminal program now.

Step 11.
I used a graphical file manger for the rest of the steps. Open up your graphical file manager and then physically remove the SD card from the computer and then reinstall it in the SD slot. You should see the SD card appear in the graphical file manager. Right click it and mount the SD card. You should see two items now. One partition called BOOT and the other partition called Linux. If you do not see this you may want to remove the SD card and try again.

Step 12.
In the graphical file manger double click on the BOOT partition. When you do, you should see a bunch of files. We are only interested in two files: script.bin and ulmage. Rename both files. I renamed them script.bin.default and ulmage.default

Step 13.
Remember that folder you created on your computer at the beginning of this little project and downloaded the two files to which you extracted? Navigate to that folder.

Step 14. 
Find the file uImage_OPI-2 or uImage_OPI-PLUS (depending on the type of Orange Pi you have ) and rename it to uImage (The Orange Pi-PC use uImage_OPI-2)

Step 15. 
Determine the resolution and refresh rate of the monitor you will connect your Orange Pi to. You may also want to figure out how you will supply the video feed to the monitor. I am using a TV with a resolution of 1080p with a 60Hz refresh rate. I also wanted to use the HDMI cable.

Step 16. 
In the folder you created on your PC, find a script.bin.OPI-XXXX file that best matches your version of Orange Pi and monitor setup. For my Orange Pi PC and the TV I was going to use as a monitor, the best file was script.bin.OPI-PC_1080p60_hdmi. After you find the best file rename it to script.bin

Step 17. 
Copy the the two files you just renamed to ulmage and script.bin and paste them into the BOOT partition. Unmount and safely remove the SD card from your computer.

Step 18. Install the SD Card into the Orange Pi and boot into your new system! The username and password are: orangepi

Step 19.
Resize the Orange Pi partition to fit your SD Card size by using the following command in a terminal: sudo fs_resize After running this command you will be prompted to reboot.

Step 20.
After rebooting it is a good idea to update all system package with the package manger

Step 21.
Have Fun!