S3c2440 UDA1341 audio card driver and madplay player transplantation,
1. Configure the UDA1341 driver for the Sound Card
Because mini3.0 kernel has the mini2440 initialization file, so directly go to the/arch/arm/mach-s3c2440/mach-mini2440.c to view the changes to get
--- mach-smdk2440_o.c 2015-04-24 11:39:20.492017397 +0800 +++ mach-smdk2440.c 2015-04-24 12:26:01.457015793 +0800 @@ -45,6 +45,7 @@ #include
#include
+#include
+#include
#include
static struct map_desc smdk2440_iodesc[] __initdata = { @@ -155,8 +156,32 @@ &s3c_device_wdt, &s3c_device_i2c0, &s3c_device_iis, + &uda1340_codec, + &s3c2440_audio, + &samsung_asoc_dma, }; +/* add by handy */ +/* AUDIO */ +static struct s3c24xx_uda134x_platform_data s3c2440_audio_pins = { + .l3_clk = S3C2410_GPB(4), + .l3_mode = S3C2410_GPB(2), + .l3_data = S3C2410_GPB(3), + .model = UDA134X_UDA1341 +}; + +static struct platform_device s3c2440_audio = { + .name = s3c24xx_uda134x, + .id = 0, + .dev = { + .platform_data = &s3c2440_audio_pins, + }, +}; +static struct platform_device uda1340_codec = { + .name = uda134x-codec, + .id = -1, +}; +/* add by handy */ static void __init smdk2440_map_io(void) { s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));
You can directly make menuconfig. PS: copy and paste should also pay attention to whether there are many blank characters. If there are many scureCRT plug-ins installed, it is recommended to directly use the Virtual Machine text editing, you can use make to edit the file on a VM. But scureCRT is not dead, and it is always undefined.
First, enterDevice Drivers -->
Make is then burned to the board. If the printed information is found in the long string, the result is successful.
2. madplay is transplanted on S3c2440 to play mp3 music smoothly.
Cross-compiler environment: arm-linux-gcc-4.5.4
Development Board platform: FL2440
Linux Kernel version: 3.0
(I) Preparations before madplay Transplantation:
Source code package:
Madplay-0.15.2b.tar.gz, // Compressed package of the playing program, source code of the MP3 player
Libmad-0.15.1b.tar.gz, // Madplay Library File
Libid3tag-0.15.1b.tar.gz// Mp3 decoding library
Zlib-1.1.4.tar.gz// Used for File compression and decompression
Create a file directory, upload the source code package to the madplay directory, and decompress the package;
[Pikaqiu @ centos6 ~] $ Mkdir madplay
[Pikaqiu @ centos6 ~] $ Mkdir madplay/mad
[Pikaqiu @ centos6 madplay] $ ls
Libid3tag-0.15.1b libmad-0.15.1b mad madplay-0.15.2b zlib-1.1.4
The main steps for porting third-party programs are decompression, configuration (./configure), compilation (make), and installation (make install );
After the source code package is decompressed, you can directly make the compilation if Makefile already exists. However, you need to use the./configure script in the source code package directory to configure the source code package to generate the Makefile file;
We can usually use./configure -- help to view configuration options.
Here we must know the following configuration parameters:
-- Host:Used to specify a platform. For example, -- host = arm-linux
-- Prefix:Used to specify the installation path of the file; for example, -- prefix =/home/pikaqiu/madplay/mad
-ISpecifies the path of the header file, for example,-I/home/pikaqiu/madplay/mad/include/
-LSpecifies the path of the library file, for example,-L/home/pikaqiu/madplay/mad/lib
-- Disable-sharedUse static library for compilation;
If you want to compile and run on the arm board, you need to add AR. o file packaging and generation. static library file of a) = LD (linked) = CC (cross compiler) =
(2) Start configuration and compile:
Note: The following steps cannot be disrupted because of dependency. You must use the sudo permission each time. Otherwise, errors may occur due to insufficient permissions.
1. First compile zlib-1.1.4
[Pikaqiu @ centos6 madplay] $ cd zlib-1.1.4/
(1) configure the configure file to generate the Makefile
[Pikaqiu @ centos6 madplay] $Sudo./configure -- prefix = home/pikaqiu/madplay/mad
(2) modify the Makefile file
[Pikaqiu @ centos6 zlib-1.1.4] $ vim Makefile
Modify the following three items:
CC = gcc changed to CC =/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc
AR = ar rc changed to AR =/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-ar rc
RANLIB = ranlib changed to RANLIB =/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-ranlib
(3) Compile make
[Pikaqiu @ centos6 zlib-1.1.4] $ sudo make
If there is no error, make is successful. You can continue to the next step.
(4) install make install
2. Compile libid3tag-0.15.1b
[Pikaqiu @ centos6 madplay] $ cd libid3tag-0.15.1b/
(1) configure the configure file to generate the Makefile
[Pikaqiu @ centos6 libid3tag-0.15.1b] $Sudo. /configure CC =/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc -- host = arm-linux -- disable-shared -- prefix =/home/pikaqiu/madplay/ mad CPPFLAGS =-I/home/pikaqiu/madplay/mad/include/LDFLAGS =-L/home/pikaqiu/madplay/mad/lib
(2) Compile make
[Pikaqiu @ centos6 libid3tag-0.15.1b] $ sudo make
If there is no error, make is successful. You can continue to the next step.
(4) install make install
3. Compile libmad-0.15.1b
[Pikaqiu @ centos6 madplay] $ cd libmad-0.15.1b/
(1) configure the configure file to generate the Makefile
[Pikaqiu @ centos6 libmad-0.15.1b] $Sudo. /configure CC =/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc -- host = arm-linux -- disable-shared -- prefix =/home/pikaqiu/madplay/ mad CPPFLAGS =-I/home/pikaqiu/madplay/mad/include/LDFLAGS =-L/home/pikaqiu/madplay/mad/lib
(2) Compile make
At this time, an error is displayed, such as: Maid: error: unrecognized command line option "-fforce-mem"
Solution:Vim Makefile
Locate the contained-fforce-mem string in about 129 rows and delete it.
Cause: the gcc 3.4 or later version has been removed, so the above error will occur.
(3) install make install
4. Install madplay
[Pikaqiu @ centos6 madplay] $ cd madplay/
(1) configure the configure file to generate the Makefile
[Pikaqiu @ centos6 madplay] $Sudo. /configure CC =/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc -- host = arm-linux -- disable-shared -- prefix =/home/pikaqiu/madplay/ mad CPPFLAGS =-I/home/pikaqiu/madplay/mad/include/LDFLAGS =-L/home/pikaqiu/madplay/mad/lib
At this time, I encountered another error:
Configure: error: mad. h was not found
* ** You must first install libmad before you can build this package.
*** If libmad is already installed, you may need to use the CPPFLAGS
* ** Environment variable to specify its installed location, e.g.-I
Cause: the system prompts that the header file is missing, that is, it reminds us to use the-I command to specify the path of the header file.
Solution:Because-L and-I already exist in the command to specify the directory of the library and header file, I first went back to the mad/include directory and found that there was really no mad. h this header file, so I returned to the top-level directory madplay using commands to find.
[Pikaqiu @ centos6 madplay] $ find-name mad. h
./Libmad-0.15.1b/mad. h then copy this to the/mad/include directory and fix it.
The following error occurs:
Configure: error: libmad was not found
* ** You must first install libmad before you can build this package.
*** If libmad is already installed, you may need to use the LDFLAGS
* ** Environment variable to specify its installed location, e.g.-L
Cause: if the library file is missing, we are reminded to use-L to specify the path of the library file.
Solution:In the/mad/lib/directory, I did not find my libmad. a file.
[Pikaqiu @ centos6 madplay] $ find-name libmad .*
./Mad/lib/libmad. la
./Mad/lib/. libs/libmad.
./Mad/lib/libmad.
./Libmad-0.15.1b/libmad. list
./Libmad-0.15.1b/msvc ++/libmad. dsp
./Libmad-0.15.1b/libmad. list. in
./Libmad-0.15.1b/libmad. la
./Libmad-0.15.1b/. libs/libmad. lai
./Libmad-0.15.1b/. libs/libmad. la
./Libmad-0.15.1b/. libs/libmad.
./Madplay-0.15.2b/. libs/libmad. la
./Madplay-0.15.2b/. libs/libmad. a (this is the find after my success, but only the libmad-0.15.1b/. libs has it before)
Because I do not know whether to use. a or. la, simply copy all of them to the corresponding path to solve it.
(2) Compile make
I was so happy to think that the problem was solved and that I could make it. Then another problem occurred.
....
Arm-linux-gcc:/home/pikaqiu/madplay/mad/lib/. libs/libmad. a: No such file or directory
Make [2]: *** [madplay] Error 1
Make [2]: Leaving directory '/home/pikaqiu/madplay/madplay-0.15.2b'
Make [1]: *** [all-recursive] Error 1
Make [1]: Leaving directory '/home/pikaqiu/madplay/madplay-0.15.2b'
Make: *** [all] Error 2
Solution:Manually create mad/lib/. libs/and copy the libmad. a file to its directory.
So far, make has finally successfully generated the green executable program for madplay, and because I am using static compilation. In this case, you can directly download madplay to the development board without making install.
Chmod 777 madplay
./Madplay xxx.mp3 will be able to listen to music, and the blogger will test it!
Madpaly also has some shortcut keys, such as: increase/decrease volume (+/-), pause (B), stop (ESC)
Without looking at the manual, I tested it randomly and found that pressing the keyboard minus sign can reduce the volume, shift + can increase the volume, shift-Instantly restore the full volume, and the s key stops.
Summary:1. When all third-party applications are ported to the Development Board for use, they will almost be linked to the dynamic library and static library. Therefore, you need to be familiar with this knowledge, such as how to link the static library of the dynamic library, how to specify the header file path, static link, and static compilation parameters;
Differences between static compilation and dynamic compilation:
A dynamically compiled executable file must be accompanied by a dynamic link library. During execution, the corresponding commands in the dynamic link library must be called. Therefore, it reduces the size of the execution file, accelerates compilation, and saves system resources. But the disadvantage is also obvious, that is, as long as the library file is used, the corresponding function library needs to be carried, and a small tail is required in any case. This is a little effort-consuming for porting small programs.
Static compilation is the dynamic link library (. so), because the files in the dynamic library are included, the executable files will be bloated, that is, occupying space resources. But it can be run directly. So its advantages and disadvantages are exactly the same as those of the dynamically compiled executable files, depending on the specific situation.
2. You also need to learn to use other driver code of the Linux kernel itself for driver modification. For example, you can go to mini2440 to find the supported dm9000 driver code, and so on.
The figure shows that the executable files generated by static compilation are only 672K and not stripped indicates that strip is not used to remove debugging information. So I did not dynamically compile it again.
But there is a problem: I can directly burn the executable file to the Development Board to run it, and at the beginning, I specified -- disable-shard to disable the shared library. The madplay after my file actually shows that the dynamic library is used. Solution
Finally, I would like to thank all our predecessors for sharing their solutions online. All problems encountered during the application porting process must be solved with patience.