4009 views|0 replies

64

Posts

0

Resources
The OP
 

[Ultra-small Linux development kit Quantum Tiny Linux]- SDK environment construction and use [Copy link]

1. Sharing of clone address:

There are two addresses in total, one is Zhihuijun’s original project SDK:

https://github.com/peng-zhihui/Project-Quantum?tab=readme-ov-file

The other is for the upper layer of this board, the address of quark -n :

https://gitee.com/coolflyreg163/quark-n

2. Clone SDK

Original Project SDK

I am used to using VM to compile Ubuntu on Windows, so I prepare the compilation environment in advance according to my own situation. For details, please refer to my article: Virtual Machine + Ubuntu Environment Construction

First, create a new quark folder and clone the SDK

mkdir quark
cd quark/
git clone https://github.com/peng-zhihui/Project-Quantum.git
git clone https://gitee.com/coolflyreg163/quark-n.git

After cloning, check the folder

linux@linux-virtual-machine:~/work/quark$ ls
Project-Quantum  quark-n
linux@linux-virtual-machine:~/work/quark$ cd Project-Quantum/
linux@linux-virtual-machine:~/work/quark/Project-Quantum$ ls
1.Hardware  2.Bootloader  3.Kernel  4.Images  5.Tools  6.Docs  LICENSE  README.md

There are several project files here, which are described by Zhihuijun in README.md. I will introduce them here:

Project file structure description

  • Hardware : The Quantum Project includes a series of ultra-mini building blocks in the form of stamp holes. Currently, the following are available in the project files:

    • Quark-Core : An ARM-Linux core board module based on the Allwinner H3/H5 chip, with external peripherals including SDIO, USBx4, I2Cx2, SPIx2, UARTx3, HDMI, CAMERA, Ethernet port, GPIO, etc.

    • Atom-Shield : The baseboard module corresponding to the core board uses almost all the peripherals of the core board. When you design the baseboard yourself, you can directly tailor the hardware based on Atom.

    • Gluon-Power : A fingernail-sized power management module, used on Atom, supports lithium battery charge and discharge management, as well as one 5V DC-DC boost and one 3.3V buck output.

    • Electron-Arduino : A coprocessor module based on ATmega328, which can directly burn Arduino's Bootloader and be used as an Arduino board. It is very mini.

  • Bootloader : SOM's u-boot source code, ported from FriendlyARM 's repository

  • Kernel : The mainline Linux kernel source code used by SOM, with some of its own drivers added and device tree configuration modified. The original repository is this

  • Image : The packaged system image can be directly burned into SD for startup.

  • Docs : Datasheet documents of related chips.

For detailed descriptions of each module (hardware, software, image), please go to the relevant folder and view README.md

quark-n

linux@linux-virtual-machine:~/work/quark/Project-Quantum$ cd ..
linux@linux-virtual-machine:~/work/quark$ cd quark-n/
linux@linux-virtual-machine:~/work/quark/quark-n$ ls
boot             images   npi-config           sun8i-h3-atom_n.dts  xrdp
drivers          Kernels  README.md            WorkSpace
gpio_key_led.py  LICENSE  sun8i-h3-atom_n.dtb  WuKong

The quark-n project file description is relatively short, I will add here:

Project file structure description

  • boot: uboot startup script

  • drivers: stores wifi driver modules

  • gpio_key_led.py: Use the blue LED device in the new dts

  • images: clock images

  • Kernels: Not much use

  • LICENSE: GPLv2

  • sun8i-h3-atom_n.dtb: Allwinner CPU device tree binary file, used to add a blue LED device in dts

  • sun8i-h3-atom_n.dts: Allwinner CPU device tree file

  • WorkSpace: Development code for a digital clock with built-in LCD screen

  • WuKong: wukong-robot is a simple, flexible and elegant Chinese voice dialogue robot/smart speaker project, which aims to enable Chinese Makers and Hackers to quickly build personalized smart speakers. Project address: https://gitee.com/yadongzhao87/wukong-robot

  • xrdp: After upgrading to Ubuntu 20.04 LTS, the xrdp solution for connecting to quark via remote desktop is unavailable

3. Compile SDK

Zhihuijun's original project SDK compilation method can refer to REDEME.md in each directory

