ILI9341 on clean NanoPi Neo Air

Obtain latest Armbian

Download it from official site.

We use Armbian Stretch with mainline kernel 4.14.y.

Unpack it and you’ll have Armbian_5.59_Nanopiair_Debian_stretch_next_4.14.65.img.

Prepare microSD card

MicroSD card with 8GB will do the job. See recommended cards here on NanoPi Neo Air wiki; more armbian-related info on Armbian documentation page.

Better way to do it with Etcher on all platforms since unlike other tools Etcher validates burning results saving you from corrupted SD card contents. Download it, unpack and run by double-click.

First boot

Insert microSD card into NanoPi. We are using cp210x (USB to UART) converter connected as on this picture:

http://wiki.friendlyarm.com/wiki/index.php/File:USB2UART-NEO2.jpg

To see what tty is your USB to UART connector, connect it to any empty USB and see

dmesg | tail | grep 'cp21.*tty'

in my case it was usb 1-2: cp210x converter now attached to ttyUSB0

Easiest way to connect to it is by using application tio (apt install tio is you have no this app):

tio /dev/ttyUSB0

and this command will be quite silent until you plug your NanoPi.

If you’ve got connected your NanoPi with cp21x via dupont cables – you have one additional feature – ease of “hard”-rebooting of your NanoPi. All you need to do is to unplug +5V or GND dupont and plug it back again.

NanoPi Neo Air will power up.

Default login is root, password is 1234. System will guide you to change it and to create new sudoer-user to use it in your system.

Setup Wi-Fi

You can use UI tool nmtui-connect to setup wifi. If you know your SSID you can do this: nmtui-connect YOUR_SSID.


Another set of tools is nmcli:

  • nmcli radio – to see radio interfaces
  • nmcli device wifi rescan – do wifi rescan rescan
  • nmcli device wifi list – show list of available networks
  • nmcli device wifi connect SSID_NAME password WIRELESS_PASSWORD_HERE – to actually connect to network

Establish quick SSH access

If you have stable working environmant like in your home or in office, we’d recommend to do next:

  • Give your NanoPi static IP (you can do it in your wifi router admin page).

  • Add your NanoPi IP into your host machine’s /etc/hosts like: 192.168.1.103 nano.pi. Even on that stage you’ll be able to connect to your NanoPi this way: ssh pi@nano.pi.

  • Hope you do already have ssh-rsa key (to check it see if there is anything here cat ~/.ssh/id_rsa.pub), if you have no key – do it as it is described on GitHub documentation.

  • From your host computer do: ssh-copy-id pi@nano.pi.

    iAs a result you’ll be able to connect to your NanoPi via simple command ssh pi@nano.pi using your ssh credentials. If you do not want to enter your passphrase each time, just do this: ssh-add a

Avoid locale settings problems

If you got locale unset problems, like:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "en_US.UTF-8",
    LC_ALL = (unset),
    LC_MONETARY = "uk_UA.UTF-8",
    LC_ADDRESS = "uk_UA.UTF-8",
    LC_TELEPHONE = "uk_UA.UTF-8",
    LC_MESSAGES = "en_US.UTF-8",
    LC_NAME = "uk_UA.UTF-8",
    LC_MEASUREMENT = "uk_UA.UTF-8",
    LC_IDENTIFICATION = "uk_UA.UTF-8",
    LC_NUMERIC = "uk_UA.UTF-8",
    LC_PAPER = "uk_UA.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_ALL to default locale: No such file or directory

You can avoid it by doing next:

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
sudo locale-gen en_US.UTF-8
sudo dpkg-reconfigure locales

And check if everything is Ok by running simple command locale.

Connect ILI9341-based display to NanoPi

Wiring

Here are ours wiring:

Display pin name Linux GPIO pin number NanoPi Neo Air pin number
BL, LED 200 16
SCK, SCLK, CLK 66 23
MISO 65 21
MOSI 64 19
CS 67 24
RST 1 22
DC 201 18

See “GPIO Pin Description” on NanoPi Neo Air Wiki for reference.

Edit /boot/armbianEnv.txt

We need to enable SPI, to do it open /boot/armbianEnv.txt for editing,

sudo nano /boot/armbianEnv.txt

Ensure that spi-spidev is included in line overlays. Add additional spidev params as follows:

...
overlay_prefix=sun8i-h3
overlays=i2c0 spi-spidev usbhost0
param_spidev_spi_bus=0
param_spidev_spi_cs=0
...

Load respective kernel modules on startup

modprobe.d

Create file fbtft.conf in /etc/modprobe.d with next contents:

options fbtft_device custom modprobe fbtft_device custom name=fb_ili9341  gpios=reset:1,dc:201,led:200 speed=16000000 rotate=90 bgr=1

modules-load.d

Create file fbtft.conf in modules-load.d with next contents:

spidev
fbtft_device

Do reboot and here you go!

Alt Text


In case of success you’ll see something like this in your dmesg:

$ dmesg | grep fb
[    0.000000] Kernel command line: root=UUID=fcb47c3b-35d1-49c5-9993-e9618014eb1b rootwait rootfstype=ext4 console=tty1 console=ttyS0,115200 hdmi.audio=EDID:0 disp.screen0_output_mode=1920x1080p60 panic=10 consoleblank=0 loglevel=1 ubootpart=0b0b6b1e-01 ubootsource=mmc usb-storage.quirks=0x2537:0x1066:u,0x2537:0x1068:u   sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_fb_mem_reserve=16 cgroup_enable=memory swapaccount=1
[    4.462109] fbtft: module is from the staging directory, the quality is unknown, you have been warned.
[    4.466877] fbtft_device: module is from the staging directory, the quality is unknown, you have been warned.
[    4.467622] fbtft_device: unknown parameter 'modprobe' ignored
[    4.467632] fbtft_device: unknown parameter 'fbtft_device' ignored
[    4.468717] fbtft_device: GPIOS used by 'fb_ili9341':
[    4.468728] fbtft_device: 'reset' = GPIO1
[    4.468732] fbtft_device: 'dc' = GPIO201
[    4.468735] fbtft_device: 'led' = GPIO200
[    4.468746] spi spi0.0: fb_ili9341 spi0.0 16000kHz 8 bits mode=0x00
[    5.051105] fb_ili9341: module is from the staging directory, the quality is unknown, you have been warned.
[    5.412314] graphics fb0: fb_ili9341 frame buffer, 320x240, 150 KiB video memory, 16 KiB buffer memory, fps=20, spi0.0 at 16 MHz
comments powered by Disqus