Wei Dongshan embedded Linux video tutorial _3 combat phase of the project and compile the ALSA sound card _ the bare board test (based on Long FS2410 excellent development board)

First, the experimental environment

1.1 virtual machine environment

    a) Vmware printed books: 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

    Liuzhou excellent FS2410 development board, UDA1341 sound card

1.3 Debugger

    Hardware: ask a hundred net OpenJTAG

    Software: OpenOCD, Eclipse 3.6 Helios


Second, the debugging process record

1, JP1 development board is set to NOR startup by u-boot DNW and the USB function programmed into the sound.bin nandflash address 0, programmed into the windows.wav at 0x60000,

      Then NAND JP1 is set to start. Re-power headphones into boards, serial terminal's menu, choose: [M] MINI2440 or [T] TQ2440, but no sound headphones!

2, with the debugging code OpenJTAG + Eclipse

   (See specific methods: Hundred Questions Network OpenJTAG Debugger Product Manual "Eclipse, OpenOCD, OpenJTAGv3.1 development tutorial v5.pdf" 2.4 using the Eclipse debugger: S3C2440 with leds program as an example)

      After starting the commissioning report:

           0x33f8028c in nand_addr (addr=<optimized out>) at init.c:125

     The investigation, because init.c in: #define NFADDR (* ((volatile unsigned char *) 0x4E00000C)), this 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, again in the terminal's serial port menu, select: [M] MINI2440 or [T] TQ2440, the headphones can hear the sound!

     However, when the sound.bin re-programmed into the nandflash, restart the development board, and try again, the headphones still no sound!

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

     (See specific methods: Hundred Questions Network OpenJTAG Debugger Product Manual "Eclipse, OpenOCD, OpenJTAGv3.1 development tutorial v5.pdf" 2.2 use OpenOCD, OpenJTAG programming process, the debugger)

     halt

     load_image sound.bin 0x0

     step 0

     After resume, sometimes into the undefined instruction abnormal!

     Sometimes it will be repeated in the pc b8, was removed between bc:

       clip_image002[4]

      I can not find the cause Sad smile. In desperation, you can only run with a step-by-sentence, through a series of step (in order to improve the efficiency of positioning, you can use dichotomy), finally found the crux of the problem:

image

image

      Charles sound.dis disassembly:

33f80330 <nand_read>:

      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 <nand_read+0xec>

      …

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

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

      33f80424: e12fff1e bx lr


      对应于init.c的nand_read:

      if ((start_addr & NAND_BLOCK_MASK) || (size & NAND_BLOCK_MASK)) { //NAND_BLOCK_MASK=511,因为K9F1208 一页大小是512字节

          return ; /* 如果地址或长度不对齐,就直接返回*/

      }


    通过查看r2寄存器的值,可知size=0x33D4,而0x33D4& 1ff !=0 ,所以程序直接return了!最终导致nand里的代码段未能拷贝到程序的链接地址,因此程序跑飞了!

    经查,调用栈是这样的:

    (head.S)

     mov r0, #0
     ldr r1, =_start
     ldr r2, =__bss_start
     sub r2, r2, r1
     bl copy_code_to_sdram # 会调用init.c的copy_code_to_sdram(0, _start, __bss_start) ,其中,_start即.text ,而.text 和__bss_start都定义在sound.lds中

        copy_code_to_sdram(src, dst, len) # 把程序从nand读出来拷贝到内存_start地址处,长度为__bss_start-_start

            nand_read(src, dest, len)

      查看sound.lds,有:

      …

      . = The ALIGN (4); // indicates that the current link address of 4-byte aligned

      __bss_start = .;

      …

      Was changed to: = ALIGN (512); again, finally able to play sounds.!

      NOTE: NAND FS2410 of K9F1208 is used, a size is 512 bytes, and network packets according to the manual, it is a read operation, any in-page address to read, but not change the code first nand_read, so have time to change.


Third, the summary

    Commissioning driven by the naked plate UDA1341 card in EURONAVY FS2410 development board, a sound driver to learn more about the operation of the hardware and process the frame, and the debugging method of driving the bare board.

    Driving bare board main difficulties:

1, codec chip configuration, soc configuration (including the DAI (such as IIS), DMA), machine configuration (which pin connections pins for controlling the chip codec (CSB, SCLK, SDIN))

2, once a problem, how to debug?

      A better approach is to use OpenJTAG + OpenOCD combined with Eclipse for source-level debugging, but if you want to debug NAND in the code, you can telnet to OpenOCD to assembly-level debugging (the drawback is relatively cumbersome operation, but also with analysis assembly code)


Fourth, references

  1, Wei Dongshan "embedded Linux application development entirely manual"

  2, Wei Dongshan "Eclipse, OpenOCD, OpenJTAGv3.1 development tutorial v5.pdf"

  . 3, of NandFlash K9F1208U0A / read operation K9F1208U0B

Guess you like

Origin www.cnblogs.com/normalmanzhao2003/p/12324519.html