Ground Embedded KO Subscribe

Notes / Embedded Linux

Linux and shell basics

To work with an embedded Linux board, the file system, permissions, processes and shell scripts have to be second nature. A summary of the commands used most.

GROUND EMBEDDED · NOTEEmbedded Linux 01Linux and shell basics 1$ make ARCH=arm 2$ insmod gnd_gpio.ko 3[ 1.024] gnd: probe ok 4$ cat /dev/gnd0 50x5A 6$ _

File system

/root/etcsettings/devdevice files/sys · /prockernel info/homeusers
Places you visit often in Linux.
Path Contents
/bin, /usr/bin Executables
/etc Configuration files
/dev Device files (ttyS0, i2c-1, spidev0.0)
/sys Kernel objects (GPIO, LEDs, driver attributes)
/proc Processes, system information
/var/log Logs

In Linux devices are files too. For a serial port you open /dev/ttyS0 and read and write it.

Commands used most

ls -l, cd, cp, mv, rm, cat, less      # files
grep, find                           # searching
ps, top, kill                        # processes
dmesg                                # kernel messages (driver logs)
chmod, chown                         # permissions
ip addr, ping, ssh, scp              # network
RoadmapSee where this note sits in Embedded Linux→

Permissions

-rwxr-x--- is the read, write and execute permission for owner / group / others. If an ordinary user cannot open /dev/i2c-1, add the user to the group or use a udev rule.

Shell scripts

They automate post-boot set-up, log collection and repeated tests.

#!/bin/sh
for i in $(seq 1 100); do
  cat /sys/class/thermal/thermal_zone0/temp >> temp.log
  sleep 1
done

What is unfamiliar to an MCU developer is that "several programs run at once and the operating system manages the resources". Hardware is touched only through kernel drivers.

FREE PDFGet the 3 free ebooksIf you want to keep reading this topic as one book: BLDC motor control, serial communication and sensors at book length. PDFs are in Korean.Get them free →