Introduction: Orange PI HowTo: Set It Up to Use With Car Rearview Display and HDMI to RCA Adapter
It seems like every other one uses large and even larger TV set or monitor with a silly Orange PI board. And it looks like a bit of overkill when intended for embedded systems. Here we need something small and something inexpensive. Like an old portable TV or an LCD display that is used typically in cars to connect to the camera of the rear view. If You are going to use something like that, then any questions that all forums all over there are full of, like "How can I set the the resolution of several thousands to several thousands?" are out of use here. Contrtaversely You will actually be interested in: "How to set the resolution LOW?".
Note also that unlike the old vaccum tube TV sets or those fancy expensive multi mode large computer monitors, the cheap and simple LCD display can usually support one or two different video modes. And if the incoming signal does not match any of them, all You will see is the blank screen. The display may even not deign to show any sign of life if the input signal does not match. It leaves You with a sense that either the display is dead or the Orange is dead, or something went wrong with the adapter...
Step 1: You Will Need:
- A (desktop) computer running Windows with Internet connection;
- An Orange PI board with HDMI connectors. (Most of them have one, but there are some exclusions. Orange PI Zero, for example) and Some 5v power supply to power up the Orange PI;
- A Micro SD(tm) flash card to write down the image of Your PI's operational system. The card should be fairly large. 4Gb is enough, but the larger the better;
- A Car rearview display having RCA composite video input. (Most of the available ones do actually rely on the RCA connectors.);
- An HDMI TO RCA adapter;
- A 12v power supply for the display;
- And of course the cables to connect one with another.
Step 2: Assemble Your Orange PI Based Computer:
Find a reasonable free area on Your table, put there Your Orange PI, the HDMI-to-RCA adapter, the display and the power supply units.
Step 3: Connect the OPI
Connect the Orange PI to the adapter by some HDMI-to-HDMI cable.
Step 4: Connect the Display
Connect the HDMI-to RCA adapter to the display with some RCA-to-RCA cable. Note that the composite video signal goes usually through the YELLOW JACK. The RED jack of the car rearview display is usually used for the 12 volts power supply (You should better ensure this by taking a look into the manual of Your display).
Step 5: Connect the Power Supply
Connect the 5v power supply module to Your Orange PI and 12v power supply module to Your car rearview lcd display. Dont plug the power supplies into the mains yet. (Anyways it is senseless at this stage, due to the Orange PI is not configured properly, so You won't see anything of interest.)
Step 6: Download a Linux Image
Download an image of some suitable operational system and write down this image onto Your Micro SD card. There are lots of guides how to do this correctly. For example You may refer to this instructable:
To my opinion it is better to use some Debian or Ubuntu distribution from the official site (http://www.orangepi.org/downloadresources/) rather than the armbian, because the latter one keeps its configuration file (script.bin) deep in the Linux native ext2 partition and it is diffucult to scavenge it out to Your desktop PC and even more difficult to put it back after the necessary modifications. To write files into Linux partition one needs either a PC running Linux or a virtual PC running Linux. Any kinds of "Windows to ext2fs" readers/writers are kinda "barrel of powder" - You never know when (and why) they will destruct Your filesystem to hell.
They say that one should do the editing of the scipt.bin file directly on the Orange Pi. but... Keep in mind the next factors:
- Your Orange PI has not yet been configured properly and "plays dead", so how one is supposed to use it to correct the script.bin is unknown
- Even if You have connected Your Orange PI to some large and fancy multi mode HDMI monitor, it is still somewhat dangerous to turn on the Orange PI board and load the improperly configured operational system. The reason is that the script.bin is used not only to configure the video resolution and refresh rate, but also to control the processor and memory clock speeds. If set improperly it can cause overheat and possibly damage to Your board. And it WILL most probably BE SET WRONG, because there are many types of the Orange PI boards out there, and the chance that the script.bin from Your particular downloaded image will suit Your particular board is miniscule. The things are even worse due to the fact that most script.bin's out there have already been prepared by overclockers. So keep Your complains in and get ready to edit the script.bin file on Your desktop PC.
Step 7: Plug the SD Card
Use some proper adapter to plug the SD card (with the operational system image having been installed on) to Your desktop PC. Further on I will assume that You are of sound mind and use Windows there. If You have followed my advise and use the image that keeps its script.bin on a FAT partition, You will readily see the disk that contains two (or more) files: script.bin and uImage. The latter one is the Linux boot kernel and it is better to us to let it go.
Step 8: Convert Bin to Fex
Copy the script.bin into some folder on Your desktop PC and convert it into the text (so called "fex") format. For the conversion You will need the conversion utility. Find a properly working copy of fexc.exe for windows or follow my previous instructable Orange PI HowTo: Compile Sunxi Tool for Windows Under Windows
Use "bin2fex" command or directly type:
"fexc -I bin -O fex script.bin script.fex"
in the "dos" prompt and press enter.
(For it to work, You certainly must have the fexc utility in the same folder, where You have copied Your script.bin to. Alternatively You may try to set the PATH environment variable of Your windows to point to where You have installed the fexc.exe. Even more alternatively You may download fexc_install.zip, unpack it to some folder and double click install.bat there. The installer script will create a folder c:\stool\ on Your c: harddisk and place two shortcuts: BIN_TO_FEX and FEX_TO_BIN onto Your desktop. All You need is then to copy Your script.bin file into the c:\stool\ folder and double click the BIN_TO_FEX icon to get the text formatted script.fex file. And after You are done with the editing, just double click FEX_TO_BIN icon to get it back into the binary format. WARNING: If You really feel badly need to reduce to this last resort You might be probably not smart enough to handle Your Orange PC well. It may be better to seek for help out there nearby.)
Finally You should end up with textual script.fex file. Use then any plain text editor to edit it. The everlasting notepad.exe (from Your Windows distribution) or Notepad++ or any editor of any programming IDE will suit. (Dont try to use Arduino IDE for this purposes - it will kick You out complaining that it is not the arduino project. Other IDE's tend to be more liberal.)
Step 9: Prepare Safe Script.fex
Now You should be able to view and edit the script.fex file. (The one You got by decrypting the script.bin). First of all look at the very first section of the file. The section is named [product] and there should be a string containing the key machine and some text value (right to the equality sign) in the quotations. Something like this:
machine = "some machine name"
If the value in the quotations matches EXACTLY Your type of the Orange Pi board, You are probably lucky enough to have a script.bin file that has the correct settings for memory and CPU and You may proceed further to NEXT STEP. Others will need to edit the script.fex file to make it safe.
First of all navigate to the section named [target]. There You will see a key named boot clock being assigned to some value. Kinda that:
[target] boot_clock = 1536
The numeric value right to the equality sign is the CPU frequency in MHz. If it is below 1000 or only sligtly above (e.g. like 1008) You may leave things as is and proceed further. If otherwise like this example the clock is set to ~1500 or even to ~2000 You better downscale it. Or else make sure that Your board is the really mighty fancy high top end of the orange pi series (like Orange Pi Plus, Orange PI Plus 2, Orange PI Prime, Orange PI Ultimate, Orange PI Unlimited, Orange PI REBIRTH and THE RETURN OF THE ORANGE PI...).
Also make sure that not only You have the proper heatsinks, but also they are installed on the Orange PC's chips already.
Another place of interest in the script.fex file will be the [dvfs_table] section. You will see the mindscraping table of cpu frequencies there. Here the frequencies are measured in Hz, so you'd like that 9-digit numbers. Once again if Your view is not distorted by very high numbers (like max_freq = 1536000000 and above) of if You have a top end board You can proceed further. Otherwise You should downscale the values. Where to get the correct ones? I suggest to copy-paste them from the: http://www.sunxi.org/Fex_Guide
For Your convinience I've copy-pasted them to here:
max_freq = 1008000000 min_freq = 60000000 lv_count = 5 lv1_freq = 1056000000 lv1_volt = 1500 lv2_freq = 1008000000 lv2_volt = 1400 lv3_freq = 912000000 lv3_volt = 1350 lv4_freq = 864000000 lv4_volt = 1300 lv5_freq = 624000000 lv5_volt = 1250
Those are certainly safe but somewhat brakish values. However You may always try to increase them in future.
And finally [dram_para] section. Here we have dram clock speed in MHz in the form of a dram_clk parameter. Sunxi Fex Guide suggests to set dram_clk = 360 here. However for the recent boards it seems to be too low. Use some value near 600 here. Like
dram_clk = 624
dram_clk = 576
Everyone there seeks for higher computing power, but still don't omit the step of downscaling the frequencies to the safe values. You might be able to understand what I am speaking about, when Your Linux begins to loose its files just in the process of simple copying them from one place to another.
Step 10: Configure Display Parameters
Finally we've got to the settings of the screen parameters. In Your script.fex file find the [boot_disp] section... And delete it as a whole section. This is due to this section is used only to display some advertisment banner during the Orange PI boot process. And since we are not going to use this feature it stays only as a source of additional possible glitches (like sticky resolution etc...)
And the section of interest will be the [disp_init]. It should be like this:
[disp_init]<br>disp_init_enable = 1 disp_mode = 0 screen0_output_type = 3 screen0_output_mode = 3 screen1_output_type = 3 screen1_output_mode = 3 fb0_format = 0 fb0_width = 0 fb0_height = 0 fb1_format = 0 fb1_width = 0 fb1_height = 0 fb0_framebuffer_num = 2
Copy it from here and paste into Your script.fex if You want. Note that the screen output type has to be 3 (hdmi) and screen output mode needs to be 3 ( 720 x 576 non interlaced ). Its a good place to note that this setting IS HARDWARE DEPENDENT. It means that if You have, say, HDMI-to-VGA adapter (not HDMI-to-RCA/TV) the necessary output mode may be another. You can try other modes to see if they suit better. Here's the time when You'll bless the fact You can edit the configuration file on Your desktop PC, not on the Orange PI being configured.
Another essential thing to do is to turn off the hdmi encryption. Find (or create) [hdmi_para] section and add the next strings:
hdcp_enable = 0
hdmi_cts_compatibility = 1
The whole section will look like:
hdmi_used = 1 hdmi_power = "vcc-hdmi-18" hdcp_enable = 0 hdmi_cts_compatibility = 1
And yet again You can copy and paste it from here to Your script.fex file.
Step 11: Done Editing Fex
We've finished with script.fex, so save it to Your hard disk and exit the text editing software.
Use fex2bin.bat (or the FEX_TO_BIN shortcut on Your desktop) to pack the file back to the binary format. Remember that script.bin usually has "read only" attribute and the fexc utility can not overwrite it authomatically. (I fixed this in the distribution for the very amateurs - the one that uses desktop shortcuts. Others should be just less forgetful.)
Step 12: Run You OPI
Finally we got our new and fresh sparkling script.bin file, so its time to copy it onto the Orange PC's bootable SD card. Insert it into Your Orange PI slot (Dont forget to click the "safe remove media" in Your Windows tray before taking the card out.)
Plug the 12v power supply into the mains to turn the car rearview display on. Do the same with 5v power supply to turn on the Orange PI. And now You can see /*dead people*/ messages from the booting Linux on Your display.
One could stop here. But somebody might be not satisfied enough by the fact that the image might not fit the screen exactly. Some part of it (near the borders) may not be seen on the display. So the final stage will be the screen adjustment.
Step 13: Adjust Right-bottom Ends of Screen
It's a pity, but fbset an alike Linux utilities... Well I cannot say, they're not working... When You're doing something completely wrong, You'll instantly end up with a corrupt screen. But while You stay in limits of reasonable changes it seems that the system of Orange Pi + HDMI to RCA Adapter + TV display behaves like it's all the same for it. So the best and proven method of setting the screen borders is out of play here.
However it's still early to give up. First of all it's rather easy to get out the rightmost and bottom most ends of screen. To do so one can use the proven approach of modifying the script.bin.
Yet again refer to the [disp_init] section. For 4.3 inch display You can use the next text:
[disp_init] disp_init_enable = 1 disp_mode = 0 screen0_output_type = 3 screen0_output_mode = 3 screen1_output_type = 3 screen1_output_mode = 3 fb0_format = 10 fb0_width = 704 fb0_height = 544 fb1_format = 10 fb1_width = 704 fb1_height = 544
For other dimensions You can try to increase/decrease vertical/horizontal resolution settings. Keep in mind however, that the numbers must be multiple of sixteen (maybe 8 actually). So dont type arbitrary values there. Start from the known ones (fb0_width = 720 and fb0_height = 576) and begin to subtract 16. I.e
fb0_width = 704 -OR- fb0_width = 720 fb0_height = 576 fb0_height = 560
Step 14: Adjust Start Menu Size
At some point You'll be able to see the right bottom border of the screen image correctly. Things are not so rainbow-like with the upper left corner. I Can only suggest to adjust Your Xorg settings. In "Debian XFCE 0.9.1" navigate to settings->panel and set increase the width and reduce the length of the start menu.
Step 15: Adjust Workspaces
Then go to Settings->workspaces and use "borders" tab to set up the screen borders. It will limit the sizes of windows of the newly launched applications to the screen area bordered by Your settings. However it is not the panacea. From time to time the applications WILL TRY to escape out of that borders (and will certainly succeed). To calm You down I can say that You're not loosing too much. Even with properly set 5" 800 x 480 TFT monitor many of the Orange PI Linux graphical applications are still unusable (QT creator especially).
We have a be nice policy.
Please be positive and constructive.