doc:appunti:hardware:x96_mini
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
doc:appunti:hardware:x96_mini [2022/01/28 10:33] – [Configure the remote control] niccolo | doc:appunti:hardware:x96_mini [2023/10/22 23:32] (current) – [Ports and connectors] niccolo | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
+ | **How to install Kodi on the X96 mini TV Box** | ||
+ | |||
+ | {{ .: | ||
I bought this little device for about 27 EUR in January 2022 from Aliexpress, I wish to use it as a TV Box, getting media from the LAN or from an external hard disk atthached via USB. It is based on the **Amlogic S905W** chip, equipped with **1 Gb** of **RAM** and **16 Gb** of **flash** storage. | I bought this little device for about 27 EUR in January 2022 from Aliexpress, I wish to use it as a TV Box, getting media from the LAN or from an external hard disk atthached via USB. It is based on the **Amlogic S905W** chip, equipped with **1 Gb** of **RAM** and **16 Gb** of **flash** storage. | ||
Line 7: | Line 10: | ||
It seems that the best combination of **Kodi** and **GNU/ | It seems that the best combination of **Kodi** and **GNU/ | ||
- | From the download section I selected | + | ===== Download the appropriate version of CoreELEC ===== |
+ | |||
+ | From the download section I selected | ||
^ Device | ^ Device | ||
Line 21: | Line 26: | ||
- Copy the image over an SD card using the Linux command line tool **dd**: < | - Copy the image over an SD card using the Linux command line tool **dd**: < | ||
- Mount the first partition on the SD card and copy the file **device_trees/ | - Mount the first partition on the SD card and copy the file **device_trees/ | ||
+ | |||
+ | ====== Ports and connectors ====== | ||
+ | |||
+ | {{.: | ||
+ | {{.: | ||
+ | |||
+ | One USB port is **white** in color, so it should be an **USB 1.x**, the **black** USB port should be instead an **USB 2.0 Hi-Speed**. But measuring the read/write performance of an USB external disk, it turned out that both the ports are 2.0 Hi-Speed. | ||
+ | |||
====== First boot using the toothpick trick ====== | ====== First boot using the toothpick trick ====== | ||
Line 34: | Line 47: | ||
====== Configure the remote control ====== | ====== Configure the remote control ====== | ||
- | The remote control provided with my device **does not work out-of-the-box** in CoreELEC. I created a custom remote control keymap | + | The remote control provided with my device **does not work out-of-the-box** in CoreELEC. I created a custom remote control keymap |
- | Connect to the CoreELEC box using **SSH** and stop kodi and infra-red | + | Connect to the CoreELEC box via **SSH** and stop the Kodi and LIRC (Linux Infrared Remote Control) |
< | < | ||
Line 43: | Line 56: | ||
</ | </ | ||
- | To check if the remote is generating some events detected by the GNU/ | + | Check if the remote is generating some events detected by the GNU/ |
< | < | ||
Line 67: | Line 80: | ||
</ | </ | ||
- | The buttons that I mapped | + | Now it is possible to **create a map** from **scancodes** to **button names**; I created the file **/ |
< | < | ||
- | KEY_0 | + | # table X96MINI_KODI, |
- | ... | + | 0x140 KEY_POWER |
- | KEY_9 | + | 0x144 KEY_VIDEO |
- | KEY_LEFT | + | # Media center keys |
- | KEY_RIGHT | + | 0x155 KEY_PREVIOUS |
- | KEY_UP | + | 0x15a KEY_PLAYPAUSE |
- | KEY_DOWN | + | 0x152 KEY_STOP |
- | KEY_ENTER | + | 0x154 KEY_NEXT |
- | KEY_ESC | + | # Color buttons |
- | KEY_MUTE | + | 0x143 KEY_RED |
- | KEY_BACKSPACE | + | 0x10f KEY_GREEN |
- | KEY_VOLUMEDOWN | + | 0x110 KEY_VOLUMEDOWN |
- | KEY_VOLUMEUP | + | 0x118 KEY_VOLUMEUP |
+ | # Arrows keypad | ||
+ | 0x151 KEY_LEFT | ||
+ | 0x150 KEY_RIGHT | ||
+ | 0x116 KEY_UP | ||
+ | 0x11a KEY_DOWN | ||
+ | 0x113 KEY_ENTER | ||
+ | # Extra buttons | ||
+ | 0x111 KEY_HOME | ||
+ | 0x119 KEY_ESC | ||
+ | 0x14c KEY_CONTEXT_MENU | ||
+ | 0x100 KEY_INFO | ||
+ | # Numeric keypad | ||
+ | 0x101 KEY_0 | ||
+ | 0x14e KEY_1 | ||
+ | 0x10d KEY_2 | ||
+ | 0x10c KEY_3 | ||
+ | 0x14a KEY_4 | ||
+ | 0x109 KEY_5 | ||
+ | 0x108 KEY_6 | ||
+ | 0x146 KEY_7 | ||
+ | 0x105 KEY_8 | ||
+ | 0x104 KEY_9 | ||
+ | 0x141 KEY_MUTE | ||
+ | 0x142 KEY_TEXT | ||
+ | </ | ||
+ | |||
+ | This table must be listed into the file **/ | ||
+ | |||
+ | < | ||
+ | # driver | ||
+ | meson-ir | ||
</ | </ | ||
Line 91: | Line 135: | ||
</ | </ | ||
- | You can verify that the key name is associated witht the scancode, e.g. pressing the left key you should get: | + | Using **ir-keytable** again, you can verify that the key name is now associated witht the scancode, e.g. pressing the left key you should get: |
< | < | ||
Line 106: | Line 150: | ||
9641.948038: | 9641.948038: | ||
9641.948038: | 9641.948038: | ||
+ | </ | ||
+ | |||
+ | Finally you can restart LIRC and Kodi services: | ||
+ | |||
+ | < | ||
+ | systemctl start eventlircd | ||
+ | systemctl start kodi | ||
+ | </ | ||
+ | |||
+ | Every key on my remote was properly mapped from a LIRC button name to a Kodi action, except the **backpasce** key (scancode 0x142). The problem is that Kodi LIRC map convert the **KEY_BACKSPACE** into the **back** action, which is the same as **KEY_ESC**. See the file **/ | ||
+ | |||
+ | So I decided to associate the scancode 0x142 to the unused **KEY_TEXT** button, which in turn is associated to the **teletex** LIRC event. Then I created a custom Kodi remote keymap, to associate that remote event to the **Backspace** Kodi action. This is the file **/ | ||
+ | |||
+ | <code xml> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
</ | </ | ||
* **[[https:// | * **[[https:// | ||
+ | |||
+ | ====== Change SSH password and enable RSA keys ====== | ||
+ | |||
+ | From Kodi interface, **Settings** => **CoreELEC** => **Services** there is the **SSH** section, where you can change password or disable password logins if you have copied RSA keys into **/ | ||
+ | |||
+ | To configure the SSH service you cannot edit the files into **/ | ||
+ | |||
+ | You can also customize the systemd service unit, just copy the system file and edit it: | ||
+ | |||
+ | < | ||
+ | cp / | ||
+ | vi / | ||
+ | </ | ||
+ | |||
+ | Shadow password (if changed) cannot be saved into / | ||
+ | |||
+ | ====== Enable crontab ====== | ||
+ | |||
+ | From Kodi interface, **Settings** => **CoreELEC** => **Services** check **Enable Cron**. | ||
+ | |||
+ | Then connect via SSH and create a directory where to store the scripts to be executed via cron, e.g. **/ | ||
+ | |||
+ | < | ||
+ | */10 * * * * / | ||
+ | </ | ||
+ | |||
+ | The users' crontabs are saved into the **/ | ||
+ | |||
+ | ====== Backup of library and configuration ====== | ||
+ | |||
+ | From Kodi interface, **Settings** => **CoreELEC** => **System** => **Backup** there is the **Create System and Kodi Backup** item. With this you can create an archive containing all the CoreELEC settings and the Kodi library, including the thumbnails directory. The archive file will be stored into **/ | ||
+ | |||
+ | The file is a **tar archive** of the following directories: | ||
+ | |||
+ | * / | ||
+ | * / | ||
+ | * / | ||
+ | * / | ||
+ | |||
+ | ====== Installing extra software with Entware ====== | ||
+ | |||
+ | **[[https:// | ||
+ | |||
+ | The architecture of the X96 Mini is **aarch64** as revealed by the command **uname -m** and the kernel is a **Linux 4.9** as revealed by **uname -a**. The **[[http:// | ||
+ | |||
+ | The **CoreELEC** distribution does not inlcue any package manager, so we have to download and unpack the **Entware** packages manually. All the Entware software is packed to be installed into the **/opt/** hiearchy, which in CoreELEC is a symlink to the **/ | ||
+ | |||
+ | In this example we want to install the **base64** utility which we need to send some archives via an http connection. First of all we dowloaded the **libc_2.27-11_aarch64-3.10.ipk**, | ||
+ | **coreutils-base64_9.1-1_aarch64-3.10.ipk** package. | ||
+ | |||
+ | Some packages requires a **postinst** script to be run in order to initialize some configuration files, the file is contained into the **control.tar.gz** archive. E.g. the **terminfo** package - which is required to run most of the fullscreen tools, with colors and cursors, like the Midnigth Commander - initializes the **/ | ||
+ | |||
+ | < | ||
+ | export TERMINFO=/ | ||
+ | </ | ||
+ | |||
+ | Finally you have to adjust your **PATH** and eventually the **LD_LIBRARY_PATH** environment variables to take into account the path of the newly installed binay packages. I added the following into my **/ | ||
+ | |||
+ | < | ||
+ | PATH='/ | ||
+ | LD_LIBRARY_PATH='/ | ||
+ | </ | ||
+ | |||
+ | ====== Connecting a 2.5" hard disk via the USB ====== | ||
+ | |||
+ | I connected an **external hard disk**; specifically it is a Toshiba MQ04UBF100, 2.5 inches hard drive, SATA 3.0, **1 Tb**, using an **USB 3.0** interface. | ||
+ | |||
+ | At first I tried to power the hard disk directly from the USB port of the X96 mini, but it turned out that the USB port **does not provide enough power**. The hard disk suddendly and randomly **disconnect and re-connect** with no reason. Here it is the relevant kernel messages displayed by the **dmesg** tool: | ||
+ | |||
+ | < | ||
+ | [ 526.677574@2]- usb 1-2: USB disconnect, device number 2 | ||
+ | [ 526.678631@2]- blk_update_request: | ||
+ | ... | ||
+ | [ 526.942573@3]- EXT4-fs error (device sda1): ext4_journal_check_start: | ||
+ | [ 526.942578@3]- EXT4-fs (sda1): Remounting filesystem read-only | ||
+ | [ 526.942585@3]- EXT4-fs (sda1): previous I/O error to superblock detected | ||
+ | [ 526.942612@3]d Buffer I/O error on dev sda1, logical block 0, lost sync page write | ||
+ | [ 526.983449@2]- sd 0:0:0:0: [sda] Synchronizing SCSI cache | ||
+ | [ 526.997855@2]- sd 0:0:0:0: [sda] Synchronize Cache(10) failed: Result: hostbyte=DID_NO_CONNECT driverbyte=DRIVER_OK | ||
+ | [ 527.796877@2]- usb 1-2: new high-speed USB device number 4 using xhci-hcd | ||
+ | [ 527.938266@2]- usb 1-2: New USB device found, idVendor=0480, | ||
+ | [ 527.938278@2]- usb 1-2: New USB device strings: Mfr=2, Product=3, SerialNumber=1 | ||
+ | [ 527.938282@2]- usb 1-2: Product: External USB 3.0 | ||
+ | </ | ||
+ | |||
+ | Typically a 2.5" drive requires about **1 A** at startup and about **500 mA** at read/write average. It is likely that the X96 Mini's circuitry provides USB ports with barely the minimum required by the USB 2.0 standard, which is **5 V, 500 mA**, regardless the rating of the power supply (mine was rated 4A). | ||
+ | |||
+ | Fortunately there is a solution: to use an **externally powered USB hub**. I purchased a **4 ports USB 3.0 hub** with an USB Type-C connector to supply it with power. In this new configuration a **3 A** power supply provides the power to the USB hub. The external hard disk is connected to one of the 4 ports of the hub and it takes its power from this. The X96 Mini is connected to the hub cable through the USB A connector and it takes the power from the hub too. The original power supply is not longer required and **all the system is powered by only one power supply**. | ||
+ | |||
+ | I measured the disk performance on both the two USB ports (the white one and the black one), they measured exactly the same transfer rate. For the test I used the **hdparm** tool: | ||
+ | |||
+ | < | ||
+ | hdparm -t /dev/sda | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | Timing buffered disk reads: 102 MB in 3.03 seconds = 33.71 MB/sec | ||
+ | </ | ||
+ | |||
+ | This is about **270 Mbit/s**, which is near the 280 Mbps of the USB 2.0 //High Speed// specifications. This means that both the USB ports are actually USB 2.0. | ||
doc/appunti/hardware/x96_mini.txt · Last modified: 2023/10/22 23:32 by niccolo