Giter Club home page Giter Club logo

rpimp3player's Introduction

rpimp3player

Buildroot configuration to turn a raspberry pi into a dumb mp3 player

steps

Clone buildroot's git repository,load rpi's config file and modify it

git clone https://github.com/buildroot/buildroot
cd buildroot
make raspberrypi_defconfig
make menuconfig

Select configuration options.

Toolchain -- > enable WCHAR support
System configuration --> root filesystem overlay directories (overlay)
System configuration --> /dev management (Dynamic using devtmpfs + eudev)
Target packages --> audio and video --> alsa-utils
Target packages --> audio and video --> mpg123
Target packages --> filesystem and flash utilities --> exfatprogs
Target packages --> filesystem and flash utilities --> ntfs-3g
Target packages --> Hardware handling --> enable hwdb installation
Filesystem images --> initial RAM filesystem linked into linux kernel

Create a folder named "overlay" with our customizations. This file sets the headphones as default audio output.

/etc/asound.conf

defaults.pcm.card 1
defaults.ctl.card 1

This script loads the soundcard module, mounts the pendrive, creates a playlist and starts playing.

/root/start.sh

modprobe snd-bcm2835
mkdir -p /media/musika
mount /dev/sda1 /media/musika -o ro
find /media/musika/ -name "*.mp3" > /tmp/lista.m3u 
mpg123 -@ /tmp/lista.m3u

This file is a copy of the original inittab, but replaces the login console with the previous script.

/etc/inittab

...
#tty1::respawn:/sbin/getty -L  tty1 0 vt100 # HDMI console
tty1::respawn:-/bin/sh /root/start.sh
...

Soundcard is disabled by default so we have to enable it. Add a line at the end of file.

board/raspberrypi/config_default.txt

...
dtparam=audio=on
hdmi_force_hotplug=1
...

Second line forces video output through hdmi. Without that option, if there is no hdmi screen attached the board outputs audio AND VIDEO through jack (so we can use 3.5mm auxiliary to composite cables).

I want to run the system in ram, so uncomment this line too.

board/raspberrypi/config_default.txt

...
#initramfs rootfs.cpio.gz
initramfs rootfs.cpio.gz
...

Modify this file to add rootfs.cpio.gz to our image, and change the size to 64M (original is 32M).

board/raspberrypi/genimage-raspberrypi.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",
                        "rootfs.cpio.gz",
                        "zImage"
                }
        }

        size = 64M
}
...

Run the project

make

Special thanks to

https://marcocetica.com/posts/buildroot-tutorial/

https://agentoss.wordpress.com/2011/03/02/how-to-build-a-tiny-linux-mp3-player-system-using-buildroot/

https://www.raspberrypi.com/news/latest-raspberry-pi-os-update-may-2020/

extra: control it with a keypad

I wanted to control the mp3 player but didn't want to use a full keyboard so plugged this keypad and configured it

https://www.amazon.es/gp/product/B00VQ3DR1E

First I found the vendor's code with lsusb (13ba)

lsusb

Bus 001 Device 014: ID 13ba:0001 PCPlay Konig Electronic CMP-KEYPAD12 Numeric Keypad

Then I found it's modalias

find /sys -name *modalias | xargs grep -i 13ba

/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:13BA:0001.0004/input/input22/modalias:input:b0003v13BAp0001e0110-e0,1,4,11,14,k71,72,73,74,75,77,79,7A,7B,7C,7D,7E,7F,80,81,82,83,84,85,86,87,88,89,8A,B7,B8,B9,BA,BB,BC,BD,BE,BF,C0,C1,C2,F0,ram4,l0,1,2,sfw

Finally got the key codes with evtest

evtest

Event: time 1651002716.523273, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7005d
Event: time 1651002716.523273, type 1 (EV_KEY), code 76 (KEY_KP5), value 1
...

And wrote the configuration file

/etc/udev/hwdb.d/numkeypad.hwdb

evdev:input:b0003v13BAp0001*
KEYBOARD_KEY_7005d=s
KEYBOARD_KEY_7005c=d
KEYBOARD_KEY_7005e=f
KEYBOARD_KEY_70060=leftbrace
KEYBOARD_KEY_7005a=rightbrace
KEYBOARD_KEY_70054=comma
KEYBOARD_KEY_70055=dot

Thanks to

https://askubuntu.com/questions/742946/how-to-find-the-hwdb-header-of-a-general-input-device

https://www.rigacci.org/wiki/doku.php/doc/appunti/linux/sa/remap_keyboard_keys

rpimp3player's People

Contributors

cesetxeberria avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.