So-net無料ブログ作成

Linuxのコンパイル4 [電子工作]

buildrootの新しいのが出ていたのでコンパイルしてみました。
root@kuro:~/work# wget https://buildroot.uclibc.org/downloads/buildroot-2017.08.tar.gz
root@kuro:~/work# tar xvf buildroot-2017.08.tar.gz
root@kuro:~/work# cd buildroot-2017.08

設定の準備をします。
root@kuro:~/work/buildroot-2017.08# cp configs/raspberrypi_defconfig configs/raspberrypi1_defconfig

buildrootのコンパイル条件をある程度設定しておきます。
root@kuro:~/work/buildroot-2017.08# vi configs/raspberrypi1_defconfig
-----
BR2_arm=y
BR2_arm1176jzf_s=y
BR2_ARM_EABIHF=y

BR2_SYSTEM_DHCP="eth0"

# Linux headers same as kernel, a 4.9 series
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_12=y

BR2_TOOLCHAIN_BUILDROOT_CXX=y

BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_GIT=y
BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/raspberrypi/linux.git"
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="rpi-4.12.y"
BR2_LINUX_KERNEL_DEFCONFIG="bcmrpi"

# Build the DTBs for A/B, A+/B+ and compute module from the kernel sources
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2708-rpi-b bcm2708-rpi-b-plus bcm2708-rpi-0-w"

BR2_PACKAGE_RPI_FIRMWARE=y
BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS=y

# Required tools to create the SD image
BR2_PACKAGE_HOST_DOSFSTOOLS=y
BR2_PACKAGE_HOST_GENIMAGE=y
BR2_PACKAGE_HOST_MTOOLS=y

# Filesystem / image
BR2_TARGET_ROOTFS_EXT2=y
BR2_TARGET_ROOTFS_EXT2_4=y
# BR2_TARGET_ROOTFS_TAR is not set
BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi1/post-build.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi1/post-image.sh"

BR2_TARGET_ROOTFS_EXT2_SIZE="200M"
BR2_TARGET_ROOTFS_INITRAMFS=y
BR2_TARGET_ROOTFS_ROMFS=y
BR2_TARGET_GENERIC_GETTY=y
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
BR2_TARGET_GENERIC_GETTY_BAUDRATE_115200=y
BR2_TARGET_GENERIC_GETTY_BAUDRATE="115200"
-----

定義ファイルをコピーしておきます。
root@kuro:~/work/buildroot-2017.08# mkdir board/raspberrypi1
root@kuro:~/work/buildroot-2017.08# cp board/raspberrypi/genimage-raspberrypi.cfg board/raspberrypi1/genimage-raspberrypi1.cfg
root@kuro:~/work/buildroot-2017.08# cp board/raspberrypi/post-build.sh board/raspberrypi1
root@kuro:~/work/buildroot-2017.08# cp board/raspberrypi/post-image.sh board/raspberrypi1

イメージファイルを作成するシェルを修正します。デフォルトサイズが小さいので大きくしておきます。
root@kuro:~/work/buildroot-2017.08# vi board/raspberrypi1/genimage-raspberrypi1.cfg
-----
image boot.vfat {
  vfat {
    files = {
      "bcm2708-rpi-b.dtb",
      "bcm2708-rpi-b-plus.dtb",
      "bcm2708-rpi-0-w.dtb",
      "rpi-firmware/bootcode.bin",
      "rpi-firmware/cmdline.txt",
      "rpi-firmware/config.txt",
      "rpi-firmware/fixup.dat",
      "rpi-firmware/start.elf",
      "zImage"
    }
  }
  size = 256M
}

image sdcard.img {
  hdimage {
  }

  partition boot {
    partition-type = 0xC
    bootable = "true"
    image = "boot.vfat"
  }

  partition rootfs {
    partition-type = 0x83
    image = "rootfs.ext4"
  }
}
-----

buildrootの設定を行います。
root@kuro:~/work/buildroot-2017.08# make raspberrypi1_defconfig

メニューに従って修正していきます。修正した箇所のみ記載します。
root@kuro:~/work/buildroot-2017.08# make menuconfig
-----
Toolchain  --->
  (buildroot) custom toolchain vendor name
    Kuro
  [*] Enable WCHAR support

