Open Source Solution: V3S-PI – Portable Terminal Based on Allwinner V3S

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

Project Name: V3S-PI Portable Terminal Based on Allwinner V3S

Author: FanHuaCloud

Introduction

To master a skill, one must practice.

The author wanted to learn Linux, so they learned while doing and successfully open-sourced a——rather good four-layer board design terminal device.

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

The project cost can be compressed to under 100 yuan, making it easy to replicate and learn from!

01Open Source Project Description
Open Source Project Description

Created a portable terminal based on the V3S chip, named V3S-PI.

It has 9 functions——fetching weather, connecting headphones to play music, 10M/100M Ethernet interface, connecting to Wi-Fi, accessing SD cards, adjusting screen brightness, button control, connecting other devices, and 1-to-4 USB HUB.

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

Next, I will share its——chip characteristics, project features, software open sourcehardware open sourcesoftware solution、open source URL.

02Allwinner V3S Chip Characteristics
1

The processor integrates a single ARM Cortex-A7 CPU, running at 1.2GHz, supporting numerous peripheral devices.

2

512Mbt DDR2 is highly integrated in V3.

3

SPINAND/NOR flash, SD/MMC has external memory interfaces.

4

Supports video engine, formats such as: 720P @ 60FPS, H.264 decoder, 1080p.

5

Can meet the needs of automotive digital video recording (DVR) and IP camera (IPC) monitoring systems.

03Project Features
1

Allwinner V3S main control, using single-core Cortex-A7 with hardware floating point.

2

The chip has 64Mbyte DDR2 built-in, no need for external DDR2 chip.

3

Supports RTL8723BS 2.4G WIFI (SDIO interface).

4

Expands dual USB ports through CH334R.

5

The headphone interface uses the built-in sound card of V3S.

6

Supports 10M/100M Ethernet interface.

7

Supports SDMMC interface for system boot.

8

Supports CH340N serial to USB for connecting serial terminals.

9

Supports LRADC, four ADC keys (not yet debugged).

10

2.4-inch LCD color screen, uses SPI interface.

11

2×8 expansion interface for expanding I2C/UART.

04Software Open Source
Software Open Source

Based on the current online materials, the author has ported the mainline kernel Uboot and root.Currently only supports SD card and SPI Nor boot, please do not refer to the current code for SPI Nand boot.

①UBoot

Quick Start

git clone https://gitee.com/fhcloud/uboot-v3scd uboot-v3smake v3s_pi_defconfigmake

The output file is in the source root directory u-boot-sunxi-with-spl.bin

②Linux

Quick Start

git clone https://gitee.com/fhcloud/linux-v3scd linux-v3smake v3s_pi_defconfigmake

The output kernel file is in arch/arm/boot/zImage

The output device tree should use arch/arm/boot/dts/sun8i-v3s-pi.dtb

③Buildroot

Quick Start

git clone https://gitee.com/fhcloud/buildroot-v3s.gitcd buildroot-v3smake v3s_pi_defconfigmake

The output file is in output/images/rootfs.tar

Test image account root, password 123456

05Hardware Open Source

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

Hardware adopts a four-layer board design, and below I will split the circuit into 11 parts and explain them one by one.

Main Control Part

The main control of this project uses Allwinner V3S, and it should be noted that R3/R5 resistors should use 1%, and there are two sets of voltages for EPHY.

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

Figure 1 Main Control Schematic

②ADC Keys

The board has four ADC keys, with a voltage span of 0.2V, implemented through voltage divider resistors.

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

Figure 2 ADC Keys

③2×16 PIN Expansion Interface

This is achieved through pin headers, leading out 8 expansion interfaces, including a serial port/a I2C bus, which can be used for connecting other devices.

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

Figure 3 Expansion Interface

④Auxiliary Power Supply

The board has four power supply chips that generate 3.0V, 3.3V, 1.8V, 1.2V, among which

  • 3.0V is used for PLL and AVCC analog power supply
  • 3.3V is responsible for chip IO and other peripheral power supply
  • 1.8V is used for memory power supply
  • 1.2V is used for V3S core main control power supply.

