(RV64GCV) F133 (MangoPi MQ-R) >> Assembly
LED
參考資料:
1. pdf
LED是連接到PWM7
PWM7是PD22
GPIO位址
PD_CFG2
PD_DAT
main.s
.global _start .equ GPIO_BASE, 0x02000000 .equ PD_CFG2, 0x0098 .equ PD_DAT, 0x00a0 .text .long 0x0a00006f .byte 'e','G','O','N','.','B','T','0' .long 0x5F0A6C39 .long 0x8000 .long 0, 0 .long 0, 0, 0, 0, 0, 0, 0, 0 .long 0, 0, 0, 0, 0, 0, 0, 0 .org 0x00a0 _vector: j _start .org 0x0100 _start: li t0, (1 << 24) li a0, GPIO_BASE + PD_CFG2 sw t0, 0(a0) li t1, (1 << 22) 0: xor t0, t0, t1 li a0, GPIO_BASE + PD_DAT sw t0, 0(a0) lui t2, 10000 1: nop addi t2, t2, -1 bgtz t2, 1b j 0b .end
main.ld
MEMORY { FLASH : ORIGIN = 0, LENGTH = 32M } SECTIONS { .text : { *(.text*) } > FLASH .rodata : { *(.rodata*) } > FLASH .bss : { *(.bss*) } > FLASH }
Makefile
all: riscv64-unknown-linux-gnu-as -o main.o main.s riscv64-unknown-linux-gnu-ld -T main.ld -o main.elf main.o riscv64-unknown-linux-gnu-objcopy -O binary main.elf tmp.bin python3 gen_checksum.py tmp.bin main.bin run: xfel ddr f133 && xfel write 0x40000000 main.bin && xfel exec 0x40000000 clean: rm -rf main.bin main.o main.elf tmp.bin
編譯
$ make riscv64-unknown-linux-gnu-as -o main.o main.s riscv64-unknown-linux-gnu-ld -T main.ld -o main.elf main.o riscv64-unknown-linux-gnu-objcopy -O binary main.elf tmp.bin python3 gen_checksum.py tmp.bin main.bin
執行
$ make run xfel ddr f133 && xfel write 0x40000000 main.bin && xfel exec 0x40000000 Initial ddr controller succeeded 100% [================================================] 16.000 KB, 431.932 KB/s
完成
返回上一頁