SSブログ
電子工作 ブログトップ
前の10件 | -

表示パネルの作り方 [電子工作]

OPAです。

VolumioプラグインのページにあるArgon ONE Raspberry Pi 4 ケースに取り付けた表示パネルの作り方について、要望がありましたので、まとめてみました。
工作もはんだ付けも初心者並みなので、笑われてしまいそうですが、暴露します。。
使用した主な部品は、秋月電子様で購入できるものです。
    20201018.jpg


  1. 基板上の部品を配置し、ピンヘッダを配置する部分をドリルで穴をあけ、やすりで四角に整える(適当でよい。ピンヘッダは きつめに入るように調整)。その後、基板の不要な部分を削除する。削除した側のねじ穴をあける。
  2. 大きさを調整した基板をアクリル板の片側のねじ穴に止めて、アクリル板を削除する部分の目安を付け、アクリル板を削除する。この時、もう片側のネジ穴をあける位置をマーカしてから削除する。削除後にネジ穴をあける。
  3. 部品を基板に配置し、ランド面で配線する。配線終わったら動作確認。
  4. アクリルパネルと基板をスペーサーまたはナットを使って液晶面の高さに合わせて固定する。ランド面側も同じアクリル板で 加工しておくと、配線が隠れていいかもしれない。
2020_09_22 16_07.jpg


基板のネジ穴の位置が、一番外側のランドの並びと一致していることに気付くのが遅れて、写真の基板には不要な穴が開いています。基板もアクリル板も脆いので慎重に加工したほうがいいと思います。私はアクリル板に新たに開けたネジ穴はヒビが入ってしまってます。スペーサーはいいサイズが手元になかったのでナットを使っています。見栄えのいいものがありましたらコメントください。
nice!(0)  コメント(13) 

タカチのケースに入れてみた [電子工作]

OPAです。
有機ELディスプレイも使えるようになったので、タカチのケースに入れてみました。参考にしたのは、new_western_elec http://nw-electric.way-nifty.com/blog/2015/10/sabreberryel-4a.html です。

ケース.JPG

アクリルパネルはこちら https://shop.emergeplus.jp/sabreberry-acrylicpanel/ から購入しました。

アクリルパネル.JPG

ケースはAmazonで購入しました。
参考まで。
nice!(0)  コメント(0) 

PCM5102A DIP化キットと0.96インチ 128×64ドット有機ELディスプレイ(OLED)の実験基板作成 [電子工作]

OPAです。週末に出来事がなかったわけではありませんでしたが、更新が久しぶりになっています。
秋月電子さんの「PCM5102A DIP化キット」を使ったRaspberry PiのDAC化基板です。Volumioでも使えます。チップ部品を使っていないので、おじさんにもつくれちゃう。

AKI-PCM5102A基板.jpg

秋月電子さんの「0.96インチ 128×64ドット有機ELディスプレイ(OLED)」を 使ったRaspberry piの制御基板です。volumio のプラグインも作成しました。基板上にタクトスイッチを配置したので、GPIO Buttonsプラグインで制御もできます。

有機ELディスプレイ基板.jpg

raspberry pi Zeroだとvolumioを使うのは厳しいので、独自にLinuxをコンパイルして音楽再生と曲名を表示するパッケージも作成しました。

AKI-PCM5102基板と有機EL基板.jpg

Raspberry pi 3Bとの組み合わせです。volumioで再生できます。

Rpi3.jpg


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

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) 

秋月のPCM5102A DIP化キットでDAC [電子工作]

秋月さんのPCM5102A DIP化キットでRaspberry pi のI2S接続DACをユニバーサル基板で作成しました。PCM5102Aチップ単体で手に入れるより、入手しやすさから作ってみました。自前でコンパイルしたLinux上でympdで音を出すことに成功しました。

DSC_0041.JPG

回路図と配線図はDesignSparkを使いました。

PIC5102ADIP2.JPG

PIC5102ADIP1.JPG

nice!(0)  コメント(0) 
共通テーマ:趣味・カルチャー

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

rootfs-overlayにコンパイルしてイメージに格納するファイルを上書きするものを格納します。
root@kuro:~/work/buildroot-2017.05# ls -R rootfs-overlay/
rootfs-overlay/:
etc  lib  var