For example, REDEME.md compiled by uboot:

 Project-Quantum

编译方法可以参考Friendly-ARM的教程:http://wiki.friendlyarm.com/wiki/index.php/Building_U-boot_and_Linux_for_H5/H3/H2%2B/zh

配置好环境之后,编译命令:

```
$ cd u-boot
$ make quark_n_h3_defconfig ARCH=arm CROSS_COMPILE=arm-linux-
$ make ARCH=arm CROSS_COMPILE=arm-linux-
```

4. Use of quark -n

Clone quark-n directly on the board

git clone https://gitee.com/coolflyreg163/quark-n.git
cd quark-n
pi@Quark-N:~/qurak/quark-n$ ls
boot             images   npi-config           sun8i-h3-atom_n.dts  xrdp
drivers          Kernels  README.md            WorkSpace
gpio_key_led.py  LICENSE  sun8i-h3-atom_n.dtb  WuKong

Refer to quark-n usage tips: https://gitee.com/coolflyreg163/quark-n/

Bluetooth

In the previous chapter, we always failed to connect using Bluetooth. I changed to an ordinary Bluetooth headset and changed the user who logged in to the system to pi, so I can successfully connect to the Bluetooth headset!

By using Tip 13, we can know:

The Bluetooth connection speaker or headset system lacks a software package by default. Install the following software packages, delete the previous pairing after restarting, and then pair again

sudo apt-get install pulseaudio-module-bluetooth bluez-tools

The following command is used to run automatically at startup

pactl load-module module-bluetooth-discover

Try to play the audio again and copy the test.wav in root to the pi directory.

#打开终端登录root用户
su
quark

#cp文件
cp /root/Music/test.wav /home/pi/Music

After a lot of trouble, I couldn't hear the music when using Audacity, so I switched to calling PulseAudio and it worked.

First, make sure the PulseAudio service is installed

pi@Quark-N:/$ dpkg -l | grep pulseaudio
ii  pulseaudio                           1:8.0-0ubuntu3.15                          armhf        PulseAudio sound server
ii  pulseaudio-module-bluetooth          1:8.0-0ubuntu3.15                          armhf        Bluetooth module for PulseAudio sound server
ii  pulseaudio-module-x11                1:8.0-0ubuntu3.15                          armhf        X11 module for PulseAudio sound server
ii  pulseaudio-utils                     1:8.0-0ubuntu3.15                          armhf        Command line tools for the PulseAudio sound server
ii  xfce4-pulseaudio-plugin:armhf        0.2.4-1                                    armhf        Xfce4 panel plugin to control pulseaudio

Then list all audio output devices:

pactl list sinks

You can see that I have a Bluetooth audio device, Kulark E2. Let’s set Kulark E2 as the default audio output:

pactl set-default-sink bluez_sink.B4_A2_EB_6B_53_71

Then play our test audio:

paplay /home/pi/Music/test.wav

Now you can hear the sound!!!

microphone

Now that the sound has been solved, I still don’t understand how to record audio with Audacity, so I’ll just use the command line to record.

First use arecord to see if there is a microphone

arecord -l

You can see H3 Audio Codec (Hardware Codec) ( card 2 ): This seems to be a physical audio input device with one child device. Let's try recording with this

arecord -D plughw:CARD=2,DEV=0 -f cd -t wav -d 10 output.wav

Here the -D option specifies the device descriptor plughw:CARD=2,DEV=0 , -f cd
means recording with CD quality (44.1 kHz, 16 bit, 2 channels), -t wav specifies the output format as WAV, -d 10
means the recording duration is 10 seconds, and output.wav is the name of the output file.

After the recording is successful, an output.wav file will appear . Let's try to play this file.

aplay output.wav

I listened to the sound with Bluetooth headphones, and sure enough, it was the sound we just recorded!

Play Video

It is best to convert the video to the same resolution as the screen, otherwise it will freeze and drop frames. Use the following command to convert

ffmpeg -i /home/pi/Videos/BadApple.mp4 -strict -2 -s 240x134 /home/pi/Videos/BadApple_240x134.mp4
  • ffmpeg: This is the main program name, calling the FFmpeg tool.

  • -i /home/pi/Videos/BadApple.mp4: The -i parameter is followed by the path to the input file. This specifies the location of the source video file to be converted.

  • -strict -2: This parameter is used to specify how FFmpeg handles incompatible streams when decoding or encoding. -strict can be followed by a number from -2 to 2. The larger the number, the stricter the compatibility of the stream. -2 is a lower strictness level, allowing more incompatible streams to be processed.

  • -s 240x134: The -s parameter is used to set the size of the output video. Here, the output video resolution is specified to be 240 pixels wide and 134 pixels high.

  • /home/pi/Videos/BadApple_240x134.mp4: This is the path and file name of the output file. The converted video will be saved in this location.

Play Video

sudo mplayer -vo fbdev2:/dev/fb1 -x 240 -y 135 -zoom /home/pi/Videos/BadApple.mp4
  • sudo: Run commands with superuser privileges.

  • mplayer: player program.

  • -vo fbdev2: Specifies the video output driver as fbdev2. fbdev2 is a variant of fbdev, providing more features and configuration options.

  • /dev/fb1: Device file for the framebuffer device. This depends on your system configuration and may need to be adjusted for your hardware.

  • -x 240 -y 135: Set the video display width and height. These values may need to be adjusted based on your display needs.

  • -zoom: Zoom the video to fit the screen.

  • /home/pi/Videos/BadApple.mp4: Path to the video file to play.

I randomly found a TikTok MP4 video and converted it like this:

openCV

The system image also has OpenCV built in, which can realize face recognition function by connecting to a USB camera

  • You will need a USB camera. Connect the USB camera to USB port A of the development board.

  • Use ls /dev/video* to view your own camera

ls /dev/video* /dev/video0 /dev/video1
  • My camera is video0. Everyone's camera may be different. Determine the camera according to your own situation. If this one doesn't work, change it. You may also need to change it to the camera you call in the python file.

  • Go to the project folder:

$ cd WorkSpace/OpenCV
  • Switch to the root user, otherwise you will not have permission to run the demo:

$ python FaceDetectOnTft.py

You can see the video on the LCD screen of the development board!!

Use the blue led device in the new dts

Replace sun8i-h3-atom_n.dtb to /boot/sun8i-h3-atom_n.dtb

cp ~/quark/quark-n/sun8i-h3-atom_n.dtb /boot/

Restart

sudo shutdown -r now

Python code for testing, gpio_key_led.py

from periphery import LED
import time
ledUser = LED("usr_led", True)
while True:   
    time.sleep(1)   
    ledUser.write(255)   
    time.sleep(1)   
    ledUser.write(0)
ledUser.close()

gpio_key_led.py is to light up the blue LED after pressing the key

Under /sys/class/leds, pwr_led (yellow), status_led (white), usr_led (blue) are displayed

ls /sys/class/leds/

Or run the following command

sudo cat /sys/kernel/debug/gpio

There is a line in the output

gpio-359 ( |usr_led ) out hi

Success

Digital clock with built-in LCD screen

Need to execute first: Use the blue LED device in the new dts

First, place the Clock at the specified location

ln -s /home/pi/quark/quark-n/WorkSpace/Clock ~/WorkSpace/

Secondly, place the startup script in the specified location

chmod +x /home/pi/quark/quark-n/WorkSpace/Scripts/start_ui_clock.sh
mkdir -p ~/WorkSpace/Scripts/services
ln -s /home/pi/quark/quark-n/WorkSpace/Scripts/services/ui_clock.service ~/WorkSpace/Scripts/services/
ln -s /home/pi/quark/quark-n/WorkSpace/Scripts/start_ui_clock.sh ~/WorkSpace/Scripts/

From here, download 2 font files: "STHeiti Light.ttc", "PingFang.ttc", and copy them to ~/WorkSpace/Clock/fonts.

https://gitee.com/coolflyreg163/quark-n/releases/Fonts

Or run the command

cd ~/WorkSpace/Clock/fonts
wget https://gitee.com/coolflyreg163/quark-n/attach_files/603438/download/STHeiti%20Light.ttc
wget https://gitee.com/coolflyreg163/quark-n/attach_files/603439/download/PingFang.ttc

Run the following command to install

