User:Immibis/PinePhone Blinky

From OSDev Wiki
Jump to: navigation, search

Blinks green, red, blue (in order of pin number - schematic says it should be red, green, blue - is it wired wrong?), then rumbles the motor and returns to the bootloader with the LED red.

code.s:

.section .stuff, "ax"

	ldr r0, =0x77711177
	ldr r1, =0x01C2086C
	str r0, [r1, #8]
	mov r0, #0x00040000
	str r0, [r1, #16]

	mov r2, #0x3F0000
loop1:
	sub r2, #1
	cmp r2, #0
	bne loop1
	
	mov r0, #0x00080000
	str r0, [r1, #16]
	
	mov r2, #0x3F0000
loop2:
	sub r2, #1
	cmp r2, #0
	bne loop2
	
	mov r0, #0x00100000
	str r0, [r1, #16]
	
	mov r2, #0x3F0000
loop3:
	sub r2, #1
	cmp r2, #0
	bne loop3
	
	mov r0, #0x00100000
	str r0, [r1, #16]
	
	
	ldr r0, =0x77777777
	str r0, [r1]
	
	ldr r0, =0x77777177
	str r0, [r1, #0]
	
	mov r0, #4
	str r0, [r1, #16]
	
	
	mov r2, #0x3F0000
loop4:
	sub r2, #1
	cmp r2, #0
	bne loop4
	
	ldr r0, =0x77777777
	str r0, [r1, #0]
	
	ldr r0, =0x77711177
	str r0, [r1, #8]
	
	mov r0, #0x00080000
	str r0, [r1, #16]
	
	bx lr
.pool

script.ld:

SECTIONS
{
	. = 0x00010000;
	.stuff : AT(0) {
		INPUT_SECTION_FLAGS(SHF_ALLOC) *(*)
	}
}

run.sh:

#!/bin/bash
set -e
arm-none-eabi-as code.s -o code.o -mcpu=cortex-a53
arm-none-eabi-ld code.o -T script.ld -o code.elf
arm-none-eabi-objcopy code.elf code.bin --output-target binary --only-section .stuff
xxd -g4 -e code.bin
sunxi-fel write 0x00010000 code.bin
sunxi-fel execute 0x00010000
Personal tools
Namespaces
Variants
Actions
Navigation
About
Toolbox