Search

Technical Discussion Group Forum

This forum is provided for user discussion. While Beacon EmbeddedWorks support staff and engineers participate, Beacon EmbeddedWorks does not guarantee the accuracy of all information within in the Technical Discussion Group (TDG).

The "Articles" forums provide brief Articles written by Beacon EmbeddedWorks engineers that address the most frequently asked technical questions.

To receive email notifications when updates are posted for a Beacon EmbeddedWorks product download, please subscribe to the TDG Forum of interest.

TDG Forum

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 27 Jan 2005 09:53 AM by  mikee@logicpd.com
error when running cross-compiled program in linux
 5 Replies
Sort:
You are not authorized to post a reply.
Author Messages
osto_82@hotmail.com
New Member
New Member
Posts:


--
24 Jan 2005 03:08 AM
    Hello,

    I have Linux on my LH7A404 board. I made c-program that controls board's leds. Then i Cross-compiled program without errors and warnings. Then i ran it on my LH7A404 and get following message:

    #
    # ./prog
    pc : [<000083d0>] lr : [<400756f4>] Not tainted
    sp : bffffe54 ip : 00000000 fp : bffffe60
    r10: 40135198 r9 : 000083a0 r8 : 00000001
    r7 : 40021ae4 r6 : 0000825c r5 : bffffe84 r4 : 000007c8
    r3 : 04331d80 r2 : 04331d80 r1 : 04331d80 r0 : 0000000d
    Flags: nZCv IRQs on FIQs on Mode USER_32 Segment user
    Control: C000317F Table: C17A4000 DAC: 00000015
    Segmentation fault
    #
    #

    What i'am doing wrong? When i run simple "hello world" program on my board it runs correctly.

    -Toni-
    mikee@logicpd.com
    New Member
    New Member
    Posts:


    --
    24 Jan 2005 11:13 AM
    osto_82,

    I can really only guess at a couple of things. First, a question. When you say:
    Quote:

    When i run simple "hello world" program on my board it runs correctly.

    what, exactly, do you mean? Are you referring to the "Hello World" program that uses the LogicLoader's API and comes with the kit? Or, are you referring to something you wrote, compiled, and then ran under Linux on the board?

    If it is the later, then your cross-complier, C-library, etc. are probably fine and I just wonder if you didn't properly map the LEDs into your process's virtual address space under Linux.

    If it is the former, then we've got some talking to do.

    Regards,
    --mikee
    osto_82@hotmail.com
    New Member
    New Member
    Posts:


    --
    26 Jan 2005 07:00 AM
    mikee,

    Yes i was referring to something i wrote, compiled, and then ran under Linux on the board.

    What i need to do to properly map the LEDs into process's virtual address space under Linux and do i need to write kernel module code or basic c-code that i can control leds?

    -Toni-
    mikee@logicpd.com
    New Member
    New Member
    Posts:


    --
    26 Jan 2005 10:25 AM
    osto_82,

    Okay, that makes sense to me. There are probably several options available to you. There are some hacks that you might be able to make use of just as a test case. Included in these would be:

    - Use the device /dev/mem. If you open it, you might be able to get away with using mmap() or lseek() to get to the physical address of the LEDs.
    - Try the following from the shell prompt:

    echo -n -e "\001" | dd of=/dev/mem bs=1 oseek=ADDRESS_OF_LEDS count=1

    Note, I have not checked that for syntax, but I think it will work. I'm not sure if the "oseek" argument will take hex notation, it might need decimal, but you get the idea.

    Personally, I recommend you grab a copy of the Linux Device Drivers book, or search the web for tutorials such as this one:
    http://www.networkcomputing.com/unixworld/tutorial/010/010.txt.html
    Then you can cook up a little device driver and access the LEDs the "proper" way.

    Let us know how it goes.

    Regards,
    --mikee
    osto_82@hotmail.com
    New Member
    New Member
    Posts:


    --
    27 Jan 2005 06:00 AM
    mikee,

    I tried dd with 0x71600000 and 0xf8000e00 but couldn't control leds. Here is errors i got:


    with 0x71600000:

    # echo -n -e "\001" | dd of=/dev/mem bs=1 seek=1902116864 count=1
    Unable to handle kernel paging request at virtual address 71600000
    pgd = c17a4000
    [71600000] *pgd=00000000, *pmd = 00000000
    Internal error: Oops: 805
    CPU: 0
    pc : [<c013a2e8>] lr : [<c00a3aa0>] Not tainted
    sp : cd4b9f2c ip : 00000001 fp : cd4b9f60
    r10: 00000000 r9 : cd4b8000 r8 : 0003f860
    r7 : 00000000 r6 : c94bbb40 r5 : 00000001 r4 : 00000001
    r3 : 00000001 r2 : 00000001 r1 : 0003f861 r0 : 71600000
    Flags: Nzcv IRQs on FIQs on Mode SVC_32 Segment user
    Control: C000317F Table: C17A4000 DAC: 00000015
    Process dd (pid: 485, stack limit = 0xcd4b8374)
    Stack: (0xcd4b9f2c to 0xcd4ba000)
    9f20: 71600000 00000001 00000001 00000001 c94bbb40
    9f40: 00000000 c00a3aa0 00000001 c94bbb20 ffffffea cd4b9f78 cd4b9f64 c00a3bd0
    9f60: c00a3a68 00000001 c94bbb40 cd4b9fa4 cd4b9f7c c004afc8 c00a3b94 c00242c4
    9f80: c0024154 00000001 00000001 0003f860 00000004 c001e6a4 00000000 cd4b9fa8
    9fa0: c001e500 c004aefc 00000001 c0024700 00000003 0003f860 00000001 00000001
    9fc0: 00000001 00000001 0003f860 00000003 00000001 00034e38 00000000 bffffe38
    9fe0: 4010e300 bffffd3c 0002c538 4010e304 60000010 00000003 cf0e8f0f 0f0b4d0c
    Backtrace:
    Function entered at [<c00a3a58>] from [<c00a3bd0>]
    r6 = FFFFFFEA r5 = C94BBB20 r4 = 00000001
    Function entered at [<c00a3b84>] from [<c004afc8>]
    Function entered at [<c004aeec>] from [<c001e500>]
    r8 = C001E6A4 r7 = 00000004 r6 = 0003F860 r5 = 00000001
    r4 = 00000001
    Code: e33c0000 0a000009 e35c0002 e4f13001 (e4c03001)
    #


    and with 0xf8000e00:

    # echo -n -e "\001" | dd of=/dev/mem bs=1 seek=4160753152 count=1
    dd: /dev/mem: Invalid argument


    I think that those addresses i used are wrong. From where i can find right addresses of board's leds that kernel uses?

    Than you for replying.

    -Toni-
    mikee@logicpd.com
    New Member
    New Member
    Posts:


    --
    27 Jan 2005 09:53 AM
    The addresses of the LEDs should be listed in the I/O controller specification available from our website or shipped with your kit.

    The LED's are controlled via a register in the CPLD. All items in the CPLD are documented in that specification.

    Note, you are not looking for the address that the kernel uses, you need to use the actual physical address.

    Again, if the shell doesn't work, try doing it programmatically:

      - Open up /dev/mem or /dev/kmem (I forget which).
      - Call mmap() to map the physical address of the LEDs into your process space.
      - Use the standard read/write calls, depending on the permissions you set in the call to open().
      - One more note, your process has to be running with super-user priviledges to do any of this.


    --mikee
    You are not authorized to post a reply.