Three paths of DCDC have a maximum output current of 2A.

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

Figure 4 Auxiliary Power Supply

⑤WIFI Module

The board has a 2.4G WIFI module, using the RTL8723BS module, and the connection between V3S and the WIFI module isvia SDIO interface, leading out one IPEX interface for external antenna, R20-R27 are pull-up resistors required by SDIO and the chip, C50/C51/C70 are peripheral filter capacitors, and the module uses 3.3V power supply.

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

Figure 5 WIFI Module Schematic

⑥10M/100M Ethernet Interface

Fast Ethernet requires the use of two sets of differential pairs, RX/TX differential respectively.Ethernet PHY generally has automatic flip function, so RX/TX can be swapped.The V3S Ethernet uses voltage drive, just need to add a 100NF capacitor to ground at the center tap of the transformer on the network port.

The internal packaged resistors and 2KV capacitors are used to discharge the motherboard’s static electricity, preventing high voltage from damaging the main control chip.

R28/R29 are LED current limiting resistors, SH1 SH2 are the shell, which can be directly grounded.

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

Figure 6 Ethernet Interface Schematic

⑦2.4-inch LCD Color Screen

The 2.4-inch color screen communicates with the main control via SPI.

  • PE8 connects to the color screen reset line
  • PE9 connects to DC

Used to distinguish data/instruction.

LEDA is the backlight anode, LEDK connects to Q1 MOS, used for main control to control backlight switch.

The screen is soldered onto the PCB.

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

Figure 7 2.4-inch LCD Screen Schematic

⑧CH340 Serial to USB

Using the CH340N chip, achieving serial to USB, for computer connection to the terminal.

R30/R31 are used to ensure that the dual-headed TYPEC cable powers normally, D1 is a TVS, to protect the USB interface, since this part uses 3.3V power supply, CH340N’s VCC and V3 need to be connected together, and add 100nf capacitor.

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

Figure 8 CH340 Serial to USB

⑨CH334R 1-to-4 USB HUB

Through the CH334R chip, achieving one to four USB Host ports.

This part uses unified power supply, so VDD33 and V5 can be connected together.

  • XI XO input 12Mhz crystal oscillator
  • DPU/DMU connects to upstream USB port

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

Figure 9 CH334R Schematic

⑩Headphone Interface

The headphone interface uses PJ-342 interface, with audio and recording:

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

Figure 10 PJ-342 Headphone Interface

⑪SD Card Interface

The SD card interface is used for inserting MicroSD cards.

R32-R36 are pull-up resistors for the SD card, and here CLK does not need to be pulled up, otherwise it may affect SDIO communication.

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

Figure 11 SD Card Interface

06Software Solution
Software Solution

The software solution mainly covers these 8 parts

——Linux kernel, 2.4-inch LCD color screen driver, USB, Ethernet, wireless network card RTL8723BS, ADC keys, audio playback, libcurl.

①Linux Kernel

The kernel uses Linux 5.15.143 mainline kernel, on which some code has been modified to adapt to most peripherals of V3S.

②2.4-inch LCD Color Screen Driver

The LCD color screen connects to the main control via SPI.

  • Software part uses TinyDRM, compared to traditional fbtft, it is no longer fixed frame rate refresh.
  • Uses DRM architecture, which can integrate with new architecture programs faster.

Since each manufacturer’s screen initialization code is different, we only need to modify the code in the st7735r_pipe_enable function based on the original st7735r.c file.

The modified code can be referenced in the file below, device tree configuration reference:

