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

Reply to
Chads
Loading thread data ...

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

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

Reply to
Juergen Beisert

Hi Juergen,

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

Reply to
Chads

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

Reply to
Juergen Beisert

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 "

formatting link
"

Chads.

Reply to
Chads

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

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.

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

To link your program its the right direction.

JB

Reply to
Juergen Beisert

Hi,

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

Please see if someone can help.

-Chads

Reply to
Chads

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

JB

Reply to
Juergen Beisert

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

Reply to
Chads

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
Chads

Hi JB,

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

Cheers Chads.

someone

have

part

assembly.

I

bare

controller

Reply to
Chads

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.