This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/PROCESSOR-SDK-AM335X: Bad startup code

Part Number: PROCESSOR-SDK-AM335X


Tool/software: Code Composer Studio

Hi,

I've had a weird situation where the standard system startup code for a project causes a data abort.  I have two projects, one initially created as a "Hello World" example, and the other as an empty (no main) C project. Each has been subsequently modified so that they have identical project Properties (this has been thoroughly checked), identical sources, identical symbols, identical directory paths, identical everything.  But while the _start code for the "hello World" version is fine, the version for the empty project causes a target exception.

The problem is not insurmountable -- as long as you create every new project as a "Hello World" example.  But you shouldn't have to do that so maybe someone could shed some light on this anomaly.

My setup is as follows:
CCS Version: 6.1.2.00015
pdk_am335x_1_0_3
GNU v4.9.3 (Linaro)
Win 7 64-bit

The good/"Hello World" _start code is as follows (copied from the disassembly window):
40300108:   E3B00016            movs       r0, #0x16
4030010c:   E28F1F4A            add        r1, pc, #0x128
40300110:   EF123456            svc        #0x123456
40300114:   E59F0120            ldr        r0, [pc, #0x120]
40300118:   E5901004            ldr        r1, [r0, #4]
4030011c:   E59F2138            ldr        r2, [pc, #0x138]
40300120:   E5821000            str        r1, [r2]
40300124:   E5901000            ldr        r1, [r0]
40300128:   E3510000            cmp        r1, #0
4030012c:   1A000001            bne        #0x40300138
40300130:   E59F1120            ldr        r1, [pc, #0x120]
40300134:   E5801000            str        r1, [r0]
40300138:   E5901008            ldr        r1, [r0, #8]
4030013c:   E590200C            ldr        r2, [r0, #0xc]
40300140:   E3510000            cmp        r1, #0
40300144:   0A000000            beq        #0x4030014c
40300148:   E1A0D001            mov        sp, r1
4030014c:   E3520000            cmp        r2, #0
40300150:   0A000000            beq        #0x40300158
40300154:   E282AC01            add        r10, r2, #0x100
40300158:   E3B01000            movs       r1, #0
4030015c:   E1A0B001            mov        r11, r1
40300160:   E1A07001            mov        r7, r1
40300164:   E59F00D4            ldr        r0, [pc, #0xd4]
40300168:   E59F20D4            ldr        r2, [pc, #0xd4]
4030016c:   E0522000            subs       r2, r2, r0
40300170:   EB001963            bl         memset
40300174:   EB0013A5            bl         initialise_monitor_handles
40300178:   E3B00015            movs       r0, #0x15
4030017c:   E28F10CC            add        r1, pc, #0xcc
40300180:   EF123456            svc        #0x123456
40300184:   E59F10C4            ldr        r1, [pc, #0xc4]
40300188:   E3B00000            movs       r0, #0
4030018c:   E92D0001            stmdb      sp!, {r0}
40300190:   E4D13001            ldrb       r3, [r1], #1
40300194:   E3530000            cmp        r3, #0
40300198:   0A000011            beq        #0x403001e4
4030019c:   E3530020            cmp        r3, #0x20
403001a0:   0AFFFFFA            beq        #0x40300190
403001a4:   E3530022            cmp        r3, #0x22
403001a8:   13530027            cmpne      r3, #0x27
403001ac:   01A02003            moveq      r2, r3
403001b0:   13A02020            movne      r2, #0x20
403001b4:   12411001            subne      r1, r1, #1
403001b8:   E92D0002            stmdb      sp!, {r1}
403001bc:   E2900001            adds       r0, r0, #1
403001c0:   E4D13001            ldrb       r3, [r1], #1
403001c4:   E3530000            cmp        r3, #0
403001c8:   0A000005            beq        #0x403001e4
403001cc:   E1520003            cmp        r2, r3
403001d0:   1AFFFFFA            bne        #0x403001c0
403001d4:   E3B02000            movs       r2, #0
403001d8:   E2513001            subs       r3, r1, #1
403001dc:   E5C32000            strb       r2, [r3]
403001e0:   EAFFFFEA            b          #0x40300190
403001e4:   E1A0100D            mov        r1, sp
403001e8:   E08D2100            add        r2, sp, r0, lsl #2
403001ec:   E1A0300D            mov        r3, sp
403001f0:   E1520003            cmp        r2, r3
403001f4:   85124004            ldrhi      r4, [r2, #-4]
403001f8:   85935000            ldrhi      r5, [r3]
403001fc:   85225004            strhi      r5, [r2, #-4]!
40300200:   84834004            strhi      r4, [r3], #4
40300204:   8AFFFFF9            bhi        #0x403001f0
40300208:   E3CDD007            bic        sp, sp, #7
4030020c:   E1B04000            movs       r4, r0
40300210:   E1B05001            movs       r5, r1
40300214:   E59F002C            ldr        r0, [pc, #0x2c]
40300218:   E3500000            cmp        r0, #0
4030021c:   0A000001            beq        #0x40300228
40300220:   E59F0024            ldr        r0, [pc, #0x24]
40300224:   EB001A49            bl         atexit
40300228:   EB001731            bl         __libc_init_array
4030022c:   E1B00004            movs       r0, r4
40300230:   E1B01005            movs       r1, r5
40300234:   EB0003DF            bl         main
40300238:   EB001608            bl         exit
4030023c:   40307794            mlasmi     r0, r4, r7, r7
40300240:   403086BC            ldrhtmi    r8, [r0], -r12
40300244:   403087C0            eorsmi     r8, r0, r0, asr #15
40300248:   40306B50            eorsmi     r6, r0, r0, asr r11
4030024c:   40306F8C            eorsmi     r6, r0, r12, lsl #31
40300250:   403077A4            eorsmi     r7, r0, r4, lsr #15
40300254:   00000001            andeq      r0, r0, r1
40300258:   403087C0            eorsmi     r8, r0, r0, asr #15
4030025c:   40307E6C            eorsmi     r7, r0, r12, ror #28
329       {
          HW_RD_REG32():

The bad/empty project _start code is:
40300108:   E59F30F0            ldr        r3, [pc, #0xf0]
4030010c:   E3530000            cmp        r3, #0
40300110:   059F30E4            ldreq      r3, [pc, #0xe4]
40300114:   E1A0D003            mov        sp, r3
40300118:   E10F2000            mrs        r2, apsr
4030011c:   E312000F            tst        r2, #0xf
40300120:   0A000015            beq        #0x4030017c
40300124:   E321F0D1            msr        cpsr_c, #0xd1
40300128:   E1A0D003            mov        sp, r3
4030012c:   E24DAA01            sub        r10, sp, #0x1000
40300130:   E1A0300A            mov        r3, r10
40300134:   E321F0D7            msr        cpsr_c, #0xd7
40300138:   E1A0D003            mov        sp, r3
4030013c:   E2433A01            sub        r3, r3, #0x1000
40300140:   E321F0DB            msr        cpsr_c, #0xdb
40300144:   E1A0D003            mov        sp, r3
40300148:   E2433A01            sub        r3, r3, #0x1000
4030014c:   E321F0D2            msr        cpsr_c, #0xd2
40300150:   E1A0D003            mov        sp, r3
40300154:   E2433A02            sub        r3, r3, #0x2000
40300158:   E321F0D3            msr        cpsr_c, #0xd3
4030015c:   E1A0D003            mov        sp, r3
40300160:   E2433902            sub        r3, r3, #0x8000
40300164:   E3C330FF            bic        r3, r3, #0xff
40300168:   E3C33CFF            bic        r3, r3, #0xff00
4030016c:   E5033004            str        r3, [r3, #-4]          <<<<<<<<<<<< THIS IS A PROBLEM
40300170:   E9532000            ldmdb      r3, {sp} ^
40300174:   E38220C0            orr        r2, r2, #0xc0
40300178:   E121F002            msr        cpsr_c, r2
4030017c:   E243A801            sub        r10, r3, #0x10000
40300180:   E3B01000            movs       r1, #0
40300184:   E1A0B001            mov        r11, r1
40300188:   E1A07001            mov        r7, r1
4030018c:   E59F0078            ldr        r0, [pc, #0x78]
40300190:   E59F2078            ldr        r2, [pc, #0x78]
40300194:   E0522000            subs       r2, r2, r0
40300198:   EB0009AD            bl         memset
4030019c:   E59F3060            ldr        r3, [pc, #0x60]
403001a0:   E3530000            cmp        r3, #0
403001a4:   0A000001            beq        #0x403001b0
403001a8:   E1A0E00F            mov        lr, pc
403001ac:   E1A0F003            mov        pc, r3
403001b0:   E59F3050            ldr        r3, [pc, #0x50]
403001b4:   E3530000            cmp        r3, #0
403001b8:   0A000001            beq        #0x403001c4
403001bc:   E1A0E00F            mov        lr, pc
403001c0:   E1A0F003            mov        pc, r3
403001c4:   E3B00000            movs       r0, #0
403001c8:   E3B01000            movs       r1, #0
403001cc:   E1B04000            movs       r4, r0
403001d0:   E1B05001            movs       r5, r1
403001d4:   E59F0038            ldr        r0, [pc, #0x38]
403001d8:   E3500000            cmp        r0, #0
403001dc:   0A000001            beq        #0x403001e8
403001e0:   E59F0030            ldr        r0, [pc, #0x30]
403001e4:   EB000A4E            bl         atexit
403001e8:   EB000795            bl         __libc_init_array
403001ec:   E1B00004            movs       r0, r4
403001f0:   E1B01005            movs       r1, r5
403001f4:   EB0003DE            bl         main
403001f8:   EB000784            bl         exit
403001fc:   00080000            andeq      r0, r8, r0
40300200:   40306120            eorsmi     r6, r0, r0, lsr #2
40300204:   00000000            andeq      r0, r0, r0
40300208:   00000000            andeq      r0, r0, r0
4030020c:   403040BC            ldrhtmi    r4, [r0], -r12
40300210:   40304114            eorsmi     r4, r0, r4, lsl r1
40300214:   40302B24            eorsmi     r2, r0, r4, lsr #22
40300218:   40302B44            eorsmi     r2, r0, r4, asr #22
329       {
          HW_RD_REG32():

Thanks,
Gerry