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=
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:
I couldn't find the reason . 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:
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
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)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Application of Field Effect Transistor
- What is overshoot? How to solve the problem of overshoot in high-speed circuit signals
- Where can I find the development environment for the domestically produced aerospace-grade CPU of the BM3803MGRH model?
- What is the difference between using * and ? in the day of the week in cron expressions? I checked some information but it's not clear.
- GD32E231 DIY Contest Brushless Motor Driver
- FAQ Power Management, Battery Management
- Together wow: Smart soldering iron based on domestic chip, portable soldering iron system IronOS (FreeRTOS)
- How to add code to ardunio ide
- Blackboard with 24 touch keys, 9 customizable LEDs
- TI DLP Pico micro-projection technology makes smart speakers more powerful