&spi0 {       status = "okay";       pinctrl-names = "default";       pinctrl-0 = <&spi0_pins>;

       display@0 {        compatible = "jianda,jd-t18003-t01";        reg = <0>;           spi-max-frequency = <95000000>;

        backlight = <&panel_backlight>;        dc-gpios = <&pio 4 9 0>; // PE9        reset-gpios = <&pio 4 8 0>; // PE8        rotation = <0>;    };};

In addition to SPI, a backlight node needs to be added, so that the backlight can be operated in the user layer:

panel_backlight: panel-backlight {              compatible = "gpio-backlight";        gpios = <&pio 4 7 GPIO_ACTIVE_HIGH>; // PE7              default-on;              status = "okay";       };

③USB

Device tree configuration reference:

&usb_otg {       dr_mode = "host"; // peripheral       status = "okay"};

&usbphy {       status = "okay"};

In addition to referencing nodes, you must add ochi/echi, otherwise USB insertion will have no response:

soc {              ehci0: usb@01c1a000 {                     compatible = "allwinner,sun8i-v3s-ehci", "generic-ehci";                     reg = <0x01c1a000 0x100>;                     interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>;                     clocks = <&ccu CLK_BUS_EHCI0>, <&ccu CLK_BUS_OHCI0>;                     resets = <&ccu RST_BUS_EHCI0>, <&ccu RST_BUS_OHCI0>;                     status = "okay";              };

              ohci0: usb@01c1a400 {                     compatible = "allwinner,sun8i-v3s-ohci", "generic-ohci";                     reg = <0x01c1a400 0x100>;                     interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;                     clocks = <&ccu CLK_BUS_EHCI0>, <&ccu CLK_BUS_OHCI0>,                     <&ccu CLK_USB_OHCI0>;                     resets = <&ccu RST_BUS_EHCI0>, <&ccu RST_BUS_OHCI0>;                     status = "okay";              };       };

④Ethernet

Directly reference the emac node in the DTSI file, device tree reference:

&emac {       allwinner,leds-active-low;       status = "okay"};

⑤Wireless Network Card RTL8723BS

Under Linux, the SDIO architecture is similar to USB.

——After the device is inserted, if there is a corresponding driver, it will load automatically.

So in the device tree, we only need to configure the MMC1 interface, and then compile the corresponding driver ko, and load it in rootfs as well.

Device tree configuration reference below:

&mmc1 {       broken-cd;       bus-width = <4>;       vmmc-supply = <&reg_vcc3v3>;       status = "okay"};

The compiled ko file is in the buildroot overlay directory, you can refer to the materials below:

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

r8723bs.ko is the compiled kernel module, this module backports the driver from the 5.19 kernel, which is more stable compared to the 5.15 driver.

In addition to the ko file, it is necessary to also load the network card firmware, reference the directory below:

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S

rtl8723bs_nic.bin can be found on GitHub or other websites.

To connect to Wi-Fi, please refer to the script below:

[root@buildroot ~]# cat conn.shmodprobe r8723bs.kowpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.confudhcpc -i wlan0

Configuration file reference:

ctrl_interface=/var/run/wpa_supplicantap_scan=1

network={        ssid="###############"        psk="###############"}

⑥ADC Keys

The test file has been open-sourced, there is no need to elaborate, if you want to use it directly, please refer to the open-source URL at the end.

⑦Audio Playback

Buildroot integrates alsa, the default sound card is muted status, open the terminal, type alsamixer, first unmute:

In the current interface, select Headphone, then press M key to unmute, then use the keyboard ↑ to adjust the volume to a suitable size, the interface can refer to Figure 12:

Open Source Solution: V3S-PI - Portable Terminal Based on Allwinner V3S
Figure 12 alsamixer

After adjustment, type mpv filename –no-video, insert headphones, and you can play music:

[root@buildroot ~]# mpv 2.flac --no-video     Video --vid=1 [P] (mjpeg 500x500 1.000fps) (+) Audio --aid=1 (flac 2ch 48000Hz)File tags: Album: 西厢寻他 Title: 西厢寻他 Track: 1AO: [alsa] 48000Hz stereo 2ch s32A: 00:00:04 / 00:03:43 (2%)

Exiting... (Quit)

Command prompt displays the current directory.

Edit the /etc/profile file, add a line:

export PS1='[\

Leave a Comment