Linux Software Features
Contents
- 1 Console
- 2 Device Tree
- 3 GStreamer
- 4 Java
- 5 Linux Kernel
- 6 NFS
- 7 OpenCV
- 8 Python
- 9 SSH
- 10 Yocto
- 10.1 How to delete temporary workspace after build process
- 10.2 How to get multi-sources from GIT server
- 10.3 Skip QA check
- 10.4 Create BB file to install pre-built SO binaries
- 10.5 Install Node-RED packages
- 10.6 How to add additional gst-plugins
- 10.7 How to use Yocto Project Application Development Toolkit (ADT)
- 10.8 How to add & use Chromium browser
Console
How to enable framebuffer console
The following operations are performed with RSB-4410(4410LBV2080)
- linux kernel config
- Device Drivers --->
- Graphics support --->
- <*> Framebuffer Console support
- Graphics support --->
- Device Drivers --->
- u-boot
setenv bootargs_base 'setenv bootargs console=ttymxc0,115200 console=tty0 enable_wait_mode=off video_mode=extension
- files need to be updated
- /etc/inittab
tty0::respawn:-/bin/bash
Notice:
- If the kernel config is set to "<M> Framebuffer Console support", console will show up after module ,fbcon, is loaded.
How to change debug console port
The following operations demonstrate how to change UBC-DS31's(based on DS31LBV1150) debug console from UART1(ttymxc0) to UART2(ttymxc1).
- u-boot
- include/configs/mx6q_ubc-d31_recovery.h
#define CONFIG_UART_BASE_ADDR UART2_BASE_ADDR
- include/configs/mx6q_ubc-d31_1G_recovery.h
- modify the settings of
bootargs_base
contained in the pre-defined macro#define CONFIG_EXTRA_ENV_SETTINGS
- modify the settings of
console=ttymxc1,115200
- board/freescale/mx6q_ubc-d31/mx6q_ubc-d31.c
- insert the following two lines into
static void setup_uart(void)
- insert the following two lines into
mxc_iomux_v3_setup_pad(MX6Q_PAD_EIM_D27__UART2_TXD);
mxc_iomux_v3_setup_pad(MX6Q_PAD_EIM_D27__UART2_RXD);
- linux kernel
- arch/arm/mach-mx6/board-mx6q_advantech.c
- modify the following two lines in
static void __init mx6_sabresd_timer_init(void)
- modify the following two lines in
uart_clk = clk_get_sys("imx-uart.1", NULL);
early_console_setup(UART2_BASE_ADDR, uart_clk);
How to disable debug console
The following operations demonstrate how to disable UBC-DS31's(based on DS31LBV1150) debug console.
- u-boot
- board/freescale/mx6q_ubc-d31/mx6q_ubc-d31.c
- comment out all the code within
static void setup_uart(void)
- comment out all the code within
- common/console.c
- modify the following line in
int console_init_f(void)
- modify the following line in
gd->have_console = 0;
- u-boot environment variable
setenv silent=y
change console setting, console=none
, within bootargs_base
- linux kernel config
- Device Drivers ---> Character devices ---> Serial drivers --->
- [*] IMX serial port support
- [ ] Support 4 IMX serial ports
- [ ] Console on IMX serial port
- Device Drivers ---> Character devices ---> Serial drivers --->
- linux kernel (recommended)
- arch/arm/boot/compressed/misc.c
- comment out the following lines in
void decompress_kernel (...
- comment out the following lines in
//putstr("Uncompressing Linux...");
/*
if (ret)
error("decompressor returned an error");
else
putstr(" done, booting the kernel.\n");
*/
- target root file system
- comment out the following line in
/etc/inittab
- comment out the following line in
#::respawn:/etc/rc.d/rc_mxc.S
Device Tree
Customize device tree
GStreamer
Play Video
Audio Information
- When the system is turned on, you can see the following audio information:
... ALSA device list: #0: imx-audio-sgtl5000 #1: imx-hdmi-soc ...
Frame Buffer Information
- After the system is turned on, you can type command to see frame buffer information. For example:
1. Type command "ls /dev/video", you will see all frame buffer devices ID:
$ video16 video17 video18 video19 video20
2. Type command "cat /sys/class/graphics/fb0/fsl_disp_dev_property", you will see frame buffer name:
$ hdmi
3. The device ID of "hdmi" frame buffer layer is "video16".
4. Type command "cat /sys/class/graphics/fb1/fsl_disp_dev_property", you will see frame buffer name:
$ overlay
5. The device ID of "hdmi" overlay layer is "video17".
6. Type command "cat /sys/class/graphics/fb2/fsl_disp_dev_property", you will see frame buffer name:
$ lcd
7. The device ID of "lcd" frame buffer layer is "video18".
8. Type command "cat /sys/class/graphics/fb3/fsl_disp_dev_property", you will see frame buffer name:
$ overlay
9. The device ID of "lcd" overlay layer is "video19".
10. Type command "cat /sys/class/graphics/fb4/fsl_disp_dev_property", you will see frame buffer name:
$ ldb
11. The device ID of "ldb" frame buffer layer is "video20".
Play Video Command
- The format of display video command:
$ GST_COMMAND uri=file://VIDEO_PATH video-sink="VIDEO_COMMAND device=DISPLAY_ID" audio-sink="alsasink device=plughw:AUDIO_ID"
Play Video Command On Yocto 1.5
1. For example:
GST_COMMAND = "gst-launch playbin2" VIDEO_PATH = "/tools/Advantech.avi" VIDEO_COMMAND = "mfw_v4lsink" DISPLAY_ID = "/dev/video17"(hdmi overlay layer) AUDIO_ID = "0"(audio-sgtl5000) or "1"(audio-hdmi) AUDIO = ""(Audio) or "volume=0"(No audio)
2. Play video with audio from sgtl5000 audio command:
$ gst-launch playbin2 uri=file:///tools/Advantech.avi video-sink="mfw_v4lsink device=/dev/video17" audio-sink="alsasink device=plughw:0"
3. Play video with audio from HDMI audio command:
$ gst-launch playbin2 uri=file:///tools/Advantech.avi video-sink="mfw_v4lsink device=/dev/video17" audio-sink="alsasink device=plughw:1"
4. Play video with no audio command:
$ gst-launch playbin2 uri=file:///tools/Advantech.avi video-sink="mfw_v4lsink device=/dev/video17" \ audio-sink="alsasink device=plughw:0" volume=0 or $ gst-launch playbin2 uri=file:///tools/Advantech.avi video-sink="mfw_v4lsink device=/dev/video17" \ audio-sink="alsasink device=plughw:1" volume=0
Play Video Command On Yocto 1.7
1. For example:
GST_COMMAND = "gst-launch playbin2" or "gst-launch-0.10 playbin2" or "gst-launch-1.0 playbin" VIDEO_PATH = "/tools/Advantech.avi" VIDEO_COMMAND = "imxv4l2sink" DISPLAY_ID = "/dev/video17"(hdmi overlay layer) AUDIO_ID = "0"(audio-sgtl5000) or "1"(audio-hdmi) AUDIO = ""(Audio) or "volume=0"(No audio)
2. Play video with audio from SGTL5000 audio command:
$ gst-launch playbin2 uri=file:///tools/Advantech.avi video-sink="imxv4l2sink device=/dev/video17" audio-sink="alsasink device=plughw:0" or $ gst-launch-0.10 playbin2 uri=file:///tools/Advantech.avi video-sink="imxv4l2sink device=/dev/video17" audio-sink="alsasink device=plughw:0" or $ gst-launch-1.0 playbin uri=file:///tools/Advantech.avi video-sink="imxv4l2sink device=/dev/video17" audio-sink="alsasink device=plughw:0"
3. Play video with audio from HDMI audio command:
$ gst-launch playbin2 uri=file:///tools/Advantech.avi video-sink="imxv4l2sink device=/dev/video17" audio-sink="alsasink device=plughw:1" or $ gst-launch-0.10 playbin2 uri=file:///tools/Advantech.avi video-sink="imxv4l2sink device=/dev/video17" audio-sink="alsasink device=plughw:1" or $ gst-launch-1.0 playbin uri=file:///tools/Advantech.avi video-sink="imxv4l2sink device=/dev/video17" audio-sink="alsasink device=plughw:1"
4. Play video with no audio command:
$ gst-launch playbin2 uri=file:///tools/Advantech.avi video-sink="imxv4l2sink device=/dev/video17" \ audio-sink="alsasink device=plughw:0" volume=0 or $ gst-launch-1.0 playbin uri=file://tools/Advantech.avi video-sink="imxv4l2sink device=/dev/video17" \ audio-sink="alsasink device=plughw:0" volume=0
Play Video Command On Yocto 1.8
1. For example:
GST_COMMAND = "gst-launch-1.0 playbin" VIDEO_PATH = "/tools/Advantech.avi" VIDEO_COMMAND = "imxv4l2sink" DISPLAY_ID = "/dev/video17"(hdmi overlay layer) AUDIO_ID = "0"(audio-sgtl5000) or "1"(audio-hdmi) AUDIO = ""(Audio) or "volume=0"(No audio)
2. Play video with audio from SGTL5000 audio command:
$ gst-launch-1.0 playbin uri=file:///tools/Advantech.avi video-sink="imxv4l2sink device=/dev/video17" audio-sink="alsasink device=plughw:0"
3. Play video with audio from HDMI audio command:
$ gst-launch-1.0 playbin uri=file:///tools/Advantech.avi video-sink="imxv4l2sink device=/dev/video17" audio-sink="alsasink device=plughw:1"
4. Play video with no audio command:
$ gst-launch-1.0 playbin uri=file://tools/Advantech.avi video-sink="imxv4l2sink device=/dev/video17" \ audio-sink="alsasink device=plughw:0" volume=0 or $ gst-launch-1.0 playbin uri=file://tools/Advantech.avi video-sink="imxv4l2sink device=/dev/video17" \ audio-sink="alsasink device=plughw:1" volume=0
SMPTE color bar
gst-launch videotestsrc ! autovideosink
video rotation
gst-launch filesrc location=/tools/Advantech.avi typefind=true ! aiurdemux name=demux demux. ! \
queue max-size-buffers=0 max-size-time=0 ! vpudec ! mfw_v4lsink rotate=180 demux. ! \
queue max-size-buffers=0 max-size-time=0 ! beepdec ! autoaudiosink
- (valid rotate value: 0, 90, 180 or 270)
- (While the angle of rotation is 90° or 270°, the maximum video resolution can not be larget than 1024*1024.)
or
gst-launch playbin2 uri=file:///tools/Advantech.avi video-sink="mfw_isink rotation=0"
- (valid rotation value: 0~7)
webcam
realtime video
gst-launch v4l2src ! video/x-raw-yuv,width=640,height=480,framerate=20/1 ! autovideosink
take one snapshot
gst-launch v4l2src num-buffers=1 ! jpegenc ! filesink location=sample.jpeg
show one snapshot
VSALPHA=1 gst-launch filesrc location=sample.jpeg ! jpegdec ! imagefreeze ! mfw_isink
network streaming
RTSP(unicast)
sender (ip: 192.168.203.41)
vlc -I rc H.264.mp4 --screen-fps=10 :screen-caching=100 --sout='#rtp{sdp=rtsp://8554/}' -vvv
receiver
gst-launch rtspsrc location=rtsp://192.168.203.41:8554 \ latency=200 name=r r. ! application/x-rtp,media=video ! \ queue max-size-buffers=0 max-size-time=0 ! rtph264depay ! \ vpudec ! mfw_v4lsink sync=false async=false r. ! \ 'application/x-rtp, media=(string)audio' ! queue max-size-buffers=0 max-size-time=0 ! \ rtpmp4gdepay ! beepdec ! alsasink sync=false async=false -vvv
RTP(multicast)
sender
vlc -I rc H.264.mp4 --screen-fps=10 :screen-caching=100 --sout='#rtp{mux=ts,dst=239.1.1.1,port=5004}' -vvv
receiver
route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0 gst-launch udpsrc uri=udp://239.1.1.1:5004 \ caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264"\ ! .recv_rtp_sink_0 gstrtpbin ! queue max-size-buffers=0 max-size-time=0 ! \ rtpmp2tdepay ! mpegtsdemux name=tsdem tsdem. ! queue max-size-buffers=0 max-size-time=0 ! \ vpudec ! mfw_isink sync=false tsdem. tsdem. ! queue max-size-buffers=0 max-size-time=0 ! \ beepdec ! alsasink sync=false -vvv
Java
How to install Java
Linux Kernel
Get kernel configs from running OS
You can get the .config file in running Linux OS by the following command.
# zcat /proc/config.gz > current.config
Furthermore, this feature is enabled by CONFIG_IKCONFIG_PROC.
Debug kernel panic and oops
To enable kernel symbols & debug information, you have to turn on these options and re-build kernel image. Just remember to keep the vmlinux & System.map files for debugging. They should be located at kernel root folder.
CONFIG_DEBUG_KERNEL=y CONFIG_KALLSYMS=y CONFIG_DEBUG_INFO=y # CONFIG_DEBUG_INFO_REDUCED is not set
Here is an example of Oops case.
Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = d8e3c000 [00000000] *pgd=68d76831, *pte=00000000, *ppte=00000000 Internal error: Oops: 17 [#1] PREEMPT SMP ARM Modules linked in: CPU: 1 PID: 1030 Comm: pulseaudio Not tainted 3.14.52-svn2009 #3 task: d8f90000 ti: d8b6c000 task.ti: d8b6c000 PC is at dac_get_volsw+0x60/0x74 LR is at dac_get_volsw+0x5c/0x74 pc : [<80558e68>] lr : [<80558e64>] psr: 60070013 sp : d8b6dea8 ip : 00000000 fp : d8617400 r10: 7ef214f8 r9 : d8b6c000 r8 : d866e280 r7 : d861757c r6 : d8617600 r5 : d8948800 r4 : 00000000 r3 : 00000000 r2 : 00000000 r1 : 00000001 r0 : 0000e564 Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user Control: 10c53c7d Table: 68e3c04a DAC: 00000015 Process pulseaudio (pid: 1030, stack limit = 0xd8b6c238) Stack: (0xd8b6dea8 to 0xd8b6e000) dea0: 80558e08 00000001 d8948800 80535bf4 f01ad000 d861757c dec0: 00000000 00000009 00000009 00000009 0035f648 00000000 00000000 00000000 dee0: 00000000 00000000 00000000 80967f28 00000007 8001a3c4 6df18338 d8b6dfb0 df00: 00000003 0035f960 7ef21aa4 d80cb410 7ef214f8 d87d53c0 c2c85512 0000000d df20: d8b6c000 00000000 7ef217f4 800e7f4c d87d53c8 800ebfc0 6ddcf000 800d2e14 df40: 80962860 0000000d 0035ccf8 8069fa10 0000000d 800f19e4 d87d53c0 d87d53c0 df60: 7ef21d94 8069fc88 00000802 d87d53c0 7ef214f8 d87d53c0 c2c85512 0000000d df80: d8b6c000 00000000 7ef217f4 800e8140 00361b58 00361cbc 00000000 00000036 dfa0: 8000e5e4 8000e460 00361b58 00361cbc 0000000d c2c85512 7ef214f8 0035cdd8 dfc0: 00361b58 00361cbc 00000000 00000036 00361ab0 00361b68 00000007 7ef217f4 dfe0: 6dfa73ac 7ef214ec 6df0efa4 76a5ecbc 20070010 0000000d 00000000 00000000 [<80558e68>] (dac_get_volsw) from [<80535bf4>] (snd_ctl_ioctl+0x5dc/0xb18) [<80535bf4>] (snd_ctl_ioctl) from [<800e7f4c>] (do_vfs_ioctl+0x3dc/0x59c) [<800e7f4c>] (do_vfs_ioctl) from [<800e8140>] (SyS_ioctl+0x34/0x5c) [<800e8140>] (SyS_ioctl) from [<8000e460>] (ret_fast_syscall+0x0/0x38) Code: e26330fc e585304c eb0501a0 e30e0564 (e5941000) ---[ end trace 7c4f0a24c41cc488 ]---
1. Check the PC (Program Counter) to find out where crash occurs.
PC is at dac_get_volsw+0x60/0x74
2. Grep dac_get_volsw() in System.map and get the symbol name address
$ cd <kernel root folder>
$ grep dac_get_volsw System.map
80558e08 t dac_get_volsw
Note: You can find the program counter is equaled to the sum of function entry address & offset.
pc : [<80558e68>] = 80558e08 + 0x60
3. Run addr2line to read the exact line number in source code.
$ arm-linux-gnueabi-addr2line -f -e vmlinux 80558e68 dac_get_volsw /home/root/Projects/Linux/fsl-yocto-3.14.52_1.1.0/linux-imx/sound/soc/codecs/sgtl5000.c:335
4-1. In alternative way, you can run objdump to get the disassembly and source code mapping.
$ arm-linux-gnueabi-objdump -DS vmlinux > kernel.objdump
Note: This step may take very long time to generate the dump file. So, maybe you can stop it, once you can find the function symbols in the file.
4-2. Find dac_get_volsw() in kernel.objdump, and check the pc address [<80558e68>]. Then, you can find the problem occurs at the same line of source code.
80558e08 <dac_get_volsw>: * ------------------------------ * userspace value 0xc0 0 */ static int dac_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { 80558e08: e92d4038 push {r3, r4, r5, lr} 80558e0c: e1a05001 mov r5, r1 ... //TEST printk("crash test!\n"); 80558e60: eb0501a0 bl 806994e8 <printk> printk("%d\n", *p); 80558e64: e30e0564 movw r0, #58724 ; 0xe564 80558e68: e5941000 ldr r1, [r4] 80558e6c: e3480080 movt r0, #32896 ; 0x8080 80558e70: eb05019c bl 806994e8 <printk>
NFS
The following operations demonstrate how to boot-up RSB-4410(4410LBV3480) with mounting the root filesystem via NFS.
- prerequisites for host
- Network
- e.g. ip address : 172.22.15.145
- NFS service
- NFS root
- e.g. /NFS/rsb-4410_rootfs
- make one copy of RSB-4410's rootfs located in the directory, /NFS/rsb-4410_rootfs
- copy the two files, uImage and imx6q-rsb4410.dtb, to /NFS/rsb-4410_rootfs
- add the following line to /etc/exports
/NFS *(rw,sync,wdelay,hide,nocrossmnt,insecure,no_root_squash,no_all_squash,subtree_check,secure_locks,acl,anonuid=65534,anongid=65534)
- execute the following command to export the directory
- $ sudo exportfs -a
- e.g. /NFS/rsb-4410_rootfs
- Network
- u-boot
> setenv serverip 172.22.15.145
> setenv nfsroot /NFS/rsb-4410_rootfs
> run netargs; setenv autoload n; dhcp
> nfs ${loadaddr} /NFS/rsb-4410_rootfs/${uimage}
> nfs ${fdt_addr} /NFS/rsb-4410_rootfs/${fdt_file}
> bootm ${loadaddr} - ${fdt_addr}
- screenshot
OpenCV
Open source computer vision
Python
Install Python
SSH
SSH connection
Yocto
In this section, we share some tips to use & modify BB files and related configurations for Yocto.
How to delete temporary workspace after build process
By default, the build system preserves the temporary files under the ${TMPDIR}/work directory of each recipe for inspection and possible debugging purposes. If you would rather have these files deleted to save disk space as the build progresses, you can enable rm_work by adding the following to your local.conf file, which is found in the Build Directory.
INHERIT += "rm_work"
To exclude some recipes from having their work directories deleted by rm_work, you can add the names of the recipe or recipes you are working on to the RM_WORK_EXCLUDE variable, which can also be set in your local.conf file. Here is an example:
RM_WORK_EXCLUDE += "busybox glibc"
How to get multi-sources from GIT server
You can assign a name to distinguish the different GIT URIs, and define different destsuffix to save them respectively. Furthermore, to override SRCREV with the name, you can assign different commit id for each GIT branch.
SRC_URI = " \ git://git.allseenalliance.org/gerrit/core/alljoyn.git;protocol=https;branch=${GIT_BRANCH};name=router;destsuffix=git/core/alljoyn \ git://git.allseenalliance.org/gerrit/services/base.git;protocol=https;branch=${GIT_BRANCH};name=services;destsuffix=git/services/base \ file://modify_flags_for_yocto.patch" SRCREV_router = "0d71b216bb3a3cadc615c3eda6f8200093c5e117" SRCREV_services = "403cda579242701d42d2d7c0da308d63a8f46070"
Skip QA check
You can skip the specific QA check for your packages. For details, check the insane.bbclass bbclass in Yocto Project Reference Manual.
INSANE_SKIP_${PN} += "dev-so"
Create BB file to install pre-built SO binaries
Below is an example to add SO binaries into your image. You may need to modify the blue items for your make install path & library name.
SRC_URI = "file://test.tar.gz" S = "${WORKDIR}/test" do_install() { install -d ${D}/usr/lib cp -axr ${S}/lib*.* ${D}/usr/lib/ } # Avoid package splitting into run-time and debug components INHIBIT_PACKAGE_DEBUG_SPLIT = "1" # Avoid QA Error for already-stripped INHIBIT_PACKAGE_STRIP = "1" # List the files for Package FILES_${PN} += "/usr/lib" # Put all SO files in main rpm package FILES_SOLIBSDEV = "" INSANE_SKIP_${PN} += "dev-so" # Set alias name to satisfy runtime dependencies RPROVIDES_${PN} = "libtest-1.00.so"
Install Node-RED packages
For Node-RED package installation, you can refer to the example below. Please note this example is based on the imyller's meta-nodejs layer for Node.js infrastructure.
SRC_URI = "git://github.com/ADVANTECH-Corp/node-red-contrib-alljoyn.git;protocol=git" SRCREV = "677333b1ed1a26a966c32d98af073d0b9a2b9088" S = "${WORKDIR}/git" # Inherit NPM class inherit npm-install-global # Do node-gyp rebuild in do_install() phase NPM_INSTALL_FLAGS = "--unsafe-perm" # Skip QA check INSANE_SKIP_${PN} = "staticdev"
How to add additional gst-plugins
- add new settings in Yocto's conf/local.conf
LICENSE_FLAGS_WHITELIST = "commercial"
COMMERCIAL_AUDIO_PLUGINS ?= " \
gst-plugins-ugly-mad \
gst-plugins-ugly-mpegaudioparse \
"
COMMERCIAL_VIDEO_PLUGINS ?= " \
gst-plugins-ugly-mpeg2dec \
gst-plugins-ugly-mpegstream \
gst-plugins-bad-mpegvideoparse \
"
CORE_IMAGE_EXTRA_INSTALL += " \
gst-plugins-bad-mpegtsdemux \
gst-plugins-bad-fbdevsink \
gst-ffmpeg \
"
- overwrite original hash code specified in the recipe x264_git
cat << EOF > meta-advantech/recipes-multimedia/x264/x264_git.bbappend
SRCREV = "ffc3ad4945da69f3caa2b40e4eed715a9a8d9526"
EOF
- snapshot verified
How to use Yocto Project Application Development Toolkit (ADT)
(see Setting-up Eclipse Plug-in to cross compile for iMX6 series)
How to add & use Chromium browser
- add new settings in conf/local.conf
LICENSE_FLAGS_WHITELIST = "commercial"
CORE_IMAGE_EXTRA_INSTALL += "chromium"
- switch "OpenGL ES H/W acceleration" on
- edit /usr/share/applications/google-chrome.desktop
[Desktop Entry]
...
Exec=/usr/bin/google-chrome --use-gl=egl %U
...
- HTML5 scores