System configuration  --->
  (buildroot) System hostname
    kuro
  (Welcome to Buildroot) System banner
    Welcome to Kuro
  /dev management (Dynamic using devtmpfs only)  --->
    (X) Dynamic using devtmpfs + mdev
  [*] support extended attributes in device tables
  ()    Root password
    root123
  ()  Root filesystem overlay directories
    rootfs-overlay
  
Target packages  --->
  Audio and video applications  --->
    [*] alsa-utils  --->
      [*]   alsaconf
      [*]   alsactl (NEW)
      [*]   alsamixer (NEW)
      [*]   amixer
      [*]   aplay/arecord
    [*] ffmpeg  --->
      [*]   Enable GPL code
      [*]   Build ffmpeg (the command line application) (NEW)
      [*]   Enable input devices (NEW)
      [*]   Enable output devices (NEW)
    [*] flac
    [*] lame
    [*] mpd  --->
      [*]   libsamplerate
      [*]   libsoxr
      [*]   dsd
      [*]   ffmpeg
      [*]   flac
      [*]   libsndfile
      [*]   lame
      [*]   avahi (zeroconf) support
    [*] mpd-mpc
    [*] mplayer
    [*] Build and install mplayer (NEW)
    [*] Build and install mencoder
    [*] ympd
  Filesystem and flash utilities  --->
    [*] nfs-utils
    [*]   rpc.lockd
  Interpreter languages and scripting  --->
    [*] python
      python module format to install (.pyc compiled sources only)  --->
        (X) .py sources and .pyc compiled
      core python modules  --->
        [*] xml module
      External python modules  --->
        [*] python-rpi-gpio
        [*] python-smbus-cffi
        [*] python-socketio
        [*] python-spidev
  Libraries  --->
    Audio/Sound  --->
      -*- alsa-lib  --->
        [*]   Python support for alsa-lib
     [*] libcdaudio
     [*] libcddb
     [*]   install cddb_query
     [*] libcdio   
     [*] libmpd 

  Networking applications  --->
     [*] bluez-utils 5.x
     [*] dropbear
     [*]   disable reverse DNS lookups
      
-----

buildrootのビルド設定を取っておきます。
root@kuro:~/work/buildroot-2017.08# cp .config build_config

Linuxの設定を行います。修正した場所のみ書きます。
root@kuro:~/work/buildroot-2017.08# make linux-menuconfig
-----
General setup  --->
  ((none)) Default hostname
    kuro
  [ ] Support for paging of anonymous memory (swap)
  [*]   Support initial ramdisks compressed using gzip
  [ ]   Support initial ramdisks compressed using bzip2
  [ ]   Support initial ramdisks compressed using LZMA
  [ ]   Support initial ramdisks compressed using XZ
  [ ]   Support initial ramdisks compressed using LZO
  [ ]   Support initial ramdisks compressed using LZ4
  
[*] Enable loadable module support  --->
  [*]   Forced module loading
  
Boot options  --->
  Default kernel command string
    console=ttyAMA0,115200

[*] Networking support  --->
  Networking options  --->
    [ ] Network packet filtering framework (Netfilter)  ----
    < > Asynchronous Transfer Mode (ATM)
    < > Layer Two Tunneling Protocol (L2TP)  ----
    < > 802.1d Ethernet Bridging
    < > 802.1Q/802.1ad VLAN Support
    < > Appletalk protocol support
    < > 6LoWPAN Support  ----
    < > IEEE Std 802.15.4 Low-Rate Wireless Personal Area Networks support  ----
    < > B.A.T.M.A.N. Advanced Meshing Protocol
    < > Open vSwitch
    [ ] MultiProtocol Label Switching  ----
  [ ]   Amateur Radio support  ----
  < >   CAN bus subsystem support  ----
  < >   WiMAX Wireless Broadband support  ----
  < >   RF switch subsystem support  ----
  < >   Plan 9 Resource Sharing Support (9P2000)  ----
  < >   NFC subsystem support  ----
   
