Hello All,
I can't seem to find the answer to my issue on the internet and several reference guides after many hours of research. I want to run a simple gpio toggle (turn on pin labeled pb2 - pin 47) program in assembly compiled using the GNU AS compiler (arm-none-eabi-as) and this is what I have so far:
-----begin of start.s --------
.syntax unified
.text
.global _start
_start:
.word 0x20007000
.word _reset
.word .
.word .
.word .
.word .
.word .
.word .
.word .
.word .
.word .
.word .
.word .
.word .
.word .
.word .
.word .
.word .
_reset:
ldr sp,=stack_top
isb
ldr r0,=0x400fe608 Enables the clock to all GPIO blocks
ldr r1,=0xff
str r1,[r0]
nop
nop
nop
nop
ldr r0,=0x40059400 Sets the direction of the gpio pins in block B
ldr r1,=0xff
str r0,[r1]
nop
nop
ldr r0,=0x40059420 Sets AFSEL - this is likely redundant as AFSEL defaults to 0x0 on reset/powerup.
ldr r1,=0x0
str r0,[r1]
ldr r0,=0x40059500 Sets the pin to DR2R.
ldr r1,=0xff
str r0,[r1]
nop
nop
ldr r0,=0x4005950c Sets ODR.
ldr r1,=0xff
str r0,[r1]
nop
nop
ldr r0,=0x4005951c Sets DEN.
ldr r1,=0xff
str r0,[r1]
ldr r0,=0x40059fff Sets DATA on all pins in block B.
ldr r1,=0xff
str r0,[r1]
---end of start.s---
----begin of start.ld---
ENTRY(_start)
SECTIONS
{
. = 0x0;
.text : {
*start.o (_start)
}
. = 0x20007000;
stack_top = .;
}
----end of start.ld----
The compile commands are as follows:
arm-none-eabi-as -mcpu=cortex-m4 -mthumb -o start.o start.s
arm-none-eabi-ld -T start.ld start.o -o start.elf
arm-none-eabi-objcopy -O binary start.elf start.bin
There are no problems compiling and uploading start.bin to the launchpad via the LM Flash Programmer; however the pin does not open and there is power to the unit (the green pwr led is on). The .word directive was used in place of the dcd directive, as the GNU assembler does not understand dcd. The hex memory addresses have been hard coded in the body and there is a better way of doing things, but that's all semantics. Any help is appreciated, thanks.
Below is the output of nm and objdump.
:~/programming# arm-none-eabi-nm start.elf
00000044 t _reset
20007000 A stack_top
00000000 T _start
~/programming# arm-none-eabi-objdump -D -b binary -marm start.bin
start.bin: file format binary
Disassembly of section .data:
00000000 <.data>:
0: 20007000 andcs r7, r0, r0
4: 00000044 andeq r0, r0, r4, asr #32
8: 00000008 andeq r0, r0, r8
c: 0000000c andeq r0, r0, ip
10: 00000010 andeq r0, r0, r0, lsl r0
14: 00000014 andeq r0, r0, r4, lsl r0
18: 00000018 andeq r0, r0, r8, lsl r0
1c: 0000001c andeq r0, r0, ip, lsl r0
20: 00000020 andeq r0, r0, r0, lsr #32
24: 00000024 andeq r0, r0, r4, lsr #32
28: 00000028 andeq r0, r0, r8, lsr #32
2c: 0000002c andeq r0, r0, ip, lsr #32
30: 00000030 andeq r0, r0, r0, lsr r0
34: 00000034 andeq r0, r0, r4, lsr r0
38: 00000038 andeq r0, r0, r8, lsr r0
3c: 0000003c andeq r0, r0, ip, lsr r0
40: 00000040 andeq r0, r0, r0, asr #32
44: d04cf8df ldrdle pc, [ip], #-143 ; 0xffffff71
48: 8f6ff3bf svchi 0x006ff3bf
4c: 49134812 ldmdbmi r3, {r1, r4, fp, lr}
50: bf006001 svclt 0x00006001
54: bf00bf00 svclt 0x0000bf00
58: 4811bf00 ldmdami r1, {r8, r9, sl, fp, ip, sp, pc}
5c: 6008490f andvs r4, r8, pc, lsl #18
60: bf00bf00 svclt 0x0000bf00
64: 4910480f ldmdbmi r0, {r0, r1, r2, r3, fp, lr}
68: bf006008 svclt 0x00006008
6c: 480fbf00 stmdami pc, {r8, r9, sl, fp, ip, sp, pc} ; <UNPREDICTABLE>
70: 6008490a andvs r4, r8, sl, lsl #18
74: bf00bf00 svclt 0x0000bf00
78: 4908480d stmdbmi r8, {r0, r2, r3, fp, lr}
7c: bf006008 svclt 0x00006008
80: 480cbf00 stmdami ip, {r8, r9, sl, fp, ip, sp, pc}
84: 60084905 andvs r4, r8, r5, lsl #18
88: bf00bf00 svclt 0x0000bf00
8c: 4903480a stmdbmi r3, {r1, r3, fp, lr}
90: 00006008 andeq r6, r0, r8
94: 20007000 andcs r7, r0, r0
98: 400fe608 andmi lr, pc, r8, lsl #12
9c: 000000ff strdeq r0, [r0], -pc ; <UNPREDICTABLE>
a0: 40059400 andmi r9, r5, r0, lsl #8
a4: 40059420 andmi r9, r5, r0, lsr #8
a8: 00000000 andeq r0, r0, r0
ac: 40059500 andmi r9, r5, r0, lsl #10
b0: 4005950c andmi r9, r5, ip, lsl #10
b4: 4005951c andmi r9, r5, ip, lsl r5
b8: 40059fff strdmi r9, [r5], -pc ; <UNPREDICTABLE>