Hi all. I like to know what is going on under the hood so I started from developing a simple app in assembler language. The app should just turn on the LED. I checked everything several times but no success. Could you please have a look and maybe find some fixes ?
Build script:
Source code of the app crt0.s ( I know I should not use 'crt0' as a name for this ):
My ideas are:
1. I handle the Watch Dog badly.
2. I setup pin 5 of port C badly.
4. Build script is invalid because of following error printed by Teensy Loader.
Build script:
Code:
./bin/arm-none-eabi-as -mcpu=cortex-m4 -o crt0.o crt0.s
./bin/arm-none-eabi-ld -Ttext 0x0 -o crt0.elf crt0.o
./bin/arm-none-eabi-objcopy -O binary crt0.elf crt0.bin
./bin/arm-none-eabi-objcopy -O ihex crt0.elf crt0.hex
Source code of the app crt0.s ( I know I should not use 'crt0' as a name for this ):
Code:
.text
.org 0
vectors:
.word 0x20000000 @ Initial Stack Pointer
.word reset @ Initial Program Counter
.word default @ NMI
.word default @ Hard Default
.word default @ Memory Manage Fault
.word default @ Bus Fault
.word default @ Usage Fault
.word default @ SV Call
.word default @ Debug monitor
.word default @ Pendable Request for System Service
.word default @ System Tick Timer
.org 0x400
.byte 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF
.align
default:
b default
reset:
unlock_watchdog:
ldr r6, =0x4005200e
ldr r0, =0xc520
strh r0, [r6]
ldr r0, =0xd928
strh r0, [r6]
disable_watchdog:
ldr r6, =0x40052000
ldr r0, =0x01d2
strh r0, [r6]
led_on:
ldr r6, = 0x40048038 @ SIM_SCGC5
ldr r0, = 0x00043F82 @ Clocks active to all GPIO
str r0, [r6]
.set GPIO_ENABLE, (0x001 << 8)
.set PULL_UP_ENABLE, (1 << 1)
.set PULL_UP_SELECT, (1 << 0)
.set DRIVE_STR, (1 << 6)
.set PORT_CTRL_FLAGS, (DRIVE_STR | GPIO_ENABLE )
ldr r6, = 0x4004B000
ldr r0, = PORT_CTRL_FLAGS
str r0, [r6]
ldr r6, = 0x400FF094 @ GPIOC_PDDR
ldr r0, = 0xFFFFFFFF @ All as output
str r0, [r6]
ldr r6, = 0x400FF080 @ GPIOC_PDOR
ldr r0, = 0xFFFFFFFF @ All as high
str r0, [r6]
loop:
b loop
My ideas are:
1. I handle the Watch Dog badly.
2. I setup pin 5 of port C badly.
4. Build script is invalid because of following error printed by Teensy Loader.
Code:
15:12:43: File "crt0.hex". 1184 bytes, 0% used
15:12:43: elf size appears to be 0
15:12:43: Code size from .elf file = 0
Last edited: