diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 00000000..e69de29b diff --git a/404.html b/404.html new file mode 100644 index 00000000..50234a07 --- /dev/null +++ b/404.html @@ -0,0 +1,1172 @@ + + + +
+ + + + + + + + + + + + + +Some GStreamer pipeline command-line examples with omxil library on TH1520, RevyOS
+In this section, the grammer of the gstreamer command-line pipeline and some usefule debug tips are introduced. They have been moved to the end of the article.
+Basically, you neet to install gstreamer1.0-plugins-base
, gstreamer1.0-plugins-good
, gstreamer1.0-plugins-bad
, gstreamer1.0-omx-generic
, gstreamer1.0-omx-bellagio-config
,gstreamer1.0-tools
.
# videotestsrc
+gst-launch-1.0 videotestsrc ! autovideosink
+
+# specify the video stream format
+gst-launch-1.0 videotestsrc ! video/x-raw, format=NV12, width=960, height=540, framerate=60/1 ! autovideosink
+
+# display framerate
+gst-launch-1.0 videotestsrc ! fpsdisplaysink
+
+# no need to sync on the clock - used to test the performance of the pipeline
+gst-launch-1.0 videotestsrc ! fpsdisplaysink sync=false
+
+# stop display on the screen, but redirect the output to stdout
+gst-launch-1.0 videotestsrc ! fpsdisplaysink text-overlay=false -v 2>&1
+
+# specify which sink to use
+gst-launch-1.0 videotestsrc ! fpsdisplaysink sink=glimagesink
+
+# combine the previous examples
+gst-launch-1.0 videotestsrc ! fpsdisplaysink sink=glimagesink sync=false text-overlay=false -v 2>&1
+
+# audiotestsrc
+gst-launch-1.0 audiotestsrc ! autoaudiosink
+
+# change volume (0 to 1)
+gst-launch-1.0 audiotestsrc volume=0.1 ! autoaudiosink
+
+# change waveform
+# could be selected among square, silence, pink-noise, etc.
+gst-launch-1.0 audiotestsrc wave=pink-noise ! autoaudiosink
+
+# set fix frequency, such as "do" (262 Hz)
+gst-launch-1.0 audiotestsrc freq=262 ! autoaudiosink
+
+# a dummy sink that swallows everything
+gst-launch-1.0 videotestsrc ! fakesink
+
+# let decodebin choose which decoder to use,
+# and autovideosink choose which video-sink to use (not recommended)
+gst-launch-1.0 filesrc location=fire.mp4 ! decodebin ! autovideosink
+
+# h264 software decode without opengl display
+gst-launch-1.0 filesrc location=fire.mp4 ! qtdemux ! h264parse ! avdec_h264 ! xvimagesink
+
+# h264 hardware decode with opengl display
+gst-launch-1.0 filesrc location=fire.mp4 ! qtdemux ! h264parse ! omxh264dec ! glimagesink
+
+# h265 hardware decode
+gst-launch-1.0 filesrc location=fire.mp4 ! qtdemux ! h265parse ! omxh265dec ! glimagesink
+
+# vp9 hardware decode
+gst-launch-1.0 filesrc location=fire.webm ! matroskademux ! omxvp9dec ! glimagesink
+
+# mpeg4 hardware decode
+gst-launch-1.0 filesrc location=fire.mp4 ! qtdemux ! queue ! mpeg4videoparse ! omxmpeg4videodec ! glimagesink
+
+# play mkv/webm file
+gst-launch-1.0 filesrc location=fire.mkv ! matroskademux ! decodebin ! glimagesink
+
+# todo 10-bit h264/h265 decode
+
+# there is no hardware decoder on th1520
+
+# let autoaudiosink choose which audio-sink to use
+gst-launch-1.0 filesrc location=blade.mp3 ! decodebin ! audioconvert ! autoaudiosink
+
+# mp3 decode
+gst-launch-1.0 filesrc location=blade.mp3 ! mpegaudioparse ! avdec_mp3 ! audioconvert ! autoaudiosink
+
+# aac decode
+gst-launch-1.0 filesrc location=blade.aac ! aacparse ! avdec_aac ! audioconvert ! autoaudiosink
+gst-launch-1.0 filesrc location=blade.aac ! aacparse ! faad ! audioconvert ! autoaudiosink
+## faad works well without aacparse
+gst-launch-1.0 filesrc location=blade.aac ! faad ! audioconvert ! autoaudiosink
+
+# opus decode
+## ogg file must be demuxed by oggdemux first
+gst-launch-1.0 filesrc location=blade.ogg ! oggdemux ! opusparse ! opusdec ! audioconvert ! autoaudiosink
+gst-launch-1.0 filesrc location=blade.ogg ! oggdemux ! opusparse ! avdec_opus ! audioconvert ! autoaudiosink
+
+# wav decode
+gst-launch-1.0 filesrc location=test.wav ! wavparse ! audioresample ! audioconvert ! autoaudiosink
+
+# use specific audiosink
+gst-launch-1.0 filesrc location=blade.mp3 ! decodebin ! audioconvert ! pulsesink
+
+# specify the output device by using alsasink with device property
+gst-launch-1.0 filesrc location=blade.mp3 ! decodebin ! audioconvert ! alsasink device=hw:0,2
+
+We play media file in this section.
+# play mp4 file with both audio and video
+gst-launch-1.0 filesrc location=fire.mp4 ! qtdemux name=demux \
+ demux.video_0 ! queue ! decodebin ! videoconvert ! autovideosink \
+ demux.audio_0 ! queue ! decodebin ! audioconvert ! autoaudiosink
+
+# h264 encode test
+# before import video stream to omxh264dec, data should be transformed to frame with rawvideoparse
+# property and pad of rawvideoparse should be set to the same, so we use 'use-sink-caps=true' here
+gst-launch-1.0 videotestsrc ! videoconvert \
+ ! video/x-raw, format=NV12, width=640, height=480 \
+ ! rawvideoparse use-sink-caps=true ! omxh264enc ! fakesink
+
+# h264 hardware encode to file
+## todo: encoded h264 file has seek problem
+gst-launch-1.0 videotestsrc ! videoconvert \
+ ! video/x-raw, format=NV12, width=640, height=480 \
+ ! rawvideoparse use-sink-caps=true ! omxh264enc \
+ ! h264parse ! qtmux ! mp4mux ! filesink location=test.mp4
+
+# h264 hardware encode to file with specific bitrate(bit per second)
+gst-launch-1.0 videotestsrc ! videoconvert \
+ ! video/x-raw, format=NV12, width=640, height=480 \
+ ! rawvideoparse use-sink-caps=true \
+ ! omxh264enc target-bitrate=3000000 \
+ ! h264parse ! filesink location=test.mp4
+
+
+# h265 hardware encode to file
+## this pipeline produces h265 stream only
+## qtdemux is not needed while decoding
+gst-launch-1.0 videotestsrc ! videoconvert \
+ ! video/x-raw, format=NV12, width=640, height=480 \
+ ! rawvideoparse use-sink-caps=true ! omxh265enc \
+ ! h265parse ! filesink location=test.h265
+
+# h264 hardware encode from camera to file
+gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert \
+ ! video/x-raw, format=NV12,width=640,height=480 \
+ ! rawvideoparse use-sink-caps=true \
+ ! omxh264enc ! h264parse ! filesink location=test.mp4 -e
+
+# There is no hardware audio encoder on th1520
+
+# encode aac stream with adts container(.aac file)
+## the unit of the bitrate is 'bit/sec'
+gst-launch-1.0 audiotestsrc ! voaacenc bitrate=128000 ! avmux_adts ! filesink location=test.aac
+
+
+# todo: encode aac stream with adif container(.m4a file)
+
+# encode to mp3 file
+## the unit of the bitrate is 'kbit/sec'
+gst-launch-1.0 audiotestsrc ! lamemp3enc quality=2 target=bitrate bitrate=192 cbr=true ! id3v2mux ! filesink location=test.mp3
+
+# encode opus stream to .ogg file
+gst-launch-1.0 audiotestsrc ! opusenc ! oggmux ! filesink location=test.opus
+
+
+# todo: encode pcm stream to .wav file
+
+This part has been removed to Video + audio transcode
section.
Since omx...dec
cannot fulfill qtdemux and mp4mux, and gst-omx is no longer maintained, it is hard to mux mp4 file with these two plugins. To mux stream from omxh264dec, use avmux_mp4
instead. But there is no h265 or vp9 muxer available for omx...dec
The raw video stream should be processed by rawvideoparse
before sent to encoder. Because itself cannot scale frame or change framerate, rawvideoparse
need to get the stream info of its sink pad(src pad of the backward element). Therefore use-sink-caps
must be set to true
.
To change width and height, set properties output-width
and output-height
of omx...dec
. To modify bitrate and bitrate control method, set properties control-rate
and target-bitrate
of omx...enc
. To change framerate, set properties of videorate
.
# h265 to h264
+gst-launch-1.0 filesrc location=test_h265.mp4 ! qtdemux ! h265parse ! omxh265dec \
+ ! rawvideoparse use-sink-caps=true \
+ ! omxh264enc ! h264parse ! avmux_mp4 ! filesink location=t_h264.mp4
+
+# vp9 to h264
+gst-launch-1.0 filesrc location=test_vp9.webm ! matroskademux ! omxvp9dec \
+ ! rawvideoparse use-sink-caps=true \
+ ! omxh264enc ! h264parse ! avmux_mp4 ! filesink location=t_h264.mp4
+
+# arbitrary input to h264
+gst-launch-1.0 filesrc location=test_h264.mp4 ! decodebin \
+ ! rawvideoparse use-sink-caps=true \
+ ! omxh264enc ! h264parse ! filesink location=t_h264.mp4
+
+# h264 to h264, with more options
+## set the video width and height to 1280×720, framerate to 15fps, bitrate mode to constant and bitrate to 5Mbps
+gst-launch-1.0 filesrc location=test_h264.mp4 ! qtdemux ! h264parse \
+ ! omxh264dec output-width=1280 output-height=720 \
+ ! videorate ! video/x-raw, framerate=15/1 \
+ ! rawvideoparse use-sink-caps=true \
+ ! omxh264enc control-rate=constant target-bitrate=5000000 ! h264parse ! filesink location=t_h264.mp4
+
+## there is no vp9 encoder in th1520 omxil lib
+
+# aac to mp3
+gst-launch-1.0 filesrc location=test.aac ! aacparse ! avdec_aac ! audioconvert ! lamemp3enc quality=2 target=bitrate bitrate=192 cbr=true ! id3v2mux ! filesink location=t.mp3
+
+# mp3 to aac
+gst-launch-1.0 filesrc location=test.mp3 ! mpegaudioparse ! avdec_mp3 ! audioconvert ! voaacenc bitrate=128000 ! avmux_adts ! filesink location=t.aac
+
+# wav to mp3
+gst-launch-1.0 filesrc location=test.wav ! wavparse ! audioresample ! audioconvert ! lamemp3enc quality=2 target=bitrate bitrate=192 cbr=true ! id3v2mux ! filesink location=t.mp3
+
+# mp3 to wav
+gst-launch-1.0 filesrc location=test.mp3 ! mpegaudioparse ! avdec_mp3 ! audioresample ! audioconvert \
+ ! audio/x-raw, rate=44100, format=S16LE ! wavenc ! filesink location=t.wav
+
+# mux test
+gst-launch-1.0 audiotestsrc ! autoaudiosink videotestsrc ! autovideosink
+
+# mux the test video and audio stream to a mp4 file
+## be aware that '-e' must be set to this pipeline,
+## and there is no '!' before audiotestsrc
+gst-launch-1.0 -e videotestsrc ! videoconvert \
+ ! video/x-raw, format=NV12, width=960, height=540 \
+ ! rawvideoparse use-sink-caps=true ! omxh264enc ! h264parse \
+ ! avmux_mp4 name=mux ! filesink location=t_h264.mp4 \
+ audiotestsrc ! lamemp3enc ! mux.
+
+# change container from mkv to mp4 with h264 stream
+## this means demux a mkv file then mux video and audio stream to mp4 file
+gst-launch-1.0 filesrc location=test_h264.mkv \
+ ! matroskademux name=demux mp4mux force-create-timecode-trak=true name=mux ! filesink location=t_h264.mp4 \
+ demux.video_0 ! queue ! video/x-h264 ! mux. \
+ demux.audio_0 ! queue ! audio/mpeg ! mux.
+
+You can use command v4l2-ctl
, which is included in package v4l-utils
to get information of your camera.
For more information, read this article
+# h264 hardware encode from camera to file
+gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert \
+ ! video/x-raw, format=NV12,width=640,height=480 \
+ ! rawvideoparse format=nv12 width=640 height=480 \
+ ! omxh264enc ! h264parse ! filesink location=test.mp4 -e
+
+
+# capture camera and stream to other machine
+
+## source
+gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! videorate \
+ ! video/x-raw, format=NV12,width=640,height=480,framerate=20/1 \
+ ! rawvideoparse format=nv12 width=640 height=480 framerate=20/1 \
+ ! omxh264enc ! h264parse config-interval=1 ! video/x-h264,stream-format=byte-stream,alignment=nal \
+ ! rtph264pay ! udpsink host=192.168.31.27 port=5600
+
+## destination
+gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' \
+ ! rtph264depay ! h264parse ! avdec_h264 ! autovideosink
+
+gst-inspect-1.0
is a tool to print info about a GStreamer element(factory), which is included in gstreamer1.0-tools
.
# print the GStreamer element list with a 'less' like paing filter.
+gst-inspect-1.0
+
+# print info of the element
+gst-inspect-1.0 <element_name>
+
+gst-discover-1.0
is a tool to show info about the media file, which is inclucded in gstreamer1.0-plugins-base-apps
.
gst-discoverer-1.0 -v test.mp4
+
+If you are tired of manually build pipeline for playback by hand. You can use gst-play-1.0
as an alternative, which is included in gstreamer1.0-plugins-base-apps
.
# play media file
+gst-play-1.0 test.mp4
+
+# play media file with specific sink
+gst-play-1.0 --videosink=glimagesink --audiosink=alsasink
+
+Left button and right button can be used to seek. For more info, please read this article.
+To get the cap info or property of an element, you may need to run gst-inspect-1.0 <element_name>
. If gst-inspect-1.0
command not found, install gstreamer1.0-tools
.
If you want to debug GStreamer, refer to the articles below. +https://gstreamer.freedesktop.org/documentation/tutorials/basic/debugging-tools.html +https://gstreamer.freedesktop.org/documentation/gstreamer/running.html?gi-language=c
+Here is a simple command-line pipeline.
+gst-launch-1.0 videotestsrc ! autovideosink
+
+!
represent a link. The established pipeline looks like
videotestsrc => autovideosink
+
+There are several properties in videotestsrc, which could be lookup by gst-inspect-1.0 videotestsrc
.Set some properties:
gst-launch-1.0 videotestsrc pattern=ball flip=true ! autovideosink
+
+NAME=VALUE
is a property. pattern
and flip
are properties of videotestsrc.
Sometimes we need to control the behavior of gst-launch-1.0
.
GST_DEBUG=3 gst-launch-1.0 videotestsrc pattern=ball flip=true ! autovideosink
+gst-launch-1.0 videotestsrc pattern=ball flip=true ! autovideosink --gst-debug-level=3
+
+There are two ways to achieve this goal. One is setting environment variable. Another one is passing command-line argument to gst-launch-1.0
. GST_DEBUG=3
and --gst-debug-level=3
have the same meaning.
In most video decoding cases, there is a video-stream and an audio stream. We need to use demuxer to seperate them. Demuxer usually have several src pad. Here is an example.
+gst-launch-1.0 filesrc location=test-video.mp4 ! qtdemux name=demux demux. ! queue ! h264parse ! omxh264dec ! glimagesink demux. ! queue ! aacparse ! avdec_aac ! audioconvert ! alsasink
+
+It is hard to read. Add some word wrap:
+gst-launch-1.0 filesrc location=test-video.mp4 ! qtdemux name=demux \
+ demux. ! queue ! h264parse ! omxh264dec ! glimagesink \
+ demux. ! queue ! aacparse ! avdec_aac ! audioconvert ! pulsesink
+
+Here we use a demuxer to seperate video and audio, the grammer is:
+... demuxer name=DEMUXER_NAME \
+DEMUXER_NAME.PIPELINE_NAME_1 ! queue ! ...(the remaining part of pipeline 1) \
+DEMUXER_NAME.PIPELINE_NAME_2 ! queue ! ...(the remaining part of pipeline 2)
+
+Sometimes we need to set certain properties of the stream at certain nodes in the pipeline, e.g set resolution of the videostream of the videotestsrc
.
gst-launch-1.0 videotestsrc ! video/x-raw, width=800, height=600 ! glimagesink
+
+We negotiated the pad properties between videotestsrc
and glimagesink
. The property names and values must be supported by both element. You can find them in Pad Templates
section of gst-inspect-1.0
.
适用SDK v1.1.2
+PTG 的 OpenMAX IL 库(下称 vpu-omxil
)可使 LicheePi 4A 能够流畅硬解码 4k 60fps 的视频,那么具体应该如何使用该库呢?本文将主要介绍 LicheePi 4A 开发板上 Parole 播放器的集成与使用,用户可根据本文来了解在 LicheePi 4A 上的适配过程
+以 h264 的硬解为例,视频硬解的工作流程如图所示
+-------------------------------------------+
+ | +------------+ +------------+ | +--------+
+video stream----+--->| omxh264dec +------>| video-sink +----+-->| player |
+ | +------+-----+ +------------+ | +--------+
+ | | GStreamer |
+ +-----------+-------------------------------+
+ |
+ +-----v-----+
+ | vpu-omxil |
+ +-----+-----+
+ |
+ |
+ +-------v-------+
+ | kernel module |
+ | (driver) |
+ +-------+-------+
+ |
+ v
+ hardware
+
+omxh264dec
中将 omxh264 解码的部分单独拎出来,大体的结构如下
+ +---+------------+----+
+ | +------------+ |
+ | | omxh264dec | |
+ | +------------+ |
+ | GStreamer |
+ +----------+----------+
+ |
+ +----+-----v-----+----+
+ | +-----------+ |
+ | | vpu-omxil | |
+ | +-----------+ |
+ | libomxil-bellagio |
+ +----------+----------+
+ |
++------------v------------+
+| - memalloc - vc8000 |
+| - hantrodec - vidmem |
+| kernel modules |
++------------+------------+
+ |
+ v
+ hardware
+
+我们依照自底向上的顺序构建图示的链条。 +本节的主要目的是使 omxh264dec 解码器能够运行,并不涉及到输出屏幕等内容。
+硬解码需要访问硬件,而访问硬件又需要驱动,所以需要编译并安装驱动
+PTG 提供的驱动源:
+https://github.com/revyos/vpu-vc8000e-kernel
+https://github.com/revyos/vpu-vc8000d-kernel
+https://github.com/revyos/video_memory
+revyos/thead-kernel 已经合并了上述三个内核模块, 使用revyos_defconfig 可以无需编译上述内核模块
+# depmod 分析可载入模块的依赖关系,在 /lib/modules/<kernel-version>中添加modules.dep文件,以便后续 modprobe 使用
+sudo depmod -a
+sudo modprobe vidmem vc8000 hantrodec memalloc
+
+## 如果 modprobe 安装有问题的话,可以尝试使用 insmod 安装
+#cd /usr/lib/modules/$(uname -r)
+#sudo insmod $(find . -name *vidmem.ko*)
+#sudo insmod $(find . -name *vc8000.ko*)
+#sudo insmod $(find . -name *hantrodec.ko*)
+#sudo insmod $(find . -name *memalloc.ko*)
+
+# 可选:设置开机加载模块
+echo -e "\nvidmem\nhantrodec\nmemalloc\nvc8000\n" | sudo tee -a /etc/modules > /dev/null
+
+安装内核模块后,/dev
目录下会出现 hantrodec
vidmem
vc8000
三个设备文件。默认情况下,用户对其没有访问权限,如果不修改权限的话,非 root 用户在打开 omxil 库时会报错。
# 生效一次
+cd /dev
+sudo chmod 666 hantrodec vidmem vc8000
+
+# 长期生效
+cat << EOF | sudo tee /lib/udev/rules.d/70-hantro.rules > /dev/null
+KERNEL=="vidmem", MODE="0666"
+KERNEL=="hantrodec", MODE="0666"
+KERNEL=="vc8000", MODE="0666"
+EOF
+
+如果要获取 RevyOS 特定版本的内核模块,可进入 revyos/thead-kernel ,并在 GitHub CI 中下载 artifacts
+首先,请将 vpu-omxil 下载并解压到 /usr/lib/omxil/中 +vpu-omxil_1.2.1.tar.gz +如下图所示, 需要
+vpu-omxil
中的 OpenMax 组件注册到 libomxil-bellagio
中gst-omx
(该包提供了 omxh264dec 解码器) 调用 libomxil-bellagio
的时候也需要知道调用的组件名称+---------+ +-------------------+ +-----------+
+| gst-omx +-->| libomxil-bellagio +-->| vpu-omxil |
++---------+ +-------------------+ +-----------+
+
+vpu-omxil
中的组件注册到 libomxil-bellagio
中sudo apt install libomxil-bellagio-bin libomxil-bellagio0
+# 注册组件
+omxregister-bellagio -v /usr/lib/omxil/
+
+使用 omxregister-bellagio 生成注册文件,默认路径为 ~/.omxregister
+th1520-vpu 利用了 debian 在 usr/lib/riscv64-linux-gnu/libomxil-bellagio0
安装之后
+触发自动注册行为 结果如下
cat /var/lib/libomxil-bellagio0/registry
+/usr/lib/riscv64-linux-gnu/libomxil-bellagio0/libOMX.hantro.H2.video.encoder.so
+ ==> OMX.hantro.H2.video.encoder ==> OMX.hantro.H2.video.encoder.avc:OMX.hantro.H2.video.encoder.hevc:
+/usr/lib/riscv64-linux-gnu/libomxil-bellagio0/libOMX.hantro.VC8000D.image.decoder.so
+ ==> OMX.hantro.VC8000D.image.decoder ==> OMX.hantro.VC8000D.image.decoder.jpeg:
+/usr/lib/riscv64-linux-gnu/libomxil-bellagio0/libOMX.hantro.H2.image.encoder.so
+ ==> OMX.hantro.H2.image.encoder ==> OMX.hantro.H2.image.encoder.jpeg:
+/usr/lib/riscv64-linux-gnu/libomxil-bellagio0/libOMX.hantro.VC8000D.video.decoder.so
+ ==> OMX.hantro.VC8000D.video.decoder ==> OMX.hantro.VC8000D.video.decoder.mpeg4:OMX.hantro.VC8000D.video.decoder.avc:OMX.hantro.VC8000D.video.decoder.avs:OMX.hantro.VC8000D.video.decoder.h263:OMX.hantro.VC8000D.video.decoder.wmv:OMX.hantro.VC8000D.video.decoder.vp6:OMX.hantro.VC8000D.video.decoder.vp8:OMX.hantro.VC8000D.video.decoder.jpeg:OMX.hantro.VC8000D.video.decoder.hevc:OMX.hantro.VC8000D.video.decoder.vp9:OMX.hantro.VC8000D.video.decoder.avs2:
+
+调整 gstomx.conf 的设置以使解码器 omxh264dec 调用正确的组件,具体请查看针对 gst-omx 的补丁
+gst-omx-01-add-libomxil-config.patch
+请查看 PTG 提供的针对 gst-omx 的 dmabuf 补丁 +gst-omx-02-set-dec-out-port-dmabuf.patch
+sudo apt install gstreamer1.0-omx-generic gstreamer1.0-omx-bellagio-config gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-gl gstreamer1.0-plugins-good gstreamer1.0-tools
+
+# 1 基本解码
+gst-launch-1.0 filesrc location=<test.mp4> ! qtdemux ! h264parse ! omxh264dec ! videoconvert ! fakesink sync=false
+# 2 在终端中显示 fps
+# 参考:https://stackoverflow.com/questions/73948308
+gst-launch-1.0 filesrc location=<test.mp4> ! qtdemux ! h264parse ! omxh264dec ! videoconvert ! fpsdisplaysink video-sink=fakesink text-overlay=false sync=false -v 2>&1
+
+fakesink
会把前面的视频流全部吞掉,不输出画面(因而不会在 video-sink 这一环节损失性能),但是结合fpsdisplaysink可以读取到解码的速度。正常日志如下:
Setting pipeline to PAUSED ...[DBGT]
+vc8kdec compiled without trace support (ENABLE_DBGT_TRACE switch not enabled)
+Pipeline is PREROLLING ...
+Redistribute latency...
+OMX ! decoder_get_parameter OMX_ErrorNoMore (2)
+Pipeline is PREROLLED ...
+Setting pipeline to PLAYING ...
+New clock: GstSystemClockRedistribute latency...
+0:01:39.5 / 0:01:49.4 (90.9 %)
+
+【TIP】如果有 [omxh264dec-omxh264dec0: Could not initialize supporting library.](https://gist.github.com/Sakura286/015fae6792e160268db7ad8a697dd2df)
等字样的报错,可以安装gst-omx
、libomxil-bellagio
与libc6
相关的 debug-symbol 包,使用 gdb
启动上述命令进行调试。调试时,先断DWLInit
,然后再断open
,具体看是打开哪个地方的时候出错了。
RevyOS 适配过程中对于初始化动态库失败找到了如下三种原因:
+omxregister-bellagio
注册 vpu-omxil/dev
目录下 hantrodec
vc8000
vidmem
等设备的权限video-sink
是视频流在整个 GStreamer pipeline 中的最后一步,其作用一般是将视频流输出到屏幕上。
+前文中fakesink
只是测试解码器是否正常工作的特殊 video-sink
,可选的 video-sink非常多,常见的有 autovideosink
,ximagesink
,xvimagesink
,fbdevsink
,waylandsink
,glimagesink
,gtkglsink
等,它们各在不同的插件包里,需要酌情安装:
video-sink | +所属包名 | +
---|---|
waylandsink | +gstreamer1.0-plugins-bad | +
fbdevsink | +gstreamer1.0-plugins-bad | +
autovideosink | +gstreamer1.0-plugins-good | +
gtkglsink | +gstreamer1.0-plugins-good | +
ximagesink | xvimagesink | +gstreamer1.0-plugins-base | +
glimagesink | +gstreamer1.0-plugins-base | gstreamer1.0-gl | +
【TIP】使用 gst-inspect-1.0 <video-sink-name>
来查看对应 video-sink 可用的选项
+【TIP】添加 --gst-debug-level=<lv>
来获得更多的输出日志,其中 <lv>
代表了从 1 到 6,啰嗦程度从低到高,建议在等级 4 及以下,否则日志会非常长
+请尝试不同的 video-sink ,并尝试不同的插件参数,以及给予不同的环境变量,直至找到可以流畅硬解 H264 的那一个。
**waylandsink**
:由于现在(20230720)RevyOS 采用了 Xfce 桌面,不可能支持 Wayland,故 waylandsink
从原理上无法使用**fbdevsink**
与**ximagesink**
:无法使用**xvimagesink**
:通过流水线图以及日志可以确定,playbin 或 autovideosink 会自动调用 xvimagesink,使用 perf 分析后可以发现,使用xvimagesink 不可避免地会进行大量的 memcpy 操作,严重降低解码性能;该问题在获得PTG的 dmabuf 补丁后依然存在,故无法使用**gtkglsink**
:GTK3 不支持 EGL on X11,而 RevyOS 目前基于 x11,且只支持 EGL,故无法使用剩下的只有glimagesink
,根据 Running and debugging GStreamer Applications,并观察其他使用到 glimagesink 的例子,可以猜测需要明确指定环境变量 GST_GL_API
与 GST_GL_PLATFORM
+由于 RevyOS 使用了 gles2+egl 的组合,使用如下的命令,成功硬解。
GST_GL_API=gles2 GST_GL_PLATFORM=egl gst-launch-1.0 filesrc location=<test.mp4> ! qtdemux ! h264parse ! omxh264dec ! videoconvert ! fpsdisplaysink video-sink=glimagesink sync=false
+
+然而 GStreamer 被播放器调用时是无法通过环境变量来传递参数的,所以构建 gst-plugins-base 时应当传递额外的 meson 编译参数:
+-Dgl_api=[\'gles2\'] -Dgl_platform=[\'egl\']
+
+GStreamer 的 pipeline 没有问题之后,就需要使播放器支持。不同播放器会使用到不同的 video-sink,同样对 gstreamer 有着不同程度的依赖。 +适配播放器时,最重要的工作便是①使播放器适配已验证的 video-sink,或者②使 gstreamer pipeline 支持播放器指定的 video-sink,此次 RevyOS 适配过程采用了①方案。
+ +-------------------------------------------+
+ | +------------+ +------------+ | +--------+
+video stream----+--->| omxh264dec +------>| video-sink +----+-->| player |
+ | +------------+ +------------+ | +--------+
+ | GStreamer |
+ +-------------------------------------------+
+
+根据 https://gstreamer.freedesktop.org/apps/ 进行简单的排查
+是否可用 | +是否更新 | +应用名 | +备注 | +
---|---|---|---|
❌ | ++ | Gnash | +Flash 播放器 | +
❌ | ++ | GEntrans | +Debian 未收录 | +
❓ | +20230226 | +Kaffeine | +❌ 需要大量 KDE 相关组件 | +
+ | + | + | ✔️ 存在于riscv64 仓库中 | +
+ | + | + | ❌ 在 Debian amd64 Gnome 上,播放窗口与控制窗口分离,且默认调用了 VLC 进行播放 | +
❌ | ++ | Lcdgrilo | +Debian 未收录 | +
✔️ | +20230218 | +Parole | +✔️ For XFCE | +
+ | + | + | ❓ 不支持 Wayland,仅支持 x11 | +
+ | + | + | ✔️ Debian amd64 Gnome 验证通过 | +
+ | + | + | ✔️ 存在于riscv64 仓库 中 | +
❌ | ++ | Songbird | +Debian 未收录 | +
❌ | ++ | Snappy | +Debian 未收录 | +
❌ | ++ | Totem | +需要 GTK3,然而 GTK3 不支持 EGL on X11 | +
最初选择的播放器是 Totem,但是发现 Totem 无法指定除了 gtkglsink 以外的 video-sink,且由于 RevyOS 不支持 gtkglsink,所以支持 Totem 播放器的难度较大。 +对支持 GStreamer 的播放器进行排查后发现了 Parole , Parole 由 GObject 编写,与常见的面向对象编程略有区别。寻找其构建 parole_gst 对象时的方法 parole_gst_constructed,将 video-sink 属性设置为前文已验证的 glimagesink,补丁:
+parole-01-add-glimagesink-support.patch
+至此,粗略的适配工作完成。
+补丁集合:
+https://gist.github.com/Sakura286/26777ea8204c1819885e093806a4f7ca
+PTG omxil 库
+https://drive.google.com/file/d/1pYgCVI7WltfpskltJ-RqzVUCEC21FS56
+ + + + + + +测试网站地址:https://webglsamples.org/aquarium/aquarium.html
+直接打开即可,左侧数字是渲染的鱼的数量,数量越多越占性能
+CoreMark是一个综合基准,用于测量嵌入式系统中使用的中央处理器(CPU)的性能。它是在2009由eembc的shay gal-on开发的,旨在成为一个行业标准,取代过时的dehrystone基准。代码用C编写,包含以下算法:列表处理(增删改查和排序)、矩阵操作(公共矩阵操作)、状态机(确定输入流是否包含有效数字)和CRC。用户可以自由的下载Coremark,并移植到自己的平台上运行,随后就可以看到分数。
+├── barebones --移植到裸机环境下需要修改的目录
+│ ├── core_portme.c --移植的目标平台配置信息
+│ ├── core_portme.h --计时以及板级初始化实现
+│ ├── core_portme.mak --该子目录的makefile
+│ ├── cvt.c
+│ └── ee_printf.c --打印函数串口发送实现
+├── core_list_join.c --列表操作程序
+├── core_main.c --主程序
+├── coremark.h --项目配置与数据结构的定义头文件
+├── coremark.md5
+├── core_matrix.c --矩阵运算程序
+├── core_state.c --状态机控制程序
+├── core_util.c --CRC计算程序
+├── cygwin --x86 cygwin和gcc 3.4(四核,双核和单核系统)的测试代码
+│ ├── core_portme.c
+│ ├── core_portme.h
+│ └── core_portme.mak
+├── freebsd --以下同理,是在不同操作系统下的测试代码
+│ ├── ...
+├── LICENSE.md
+├── linux
+│ ├── ...
+├── linux64
+│ ├── ...
+├── macos
+│ ├── ...
+├── Makefile
+├── README.md --自述文件,CoreMark项目的基本介绍
+├── rtems
+│ ├── ...
+└── simple
+ ├── ...
+ └──
+
+根据 README 说法,只需要在 coremark 文件夹下执行 make 即可进行编译与测试。测试结果会出现在 Results 文件夹中,其中 run1.log 是测试结果。
+coremark 总体测试时间较短。 +计划同时测试 10 次取平均数值。
+$ git clone https://github.com/eembc/coremark.git
+$ cd coremark
+$ make
+
+2K performance run parameters for coremark.
+CoreMark Size : 666
+Total ticks : 12915
+Total time (secs): 12.915000
+Iterations/Sec : 8517.228029
+Iterations : 110000
+Compiler version : GCC13.1.0
+Compiler flags : -O2 -DPERFORMANCE_RUN=1 -lrt
+Memory location : Please put data memory location here
+ (e.g. code in flash, data on heap etc)
+seedcrc : 0xe9f5
+[0]crclist : 0xe714
+[0]crcmatrix : 0x1fd7
+[0]crcstate : 0x8e3a
+[0]crcfinal : 0x33ff
+Correct operation validated. See README.md for run and reporting rules.
+CoreMark 1.0 : 8517.228029 / GCC13.1.0 -O2 -DPERFORMANCE_RUN=1 -lrt / Heap
+
+
+make XCFLAGS="-march=rv64gv0p7_zfh_xtheadc -O3 -funroll-all-loops -finline-limit=500 -fgcse-sm -fno-schedule-insns -msignedness-cmpiv -fno-code-hoisting -mno-thread-jumps1 -mno-iv-adjust-addr-cost -mno-expand-split-imm"
+
+2K performance run parameters for coremark.
+CoreMark Size : 666
+Total ticks : 15129
+Total time (secs): 15.129000
+Iterations/Sec : 13219.644392
+Iterations : 200000
+Compiler version : GCC10.4.0
+Compiler flags : -O2 -march=rv64gv0p7_zfh_xtheadc -O3 -funroll-all-loops -finline-limit=500 -fgcse-sm -fno-schedule-insns -msignedness-cmpiv -fno-code-hoisting -mno-thread-jumps1 -mno-iv-adjust-addr-cost -mno-expand-split-imm -DPERFORMANCE_RUN=1 -lrt
+Memory location : Please put data memory location here
+ (e.g. code in flash, data on heap etc)
+seedcrc : 0xe9f5
+[0]crclist : 0xe714
+[0]crcmatrix : 0x1fd7
+[0]crcstate : 0x8e3a
+[0]crcfinal : 0x4983
+Correct operation validated. See README.md for run and reporting rules.
+CoreMark 1.0 : 13219.644392 / GCC10.4.0 -O2 -march=rv64gv0p7_zfh_xtheadc -O3 -funroll-all-loops -finline-limit=500 -fgcse-sm -fno-schedule-insns -msignedness-cmpiv -fno-code-hoisting -mno-thread-jumps1 -mno-iv-adjust-addr-cost -mno-expand-split-imm -DPERFORMANCE_RUN=1 -lrt / Heap
+
+make XCFLAGS="-march=rv64imafd_xtheadba_xtheadbb_xtheadbs_xtheadcmo_xtheadcondmov_xtheadfmemidx_xtheadfmv_xtheadint_xtheadmac_xtheadmemidx_xtheadmempair_xtheadsync -O3 -funroll-all-loops -finline-limit=500 -fgcse-sm -fno-schedule-insns -fno-code-hoisting -mno-thread-jumps"
+
+2K performance run parameters for coremark.
+CoreMark Size : 666
+Total ticks : 11897
+Total time (secs): 11.897000
+Iterations/Sec : 9246.028411
+Iterations : 110000
+Compiler version : GCC13.1.0
+Compiler flags : -O2 -march=rv64imafd_xtheadba_xtheadbb_xtheadbs_xtheadcmo_xtheadcondmov_xtheadfmemidx_xtheadfmv_xtheadint_xtheadmac_xtheadmemidx_xtheadmempair_xtheadsync -O3 -funroll-all-loops -finline-limit=500 -fgcse-sm -fno-schedule-insns -fno-code-hoisting -DPERFORMANCE_RUN=1 -lrt
+Memory location : Please put data memory location here
+ (e.g. code in flash, data on heap etc)
+seedcrc : 0xe9f5
+[0]crclist : 0xe714
+[0]crcmatrix : 0x1fd7
+[0]crcstate : 0x8e3a
+[0]crcfinal : 0x33ff
+Correct operation validated. See README.md for run and reporting rules.
+CoreMark 1.0 : 9246.028411 / GCC13.1.0 -O2 -march=rv64imafd_xtheadba_xtheadbb_xtheadbs_xtheadcmo_xtheadcondmov_xtheadfmemidx_xtheadfmv_xtheadint_xtheadmac_xtheadmemidx_xtheadmempair_xtheadsync -O3 -funroll-all-loops -finline-limit=500 -fgcse-sm -fno-schedule-insns -fno-code-hoisting -DPERFORMANCE_RUN=1 -lrt / Heap
+
+
+
+
+
+
+
+ glmark2 is an OpenGL 2.0 and ES 2.0 benchmark. +We will only use glmark2-es2 for relevant tests here . This is a testing tool for x11-glesv2.
+This software package is already pre-installed in the system.
+th1520
only support glmark-es2.
If you need perfect performance, put your device into performance mode before you start, here's how to do it.
+Please execute the following commands in the terminal. This command requires a root account.
+echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
+
+cat /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq
+
+After the execution is completed, you will see a series of numbers, such as "1848000".
+Open a terminal and enter glmark2-es2. This test allows the use of non-root accounts.
+After entering the command, a new window will appear on your desktop with an active screen.
+After the test is completed, the additional activity screen will disappear and the score will be output in the terminal in the form of "glmark2 Score: xxx".
+For example:
+debian@lpi4a:~/Desktop$ glmark2-es2
+=======================================================
+ glmark2 2021.12
+=======================================================
+ OpenGL Information
+ GL_VENDOR: Imagination Technologies
+ GL_RENDERER: PowerVR B-Series BXM-4-64
+ GL_VERSION: OpenGL ES 3.2 build 1.17@6210866
+ Surface Config: buf=32 r=8 g=8 b=8 a=8 depth=24 stencil=8
+ Surface Size: 800x600 windowed
+=======================================================
+[build] use-vbo=false: FPS: 513 FrameTime: 1.949 ms
+[build] use-vbo=true: FPS: 1367 FrameTime: 0.732 ms
+[texture] texture-filter=nearest: FPS: 1449 FrameTime: 0.690 ms
+[texture] texture-filter=linear: FPS: 1454 FrameTime: 0.688 ms
+[texture] texture-filter=mipmap: FPS: 1453 FrameTime: 0.688 ms
+[shading] shading=gouraud: FPS: 1172 FrameTime: 0.853 ms
+[shading] shading=blinn-phong-inf: FPS: 1180 FrameTime: 0.847 ms
+[shading] shading=phong: FPS: 1002 FrameTime: 0.998 ms
+[shading] shading=cel: FPS: 979 FrameTime: 1.021 ms
+[bump] bump-render=high-poly: FPS: 700 FrameTime: 1.429 ms
+[bump] bump-render=normals: FPS: 1354 FrameTime: 0.739 ms
+[bump] bump-render=height: FPS: 1320 FrameTime: 0.758 ms
+[effect2d] kernel=0,1,0;1,-4,1;0,1,0;: FPS: 1059 FrameTime: 0.944 ms
+[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;: FPS: 381 FrameTime: 2.625 ms
+[pulsar] light=false:quads=5:texture=false: FPS: 1484 FrameTime: 0.674 ms
+[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4: FPS: 349 FrameTime: 2.865 ms
+[desktop] effect=shadow:windows=4: FPS: 736 FrameTime: 1.359 ms
+[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 161 FrameTime: 6.211 ms
+[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=subdata: FPS: 173 FrameTime: 5.780 ms
+[buffer] columns=200:interleave=true:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 242 FrameTime: 4.132 ms
+[ideas] speed=duration: FPS: 593 FrameTime: 1.686 ms
+[jellyfish] <default>: FPS: 572 FrameTime: 1.748 ms
+[terrain] <default>: FPS: 42 FrameTime: 23.810 ms
+[shadow] <default>: FPS: 619 FrameTime: 1.616 ms
+[refract] <default>: FPS: 82 FrameTime: 12.195 ms
+[conditionals] fragment-steps=0:vertex-steps=0: FPS: 1539 FrameTime: 0.650 ms
+[conditionals] fragment-steps=5:vertex-steps=0: FPS: 1238 FrameTime: 0.808 ms
+[conditionals] fragment-steps=0:vertex-steps=5: FPS: 1535 FrameTime: 0.651 ms
+[function] fragment-complexity=low:fragment-steps=5: FPS: 1411 FrameTime: 0.709 ms
+[function] fragment-complexity=medium:fragment-steps=5: FPS: 1050 FrameTime: 0.952 ms
+[loop] fragment-loop=false:fragment-steps=5:vertex-steps=5: FPS: 1376 FrameTime: 0.727 ms
+[loop] fragment-steps=5:fragment-uniform=false:vertex-steps=5: FPS: 1394 FrameTime: 0.717 ms
+[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5: FPS: 1379 FrameTime: 0.725 ms
+=======================================================
+ glmark2 Score: 950
+=======================================================
+
+
+
+
+
+
+
+
+ ++lmbench for revyOS
+
带宽测评工具 | +反应时间测评工具 | +其他 | +
---|---|---|
读取缓存文件 | +上下文切换 | +\ | +
拷贝内存 | +网络:连接的建立,管道,TCP,UDP 和RPC hot potato | +\ | +
读内存 | +文件系统的建立和删除 | +\ | +
写内存 | +进程创建 | +处理器时钟比率计算 | +
管道 | +信号处理 | +\ | +
TCP | +上层的系统调用 | +\ | +
\ | +内存读入反应时间 | +\ | +
下载测试工具:
+git clone https://github.com/revyos/lmbench3.git
+
+++该版本为已为 RevyOS 移植版本。
+
在开始测试前,需要先安装依赖:
+sudo apt install gcc make libntirpc-dev -y
+
+执行命令进行编译,配置,并测试
+cd lmbench3
+cd src
+make results
+
+编译完成后会有以下选项提示需要设置:
+以下不需要更改的项目直接回车,会自动设置默认值。
+MULTIPLE COPIES [default 1]
: 设置同时运行 lmbench 的份数,份数多会使 lmbench 运行缓慢,默认是 1,这里设置为默认值 1。
=====================================================================
+
+If you are running on an MP machine and you want to try running
+multiple copies of lmbench in parallel, you can specify how many here.
+
+Using this option will make the benchmark run 100x slower (sorry).
+
+NOTE: WARNING! This feature is experimental and many results are
+ known to be incorrect or random!
+
+MULTIPLE COPIES [default 1]:
+=====================================================================
+
+Job placement selection [default 1]
: 作业调度控制方法,默认值是 1,表示允许作业调度,这里设置为默认值。
=====================================================================
+
+Options to control job placement
+1) Allow scheduler to place jobs
+2) Assign each benchmark process with any attendent child processes
+ to its own processor
+3) Assign each benchmark process with any attendent child processes
+ to its own processor, except that it will be as far as possible
+ from other processes
+4) Assign each benchmark and attendent processes to their own
+ processors
+5) Assign each benchmark and attendent processes to their own
+ processors, except that they will be as far as possible from
+ each other and other processes
+6) Custom placement: you assign each benchmark process with attendent
+ child processes to processors
+7) Custom placement: you assign each benchmark and attendent
+ processes to processors
+
+Note: some benchmarks, such as bw_pipe, create attendent child
+processes for each benchmark process. For example, bw_pipe
+needs a second process to send data down the pipe to be read
+by the benchmark process. If you have three copies of the
+benchmark process running, then you actually have six processes;
+three attendent child processes sending data down the pipes and
+three benchmark processes reading data and doing the measurements.
+
+Job placement selection [default 1]:
+=====================================================================
+
+Memory
: 设置测试内存大小,默认是 $MB
, 即为程序计算出来的最大可测试内存,也可以手动定义测试值,这里设置为这里使用默认值。
=====================================================================
+
+Several benchmarks operate on a range of memory. This memory should be
+sized such that it is at least 4 times as big as the external cache[s]
+on your system. It should be no more than 80% of your physical memory.
+
+The bigger the range, the more accurate the results, but larger sizes
+take somewhat longer to run the benchmark.
+
+MB [default 686]:
+Checking to see if you have 686 MB; please wait for a moment...
+686MB OK
+686MB OK
+686MB OK
+Hang on, we are calculating your cache line size.
+OK, it looks like your cache line is 64 bytes.
+
+=====================================================================
+
+SUBSET (ALL|HARWARE|OS|DEVELOPMENT) [default all]
: 要运行的测试集,包含 ALL/HARWARE/OS/DEVELOPMENT
,默认选 all
,这里选 all
。
=====================================================================
+
+lmbench measures a wide variety of system performance, and the full suite
+of benchmarks can take a long time on some platforms. Consequently, we
+offer the capability to run only predefined subsets of benchmarks, one
+for operating system specific benchmarks and one for hardware specific
+benchmarks. We also offer the option of running only selected benchmarks
+which is useful during operating system development.
+
+Please remember that if you intend to publish the results you either need
+to do a full run or one of the predefined OS or hardware subsets.
+
+SUBSET (ALL|HARWARE|OS|DEVELOPMENT) [default all]:
+=====================================================================
+
+FASTMEM [default no]
: 内存 latency
测试,如果跳过该测试,则设置为 yes
,如果不跳过则设置为 no
,默认是 no
,这里设置为默认值。
=====================================================================
+
+This benchmark measures, by default, memory latency for a number of
+different strides. That can take a long time and is most useful if you
+are trying to figure out your cache line size or if your cache line size
+is greater than 128 bytes.
+
+If you are planning on sending in these results, please don't do a fast
+run.
+
+Answering yes means that we measure memory latency with a 128 byte stride.
+
+FASTMEM [default no]:
+=====================================================================
+
+SLOWFS [default no]
: 文件系统 latency
测试,如果跳过值设置为 yes
,不跳过设置为 no
,默认 no
,这里设置为默认值。
=====================================================================
+
+This benchmark measures, by default, file system latency. That can
+take a long time on systems with old style file systems (i.e., UFS,
+FFS, etc.). Linux' ext2fs and Sun's tmpfs are fast enough that this
+test is not painful.
+
+If you are planning on sending in these results, please don't do a fast
+run.
+
+If you want to skip the file system latency tests, answer "yes" below.
+
+SLOWFS [default no]:
+=====================================================================
+
+DISKS [default none]
: 硬盘带宽和 seek time
,需要设置测试硬盘的盘符,例如 /dev/sda
,默认不测试(默认 none ),这里设置为默认值。
=====================================================================
+
+This benchmark can measure disk zone bandwidths and seek times. These can
+be turned into whizzy graphs that pretty much tell you everything you might
+need to know about the performance of your disk.
+
+This takes a while and requires read access to a disk drive.
+Write is not measured, see disk.c to see how if you want to do so.
+
+If you want to skip the disk tests, hit return below.
+
+If you want to include disk tests, then specify the path to the disk
+device, such as /dev/sda. For each disk that is readable, you'll be
+prompted for a one line description of the drive, i.e.,
+
+ Iomega IDE ZIP
+or
+ HP C3725S 2GB on 10MB/sec NCR SCSI bus
+
+DISKS [default none]:
+=====================================================================
+
+REMOTE [default none]
: 网络测试,需要 2
台机器并设置 rsh
,是测试机器能 rsh
访问另一台,默认不测试(默认 none ),这里设置为默认值。
=====================================================================
+
+If you are running on an idle network and there are other, identically
+configured systems, on the same wire (no gateway between you and them),
+and you have rsh access to them, then you should run the network part
+of the benchmarks to them. Please specify any such systems as a space
+separated list such as: ether-host fddi-host hippi-host.
+
+REMOTE [default none]:
+=====================================================================
+
+Processor mhz [default 999 MHz, 1.0010 nanosec clock]
: 测试 cpu
,默认 $MHZ
,即为程序判断出的频率,也可以根据情况自己设定,例如 3500,单位 MHz
,这里设置为默认值。
=====================================================================
+
+Calculating mhz, please wait for a moment...
+I think your CPU mhz is
+
+ 999 MHz, 1.0010 nanosec clock
+
+but I am frequently wrong. If that is the wrong Mhz, type in your
+best guess as to your processor speed. It doesn't have to be exact,
+but if you know it is around 800, say 800.
+
+Please note that some processors, such as the P4, have a core which
+is double-clocked, so on those processors the reported clock speed
+will be roughly double the advertised clock rate. For example, a
+1.8GHz P4 may be reported as a 3592MHz processor.
+
+Processor mhz [default 999 MHz, 1.0010 nanosec clock]:
+=====================================================================
+
+FSDIR [default /usr/tmp]
: 临时目录用来存放测试文件,可以自己设定,默认 /usr/tmp
,这里设置为默认值。
=====================================================================
+
+We need a place to store a 686 Mbyte file as well as create and delete a
+large number of small files. We default to /usr/tmp. If /usr/tmp is a
+memory resident file system (i.e., tmpfs), pick a different place.
+Please specify a directory that has enough space and is a local file
+system.
+
+FSDIR [default /usr/tmp]:
+=====================================================================
+
+Status output file [default /dev/tty]
: 测试输出信息文件存放目录,可以自己设定,默认 /dev/tty
。
=====================================================================
+
+lmbench outputs status information as it runs various benchmarks.
+By default this output is sent to /dev/tty, but you may redirect
+it to any file you wish (such as /dev/null...).
+
+Status output file [default /dev/tty]:
+=====================================================================
+
+Mail results [default yes]
: 是否将测试结果邮件发出来,默认是 yes
,这里设置为 no
。
=====================================================================
+
+There is a database of benchmark results that is shipped with new
+releases of lmbench. Your results can be included in the database
+if you wish. The more results the better, especially if they include
+remote networking. If your results are interesting, i.e., for a new
+fast box, they may be made available on the lmbench web page, which is
+
+ http://www.bitmover.com/lmbench
+
+Mail results [default yes]: no
+OK, no results mailed.
+=====================================================================
+
+以上项目设置完成后,开始自动执行测试。
+p7zip 测试是用于测试系统解压性能,通过数据直观评估性能,以下是运行 7pzip 测试的操作步骤
+首先需要在 RevyOS 中 安装 p7zip
+debian@lpi4a:~/Desktop$ sudo apt update
+debian@lpi4a:~/Desktop$ sudo apt install p7zip-full
+
+进行 p7zip 测试需要在终端中输入以下命令来执行:
+debian@lpi4a:~/Desktop$ 7z b
+
+系统会开始进行测试然后输出性能数据。
+通过以上步骤,可以在 RevyOS 上安装并测试 7zip 的性能。
+以下是测试结果参考,使用镜像版本为RevyOS2023121016g版本
+debian@lpi4a:~/Desktop$ 7z b
+
+7-Zip 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
+p7zip Version 16.02 (locale=C.UTF-8,Utf16=on,HugeFiles=on,64 bits,4 CPUs LE)
+
+LE
+CPU Freq: - 64000000 64000000 - - - - - -
+
+RAM size: 15739 MB, # CPU hardware threads: 4
+RAM usage: 882 MB, # Benchmark threads: 4
+
+ Compressing | Decompressing
+Dict Speed Usage R/U Rating | Speed Usage R/U Rating
+ KiB/s % MIPS MIPS | KiB/s % MIPS MIPS
+
+22: 3252 303 1045 3164 | 75268 394 1628 6422
+23: 3092 307 1025 3151 | 74514 399 1617 6447
+24: 3021 318 1022 3249 | 72017 398 1588 6322
+25: 2945 320 1050 3363 | 67801 395 1529 6034
+---------------------------------- | ------------------------------
+Avr: 312 1036 3232 | 396 1591 6306
+Tot: 354 1313 4769
+
+
+
+
+
+
+
+ 使用脚本对整机进行重启测试。
+测试机器重启会不会出现死机等问题。
+进行重启测试 500 次。
+在 /lib/system/system 下创建名为 cycletest.service_ 重启脚本:
+[Unit]
+Description=Reboots unit after 30s
+
+[Service]
+StandardOutput=syslog+console
+ExecStart=/bin/sh -c "\
+test -f /cycle-count || echo 0 > /cycle-count;\
+echo 'starting cycletest';\
+sleep 30;\
+expr `cat /cycle-count` + 1 > /cycle-count;\
+systemctl reboot;\
+"
+
+[Install]
+WantedBy=multi-user.target
+
+后根据以下指令安装并开始测试:
+systemctl daemon-reload
+systemctl enable cycletest.service (enable the service to start on reboot)
+systemctl start cycletest.service (start the service, should reboot in 30s)
+
+
+
+
+
+
+
+ STREAM 基准测试是一个简单的综合基准测试程序,它测量可持续内存带宽(以 MB/s 为单位)和简单向量内核的相应计算速率。
+stream 仅有单个文件,在进行测试时只需要对 stream.c
进行编译即可:
git clone <https://github.com/microseyuyu/STREAM.git>
+cd STREAM
+gcc -O3 -fopenmp -DN=2000000 -DNTIMES=10 stream.c -o stream
+export OMP_NUM_THREADS=8
+./stream
+
+参数说明:
+DN=2000000:指定测试数组a[]、b[]、c[]的大小(Array size)。该值对测试结果影响较大(5.9版本默认值2000000,。若stream.c为5.10版本,参数名变为-DSTREAM_ARRAY_SIZE,默认值10000000)。注意:必须设置测试数组大小远大于CPU 最高级缓存(一般为L3 Cache)的大小,否则就是测试CPU缓存的吞吐性能,而非内存吞吐性能。 +- -DNTIMES=10:执行的次数,并从这些结果中选最优值。 +- OMP_NUM_THREADS=8 线程数量。
+参考结果:
+debian@lpi4a:~/Desktop/STREAM$ ./stream
+-------------------------------------------------------------
+STREAM version $Revision: 5.10 $
+-------------------------------------------------------------
+This system uses 8 bytes per array element.
+-------------------------------------------------------------
+***** WARNING: ******
+ It appears that you set the preprocessor variable N when compiling this code.
+ This version of the code uses the preprocesor variable STREAM_ARRAY_SIZE to control the array size
+ Reverting to default value of STREAM_ARRAY_SIZE=10000000
+***** WARNING: ******
+Array size = 10000000 (elements), Offset = 0 (elements)
+Memory per array = 76.3 MiB (= 0.1 GiB).
+Total memory required = 228.9 MiB (= 0.2 GiB).
+Each kernel will be executed 10 times.
+ The *best* time for each kernel (excluding the first iteration)
+ will be used to compute the reported bandwidth.
+-------------------------------------------------------------
+Number of Threads requested = 8
+Number of Threads counted = 8
+-------------------------------------------------------------
+Your clock granularity/precision appears to be 1 microseconds.
+Each test below will take on the order of 21622 microseconds.
+ (= 21622 clock ticks)
+Increase the size of the arrays if this shows that
+you are not getting at least 20 clock ticks per test.
+-------------------------------------------------------------
+WARNING -- The above is only a rough guideline.
+For best results, please be sure you know the
+precision of your system timer.
+-------------------------------------------------------------
+Function Best Rate MB/s Avg time Min time Max time
+Copy: 8364.2 0.019258 0.019129 0.019508
+Scale: 8291.0 0.019572 0.019298 0.020162
+Add: 6223.6 0.038835 0.038563 0.040011
+Triad: 6222.5 0.038776 0.038570 0.039470
+-------------------------------------------------------------
+Solution Validates: avg error less than 1.000000e-13 on all three arrays
+-------------------------------------------------------------
+
+
+
+
+
+
+
+ # qemu-user 下编译
+sudo apt update
+sudo apt install -y \
+ sbuild buildd qemu-system-misc qemu-user-static binfmt-support \
+ ca-certificates apt-transport-https devscripts mmdebstrap
+
+# native
+sudo apt install -y \
+ sbuild buildd ca-certificates apt-transport-https devscripts mmdebstrap
+
+# 修正宿主的debian-ports证书相关问题 现阶段可能不需要了
+wget https://mirror.sjtu.edu.cn/debian/pool/main/d/debian-ports-archive-keyring/debian-ports-archive-keyring_2023.02.01_all.deb
+sudo dpkg -i ./debian-ports-archive-keyring_2023.02.01_all.deb
+
+
+# sbuild 增加当前用户免root
+sudo sbuild-adduser $USER
+
+export SUFFIX=revyos-c910v-sbuild
+sudo sbuild-createchroot --debootstrap=debootstrap --arch=riscv64 \
+ --chroot-suffix=-$SUFFIX \
+ --keyring='' \
+ --no-deb-src \
+ --include=debian-ports-archive-keyring,ca-certificates,apt-transport-https,eatmydata \
+ --extra-repository="deb [trusted=yes] https://mirror.iscas.ac.cn/revyos/revyos-c910v/ revyos-c910v main contrib non-free" \
+ --extra-repository="deb [trusted=yes] https://mirror.iscas.ac.cn/revyos/revyos-addons/ revyos-addons main" \
+ sid /srv/chroot/sid-riscv64-$SUFFIX \
+ https://mirror.iscas.ac.cn/revyos/revyos-base/
+
+# 修正环境相关问题
+sudo sed -i 's/deb http/deb [trusted=yes] http/g' /srv/chroot/sid-riscv64-$SUFFIX/etc/apt/sources.list
+sudo rm -rf /srv/chroot/sid-riscv64-$SUFFIX/var/lib/apt/lists/*
+echo "command-prefix=eatmydata" | sudo tee -a /etc/schroot/chroot.d/sid-riscv64-$SUFFIX-*
+
+# 调整source顺序 - 目的是同版本使用c910v仓库的
+# 编辑sources.list 确保以下顺序
+deb [trusted=yes] https://mirror.iscas.ac.cn/revyos/revyos-c910v/ revyos-c910v main contrib non-free
+deb [trusted=yes] https://mirror.iscas.ac.cn/revyos/revyos-addons/ revyos-addons main
+deb [trusted=yes] https://mirror.iscas.ac.cn/revyos/revyos-base/ sid main contrib non-free non-free-firmware
+
+sbuild --arch=riscv64 -d sid -c sid-riscv64-revyos-c910v-sbuild xxx.dsc
+
+
+
+
+
+
+
+ 实验性 feature
如果发现问题可以进行issue申报
# 增加优化源
+sudo sed -i '1ideb https://mirror.iscas.ac.cn/revyos/revyos-c910v/ revyos-c910v main' /etc/apt/sources.list
+# 更新软件
+sudo apt update && sudo apt upgrade -y
+# 安装 gcc-10/gcc-13
+sudo apt install -y build-essential gcc-13 g++-13
+# 重启避免其他问题
+sudo reboot
+
+gcc -v
+Using built-in specs.
+COLLECT_GCC=gcc
+COLLECT_LTO_WRAPPER=/usr/lib/gcc/riscv64-linux-gnu/10/lto-wrapper
+Target: riscv64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Debian 10.4.0-8revyos2.3' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=riscv64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libsanitizer --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --disable-multilib --with-arch=rv64gcv0p7_zfh_xtheadc --with-abi=lp64d --enable-checking=release --build=riscv64-linux-gnu --host=riscv64-linux-gnu --target=riscv64-linux-gnu
+Thread model: posix
+Supported LTO compression algorithms: zlib zstd
+gcc version 10.4.0 (Debian 10.4.0-8revyos2.3)
+
+gcc-13 -v
+Using built-in specs.
+COLLECT_GCC=gcc-13
+COLLECT_LTO_WRAPPER=/usr/libexec/gcc/riscv64-linux-gnu/13/lto-wrapper
+Target: riscv64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Debian 13.2.0-1revyos1' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-13 --program-prefix=riscv64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --disable-multilib --with-arch=rv64gc_zfh_xtheadba_xtheadbb_xtheadbs_xtheadcmo_xtheadcondmov_xtheadfmemidx_xtheadfmv_xtheadint_xtheadmac_xtheadmemidx_xtheadmempair_xtheadsync --with-abi=lp64d --enable-checking=release --build=riscv64-linux-gnu --host=riscv64-linux-gnu --target=riscv64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=16
+Thread model: posix
+Supported LTO compression algorithms: zlib zstd
+gcc version 13.2.0 (Debian 13.2.0-1revyos1)
+
+除了v0p7 其他优化都可以用 gcc-13 代替 gcc-10
+后者的优化可以主线报问题 是已经主线化的功能
+ + + + + + +RevyOS 会预制相关优化编译器 基本支持rv64gc
支持的优化 | +gcc-10 | +gcc-13 | +clang-17 | +
---|---|---|---|
Zfh | +✅ | +✅ | +✅ | +
v0p7 | +✅ | +❌ | +❌ | +
xthead 当前版本 v2.2
+支持的优化1 | +gcc-102 | +gcc-13.2 | +clang-17 | +
---|---|---|---|
XTheadCmo | +✅ | +✅ | +✅ | +
XTheadSync | +✅ | +✅ | +✅ | +
XTheadBa | +✅ | +✅ | +✅ | +
XTheadBb | +✅ | +✅ | +✅ | +
XTheadBs | +✅ | +✅ | +✅ | +
XTheadCondMov | +✅ | +✅ | +✅ | +
XTheadMemIdx | +✅ | +✅ | +✅ | +
XTheadMemPair | +✅ | +✅ | +✅ | +
XTheadFMemIdx | +✅ | +✅ | +✅ | +
XTheadMac | +✅ | +✅ | +✅ | +
XTheadFmv | +✅ | +✅ | +❌ | +
XTheadInt | +✅ | +✅ | +❌ | +
XTHeadVdot3 | +✅ | +✅ | +✅ | +
注:
+首先确保安装gcc:
+sudo apt update
+sudo apt install gcc
+
+下面以最简单的 'hello,world' 程序为例演示如何编译并运行:
+编译以下内容并命名为 hello.c
:
#include <stdio.h>
+
+int main()
+{
+ printf("hello, world\n");
+ return 0;
+}
+
+编译并执行:
+debian@lpi4a:~/test$ gcc -g hello.c -o hello
+
+debian@lpi4a:~/test$ ./hello
+hello, world
+
+
+首先确保安装g++:
+sudo apt update
+sudo apt install g++
+
+下面以最简单的 'hello,world' 程序为例演示如何编译并运行:
+编译以下内容并命名为 hello.cpp
:
#include <iostream>
+using namespace std;
+
+int main()
+{
+ cout << "Hello, World!\n";
+ return 0;
+}
+
+
+编译并执行:
+debian@lpi4a:~/test$ g++ -g hello.cpp -o hello
+debian@lpi4a:~/test$ ./hello
+Hello, World!
+
+以上就是gcc/g++ 编译程序并运行的最简单实例,更复杂的应用案例可以参考相应的 +系统编程手册。
+ + + + + + +内核工具链下载地址:
+https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1663142514282/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-20220906.tar.gz
+这里假设编译环境为 Ubuntu
或 Debian
安装依赖:
+sudo apt install -y gdisk dosfstools g++-12-riscv64-linux-gnu build-essential libncurses-dev gawk flex bison openssl libssl-dev tree dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf device-tree-compiler
+
+解压工具链(这里解压到/opt):
+tar -xvf Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-20220906.tar.gz -C /opt
+
+设置环境变量,将工具链加入环境变量中(假设工具链放在/opt中):
+export PATH="/opt/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1/bin:$PATH"
+export CROSS_COMPILE=riscv64-unknown-linux-gnu-
+export ARCH=riscv
+
+使用git下载内核代码:
+# 内核仓库
+git clone https://github.com/revyos/thead-kernel.git
+
+编译内核:
+# 创建安装目标目录
+mkdir rootfs && mkdir rootfs/boot
+
+# 目录创建完成后,目录结构应该看起来是这样:
+# .. << 当前工作路径
+# |-- rootfs
+# |-- boot
+# |-- thead-kernel
+# |-- ...
+
+# 进入内核代码目录,开始构建
+cd thead-kernel
+make CROSS_COMPILE=riscv64-unknown-linux-gnu- ARCH=riscv revyos_defconfig
+make CROSS_COMPILE=riscv64-unknown-linux-gnu- ARCH=riscv -j$(nproc)
+make CROSS_COMPILE=riscv64-unknown-linux-gnu- ARCH=riscv -j$(nproc) dtbs
+sudo make CROSS_COMPILE=riscv64-unknown-linux-gnu- ARCH=riscv INSTALL_MOD_PATH=../rootfs/ modules_install -j$(nproc)
+sudo make CROSS_COMPILE=riscv64-unknown-linux-gnu- ARCH=riscv INSTALL_PATH=../rootfs/boot zinstall -j$(nproc)
+# 构建perf(如果需要的话)
+make CROSS_COMPILE=riscv64-unknown-linux-gnu- ARCH=riscv LDFLAGS=-static NO_LIBELF=1 NO_JVMTI=1 VF=1 -C tools/perf/
+sudo cp -v tools/perf/perf ../rootfs/sbin/perf-thead
+# 安装内核到安装目标目录
+sudo cp -v arch/riscv/boot/Image ../rootfs/boot/
+# 安装设备树到安装目标目录
+sudo cp -v arch/riscv/boot/dts/thead/light-lpi4a.dtb ../rootfs/boot/
+sudo cp -v arch/riscv/boot/dts/thead/light-lpi4a-dsi0-hdmi.dtb ../rootfs/boot/
+
+之后只需要把rootfs中内容拷贝或覆盖到对应目录即可,注意内核Image和内核module目录一定要对应,不然会因缺失内核模块导致外设功能失效。
+ + + + + + +C910V强制cpu指定补丁
+From 5164bca5a4bcde4534dc1a9aa3a7f619719874cf Mon Sep 17 00:00:00 2001
+From: Han Gao <gaohan@iscas.ac.cn>
+Date: Sun, 23 Apr 2023 22:11:35 +0800
+Subject: [PATCH] qemu-user-riscv64 default cpu is c910v
+
+Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
+---
+ linux-user/riscv/target_elf.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/linux-user/riscv/target_elf.h b/linux-user/riscv/target_elf.h
+index 9dd65652ee45..3195cfa71408 100644
+--- a/linux-user/riscv/target_elf.h
++++ b/linux-user/riscv/target_elf.h
+@@ -9,7 +9,7 @@
+ #define RISCV_TARGET_ELF_H
+ static inline const char *cpu_get_model(uint32_t eflags)
+ {
+- /* TYPE_RISCV_CPU_ANY */
+- return "any";
++ /* TYPE_RISCV_CPU_C910V */
++ return "c910v";
+ }
+ #endif
+
+编译流程
+./configure \
+ --prefix=$HOME/qemu-install \
+ --static \
+ --target-list=riscv64-linux-user \
+ --disable-system \
+ --disable-pie \
+ --interp-prefix=/etc/qemu-binfmt/%M
+
+make -j20
+
+
+
+
+
+
+
+ 这里描述了 RevyOS 相关的构建文档
+ + + + + + +测试版镜像
+基于 lpi4a 20230614 版本 +增加 ahead 支持 混合新 20230820 改动
+https://mirror.iscas.ac.cn/revyos/extra/images/beagle/test/20230802/
+RevyOS 20230412 版本
+RevyOS 20230425 版本
+RevyOS 20230511 版本
+添加了gnome桌面支持
+RevyOS 20230614 版本
+当前版本只提供xfce4桌面支持
+提供了chromium支持
+RevyOS 20230810 版本
+重新设计了启动流程 所以需要重新刷写所有分区
+Retrieving file: /dtbs/linux-image-5.10.113-lpi4a/<NULL>-light-c910.
+Skipping l0r for failure retrieving fdt
+Light LPI4A#
+
+遇见这种情况需要执行</br>
+env default -a -f;env save;reset
+
+当前版本只提供xfce4桌面支持
+内核 commit ID: #2023.08.10.02.31+c130cdb21
+RevyOS 20230916 版本
+SBI 时间戳
+u-boot 时间戳
+内核 commit ID
+版本时间戳(/etc/revyos-release)
+RevyOS 20231026 版本
+RevyOS 20231210 版本
+SBI 时间戳
+u-boot 时间戳
+内核 commit ID
+版本时间戳(/etc/revyos-release)
+RevyOS 20240202 版本
+SBI 时间戳
+u-boot 时间戳
+内核 commit ID
+版本时间戳(/etc/revyos-release)
+RevyOS 20240601 版本
+SBI 时间戳
+u-boot 时间戳
+内核 commit ID
+版本时间戳(/etc/revyos-release)
+状态: +可以运行,软解图形
+资料: +https://github.com/OpenTTD/OpenTTD/blob/master/COMPILING.md +https://salsa.debian.org/openttd-team/openttd/-/blob/master/debian/control
+# 安装依赖
+sudo apt install libsdl2-dev zlib1g-dev libpng-dev libfreetype-dev libfontconfig-dev libicu-dev liblzo2-dev liblzma-dev libfluidsynth-dev libopengl-dev grfcodec openttd-opengfx cmake
+
+# 下载代码&编译
+git clone https://github.com/OpenTTD/OpenTTD.git
+cd OpenTTD
+mkdir build
+cd build
+cmake ..
+make
+
+# 运行
+./openttd
+
+图形和音频资源文件通过游戏内功能下载,支持中文
+状态: +可以运行,支持GLES加速
+资料: +https://github.com/yquake2/yquake2/blob/master/doc/020_installation.md +https://github.com/yquake2/yquake2/blob/master/doc/030_configuration.md
+# 安装依赖
+sudo apt install build-essential libgl1-mesa-dev libsdl2-dev libopenal-dev libcurl4-openssl-dev
+
+# 下载代码&编译
+git clone https://github.com/yquake2/yquake2.git
+mkdir build
+cd build
+cmake ..
+make
+
+# 运行
+#(需要准备好游戏原始资源文件夹baseq2)
+cd ..
+cd release
+cp -r ~/baseq2 .
+./quake2
+
+需要将原始游戏资源文件夹baseq2放到和quake2程序同一个目录中(Steam版可用)
+分辨率和图形加速选项在游戏内设置菜单修改,不修改默认是软渲染,硬渲染设置请改为“OpenGL ES3”(参见下图)
+在RevyOS中安装包只需要在 terminal 中输入
+apt install + 包名
+
+即可安装
+以下以安装 git作为演示
+debian@lpi4a:~$ sudo apt install git
+[sudo] password for debian:
+Reading package lists... Done
+Building dependency tree... Done
+Reading state information... Done
+The following additional packages will be installed:
+ git-man liberror-perl patch
+Suggested packages:
+ gettext-base git-daemon-run | git-daemon-sysvinit git-doc git-email git-gui
+ gitk gitweb git-cvs git-mediawiki git-svn ed diffutils-doc
+The following NEW packages will be installed:
+ git git-man liberror-perl patch
+0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
+Need to get 8605 kB of archives.
+After this operation, 39.4 MB of additional disk space will be used.
+Do you want to continue? [Y/n] y
+Get:1 https://mirror.iscas.ac.cn/revyos/revyos-base sid/main riscv64 liberror-perl all 0.17029-2 [29.0 kB]
+Get:2 https://mirror.iscas.ac.cn/revyos/revyos-base sid/main riscv64 git-man all 1:2.40.1-1 [2072 kB]
+Get:3 https://mirror.iscas.ac.cn/revyos/revyos-base sid/main riscv64 git riscv64 1:2.40.1-1 [6390 kB]
+Get:4 https://mirror.iscas.ac.cn/revyos/revyos-base sid/main riscv64 patch riscv64 2.7.6-7+b1 [114 kB]
+Fetched 8605 kB in 1s (6656 kB/s)
+Selecting previously unselected package liberror-perl.
+(Reading database ... 75688 files and directories currently installed.)
+Preparing to unpack .../liberror-perl_0.17029-2_all.deb ...
+Unpacking liberror-perl (0.17029-2) ...
+Selecting previously unselected package git-man.
+Preparing to unpack .../git-man_1%3a2.40.1-1_all.deb ...
+Unpacking git-man (1:2.40.1-1) ...
+Selecting previously unselected package git.
+Preparing to unpack .../git_1%3a2.40.1-1_riscv64.deb ...
+Unpacking git (1:2.40.1-1) ...
+Selecting previously unselected package patch.
+Preparing to unpack .../patch_2.7.6-7+b1_riscv64.deb ...
+Unpacking patch (2.7.6-7+b1) ...
+Setting up liberror-perl (0.17029-2) ...
+Setting up patch (2.7.6-7+b1) ...
+Setting up git-man (1:2.40.1-1) ...
+Setting up git (1:2.40.1-1) ...
+Processing triggers for man-db (2.11.2-2) ...
+
+
+
+
+
+
+
+ sudo apt install golang-go
+
+测试安装是否成功:
+debian@lpi4a:~$ go version
+go version go1.19.8 linux/riscv64
+
+源中已有 riscv64 的docker安装包,名为 docker.io
,可以直接使用:
sudo apt install docker.io
+
+sudo docker pull riscv64/debian:unstable
+
+如果使用命令sudo docker pull riscv64/debian:unstable
出现以下错误:
debian@lpi4a:~$ docker pull riscv64/debian:unstable
+Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/create?fromImage=riscv64%2Fdebian&tag=unstable": dial unix /var/run/docker.sock: connect: permission denied
+
+
+需要执行以下命令进行修复:
+# 1.
+sudo chmod 666 /var/run/docker.sock
+
+# 2.
+sudo systemctl start docker
+
+# 3.
+sudo docker run hello-world
+
+
+
+
+
+
+
+ 状态:可以运行
+官方资料页:https://docs.gimp.org/2.10/en/
+GIMP 是一个多平台工具,用于创建和编辑各种图像。 GIMP 是 GNU Image Manipulation Program 的首字母缩写。 GIMP 有很多功能。它可以用作简单的绘画程序、专家级的照片修饰程序、创建数字艺术的工具、在线批处理系统、批量生产的图像渲染器、图像格式转换器等。 GIMP 是可扩展和可扩展的。它旨在通过插件和扩展来增强以执行任何操作。先进的脚本界面允许从最简单的任务到最复杂的图像处理程序的所有内容都可以轻松编写脚本。
+GIMP是 RevyOS 预安装图形处理软件,如想使用 GIMP,在terminal中输入
+gimp
+
+在等待资源加载后就会弹出 GIMP 主界面
+使用功能参考官方资料页
+ + + + + + +状态:可以运行
+资料:https://wiki.debian.org/I18n/ibus
+sudo apt install ibus ibus-libpinyin
+sudo reboot
+
+重启后需要手动将中文输入法添加到输入选项中:
+托盘图标->右击->Preference
+
点击选项卡Input Method->Add,打开下图窗口
+
点击Chinese->Intelligent Pinyin->Add
+
Some GStreamer pipeline command-line examples with omxil library on TH1520, RevyOS
+In this section, the grammer of the gstreamer command-line pipeline and some usefule debug tips are introduced. They have been moved to the end of the article.
+Basically, you neet to install gstreamer1.0-plugins-base
, gstreamer1.0-plugins-good
, gstreamer1.0-plugins-bad
, gstreamer1.0-omx-generic
, gstreamer1.0-omx-bellagio-config
,gstreamer1.0-tools
.
# videotestsrc
+gst-launch-1.0 videotestsrc ! autovideosink
+
+# specify the video stream format
+gst-launch-1.0 videotestsrc ! video/x-raw, format=NV12, width=960, height=540, framerate=60/1 ! autovideosink
+
+# display framerate
+gst-launch-1.0 videotestsrc ! fpsdisplaysink
+
+# no need to sync on the clock - used to test the performance of the pipeline
+gst-launch-1.0 videotestsrc ! fpsdisplaysink sync=false
+
+# stop display on the screen, but redirect the output to stdout
+gst-launch-1.0 videotestsrc ! fpsdisplaysink text-overlay=false -v 2>&1
+
+# specify which sink to use
+gst-launch-1.0 videotestsrc ! fpsdisplaysink sink=glimagesink
+
+# combine the previous examples
+gst-launch-1.0 videotestsrc ! fpsdisplaysink sink=glimagesink sync=false text-overlay=false -v 2>&1
+
+# audiotestsrc
+gst-launch-1.0 audiotestsrc ! autoaudiosink
+
+# change volume (0 to 1)
+gst-launch-1.0 audiotestsrc volume=0.1 ! autoaudiosink
+
+# change waveform
+# could be selected among square, silence, pink-noise, etc.
+gst-launch-1.0 audiotestsrc wave=pink-noise ! autoaudiosink
+
+# set fix frequency, such as "do" (262 Hz)
+gst-launch-1.0 audiotestsrc freq=262 ! autoaudiosink
+
+# a dummy sink that swallows everything
+gst-launch-1.0 videotestsrc ! fakesink
+
+# let decodebin choose which decoder to use,
+# and autovideosink choose which video-sink to use (not recommended)
+gst-launch-1.0 filesrc location=fire.mp4 ! decodebin ! autovideosink
+
+# h264 software decode without opengl display
+gst-launch-1.0 filesrc location=fire.mp4 ! qtdemux ! h264parse ! avdec_h264 ! xvimagesink
+
+# h264 hardware decode with opengl display
+gst-launch-1.0 filesrc location=fire.mp4 ! qtdemux ! h264parse ! omxh264dec ! glimagesink
+
+# h265 hardware decode
+gst-launch-1.0 filesrc location=fire.mp4 ! qtdemux ! h265parse ! omxh265dec ! glimagesink
+
+# vp9 hardware decode
+gst-launch-1.0 filesrc location=fire.webm ! matroskademux ! omxvp9dec ! glimagesink
+
+# mpeg4 hardware decode
+gst-launch-1.0 filesrc location=fire.mp4 ! qtdemux ! queue ! mpeg4videoparse ! omxmpeg4videodec ! glimagesink
+
+# play mkv/webm file
+gst-launch-1.0 filesrc location=fire.mkv ! matroskademux ! decodebin ! glimagesink
+
+# todo 10-bit h264/h265 decode
+
+# there is no hardware decoder on th1520
+
+# let autoaudiosink choose which audio-sink to use
+gst-launch-1.0 filesrc location=blade.mp3 ! decodebin ! audioconvert ! autoaudiosink
+
+# mp3 decode
+gst-launch-1.0 filesrc location=blade.mp3 ! mpegaudioparse ! avdec_mp3 ! audioconvert ! autoaudiosink
+
+# aac decode
+gst-launch-1.0 filesrc location=blade.aac ! aacparse ! avdec_aac ! audioconvert ! autoaudiosink
+gst-launch-1.0 filesrc location=blade.aac ! aacparse ! faad ! audioconvert ! autoaudiosink
+## faad works well without aacparse
+gst-launch-1.0 filesrc location=blade.aac ! faad ! audioconvert ! autoaudiosink
+
+# opus decode
+## ogg file must be demuxed by oggdemux first
+gst-launch-1.0 filesrc location=blade.ogg ! oggdemux ! opusparse ! opusdec ! audioconvert ! autoaudiosink
+gst-launch-1.0 filesrc location=blade.ogg ! oggdemux ! opusparse ! avdec_opus ! audioconvert ! autoaudiosink
+
+# wav decode
+gst-launch-1.0 filesrc location=test.wav ! wavparse ! audioresample ! audioconvert ! autoaudiosink
+
+# use specific audiosink
+gst-launch-1.0 filesrc location=blade.mp3 ! decodebin ! audioconvert ! pulsesink
+
+# specify the output device by using alsasink with device property
+gst-launch-1.0 filesrc location=blade.mp3 ! decodebin ! audioconvert ! alsasink device=hw:0,2
+
+We play media file in this section.
+# play mp4 file with both audio and video
+gst-launch-1.0 filesrc location=fire.mp4 ! qtdemux name=demux \
+ demux.video_0 ! queue ! decodebin ! videoconvert ! autovideosink \
+ demux.audio_0 ! queue ! decodebin ! audioconvert ! autoaudiosink
+
+# h264 encode test
+# before import video stream to omxh264dec, data should be transformed to frame with rawvideoparse
+# property and pad of rawvideoparse should be set to the same, so we use 'use-sink-caps=true' here
+gst-launch-1.0 videotestsrc ! videoconvert \
+ ! video/x-raw, format=NV12, width=640, height=480 \
+ ! rawvideoparse use-sink-caps=true ! omxh264enc ! fakesink
+
+# h264 hardware encode to file
+## todo: encoded h264 file has seek problem
+gst-launch-1.0 videotestsrc ! videoconvert \
+ ! video/x-raw, format=NV12, width=640, height=480 \
+ ! rawvideoparse use-sink-caps=true ! omxh264enc \
+ ! h264parse ! qtmux ! mp4mux ! filesink location=test.mp4
+
+# h264 hardware encode to file with specific bitrate(bit per second)
+gst-launch-1.0 videotestsrc ! videoconvert \
+ ! video/x-raw, format=NV12, width=640, height=480 \
+ ! rawvideoparse use-sink-caps=true \
+ ! omxh264enc target-bitrate=3000000 \
+ ! h264parse ! filesink location=test.mp4
+
+
+# h265 hardware encode to file
+## this pipeline produces h265 stream only
+## qtdemux is not needed while decoding
+gst-launch-1.0 videotestsrc ! videoconvert \
+ ! video/x-raw, format=NV12, width=640, height=480 \
+ ! rawvideoparse use-sink-caps=true ! omxh265enc \
+ ! h265parse ! filesink location=test.h265
+
+# h264 hardware encode from camera to file
+gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert \
+ ! video/x-raw, format=NV12,width=640,height=480 \
+ ! rawvideoparse use-sink-caps=true \
+ ! omxh264enc ! h264parse ! filesink location=test.mp4 -e
+
+# There is no hardware audio encoder on th1520
+
+# encode aac stream with adts container(.aac file)
+## the unit of the bitrate is 'bit/sec'
+gst-launch-1.0 audiotestsrc ! voaacenc bitrate=128000 ! avmux_adts ! filesink location=test.aac
+
+
+# todo: encode aac stream with adif container(.m4a file)
+
+# encode to mp3 file
+## the unit of the bitrate is 'kbit/sec'
+gst-launch-1.0 audiotestsrc ! lamemp3enc quality=2 target=bitrate bitrate=192 cbr=true ! id3v2mux ! filesink location=test.mp3
+
+# encode opus stream to .ogg file
+gst-launch-1.0 audiotestsrc ! opusenc ! oggmux ! filesink location=test.opus
+
+
+# todo: encode pcm stream to .wav file
+
+This part has been removed to Video + audio transcode
section.
Since omx...dec
cannot fulfill qtdemux and mp4mux, and gst-omx is no longer maintained, it is hard to mux mp4 file with these two plugins. To mux stream from omxh264dec, use avmux_mp4
instead. But there is no h265 or vp9 muxer available for omx...dec
The raw video stream should be processed by rawvideoparse
before sent to encoder. Because itself cannot scale frame or change framerate, rawvideoparse
need to get the stream info of its sink pad(src pad of the backward element). Therefore use-sink-caps
must be set to true
.
To change width and height, set properties output-width
and output-height
of omx...dec
. To modify bitrate and bitrate control method, set properties control-rate
and target-bitrate
of omx...enc
. To change framerate, set properties of videorate
.
# h265 to h264
+gst-launch-1.0 filesrc location=test_h265.mp4 ! qtdemux ! h265parse ! omxh265dec \
+ ! rawvideoparse use-sink-caps=true \
+ ! omxh264enc ! h264parse ! avmux_mp4 ! filesink location=t_h264.mp4
+
+# vp9 to h264
+gst-launch-1.0 filesrc location=test_vp9.webm ! matroskademux ! omxvp9dec \
+ ! rawvideoparse use-sink-caps=true \
+ ! omxh264enc ! h264parse ! avmux_mp4 ! filesink location=t_h264.mp4
+
+# arbitrary input to h264
+gst-launch-1.0 filesrc location=test_h264.mp4 ! decodebin \
+ ! rawvideoparse use-sink-caps=true \
+ ! omxh264enc ! h264parse ! filesink location=t_h264.mp4
+
+# h264 to h264, with more options
+## set the video width and height to 1280×720, framerate to 15fps, bitrate mode to constant and bitrate to 5Mbps
+gst-launch-1.0 filesrc location=test_h264.mp4 ! qtdemux ! h264parse \
+ ! omxh264dec output-width=1280 output-height=720 \
+ ! videorate ! video/x-raw, framerate=15/1 \
+ ! rawvideoparse use-sink-caps=true \
+ ! omxh264enc control-rate=constant target-bitrate=5000000 ! h264parse ! filesink location=t_h264.mp4
+
+## there is no vp9 encoder in th1520 omxil lib
+
+# aac to mp3
+gst-launch-1.0 filesrc location=test.aac ! aacparse ! avdec_aac ! audioconvert ! lamemp3enc quality=2 target=bitrate bitrate=192 cbr=true ! id3v2mux ! filesink location=t.mp3
+
+# mp3 to aac
+gst-launch-1.0 filesrc location=test.mp3 ! mpegaudioparse ! avdec_mp3 ! audioconvert ! voaacenc bitrate=128000 ! avmux_adts ! filesink location=t.aac
+
+# wav to mp3
+gst-launch-1.0 filesrc location=test.wav ! wavparse ! audioresample ! audioconvert ! lamemp3enc quality=2 target=bitrate bitrate=192 cbr=true ! id3v2mux ! filesink location=t.mp3
+
+# mp3 to wav
+gst-launch-1.0 filesrc location=test.mp3 ! mpegaudioparse ! avdec_mp3 ! audioresample ! audioconvert \
+ ! audio/x-raw, rate=44100, format=S16LE ! wavenc ! filesink location=t.wav
+
+# mux test
+gst-launch-1.0 audiotestsrc ! autoaudiosink videotestsrc ! autovideosink
+
+# mux the test video and audio stream to a mp4 file
+## be aware that '-e' must be set to this pipeline,
+## and there is no '!' before audiotestsrc
+gst-launch-1.0 -e videotestsrc ! videoconvert \
+ ! video/x-raw, format=NV12, width=960, height=540 \
+ ! rawvideoparse use-sink-caps=true ! omxh264enc ! h264parse \
+ ! avmux_mp4 name=mux ! filesink location=t_h264.mp4 \
+ audiotestsrc ! lamemp3enc ! mux.
+
+# change container from mkv to mp4 with h264 stream
+## this means demux a mkv file then mux video and audio stream to mp4 file
+gst-launch-1.0 filesrc location=test_h264.mkv \
+ ! matroskademux name=demux mp4mux force-create-timecode-trak=true name=mux ! filesink location=t_h264.mp4 \
+ demux.video_0 ! queue ! video/x-h264 ! mux. \
+ demux.audio_0 ! queue ! audio/mpeg ! mux.
+
+You can use command v4l2-ctl
, which is included in package v4l-utils
to get information of your camera.
For more information, read this article
+# h264 hardware encode from camera to file
+gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert \
+ ! video/x-raw, format=NV12,width=640,height=480 \
+ ! rawvideoparse format=nv12 width=640 height=480 \
+ ! omxh264enc ! h264parse ! filesink location=test.mp4 -e
+
+
+# capture camera and stream to other machine
+
+## source
+gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! videorate \
+ ! video/x-raw, format=NV12,width=640,height=480,framerate=20/1 \
+ ! rawvideoparse format=nv12 width=640 height=480 framerate=20/1 \
+ ! omxh264enc ! h264parse config-interval=1 ! video/x-h264,stream-format=byte-stream,alignment=nal \
+ ! rtph264pay ! udpsink host=192.168.31.27 port=5600
+
+## destination
+gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' \
+ ! rtph264depay ! h264parse ! avdec_h264 ! autovideosink
+
+gst-inspect-1.0
is a tool to print info about a GStreamer element(factory), which is included in gstreamer1.0-tools
.
# print the GStreamer element list with a 'less' like paing filter.
+gst-inspect-1.0
+
+# print info of the element
+gst-inspect-1.0 <element_name>
+
+gst-discover-1.0
is a tool to show info about the media file, which is inclucded in gstreamer1.0-plugins-base-apps
.
gst-discoverer-1.0 -v test.mp4
+
+If you are tired of manually build pipeline for playback by hand. You can use gst-play-1.0
as an alternative, which is included in gstreamer1.0-plugins-base-apps
.
# play media file
+gst-play-1.0 test.mp4
+
+# play media file with specific sink
+gst-play-1.0 --videosink=glimagesink --audiosink=alsasink
+
+Left button and right button can be used to seek. For more info, please read this article.
+To get the cap info or property of an element, you may need to run gst-inspect-1.0 <element_name>
. If gst-inspect-1.0
command not found, install gstreamer1.0-tools
.
If you want to debug GStreamer, refer to the articles below. +https://gstreamer.freedesktop.org/documentation/tutorials/basic/debugging-tools.html +https://gstreamer.freedesktop.org/documentation/gstreamer/running.html?gi-language=c
+Here is a simple command-line pipeline.
+gst-launch-1.0 videotestsrc ! autovideosink
+
+!
represent a link. The established pipeline looks like
videotestsrc => autovideosink
+
+There are several properties in videotestsrc, which could be lookup by gst-inspect-1.0 videotestsrc
.Set some properties:
gst-launch-1.0 videotestsrc pattern=ball flip=true ! autovideosink
+
+NAME=VALUE
is a property. pattern
and flip
are properties of videotestsrc.
Sometimes we need to control the behavior of gst-launch-1.0
.
GST_DEBUG=3 gst-launch-1.0 videotestsrc pattern=ball flip=true ! autovideosink
+gst-launch-1.0 videotestsrc pattern=ball flip=true ! autovideosink --gst-debug-level=3
+
+There are two ways to achieve this goal. One is setting environment variable. Another one is passing command-line argument to gst-launch-1.0
. GST_DEBUG=3
and --gst-debug-level=3
have the same meaning.
In most video decoding cases, there is a video-stream and an audio stream. We need to use demuxer to seperate them. Demuxer usually have several src pad. Here is an example.
+gst-launch-1.0 filesrc location=test-video.mp4 ! qtdemux name=demux demux. ! queue ! h264parse ! omxh264dec ! glimagesink demux. ! queue ! aacparse ! avdec_aac ! audioconvert ! alsasink
+
+It is hard to read. Add some word wrap:
+gst-launch-1.0 filesrc location=test-video.mp4 ! qtdemux name=demux \
+ demux. ! queue ! h264parse ! omxh264dec ! glimagesink \
+ demux. ! queue ! aacparse ! avdec_aac ! audioconvert ! pulsesink
+
+Here we use a demuxer to seperate video and audio, the grammer is:
+... demuxer name=DEMUXER_NAME \
+DEMUXER_NAME.PIPELINE_NAME_1 ! queue ! ...(the remaining part of pipeline 1) \
+DEMUXER_NAME.PIPELINE_NAME_2 ! queue ! ...(the remaining part of pipeline 2)
+
+Sometimes we need to set certain properties of the stream at certain nodes in the pipeline, e.g set resolution of the videostream of the videotestsrc
.
gst-launch-1.0 videotestsrc ! video/x-raw, width=800, height=600 ! glimagesink
+
+We negotiated the pad properties between videotestsrc
and glimagesink
. The property names and values must be supported by both element. You can find them in Pad Templates
section of gst-inspect-1.0
.
适用SDK v1.1.2
+PTG 的 OpenMAX IL 库(下称 vpu-omxil
)可使 LicheePi 4A 能够流畅硬解码 4k 60fps 的视频,那么具体应该如何使用该库呢?本文将主要介绍 LicheePi 4A 开发板上 Parole 播放器的集成与使用,用户可根据本文来了解在 LicheePi 4A 上的适配过程
+以 h264 的硬解为例,视频硬解的工作流程如图所示
+-------------------------------------------+
+ | +------------+ +------------+ | +--------+
+video stream----+--->| omxh264dec +------>| video-sink +----+-->| player |
+ | +------+-----+ +------------+ | +--------+
+ | | GStreamer |
+ +-----------+-------------------------------+
+ |
+ +-----v-----+
+ | vpu-omxil |
+ +-----+-----+
+ |
+ |
+ +-------v-------+
+ | kernel module |
+ | (driver) |
+ +-------+-------+
+ |
+ v
+ hardware
+
+omxh264dec
中将 omxh264 解码的部分单独拎出来,大体的结构如下
+ +---+------------+----+
+ | +------------+ |
+ | | omxh264dec | |
+ | +------------+ |
+ | GStreamer |
+ +----------+----------+
+ |
+ +----+-----v-----+----+
+ | +-----------+ |
+ | | vpu-omxil | |
+ | +-----------+ |
+ | libomxil-bellagio |
+ +----------+----------+
+ |
++------------v------------+
+| - memalloc - vc8000 |
+| - hantrodec - vidmem |
+| kernel modules |
++------------+------------+
+ |
+ v
+ hardware
+
+我们依照自底向上的顺序构建图示的链条。 +本节的主要目的是使 omxh264dec 解码器能够运行,并不涉及到输出屏幕等内容。
+硬解码需要访问硬件,而访问硬件又需要驱动,所以需要编译并安装驱动
+PTG 提供的驱动源:
+https://github.com/revyos/vpu-vc8000e-kernel
+https://github.com/revyos/vpu-vc8000d-kernel
+https://github.com/revyos/video_memory
+revyos/thead-kernel 已经合并了上述三个内核模块, 使用revyos_defconfig 可以无需编译上述内核模块
+# depmod 分析可载入模块的依赖关系,在 /lib/modules/<kernel-version>中添加modules.dep文件,以便后续 modprobe 使用
+sudo depmod -a
+sudo modprobe vidmem vc8000 hantrodec memalloc
+
+## 如果 modprobe 安装有问题的话,可以尝试使用 insmod 安装
+#cd /usr/lib/modules/$(uname -r)
+#sudo insmod $(find . -name *vidmem.ko*)
+#sudo insmod $(find . -name *vc8000.ko*)
+#sudo insmod $(find . -name *hantrodec.ko*)
+#sudo insmod $(find . -name *memalloc.ko*)
+
+# 可选:设置开机加载模块
+echo -e "\nvidmem\nhantrodec\nmemalloc\nvc8000\n" | sudo tee -a /etc/modules > /dev/null
+
+安装内核模块后,/dev
目录下会出现 hantrodec
vidmem
vc8000
三个设备文件。默认情况下,用户对其没有访问权限,如果不修改权限的话,非 root 用户在打开 omxil 库时会报错。
# 生效一次
+cd /dev
+sudo chmod 666 hantrodec vidmem vc8000
+
+# 长期生效
+cat << EOF | sudo tee /lib/udev/rules.d/70-hantro.rules > /dev/null
+KERNEL=="vidmem", MODE="0666"
+KERNEL=="hantrodec", MODE="0666"
+KERNEL=="vc8000", MODE="0666"
+EOF
+
+如果要获取 RevyOS 特定版本的内核模块,可进入 revyos/thead-kernel ,并在 GitHub CI 中下载 artifacts
+首先,请将 vpu-omxil 下载并解压到 /usr/lib/omxil/中 +vpu-omxil_1.2.1.tar.gz +如下图所示, 需要
+vpu-omxil
中的 OpenMax 组件注册到 libomxil-bellagio
中gst-omx
(该包提供了 omxh264dec 解码器) 调用 libomxil-bellagio
的时候也需要知道调用的组件名称+---------+ +-------------------+ +-----------+
+| gst-omx +-->| libomxil-bellagio +-->| vpu-omxil |
++---------+ +-------------------+ +-----------+
+
+vpu-omxil
中的组件注册到 libomxil-bellagio
中sudo apt install libomxil-bellagio-bin libomxil-bellagio0
+# 注册组件
+omxregister-bellagio -v /usr/lib/omxil/
+
+使用 omxregister-bellagio 生成注册文件,默认路径为 ~/.omxregister
+th1520-vpu 利用了 debian 在 usr/lib/riscv64-linux-gnu/libomxil-bellagio0
安装之后
+触发自动注册行为 结果如下
cat /var/lib/libomxil-bellagio0/registry
+/usr/lib/riscv64-linux-gnu/libomxil-bellagio0/libOMX.hantro.H2.video.encoder.so
+ ==> OMX.hantro.H2.video.encoder ==> OMX.hantro.H2.video.encoder.avc:OMX.hantro.H2.video.encoder.hevc:
+/usr/lib/riscv64-linux-gnu/libomxil-bellagio0/libOMX.hantro.VC8000D.image.decoder.so
+ ==> OMX.hantro.VC8000D.image.decoder ==> OMX.hantro.VC8000D.image.decoder.jpeg:
+/usr/lib/riscv64-linux-gnu/libomxil-bellagio0/libOMX.hantro.H2.image.encoder.so
+ ==> OMX.hantro.H2.image.encoder ==> OMX.hantro.H2.image.encoder.jpeg:
+/usr/lib/riscv64-linux-gnu/libomxil-bellagio0/libOMX.hantro.VC8000D.video.decoder.so
+ ==> OMX.hantro.VC8000D.video.decoder ==> OMX.hantro.VC8000D.video.decoder.mpeg4:OMX.hantro.VC8000D.video.decoder.avc:OMX.hantro.VC8000D.video.decoder.avs:OMX.hantro.VC8000D.video.decoder.h263:OMX.hantro.VC8000D.video.decoder.wmv:OMX.hantro.VC8000D.video.decoder.vp6:OMX.hantro.VC8000D.video.decoder.vp8:OMX.hantro.VC8000D.video.decoder.jpeg:OMX.hantro.VC8000D.video.decoder.hevc:OMX.hantro.VC8000D.video.decoder.vp9:OMX.hantro.VC8000D.video.decoder.avs2:
+
+调整 gstomx.conf 的设置以使解码器 omxh264dec 调用正确的组件,具体请查看针对 gst-omx 的补丁
+gst-omx-01-add-libomxil-config.patch
+请查看 PTG 提供的针对 gst-omx 的 dmabuf 补丁 +gst-omx-02-set-dec-out-port-dmabuf.patch
+sudo apt install gstreamer1.0-omx-generic gstreamer1.0-omx-bellagio-config gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-gl gstreamer1.0-plugins-good gstreamer1.0-tools
+
+# 1 基本解码
+gst-launch-1.0 filesrc location=<test.mp4> ! qtdemux ! h264parse ! omxh264dec ! videoconvert ! fakesink sync=false
+# 2 在终端中显示 fps
+# 参考:https://stackoverflow.com/questions/73948308
+gst-launch-1.0 filesrc location=<test.mp4> ! qtdemux ! h264parse ! omxh264dec ! videoconvert ! fpsdisplaysink video-sink=fakesink text-overlay=false sync=false -v 2>&1
+
+fakesink
会把前面的视频流全部吞掉,不输出画面(因而不会在 video-sink 这一环节损失性能),但是结合fpsdisplaysink可以读取到解码的速度。正常日志如下:
Setting pipeline to PAUSED ...[DBGT]
+vc8kdec compiled without trace support (ENABLE_DBGT_TRACE switch not enabled)
+Pipeline is PREROLLING ...
+Redistribute latency...
+OMX ! decoder_get_parameter OMX_ErrorNoMore (2)
+Pipeline is PREROLLED ...
+Setting pipeline to PLAYING ...
+New clock: GstSystemClockRedistribute latency...
+0:01:39.5 / 0:01:49.4 (90.9 %)
+
+【TIP】如果有 [omxh264dec-omxh264dec0: Could not initialize supporting library.](https://gist.github.com/Sakura286/015fae6792e160268db7ad8a697dd2df)
等字样的报错,可以安装gst-omx
、libomxil-bellagio
与libc6
相关的 debug-symbol 包,使用 gdb
启动上述命令进行调试。调试时,先断DWLInit
,然后再断open
,具体看是打开哪个地方的时候出错了。
RevyOS 适配过程中对于初始化动态库失败找到了如下三种原因:
+omxregister-bellagio
注册 vpu-omxil/dev
目录下 hantrodec
vc8000
vidmem
等设备的权限video-sink
是视频流在整个 GStreamer pipeline 中的最后一步,其作用一般是将视频流输出到屏幕上。
+前文中fakesink
只是测试解码器是否正常工作的特殊 video-sink
,可选的 video-sink非常多,常见的有 autovideosink
,ximagesink
,xvimagesink
,fbdevsink
,waylandsink
,glimagesink
,gtkglsink
等,它们各在不同的插件包里,需要酌情安装:
video-sink | +所属包名 | +
---|---|
waylandsink | +gstreamer1.0-plugins-bad | +
fbdevsink | +gstreamer1.0-plugins-bad | +
autovideosink | +gstreamer1.0-plugins-good | +
gtkglsink | +gstreamer1.0-plugins-good | +
ximagesink | xvimagesink | +gstreamer1.0-plugins-base | +
glimagesink | +gstreamer1.0-plugins-base | gstreamer1.0-gl | +
【TIP】使用 gst-inspect-1.0 <video-sink-name>
来查看对应 video-sink 可用的选项
+【TIP】添加 --gst-debug-level=<lv>
来获得更多的输出日志,其中 <lv>
代表了从 1 到 6,啰嗦程度从低到高,建议在等级 4 及以下,否则日志会非常长
+请尝试不同的 video-sink ,并尝试不同的插件参数,以及给予不同的环境变量,直至找到可以流畅硬解 H264 的那一个。
**waylandsink**
:由于现在(20230720)RevyOS 采用了 Xfce 桌面,不可能支持 Wayland,故 waylandsink
从原理上无法使用**fbdevsink**
与**ximagesink**
:无法使用**xvimagesink**
:通过流水线图以及日志可以确定,playbin 或 autovideosink 会自动调用 xvimagesink,使用 perf 分析后可以发现,使用xvimagesink 不可避免地会进行大量的 memcpy 操作,严重降低解码性能;该问题在获得PTG的 dmabuf 补丁后依然存在,故无法使用**gtkglsink**
:GTK3 不支持 EGL on X11,而 RevyOS 目前基于 x11,且只支持 EGL,故无法使用剩下的只有glimagesink
,根据 Running and debugging GStreamer Applications,并观察其他使用到 glimagesink 的例子,可以猜测需要明确指定环境变量 GST_GL_API
与 GST_GL_PLATFORM
+由于 RevyOS 使用了 gles2+egl 的组合,使用如下的命令,成功硬解。
GST_GL_API=gles2 GST_GL_PLATFORM=egl gst-launch-1.0 filesrc location=<test.mp4> ! qtdemux ! h264parse ! omxh264dec ! videoconvert ! fpsdisplaysink video-sink=glimagesink sync=false
+
+然而 GStreamer 被播放器调用时是无法通过环境变量来传递参数的,所以构建 gst-plugins-base 时应当传递额外的 meson 编译参数:
+-Dgl_api=[\'gles2\'] -Dgl_platform=[\'egl\']
+
+GStreamer 的 pipeline 没有问题之后,就需要使播放器支持。不同播放器会使用到不同的 video-sink,同样对 gstreamer 有着不同程度的依赖。 +适配播放器时,最重要的工作便是①使播放器适配已验证的 video-sink,或者②使 gstreamer pipeline 支持播放器指定的 video-sink,此次 RevyOS 适配过程采用了①方案。
+ +-------------------------------------------+
+ | +------------+ +------------+ | +--------+
+video stream----+--->| omxh264dec +------>| video-sink +----+-->| player |
+ | +------------+ +------------+ | +--------+
+ | GStreamer |
+ +-------------------------------------------+
+
+根据 https://gstreamer.freedesktop.org/apps/ 进行简单的排查
+是否可用 | +是否更新 | +应用名 | +备注 | +
---|---|---|---|
❌ | ++ | Gnash | +Flash 播放器 | +
❌ | ++ | GEntrans | +Debian 未收录 | +
❓ | +20230226 | +Kaffeine | +❌ 需要大量 KDE 相关组件 | +
+ | + | + | ✔️ 存在于riscv64 仓库中 | +
+ | + | + | ❌ 在 Debian amd64 Gnome 上,播放窗口与控制窗口分离,且默认调用了 VLC 进行播放 | +
❌ | ++ | Lcdgrilo | +Debian 未收录 | +
✔️ | +20230218 | +Parole | +✔️ For XFCE | +
+ | + | + | ❓ 不支持 Wayland,仅支持 x11 | +
+ | + | + | ✔️ Debian amd64 Gnome 验证通过 | +
+ | + | + | ✔️ 存在于riscv64 仓库 中 | +
❌ | ++ | Songbird | +Debian 未收录 | +
❌ | ++ | Snappy | +Debian 未收录 | +
❌ | ++ | Totem | +需要 GTK3,然而 GTK3 不支持 EGL on X11 | +
最初选择的播放器是 Totem,但是发现 Totem 无法指定除了 gtkglsink 以外的 video-sink,且由于 RevyOS 不支持 gtkglsink,所以支持 Totem 播放器的难度较大。 +对支持 GStreamer 的播放器进行排查后发现了 Parole , Parole 由 GObject 编写,与常见的面向对象编程略有区别。寻找其构建 parole_gst 对象时的方法 parole_gst_constructed,将 video-sink 属性设置为前文已验证的 glimagesink,补丁:
+parole-01-add-glimagesink-support.patch
+至此,粗略的适配工作完成。
+补丁集合:
+https://gist.github.com/Sakura286/26777ea8204c1819885e093806a4f7ca
+PTG omxil 库
+https://drive.google.com/file/d/1pYgCVI7WltfpskltJ-RqzVUCEC21FS56
+ + + + + + +测试网站地址:https://webglsamples.org/aquarium/aquarium.html
+直接打开即可,左侧数字是渲染的鱼的数量,数量越多越占性能
+CoreMark是一个综合基准,用于测量嵌入式系统中使用的中央处理器(CPU)的性能。它是在2009由eembc的shay gal-on开发的,旨在成为一个行业标准,取代过时的dehrystone基准。代码用C编写,包含以下算法:列表处理(增删改查和排序)、矩阵操作(公共矩阵操作)、状态机(确定输入流是否包含有效数字)和CRC。用户可以自由的下载Coremark,并移植到自己的平台上运行,随后就可以看到分数。
+├── barebones --移植到裸机环境下需要修改的目录
+│ ├── core_portme.c --移植的目标平台配置信息
+│ ├── core_portme.h --计时以及板级初始化实现
+│ ├── core_portme.mak --该子目录的makefile
+│ ├── cvt.c
+│ └── ee_printf.c --打印函数串口发送实现
+├── core_list_join.c --列表操作程序
+├── core_main.c --主程序
+├── coremark.h --项目配置与数据结构的定义头文件
+├── coremark.md5
+├── core_matrix.c --矩阵运算程序
+├── core_state.c --状态机控制程序
+├── core_util.c --CRC计算程序
+├── cygwin --x86 cygwin和gcc 3.4(四核,双核和单核系统)的测试代码
+│ ├── core_portme.c
+│ ├── core_portme.h
+│ └── core_portme.mak
+├── freebsd --以下同理,是在不同操作系统下的测试代码
+│ ├── ...
+├── LICENSE.md
+├── linux
+│ ├── ...
+├── linux64
+│ ├── ...
+├── macos
+│ ├── ...
+├── Makefile
+├── README.md --自述文件,CoreMark项目的基本介绍
+├── rtems
+│ ├── ...
+└── simple
+ ├── ...
+ └──
+
+根据 README 说法,只需要在 coremark 文件夹下执行 make 即可进行编译与测试。测试结果会出现在 Results 文件夹中,其中 run1.log 是测试结果。
+coremark 总体测试时间较短。 +计划同时测试 10 次取平均数值。
+$ git clone https://github.com/eembc/coremark.git
+$ cd coremark
+$ make
+
+2K performance run parameters for coremark.
+CoreMark Size : 666
+Total ticks : 12915
+Total time (secs): 12.915000
+Iterations/Sec : 8517.228029
+Iterations : 110000
+Compiler version : GCC13.1.0
+Compiler flags : -O2 -DPERFORMANCE_RUN=1 -lrt
+Memory location : Please put data memory location here
+ (e.g. code in flash, data on heap etc)
+seedcrc : 0xe9f5
+[0]crclist : 0xe714
+[0]crcmatrix : 0x1fd7
+[0]crcstate : 0x8e3a
+[0]crcfinal : 0x33ff
+Correct operation validated. See README.md for run and reporting rules.
+CoreMark 1.0 : 8517.228029 / GCC13.1.0 -O2 -DPERFORMANCE_RUN=1 -lrt / Heap
+
+
+make XCFLAGS="-march=rv64gv0p7_zfh_xtheadc -O3 -funroll-all-loops -finline-limit=500 -fgcse-sm -fno-schedule-insns -msignedness-cmpiv -fno-code-hoisting -mno-thread-jumps1 -mno-iv-adjust-addr-cost -mno-expand-split-imm"
+
+2K performance run parameters for coremark.
+CoreMark Size : 666
+Total ticks : 15129
+Total time (secs): 15.129000
+Iterations/Sec : 13219.644392
+Iterations : 200000
+Compiler version : GCC10.4.0
+Compiler flags : -O2 -march=rv64gv0p7_zfh_xtheadc -O3 -funroll-all-loops -finline-limit=500 -fgcse-sm -fno-schedule-insns -msignedness-cmpiv -fno-code-hoisting -mno-thread-jumps1 -mno-iv-adjust-addr-cost -mno-expand-split-imm -DPERFORMANCE_RUN=1 -lrt
+Memory location : Please put data memory location here
+ (e.g. code in flash, data on heap etc)
+seedcrc : 0xe9f5
+[0]crclist : 0xe714
+[0]crcmatrix : 0x1fd7
+[0]crcstate : 0x8e3a
+[0]crcfinal : 0x4983
+Correct operation validated. See README.md for run and reporting rules.
+CoreMark 1.0 : 13219.644392 / GCC10.4.0 -O2 -march=rv64gv0p7_zfh_xtheadc -O3 -funroll-all-loops -finline-limit=500 -fgcse-sm -fno-schedule-insns -msignedness-cmpiv -fno-code-hoisting -mno-thread-jumps1 -mno-iv-adjust-addr-cost -mno-expand-split-imm -DPERFORMANCE_RUN=1 -lrt / Heap
+
+make XCFLAGS="-march=rv64imafd_xtheadba_xtheadbb_xtheadbs_xtheadcmo_xtheadcondmov_xtheadfmemidx_xtheadfmv_xtheadint_xtheadmac_xtheadmemidx_xtheadmempair_xtheadsync -O3 -funroll-all-loops -finline-limit=500 -fgcse-sm -fno-schedule-insns -fno-code-hoisting -mno-thread-jumps"
+
+2K performance run parameters for coremark.
+CoreMark Size : 666
+Total ticks : 11897
+Total time (secs): 11.897000
+Iterations/Sec : 9246.028411
+Iterations : 110000
+Compiler version : GCC13.1.0
+Compiler flags : -O2 -march=rv64imafd_xtheadba_xtheadbb_xtheadbs_xtheadcmo_xtheadcondmov_xtheadfmemidx_xtheadfmv_xtheadint_xtheadmac_xtheadmemidx_xtheadmempair_xtheadsync -O3 -funroll-all-loops -finline-limit=500 -fgcse-sm -fno-schedule-insns -fno-code-hoisting -DPERFORMANCE_RUN=1 -lrt
+Memory location : Please put data memory location here
+ (e.g. code in flash, data on heap etc)
+seedcrc : 0xe9f5
+[0]crclist : 0xe714
+[0]crcmatrix : 0x1fd7
+[0]crcstate : 0x8e3a
+[0]crcfinal : 0x33ff
+Correct operation validated. See README.md for run and reporting rules.
+CoreMark 1.0 : 9246.028411 / GCC13.1.0 -O2 -march=rv64imafd_xtheadba_xtheadbb_xtheadbs_xtheadcmo_xtheadcondmov_xtheadfmemidx_xtheadfmv_xtheadint_xtheadmac_xtheadmemidx_xtheadmempair_xtheadsync -O3 -funroll-all-loops -finline-limit=500 -fgcse-sm -fno-schedule-insns -fno-code-hoisting -DPERFORMANCE_RUN=1 -lrt / Heap
+
+
+
+
+
+
+
+ glmark2 is an OpenGL 2.0 and ES 2.0 benchmark. +We will only use glmark2-es2 for relevant tests here . This is a testing tool for x11-glesv2.
+This software package is already pre-installed in the system.
+th1520
only support glmark-es2.
If you need perfect performance, put your device into performance mode before you start, here's how to do it.
+Please execute the following commands in the terminal. This command requires a root account.
+echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
+
+cat /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq
+
+After the execution is completed, you will see a series of numbers, such as "1848000".
+Open a terminal and enter glmark2-es2. This test allows the use of non-root accounts.
+After entering the command, a new window will appear on your desktop with an active screen.
+After the test is completed, the additional activity screen will disappear and the score will be output in the terminal in the form of "glmark2 Score: xxx".
+For example:
+debian@lpi4a:~/Desktop$ glmark2-es2
+=======================================================
+ glmark2 2021.12
+=======================================================
+ OpenGL Information
+ GL_VENDOR: Imagination Technologies
+ GL_RENDERER: PowerVR B-Series BXM-4-64
+ GL_VERSION: OpenGL ES 3.2 build 1.17@6210866
+ Surface Config: buf=32 r=8 g=8 b=8 a=8 depth=24 stencil=8
+ Surface Size: 800x600 windowed
+=======================================================
+[build] use-vbo=false: FPS: 513 FrameTime: 1.949 ms
+[build] use-vbo=true: FPS: 1367 FrameTime: 0.732 ms
+[texture] texture-filter=nearest: FPS: 1449 FrameTime: 0.690 ms
+[texture] texture-filter=linear: FPS: 1454 FrameTime: 0.688 ms
+[texture] texture-filter=mipmap: FPS: 1453 FrameTime: 0.688 ms
+[shading] shading=gouraud: FPS: 1172 FrameTime: 0.853 ms
+[shading] shading=blinn-phong-inf: FPS: 1180 FrameTime: 0.847 ms
+[shading] shading=phong: FPS: 1002 FrameTime: 0.998 ms
+[shading] shading=cel: FPS: 979 FrameTime: 1.021 ms
+[bump] bump-render=high-poly: FPS: 700 FrameTime: 1.429 ms
+[bump] bump-render=normals: FPS: 1354 FrameTime: 0.739 ms
+[bump] bump-render=height: FPS: 1320 FrameTime: 0.758 ms
+[effect2d] kernel=0,1,0;1,-4,1;0,1,0;: FPS: 1059 FrameTime: 0.944 ms
+[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;: FPS: 381 FrameTime: 2.625 ms
+[pulsar] light=false:quads=5:texture=false: FPS: 1484 FrameTime: 0.674 ms
+[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4: FPS: 349 FrameTime: 2.865 ms
+[desktop] effect=shadow:windows=4: FPS: 736 FrameTime: 1.359 ms
+[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 161 FrameTime: 6.211 ms
+[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=subdata: FPS: 173 FrameTime: 5.780 ms
+[buffer] columns=200:interleave=true:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 242 FrameTime: 4.132 ms
+[ideas] speed=duration: FPS: 593 FrameTime: 1.686 ms
+[jellyfish] <default>: FPS: 572 FrameTime: 1.748 ms
+[terrain] <default>: FPS: 42 FrameTime: 23.810 ms
+[shadow] <default>: FPS: 619 FrameTime: 1.616 ms
+[refract] <default>: FPS: 82 FrameTime: 12.195 ms
+[conditionals] fragment-steps=0:vertex-steps=0: FPS: 1539 FrameTime: 0.650 ms
+[conditionals] fragment-steps=5:vertex-steps=0: FPS: 1238 FrameTime: 0.808 ms
+[conditionals] fragment-steps=0:vertex-steps=5: FPS: 1535 FrameTime: 0.651 ms
+[function] fragment-complexity=low:fragment-steps=5: FPS: 1411 FrameTime: 0.709 ms
+[function] fragment-complexity=medium:fragment-steps=5: FPS: 1050 FrameTime: 0.952 ms
+[loop] fragment-loop=false:fragment-steps=5:vertex-steps=5: FPS: 1376 FrameTime: 0.727 ms
+[loop] fragment-steps=5:fragment-uniform=false:vertex-steps=5: FPS: 1394 FrameTime: 0.717 ms
+[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5: FPS: 1379 FrameTime: 0.725 ms
+=======================================================
+ glmark2 Score: 950
+=======================================================
+
+
+
+
+
+
+
+
+ ++lmbench for revyOS
+
带宽测评工具 | +反应时间测评工具 | +其他 | +
---|---|---|
读取缓存文件 | +上下文切换 | +\ | +
拷贝内存 | +网络:连接的建立,管道,TCP,UDP 和RPC hot potato | +\ | +
读内存 | +文件系统的建立和删除 | +\ | +
写内存 | +进程创建 | +处理器时钟比率计算 | +
管道 | +信号处理 | +\ | +
TCP | +上层的系统调用 | +\ | +
\ | +内存读入反应时间 | +\ | +
下载测试工具:
+git clone https://github.com/revyos/lmbench3.git
+
+++该版本为已为 RevyOS 移植版本。
+
在开始测试前,需要先安装依赖:
+sudo apt install gcc make libntirpc-dev -y
+
+执行命令进行编译,配置,并测试
+cd lmbench3
+cd src
+make results
+
+编译完成后会有以下选项提示需要设置:
+以下不需要更改的项目直接回车,会自动设置默认值。
+MULTIPLE COPIES [default 1]
: 设置同时运行 lmbench 的份数,份数多会使 lmbench 运行缓慢,默认是 1,这里设置为默认值 1。
=====================================================================
+
+If you are running on an MP machine and you want to try running
+multiple copies of lmbench in parallel, you can specify how many here.
+
+Using this option will make the benchmark run 100x slower (sorry).
+
+NOTE: WARNING! This feature is experimental and many results are
+ known to be incorrect or random!
+
+MULTIPLE COPIES [default 1]:
+=====================================================================
+
+Job placement selection [default 1]
: 作业调度控制方法,默认值是 1,表示允许作业调度,这里设置为默认值。
=====================================================================
+
+Options to control job placement
+1) Allow scheduler to place jobs
+2) Assign each benchmark process with any attendent child processes
+ to its own processor
+3) Assign each benchmark process with any attendent child processes
+ to its own processor, except that it will be as far as possible
+ from other processes
+4) Assign each benchmark and attendent processes to their own
+ processors
+5) Assign each benchmark and attendent processes to their own
+ processors, except that they will be as far as possible from
+ each other and other processes
+6) Custom placement: you assign each benchmark process with attendent
+ child processes to processors
+7) Custom placement: you assign each benchmark and attendent
+ processes to processors
+
+Note: some benchmarks, such as bw_pipe, create attendent child
+processes for each benchmark process. For example, bw_pipe
+needs a second process to send data down the pipe to be read
+by the benchmark process. If you have three copies of the
+benchmark process running, then you actually have six processes;
+three attendent child processes sending data down the pipes and
+three benchmark processes reading data and doing the measurements.
+
+Job placement selection [default 1]:
+=====================================================================
+
+Memory
: 设置测试内存大小,默认是 $MB
, 即为程序计算出来的最大可测试内存,也可以手动定义测试值,这里设置为这里使用默认值。
=====================================================================
+
+Several benchmarks operate on a range of memory. This memory should be
+sized such that it is at least 4 times as big as the external cache[s]
+on your system. It should be no more than 80% of your physical memory.
+
+The bigger the range, the more accurate the results, but larger sizes
+take somewhat longer to run the benchmark.
+
+MB [default 686]:
+Checking to see if you have 686 MB; please wait for a moment...
+686MB OK
+686MB OK
+686MB OK
+Hang on, we are calculating your cache line size.
+OK, it looks like your cache line is 64 bytes.
+
+=====================================================================
+
+SUBSET (ALL|HARWARE|OS|DEVELOPMENT) [default all]
: 要运行的测试集,包含 ALL/HARWARE/OS/DEVELOPMENT
,默认选 all
,这里选 all
。
=====================================================================
+
+lmbench measures a wide variety of system performance, and the full suite
+of benchmarks can take a long time on some platforms. Consequently, we
+offer the capability to run only predefined subsets of benchmarks, one
+for operating system specific benchmarks and one for hardware specific
+benchmarks. We also offer the option of running only selected benchmarks
+which is useful during operating system development.
+
+Please remember that if you intend to publish the results you either need
+to do a full run or one of the predefined OS or hardware subsets.
+
+SUBSET (ALL|HARWARE|OS|DEVELOPMENT) [default all]:
+=====================================================================
+
+FASTMEM [default no]
: 内存 latency
测试,如果跳过该测试,则设置为 yes
,如果不跳过则设置为 no
,默认是 no
,这里设置为默认值。
=====================================================================
+
+This benchmark measures, by default, memory latency for a number of
+different strides. That can take a long time and is most useful if you
+are trying to figure out your cache line size or if your cache line size
+is greater than 128 bytes.
+
+If you are planning on sending in these results, please don't do a fast
+run.
+
+Answering yes means that we measure memory latency with a 128 byte stride.
+
+FASTMEM [default no]:
+=====================================================================
+
+SLOWFS [default no]
: 文件系统 latency
测试,如果跳过值设置为 yes
,不跳过设置为 no
,默认 no
,这里设置为默认值。
=====================================================================
+
+This benchmark measures, by default, file system latency. That can
+take a long time on systems with old style file systems (i.e., UFS,
+FFS, etc.). Linux' ext2fs and Sun's tmpfs are fast enough that this
+test is not painful.
+
+If you are planning on sending in these results, please don't do a fast
+run.
+
+If you want to skip the file system latency tests, answer "yes" below.
+
+SLOWFS [default no]:
+=====================================================================
+
+DISKS [default none]
: 硬盘带宽和 seek time
,需要设置测试硬盘的盘符,例如 /dev/sda
,默认不测试(默认 none ),这里设置为默认值。
=====================================================================
+
+This benchmark can measure disk zone bandwidths and seek times. These can
+be turned into whizzy graphs that pretty much tell you everything you might
+need to know about the performance of your disk.
+
+This takes a while and requires read access to a disk drive.
+Write is not measured, see disk.c to see how if you want to do so.
+
+If you want to skip the disk tests, hit return below.
+
+If you want to include disk tests, then specify the path to the disk
+device, such as /dev/sda. For each disk that is readable, you'll be
+prompted for a one line description of the drive, i.e.,
+
+ Iomega IDE ZIP
+or
+ HP C3725S 2GB on 10MB/sec NCR SCSI bus
+
+DISKS [default none]:
+=====================================================================
+
+REMOTE [default none]
: 网络测试,需要 2
台机器并设置 rsh
,是测试机器能 rsh
访问另一台,默认不测试(默认 none ),这里设置为默认值。
=====================================================================
+
+If you are running on an idle network and there are other, identically
+configured systems, on the same wire (no gateway between you and them),
+and you have rsh access to them, then you should run the network part
+of the benchmarks to them. Please specify any such systems as a space
+separated list such as: ether-host fddi-host hippi-host.
+
+REMOTE [default none]:
+=====================================================================
+
+Processor mhz [default 999 MHz, 1.0010 nanosec clock]
: 测试 cpu
,默认 $MHZ
,即为程序判断出的频率,也可以根据情况自己设定,例如 3500,单位 MHz
,这里设置为默认值。
=====================================================================
+
+Calculating mhz, please wait for a moment...
+I think your CPU mhz is
+
+ 999 MHz, 1.0010 nanosec clock
+
+but I am frequently wrong. If that is the wrong Mhz, type in your
+best guess as to your processor speed. It doesn't have to be exact,
+but if you know it is around 800, say 800.
+
+Please note that some processors, such as the P4, have a core which
+is double-clocked, so on those processors the reported clock speed
+will be roughly double the advertised clock rate. For example, a
+1.8GHz P4 may be reported as a 3592MHz processor.
+
+Processor mhz [default 999 MHz, 1.0010 nanosec clock]:
+=====================================================================
+
+FSDIR [default /usr/tmp]
: 临时目录用来存放测试文件,可以自己设定,默认 /usr/tmp
,这里设置为默认值。
=====================================================================
+
+We need a place to store a 686 Mbyte file as well as create and delete a
+large number of small files. We default to /usr/tmp. If /usr/tmp is a
+memory resident file system (i.e., tmpfs), pick a different place.
+Please specify a directory that has enough space and is a local file
+system.
+
+FSDIR [default /usr/tmp]:
+=====================================================================
+
+Status output file [default /dev/tty]
: 测试输出信息文件存放目录,可以自己设定,默认 /dev/tty
。
=====================================================================
+
+lmbench outputs status information as it runs various benchmarks.
+By default this output is sent to /dev/tty, but you may redirect
+it to any file you wish (such as /dev/null...).
+
+Status output file [default /dev/tty]:
+=====================================================================
+
+Mail results [default yes]
: 是否将测试结果邮件发出来,默认是 yes
,这里设置为 no
。
=====================================================================
+
+There is a database of benchmark results that is shipped with new
+releases of lmbench. Your results can be included in the database
+if you wish. The more results the better, especially if they include
+remote networking. If your results are interesting, i.e., for a new
+fast box, they may be made available on the lmbench web page, which is
+
+ http://www.bitmover.com/lmbench
+
+Mail results [default yes]: no
+OK, no results mailed.
+=====================================================================
+
+以上项目设置完成后,开始自动执行测试。
+p7zip 测试是用于测试系统解压性能,通过数据直观评估性能,以下是运行 7pzip 测试的操作步骤
+首先需要在 RevyOS 中 安装 p7zip
+debian@lpi4a:~/Desktop$ sudo apt update
+debian@lpi4a:~/Desktop$ sudo apt install p7zip-full
+
+进行 p7zip 测试需要在终端中输入以下命令来执行:
+debian@lpi4a:~/Desktop$ 7z b
+
+系统会开始进行测试然后输出性能数据。
+通过以上步骤,可以在 RevyOS 上安装并测试 7zip 的性能。
+以下是测试结果参考,使用镜像版本为RevyOS2023121016g版本
+debian@lpi4a:~/Desktop$ 7z b
+
+7-Zip 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
+p7zip Version 16.02 (locale=C.UTF-8,Utf16=on,HugeFiles=on,64 bits,4 CPUs LE)
+
+LE
+CPU Freq: - 64000000 64000000 - - - - - -
+
+RAM size: 15739 MB, # CPU hardware threads: 4
+RAM usage: 882 MB, # Benchmark threads: 4
+
+ Compressing | Decompressing
+Dict Speed Usage R/U Rating | Speed Usage R/U Rating
+ KiB/s % MIPS MIPS | KiB/s % MIPS MIPS
+
+22: 3252 303 1045 3164 | 75268 394 1628 6422
+23: 3092 307 1025 3151 | 74514 399 1617 6447
+24: 3021 318 1022 3249 | 72017 398 1588 6322
+25: 2945 320 1050 3363 | 67801 395 1529 6034
+---------------------------------- | ------------------------------
+Avr: 312 1036 3232 | 396 1591 6306
+Tot: 354 1313 4769
+
+
+
+
+
+
+
+ 使用脚本对整机进行重启测试。
+测试机器重启会不会出现死机等问题。
+进行重启测试 500 次。
+在 /lib/system/system 下创建名为 cycletest.service_ 重启脚本:
+[Unit]
+Description=Reboots unit after 30s
+
+[Service]
+StandardOutput=syslog+console
+ExecStart=/bin/sh -c "\
+test -f /cycle-count || echo 0 > /cycle-count;\
+echo 'starting cycletest';\
+sleep 30;\
+expr `cat /cycle-count` + 1 > /cycle-count;\
+systemctl reboot;\
+"
+
+[Install]
+WantedBy=multi-user.target
+
+后根据以下指令安装并开始测试:
+systemctl daemon-reload
+systemctl enable cycletest.service (enable the service to start on reboot)
+systemctl start cycletest.service (start the service, should reboot in 30s)
+
+
+
+
+
+
+
+ STREAM 基准测试是一个简单的综合基准测试程序,它测量可持续内存带宽(以 MB/s 为单位)和简单向量内核的相应计算速率。
+stream 仅有单个文件,在进行测试时只需要对 stream.c
进行编译即可:
git clone <https://github.com/microseyuyu/STREAM.git>
+cd STREAM
+gcc -O3 -fopenmp -DN=2000000 -DNTIMES=10 stream.c -o stream
+export OMP_NUM_THREADS=8
+./stream
+
+参数说明:
+DN=2000000:指定测试数组a[]、b[]、c[]的大小(Array size)。该值对测试结果影响较大(5.9版本默认值2000000,。若stream.c为5.10版本,参数名变为-DSTREAM_ARRAY_SIZE,默认值10000000)。注意:必须设置测试数组大小远大于CPU 最高级缓存(一般为L3 Cache)的大小,否则就是测试CPU缓存的吞吐性能,而非内存吞吐性能。 +- -DNTIMES=10:执行的次数,并从这些结果中选最优值。 +- OMP_NUM_THREADS=8 线程数量。
+参考结果:
+debian@lpi4a:~/Desktop/STREAM$ ./stream
+-------------------------------------------------------------
+STREAM version $Revision: 5.10 $
+-------------------------------------------------------------
+This system uses 8 bytes per array element.
+-------------------------------------------------------------
+***** WARNING: ******
+ It appears that you set the preprocessor variable N when compiling this code.
+ This version of the code uses the preprocesor variable STREAM_ARRAY_SIZE to control the array size
+ Reverting to default value of STREAM_ARRAY_SIZE=10000000
+***** WARNING: ******
+Array size = 10000000 (elements), Offset = 0 (elements)
+Memory per array = 76.3 MiB (= 0.1 GiB).
+Total memory required = 228.9 MiB (= 0.2 GiB).
+Each kernel will be executed 10 times.
+ The *best* time for each kernel (excluding the first iteration)
+ will be used to compute the reported bandwidth.
+-------------------------------------------------------------
+Number of Threads requested = 8
+Number of Threads counted = 8
+-------------------------------------------------------------
+Your clock granularity/precision appears to be 1 microseconds.
+Each test below will take on the order of 21622 microseconds.
+ (= 21622 clock ticks)
+Increase the size of the arrays if this shows that
+you are not getting at least 20 clock ticks per test.
+-------------------------------------------------------------
+WARNING -- The above is only a rough guideline.
+For best results, please be sure you know the
+precision of your system timer.
+-------------------------------------------------------------
+Function Best Rate MB/s Avg time Min time Max time
+Copy: 8364.2 0.019258 0.019129 0.019508
+Scale: 8291.0 0.019572 0.019298 0.020162
+Add: 6223.6 0.038835 0.038563 0.040011
+Triad: 6222.5 0.038776 0.038570 0.039470
+-------------------------------------------------------------
+Solution Validates: avg error less than 1.000000e-13 on all three arrays
+-------------------------------------------------------------
+
+
+
+
+
+
+
+ # qemu-user 下编译
+sudo apt update
+sudo apt install -y \
+ sbuild buildd qemu-system-misc qemu-user-static binfmt-support \
+ ca-certificates apt-transport-https devscripts mmdebstrap
+
+# native
+sudo apt install -y \
+ sbuild buildd ca-certificates apt-transport-https devscripts mmdebstrap
+
+# 修正宿主的debian-ports证书相关问题 现阶段可能不需要了
+wget https://mirror.sjtu.edu.cn/debian/pool/main/d/debian-ports-archive-keyring/debian-ports-archive-keyring_2023.02.01_all.deb
+sudo dpkg -i ./debian-ports-archive-keyring_2023.02.01_all.deb
+
+
+# sbuild 增加当前用户免root
+sudo sbuild-adduser $USER
+
+export SUFFIX=revyos-c910v-sbuild
+sudo sbuild-createchroot --debootstrap=debootstrap --arch=riscv64 \
+ --chroot-suffix=-$SUFFIX \
+ --keyring='' \
+ --no-deb-src \
+ --include=debian-ports-archive-keyring,ca-certificates,apt-transport-https,eatmydata \
+ --extra-repository="deb [trusted=yes] https://mirror.iscas.ac.cn/revyos/revyos-c910v/ revyos-c910v main contrib non-free" \
+ --extra-repository="deb [trusted=yes] https://mirror.iscas.ac.cn/revyos/revyos-addons/ revyos-addons main" \
+ sid /srv/chroot/sid-riscv64-$SUFFIX \
+ https://mirror.iscas.ac.cn/revyos/revyos-base/
+
+# 修正环境相关问题
+sudo sed -i 's/deb http/deb [trusted=yes] http/g' /srv/chroot/sid-riscv64-$SUFFIX/etc/apt/sources.list
+sudo rm -rf /srv/chroot/sid-riscv64-$SUFFIX/var/lib/apt/lists/*
+echo "command-prefix=eatmydata" | sudo tee -a /etc/schroot/chroot.d/sid-riscv64-$SUFFIX-*
+
+# 调整source顺序 - 目的是同版本使用c910v仓库的
+# 编辑sources.list 确保以下顺序
+deb [trusted=yes] https://mirror.iscas.ac.cn/revyos/revyos-c910v/ revyos-c910v main contrib non-free
+deb [trusted=yes] https://mirror.iscas.ac.cn/revyos/revyos-addons/ revyos-addons main
+deb [trusted=yes] https://mirror.iscas.ac.cn/revyos/revyos-base/ sid main contrib non-free non-free-firmware
+
+sbuild --arch=riscv64 -d sid -c sid-riscv64-revyos-c910v-sbuild xxx.dsc
+
+
+
+
+
+
+
+ Experimental feature
如果发现问题可以进行issue report
# Add Optimization deb source
+sudo sed -i '1ideb https://mirror.iscas.ac.cn/revyos/revyos-c910v/ revyos-c910v main' /etc/apt/sources.list
+# Update
+sudo apt update && sudo apt upgrade -y
+# Install gcc-10/gcc-13
+sudo apt install -y build-essential gcc-13 g++-13
+# Reboot to avoid other problems
+sudo reboot
+
+gcc -v
+Using built-in specs.
+COLLECT_GCC=gcc
+COLLECT_LTO_WRAPPER=/usr/lib/gcc/riscv64-linux-gnu/10/lto-wrapper
+Target: riscv64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Debian 10.4.0-8revyos2.3' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=riscv64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libsanitizer --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --disable-multilib --with-arch=rv64gcv0p7_zfh_xtheadc --with-abi=lp64d --enable-checking=release --build=riscv64-linux-gnu --host=riscv64-linux-gnu --target=riscv64-linux-gnu
+Thread model: posix
+Supported LTO compression algorithms: zlib zstd
+gcc version 10.4.0 (Debian 10.4.0-8revyos2.3)
+
+gcc-13 -v
+Using built-in specs.
+COLLECT_GCC=gcc-13
+COLLECT_LTO_WRAPPER=/usr/libexec/gcc/riscv64-linux-gnu/13/lto-wrapper
+Target: riscv64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Debian 13.2.0-1revyos1' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-13 --program-prefix=riscv64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --disable-multilib --with-arch=rv64gc_zfh_xtheadba_xtheadbb_xtheadbs_xtheadcmo_xtheadcondmov_xtheadfmemidx_xtheadfmv_xtheadint_xtheadmac_xtheadmemidx_xtheadmempair_xtheadsync --with-abi=lp64d --enable-checking=release --build=riscv64-linux-gnu --host=riscv64-linux-gnu --target=riscv64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=16
+Thread model: posix
+Supported LTO compression algorithms: zlib zstd
+gcc version 13.2.0 (Debian 13.2.0-1revyos1)
+
+除了v0p7 其他优化都可以用 gcc-13 代替 gcc-10
+后者的优化可以主线报问题 是已经主线化的功能
+ + + + + + +RevyOS 会预制相关优化编译器 基本支持rv64gc
支持的优化 | +gcc-10 | +gcc-13 | +clang-17 | +
---|---|---|---|
Zfh | +✅ | +✅ | +✅ | +
v0p7 | +✅ | +❌ | +❌ | +
xthead 当前版本 v2.2
+支持的优化1 | +gcc-102 | +gcc-13.2 | +clang-17 | +
---|---|---|---|
XTheadCmo | +✅ | +✅ | +✅ | +
XTheadSync | +✅ | +✅ | +✅ | +
XTheadBa | +✅ | +✅ | +✅ | +
XTheadBb | +✅ | +✅ | +✅ | +
XTheadBs | +✅ | +✅ | +✅ | +
XTheadCondMov | +✅ | +✅ | +✅ | +
XTheadMemIdx | +✅ | +✅ | +✅ | +
XTheadMemPair | +✅ | +✅ | +✅ | +
XTheadFMemIdx | +✅ | +✅ | +✅ | +
XTheadMac | +✅ | +✅ | +✅ | +
XTheadFmv | +✅ | +✅ | +❌ | +
XTheadInt | +✅ | +✅ | +❌ | +
XTHeadVdot3 | +✅ | +✅ | +✅ | +
注:
+首先确保安装gcc:
+sudo apt update
+sudo apt install gcc
+
+下面以最简单的 'hello,world' 程序为例演示如何编译并运行:
+编译以下内容并命名为 hello.c
:
#include <stdio.h>
+
+int main()
+{
+ printf("hello, world\n");
+ return 0;
+}
+
+编译并执行:
+debian@lpi4a:~/test$ gcc -g hello.c -o hello
+
+debian@lpi4a:~/test$ ./hello
+hello, world
+
+
+首先确保安装g++:
+sudo apt update
+sudo apt install g++
+
+下面以最简单的 'hello,world' 程序为例演示如何编译并运行:
+编译以下内容并命名为 hello.cpp
:
#include <iostream>
+using namespace std;
+
+int main()
+{
+ cout << "Hello, World!\n";
+ return 0;
+}
+
+
+编译并执行:
+debian@lpi4a:~/test$ g++ -g hello.cpp -o hello
+debian@lpi4a:~/test$ ./hello
+Hello, World!
+
+以上就是gcc/g++ 编译程序并运行的最简单实例,更复杂的应用案例可以参考相应的 +系统编程手册。
+ + + + + + +Build Toolchain Download link:
+https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1663142514282/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-20220906.tar.gz
+Assuming Build environment is Ubuntu
or Debian
Install dependency:
+sudo apt install -y gdisk dosfstools g++-12-riscv64-linux-gnu build-essential libncurses-dev gawk flex bison openssl libssl-dev tree dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf device-tree-compiler
+
+Uncompress Toolchain (Assuming install to /opt):
+tar -xvf Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-20220906.tar.gz -C /opt
+
+Setup environment variables (Assuming Toolchain is in /opt):
+export PATH="/opt/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1/bin:$PATH"
+export CROSS_COMPILE=riscv64-unknown-linux-gnu-
+export ARCH=riscv
+
+Download code using git:
+# Kernel repo
+git clone https://github.com/revyos/thead-kernel.git
+
+Build Kernel:
+# make install target directory
+mkdir rootfs && mkdir rootfs/boot
+
+# after mkdir, the directory tree should look like this:
+# .. << current workdir
+# |-- rootfs
+# |-- boot
+# |-- thead-kernel
+# |-- ...
+
+# enter kernel directory and start build
+cd thead-kernel
+make CROSS_COMPILE=riscv64-unknown-linux-gnu- ARCH=riscv revyos_defconfig
+make CROSS_COMPILE=riscv64-unknown-linux-gnu- ARCH=riscv -j$(nproc)
+make CROSS_COMPILE=riscv64-unknown-linux-gnu- ARCH=riscv -j$(nproc) dtbs
+sudo make CROSS_COMPILE=riscv64-unknown-linux-gnu- ARCH=riscv INSTALL_MOD_PATH=../rootfs/ modules_install -j$(nproc)
+sudo make CROSS_COMPILE=riscv64-unknown-linux-gnu- ARCH=riscv INSTALL_PATH=../rootfs/boot zinstall -j$(nproc)
+# build perf (if needed)
+make CROSS_COMPILE=riscv64-unknown-linux-gnu- ARCH=riscv LDFLAGS=-static NO_LIBELF=1 NO_JVMTI=1 VF=1 -C tools/perf/
+sudo cp -v tools/perf/perf ../rootfs/sbin/perf-thead
+# Install Kernel
+sudo cp -v arch/riscv/boot/Image ../rootfs/boot/
+# Install DTB
+sudo cp -v arch/riscv/boot/dts/thead/light-lpi4a.dtb ../rootfs/boot/
+sudo cp -v arch/riscv/boot/dts/thead/light-lpi4a-dsi0-hdmi.dtb ../rootfs/boot/
+
+After all build steps, you can copy or override kernel and module files on your board using files in "rootfs", If you replace kernel with new one please make sure you also replace with corresponding kernel module folder.
+ + + + + + +C910V强制cpu指定补丁
+From 5164bca5a4bcde4534dc1a9aa3a7f619719874cf Mon Sep 17 00:00:00 2001
+From: Han Gao <gaohan@iscas.ac.cn>
+Date: Sun, 23 Apr 2023 22:11:35 +0800
+Subject: [PATCH] qemu-user-riscv64 default cpu is c910v
+
+Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
+---
+ linux-user/riscv/target_elf.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/linux-user/riscv/target_elf.h b/linux-user/riscv/target_elf.h
+index 9dd65652ee45..3195cfa71408 100644
+--- a/linux-user/riscv/target_elf.h
++++ b/linux-user/riscv/target_elf.h
+@@ -9,7 +9,7 @@
+ #define RISCV_TARGET_ELF_H
+ static inline const char *cpu_get_model(uint32_t eflags)
+ {
+- /* TYPE_RISCV_CPU_ANY */
+- return "any";
++ /* TYPE_RISCV_CPU_C910V */
++ return "c910v";
+ }
+ #endif
+
+编译流程
+./configure \
+ --prefix=$HOME/qemu-install \
+ --static \
+ --target-list=riscv64-linux-user \
+ --disable-system \
+ --disable-pie \
+ --interp-prefix=/etc/qemu-binfmt/%M
+
+make -j20
+
+
+
+
+
+
+
+ 这里描述了 RevyOS 相关的构建文档
+ + + + + + +Test Image
+Based on lpi4a 20230614 +Add ahead support & mixed 20230820 changes
+https://mirror.iscas.ac.cn/revyos/extra/images/beagle/test/20230802/
+RevyOS 20230412 版本
+RevyOS 20230425 版本
+RevyOS 20230511 版本
+添加了gnome桌面支持
+RevyOS 20230614 版本
+当前版本只提供xfce4桌面支持
+提供了chromium支持
+RevyOS 20230810 版本
+重新设计了启动流程 所以需要重新刷写所有分区
+Retrieving file: /dtbs/linux-image-5.10.113-lpi4a/<NULL>-light-c910.
+Skipping l0r for failure retrieving fdt
+Light LPI4A#
+
+遇见这种情况需要执行</br>
+env default -a -f;env save;reset
+
+当前版本只提供xfce4桌面支持
+内核 commit ID: #2023.08.10.02.31+c130cdb21
+RevyOS 20230916 版本
+SBI 时间戳
+u-boot 时间戳
+内核 commit ID
+版本时间戳(/etc/revyos-release)
+RevyOS 20231026 版本
+RevyOS 20231210 版本
+SBI 时间戳
+u-boot 时间戳
+内核 commit ID
+版本时间戳(/etc/revyos-release)
+RevyOS 20240202 版本
+SBI 时间戳
+u-boot 时间戳
+内核 commit ID
+版本时间戳(/etc/revyos-release)
+RevyOS 20240601 版本
+SBI 时间戳
+u-boot 时间戳
+内核 commit ID
+版本时间戳(/etc/revyos-release)
+状态: +可以运行,软解图形
+资料: +https://github.com/OpenTTD/OpenTTD/blob/master/COMPILING.md +https://salsa.debian.org/openttd-team/openttd/-/blob/master/debian/control
+# 安装依赖
+sudo apt install libsdl2-dev zlib1g-dev libpng-dev libfreetype-dev libfontconfig-dev libicu-dev liblzo2-dev liblzma-dev libfluidsynth-dev libopengl-dev grfcodec openttd-opengfx cmake
+
+# 下载代码&编译
+git clone https://github.com/OpenTTD/OpenTTD.git
+cd OpenTTD
+mkdir build
+cd build
+cmake ..
+make
+
+# 运行
+./openttd
+
+图形和音频资源文件通过游戏内功能下载,支持中文
+状态: +可以运行,支持GLES加速
+资料: +https://github.com/yquake2/yquake2/blob/master/doc/020_installation.md +https://github.com/yquake2/yquake2/blob/master/doc/030_configuration.md
+# 安装依赖
+sudo apt install build-essential libgl1-mesa-dev libsdl2-dev libopenal-dev libcurl4-openssl-dev
+
+# 下载代码&编译
+git clone https://github.com/yquake2/yquake2.git
+mkdir build
+cd build
+cmake ..
+make
+
+# 运行
+#(需要准备好游戏原始资源文件夹baseq2)
+cd ..
+cd release
+cp -r ~/baseq2 .
+./quake2
+
+需要将原始游戏资源文件夹baseq2放到和quake2程序同一个目录中(Steam版可用)
+分辨率和图形加速选项在游戏内设置菜单修改,不修改默认是软渲染,硬渲染设置请改为“OpenGL ES3”(参见下图)
+在RevyOS中安装包只需要在 terminal 中输入
+apt install + 包名
+
+即可安装
+以下以安装 git作为演示
+debian@lpi4a:~$ sudo apt install git
+[sudo] password for debian:
+Reading package lists... Done
+Building dependency tree... Done
+Reading state information... Done
+The following additional packages will be installed:
+ git-man liberror-perl patch
+Suggested packages:
+ gettext-base git-daemon-run | git-daemon-sysvinit git-doc git-email git-gui
+ gitk gitweb git-cvs git-mediawiki git-svn ed diffutils-doc
+The following NEW packages will be installed:
+ git git-man liberror-perl patch
+0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
+Need to get 8605 kB of archives.
+After this operation, 39.4 MB of additional disk space will be used.
+Do you want to continue? [Y/n] y
+Get:1 https://mirror.iscas.ac.cn/revyos/revyos-base sid/main riscv64 liberror-perl all 0.17029-2 [29.0 kB]
+Get:2 https://mirror.iscas.ac.cn/revyos/revyos-base sid/main riscv64 git-man all 1:2.40.1-1 [2072 kB]
+Get:3 https://mirror.iscas.ac.cn/revyos/revyos-base sid/main riscv64 git riscv64 1:2.40.1-1 [6390 kB]
+Get:4 https://mirror.iscas.ac.cn/revyos/revyos-base sid/main riscv64 patch riscv64 2.7.6-7+b1 [114 kB]
+Fetched 8605 kB in 1s (6656 kB/s)
+Selecting previously unselected package liberror-perl.
+(Reading database ... 75688 files and directories currently installed.)
+Preparing to unpack .../liberror-perl_0.17029-2_all.deb ...
+Unpacking liberror-perl (0.17029-2) ...
+Selecting previously unselected package git-man.
+Preparing to unpack .../git-man_1%3a2.40.1-1_all.deb ...
+Unpacking git-man (1:2.40.1-1) ...
+Selecting previously unselected package git.
+Preparing to unpack .../git_1%3a2.40.1-1_riscv64.deb ...
+Unpacking git (1:2.40.1-1) ...
+Selecting previously unselected package patch.
+Preparing to unpack .../patch_2.7.6-7+b1_riscv64.deb ...
+Unpacking patch (2.7.6-7+b1) ...
+Setting up liberror-perl (0.17029-2) ...
+Setting up patch (2.7.6-7+b1) ...
+Setting up git-man (1:2.40.1-1) ...
+Setting up git (1:2.40.1-1) ...
+Processing triggers for man-db (2.11.2-2) ...
+
+
+
+
+
+
+
+ sudo apt install golang-go
+
+测试安装是否成功:
+debian@lpi4a:~$ go version
+go version go1.19.8 linux/riscv64
+
+源中已有 riscv64 的docker安装包,名为 docker.io
,可以直接使用:
sudo apt install docker.io
+
+sudo docker pull riscv64/debian:unstable
+
+如果使用命令sudo docker pull riscv64/debian:unstable
出现以下错误:
debian@lpi4a:~$ docker pull riscv64/debian:unstable
+Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/create?fromImage=riscv64%2Fdebian&tag=unstable": dial unix /var/run/docker.sock: connect: permission denied
+
+
+需要执行以下命令进行修复:
+# 1.
+sudo chmod 666 /var/run/docker.sock
+
+# 2.
+sudo systemctl start docker
+
+# 3.
+sudo docker run hello-world
+
+
+
+
+
+
+
+ 状态:可以运行
+官方资料页:https://docs.gimp.org/2.10/en/
+GIMP 是一个多平台工具,用于创建和编辑各种图像。 GIMP 是 GNU Image Manipulation Program 的首字母缩写。 GIMP 有很多功能。它可以用作简单的绘画程序、专家级的照片修饰程序、创建数字艺术的工具、在线批处理系统、批量生产的图像渲染器、图像格式转换器等。 GIMP 是可扩展和可扩展的。它旨在通过插件和扩展来增强以执行任何操作。先进的脚本界面允许从最简单的任务到最复杂的图像处理程序的所有内容都可以轻松编写脚本。
+GIMP是 RevyOS 预安装图形处理软件,如想使用 GIMP,在terminal中输入
+gimp
+
+在等待资源加载后就会弹出 GIMP 主界面
+使用功能参考官方资料页
+ + + + + + +状态:可以运行
+资料:https://wiki.debian.org/I18n/ibus
+sudo apt install ibus ibus-libpinyin
+sudo reboot
+
+重启后需要手动将中文输入法添加到输入选项中:
+托盘图标->右击->Preference
+
点击选项卡Input Method->Add,打开下图窗口
+
点击Chinese->Intelligent Pinyin->Add
+
RevyOS是由RuyiSDK团队的RevyOS小队支持开发的一款针对T-Head芯片生态的Debian优化定制发行版。
+RevyOS 围绕 c910v/c920/c906fdv/c908 等芯片提供了完整而全面的适配和优化支持,默认集成支持 RVV0.7.1 和 XThead 的 GCC 工具链,并搭载使用 RVV0.7.1 指令集优化过的 glibc 和 thead-kernel。
+目前,RevyOS 在办公、网页浏览、观看视频等方面已经能满足用户的基本使用需求。
+基于上述定制和优化的 RevyOS,在 Lichee Pi 4A,beaglev-ahead,milkv-pioneer 等硬件平台上,能够提供优秀的性能和极佳的体验。
+RevyOS 的用户版镜像目前在 ISCAS(INSTITUTE OF SOFTWARE CHINESE ACADEMY OF SCIENCES) / felix Finland Mirror 开源镜像站进行更新。
+如您想获取 RevyOS 最新版镜像请选择对应板子获取对应的U-Boot/boo分区/root分区文件:
+Support Hardware | +lpi4a/vala(荔枝派4a/评估板a) | +ahead(beaglev-ahead) | +
---|---|---|
Latest Image | +lpi4a 20231210 | +ahead 202301210 | +
Changelog | +lpi4a 20231210 | +ahead 20231210 | +
镜像刷写请参考:镜像刷写教程
+在完成镜像刷写后用户在登录界面,输入用户名 debian
,密码 debian
就可以登录进入系统了。
详见这篇文档Enable Optimization GCC
+镜像版本更新后我们会公布当前版本镜像支持内容,如您想查看镜像支持内容请点击RevyOS版本更新日志后选择您所需要的版本进行查看。
+同时我们会在此界面发布下版本预期更新内容,您可在该页面进行查看。
+如果您在使用过程中遇到问题,可以进行issue申报。
+在本仓库中,我们拥有相关的使用构建与适配文档以及测试文档方便让用户对部分内容进行参考,完善的文档支持加快了用户对于系统的上手时间。
+ + + + + + +RevyOS是由RuyiSDK团队的RevyOS小队支持开发的一款针对XuanTie芯片生态的Debian优化定制发行版。
+RevyOS 围绕 c910v/c920/c906fdv/c908 等芯片提供了完整而全面的适配和优化支持,默认集成支持 RVV0.7.1 和 XThead 的 GCC 工具链,并搭载使用 RVV0.7.1 指令集优化过的 glibc 和 thead-kernel。
+目前,RevyOS 在办公、网页浏览、观看视频等方面已经能满足用户的基本使用需求。
+基于上述定制和优化的 RevyOS,在 Lichee Pi 4A,beaglev-ahead,milkv-pioneer 等硬件平台上,能够提供优秀的性能和极佳的体验。
+RevyOS 的用户版镜像目前在 ISCAS(中国科学院软件研究所) / felix 芬兰源 开源镜像站进行更新。
+如您想获取 RevyOS 最新版镜像请选择对应板子获取对应的U-Boot/boo分区/root分区文件:
+支持设备 | +LicheePi 4A/vala(荔枝派4a/评估板a) | +LicheePi Cluster 4A | +ahead(beaglev-ahead) | +Milk-V Pioneer | +Milk-V Meles | +
---|---|---|---|---|---|
最新镜像 | +lpi4a 20240601 | +LicheePi Cluster 4A 20240601 | +ahead 20240529 | +pioneer20240327 | +meles20240601 | +
更新日志 | +lpi4a 20240529 | +lc4a 20240529 | +ahead 20240529 | +pioneer20240327 | +Meles20240601 | +
RevyOS 0529版本U-boot文件下载:链接
+镜像刷写请参考:镜像刷写教程
+在完成镜像刷写后用户在登录界面,输入用户名 debian
,密码 debian
就可以登录进入系统了。
详见这篇文档如何启用优化GCC
+镜像版本更新后我们会公布当前版本镜像支持内容,如您想查看镜像支持内容请点击RevyOS版本更新日志后选择您所需要的版本进行查看。
+如果您在使用过程中遇到问题,可以进行issue申报。
+在本DOCS中,我们拥有相关的使用构建与适配文档以及测试文档方便让用户对部分内容进行参考,完善的文档支持加快了用户对于系统的上手时间。
+ + + + + + +Some GStreamer pipeline command-line examples with omxil library on TH1520, RevyOS
+In this section, the grammer of the gstreamer command-line pipeline and some usefule debug tips are introduced. They have been moved to the end of the article.
+Basically, you neet to install gstreamer1.0-plugins-base
, gstreamer1.0-plugins-good
, gstreamer1.0-plugins-bad
, gstreamer1.0-omx-generic
, gstreamer1.0-omx-bellagio-config
,gstreamer1.0-tools
.
# videotestsrc
+gst-launch-1.0 videotestsrc ! autovideosink
+
+# specify the video stream format
+gst-launch-1.0 videotestsrc ! video/x-raw, format=NV12, width=960, height=540, framerate=60/1 ! autovideosink
+
+# display framerate
+gst-launch-1.0 videotestsrc ! fpsdisplaysink
+
+# no need to sync on the clock - used to test the performance of the pipeline
+gst-launch-1.0 videotestsrc ! fpsdisplaysink sync=false
+
+# stop display on the screen, but redirect the output to stdout
+gst-launch-1.0 videotestsrc ! fpsdisplaysink text-overlay=false -v 2>&1
+
+# specify which sink to use
+gst-launch-1.0 videotestsrc ! fpsdisplaysink sink=glimagesink
+
+# combine the previous examples
+gst-launch-1.0 videotestsrc ! fpsdisplaysink sink=glimagesink sync=false text-overlay=false -v 2>&1
+
+# audiotestsrc
+gst-launch-1.0 audiotestsrc ! autoaudiosink
+
+# change volume (0 to 1)
+gst-launch-1.0 audiotestsrc volume=0.1 ! autoaudiosink
+
+# change waveform
+# could be selected among square, silence, pink-noise, etc.
+gst-launch-1.0 audiotestsrc wave=pink-noise ! autoaudiosink
+
+# set fix frequency, such as "do" (262 Hz)
+gst-launch-1.0 audiotestsrc freq=262 ! autoaudiosink
+
+# a dummy sink that swallows everything
+gst-launch-1.0 videotestsrc ! fakesink
+
+# let decodebin choose which decoder to use,
+# and autovideosink choose which video-sink to use (not recommended)
+gst-launch-1.0 filesrc location=fire.mp4 ! decodebin ! autovideosink
+
+# h264 software decode without opengl display
+gst-launch-1.0 filesrc location=fire.mp4 ! qtdemux ! h264parse ! avdec_h264 ! xvimagesink
+
+# h264 hardware decode with opengl display
+gst-launch-1.0 filesrc location=fire.mp4 ! qtdemux ! h264parse ! omxh264dec ! glimagesink
+
+# h265 hardware decode
+gst-launch-1.0 filesrc location=fire.mp4 ! qtdemux ! h265parse ! omxh265dec ! glimagesink
+
+# vp9 hardware decode
+gst-launch-1.0 filesrc location=fire.webm ! matroskademux ! omxvp9dec ! glimagesink
+
+# mpeg4 hardware decode
+gst-launch-1.0 filesrc location=fire.mp4 ! qtdemux ! queue ! mpeg4videoparse ! omxmpeg4videodec ! glimagesink
+
+# play mkv/webm file
+gst-launch-1.0 filesrc location=fire.mkv ! matroskademux ! decodebin ! glimagesink
+
+# todo 10-bit h264/h265 decode
+
+# there is no hardware decoder on th1520
+
+# let autoaudiosink choose which audio-sink to use
+gst-launch-1.0 filesrc location=blade.mp3 ! decodebin ! audioconvert ! autoaudiosink
+
+# mp3 decode
+gst-launch-1.0 filesrc location=blade.mp3 ! mpegaudioparse ! avdec_mp3 ! audioconvert ! autoaudiosink
+
+# aac decode
+gst-launch-1.0 filesrc location=blade.aac ! aacparse ! avdec_aac ! audioconvert ! autoaudiosink
+gst-launch-1.0 filesrc location=blade.aac ! aacparse ! faad ! audioconvert ! autoaudiosink
+## faad works well without aacparse
+gst-launch-1.0 filesrc location=blade.aac ! faad ! audioconvert ! autoaudiosink
+
+# opus decode
+## ogg file must be demuxed by oggdemux first
+gst-launch-1.0 filesrc location=blade.ogg ! oggdemux ! opusparse ! opusdec ! audioconvert ! autoaudiosink
+gst-launch-1.0 filesrc location=blade.ogg ! oggdemux ! opusparse ! avdec_opus ! audioconvert ! autoaudiosink
+
+# wav decode
+gst-launch-1.0 filesrc location=test.wav ! wavparse ! audioresample ! audioconvert ! autoaudiosink
+
+# use specific audiosink
+gst-launch-1.0 filesrc location=blade.mp3 ! decodebin ! audioconvert ! pulsesink
+
+# specify the output device by using alsasink with device property
+gst-launch-1.0 filesrc location=blade.mp3 ! decodebin ! audioconvert ! alsasink device=hw:0,2
+
+We play media file in this section.
+# play mp4 file with both audio and video
+gst-launch-1.0 filesrc location=fire.mp4 ! qtdemux name=demux \
+ demux.video_0 ! queue ! decodebin ! videoconvert ! autovideosink \
+ demux.audio_0 ! queue ! decodebin ! audioconvert ! autoaudiosink
+
+# h264 encode test
+# before import video stream to omxh264dec, data should be transformed to frame with rawvideoparse
+# property and pad of rawvideoparse should be set to the same, so we use 'use-sink-caps=true' here
+gst-launch-1.0 videotestsrc ! videoconvert \
+ ! video/x-raw, format=NV12, width=640, height=480 \
+ ! rawvideoparse use-sink-caps=true ! omxh264enc ! fakesink
+
+# h264 hardware encode to file
+## todo: encoded h264 file has seek problem
+gst-launch-1.0 videotestsrc ! videoconvert \
+ ! video/x-raw, format=NV12, width=640, height=480 \
+ ! rawvideoparse use-sink-caps=true ! omxh264enc \
+ ! h264parse ! qtmux ! mp4mux ! filesink location=test.mp4
+
+# h264 hardware encode to file with specific bitrate(bit per second)
+gst-launch-1.0 videotestsrc ! videoconvert \
+ ! video/x-raw, format=NV12, width=640, height=480 \
+ ! rawvideoparse use-sink-caps=true \
+ ! omxh264enc target-bitrate=3000000 \
+ ! h264parse ! filesink location=test.mp4
+
+
+# h265 hardware encode to file
+## this pipeline produces h265 stream only
+## qtdemux is not needed while decoding
+gst-launch-1.0 videotestsrc ! videoconvert \
+ ! video/x-raw, format=NV12, width=640, height=480 \
+ ! rawvideoparse use-sink-caps=true ! omxh265enc \
+ ! h265parse ! filesink location=test.h265
+
+# h264 hardware encode from camera to file
+gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert \
+ ! video/x-raw, format=NV12,width=640,height=480 \
+ ! rawvideoparse use-sink-caps=true \
+ ! omxh264enc ! h264parse ! filesink location=test.mp4 -e
+
+# There is no hardware audio encoder on th1520
+
+# encode aac stream with adts container(.aac file)
+## the unit of the bitrate is 'bit/sec'
+gst-launch-1.0 audiotestsrc ! voaacenc bitrate=128000 ! avmux_adts ! filesink location=test.aac
+
+
+# todo: encode aac stream with adif container(.m4a file)
+
+# encode to mp3 file
+## the unit of the bitrate is 'kbit/sec'
+gst-launch-1.0 audiotestsrc ! lamemp3enc quality=2 target=bitrate bitrate=192 cbr=true ! id3v2mux ! filesink location=test.mp3
+
+# encode opus stream to .ogg file
+gst-launch-1.0 audiotestsrc ! opusenc ! oggmux ! filesink location=test.opus
+
+
+# todo: encode pcm stream to .wav file
+
+This part has been removed to Video + audio transcode
section.
Since omx...dec
cannot fulfill qtdemux and mp4mux, and gst-omx is no longer maintained, it is hard to mux mp4 file with these two plugins. To mux stream from omxh264dec, use avmux_mp4
instead. But there is no h265 or vp9 muxer available for omx...dec
The raw video stream should be processed by rawvideoparse
before sent to encoder. Because itself cannot scale frame or change framerate, rawvideoparse
need to get the stream info of its sink pad(src pad of the backward element). Therefore use-sink-caps
must be set to true
.
To change width and height, set properties output-width
and output-height
of omx...dec
. To modify bitrate and bitrate control method, set properties control-rate
and target-bitrate
of omx...enc
. To change framerate, set properties of videorate
.
# h265 to h264
+gst-launch-1.0 filesrc location=test_h265.mp4 ! qtdemux ! h265parse ! omxh265dec \
+ ! rawvideoparse use-sink-caps=true \
+ ! omxh264enc ! h264parse ! avmux_mp4 ! filesink location=t_h264.mp4
+
+# vp9 to h264
+gst-launch-1.0 filesrc location=test_vp9.webm ! matroskademux ! omxvp9dec \
+ ! rawvideoparse use-sink-caps=true \
+ ! omxh264enc ! h264parse ! avmux_mp4 ! filesink location=t_h264.mp4
+
+# arbitrary input to h264
+gst-launch-1.0 filesrc location=test_h264.mp4 ! decodebin \
+ ! rawvideoparse use-sink-caps=true \
+ ! omxh264enc ! h264parse ! filesink location=t_h264.mp4
+
+# h264 to h264, with more options
+## set the video width and height to 1280×720, framerate to 15fps, bitrate mode to constant and bitrate to 5Mbps
+gst-launch-1.0 filesrc location=test_h264.mp4 ! qtdemux ! h264parse \
+ ! omxh264dec output-width=1280 output-height=720 \
+ ! videorate ! video/x-raw, framerate=15/1 \
+ ! rawvideoparse use-sink-caps=true \
+ ! omxh264enc control-rate=constant target-bitrate=5000000 ! h264parse ! filesink location=t_h264.mp4
+
+## there is no vp9 encoder in th1520 omxil lib
+
+# aac to mp3
+gst-launch-1.0 filesrc location=test.aac ! aacparse ! avdec_aac ! audioconvert ! lamemp3enc quality=2 target=bitrate bitrate=192 cbr=true ! id3v2mux ! filesink location=t.mp3
+
+# mp3 to aac
+gst-launch-1.0 filesrc location=test.mp3 ! mpegaudioparse ! avdec_mp3 ! audioconvert ! voaacenc bitrate=128000 ! avmux_adts ! filesink location=t.aac
+
+# wav to mp3
+gst-launch-1.0 filesrc location=test.wav ! wavparse ! audioresample ! audioconvert ! lamemp3enc quality=2 target=bitrate bitrate=192 cbr=true ! id3v2mux ! filesink location=t.mp3
+
+# mp3 to wav
+gst-launch-1.0 filesrc location=test.mp3 ! mpegaudioparse ! avdec_mp3 ! audioresample ! audioconvert \
+ ! audio/x-raw, rate=44100, format=S16LE ! wavenc ! filesink location=t.wav
+
+# mux test
+gst-launch-1.0 audiotestsrc ! autoaudiosink videotestsrc ! autovideosink
+
+# mux the test video and audio stream to a mp4 file
+## be aware that '-e' must be set to this pipeline,
+## and there is no '!' before audiotestsrc
+gst-launch-1.0 -e videotestsrc ! videoconvert \
+ ! video/x-raw, format=NV12, width=960, height=540 \
+ ! rawvideoparse use-sink-caps=true ! omxh264enc ! h264parse \
+ ! avmux_mp4 name=mux ! filesink location=t_h264.mp4 \
+ audiotestsrc ! lamemp3enc ! mux.
+
+# change container from mkv to mp4 with h264 stream
+## this means demux a mkv file then mux video and audio stream to mp4 file
+gst-launch-1.0 filesrc location=test_h264.mkv \
+ ! matroskademux name=demux mp4mux force-create-timecode-trak=true name=mux ! filesink location=t_h264.mp4 \
+ demux.video_0 ! queue ! video/x-h264 ! mux. \
+ demux.audio_0 ! queue ! audio/mpeg ! mux.
+
+You can use command v4l2-ctl
, which is included in package v4l-utils
to get information of your camera.
For more information, read this article
+# h264 hardware encode from camera to file
+gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert \
+ ! video/x-raw, format=NV12,width=640,height=480 \
+ ! rawvideoparse format=nv12 width=640 height=480 \
+ ! omxh264enc ! h264parse ! filesink location=test.mp4 -e
+
+
+# capture camera and stream to other machine
+
+## source
+gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! videorate \
+ ! video/x-raw, format=NV12,width=640,height=480,framerate=20/1 \
+ ! rawvideoparse format=nv12 width=640 height=480 framerate=20/1 \
+ ! omxh264enc ! h264parse config-interval=1 ! video/x-h264,stream-format=byte-stream,alignment=nal \
+ ! rtph264pay ! udpsink host=192.168.31.27 port=5600
+
+## destination
+gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' \
+ ! rtph264depay ! h264parse ! avdec_h264 ! autovideosink
+
+gst-inspect-1.0
is a tool to print info about a GStreamer element(factory), which is included in gstreamer1.0-tools
.
# print the GStreamer element list with a 'less' like paing filter.
+gst-inspect-1.0
+
+# print info of the element
+gst-inspect-1.0 <element_name>
+
+gst-discover-1.0
is a tool to show info about the media file, which is inclucded in gstreamer1.0-plugins-base-apps
.
gst-discoverer-1.0 -v test.mp4
+
+If you are tired of manually build pipeline for playback by hand. You can use gst-play-1.0
as an alternative, which is included in gstreamer1.0-plugins-base-apps
.
# play media file
+gst-play-1.0 test.mp4
+
+# play media file with specific sink
+gst-play-1.0 --videosink=glimagesink --audiosink=alsasink
+
+Left button and right button can be used to seek. For more info, please read this article.
+To get the cap info or property of an element, you may need to run gst-inspect-1.0 <element_name>
. If gst-inspect-1.0
command not found, install gstreamer1.0-tools
.
If you want to debug GStreamer, refer to the articles below. +https://gstreamer.freedesktop.org/documentation/tutorials/basic/debugging-tools.html +https://gstreamer.freedesktop.org/documentation/gstreamer/running.html?gi-language=c
+Here is a simple command-line pipeline.
+gst-launch-1.0 videotestsrc ! autovideosink
+
+!
represent a link. The established pipeline looks like
videotestsrc => autovideosink
+
+There are several properties in videotestsrc, which could be lookup by gst-inspect-1.0 videotestsrc
.Set some properties:
gst-launch-1.0 videotestsrc pattern=ball flip=true ! autovideosink
+
+NAME=VALUE
is a property. pattern
and flip
are properties of videotestsrc.
Sometimes we need to control the behavior of gst-launch-1.0
.
GST_DEBUG=3 gst-launch-1.0 videotestsrc pattern=ball flip=true ! autovideosink
+gst-launch-1.0 videotestsrc pattern=ball flip=true ! autovideosink --gst-debug-level=3
+
+There are two ways to achieve this goal. One is setting environment variable. Another one is passing command-line argument to gst-launch-1.0
. GST_DEBUG=3
and --gst-debug-level=3
have the same meaning.
In most video decoding cases, there is a video-stream and an audio stream. We need to use demuxer to seperate them. Demuxer usually have several src pad. Here is an example.
+gst-launch-1.0 filesrc location=test-video.mp4 ! qtdemux name=demux demux. ! queue ! h264parse ! omxh264dec ! glimagesink demux. ! queue ! aacparse ! avdec_aac ! audioconvert ! alsasink
+
+It is hard to read. Add some word wrap:
+gst-launch-1.0 filesrc location=test-video.mp4 ! qtdemux name=demux \
+ demux. ! queue ! h264parse ! omxh264dec ! glimagesink \
+ demux. ! queue ! aacparse ! avdec_aac ! audioconvert ! pulsesink
+
+Here we use a demuxer to seperate video and audio, the grammer is:
+... demuxer name=DEMUXER_NAME \
+DEMUXER_NAME.PIPELINE_NAME_1 ! queue ! ...(the remaining part of pipeline 1) \
+DEMUXER_NAME.PIPELINE_NAME_2 ! queue ! ...(the remaining part of pipeline 2)
+
+Sometimes we need to set certain properties of the stream at certain nodes in the pipeline, e.g set resolution of the videostream of the videotestsrc
.
gst-launch-1.0 videotestsrc ! video/x-raw, width=800, height=600 ! glimagesink
+
+We negotiated the pad properties between videotestsrc
and glimagesink
. The property names and values must be supported by both element. You can find them in Pad Templates
section of gst-inspect-1.0
.
适用SDK v1.1.2
+PTG 的 OpenMAX IL 库(下称 vpu-omxil
)可使 LicheePi 4A 能够流畅硬解码 4k 60fps 的视频,那么具体应该如何使用该库呢?本文将主要介绍 LicheePi 4A 开发板上 Parole 播放器的集成与使用,用户可根据本文来了解在 LicheePi 4A 上的适配过程
+以 h264 的硬解为例,视频硬解的工作流程如图所示
+-------------------------------------------+
+ | +------------+ +------------+ | +--------+
+video stream----+--->| omxh264dec +------>| video-sink +----+-->| player |
+ | +------+-----+ +------------+ | +--------+
+ | | GStreamer |
+ +-----------+-------------------------------+
+ |
+ +-----v-----+
+ | vpu-omxil |
+ +-----+-----+
+ |
+ |
+ +-------v-------+
+ | kernel module |
+ | (driver) |
+ +-------+-------+
+ |
+ v
+ hardware
+
+omxh264dec
中将 omxh264 解码的部分单独拎出来,大体的结构如下
+ +---+------------+----+
+ | +------------+ |
+ | | omxh264dec | |
+ | +------------+ |
+ | GStreamer |
+ +----------+----------+
+ |
+ +----+-----v-----+----+
+ | +-----------+ |
+ | | vpu-omxil | |
+ | +-----------+ |
+ | libomxil-bellagio |
+ +----------+----------+
+ |
++------------v------------+
+| - memalloc - vc8000 |
+| - hantrodec - vidmem |
+| kernel modules |
++------------+------------+
+ |
+ v
+ hardware
+
+我们依照自底向上的顺序构建图示的链条。 +本节的主要目的是使 omxh264dec 解码器能够运行,并不涉及到输出屏幕等内容。
+硬解码需要访问硬件,而访问硬件又需要驱动,所以需要编译并安装驱动
+PTG 提供的驱动源:
+https://github.com/revyos/vpu-vc8000e-kernel
+https://github.com/revyos/vpu-vc8000d-kernel
+https://github.com/revyos/video_memory
+revyos/thead-kernel 已经合并了上述三个内核模块, 使用revyos_defconfig 可以无需编译上述内核模块
+# depmod 分析可载入模块的依赖关系,在 /lib/modules/<kernel-version>中添加modules.dep文件,以便后续 modprobe 使用
+sudo depmod -a
+sudo modprobe vidmem vc8000 hantrodec memalloc
+
+## 如果 modprobe 安装有问题的话,可以尝试使用 insmod 安装
+#cd /usr/lib/modules/$(uname -r)
+#sudo insmod $(find . -name *vidmem.ko*)
+#sudo insmod $(find . -name *vc8000.ko*)
+#sudo insmod $(find . -name *hantrodec.ko*)
+#sudo insmod $(find . -name *memalloc.ko*)
+
+# 可选:设置开机加载模块
+echo -e "\nvidmem\nhantrodec\nmemalloc\nvc8000\n" | sudo tee -a /etc/modules > /dev/null
+
+安装内核模块后,/dev
目录下会出现 hantrodec
vidmem
vc8000
三个设备文件。默认情况下,用户对其没有访问权限,如果不修改权限的话,非 root 用户在打开 omxil 库时会报错。
# 生效一次
+cd /dev
+sudo chmod 666 hantrodec vidmem vc8000
+
+# 长期生效
+cat << EOF | sudo tee /lib/udev/rules.d/70-hantro.rules > /dev/null
+KERNEL=="vidmem", MODE="0666"
+KERNEL=="hantrodec", MODE="0666"
+KERNEL=="vc8000", MODE="0666"
+EOF
+
+如果要获取 RevyOS 特定版本的内核模块,可进入 revyos/thead-kernel ,并在 GitHub CI 中下载 artifacts
+首先,请将 vpu-omxil 下载并解压到 /usr/lib/omxil/中 +vpu-omxil_1.2.1.tar.gz +如下图所示, 需要
+vpu-omxil
中的 OpenMax 组件注册到 libomxil-bellagio
中gst-omx
(该包提供了 omxh264dec 解码器) 调用 libomxil-bellagio
的时候也需要知道调用的组件名称+---------+ +-------------------+ +-----------+
+| gst-omx +-->| libomxil-bellagio +-->| vpu-omxil |
++---------+ +-------------------+ +-----------+
+
+vpu-omxil
中的组件注册到 libomxil-bellagio
中sudo apt install libomxil-bellagio-bin libomxil-bellagio0
+# 注册组件
+omxregister-bellagio -v /usr/lib/omxil/
+
+使用 omxregister-bellagio 生成注册文件,默认路径为 ~/.omxregister
+th1520-vpu 利用了 debian 在 usr/lib/riscv64-linux-gnu/libomxil-bellagio0
安装之后
+触发自动注册行为 结果如下
cat /var/lib/libomxil-bellagio0/registry
+/usr/lib/riscv64-linux-gnu/libomxil-bellagio0/libOMX.hantro.H2.video.encoder.so
+ ==> OMX.hantro.H2.video.encoder ==> OMX.hantro.H2.video.encoder.avc:OMX.hantro.H2.video.encoder.hevc:
+/usr/lib/riscv64-linux-gnu/libomxil-bellagio0/libOMX.hantro.VC8000D.image.decoder.so
+ ==> OMX.hantro.VC8000D.image.decoder ==> OMX.hantro.VC8000D.image.decoder.jpeg:
+/usr/lib/riscv64-linux-gnu/libomxil-bellagio0/libOMX.hantro.H2.image.encoder.so
+ ==> OMX.hantro.H2.image.encoder ==> OMX.hantro.H2.image.encoder.jpeg:
+/usr/lib/riscv64-linux-gnu/libomxil-bellagio0/libOMX.hantro.VC8000D.video.decoder.so
+ ==> OMX.hantro.VC8000D.video.decoder ==> OMX.hantro.VC8000D.video.decoder.mpeg4:OMX.hantro.VC8000D.video.decoder.avc:OMX.hantro.VC8000D.video.decoder.avs:OMX.hantro.VC8000D.video.decoder.h263:OMX.hantro.VC8000D.video.decoder.wmv:OMX.hantro.VC8000D.video.decoder.vp6:OMX.hantro.VC8000D.video.decoder.vp8:OMX.hantro.VC8000D.video.decoder.jpeg:OMX.hantro.VC8000D.video.decoder.hevc:OMX.hantro.VC8000D.video.decoder.vp9:OMX.hantro.VC8000D.video.decoder.avs2:
+
+调整 gstomx.conf 的设置以使解码器 omxh264dec 调用正确的组件,具体请查看针对 gst-omx 的补丁
+gst-omx-01-add-libomxil-config.patch
+请查看 PTG 提供的针对 gst-omx 的 dmabuf 补丁 +gst-omx-02-set-dec-out-port-dmabuf.patch
+sudo apt install gstreamer1.0-omx-generic gstreamer1.0-omx-bellagio-config gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-gl gstreamer1.0-plugins-good gstreamer1.0-tools
+
+# 1 基本解码
+gst-launch-1.0 filesrc location=<test.mp4> ! qtdemux ! h264parse ! omxh264dec ! videoconvert ! fakesink sync=false
+# 2 在终端中显示 fps
+# 参考:https://stackoverflow.com/questions/73948308
+gst-launch-1.0 filesrc location=<test.mp4> ! qtdemux ! h264parse ! omxh264dec ! videoconvert ! fpsdisplaysink video-sink=fakesink text-overlay=false sync=false -v 2>&1
+
+fakesink
会把前面的视频流全部吞掉,不输出画面(因而不会在 video-sink 这一环节损失性能),但是结合fpsdisplaysink可以读取到解码的速度。正常日志如下:
Setting pipeline to PAUSED ...[DBGT]
+vc8kdec compiled without trace support (ENABLE_DBGT_TRACE switch not enabled)
+Pipeline is PREROLLING ...
+Redistribute latency...
+OMX ! decoder_get_parameter OMX_ErrorNoMore (2)
+Pipeline is PREROLLED ...
+Setting pipeline to PLAYING ...
+New clock: GstSystemClockRedistribute latency...
+0:01:39.5 / 0:01:49.4 (90.9 %)
+
+【TIP】如果有 [omxh264dec-omxh264dec0: Could not initialize supporting library.](https://gist.github.com/Sakura286/015fae6792e160268db7ad8a697dd2df)
等字样的报错,可以安装gst-omx
、libomxil-bellagio
与libc6
相关的 debug-symbol 包,使用 gdb
启动上述命令进行调试。调试时,先断DWLInit
,然后再断open
,具体看是打开哪个地方的时候出错了。
RevyOS 适配过程中对于初始化动态库失败找到了如下三种原因:
+omxregister-bellagio
注册 vpu-omxil/dev
目录下 hantrodec
vc8000
vidmem
等设备的权限video-sink
是视频流在整个 GStreamer pipeline 中的最后一步,其作用一般是将视频流输出到屏幕上。
+前文中fakesink
只是测试解码器是否正常工作的特殊 video-sink
,可选的 video-sink非常多,常见的有 autovideosink
,ximagesink
,xvimagesink
,fbdevsink
,waylandsink
,glimagesink
,gtkglsink
等,它们各在不同的插件包里,需要酌情安装:
video-sink | +所属包名 | +
---|---|
waylandsink | +gstreamer1.0-plugins-bad | +
fbdevsink | +gstreamer1.0-plugins-bad | +
autovideosink | +gstreamer1.0-plugins-good | +
gtkglsink | +gstreamer1.0-plugins-good | +
ximagesink | xvimagesink | +gstreamer1.0-plugins-base | +
glimagesink | +gstreamer1.0-plugins-base | gstreamer1.0-gl | +
【TIP】使用 gst-inspect-1.0 <video-sink-name>
来查看对应 video-sink 可用的选项
+【TIP】添加 --gst-debug-level=<lv>
来获得更多的输出日志,其中 <lv>
代表了从 1 到 6,啰嗦程度从低到高,建议在等级 4 及以下,否则日志会非常长
+请尝试不同的 video-sink ,并尝试不同的插件参数,以及给予不同的环境变量,直至找到可以流畅硬解 H264 的那一个。
**waylandsink**
:由于现在(20230720)RevyOS 采用了 Xfce 桌面,不可能支持 Wayland,故 waylandsink
从原理上无法使用**fbdevsink**
与**ximagesink**
:无法使用**xvimagesink**
:通过流水线图以及日志可以确定,playbin 或 autovideosink 会自动调用 xvimagesink,使用 perf 分析后可以发现,使用xvimagesink 不可避免地会进行大量的 memcpy 操作,严重降低解码性能;该问题在获得PTG的 dmabuf 补丁后依然存在,故无法使用**gtkglsink**
:GTK3 不支持 EGL on X11,而 RevyOS 目前基于 x11,且只支持 EGL,故无法使用剩下的只有glimagesink
,根据 Running and debugging GStreamer Applications,并观察其他使用到 glimagesink 的例子,可以猜测需要明确指定环境变量 GST_GL_API
与 GST_GL_PLATFORM
+由于 RevyOS 使用了 gles2+egl 的组合,使用如下的命令,成功硬解。
GST_GL_API=gles2 GST_GL_PLATFORM=egl gst-launch-1.0 filesrc location=<test.mp4> ! qtdemux ! h264parse ! omxh264dec ! videoconvert ! fpsdisplaysink video-sink=glimagesink sync=false
+
+然而 GStreamer 被播放器调用时是无法通过环境变量来传递参数的,所以构建 gst-plugins-base 时应当传递额外的 meson 编译参数:
+-Dgl_api=[\'gles2\'] -Dgl_platform=[\'egl\']
+
+GStreamer 的 pipeline 没有问题之后,就需要使播放器支持。不同播放器会使用到不同的 video-sink,同样对 gstreamer 有着不同程度的依赖。 +适配播放器时,最重要的工作便是①使播放器适配已验证的 video-sink,或者②使 gstreamer pipeline 支持播放器指定的 video-sink,此次 RevyOS 适配过程采用了①方案。
+ +-------------------------------------------+
+ | +------------+ +------------+ | +--------+
+video stream----+--->| omxh264dec +------>| video-sink +----+-->| player |
+ | +------------+ +------------+ | +--------+
+ | GStreamer |
+ +-------------------------------------------+
+
+根据 https://gstreamer.freedesktop.org/apps/ 进行简单的排查
+是否可用 | +是否更新 | +应用名 | +备注 | +
---|---|---|---|
❌ | ++ | Gnash | +Flash 播放器 | +
❌ | ++ | GEntrans | +Debian 未收录 | +
❓ | +20230226 | +Kaffeine | +❌ 需要大量 KDE 相关组件 | +
+ | + | + | ✔️ 存在于riscv64 仓库中 | +
+ | + | + | ❌ 在 Debian amd64 Gnome 上,播放窗口与控制窗口分离,且默认调用了 VLC 进行播放 | +
❌ | ++ | Lcdgrilo | +Debian 未收录 | +
✔️ | +20230218 | +Parole | +✔️ For XFCE | +
+ | + | + | ❓ 不支持 Wayland,仅支持 x11 | +
+ | + | + | ✔️ Debian amd64 Gnome 验证通过 | +
+ | + | + | ✔️ 存在于riscv64 仓库 中 | +
❌ | ++ | Songbird | +Debian 未收录 | +
❌ | ++ | Snappy | +Debian 未收录 | +
❌ | ++ | Totem | +需要 GTK3,然而 GTK3 不支持 EGL on X11 | +
最初选择的播放器是 Totem,但是发现 Totem 无法指定除了 gtkglsink 以外的 video-sink,且由于 RevyOS 不支持 gtkglsink,所以支持 Totem 播放器的难度较大。 +对支持 GStreamer 的播放器进行排查后发现了 Parole , Parole 由 GObject 编写,与常见的面向对象编程略有区别。寻找其构建 parole_gst 对象时的方法 parole_gst_constructed,将 video-sink 属性设置为前文已验证的 glimagesink,补丁:
+parole-01-add-glimagesink-support.patch
+至此,粗略的适配工作完成。
+补丁集合:
+https://gist.github.com/Sakura286/26777ea8204c1819885e093806a4f7ca
+PTG omxil 库
+https://drive.google.com/file/d/1pYgCVI7WltfpskltJ-RqzVUCEC21FS56
+ + + + + + +测试网站地址:https://webglsamples.org/aquarium/aquarium.html
+直接打开即可,左侧数字是渲染的鱼的数量,数量越多越占性能
+CoreMark是一个综合基准,用于测量嵌入式系统中使用的中央处理器(CPU)的性能。它是在2009由eembc的shay gal-on开发的,旨在成为一个行业标准,取代过时的dehrystone基准。代码用C编写,包含以下算法:列表处理(增删改查和排序)、矩阵操作(公共矩阵操作)、状态机(确定输入流是否包含有效数字)和CRC。用户可以自由的下载Coremark,并移植到自己的平台上运行,随后就可以看到分数。
+├── barebones --移植到裸机环境下需要修改的目录
+│ ├── core_portme.c --移植的目标平台配置信息
+│ ├── core_portme.h --计时以及板级初始化实现
+│ ├── core_portme.mak --该子目录的makefile
+│ ├── cvt.c
+│ └── ee_printf.c --打印函数串口发送实现
+├── core_list_join.c --列表操作程序
+├── core_main.c --主程序
+├── coremark.h --项目配置与数据结构的定义头文件
+├── coremark.md5
+├── core_matrix.c --矩阵运算程序
+├── core_state.c --状态机控制程序
+├── core_util.c --CRC计算程序
+├── cygwin --x86 cygwin和gcc 3.4(四核,双核和单核系统)的测试代码
+│ ├── core_portme.c
+│ ├── core_portme.h
+│ └── core_portme.mak
+├── freebsd --以下同理,是在不同操作系统下的测试代码
+│ ├── ...
+├── LICENSE.md
+├── linux
+│ ├── ...
+├── linux64
+│ ├── ...
+├── macos
+│ ├── ...
+├── Makefile
+├── README.md --自述文件,CoreMark项目的基本介绍
+├── rtems
+│ ├── ...
+└── simple
+ ├── ...
+ └──
+
+根据 README 说法,只需要在 coremark 文件夹下执行 make 即可进行编译与测试。测试结果会出现在 Results 文件夹中,其中 run1.log 是测试结果。
+coremark 总体测试时间较短。 +计划同时测试 10 次取平均数值。
+$ git clone https://github.com/eembc/coremark.git
+$ cd coremark
+$ make
+
+2K performance run parameters for coremark.
+CoreMark Size : 666
+Total ticks : 12915
+Total time (secs): 12.915000
+Iterations/Sec : 8517.228029
+Iterations : 110000
+Compiler version : GCC13.1.0
+Compiler flags : -O2 -DPERFORMANCE_RUN=1 -lrt
+Memory location : Please put data memory location here
+ (e.g. code in flash, data on heap etc)
+seedcrc : 0xe9f5
+[0]crclist : 0xe714
+[0]crcmatrix : 0x1fd7
+[0]crcstate : 0x8e3a
+[0]crcfinal : 0x33ff
+Correct operation validated. See README.md for run and reporting rules.
+CoreMark 1.0 : 8517.228029 / GCC13.1.0 -O2 -DPERFORMANCE_RUN=1 -lrt / Heap
+
+
+make XCFLAGS="-march=rv64gv0p7_zfh_xtheadc -O3 -funroll-all-loops -finline-limit=500 -fgcse-sm -fno-schedule-insns -msignedness-cmpiv -fno-code-hoisting -mno-thread-jumps1 -mno-iv-adjust-addr-cost -mno-expand-split-imm"
+
+2K performance run parameters for coremark.
+CoreMark Size : 666
+Total ticks : 15129
+Total time (secs): 15.129000
+Iterations/Sec : 13219.644392
+Iterations : 200000
+Compiler version : GCC10.4.0
+Compiler flags : -O2 -march=rv64gv0p7_zfh_xtheadc -O3 -funroll-all-loops -finline-limit=500 -fgcse-sm -fno-schedule-insns -msignedness-cmpiv -fno-code-hoisting -mno-thread-jumps1 -mno-iv-adjust-addr-cost -mno-expand-split-imm -DPERFORMANCE_RUN=1 -lrt
+Memory location : Please put data memory location here
+ (e.g. code in flash, data on heap etc)
+seedcrc : 0xe9f5
+[0]crclist : 0xe714
+[0]crcmatrix : 0x1fd7
+[0]crcstate : 0x8e3a
+[0]crcfinal : 0x4983
+Correct operation validated. See README.md for run and reporting rules.
+CoreMark 1.0 : 13219.644392 / GCC10.4.0 -O2 -march=rv64gv0p7_zfh_xtheadc -O3 -funroll-all-loops -finline-limit=500 -fgcse-sm -fno-schedule-insns -msignedness-cmpiv -fno-code-hoisting -mno-thread-jumps1 -mno-iv-adjust-addr-cost -mno-expand-split-imm -DPERFORMANCE_RUN=1 -lrt / Heap
+
+make XCFLAGS="-march=rv64imafd_xtheadba_xtheadbb_xtheadbs_xtheadcmo_xtheadcondmov_xtheadfmemidx_xtheadfmv_xtheadint_xtheadmac_xtheadmemidx_xtheadmempair_xtheadsync -O3 -funroll-all-loops -finline-limit=500 -fgcse-sm -fno-schedule-insns -fno-code-hoisting -mno-thread-jumps"
+
+2K performance run parameters for coremark.
+CoreMark Size : 666
+Total ticks : 11897
+Total time (secs): 11.897000
+Iterations/Sec : 9246.028411
+Iterations : 110000
+Compiler version : GCC13.1.0
+Compiler flags : -O2 -march=rv64imafd_xtheadba_xtheadbb_xtheadbs_xtheadcmo_xtheadcondmov_xtheadfmemidx_xtheadfmv_xtheadint_xtheadmac_xtheadmemidx_xtheadmempair_xtheadsync -O3 -funroll-all-loops -finline-limit=500 -fgcse-sm -fno-schedule-insns -fno-code-hoisting -DPERFORMANCE_RUN=1 -lrt
+Memory location : Please put data memory location here
+ (e.g. code in flash, data on heap etc)
+seedcrc : 0xe9f5
+[0]crclist : 0xe714
+[0]crcmatrix : 0x1fd7
+[0]crcstate : 0x8e3a
+[0]crcfinal : 0x33ff
+Correct operation validated. See README.md for run and reporting rules.
+CoreMark 1.0 : 9246.028411 / GCC13.1.0 -O2 -march=rv64imafd_xtheadba_xtheadbb_xtheadbs_xtheadcmo_xtheadcondmov_xtheadfmemidx_xtheadfmv_xtheadint_xtheadmac_xtheadmemidx_xtheadmempair_xtheadsync -O3 -funroll-all-loops -finline-limit=500 -fgcse-sm -fno-schedule-insns -fno-code-hoisting -DPERFORMANCE_RUN=1 -lrt / Heap
+
+
+
+
+
+
+
+ glmark2 is an OpenGL 2.0 and ES 2.0 benchmark. +We will only use glmark2-es2 for relevant tests here . This is a testing tool for x11-glesv2.
+This software package is already pre-installed in the system.
+th1520
only support glmark-es2.
If you need perfect performance, put your device into performance mode before you start, here's how to do it.
+Please execute the following commands in the terminal. This command requires a root account.
+echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
+
+cat /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq
+
+After the execution is completed, you will see a series of numbers, such as "1848000".
+Open a terminal and enter glmark2-es2. This test allows the use of non-root accounts.
+After entering the command, a new window will appear on your desktop with an active screen.
+After the test is completed, the additional activity screen will disappear and the score will be output in the terminal in the form of "glmark2 Score: xxx".
+For example:
+debian@lpi4a:~/Desktop$ glmark2-es2
+=======================================================
+ glmark2 2021.12
+=======================================================
+ OpenGL Information
+ GL_VENDOR: Imagination Technologies
+ GL_RENDERER: PowerVR B-Series BXM-4-64
+ GL_VERSION: OpenGL ES 3.2 build 1.17@6210866
+ Surface Config: buf=32 r=8 g=8 b=8 a=8 depth=24 stencil=8
+ Surface Size: 800x600 windowed
+=======================================================
+[build] use-vbo=false: FPS: 513 FrameTime: 1.949 ms
+[build] use-vbo=true: FPS: 1367 FrameTime: 0.732 ms
+[texture] texture-filter=nearest: FPS: 1449 FrameTime: 0.690 ms
+[texture] texture-filter=linear: FPS: 1454 FrameTime: 0.688 ms
+[texture] texture-filter=mipmap: FPS: 1453 FrameTime: 0.688 ms
+[shading] shading=gouraud: FPS: 1172 FrameTime: 0.853 ms
+[shading] shading=blinn-phong-inf: FPS: 1180 FrameTime: 0.847 ms
+[shading] shading=phong: FPS: 1002 FrameTime: 0.998 ms
+[shading] shading=cel: FPS: 979 FrameTime: 1.021 ms
+[bump] bump-render=high-poly: FPS: 700 FrameTime: 1.429 ms
+[bump] bump-render=normals: FPS: 1354 FrameTime: 0.739 ms
+[bump] bump-render=height: FPS: 1320 FrameTime: 0.758 ms
+[effect2d] kernel=0,1,0;1,-4,1;0,1,0;: FPS: 1059 FrameTime: 0.944 ms
+[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;: FPS: 381 FrameTime: 2.625 ms
+[pulsar] light=false:quads=5:texture=false: FPS: 1484 FrameTime: 0.674 ms
+[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4: FPS: 349 FrameTime: 2.865 ms
+[desktop] effect=shadow:windows=4: FPS: 736 FrameTime: 1.359 ms
+[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 161 FrameTime: 6.211 ms
+[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=subdata: FPS: 173 FrameTime: 5.780 ms
+[buffer] columns=200:interleave=true:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 242 FrameTime: 4.132 ms
+[ideas] speed=duration: FPS: 593 FrameTime: 1.686 ms
+[jellyfish] <default>: FPS: 572 FrameTime: 1.748 ms
+[terrain] <default>: FPS: 42 FrameTime: 23.810 ms
+[shadow] <default>: FPS: 619 FrameTime: 1.616 ms
+[refract] <default>: FPS: 82 FrameTime: 12.195 ms
+[conditionals] fragment-steps=0:vertex-steps=0: FPS: 1539 FrameTime: 0.650 ms
+[conditionals] fragment-steps=5:vertex-steps=0: FPS: 1238 FrameTime: 0.808 ms
+[conditionals] fragment-steps=0:vertex-steps=5: FPS: 1535 FrameTime: 0.651 ms
+[function] fragment-complexity=low:fragment-steps=5: FPS: 1411 FrameTime: 0.709 ms
+[function] fragment-complexity=medium:fragment-steps=5: FPS: 1050 FrameTime: 0.952 ms
+[loop] fragment-loop=false:fragment-steps=5:vertex-steps=5: FPS: 1376 FrameTime: 0.727 ms
+[loop] fragment-steps=5:fragment-uniform=false:vertex-steps=5: FPS: 1394 FrameTime: 0.717 ms
+[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5: FPS: 1379 FrameTime: 0.725 ms
+=======================================================
+ glmark2 Score: 950
+=======================================================
+
+
+
+
+
+
+
+
+ ++lmbench for revyOS
+
带宽测评工具 | +反应时间测评工具 | +其他 | +
---|---|---|
读取缓存文件 | +上下文切换 | +\ | +
拷贝内存 | +网络:连接的建立,管道,TCP,UDP 和RPC hot potato | +\ | +
读内存 | +文件系统的建立和删除 | +\ | +
写内存 | +进程创建 | +处理器时钟比率计算 | +
管道 | +信号处理 | +\ | +
TCP | +上层的系统调用 | +\ | +
\ | +内存读入反应时间 | +\ | +
下载测试工具:
+git clone https://github.com/revyos/lmbench3.git
+
+++该版本为已为 RevyOS 移植版本。
+
在开始测试前,需要先安装依赖:
+sudo apt install gcc make libntirpc-dev -y
+
+执行命令进行编译,配置,并测试
+cd lmbench3
+cd src
+make results
+
+编译完成后会有以下选项提示需要设置:
+以下不需要更改的项目直接回车,会自动设置默认值。
+MULTIPLE COPIES [default 1]
: 设置同时运行 lmbench 的份数,份数多会使 lmbench 运行缓慢,默认是 1,这里设置为默认值 1。
=====================================================================
+
+If you are running on an MP machine and you want to try running
+multiple copies of lmbench in parallel, you can specify how many here.
+
+Using this option will make the benchmark run 100x slower (sorry).
+
+NOTE: WARNING! This feature is experimental and many results are
+ known to be incorrect or random!
+
+MULTIPLE COPIES [default 1]:
+=====================================================================
+
+Job placement selection [default 1]
: 作业调度控制方法,默认值是 1,表示允许作业调度,这里设置为默认值。
=====================================================================
+
+Options to control job placement
+1) Allow scheduler to place jobs
+2) Assign each benchmark process with any attendent child processes
+ to its own processor
+3) Assign each benchmark process with any attendent child processes
+ to its own processor, except that it will be as far as possible
+ from other processes
+4) Assign each benchmark and attendent processes to their own
+ processors
+5) Assign each benchmark and attendent processes to their own
+ processors, except that they will be as far as possible from
+ each other and other processes
+6) Custom placement: you assign each benchmark process with attendent
+ child processes to processors
+7) Custom placement: you assign each benchmark and attendent
+ processes to processors
+
+Note: some benchmarks, such as bw_pipe, create attendent child
+processes for each benchmark process. For example, bw_pipe
+needs a second process to send data down the pipe to be read
+by the benchmark process. If you have three copies of the
+benchmark process running, then you actually have six processes;
+three attendent child processes sending data down the pipes and
+three benchmark processes reading data and doing the measurements.
+
+Job placement selection [default 1]:
+=====================================================================
+
+Memory
: 设置测试内存大小,默认是 $MB
, 即为程序计算出来的最大可测试内存,也可以手动定义测试值,这里设置为这里使用默认值。
=====================================================================
+
+Several benchmarks operate on a range of memory. This memory should be
+sized such that it is at least 4 times as big as the external cache[s]
+on your system. It should be no more than 80% of your physical memory.
+
+The bigger the range, the more accurate the results, but larger sizes
+take somewhat longer to run the benchmark.
+
+MB [default 686]:
+Checking to see if you have 686 MB; please wait for a moment...
+686MB OK
+686MB OK
+686MB OK
+Hang on, we are calculating your cache line size.
+OK, it looks like your cache line is 64 bytes.
+
+=====================================================================
+
+SUBSET (ALL|HARWARE|OS|DEVELOPMENT) [default all]
: 要运行的测试集,包含 ALL/HARWARE/OS/DEVELOPMENT
,默认选 all
,这里选 all
。
=====================================================================
+
+lmbench measures a wide variety of system performance, and the full suite
+of benchmarks can take a long time on some platforms. Consequently, we
+offer the capability to run only predefined subsets of benchmarks, one
+for operating system specific benchmarks and one for hardware specific
+benchmarks. We also offer the option of running only selected benchmarks
+which is useful during operating system development.
+
+Please remember that if you intend to publish the results you either need
+to do a full run or one of the predefined OS or hardware subsets.
+
+SUBSET (ALL|HARWARE|OS|DEVELOPMENT) [default all]:
+=====================================================================
+
+FASTMEM [default no]
: 内存 latency
测试,如果跳过该测试,则设置为 yes
,如果不跳过则设置为 no
,默认是 no
,这里设置为默认值。
=====================================================================
+
+This benchmark measures, by default, memory latency for a number of
+different strides. That can take a long time and is most useful if you
+are trying to figure out your cache line size or if your cache line size
+is greater than 128 bytes.
+
+If you are planning on sending in these results, please don't do a fast
+run.
+
+Answering yes means that we measure memory latency with a 128 byte stride.
+
+FASTMEM [default no]:
+=====================================================================
+
+SLOWFS [default no]
: 文件系统 latency
测试,如果跳过值设置为 yes
,不跳过设置为 no
,默认 no
,这里设置为默认值。
=====================================================================
+
+This benchmark measures, by default, file system latency. That can
+take a long time on systems with old style file systems (i.e., UFS,
+FFS, etc.). Linux' ext2fs and Sun's tmpfs are fast enough that this
+test is not painful.
+
+If you are planning on sending in these results, please don't do a fast
+run.
+
+If you want to skip the file system latency tests, answer "yes" below.
+
+SLOWFS [default no]:
+=====================================================================
+
+DISKS [default none]
: 硬盘带宽和 seek time
,需要设置测试硬盘的盘符,例如 /dev/sda
,默认不测试(默认 none ),这里设置为默认值。
=====================================================================
+
+This benchmark can measure disk zone bandwidths and seek times. These can
+be turned into whizzy graphs that pretty much tell you everything you might
+need to know about the performance of your disk.
+
+This takes a while and requires read access to a disk drive.
+Write is not measured, see disk.c to see how if you want to do so.
+
+If you want to skip the disk tests, hit return below.
+
+If you want to include disk tests, then specify the path to the disk
+device, such as /dev/sda. For each disk that is readable, you'll be
+prompted for a one line description of the drive, i.e.,
+
+ Iomega IDE ZIP
+or
+ HP C3725S 2GB on 10MB/sec NCR SCSI bus
+
+DISKS [default none]:
+=====================================================================
+
+REMOTE [default none]
: 网络测试,需要 2
台机器并设置 rsh
,是测试机器能 rsh
访问另一台,默认不测试(默认 none ),这里设置为默认值。
=====================================================================
+
+If you are running on an idle network and there are other, identically
+configured systems, on the same wire (no gateway between you and them),
+and you have rsh access to them, then you should run the network part
+of the benchmarks to them. Please specify any such systems as a space
+separated list such as: ether-host fddi-host hippi-host.
+
+REMOTE [default none]:
+=====================================================================
+
+Processor mhz [default 999 MHz, 1.0010 nanosec clock]
: 测试 cpu
,默认 $MHZ
,即为程序判断出的频率,也可以根据情况自己设定,例如 3500,单位 MHz
,这里设置为默认值。
=====================================================================
+
+Calculating mhz, please wait for a moment...
+I think your CPU mhz is
+
+ 999 MHz, 1.0010 nanosec clock
+
+but I am frequently wrong. If that is the wrong Mhz, type in your
+best guess as to your processor speed. It doesn't have to be exact,
+but if you know it is around 800, say 800.
+
+Please note that some processors, such as the P4, have a core which
+is double-clocked, so on those processors the reported clock speed
+will be roughly double the advertised clock rate. For example, a
+1.8GHz P4 may be reported as a 3592MHz processor.
+
+Processor mhz [default 999 MHz, 1.0010 nanosec clock]:
+=====================================================================
+
+FSDIR [default /usr/tmp]
: 临时目录用来存放测试文件,可以自己设定,默认 /usr/tmp
,这里设置为默认值。
=====================================================================
+
+We need a place to store a 686 Mbyte file as well as create and delete a
+large number of small files. We default to /usr/tmp. If /usr/tmp is a
+memory resident file system (i.e., tmpfs), pick a different place.
+Please specify a directory that has enough space and is a local file
+system.
+
+FSDIR [default /usr/tmp]:
+=====================================================================
+
+Status output file [default /dev/tty]
: 测试输出信息文件存放目录,可以自己设定,默认 /dev/tty
。
=====================================================================
+
+lmbench outputs status information as it runs various benchmarks.
+By default this output is sent to /dev/tty, but you may redirect
+it to any file you wish (such as /dev/null...).
+
+Status output file [default /dev/tty]:
+=====================================================================
+
+Mail results [default yes]
: 是否将测试结果邮件发出来,默认是 yes
,这里设置为 no
。
=====================================================================
+
+There is a database of benchmark results that is shipped with new
+releases of lmbench. Your results can be included in the database
+if you wish. The more results the better, especially if they include
+remote networking. If your results are interesting, i.e., for a new
+fast box, they may be made available on the lmbench web page, which is
+
+ http://www.bitmover.com/lmbench
+
+Mail results [default yes]: no
+OK, no results mailed.
+=====================================================================
+
+以上项目设置完成后,开始自动执行测试。
+p7zip 测试是用于测试系统解压性能,通过数据直观评估性能,以下是运行 7pzip 测试的操作步骤
+首先需要在 RevyOS 中 安装 p7zip
+debian@lpi4a:~/Desktop$ sudo apt update
+debian@lpi4a:~/Desktop$ sudo apt install p7zip-full
+
+进行 p7zip 测试需要在终端中输入以下命令来执行:
+debian@lpi4a:~/Desktop$ 7z b
+
+系统会开始进行测试然后输出性能数据。
+通过以上步骤,可以在 RevyOS 上安装并测试 7zip 的性能。
+以下是测试结果参考,使用镜像版本为RevyOS2023121016g版本
+debian@lpi4a:~/Desktop$ 7z b
+
+7-Zip 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
+p7zip Version 16.02 (locale=C.UTF-8,Utf16=on,HugeFiles=on,64 bits,4 CPUs LE)
+
+LE
+CPU Freq: - 64000000 64000000 - - - - - -
+
+RAM size: 15739 MB, # CPU hardware threads: 4
+RAM usage: 882 MB, # Benchmark threads: 4
+
+ Compressing | Decompressing
+Dict Speed Usage R/U Rating | Speed Usage R/U Rating
+ KiB/s % MIPS MIPS | KiB/s % MIPS MIPS
+
+22: 3252 303 1045 3164 | 75268 394 1628 6422
+23: 3092 307 1025 3151 | 74514 399 1617 6447
+24: 3021 318 1022 3249 | 72017 398 1588 6322
+25: 2945 320 1050 3363 | 67801 395 1529 6034
+---------------------------------- | ------------------------------
+Avr: 312 1036 3232 | 396 1591 6306
+Tot: 354 1313 4769
+
+
+
+
+
+
+
+ 使用脚本对整机进行重启测试。
+测试机器重启会不会出现死机等问题。
+进行重启测试 500 次。
+在 /lib/system/system 下创建名为 cycletest.service_ 重启脚本:
+[Unit]
+Description=Reboots unit after 30s
+
+[Service]
+StandardOutput=syslog+console
+ExecStart=/bin/sh -c "\
+test -f /cycle-count || echo 0 > /cycle-count;\
+echo 'starting cycletest';\
+sleep 30;\
+expr `cat /cycle-count` + 1 > /cycle-count;\
+systemctl reboot;\
+"
+
+[Install]
+WantedBy=multi-user.target
+
+后根据以下指令安装并开始测试:
+systemctl daemon-reload
+systemctl enable cycletest.service (enable the service to start on reboot)
+systemctl start cycletest.service (start the service, should reboot in 30s)
+
+
+
+
+
+
+
+ STREAM 基准测试是一个简单的综合基准测试程序,它测量可持续内存带宽(以 MB/s 为单位)和简单向量内核的相应计算速率。
+stream 仅有单个文件,在进行测试时只需要对 stream.c
进行编译即可:
git clone <https://github.com/microseyuyu/STREAM.git>
+cd STREAM
+gcc -O3 -fopenmp -DN=2000000 -DNTIMES=10 stream.c -o stream
+export OMP_NUM_THREADS=8
+./stream
+
+参数说明:
+DN=2000000:指定测试数组a[]、b[]、c[]的大小(Array size)。该值对测试结果影响较大(5.9版本默认值2000000,。若stream.c为5.10版本,参数名变为-DSTREAM_ARRAY_SIZE,默认值10000000)。注意:必须设置测试数组大小远大于CPU 最高级缓存(一般为L3 Cache)的大小,否则就是测试CPU缓存的吞吐性能,而非内存吞吐性能。 +- -DNTIMES=10:执行的次数,并从这些结果中选最优值。 +- OMP_NUM_THREADS=8 线程数量。
+参考结果:
+debian@lpi4a:~/Desktop/STREAM$ ./stream
+-------------------------------------------------------------
+STREAM version $Revision: 5.10 $
+-------------------------------------------------------------
+This system uses 8 bytes per array element.
+-------------------------------------------------------------
+***** WARNING: ******
+ It appears that you set the preprocessor variable N when compiling this code.
+ This version of the code uses the preprocesor variable STREAM_ARRAY_SIZE to control the array size
+ Reverting to default value of STREAM_ARRAY_SIZE=10000000
+***** WARNING: ******
+Array size = 10000000 (elements), Offset = 0 (elements)
+Memory per array = 76.3 MiB (= 0.1 GiB).
+Total memory required = 228.9 MiB (= 0.2 GiB).
+Each kernel will be executed 10 times.
+ The *best* time for each kernel (excluding the first iteration)
+ will be used to compute the reported bandwidth.
+-------------------------------------------------------------
+Number of Threads requested = 8
+Number of Threads counted = 8
+-------------------------------------------------------------
+Your clock granularity/precision appears to be 1 microseconds.
+Each test below will take on the order of 21622 microseconds.
+ (= 21622 clock ticks)
+Increase the size of the arrays if this shows that
+you are not getting at least 20 clock ticks per test.
+-------------------------------------------------------------
+WARNING -- The above is only a rough guideline.
+For best results, please be sure you know the
+precision of your system timer.
+-------------------------------------------------------------
+Function Best Rate MB/s Avg time Min time Max time
+Copy: 8364.2 0.019258 0.019129 0.019508
+Scale: 8291.0 0.019572 0.019298 0.020162
+Add: 6223.6 0.038835 0.038563 0.040011
+Triad: 6222.5 0.038776 0.038570 0.039470
+-------------------------------------------------------------
+Solution Validates: avg error less than 1.000000e-13 on all three arrays
+-------------------------------------------------------------
+
+
+
+
+
+
+
+ # qemu-user 下编译
+sudo apt update
+sudo apt install -y \
+ sbuild buildd qemu-system-misc qemu-user-static binfmt-support \
+ ca-certificates apt-transport-https devscripts mmdebstrap
+
+# native
+sudo apt install -y \
+ sbuild buildd ca-certificates apt-transport-https devscripts mmdebstrap
+
+# 修正宿主的debian-ports证书相关问题 现阶段可能不需要了
+wget https://mirror.sjtu.edu.cn/debian/pool/main/d/debian-ports-archive-keyring/debian-ports-archive-keyring_2023.02.01_all.deb
+sudo dpkg -i ./debian-ports-archive-keyring_2023.02.01_all.deb
+
+
+# sbuild 增加当前用户免root
+sudo sbuild-adduser $USER
+
+export SUFFIX=revyos-c910v-sbuild
+sudo sbuild-createchroot --debootstrap=debootstrap --arch=riscv64 \
+ --chroot-suffix=-$SUFFIX \
+ --keyring='' \
+ --no-deb-src \
+ --include=debian-ports-archive-keyring,ca-certificates,apt-transport-https,eatmydata \
+ --extra-repository="deb [trusted=yes] https://mirror.iscas.ac.cn/revyos/revyos-c910v/ revyos-c910v main contrib non-free" \
+ --extra-repository="deb [trusted=yes] https://mirror.iscas.ac.cn/revyos/revyos-addons/ revyos-addons main" \
+ sid /srv/chroot/sid-riscv64-$SUFFIX \
+ https://mirror.iscas.ac.cn/revyos/revyos-base/
+
+# 修正环境相关问题
+sudo sed -i 's/deb http/deb [trusted=yes] http/g' /srv/chroot/sid-riscv64-$SUFFIX/etc/apt/sources.list
+sudo rm -rf /srv/chroot/sid-riscv64-$SUFFIX/var/lib/apt/lists/*
+echo "command-prefix=eatmydata" | sudo tee -a /etc/schroot/chroot.d/sid-riscv64-$SUFFIX-*
+
+# 调整source顺序 - 目的是同版本使用c910v仓库的
+# 编辑sources.list 确保以下顺序
+deb [trusted=yes] https://mirror.iscas.ac.cn/revyos/revyos-c910v/ revyos-c910v main contrib non-free
+deb [trusted=yes] https://mirror.iscas.ac.cn/revyos/revyos-addons/ revyos-addons main
+deb [trusted=yes] https://mirror.iscas.ac.cn/revyos/revyos-base/ sid main contrib non-free non-free-firmware
+
+sbuild --arch=riscv64 -d sid -c sid-riscv64-revyos-c910v-sbuild xxx.dsc
+
+
+
+
+
+
+
+ 实验性 feature
如果发现问题可以进行issue申报
# 增加优化源
+sudo sed -i '1ideb https://mirror.iscas.ac.cn/revyos/revyos-c910v/ revyos-c910v main' /etc/apt/sources.list
+# 更新软件
+sudo apt update && sudo apt upgrade -y
+# 安装 gcc-10/gcc-13
+sudo apt install -y build-essential gcc-13 g++-13
+# 重启避免其他问题
+sudo reboot
+
+gcc -v
+Using built-in specs.
+COLLECT_GCC=gcc
+COLLECT_LTO_WRAPPER=/usr/lib/gcc/riscv64-linux-gnu/10/lto-wrapper
+Target: riscv64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Debian 10.4.0-8revyos2.3' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=riscv64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libsanitizer --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --disable-multilib --with-arch=rv64gcv0p7_zfh_xtheadc --with-abi=lp64d --enable-checking=release --build=riscv64-linux-gnu --host=riscv64-linux-gnu --target=riscv64-linux-gnu
+Thread model: posix
+Supported LTO compression algorithms: zlib zstd
+gcc version 10.4.0 (Debian 10.4.0-8revyos2.3)
+
+gcc-13 -v
+Using built-in specs.
+COLLECT_GCC=gcc-13
+COLLECT_LTO_WRAPPER=/usr/libexec/gcc/riscv64-linux-gnu/13/lto-wrapper
+Target: riscv64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Debian 13.2.0-1revyos1' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-13 --program-prefix=riscv64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --disable-multilib --with-arch=rv64gc_zfh_xtheadba_xtheadbb_xtheadbs_xtheadcmo_xtheadcondmov_xtheadfmemidx_xtheadfmv_xtheadint_xtheadmac_xtheadmemidx_xtheadmempair_xtheadsync --with-abi=lp64d --enable-checking=release --build=riscv64-linux-gnu --host=riscv64-linux-gnu --target=riscv64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=16
+Thread model: posix
+Supported LTO compression algorithms: zlib zstd
+gcc version 13.2.0 (Debian 13.2.0-1revyos1)
+
+除了v0p7 其他优化都可以用 gcc-13 代替 gcc-10
+后者的优化可以主线报问题 是已经主线化的功能
+ + + + + + +RevyOS 会预制相关优化编译器 基本支持rv64gc
支持的优化 | +gcc-10 | +gcc-13 | +clang-17 | +
---|---|---|---|
Zfh | +✅ | +✅ | +✅ | +
v0p7 | +✅ | +❌ | +❌ | +
xthead 当前版本 v2.2
+支持的优化1 | +gcc-102 | +gcc-13.2 | +clang-17 | +
---|---|---|---|
XTheadCmo | +✅ | +✅ | +✅ | +
XTheadSync | +✅ | +✅ | +✅ | +
XTheadBa | +✅ | +✅ | +✅ | +
XTheadBb | +✅ | +✅ | +✅ | +
XTheadBs | +✅ | +✅ | +✅ | +
XTheadCondMov | +✅ | +✅ | +✅ | +
XTheadMemIdx | +✅ | +✅ | +✅ | +
XTheadMemPair | +✅ | +✅ | +✅ | +
XTheadFMemIdx | +✅ | +✅ | +✅ | +
XTheadMac | +✅ | +✅ | +✅ | +
XTheadFmv | +✅ | +✅ | +❌ | +
XTheadInt | +✅ | +✅ | +❌ | +
XTHeadVdot3 | +✅ | +✅ | +✅ | +
注:
+首先确保安装gcc:
+sudo apt update
+sudo apt install gcc
+
+下面以最简单的 'hello,world' 程序为例演示如何编译并运行:
+编译以下内容并命名为 hello.c
:
#include <stdio.h>
+
+int main()
+{
+ printf("hello, world\n");
+ return 0;
+}
+
+编译并执行:
+debian@lpi4a:~/test$ gcc -g hello.c -o hello
+
+debian@lpi4a:~/test$ ./hello
+hello, world
+
+
+首先确保安装g++:
+sudo apt update
+sudo apt install g++
+
+下面以最简单的 'hello,world' 程序为例演示如何编译并运行:
+编译以下内容并命名为 hello.cpp
:
#include <iostream>
+using namespace std;
+
+int main()
+{
+ cout << "Hello, World!\n";
+ return 0;
+}
+
+
+编译并执行:
+debian@lpi4a:~/test$ g++ -g hello.cpp -o hello
+debian@lpi4a:~/test$ ./hello
+Hello, World!
+
+以上就是gcc/g++ 编译程序并运行的最简单实例,更复杂的应用案例可以参考相应的 +系统编程手册。
+ + + + + + +内核工具链下载地址:
+https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1663142514282/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-20220906.tar.gz
+这里假设编译环境为 Ubuntu
或 Debian
安装依赖:
+sudo apt install -y gdisk dosfstools g++-12-riscv64-linux-gnu build-essential libncurses-dev gawk flex bison openssl libssl-dev tree dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf device-tree-compiler
+
+解压工具链(这里解压到/opt):
+tar -xvf Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-20220906.tar.gz -C /opt
+
+设置环境变量,将工具链加入环境变量中(假设工具链放在/opt中):
+export PATH="/opt/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1/bin:$PATH"
+export CROSS_COMPILE=riscv64-unknown-linux-gnu-
+export ARCH=riscv
+
+使用git下载内核代码:
+# 内核仓库
+git clone https://github.com/revyos/thead-kernel.git
+
+编译内核:
+# 创建安装目标目录
+mkdir rootfs && mkdir rootfs/boot
+
+# 目录创建完成后,目录结构应该看起来是这样:
+# .. << 当前工作路径
+# |-- rootfs
+# |-- boot
+# |-- thead-kernel
+# |-- ...
+
+# 进入内核代码目录,开始构建
+cd thead-kernel
+make CROSS_COMPILE=riscv64-unknown-linux-gnu- ARCH=riscv revyos_defconfig
+make CROSS_COMPILE=riscv64-unknown-linux-gnu- ARCH=riscv -j$(nproc)
+make CROSS_COMPILE=riscv64-unknown-linux-gnu- ARCH=riscv -j$(nproc) dtbs
+sudo make CROSS_COMPILE=riscv64-unknown-linux-gnu- ARCH=riscv INSTALL_MOD_PATH=../rootfs/ modules_install -j$(nproc)
+sudo make CROSS_COMPILE=riscv64-unknown-linux-gnu- ARCH=riscv INSTALL_PATH=../rootfs/boot zinstall -j$(nproc)
+# 构建perf(如果需要的话)
+make CROSS_COMPILE=riscv64-unknown-linux-gnu- ARCH=riscv LDFLAGS=-static NO_LIBELF=1 NO_JVMTI=1 VF=1 -C tools/perf/
+sudo cp -v tools/perf/perf ../rootfs/sbin/perf-thead
+# 安装内核到安装目标目录
+sudo cp -v arch/riscv/boot/Image ../rootfs/boot/
+# 安装设备树到安装目标目录
+sudo cp -v arch/riscv/boot/dts/thead/light-lpi4a.dtb ../rootfs/boot/
+sudo cp -v arch/riscv/boot/dts/thead/light-lpi4a-dsi0-hdmi.dtb ../rootfs/boot/
+
+之后只需要把rootfs中内容拷贝或覆盖到对应目录即可,注意内核Image和内核module目录一定要对应,不然会因缺失内核模块导致外设功能失效。
+ + + + + + +C910V强制cpu指定补丁
+From 5164bca5a4bcde4534dc1a9aa3a7f619719874cf Mon Sep 17 00:00:00 2001
+From: Han Gao <gaohan@iscas.ac.cn>
+Date: Sun, 23 Apr 2023 22:11:35 +0800
+Subject: [PATCH] qemu-user-riscv64 default cpu is c910v
+
+Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
+---
+ linux-user/riscv/target_elf.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/linux-user/riscv/target_elf.h b/linux-user/riscv/target_elf.h
+index 9dd65652ee45..3195cfa71408 100644
+--- a/linux-user/riscv/target_elf.h
++++ b/linux-user/riscv/target_elf.h
+@@ -9,7 +9,7 @@
+ #define RISCV_TARGET_ELF_H
+ static inline const char *cpu_get_model(uint32_t eflags)
+ {
+- /* TYPE_RISCV_CPU_ANY */
+- return "any";
++ /* TYPE_RISCV_CPU_C910V */
++ return "c910v";
+ }
+ #endif
+
+编译流程
+./configure \
+ --prefix=$HOME/qemu-install \
+ --static \
+ --target-list=riscv64-linux-user \
+ --disable-system \
+ --disable-pie \
+ --interp-prefix=/etc/qemu-binfmt/%M
+
+make -j20
+
+
+
+
+
+
+
+ 这里描述了 RevyOS 相关的构建文档
+ + + + + + +测试版镜像
+基于 lpi4a 20230614 版本 +增加 ahead 支持 混合新 20230820 改动
+https://mirror.iscas.ac.cn/revyos/extra/images/beagle/test/20230802/
+RevyOS 20230412 版本
+RevyOS 20230425 版本
+RevyOS 20230511 版本
+添加了gnome桌面支持
+RevyOS 20230614 版本
+当前版本只提供xfce4桌面支持
+提供了chromium支持
+RevyOS 20230810 版本
+重新设计了启动流程 所以需要重新刷写所有分区
+Retrieving file: /dtbs/linux-image-5.10.113-lpi4a/<NULL>-light-c910.
+Skipping l0r for failure retrieving fdt
+Light LPI4A#
+
+遇见这种情况需要执行</br>
+env default -a -f;env save;reset
+
+当前版本只提供xfce4桌面支持
+内核 commit ID: #2023.08.10.02.31+c130cdb21
+RevyOS 20230916 版本
+SBI 时间戳
+u-boot 时间戳
+内核 commit ID
+版本时间戳(/etc/revyos-release)
+RevyOS 20231026 版本
+RevyOS 20231210 版本
+SBI 时间戳
+u-boot 时间戳
+内核 commit ID
+版本时间戳(/etc/revyos-release)
+RevyOS 20240202 版本
+SBI 时间戳
+u-boot 时间戳
+内核 commit ID
+版本时间戳(/etc/revyos-release)
+RevyOS 20240601 版本
+SBI 时间戳
+u-boot 时间戳
+内核 commit ID
+版本时间戳(/etc/revyos-release)
+状态: +可以运行,软解图形
+资料: +https://github.com/OpenTTD/OpenTTD/blob/master/COMPILING.md +https://salsa.debian.org/openttd-team/openttd/-/blob/master/debian/control
+# 安装依赖
+sudo apt install libsdl2-dev zlib1g-dev libpng-dev libfreetype-dev libfontconfig-dev libicu-dev liblzo2-dev liblzma-dev libfluidsynth-dev libopengl-dev grfcodec openttd-opengfx cmake
+
+# 下载代码&编译
+git clone https://github.com/OpenTTD/OpenTTD.git
+cd OpenTTD
+mkdir build
+cd build
+cmake ..
+make
+
+# 运行
+./openttd
+
+图形和音频资源文件通过游戏内功能下载,支持中文
+状态: +可以运行,支持GLES加速
+资料: +https://github.com/yquake2/yquake2/blob/master/doc/020_installation.md +https://github.com/yquake2/yquake2/blob/master/doc/030_configuration.md
+# 安装依赖
+sudo apt install build-essential libgl1-mesa-dev libsdl2-dev libopenal-dev libcurl4-openssl-dev
+
+# 下载代码&编译
+git clone https://github.com/yquake2/yquake2.git
+mkdir build
+cd build
+cmake ..
+make
+
+# 运行
+#(需要准备好游戏原始资源文件夹baseq2)
+cd ..
+cd release
+cp -r ~/baseq2 .
+./quake2
+
+需要将原始游戏资源文件夹baseq2放到和quake2程序同一个目录中(Steam版可用)
+分辨率和图形加速选项在游戏内设置菜单修改,不修改默认是软渲染,硬渲染设置请改为“OpenGL ES3”(参见下图)
+在RevyOS中安装包只需要在 terminal 中输入
+apt install + 包名
+
+即可安装
+以下以安装 git作为演示
+debian@lpi4a:~$ sudo apt install git
+[sudo] password for debian:
+Reading package lists... Done
+Building dependency tree... Done
+Reading state information... Done
+The following additional packages will be installed:
+ git-man liberror-perl patch
+Suggested packages:
+ gettext-base git-daemon-run | git-daemon-sysvinit git-doc git-email git-gui
+ gitk gitweb git-cvs git-mediawiki git-svn ed diffutils-doc
+The following NEW packages will be installed:
+ git git-man liberror-perl patch
+0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
+Need to get 8605 kB of archives.
+After this operation, 39.4 MB of additional disk space will be used.
+Do you want to continue? [Y/n] y
+Get:1 https://mirror.iscas.ac.cn/revyos/revyos-base sid/main riscv64 liberror-perl all 0.17029-2 [29.0 kB]
+Get:2 https://mirror.iscas.ac.cn/revyos/revyos-base sid/main riscv64 git-man all 1:2.40.1-1 [2072 kB]
+Get:3 https://mirror.iscas.ac.cn/revyos/revyos-base sid/main riscv64 git riscv64 1:2.40.1-1 [6390 kB]
+Get:4 https://mirror.iscas.ac.cn/revyos/revyos-base sid/main riscv64 patch riscv64 2.7.6-7+b1 [114 kB]
+Fetched 8605 kB in 1s (6656 kB/s)
+Selecting previously unselected package liberror-perl.
+(Reading database ... 75688 files and directories currently installed.)
+Preparing to unpack .../liberror-perl_0.17029-2_all.deb ...
+Unpacking liberror-perl (0.17029-2) ...
+Selecting previously unselected package git-man.
+Preparing to unpack .../git-man_1%3a2.40.1-1_all.deb ...
+Unpacking git-man (1:2.40.1-1) ...
+Selecting previously unselected package git.
+Preparing to unpack .../git_1%3a2.40.1-1_riscv64.deb ...
+Unpacking git (1:2.40.1-1) ...
+Selecting previously unselected package patch.
+Preparing to unpack .../patch_2.7.6-7+b1_riscv64.deb ...
+Unpacking patch (2.7.6-7+b1) ...
+Setting up liberror-perl (0.17029-2) ...
+Setting up patch (2.7.6-7+b1) ...
+Setting up git-man (1:2.40.1-1) ...
+Setting up git (1:2.40.1-1) ...
+Processing triggers for man-db (2.11.2-2) ...
+
+
+
+
+
+
+
+ sudo apt install golang-go
+
+测试安装是否成功:
+debian@lpi4a:~$ go version
+go version go1.19.8 linux/riscv64
+
+源中已有 riscv64 的docker安装包,名为 docker.io
,可以直接使用:
sudo apt install docker.io
+
+sudo docker pull riscv64/debian:unstable
+
+如果使用命令sudo docker pull riscv64/debian:unstable
出现以下错误:
debian@lpi4a:~$ docker pull riscv64/debian:unstable
+Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/create?fromImage=riscv64%2Fdebian&tag=unstable": dial unix /var/run/docker.sock: connect: permission denied
+
+
+需要执行以下命令进行修复:
+# 1.
+sudo chmod 666 /var/run/docker.sock
+
+# 2.
+sudo systemctl start docker
+
+# 3.
+sudo docker run hello-world
+
+
+
+
+
+
+
+ 状态:可以运行
+官方资料页:https://docs.gimp.org/2.10/en/
+GIMP 是一个多平台工具,用于创建和编辑各种图像。 GIMP 是 GNU Image Manipulation Program 的首字母缩写。 GIMP 有很多功能。它可以用作简单的绘画程序、专家级的照片修饰程序、创建数字艺术的工具、在线批处理系统、批量生产的图像渲染器、图像格式转换器等。 GIMP 是可扩展和可扩展的。它旨在通过插件和扩展来增强以执行任何操作。先进的脚本界面允许从最简单的任务到最复杂的图像处理程序的所有内容都可以轻松编写脚本。
+GIMP是 RevyOS 预安装图形处理软件,如想使用 GIMP,在terminal中输入
+gimp
+
+在等待资源加载后就会弹出 GIMP 主界面
+使用功能参考官方资料页
+ + + + + + +状态:可以运行
+资料:https://wiki.debian.org/I18n/ibus
+sudo apt install ibus ibus-libpinyin
+sudo reboot
+
+重启后需要手动将中文输入法添加到输入选项中:
+托盘图标->右击->Preference
+
点击选项卡Input Method->Add,打开下图窗口
+
点击Chinese->Intelligent Pinyin->Add
+
RevyOS是由RuyiSDK团队的RevyOS小队支持开发的一款针对XuanTie芯片生态的Debian优化定制发行版。
+RevyOS 围绕 c910v/c920/c906fdv/c908 等芯片提供了完整而全面的适配和优化支持,默认集成支持 RVV0.7.1 和 XThead 的 GCC 工具链,并搭载使用 RVV0.7.1 指令集优化过的 glibc 和 thead-kernel。
+目前,RevyOS 在办公、网页浏览、观看视频等方面已经能满足用户的基本使用需求。
+基于上述定制和优化的 RevyOS,在 Lichee Pi 4A,beaglev-ahead,milkv-pioneer 等硬件平台上,能够提供优秀的性能和极佳的体验。
+RevyOS 的用户版镜像目前在 ISCAS(中国科学院软件研究所) / felix 芬兰源 开源镜像站进行更新。
+如您想获取 RevyOS 最新版镜像请选择对应板子获取对应的U-Boot/boo分区/root分区文件:
+支持设备 | +LicheePi 4A/vala(荔枝派4a/评估板a) | +LicheePi Cluster 4A | +ahead(beaglev-ahead) | +Milk-V Pioneer | +Milk-V Meles | +
---|---|---|---|---|---|
最新镜像 | +lpi4a 20240601 | +LicheePi Cluster 4A 20240601 | +ahead 20240529 | +pioneer20240327 | +meles20240601 | +
更新日志 | +lpi4a 20240529 | +lc4a 20240529 | +ahead 20240529 | +pioneer20240327 | +Meles20240601 | +
RevyOS 0529版本U-boot文件下载:链接
+镜像刷写请参考:镜像刷写教程
+在完成镜像刷写后用户在登录界面,输入用户名 debian
,密码 debian
就可以登录进入系统了。
详见这篇文档如何启用优化GCC
+镜像版本更新后我们会公布当前版本镜像支持内容,如您想查看镜像支持内容请点击RevyOS版本更新日志后选择您所需要的版本进行查看。
+如果您在使用过程中遇到问题,可以进行issue申报。
+在本DOCS中,我们拥有相关的使用构建与适配文档以及测试文档方便让用户对部分内容进行参考,完善的文档支持加快了用户对于系统的上手时间。
+ + + + + + +