rootfs-overlay/etc:
asound.conf  default  init.d  mdev.conf

rootfs-overlay/etc/default:

rootfs-overlay/etc/init.d:
S11setup  S90tools  S96ympd

rootfs-overlay/lib:
lsb

rootfs-overlay/lib/lsb:
init-functions

rootfs-overlay/var:
lib

rootfs-overlay/var/lib:
mpd

rootfs-overlay/var/lib/mpd:
music  state

rootfs-overlay/var/lib/mpd/music:

前にも出てきましたがasound.confファイルです。
pcm.!default  {
 type hw card 0
}
ctl.!default {
 type hw card 0
}
mdev.confはoutput/target/etcにあるコピーしてきてethernetの設定を追加します。
(eth.*)         root:netdev 660 >net/%1 @/sbin/ifup $INTERFACE
rootfs-overlay/etc/init.dディレクトリには、起動時に実行してほしい実行ファイルを格納します。 S11setupは、SDカードからファイルをコピーします。S90toolsはコピーした実行ファイルを起動させます。S96ympdはympdをコンパイル対象にした場合に使います。それぞれchmod 755で実行権を付けます。
S11setupは以下の通りです。SDカードをマウントしてファイルをコピーしてアンマウントしているだけです。
#!/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
S90toolsファイルはコピーした実行ファイルを実行します。/etc/init.dに直接コピーしてもinit.dが起動した後のため、実行されません。そこで、実行ファイルを/root/binディレクトリにコピーしてそのファイルを実行する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
S96ympdファイルは、output/build/ympd-v1.2.3/contrib/init.debianをコピーして作成します。
S96ympdで必要なinit-functionsファイルを作成します。このファイルもchmod 755で実行権を付けます。
#!/bin/sh

log_daemon_msg() { logger "$@"; }
log_end_msg() { [ $1 -eq 0 ] && RES=OK; logger ${RES:=FAIL}; }
stateファイルは、touchコマンドで作成し、chmod 666で読み書き権限を付与します。
つぎにSDカードに格納するファイルを作成します。
root@kuro:~/work/config# ls -R root/
root/:
etc  root

root/etc:
init.d  mpd.conf

root/etc/init.d:

root/root:
bin

root/root/bin:
S90mount
S90mountは、自宅のsambaサーバのフォルダをマウントするのに用意しました。root/binフォルダに置かれるファイルは先ほどの/etc/init.d/S90toolsファイルから起動されます。NASの/shareを/mntにマウントします。
#!/bin/sh

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

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.confファイルはマウントしたNASにある音楽ファイルを指定するようにします。必要に応じてNAS上にファイルやディレクトリを作成してください。
music_directory         "/mnt/Music"

playlist_directory      "/mnt/mpd/var/lib/mpd"

db_file                 "/mnt/mpd/var/lib/mpd/database"

log_file                "/mnt/mpd/var/log/mpd.log"

pid_file                "/var/run/mpd.pid"

state_file              "/var/lib/mpd/state"

#user                   "nobody"

bind_to_address         "any"

bind_to_address         "/var/lib/mpd/socket"

SDカードのマウント [電子工作]

SDカードをマウントします。起動時にいろいろな設定ファイルをSDカードからコピーすれば、いちいちコンパイルする必要がなくなります。
# mount -t vfat /dev/mmcblk0p1 /mnt
アンマウントは、
# umount /mnt
です。

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

前回、Linuxをコンパイルしたのですが、DACのドライバが認識しなくて悩んでいたのですが、 buildrootの新しいのを使って再度コンパイルしてみました。
root@kuro:~/work# wget https://buildroot.uclibc.org/downloads/buildroot-2017.05.tar.gz
root@kuro:~/work# tar xvf buildroot-2017.05.tar.gz
root@kuro:~/work# cd buildroot-2017.05
設定の準備をします。
root@kuro:~/work/buildroot-2017.05# cp configs/raspberrypi_defconfig configs/raspberrypi1_defconfig
root@kuro:~/work/buildroot-2017.05# cp -r board/raspberrypi board/raspberrypi1
root@kuro:~/work/buildroot-2017.02.2$ vi configs/raspberrypi1_defconfig
-----
BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi1/post-build.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi1/post-image.sh"
-----
root@kuro:~/work/buildroot-2017.05# cp board/raspberrypi1/genimage-raspberrypi.cfg board/raspberrypi1/genimage-raspberrypi1.cfg