Device Drivers  --->
  SCSI device support  --->
    < > SCSI device support
  [ ] Multiple devices driver support (RAID and LVM)  ----
  [*] Network device support  --->
    < >     Bonding driver support
    < >     Dummy net driver support
    < >     MAC-VLAN support
    < >     Virtual eXtensible Local Area Network (VXLAN)
    < >     Universal TUN/TAP device driver support
    < >     Virtual ethernet pair device
    [*]   Ethernet driver support  --->
           ASIX AX88796 NE2000 clone support
      [*]       ASIX AX88796 external 93CX6 eeprom support
           SMC 91C9x/91C1xxx support
           SMSC LAN911[5678] support
           SMSC LAN911x/LAN921x families embedded ethernet support

    < >   PPP (point-to-point protocol) support
    < >   SLIP (serial line) support

  Input device support  --->
    < >   Mouse interface
    < >   Joystick interface
    [ ]   Keyboards  ----
    [ ]   Joysticks/Gamepads  ----
    [ ]   Touchscreens  ----

     Multimedia support  --->
      [ ]   Analog TV support
      [ ]   Digital TV support
      [ ]   AM/FM radio receivers/transmitters support
      
    Graphics support  --->
      < > Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)  ----
      [ ] Bootup logo  ----

    <*> Sound card support  --->
         Advanced Linux Sound Architecture  --->
        [*]   Dynamic device file minor numbers

    [*] USB support  --->
      < >   USB Printer support
      < >   USB Mustek MDC800 Digital Camera support
      < >   USB Serial Converter support  --->
        [*]   USB Generic Serial Driver
           USB Serial Simple Driver
           USB FTDI Single Port Serial Driver
        ※上記以外外す
      < >   USB 7-Segment LED Display
      < >   USB Diamond Rio500 support
      < >   USB Lego Infrared Tower support
      < >   USB LCD driver support
      < >   Cypress CY7C63xxx USB driver support
      < >   Cypress USB thermometer driver support
      < >   Siemens ID USB Mouse Fingerprint sensor support
      < >   Elan PCMCIA CardBus Adapter USB Client
      < >   Apple Cinema Display support
      < >   USB LD driver
      < >   PlayStation 2 Trance Vibrator driver support
      < >   IO Warrior driver support
      < >   USB testing driver
      < >   iSight firmware loading support
      < >   USB YUREX driver support
      < >   Functions for loading firmware on EZUSB chips
      < >   USB Gadget Support  ----
    [*] Real Time Clock  --->
      < >   Abracon ABx80x
      [ ]     HWMON support for rtc-ds1307
      < >   Intersil ISL1208
      < >   Intersil ISL12022
      < >   Xicor/Intersil X1205
      < >   NXP PCF8523
      < >   Philips PCF8563/Epson RTC8564
      < >   Philips PCF8583
      < >   ST M41T62/65/M41T80/81/82/83/84/85/87 and compatible
      < >   TI BQ32000
      < >   Ramtron FM3130
      < >   EM Microelectronic EM3027
      < >   NXP PCF2123
      < >   NXP PCF2127
      < >   Micro Crystal RV3029/3049

File systems  --->
  [ ]   ReiserFS extended attributes
  < > JFS filesystem support
  < > GFS2 file system support
  < > OCFS2 file system support
  < > Btrfs filesystem support
  < > NILFS2 file system support
  
 -----

Linuxの設定を取っておきます。
root@kuro:~/work/buildroot-2017.08# cp output/build/linux-rpi-4.12.y/.config linux_config

独自の設定を格納するためのディレクトリを作成します。
root@kuro:~/work/buildroot-2017.08# mkdir -p rootfs-overlay/etc/init.d
root@kuro:~/work/buildroot-2017.08# mkdir -p rootfs-overlay/etc/default
root@kuro:~/work/buildroot-2017.08# mkdir -p rootfs-overlay/etc/mdev/scripts
root@kuro:~/work/buildroot-2017.08# mkdir -p rootfs-overlay/lib/lsb
root@kuro:~/work/buildroot-2017.08# mkdir -p rootfs-overlay/var/lib/mpd/music

ALSAの設定を行います。
root@kuro:~/work/buildroot-2017.08# vi rootfs-overlay/etc/asound.conf
-----
pcm.!default  {
 type hw card 0
}
ctl.!default {
 type hw card 0
}
-----

mdevの設定を行います。
root@kuro:~/work/buildroot-2017.08# vi rootfs-overlay/etc/mdev.conf
-----
# null may already exist; therefore ownership has to be changed with command
null            root:root 666 @chmod 666 $MDEV
zero            root:root 666
full            root:root 666
random          root:root 444
urandom         root:root 444
hwrandom        root:root 444
grsec           root:root 660

