2. Transplantation of embedded player madplay
The madplay player program mainly depends on the following libraries:
zlib zlib-1.1.4.tar.gz Provides a library for data compression
libid3tag libid3tag-0.15.1b.tar.gz MP3 file ID3 tag analysis library
libmad libmad-0.15.1b.tar.gz High-precision MPEG audio decoding library, supporting MPEG-1 (Layer I, Layer II and LayerIII (that is, MP3)
Copy the following contents of the resource directory in the sdk to the Linux system. Suppose we copy it to /home/Project/Motion/OK6410/Resource and enter this directory.
Now install these libraries in the root file system in turn:
1. File preparation:
Unzip the 4 source code packages in the provided madplay directory, using the command:
tar -xzf libid3tag-0.15.1b.tar.gz
tar -xzf libmad-0.15.1b.tar.gz
tar -xzf zlib-1.1.4.tar.gz
tar -xzf madplay-0.15.2b.tar.gz
2. Compile and install zlib:
a. Enter the zlib source directory. Use the command: ./configure --shared --prefix=_install to generate a Makefile. Among them, —shared indicates that a dynamic library can be generated, and --prefix=_install indicates the installation path of the library and header files after executing make install. The _install specified here does not exist, so it needs to be created in the top-level directory of zlib. Use the command: mkdir _install to create the directory.
b. Modify the Makefile. The following content needs to be modified:
CC=arm-linux-gcc
LDSHARED=arm-linux-gcc -shared -Wl,-soname,libz.so.1
CPP=arm-linux-gcc -E
AR=arm-linux-ar
RANLIB=arm-linux-ranlib
c. Use the command: make to compile the source code
Use the command: make install to install the generated library and header files to the specified directory, of course, this refers to the _install directory we created earlier.
d. Copy the generated dynamic library to the lib directory under the root file system /nfs/rootfs
Use the command: cp _install/lib/*.so* /nfs/rootfs/lib. Of course, if these libraries already exist, there is no need to copy them.
e. Copy the generated dynamic library and header files to the library and header file directories under the cross-compilation tool installation directory. Of course, if these libraries and header files already exist, there is no need to copy them.
For example, if the cross-compilation tool is installed in /opt/EmbedSky/4.3.3, you can use the following command to copy:
cp _install/include/*.h /opt/EmbedSky/4.3.3/arm-none-linux-gnueabi/include/ -rf
cp _install/lib/* /opt/EmbedSky/4.3.3/arm-none-linux-gnueabi/lib/ -rf
3. Compile and install libid3tag:
a. Enter the libid3tag source directory. Use the command:
./configure --host=arm-linux --prefix=${PWD}/_install to generate a Makefile. Among them
--host specifies the cross-compilation tool prefix.
--prefix=${PWD}/_install specifies the installation path of the library and header files after executing make install. Although the _install specified here does not exist, it will be automatically created after executing make install.
b. Use the command: make to compile the source code, and use the command: make install to install the generated library and header files to the specified directory, which is the _install directory we created earlier.
c. Copy the generated dynamic library to the lib directory under the root file system /nfs/rootfs, use the command: cp _install/lib/*.so* /nfs/rootfs/lib. If these libraries already exist, there is no need to copy them.
d. Copy the generated dynamic library and header files to the library and header file directories under the cross-compilation tool installation directory.
If these libraries and header files already exist, there is no need to copy them.
cp _install/include/*.h /opt/EmbedSky/4.3.3/arm-none-linux-gnueabi/include/ -rf
cp _install/lib/* /opt/EmbedSky/4.3.3/arm-none-linux-gnueabi/lib/ -rf
4. Compile and install libmad:
Refer to the previous step. It should be noted that in the Makefile generated by executing ./configure, a compilation option that is no longer supported by the current compiler needs to be removed. In line 129 of the Makefile, remove the -fforce-mem option.
./configure --host=arm-linux --prefix=${PWD}/_install
Vim Makefile
Make
make install
cp _install/lib/*.so* /nfs/rootfs/lib
cp _install/include/*.h /opt/EmbedSky/4.3.3/arm-none-linux-gnueabi/include/ -rf
cp _install/lib/* /opt/EmbedSky/4.3.3/arm-none-linux-gnueabi/lib/ -rf
5. Port the madplay application:
Enter the madplay source code directory. Since we have copied the dynamic library that madplay depends on to the /lib directory of the root file system, we only need to compile the dynamically linked madplay program here, and this compilation and installation will be very simple.
a. Use the command: ./configure --host=arm-linux to generate the Makefile file.
b. Use the command: make to compile madplay, and you can find the generated player main program madplay at the top level of the madplay source code directory.
c. Use the command: cp madplay /nfs/rootfs/sbin to copy madplay to the root file system directory of the development board.
d. Copy the glibc library file of the arm-linux-gcc cross compiler to the file system of the development board. The cross-compiled c library file is in the /opt/EmbedSky/4.3.3/arm-none-linux-gnueabi/libc/armv4t/lib directory. Enter the directory
and enter cp ./* /nfs/rootfs/lib/ -rf.
Check what dynamic library madplay needs in Linux on the PC
arm-linux-readelf -d madplay
shows the following content
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libmad.so.0]
0x00000001 (NEEDED) Shared library: [libid3tag.so.0]
0x00000001 (NEEDED) Shared library: [libz.so.1]
0x00000001 (NEEDED) Shared library: [libm.so.6]
0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x00000001 (NEEDED) Shared library: [libc.so.6]
Ignore the following content, you can see that 6 dynamic libraries are needed, and now go to the lib directory of our nfs file system to check whether these dynamic libraries exist. If you really follow the steps step by step, you can find that all the libraries are available.
6. Porting alsa interface library and toolkit
Since the Linux kernel of OK6410 has a sound card driver, it does not have the application interface library required by the ALSA architecture. When accessing the sound card in user space, it needs to go through the ALSA library before the kernel accesses the driver, so we need to port the ALSA library. And because 6410 uses the wm9713 or wm9714 sound card, the sound card needs to be specially configured before it can be used, otherwise it cannot play sound. This configuration tool needs to be provided by the alsa-utils tool set.
(1) Porting alsa-lib
a. You can download the latest version of the alsa library (alsa-lib-1.0.29.tar.bz2) and toolkit (alsa-utils-1.0.29.tar.bz2) from http://www.alsa-project.org/main/index.php/Download.
b. Unzip alsa-lib-1.0.29.tar.bz2
c. Configure alsa-lib
./configure
--host=arm-linux
--prefix=/usr/local/share/arm-alsa
--enable-shared
--disable-python --with-configdir=/usr/local/share/alsa --with-plugindir=/usr/local/lib/alsa_lib
CC=arm-linux-gcc CXX=arm-linux-g++ LD=arm-linux-ld
--host: is the name of the cross-compilation tool used. You can also use arm-linux directly. It depends on the cross-compilation tool installed on the PC.
--prefix: the directory where the program is installed when make install. You can modify it according to your own situation. Don't stick to it.
--enable: turn on the function --disable: turn off the function. Python is not required when using dynamic libraries.
--with-configdir: the directory where the alsa configuration file is located. The location of this directory must be determined. After cross-compilation, it must be consistent with the path on the PC when it is transplanted to the board. That is to say, if the /usr/local/share/alsa directory is specified during configuration, then the absolute path of your configuration file on the development board must also be /usr/local/share/alsa. The default alsa configuration file will be in the installation directory. This is very important. The PC and the development board cannot be mismatched.
--with-plugindir: The directory where alsa_lib is located. The meaning is currently unknown. It can be freely located or installed by default. Don't worry about it for now. However, the directory specified here will generate the necessary library files. When putting it on the development board, the path must be the same as the PC.
d. Compile and install
make
make install
(2)Transplant alsa-utils
a. After decompression, enter the decompressed directory
b. Configure
./configure --host=arm-linux --prefix=/usr/local/share/arm-alsa
CFLAGS="-I/usr/local/share/arm-alsa/include" LDFLAGS="-L/usr/local/share/arm-alsa/lib
-lasound" --disable-alsamixer --disable-xmlto
--with-alsa-inc-prefix=/usr/local/share/arm-alsa/include
--with-alsa-prefix=/usr/local/share/arm-alsa/lib CC=arm-linux-gcc CXX=arm-linux-g++
LD=arm-linux-ld
CFLAGS: The directory of header files required by the compiler, which is the header files obtained by compiling the library files in the previous
section.
LDFLAGS: The directory of library files required by the compiler, which is the library files obtained by compiling the library files in the previous
section.
--with-alsa-inc-prefix: Same as CFLAGS --with-alsa-prefix: Same as LDFLAGS.
c. Compile and configure
make
make install
(3) Deploy files to the development board
Enter the /usr/local/share directory of the PC (specified during the previous configuration, depending on your configuration options), because all our installation directories are in this directory.
a. Copy alsa and arm-alsa in the /usr/local/share directory to the /usr/local/share directory of the development board
cp ./alsa /home/OK6410/rootfs/usr/local/share -rfa
cp ./arm-alsa /home/OK6410/rootfs/usr/local/share -rfa
b. Copy alsa_lib in the /usr/local/lib directory to the /usr/local/lib directory (create it yourself) on the development board
cp ./alsa_lib /home/OK6410/rootfs/usr/local/lib/ -rfa
c. Copy the files in the arm-alsa/lib directory to the /lib directory of the development board’s root file system
cp ./arm-alsa/lib/* /home/OK6410/rootfs/lib –rfa
d. Copy the files in the arm-alsa/bin directory to the /sbin directory
cp ./arm-alsa/bin/* /home/OK6410/rootfs/bin -rfa
e. Copy the files in the arm-alsa/sbin directory to the /sbin directory
cp ./arm-alsa/sbin/* /home/OK6410/rootfs/bin -rfa
f. Add environment variables, edit /etc/profile in the file system of the development board, remember that it is the file system of the development board, not the file system of the PC! ! ! Add
exportALSA_CONFIG_PATH=/usr/local/share/alsa/alsa.conf
at the end
g. Copy the configuration file required for the sound card
Since wm9713/9714 requires special configuration, we can use alsactl in this tool set to configure wm9714/9713 after porting alsa-util. The configuration file required for configuration is in the wm9713 directory of the SDK. Copy it to the /etc directory of the development board.
h. Modify the system initialization script
Since the libraries and programs of the alsa architecture need to access these files in the /dev/snd directory
controlC0 pcmC0D0c pcmC0D0p seq timer
But in fact, the kernel and file system we use do not have the directory /dev/snd. Instead, these device nodes are directly created in the /dev directory, so we need to create them manually and hard link the device nodes. Therefore, we complete this task in the initialization script and add the following content to /etc/init.d/rcS in the development board file system.
mkdir /dev/snd
ln /dev/controlC0
/dev/snd/controlC0 ln /dev/
pcmC0D0c /dev/snd/pcmC0D0c ln /dev/pcmC0D0p /dev/snd/pcmC0D0p
ln /dev/timer /dev/snd/timer
ln /dev/seq /dev/snd/seq
amixer cset numid=86 2
amixer cset numid=87 2
alsactl restore -f /etc/wm9714.confThe
last step is to configure the sound card. This is the key to the key. If you fail to execute this step, although your playback tool is playing music, there will be no sound! ! ! ! !
Copy a song with an MP3 suffix from Windows to the root directory of the nfs file system in Linux on the PC through samba, and rename it to 1.MP3. (Because Chinese is not easy to operate on the development board.) Test madplay in the file system of the development board. Input madplay 1.mp3 in the serial port and you can hear pleasant songs. (Please plug in headphones.) Although there may be garbled characters, we don't care about it now. That is the information of the output song. If there is Chinese, it will be garbled because we have not perfected the support of Chinese on the development board. If you find it troublesome, you can do this.
madplay 1.mp3>> mp3_log.txt 2>&1 or madplay –Q 1.MP3
, then those annoying garbled characters will not appear. If the playback is not successful, it prompts that madplay cannot be found, which means that there is a problem with the transplantation. Please think about whether all dynamic libraries have been copied completely!
Previous article:Classical CAN test of LPC55S16
Next article:Analysis of LCD driver of S3C2440 built-in Linux kernel
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- [RVB2601 Creative Application Development] User Experience 04 -- Wi-Fi Networking
- Share CC2541 Bluetooth Learning About Watchdog
- [National Technology Low Power Series N32L43x Review] 05. SPI drive TFT screen & TF card to achieve Chinese and English mixed display
- How to prevent LCD screen from moisture and humidity
- Ask for help 50 E coins
- circuitpython starts testing WebBluetooth functionality
- What are the remedies for a pulse with a shallow rising edge?
- Novice talks about the application and difference of CAN (FD), RS485/RS422, RS232, Ethernet, and EtherCat
- Initial performance test of R329 development board
- Arteli-AT32F4xx timer input capture mode