root@kuro:~/work/buildroot-2017.05# vi board/raspberrypi1/genimage-raspberrypi1.cfg

-----
image boot.vfat {
  vfat {
    files = {
      "bcm2708-rpi-b.dtb",
      "bcm2708-rpi-b-plus.dtb",
      "bcm2708-rpi-cm.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"
  }
}
-----
設定を行います。
root@kuro:~/work/buildroot-2017.05# make raspberrypi1_defconfig
root@kuro:~/work/buildroot-2017.05# make menuconfig
------
-----
Toolchain  --->
 custom toolchain vendor name
  kuro
 Custom kernel headers series (4.11.x)  --->
  (X) 4.10.x
 [*] Enable WCHAR support
System configuration  --->
 System hostname
  kuro
 System banner
  Welcome to Kuro
  /dev management (Dynamic using devtmpfs only)  --->
   (X) Dynamic using devtmpfs + mdev
 Root password
  root123
 Run a getty (login prompt) after boot  --->
  (console) TTY port
   ttyAMA0
  Baudrate (keep kernel default)  --->
   115200
 ()  Root filesystem overlay directories
  rootfs-overlay
Kernel  --->
 Kernel version (Custom Git repository)  --->
  (X) Custom Git repository
 (rpi-4.10.y) Custom repository version
  rpi-4.10.y
 Linux Kernel Tools  --->
  [*] gpio
Target packages  --->
 Audio and video applications  --->
 [*] alsa-utils  --->
  [*]   alsactl (NEW)
  [*]   alsamixer (NEW)
  [*]   aplay/arecord
 [*] ffmpeg  --->
  [*]   Enable GPL code
  [*]   Build ffmpeg (the command line application) (NEW)
  [*]   Enable input devices (NEW)
  [*]   Enable output devices (NEW)
  [*]   Build libavresample
 [*] flac
 [*] lame
 [*] mpd  --->
  [*]   libsamplerate
  [*]   libsoxr
  [*]   dsd
  [*]   ffmpeg
  [*]   flac
  [*]   lame
 [*] mpd-mpc
 [*] mplayer
 [*] Build and install mplayer (NEW)
Filesystem and flash utilities  --->
 [*] nfs-utils
  [*]   rpc.lockd
Interpreter languages and scripting  --->
 [*] python
Networking applications  --->
 [*] bluez-utils
  [*]   audio support
  [*]   USB support
  [*]   GATT support
 [*] dropbear
 [*] openssh
Filesystem images  --->
 [*] initial RAM filesystem linked into linux kernel
 [*] romfs root filesystem
-----
root@kuro:~/work/buildroot-2017.05# vi .config
-----
BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS=y
BR2_TARGET_ROOTFS_EXT2_BLOCKS=250000
------
今回の変更点は、カーネルを4.9から4.10へ、/devのマネジメントをmdevにしたところです。
設定を取っておきます。
root@kuro:~/work/buildroot-2017.05# cp .config build_config
Linuxの設定を行います。
root@kuro:~/work/buildroot-2017.05# make linux-menuconfig
-----
General setup  --->
 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
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
  < > 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  --->
 [ ] Multiple devices driver support (RAID and LVM)  ----
 [*] Network device support  --->
  < >     Bonding driver support
  < >     Dummy net driver support
  < >     MAC-VLAN support
  < >     IP-VLAN support
  < >     Virtual eXtensible Local Area Network (VXLAN)
  < >     Universal TUN/TAP device driver support
  < >     Virtual ethernet pair device
  < >   PPP (point-to-point protocol) support
  < >   SLIP (serial line) support
  < >   IEEE 802.15.4 drivers  ----
  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  ----
 [*] USB support  --->
  < >     Synopsis DWC host support
  < >     USB Printer support
  < >       Realtek Card Reader support
  < >       Datafab Compact Flash Reader support
  < >       Freecom USB/ATAPI Bridge support
  < >       ISD-200 USB/ATA Bridge support
  < >       USBAT/USBAT02-based storage support
  < >       SanDisk SDDR-09 (and other SmartMedia, including DPCM) support
  < >       SanDisk SDDR-55 SmartMedia support
  < >       Lexar Jumpshot Compact Flash Reader
  < >       Olympus MAUSB-10/Fuji DPC-R1 support
  < >       Support OneTouch Button on Maxtor Hard Drives
  < >       Support for Rio Karma music player
  < >       SAT emulation on Cypress USB/ATA Bridge with ATACB
  < >       USB ENE card reader support
  < >     USB Mustek MDC800 Digital Camera support
  < >     Microtek X6USB scanner support
  < >   DesignWare USB2 DRD Core Support
  < >   ADU devices from Ontrak Control Systems
  < >   USB 7-Segment LED Display
  < >   USB Diamond Rio500 support
  < >   USB Lego Infrared Tower support
  < >   USB LCD driver support
  < >   USB LED 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
  < >   USB Gadget Support  ----
 < > Industrial I/O support  ----
-----
Linuxの設定はXFree86 4.1.0のマネージャを切ったことです。
独自に設定を格納するためのディレクトリを作成します。
root@kuro:~/work/buildroot-2017.05# mkdir -p rootfs-overlay/etc
root@kuro:~/work/buildroot-2017.05# mkdir -p rootfs-overlay/var/lib/mpd
root@kuro:~/work/buildroot-2017.05# vi rootfs-overlay/etc/asound.conf
------
pcm.!default  {
 type hw card 0
}
ctl.!default {
 type hw card 0
}
------
コンパイルします。
root@kuro:~/work/buildroot-2017.05# make -j40
コンパイルできた後、一旦できたファイルを削除します。
rm output/build/linux-rpi-4.10.y/arch/arm/boot/zImage
rm output/images/rootfs.*
rm output/images/sdcard.img
rm output/images/boot.vfat
rm output/images/zImage
設定ファイルをコピーします。
root@kuro:~/work/buildroot-2017.05# cp output/target/etc/mdev.conf ootfs-overlay/etc
以下を追加します。
#network interface 
(eth.*)         root:netdev 660 >net/%1 @/sbin/ifup $INTERFACE
再度コンパイルします。
root@kuro:~/work/buildroot-2017.05# make
コンパイルしたものをWindowsへもっていく準備をします。
root@kuro:~/work$ mkdir image
root@kuro:~/work$ mkdir config
root@kuro:~/work$ cd config
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
dtoverlay=hifiberry-dac
-----
root@kuro:~/work/config# cd ../image
イメージを持ってきます。
cp ../buildroot-2017.05/output/images/zImage .
cp ../buildroot-2017.05/output/images/bcm2708-rpi-b-plus.dtb .
cp -r ../buildroot-2017.05/output/images/rpi-firmware/* .
cp ../buildroot-2017.05/output/images/rootfs.romfs .
cp ../config/* .
Windowsへもっていき、FATでフォーマットしたSDカードにコピーして出来上がりです。
root@kuro:~/work/image# ls
bcm2708-rpi-b-plus.dtb  cmdline.txt  fixup.dat  rootfs.romfs  zImage
bootcode.bin            config.txt   overlays   start.elf

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

Raspberry Pi Zeroに乗せるLinuxカーネルのコンパイルをしてみました。ubuntu-16.04.2-serverをHyper-Vで動かします。SSHサーバの設定で戸惑いましたが、無事にtera-termからsshでつながるようになりました。
まず最初に必要なツールをインストールします。
root@kuro:~$ sudo su -
[sudo] password for kuro:
root@kuro:~#
root@kuro:~$ apt-get update
root@kuro:~$ apt-get install make gcc git libncurses-dev bc unzip g++ genromfs subversion texinfo python
つぎにworkディレクトリを作成し、buildrootをダウンロードして展開します。
root@kuro:~$ mkdir work
root@kuro:~$ cd work
root@kuro:~/work$ wget https://buildroot.uclibc.org/downloads/buildroot-2017.02.2.tar.gz
root@kuro:~/work$ tar xvf buildroot-2017.02.2.tar.gz
root@kuro:~/work$ cd buildroot-2017.02.2

カーネルのバージョンをbuildrootのデフォルトのバージョンとは異なるバージョンでコンパイルするため、buildrootの設定ファイルをコピーして使用します。(編集内容は変更のあるところを抜き出して書いています)
root@kuro:~/work/buildroot-2017.02.2$ cp  configs/raspberrypi0_defconfig configs/raspberrypi1_defconfig
root@kuro:~/work/buildroot-2017.02.2$ cp -r board/raspberrypi0 board/raspberrypi1
root@kuro:~/work/buildroot-2017.02.2$ vi configs/raspberrypi1_defconfig
-----
BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi1/post-build.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi1/post-image.sh"
-----
root@kuro:~/work/buildroot-2017.02.2# mv board/raspberrypi0/genimage-raspberrypi.cfg board/raspberrypi1/genimage-raspberrypi1.cfg
root@kuro:~/work/buildroot-2017.02.2$ vi board/raspberrypi0/genimage-raspberrypi1.cfg
-----
image boot.vfat {
  vfat {
    files = {
      "bcm2708-rpi-b-plus.dtb",
      "rpi-firmware/bootcode.bin",
      "rpi-firmware/cmdline.txt",
      "rpi-firmware/config.txt",
      "rpi-firmware/fixup.dat",
      "rpi-firmware/start.elf",
      "zImage"
    }
  }
  size = 256M
}
-----

コンパイルするための設定をおこないます。
root@kuro:~/work/buildroot-2017.02.2$ make raspberrypi1_defconfig
root@kuro:~/work/buildroot-2017.02.2$ make menuconfig
-----
Toolchain  --->
 custom toolchain vendor name
  kuro
 Custom kernel headers series (4.4.x)  --->
  (X) 4.9.x
 [*] Enable RPC support
 [*] Enable WCHAR support
System configuration  --->
 System hostname
  kuro
 System banner
  Welcome to Kuro
 Root password
  root123
 Run a getty (login prompt) after boot  --->
  (console) TTY port
   ttyAMA0
  Baudrate (keep kernel default)  --->
   115200
 ()  Root filesystem overlay directories
  rootfs-overlay
Kernel  --->
 Custom repository version
  rpi-4.9.y
 Linux Kernel Tools  --->
  [*] gpio
Target packages  --->
 Audio and video applications  --->
 [*] alsa-utils  --->
  [*]   alsactl (NEW)
  [*]   alsamixer (NEW)
  [*]   aplay/arecord
 [*] ffmpeg  --->
  [*]   Build ffmpeg (the command line application) (NEW)
  [*]   Enable input devices (NEW)
  [*]   Enable output devices (NEW)
  [*]   Build libavresample
 [*] flac
 [*] lame
 [*] mpd  --->
  [*]   libsamplerate
  [*]   libsoxr
  [*]   dsd
  [*]   ffmpeg
  [*]   flac
  [*]   lame
 [*] mpd-mpc
 [*] mplayer
 [*] Build and install mplayer (NEW)
Filesystem and flash utilities  --->
 [*] nfs-utils
  [*]   rpc.lockd
Interpreter languages and scripting  --->
 [*] python
Networking applications  --->
 [*] bluez-utils
  [*]   audio support
  [*]   USB support
  [*]   GATT support
 [*] dropbear
 [*] openssh
Filesystem images  --->
 [*] initial RAM filesystem linked into linux kernel
 [*] romfs root filesystem
-----

一部設定を書き換えてバックアップしておきます。こうすることでmake menuconfigの設定を省くことができます。
root@kuro:~/work/buildroot-2017.02.2$ vi .config
-----
BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS=y
-----
root@kuro:~/work/buildroot-2017.02.2$ cp .config configs/raspberrypi1_defconfig

次にLinuxカーネルのコンパイル設定を行います。
root@kuro:~/work/buildroot-2017.02.2$ make linux-menuconfig
-----
General setup  --->
 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
Boot options  --->
 (console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ex
  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
  < > 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  --->
 [ ] Multiple devices driver support (RAID and LVM)  ----
 [*] Network device support  --->
  < >     Bonding driver support
  < >     Dummy net driver support
  < >     MAC-VLAN support
  < >     IP-VLAN support
  < >     Virtual eXtensible Local Area Network (VXLAN)
  < >     Universal TUN/TAP device driver support
  < >     Virtual ethernet pair device
  < >   PPP (point-to-point protocol) support
  < >   SLIP (serial line) support
  < >   IEEE 802.15.4 drivers  ----
  Multimedia support  --->
  [ ]   Analog TV support
  [ ]   Digital TV support
  [ ]   AM/FM radio receivers/transmitters support
 [*] USB support  --->
  < >     Synopsis DWC host support
  < >     USB Printer support
  < >       Realtek Card Reader support
  < >       Datafab Compact Flash Reader support
  < >       Freecom USB/ATAPI Bridge support
  < >       ISD-200 USB/ATA Bridge support
  < >       USBAT/USBAT02-based storage support
  < >       SanDisk SDDR-09 (and other SmartMedia, including DPCM) support
  < >       SanDisk SDDR-55 SmartMedia support
  < >       Lexar Jumpshot Compact Flash Reader
  < >       Olympus MAUSB-10/Fuji DPC-R1 support
  < >       Support OneTouch Button on Maxtor Hard Drives
  < >       Support for Rio Karma music player
  < >       SAT emulation on Cypress USB/ATA Bridge with ATACB
  < >       USB ENE card reader support
  < >     USB Mustek MDC800 Digital Camera support
  < >     Microtek X6USB scanner support
  < >   DesignWare USB2 DRD Core Support
  < >   ADU devices from Ontrak Control Systems
  < >   USB 7-Segment LED Display
  < >   USB Diamond Rio500 support
  < >   USB Lego Infrared Tower support
  < >   USB LCD driver support
  < >   USB LED 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
  < >   USB Gadget Support  ----
 < > Industrial I/O support  ----
-----

buildrootと同様の設定をバックアップしておきます。
root@kuro:~/work/buildroot-2017.02.2$ cp output/build/linux-rpi-4.9.y/.config linux_config

必要なディレクトリを作成します。
root@kuro:~/work/buildroot-2017.02.2$ mkdir rootfs-overlay

コンパイルします。
root@kuro:~/work/buildroot-2017.02.2$ make -j40

ビルドが終わったら必要なファイルをコピーするディレクトリを作成します。
root@kuro:~/work/buildroot-2017.02.2$ make -j40
root@kuro:~/work/buildroot-2017.02.2$ cd ..
root@kuro:~/work$ mkdir image
root@kuro:~/work$ cd image/

コピーします。
cp ../buildroot-2017.02.2/output/images/zImage .
cp ../buildroot-2017.02.2/output/images/bcm2708-rpi-b-plus.dtb .
cp -r ../buildroot-2017.02.2/output/images/rpi-firmware/* .
cp ../buildroot-2017.02.2/output/images/rootfs.romfs .

設定ファイルを編集します。
root@kuro:~/work/image$ vi cmdline.txt
-----
console=ttyAMA0,115200
-----
root@kuro:~/work/image$ vi config.txt
-----
kernel=zImage

#initramfs rootfs.cpio.gz

disable_overscan=1

# gpu_mem_256=100
# gpu_mem_512=100
# gpu_mem_1024=100


ファイルをwindowsへもっていき(WinScpなど)FATでフォーマットしたSDカードにファイルをコピーしておしまいです。

動作確認 [電子工作]

コネクタも来たので実装してみました。まだ仮配線ですが、今度はケースをアクリル板で作りたい と思います。レーザーカッターなんてないので、普通のカッターですけど。 動作確認しました。ちょっとノイズが入るようですが、たぶんコンデンサ周りの接触不良かと。素人なんで高い器具もっていないので、よくわからないんですが、たぶんそうでしょう。半田を来週にでも再度当ててみます。

DSC_0019.JPG

前の10件 | - 電子工作 ブログトップ

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。