kmem            root:root 640
mem             root:root 640
port            root:root 640
# console may already exist; therefore ownership has to be changed with command
console         root:tty 600 @chmod 600 $MDEV
ptmx            root:tty 666
pty.*           root:tty 660

# Typical devices
tty             root:tty 666
tty[0-9]*       root:tty 660
vcsa*[0-9]*     root:tty 660
ttyS[0-9]*      root:root 660
ttyUSB[0-9]*    root:root 660

# alsa sound devices
snd/pcm.*       root:audio 660
snd/control.*   root:audio 660
snd/midi.*      root:audio 660
snd/seq         root:audio 660
snd/timer       root:audio 660

# input stuff
input/event[0-9]+       root:root 640
input/mice              root:root 640
input/mouse[0-9]        root:root 640
input/ts[0-9]           root:root 600

# load modules
$MODALIAS=.*    root:root 660 @modprobe "$MODALIAS"

#network interface
(eth.*)         root:netdev 660 >net/%1 @/sbin/ifup $INTERFACE

SUBSYSTEM=usb;DEVTYPE=usb_device;.* root:root 660 */etc/mdev/scripts/dev-bus-usb.sh
-----

ロードするモジュールを記述するファイルを作成します。
root@kuro:~/work/buildroot-2017.08# vi rootfs-overlay/etc/modules
-----
snd_soc_bcm2835_i2s
snd_soc_pcm5102a
snd_soc_hifiberry_dac
-----

SDカードをマウントし、rootファイルに上書きするファイルをコピーするスタートアップファイルを作成します。
root@kuro:~/work/buildroot-2017.08# vi rootfs-overlay/etc/init.d/S11setup
-----
#!/bin/sh

