First program on arm board - Embedded

This is a discussion on First program on arm board - Embedded ; Hi, I am very new to embedded linux. I have a pxa255 based board and I am planning to put linux on it. To start with I am writing a small program by which I can just toggle the LED. ...

+ Reply to Thread
Results 1 to 11 of 11

Thread: First program on arm board

  1. First program on arm board

    Hi,

    I am very new to embedded linux. I have a pxa255 based board and I am
    planning to put linux on it. To start with I am writing a small
    program by which I can just toggle the LED. Below is snapshot for
    assembly program which ON the LED.

    .text /*Executable code follows*/
    _start: .global _start /* "_start" is required by the linkera*/
    .global main /* "main" is our main program */
    b main /* Start running the main program */
    /* Insert your code here */

    MAIN:
    MOV R1, #0x40000000 /* GPDR0 for configuring the PIN 10 as
    output*/
    ADD R1,R1, #0x00E00000
    ADD R1,R1, #0x0000000C

    /*MOV R5, #0x3B9AC9FF*/

    MOV R2, #0B01000000000
    STR R2,[R1] /* Pin 10 now configured as Output*/

    LOOP:
    MOV R0,#0
    MOV R6, #0x40000000 /* Register6 with a large value stored*/

    MOV R1,#0x40000000 /* Address of GPSR0 - set register*/
    ADD R1,R1, #0x00E00000
    ADD R1,R1, #0x00000018

    MOV R2, #0B01000000000 /* Set the 10th bit */

    STR R2,[R1] /* LED shall turn ON here*/

    BAL LOOP
    /* mov pc,lr need to see what it is ??? Return to the
    caller*/
    .end

    It's not working. Seems I missing lots of things here. First thing
    which comes is how to write linker file for it. Can someone please
    guide me or give me pointer so that I can study it. I have found few
    sample linker files from Linux kernel code also and trying to figure
    out how to write them.

    Please also let me know where else I am missing so that I can work in
    that direction.

    Any kind of help or pointers will be really helpful.

    Regards
    Chads

  2. Re: First program on arm board

    Chads wrote:
    > I am very new to embedded linux. I have a pxa255 based board and I am
    > planning to put linux on it. To start with I am writing a small
    > program by which I can just toggle the LED. Below is snapshot for
    > assembly program which ON the LED.
    >
    > .text /*Executable code follows*/
    > _start: .global _start /* "_start" is required by the linkera*/
    > .global main /* "main" is our main program */
    > b main /* Start running the main program */
    > /* Insert your code here */
    >
    > MAIN:
    > MOV R1, #0x40000000 /* GPDR0 for configuring the PIN 10 as
    > output*/
    > ADD R1,R1, #0x00E00000
    > ADD R1,R1, #0x0000000C
    >
    > /*MOV R5, #0x3B9AC9FF*/
    >
    > MOV R2, #0B01000000000
    > STR R2,[R1] /* Pin 10 now configured as Output*/
    >
    > LOOP:
    > MOV R0,#0
    > MOV R6, #0x40000000 /* Register6 with a large value stored*/
    >
    > MOV R1,#0x40000000 /* Address of GPSR0 - set register*/
    > ADD R1,R1, #0x00E00000
    > ADD R1,R1, #0x00000018
    >
    > MOV R2, #0B01000000000 /* Set the 10th bit */
    >
    > STR R2,[R1] /* LED shall turn ON here*/
    >
    > BAL LOOP
    > /* mov pc,lr need to see what it is ??? Return to the
    > caller*/
    > .end


    You like the hard way? Why do you do it in assembler?

    > It's not working. Seems I missing lots of things here. First thing
    > which comes is how to write linker file for it. Can someone please
    > guide me or give me pointer so that I can study it. I have found few
    > sample linker files from Linux kernel code also and trying to figure
    > out how to write them.


    What's your intention? A program that runs on bare metal or as part of the
    Linux kernel or something that should run as a usermode program?
    Programming in assembler *could* make sense if it should run on bare metal.
    For the other cases you should do it in "C".

    Juergen

  3. Re: First program on arm board

    On Jan 31, 2:15 pm, Juergen Beisert wrote:
    > Chads wrote:
    > > I am very new to embedded linux. I have a pxa255 based board and I am
    > > planning to put linux on it. To start with I am writing a small
    > > program by which I can just toggle the LED. Below is snapshot for
    > > assembly program which ON the LED.

    >
    > > .text /*Executable code follows*/
    > > _start: .global _start /* "_start" is required by the linkera*/
    > > .global main /* "main" is our main program */
    > > b main /* Start running the main program */
    > > /* Insert your code here */

    >
    > > MAIN:
    > > MOV R1, #0x40000000 /* GPDR0 for configuring the PIN 10 as
    > > output*/
    > > ADD R1,R1, #0x00E00000
    > > ADD R1,R1, #0x0000000C

    >
    > > /*MOV R5, #0x3B9AC9FF*/

    >
    > > MOV R2, #0B01000000000
    > > STR R2,[R1] /* Pin 10 now configured as Output*/

    >
    > > LOOP:
    > > MOV R0,#0
    > > MOV R6, #0x40000000 /* Register6 with a large value stored*/

    >
    > > MOV R1,#0x40000000 /* Address of GPSR0 - set register*/
    > > ADD R1,R1, #0x00E00000
    > > ADD R1,R1, #0x00000018

    >
    > > MOV R2, #0B01000000000 /* Set the 10th bit */

    >
    > > STR R2,[R1] /* LED shall turn ON here*/

    >
    > > BAL LOOP
    > > /* mov pc,lr need to see what it is ??? Return to the
    > > caller*/
    > > .end

    >
    > You like the hard way? Why do you do it in assembler?
    >
    > > It's not working. Seems I missing lots of things here. First thing
    > > which comes is how to write linker file for it. Can someone please
    > > guide me or give me pointer so that I can study it. I have found few
    > > sample linker files from Linux kernel code also and trying to figure
    > > out how to write them.

    >
    > What's your intention? A program that runs on bare metal or as part of the
    > Linux kernel or something that should run as a usermode program?
    > Programming in assembler *could* make sense if it should run on bare metal.
    > For the other cases you should do it in "C".
    >
    > Juergen


    Hi Juergen,

    Thank you for your response.
    Yes I want to run it on bare metal thats why witting it in assembly.

  4. Re: First program on arm board

    Chads wrote:

    > On Jan 31, 2:15 pm, Juergen Beisert wrote:
    >> Chads wrote:
    >> > I am very new to embedded linux. I have a pxa255 based board and I am
    >> > planning to put linux on it. To start with I am writing a small
    >> > program by which I can just toggle the LED. Below is snapshot for
    >> > assembly program which ON the LED.

    >>
    >> > .text /*Executable code follows*/
    >> > _start: .global _start /* "_start" is required by the linkera*/
    >> > .global main /* "main" is our main program */
    >> > b main /* Start running the main program */
    >> > /* Insert your code here */

    >>
    >> > MAIN:
    >> > MOV R1, #0x40000000 /* GPDR0 for configuring the PIN 10 as
    >> > output*/
    >> > ADD R1,R1, #0x00E00000
    >> > ADD R1,R1, #0x0000000C

    >>
    >> > /*MOV R5, #0x3B9AC9FF*/

    >>
    >> > MOV R2, #0B01000000000
    >> > STR R2,[R1] /* Pin 10 now configured as Output*/

    >>
    >> > LOOP:
    >> > MOV R0,#0
    >> > MOV R6, #0x40000000 /* Register6 with a large value stored*/

    >>
    >> > MOV R1,#0x40000000 /* Address of GPSR0 - set register*/
    >> > ADD R1,R1, #0x00E00000
    >> > ADD R1,R1, #0x00000018

    >>
    >> > MOV R2, #0B01000000000 /* Set the 10th bit */

    >>
    >> > STR R2,[R1] /* LED shall turn ON here*/

    >>
    >> > BAL LOOP
    >> > /* mov pc,lr need to see what it is ??? Return to the
    >> > caller*/
    >> > .end

    >>
    >> You like the hard way? Why do you do it in assembler?
    >>
    >> > It's not working. Seems I missing lots of things here. First thing
    >> > which comes is how to write linker file for it. Can someone please
    >> > guide me or give me pointer so that I can study it. I have found few
    >> > sample linker files from Linux kernel code also and trying to figure
    >> > out how to write them.

    >>
    >> What's your intention? A program that runs on bare metal or as part of
    >> the Linux kernel or something that should run as a usermode program?
    >> Programming in assembler *could* make sense if it should run on bare
    >> metal. For the other cases you should do it in "C".

    >
    > Thank you for your response.
    > Yes I want to run it on bare metal thats why witting it in assembly.


    But you wrote:
    >> I am very new to embedded linux. I have a pxa255 based board and I am
    >> planning to put linux on it.


    But if you plan to bring Linux in your box, why do you start with bare
    metal?

    Writing linker script files is not such complicated. Refer ld's manpages.
    All it does is to give your code some kind of "layout" when it gets
    translated to binary: Where to place the text segment content in the file
    and at runtime (same for data and bss segment).
    But how do you want to run this program on your bare metal? This CPU needs
    some kind of setup after reset. To bring up the SDRAM controller for
    example.

    Juergen


  5. Re: First program on arm board

    On Jan 31, 3:17 pm, Juergen Beisert wrote:
    > Chads wrote:
    > > On Jan 31, 2:15 pm, Juergen Beisert wrote:
    > >> Chads wrote:
    > >> > I am very new to embedded linux. I have a pxa255 based board and I am
    > >> > planning to put linux on it. To start with I am writing a small
    > >> > program by which I can just toggle the LED. Below is snapshot for
    > >> > assembly program which ON the LED.

    >
    > >> > .text /*Executable code follows*/
    > >> > _start: .global _start /* "_start" is required by the linkera*/
    > >> > .global main /* "main" is our main program */
    > >> > b main /* Start running the main program */
    > >> > /* Insert your code here */

    >
    > >> > MAIN:
    > >> > MOV R1, #0x40000000 /* GPDR0 for configuring the PIN 10 as
    > >> > output*/
    > >> > ADD R1,R1, #0x00E00000
    > >> > ADD R1,R1, #0x0000000C

    >
    > >> > /*MOV R5, #0x3B9AC9FF*/

    >
    > >> > MOV R2, #0B01000000000
    > >> > STR R2,[R1] /* Pin 10 now configured as Output*/

    >
    > >> > LOOP:
    > >> > MOV R0,#0
    > >> > MOV R6, #0x40000000 /* Register6 with a large value stored*/

    >
    > >> > MOV R1,#0x40000000 /* Address of GPSR0 - set register*/
    > >> > ADD R1,R1, #0x00E00000
    > >> > ADD R1,R1, #0x00000018

    >
    > >> > MOV R2, #0B01000000000 /* Set the 10th bit */

    >
    > >> > STR R2,[R1] /* LED shall turn ON here*/

    >
    > >> > BAL LOOP
    > >> > /* mov pc,lr need to see what it is ??? Return to the
    > >> > caller*/
    > >> > .end

    >
    > >> You like the hard way? Why do you do it in assembler?

    >
    > >> > It's not working. Seems I missing lots of things here. First thing
    > >> > which comes is how to write linker file for it. Can someone please
    > >> > guide me or give me pointer so that I can study it. I have found few
    > >> > sample linker files from Linux kernel code also and trying to figure
    > >> > out how to write them.

    >
    > >> What's your intention? A program that runs on bare metal or as part of
    > >> the Linux kernel or something that should run as a usermode program?
    > >> Programming in assembler *could* make sense if it should run on bare
    > >> metal. For the other cases you should do it in "C".

    >
    > > Thank you for your response.
    > > Yes I want to run it on bare metal thats why witting it in assembly.

    > But you wrote:
    > >> I am very new to embedded linux. I have a pxa255 based board and I am
    > >> planning to put linux on it.

    >
    > But if you plan to bring Linux in your box, why do you start with bare
    > metal?
    >
    > Writing linker script files is not such complicated. Refer ld's manpages.
    > All it does is to give your code some kind of "layout" when it gets
    > translated to binary: Where to place the text segment content in the file
    > and at runtime (same for data and bss segment).
    > But how do you want to run this program on your bare metal? This CPU needs
    > some kind of setup after reset. To bring up the SDRAM controller for
    > example.
    >
    > Juergen


    First I am planning to have my basics ready. The very basic program
    which I can think of is writing this code to toggle LED. Can you
    please let me know in detail what all setups will be required to run
    program on bare metal?
    Even if you can share path of any tutorial which explain in detail
    will be very helpful. I am currently reading "http://www.redhat.com/
    docs/manuals/enterprise/RHEL-4-Manual/gnu-linker/scripts.html"

    Chads.

  6. Re: First program on arm board

    Chads wrote:

    > On Jan 31, 3:17 pm, Juergen Beisert wrote:
    >> >> You like the hard way? Why do you do it in assembler?

    >>
    >> >> > It's not working. Seems I missing lots of things here. First thing
    >> >> > which comes is how to write linker file for it. Can someone please
    >> >> > guide me or give me pointer so that I can study it. I have found few
    >> >> > sample linker files from Linux kernel code also and trying to figure
    >> >> > out how to write them.

    >>
    >> >> What's your intention? A program that runs on bare metal or as part of
    >> >> the Linux kernel or something that should run as a usermode program?
    >> >> Programming in assembler *could* make sense if it should run on bare
    >> >> metal. For the other cases you should do it in "C".

    >>
    >> > Thank you for your response.
    >> > Yes I want to run it on bare metal thats why witting it in assembly.

    >> But you wrote:
    >> >> I am very new to embedded linux. I have a pxa255 based board and I am
    >> >> planning to put linux on it.

    >>
    >> But if you plan to bring Linux in your box, why do you start with bare
    >> metal?
    >>
    >> Writing linker script files is not such complicated. Refer ld's manpages.
    >> All it does is to give your code some kind of "layout" when it gets
    >> translated to binary: Where to place the text segment content in the file
    >> and at runtime (same for data and bss segment).
    >> But how do you want to run this program on your bare metal? This CPU
    >> needs some kind of setup after reset. To bring up the SDRAM controller
    >> for example.
    >>
    >> Juergen

    >
    > First I am planning to have my basics ready. The very basic program
    > which I can think of is writing this code to toggle LED.


    All right, you want to go the hard way...

    > Can you please let me know in detail what all setups will be required
    > to run program on bare metal?


    Sorry, I can't. Because I know nothing about your hardware (only your
    processor). At least your SDRAM controller must be actice and your clock
    setup must be correct. Otherwise nothing will happen. And you will need
    some kind of JTAG tool to bring your small program into your target.

    > Even if you can share path of any tutorial which explain in detail
    > will be very helpful.


    Try to study the U-Boot bootloader code. They do all the required setup
    and - maybe - your hardware is also supported.

    > I am currently reading "http://www.redhat.com/
    > docs/manuals/enterprise/RHEL-4-Manual/gnu-linker/scripts.html"


    To link your program its the right direction.

    JB

  7. Re: First program on arm board

    On Jan 31, 6:23 pm, Juergen Beisert wrote:
    > Chads wrote:
    > > On Jan 31, 3:17 pm, Juergen Beisert wrote:
    > >> >> You like the hard way? Why do you do it in assembler?

    >
    > >> >> > It's not working. Seems I missing lots of things here. First thing
    > >> >> > which comes is how to write linker file for it. Can someone please
    > >> >> > guide me or give me pointer so that I can study it. I have found few
    > >> >> > sample linker files from Linux kernel code also and trying to figure
    > >> >> > out how to write them.

    >
    > >> >> What's your intention? A program that runs on bare metal or as part of
    > >> >> the Linux kernel or something that should run as a usermode program?
    > >> >> Programming in assembler *could* make sense if it should run on bare
    > >> >> metal. For the other cases you should do it in "C".

    >
    > >> > Thank you for your response.
    > >> > Yes I want to run it on bare metal thats why witting it in assembly.
    > >> But you wrote:
    > >> >> I am very new to embedded linux. I have a pxa255 based board and I am
    > >> >> planning to put linux on it.

    >
    > >> But if you plan to bring Linux in your box, why do you start with bare
    > >> metal?

    >
    > >> Writing linker script files is not such complicated. Refer ld's manpages.
    > >> All it does is to give your code some kind of "layout" when it gets
    > >> translated to binary: Where to place the text segment content in the file
    > >> and at runtime (same for data and bss segment).
    > >> But how do you want to run this program on your bare metal? This CPU
    > >> needs some kind of setup after reset. To bring up the SDRAM controller
    > >> for example.

    >
    > >> Juergen

    >
    > > First I am planning to have my basics ready. The very basic program
    > > which I can think of is writing this code to toggle LED.

    >
    > All right, you want to go the hard way...
    >
    > > Can you please let me know in detail what all setups will be required
    > > to run program on bare metal?

    >
    > Sorry, I can't. Because I know nothing about your hardware (only your
    > processor). At least your SDRAM controller must be actice and your clock
    > setup must be correct. Otherwise nothing will happen. And you will need

    Hi,

    I was able to write linker script but still my first program is not
    working.

    Please see if someone can help.

    -Chads

    > some kind of JTAG tool to bring your small program into your target.
    >
    > > Even if you can share path of any tutorial which explain in detail
    > > will be very helpful.

    >
    > Try to study the U-Boot bootloader code. They do all the required setup
    > and - maybe - your hardware is also supported.
    >
    > > I am currently reading "http://www.redhat.com/
    > > docs/manuals/enterprise/RHEL-4-Manual/gnu-linker/scripts.html"

    >
    > To link your program its the right direction.
    >
    > JB



  8. Re: First program on arm board

    Hi,

    Chads wrote:
    > On Jan 31, 6:23 pm, Juergen Beisert wrote:
    >> Chads wrote:
    >> > On Jan 31, 3:17 pm, Juergen Beisert wrote:
    >> >> >> You like the hard way? Why do you do it in assembler?

    >>
    >> >> >> > It's not working. Seems I missing lots of things here. First
    >> >> >> > thing which comes is how to write linker file for it. Can someone
    >> >> >> > please guide me or give me pointer so that I can study it. I have
    >> >> >> > found few sample linker files from Linux kernel code also and
    >> >> >> > trying to figure out how to write them.

    >>
    >> >> >> What's your intention? A program that runs on bare metal or as part
    >> >> >> of the Linux kernel or something that should run as a usermode
    >> >> >> program? Programming in assembler *could* make sense if it should
    >> >> >> run on bare metal. For the other cases you should do it in "C".

    >>
    >> >> > Thank you for your response.
    >> >> > Yes I want to run it on bare metal thats why witting it in assembly.
    >> >> But you wrote:
    >> >> >> I am very new to embedded linux. I have a pxa255 based board and I
    >> >> >> am planning to put linux on it.

    >>
    >> >> But if you plan to bring Linux in your box, why do you start with bare
    >> >> metal?

    >>
    >> >> Writing linker script files is not such complicated. Refer ld's
    >> >> manpages. All it does is to give your code some kind of "layout" when
    >> >> it gets translated to binary: Where to place the text segment content
    >> >> in the file and at runtime (same for data and bss segment).
    >> >> But how do you want to run this program on your bare metal? This CPU
    >> >> needs some kind of setup after reset. To bring up the SDRAM controller
    >> >> for example.

    >>
    >> >> Juergen

    >>
    >> > First I am planning to have my basics ready. The very basic program
    >> > which I can think of is writing this code to toggle LED.

    >>
    >> All right, you want to go the hard way...
    >>
    >> > Can you please let me know in detail what all setups will be required
    >> > to run program on bare metal?

    >>
    >> Sorry, I can't. Because I know nothing about your hardware (only your
    >> processor). At least your SDRAM controller must be actice and your clock
    >> setup must be correct. Otherwise nothing will happen. And you will need

    >
    > I was able to write linker script but still my first program is not
    > working.
    >
    > Please see if someone can help.


    ? It seems I'm blind, I can't see anything... ;-)

    JB

  9. Re: First program on arm board

    On Feb 13, 6:24 pm, Juergen Beisert wrote:
    > Hi,
    >
    >
    >
    > Chads wrote:
    > > On Jan 31, 6:23 pm, Juergen Beisert wrote:
    > >> Chads wrote:
    > >> > On Jan 31, 3:17 pm, Juergen Beisert wrote:
    > >> >> >> You like the hard way? Why do you do it in assembler?

    >
    > >> >> >> > It's not working. Seems I missing lots of things here. First
    > >> >> >> > thing which comes is how to write linker file for it. Can someone
    > >> >> >> > please guide me or give me pointer so that I can study it. I have
    > >> >> >> > found few sample linker files from Linux kernel code also and
    > >> >> >> > trying to figure out how to write them.

    >
    > >> >> >> What's your intention? A program that runs on bare metal or as part
    > >> >> >> of the Linux kernel or something that should run as a usermode
    > >> >> >> program? Programming in assembler *could* make sense if it should
    > >> >> >> run on bare metal. For the other cases you should do it in "C".

    >
    > >> >> > Thank you for your response.
    > >> >> > Yes I want to run it on bare metal thats why witting it in assembly.
    > >> >> But you wrote:
    > >> >> >> I am very new to embedded linux. I have a pxa255 based board and I
    > >> >> >> am planning to put linux on it.

    >
    > >> >> But if you plan to bring Linux in your box, why do you start with bare
    > >> >> metal?

    >
    > >> >> Writing linker script files is not such complicated. Refer ld's
    > >> >> manpages. All it does is to give your code some kind of "layout" when
    > >> >> it gets translated to binary: Where to place the text segment content
    > >> >> in the file and at runtime (same for data and bss segment).
    > >> >> But how do you want to run this program on your bare metal? This CPU
    > >> >> needs some kind of setup after reset. To bring up the SDRAM controller
    > >> >> for example.

    >
    > >> >> Juergen

    >
    > >> > First I am planning to have my basics ready. The very basic program
    > >> > which I can think of is writing this code to toggle LED.

    >
    > >> All right, you want to go the hard way...

    >
    > >> > Can you please let me know in detail what all setups will be required
    > >> > to run program on bare metal?

    >
    > >> Sorry, I can't. Because I know nothing about your hardware (only your
    > >> processor). At least your SDRAM controller must be actice and your clock
    > >> setup must be correct. Otherwise nothing will happen. And you will need

    >
    > > I was able to write linker script but still my first program is not
    > > working.

    >
    > > Please see if someone can help.

    >
    > ? It seems I'm blind, I can't see anything... ;-)
    >
    > JB


    Hi JB,

    Please find details below.

    My LED is connected at GPIO 10 of PXA255. I have written following
    program to ON it.

    .text /*Executable code follows*/
    _start: .global _start /* "_start" is required by the linkera*/
    .global main /* "main" is our main program */
    b main /* Start running the main program */
    /* Insert your code here */

    MAIN:
    MOV R1, #0x40000000 /* GPDR0 for configuring the PIN 10 as
    output*/
    ADD R1,R1, #0x00E00000
    ADD R1,R1, #0x0000000C

    /*MOV R5, #0x3B9AC9FF*/

    MOV R2, #0B01000000000
    STR R2,[R1] /* Pin 10 now configured as Output*/

    LOOP:
    MOV R0,#0
    MOV R6, #0x40000000 /* Register6 with a large value
    stored*/

    MOV R1,#0x40000000 /* Address of GPSR0 - set register*/
    ADD R1,R1, #0x00E00000
    ADD R1,R1, #0x00000018

    MOV R2, #0B01000000000 /* Set the 10th bit */

    STR R2,[R1] /* LED shall turn ON here*/

    BAL LOOP
    /* mov pc,lr need to see what it is ??? Return to the
    caller*/
    .end
    And progra

  10. Re: First program on arm board

    On Feb 14, 8:15 am, Chads wrote:
    > On Feb 13, 6:24 pm, Juergen Beisert wrote:
    >
    >
    >
    > > Hi,

    >
    > > Chads wrote:
    > > > On Jan 31, 6:23 pm, Juergen Beisert wrote:
    > > >> Chads wrote:
    > > >> > On Jan 31, 3:17 pm, Juergen Beisert wrote:
    > > >> >> >> You like the hard way? Why do you do it in assembler?

    >
    > > >> >> >> > It's not working. Seems I missing lots of things here. First
    > > >> >> >> > thing which comes is how to write linker file for it. Can someone
    > > >> >> >> > please guide me or give me pointer so that I can study it. I have
    > > >> >> >> > found few sample linker files from Linux kernel code also and
    > > >> >> >> > trying to figure out how to write them.

    >
    > > >> >> >> What's your intention? A program that runs on bare metal or as part
    > > >> >> >> of the Linux kernel or something that should run as a usermode
    > > >> >> >> program? Programming in assembler *could* make sense if it should
    > > >> >> >> run on bare metal. For the other cases you should do it in "C".

    >
    > > >> >> > Thank you for your response.
    > > >> >> > Yes I want to run it on bare metal thats why witting it in assembly.
    > > >> >> But you wrote:
    > > >> >> >> I am very new to embedded linux. I have a pxa255 based board and I
    > > >> >> >> am planning to put linux on it.

    >
    > > >> >> But if you plan to bring Linux in your box, why do you start with bare
    > > >> >> metal?

    >
    > > >> >> Writing linker script files is not such complicated. Refer ld's
    > > >> >> manpages. All it does is to give your code some kind of "layout" when
    > > >> >> it gets translated to binary: Where to place the text segment content
    > > >> >> in the file and at runtime (same for data and bss segment).
    > > >> >> But how do you want to run this program on your bare metal? This CPU
    > > >> >> needs some kind of setup after reset. To bring up the SDRAM controller
    > > >> >> for example.

    >
    > > >> >> Juergen

    >
    > > >> > First I am planning to have my basics ready. The very basic program
    > > >> > which I can think of is writing this code to toggle LED.

    >
    > > >> All right, you want to go the hard way...

    >
    > > >> > Can you please let me know in detail what all setups will be required
    > > >> > to run program on bare metal?

    >
    > > >> Sorry, I can't. Because I know nothing about your hardware (only your
    > > >> processor). At least your SDRAM controller must be actice and your clock
    > > >> setup must be correct. Otherwise nothing will happen. And you will need

    >
    > > > I was able to write linker script but still my first program is not
    > > > working.

    >
    > > > Please see if someone can help.

    >
    > > ? It seems I'm blind, I can't see anything... ;-)

    >
    > > JB

    >
    > Hi JB,
    >
    > Please find details below.
    >
    > My LED is connected at GPIO 10 of PXA255. I have written following
    > program to ON it.
    >
    > .text /*Executable code follows*/
    > _start: .global _start /* "_start" is required by the linkera*/
    > .global main /* "main" is our main program */
    > b main /* Start running the main program */
    > /* Insert your code here */
    >
    > MAIN:
    > MOV R1, #0x40000000 /* GPDR0 for configuring the PIN 10 as
    > output*/
    > ADD R1,R1, #0x00E00000
    > ADD R1,R1, #0x0000000C
    >
    > /*MOV R5, #0x3B9AC9FF*/
    >
    > MOV R2, #0B01000000000
    > STR R2,[R1] /* Pin 10 now configured as Output*/
    >
    > LOOP:
    > MOV R0,#0
    > MOV R6, #0x40000000 /* Register6 with a large value
    > stored*/
    >
    > MOV R1,#0x40000000 /* Address of GPSR0 - set register*/
    > ADD R1,R1, #0x00E00000
    > ADD R1,R1, #0x00000018
    >
    > MOV R2, #0B01000000000 /* Set the 10th bit */
    >
    > STR R2,[R1] /* LED shall turn ON here*/
    >
    > BAL LOOP
    > /* mov pc,lr need to see what it is ??? Return to the
    > caller*/
    > .end
    > And progra


    I am sorry for incomplete post.

    I have also written program on similar lines to OFF, Toggle LED.

    I have used following steps:

    1) Used cross arm assembler to create its executable file(ELF format).
    2) Used cross objcopy to convert it into binary image
    3) Transferring this binary image to my board at 0x0 as processor
    start execution from 0x0 on reset.

    I thought I might have to write a basis linker script for it? Please
    let me know if I really need it or not as my memory map shows that at
    0x0 it has boot flash I am witting my program there so it should work.
    I have share my linker script in case you feel that I need it

    Please let me know what more information is required from my side.

    Thanks
    Chads


  11. Re: First program on arm board

    Hi JB,

    Finally I was able to run my first program on ARM board.

    Cheers Chads.

    On Feb 14, 8:23 am, Chads wrote:
    > On Feb 14, 8:15 am, Chads wrote:
    >
    >
    >
    > > On Feb 13, 6:24 pm, Juergen Beisert wrote:

    >
    > > > Hi,

    >
    > > > Chads wrote:
    > > > > On Jan 31, 6:23 pm, Juergen Beisert wrote:
    > > > >> Chads wrote:
    > > > >> > On Jan 31, 3:17 pm, Juergen Beisert wrote:
    > > > >> >> >> You like the hard way? Why do you do it in assembler?

    >
    > > > >> >> >> > It's not working. Seems I missing lots of things here. First
    > > > >> >> >> > thing which comes is how to write linker file for it. Can someone
    > > > >> >> >> > please guide me or give me pointer so that I can study it. I have
    > > > >> >> >> > found few sample linker files from Linux kernel code also and
    > > > >> >> >> > trying to figure out how to write them.

    >
    > > > >> >> >> What's your intention? A program that runs on bare metal or as part
    > > > >> >> >> of the Linux kernel or something that should run as a usermode
    > > > >> >> >> program? Programming in assembler *could* make sense if it should
    > > > >> >> >> run on bare metal. For the other cases you should do it in "C".

    >
    > > > >> >> > Thank you for your response.
    > > > >> >> > Yes I want to run it on bare metal thats why witting it in assembly.
    > > > >> >> But you wrote:
    > > > >> >> >> I am very new to embedded linux. I have a pxa255 based board and I
    > > > >> >> >> am planning to put linux on it.

    >
    > > > >> >> But if you plan to bring Linux in your box, why do you start with bare
    > > > >> >> metal?

    >
    > > > >> >> Writing linker script files is not such complicated. Refer ld's
    > > > >> >> manpages. All it does is to give your code some kind of "layout" when
    > > > >> >> it gets translated to binary: Where to place the text segment content
    > > > >> >> in the file and at runtime (same for data and bss segment).
    > > > >> >> But how do you want to run this program on your bare metal? This CPU
    > > > >> >> needs some kind of setup after reset. To bring up the SDRAM controller
    > > > >> >> for example.

    >
    > > > >> >> Juergen

    >
    > > > >> > First I am planning to have my basics ready. The very basic program
    > > > >> > which I can think of is writing this code to toggle LED.

    >
    > > > >> All right, you want to go the hard way...

    >
    > > > >> > Can you please let me know in detail what all setups will be required
    > > > >> > to run program on bare metal?

    >
    > > > >> Sorry, I can't. Because I know nothing about your hardware (only your
    > > > >> processor). At least your SDRAM controller must be actice and your clock
    > > > >> setup must be correct. Otherwise nothing will happen. And you will need

    >
    > > > > I was able to write linker script but still my first program is not
    > > > > working.

    >
    > > > > Please see if someone can help.

    >
    > > > ? It seems I'm blind, I can't see anything... ;-)

    >
    > > > JB

    >
    > > Hi JB,

    >
    > > Please find details below.

    >
    > > My LED is connected at GPIO 10 of PXA255. I have written following
    > > program to ON it.

    >
    > > .text /*Executable code follows*/
    > > _start: .global _start /* "_start" is required by the linkera*/
    > > .global main /* "main" is our main program */
    > > b main /* Start running the main program */
    > > /* Insert your code here */

    >
    > > MAIN:
    > > MOV R1, #0x40000000 /* GPDR0 for configuring the PIN 10 as
    > > output*/
    > > ADD R1,R1, #0x00E00000
    > > ADD R1,R1, #0x0000000C

    >
    > > /*MOV R5, #0x3B9AC9FF*/

    >
    > > MOV R2, #0B01000000000
    > > STR R2,[R1] /* Pin 10 now configured as Output*/

    >
    > > LOOP:
    > > MOV R0,#0
    > > MOV R6, #0x40000000 /* Register6 with a large value
    > > stored*/

    >
    > > MOV R1,#0x40000000 /* Address of GPSR0 - set register*/
    > > ADD R1,R1, #0x00E00000
    > > ADD R1,R1, #0x00000018

    >
    > > MOV R2, #0B01000000000 /* Set the 10th bit */

    >
    > > STR R2,[R1] /* LED shall turn ON here*/

    >
    > > BAL LOOP
    > > /* mov pc,lr need to see what it is ??? Return to the
    > > caller*/
    > > .end
    > > And progra

    >
    > I am sorry for incomplete post.
    >
    > I have also written program on similar lines to OFF, Toggle LED.
    >
    > I have used following steps:
    >
    > 1) Used cross arm assembler to create its executable file(ELF format).
    > 2) Used cross objcopy to convert it into binary image
    > 3) Transferring this binary image to my board at 0x0 as processor
    > start execution from 0x0 on reset.
    >
    > I thought I might have to write a basis linker script for it? Please
    > let me know if I really need it or not as my memory map shows that at
    > 0x0 it has boot flash I am witting my program there so it should work.
    > I have share my linker script in case you feel that I need it
    >
    > Please let me know what more information is required from my side.
    >
    > Thanks
    > Chads



+ Reply to Thread