cd /home/pi/WorkSpace/Clock/
sudo python -m pip install --index http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com -r requirements.txt
mkdir /home/pi/WorkSpace/Clock/logs
sudo ln -s /home/pi/WorkSpace/Scripts/services/ui_clock.service /lib/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable ui_clock

At this point, Clock will automatically start after reboot. Here are the manual commands:

#1.启动(手动启动后按Ctrl + C可脱离)
sudo systemctl start ui_clock
#2.停止
sudo systemctl stop ui_clock
#3.产看状态
sudo systemctl status ui_clock
#4.重启系统
sudo shutdown -r now

But I found a problem after running it. The ruamel.yaml version was wrong, so I updated the system and upgraded to Ubuntu 18.04

Upgrading from Ubuntu 16.04 to Ubuntu 18.04

First update the system to the latest version and run the following command:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove
sudo apt dist-upgrade

Install update-manager-core and execute the following command:

sudo apt-get install update-manager-core

To perform a system upgrade, execute the following command:

sudo do-release-upgrade

The upgrade took quite a while, it took me hours!

Problems encountered during the upgrade process

If the message "Your python3 install is corrupted. Please fix the '/usr/bin/python3' symlink." appears, execute the following command:

sudo ln -sf /usr/bin/python2.7 /usr/bin/python
sudo ln -sf /usr/bin/python3.5 /usr/bin/python3

提示“The upgrade has aborted. The upgrade needs a total of 1,606 M free space on disk '/'. Please free at least an additional 388 M of disk space on '/'. Empty your trash and remove temporary packages of former installations using 'sudo apt-get clean'. ”,执行如下命令:

#删除临时文件
sudo rm -rf /tmp/*
#清理ATP缓存
sudo apt-get clean

After performing the cleanup operation, you can try the upgrade again

If there are still problems that still prevent the upgrade, then we need to check the upgrade log to determine the specific reason why the upgrade cannot be performed.

cat /var/log/dist-upgrade/main.log

After upgrading to Ubuntu 18.04 LTS, follow the steps below to install the ui_clock dependency package:

Note: After the upgrade, the version of python3 becomes 3.6.9, and the previous system 3.5.2 package is no longer available

First install the pip module of python3

sudo apt-get install python3-pip

Install the python3 package Note: It takes a long time to install pygame, so be patient

sudo python3 -m pip install fire 
sudo python3 -m pip install ruamel.yaml 
sudo python3 -m pip install pygame==1.9.6 
sudo python3 -m pip install python-periphery 
sudo python3 -m pip install PyYAML 
sudo python3 -m pip install Markdown 
sudo python3 -m pip install tornado 
sudo python3 -m pip install smbus
sudo python3 -m pip install Pillow
sudo python3 -m pip install numpy

Note: If the installation fails with the above command and the message "Could not find a version that satisfies the requirement" appears, you can use the following method. The original link for the solution is: http://t.csdnimg.cn/UQR0i

方法一:pip install 安装包名字 -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com //豆瓣镜像网站
(如果还不行记得加sudo)

sudo pip install fire -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com
sudo pip install ruamel.yaml -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com
sudo pip install pygame==1.9.6 -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com
sudo pip install python-periphery -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com
sudo pip install PyYAML -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com
sudo pip install Markdown -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com
sudo pip install tornado -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com
sudo pip install smbus -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com
sudo pip install Pillow -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com
sudo pip install numpy -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com

Note: If installing numpy using pip fails, you can install numpy using the following command

sudo apt-get install python3-numpy

Use LCD screen to display digital clock

After a long time, I finally reached the last step. Use the following command to manually open the digital clock

 sudo python3 /home/pi/WorkSpace/Clock/main.py

I don't know why the system can't start automatically. I'll see if there is anyone who knows this part later.

[FAILED] Failed to start ui_clock.service.
See 'systemctl status ui_clock.service' for details.

pi@Quark-N:~$ sudo systemctl start ui_clock
Job for ui_clock.service failed because the control process exited with error code.
See "systemctl status ui_clock.service" and "journalctl -xe" for details.

This dial can also be used in conjunction with WuKong-robot. For this part, you can directly refer to quark-n's usage tips, so I will not go into details here.

This post is from Embedded System

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list