start() {
        printf "Starting setup tool"
        mount -t vfat /dev/mmcblk0p1 /mnt
        cp -r /mnt/root/* /
        umount /mnt
}

stop() {
        printf "Stopping setup tool"
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart|reload)
                stop
                sleep 1
                start
                ;;
        *)
                echo "Usage $0 {start|stop|restart}"
                exit 1
esac
-----

モジュールをロードするスタートアップファイルを作成します。
root@kuro:~/work/buildroot-2017.08# vi rootfs-overlay/etc/init.d/S18loadmod
-----
#!/bin/sh

MODULES_PATH="/etc/modules"

start() {
        printf "Starting Loading modules"
        for line in $(cat ${MODULES_PATH});
        do
                [[ $line = \#* ]] && continue
                modprobe $line;
        done
}

stop() {
        printf ""
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart|reload)
                ;;
        *)
                echo "Usage $0 {start|stop|restart}"
                exit 1
esac
-----

rootファイルシステムに上書きしたファイルを実行するスタートアップファイルを作成します。
root@kuro:~/work/buildroot-2017.08# vi rootfs-overlay/etc/init.d/S90tools
-----
#!/bin/sh

start() {
        printf "Starting tools"
        chmod 755 /root/bin/S*
        list=`ls /root/bin/S*`
        for i in $list
        do
                eval $i start
        done
}

stop() {
        printf "Stopping tools"
        list=`ls -r /root/bin/S*`
        for i in $list
        do
                eval $i stop
        done
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart|reload)
                stop
                sleep 1
                start
                ;;
        *)
                echo "Usage $0 {start|stop|restart}"
                exit 1
esac
-----

ympdのスタートアップファイルを作成します。
root@kuro:~/work/buildroot-2017.08# vi rootfs-overlay/etc/init.d/S96ympd
-----
/bin/sh
### BEGIN INIT INFO
# Provides:          ympd
# Required-Start:    $local_fs $mpd
# Required-Stop:     $local_fs $mpd
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Daemonized version of ympd.
# Description:       Enable service provided by ympd.
### END INIT INFO
#Author: Andrew Karpow 

. /lib/lsb/init-functions

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="ympd Daemon"
NAME=ympd
DAEMON=/usr/bin/$NAME
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
LOG_OUT=/var/log/$NAME.out
LOG_ERR=/var/log/$NAME.err
YMPD_USER=mpd
DAEMON_OPT="--user $YMPD_USER --webport 80"

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
[ -f /etc/default/rcS ] && . /etc/default/rcS

do_start()
{
    start-stop-daemon --start --background --quiet --pidfile $PIDFILE --make-pidfile \
        --exec $DAEMON --test > /dev/null || return 1
    start-stop-daemon --start --background --quiet --pidfile $PIDFILE --make-pidfile \
        --exec $DAEMON -- $DAEMON_OPT || return 2
}
do_stop()
{
    start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
    RETVAL="$?"

    [ "$RETVAL" = 2 ] && return 2
    rm -f $PIDFILE
    return "$RETVAL"
}

case "$1" in
  start)
    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
    do_start
    case "$?" in
        0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
        2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
    esac
    ;;
  stop)
    [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
    do_stop
    case "$?" in
        0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
        2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
    esac
    ;;
  status)
    status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
    ;;
  restart|force-reload)
    #
    # If the "reload" option is implemented then remove the
    # 'force-reload' alias
    #
    log_daemon_msg "Restarting $DESC" "$NAME"
    do_stop
    case "$?" in
      0|1)
        do_start
        case "$?" in
            0) log_end_msg 0 ;;
            1) log_end_msg 1 ;; # Old process is still running
            *) log_end_msg 1 ;; # Failed to start
        esac
        ;;
      *)
        # Failed to stop
        log_end_msg 1
        ;;
    esac
    ;;
  *)
    echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
    exit 3
    ;;
esac
-----

作成したスタートアップファイルに実行権を設定します。
root@kuro:~/work/buildroot-2017.08# chmod 755 rootfs-overlay/etc/init.d/S*

usbに接続したときに呼ばれるシェルを作成します。
root@kuro:~/work/buildroot-2017.08# vi rootfs-overlay/etc/mdev/scripts/dev-bus-usb.sh
-----
#!/bin/sh

umask 022

sys_path="/sys/${DEVPATH}"

case "${ACTION}" in
    'add')
        [ "${BUSNUM}" ] || return 1
        [ "${DEVNUM}" ] || return 1
        [ "${MAJOR}" ] || return 1
        [ "${MINOR}" ] || return 1
        mkdir -p "/dev/bus/usb/${BUSNUM}"
        [ "/dev/${MDEV}" != "/dev/bus/usb/${BUSNUM}/${DEVNUM}" ] && mv "/dev/${MDEV}" "/dev/bus/usb/${BUSNUM}/${DEVNUM}"
        [ "${DEVPATH}" ] || return 1

        if [ -f "${sys_path}/product" ]; then
            idVendor="$(cat ${sys_path}/idVendor)"
            case "${idVendor}" in
                '0bb4'|'18d1'|'22b8'|'0fce'|'19d2'|'04e8'|'2717'|'05c6')
                chgrp 'plugdev' "/dev/bus/usb/${BUSNUM}/${DEVNUM}" 2>/dev/null && chmod 660 "/dev/bus/usb/${BUSNUM}/${DEVNUM}"
            ;;
            esac
        fi

    ;;
    'remove')
        [ "${BUSNUM}" ] || return 1
        [ "${DEVNUM}" ] || return 1
        [ "${MAJOR}" ] || return 1
        [ "${MINOR}" ] || return 1
        rm "/dev/bus/usb/${BUSNUM}/${DEVNUM}"
        rmdir "/dev/bus/usb/${BUSNUM}" 2>/dev/null
        rmdir "/dev/bus/usb" 2>/dev/null

    ;;
esac
-----

実行権を設定します。
root@kuro:~/work/buildroot-2017.08# chmod 755 rootfs-overlay/etc/mdev/scripts/dev-bus-usb.sh

ympdのスタートアップから呼ばれるスクリプトを定義します。
root@kuro:~/work/buildroot-2017.08# vi rootfs-overlay/lib/lsb/init-functions
-----
#!/bin/sh

log_daemon_msg() { logger "$@"; }
log_end_msg() { [ $1 -eq 0 ] && RES=OK; logger ${RES:=FAIL}; }
-----

実行権を設定します。
root@kuro:~/work/buildroot-2017.08# chmod 755 rootfs-overlay/lib/lsb/init-functions

mpdの状態を設定するファイルを作成します。
root@kuro:~/work/buildroot-2017.08# touch rootfs-overlay/var/lib/mpd/state

配布するファイル群の設定ファイルやイメージを格納するフォルダを作成します。
root@kuro:~/work/buildroot-2017.08# cd ..
root@kuro:~/work# mkdir config
root@kuro:~/work# mkdir image
root@kuro:~/work# cd config
root@kuro:~/work/config# mkdir -p mpd/var/lib/mpd
root@kuro:~/work/config# mkdir Music
root@kuro:~/work/config# mkdir -p root/root/bin
root@kuro:~/work/config# mkdir -p root/etc
root@kuro:~/work/config# touch  mpd/var/lib/mpd/database
root@kuro:~/work/config# touch  mpd/var/lib/mpd/tag_cache

カーネルの起動引数の設定ファイルを作成します。
root@kuro:~/work/config# vi cmdline.txt
-----
console=ttyAMA0,115200
-----

カーネルの起動パラメータファイルを作成します。
root@kuro:~/work/config# vi config.txt
-----
kernel=zImage
#initramfs rootfs.cpio.gz
disable_overscan=1
# gpu_mem_256=100
# gpu_mem_512=100
# gpu_mem_1024=100
dtparam=i2c_arm=on
dtparam=i2s=on
dtparam=spi=on
dtdebug=on
dtoverlay=hifiberry-dac
-----

SDカードをマウントするシェルを作成します。
root@kuro:~/work/config# vi root/root/bin/S90mount
-----
#!/bin/sh

start() {
        printf "Starting mount smb"
        #mount -t cifs //[NASのIPアドレス]/share /mnt -o username=[ユーザ名],password=[パスワード],iocharset=utf8
        mount -t vfat /dev/mmcblk0p1 /mnt
}

stop() {
        printf "Stopping mount smb"
        umount /mnt
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart|reload)
                stop
                sleep 1
                start
                ;;
        *)
                echo "Usage $0 {start|stop|restart}"
                exit 1
esac
-----

mpdの設定ファイルを作成します。
root@kuro:~/work/config# vi root/etc/mpd.conf
-----
database {
   plugin   "simple"
   path    "/mnt/mpd/var/lib/mpd/tag_cache"
   compress   "no"
}

music_directory         "/mnt/Music"

# Directory where user-made playlists are stored (RW)
playlist_directory      "/mnt/mpd/var/lib/mpd"

# Database file (RW)
#db_file                        "/mnt/mpd/var/lib/mpd/database"

# Log file (RW)
log_file                "/dev/null"

# Process ID file (RW)
pid_file                "/var/run/mpd.pid"

# State file (RW)
state_file              "/var/lib/mpd/state"

# User id to run the daemon as
#user                   "nobody"

# TCP socket binding
bind_to_address         "any"
#bind_to_address        "localhost"

auto_update "yes"
audio_output_format             "192000:24:2"
samplerate_converter            "soxr very high"
mixer_type "disabled"
filesystem_charset              "UTF-8"
id3v1_encoding                  "UTF-8"

# Unix socket to listen on
#bind_to_address                "/var/lib/mpd/socket"

audio_output {
    type "alsa"
    name "my ALSA device"
    device "hw:0"
}
-----

buildrootに戻ってコンパイルします。
root@kuro:~/work/config# cd ../buildroot-2017.08
root@kuro:~/work/buildroot-2017.08# make -j40

コンパイルが終わったら、ファイルをコピーします。
root@kuro:~/work/buildroot-2017.08# cd ../image

コマンドは以下の通りです。
rm -r *
cp ../buildroot-2017.08/output/images/zImage .
cp ../buildroot-2017.08/output/images/bcm2708-rpi-b-plus.dtb .
cp ../buildroot-2017.08/output/images/bcm2708-rpi-0-w.dtb .
cp ../buildroot-2017.08/output/images/bcm2708-rpi-b.dtb .
cp -r ../buildroot-2017.08/output/images/rpi-firmware/* .
cp ../buildroot-2017.08/output/images/rootfs.romfs .
cp -r ../config/* .

WindowsへWinSCP等でファイル転送し、FATでフォーマットしたSDカードにファイルをコピーします。
Musicフォルダに曲をコピーします。転送が終わったらWindowsからSDカードを取り出しし、Raspberry piに SDカードを刺して電源を入れます。しばらくしてWebブラウザで「http://kuro.local:8080/」に アクセスしてympdが表示されることを確認します。databaseから曲(フォルダ)を選択して追加し、Queueで曲を選択して 曲が流れることを確認して押しまいです。
ympdは電源切ってしまうと設定した曲を再度設定しないといけないところが使いにくいですね。

nice!(0)  コメント(0)