ALSA sound card_bare board compilation and testing (based on Youlong FS2410 development board)

Publisher:MindfulYogiLatest update time:2024-07-11 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Experimental Environment

1.1 Virtual Machine Environment

a) Vmware version: Vmware Workstation 12.5.7

b) Ubuntu version: 9.10

c) Kernel version: 2.6.31.14

d) Toolchain version: arm-linux-gcc 3.4.5

1.2 Development Board

Youlong FS2410 development board, UDA1341 sound card

1.3 Debugger

Hardware: Baiwen.com OpenJTAG

Software: OpenOCD, Eclipse 3.6 Helios


2. Debugging process record

1. Set JP1 of the development board to NOR boot, then use u-boot and DNW's USB function to burn sound.bin to address 0 of nandflash and burn windows.wav to 0x60000.

Then set JP1 to NAND boot. Re-power on, plug the earphones into the development board, and select [M] MINI2440 or [T] TQ2440 in the menu of the serial terminal, but there is no sound in the earphones!

2. Debug code with OpenJTAG+Eclipse

(For detailed methods, see: Baiwen.com OpenJTAG debugger product manual "Eclipse, OpenOCD, OpenJTAGv3.1 Development Tutorial v5.pdf" 2.4 Using Eclipse to debug the program: Taking the S3C2440 leds program as an example)

After starting debugging, report:

0x33f8028c in nand_addr (addr=) at init.c:125

After checking, it was because in init.c: #define NFADDR (*((volatile unsigned char *)0x4E00000C)), which is 2440, not 2410.

Solution:

Modify init.c:


// #define NFCONT (*((volatile unsigned long *)0x4E000004))


// #define NFCMMD (*((volatile unsigned char *)0x4E000008))


// #define NFADDR (*((volatile unsigned char *)0x4E00000C))


// #define NFDATA (*((volatile unsigned char *)0x4E000010))


// #define NFSTAT (*((volatile unsigned char *)0x4E000020))


#define NFCMMD (*((volatile unsigned char *)0x4E000004))


#define NFADDR (*((volatile unsigned char *)0x4E000008))


#define NFDATA (*((volatile unsigned char *)0x4E00000C))


#define NFSTAT (*((volatile unsigned char *)0x4E000010))


3. In the menu of the serial terminal again, select: [M] MINI2440 or [T] TQ2440. This time you can hear the sound in the headphones!

However, after re-burning sound.bin to nandflash, restarting the development board, and trying again, there is still no sound in the headphones!

4. Since eclipse does not support debugging code located in nand, you can only use the telnet client to log in to OpenOCD for debugging

(For specific methods, see: Baiwen.com OpenJTAG debugger product manual "Eclipse, OpenOCD, OpenJTAGv3.1 Development Tutorial v5.pdf" 2.2 Using OpenOCD and OpenJTAG to burn and debug programs)

halt

load_image sound.bin 0x0

step 0

After resume, sometimes an undefined instruction exception occurs!

Sometimes, pc will repeatedly switch between b8 and bc:

clip_image002[4]

I couldn't find the reason Sad smile . I had no choice but to run the statements one by one using step. After a series of steps (in order to improve the efficiency of positioning, I can use the binary method), I finally found the crux of the problem:

image

image

Check the disassembly code of sound.dis:

33f80330 :


33f80330: e92d41f0 push {r4, r5, r6, r7, r8, lr}


33f80334: e1823000 orr r3, r2, r0


33f80338: e1a0cb83 lsl ip, r3, #23


33f8033c: e1a0cbac lsr ip, ip, #23


33f80340: e35c0000 cmp ip, #0; 0x0


33f80344: e24dd008 sub sp, sp, #8; 0x8


33f80348: e1a05002 mov r5, r2


33f8034c: e1a04001 mov r4, r1


33f80350: 1a000031 bne 33f8041c



33f8041c: e28dd008 add sp, sp, #8; 0x8


33f80420: e8bd41f0 pop {r4, r5, r6, r7, r8, lr}


33f80424: e12fff1e bx lr

Copy code



Corresponding to nand_read init.c:


if ((start_addr & NAND_BLOCK_MASK) || (size & NAND_BLOCK_MASK)) { //NAND_BLOCK_MASK=511, because the page size of K9F1208 is 512 bytes


return ; /* If the address or length is not aligned, return directly*/


}



By checking the value of register r2, we know that size=0x33D4, and 0x33D4& 1ff !=0, so the program returns directly! As a result, the code segment in nand cannot be copied to the link address of the program, so the program runs away!


After checking, the call stack is as follows:


(head.S)


mov r0, #0

ldr r1, =_start

ldr r2, =__bss_start

sub r2, r2, r1

bl copy_code_to_sdram # will call init.c's copy_code_to_sdram(0, _start, __bss_start), where _start is .text, and .text and __bss_start are both defined in sound.lds


copy_code_to_sdram(src, dst, len) # read the program from nand and copy it to the memory _start address, the length is __bss_start-_start


nand_read(src, dest, len)


Check sound.lds, there is:



. = ALIGN(4); //Indicates that the current link address is aligned to 4 bytes


__bss_start = .;



So I changed it to: . = ALIGN(512); and tried again. Finally, the sound can be played!


Note: The NAND used by FS2410 is K9F1208, and the page size is 512 bytes. According to the data sheet and online articles, its read operation supports reading any address within the page, but the nand_read code will not be changed for now, and will be changed later when there is time.




Conclusion


By debugging the bare board driver of the UDA1341 sound card on the Youlong FS2410 development board, we have a further understanding of the hardware operation framework and process of the sound card driver, as well as the debugging method of the bare board driver.


The main difficulties of bare board driving are:


1. Codec chip configuration, soc configuration (including DAI (such as IIS), DMA), machine configuration (which pins are used to connect the control pins of the codec chip (CSB, SCLK, SDIN))


2. Once a problem occurs, how to debug it?


A better way is to use OpenJTAG+OpenOCD combined with Eclipse for source-level debugging. If you want to debug the code in NAND, you can use telnet to OpenOCD for assembly-level debugging (the disadvantage is that the operation is more cumbersome and the assembly code needs to be analyzed)




IV. References


1. Wei Dongshan "Complete Handbook of Embedded Linux Application Development"


2. Wei Dongshan "Eclipse, OpenOCD, OpenJTAGv3.1 Development Tutorial v5.pdf"


3. Reading operation of NandFlash K9F1208U0A/K9F1208U0B


Reference address:ALSA sound card_bare board compilation and testing (based on Youlong FS2410 development board)

Previous article:ALSA sound card_framework written from scratch (based on Youlong FS2410 development board, UDA1341 sound card)
Next article:Wei Dongshan Phase II Driver_IIC Bare Board Driver Notes (revised version)

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号