Linux Examples
Low-level Examples
Play MP3
mplayer test.mp3
Run in Background
./app &
Stop a Program
ps
kill <pid>
killall app
Screenshot
Use gsnap or the platform screenshot tool.
Mount TF Card
mkdir -p /mnt/sdcard
mount /dev/mmcblk1p1 /mnt/sdcard
Mount USB Disk
mkdir -p /mnt/udisk
mount /dev/sda1 /mnt/udisk
Save System Clock
date
hwclock -w
hwclock -r
Save Data Before Power Loss
sync
Auto-start Program
Use init scripts, systemd services, or rc.local depending on the rootfs.
Memory Information
cat /proc/meminfo
free -m
Application Examples
The Linux manual includes:
- Hello World
- Math library call
- Multi-thread programming
- Multi-process programming
- Makefile programming
- mplayer porting
- madplayer porting
- gsnap screenshot tool porting
Hello World
#include <stdio.h>
int main(void)
{
printf("Hello X30 Linux!\\n");
return 0;
}
Compile:
gcc hello.c -o hello
./hello
Makefile
CC = gcc
TARGET = hello
SRCS = hello.c
all:
$(CC) $(SRCS) -o $(TARGET)
clean:
rm -f $(TARGET)