Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4856

Bare metal, Assembly language • Re: For Baremetal Raspberry Pi Zero 2W, how can I use GPIO pins?

$
0
0
Alright, I got it to work, but only the 32-bit-elf files with the apt arm-none-eabi-gcc, for now

Code:

ldr r0, gpiomov r1, #8str r1, [r0, #8]ldr r1, pin21str r1, [r0, #28]    bx lrpin21:.word 0x00200000gpio:.word 0x3f200000
This should light up GPIO pin 21

Compiling commands
  • 1. arm-none-eabi-gcc -Wall -O2 -nostdlib -c main.s -o kernel7.o
    2. arm-none-eabi-ld -nostdlib -T link.ld kernel7.o -o kernel7.elf
    3. arm-none-eabi-objcopy -O binary kernel7.elf kernel7.img
One thing to note is that this is not an ARMv8-A, but a 32-bit assembly.

and the .elf file is a
kernel7.elf: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, not stripped
I will try to get a 64-bit executable working with aarch-elf-gcc

Statistics: Posted by theINCORRECTone — Mon Jun 24, 2024 9:31 am



Viewing all articles
Browse latest Browse all 4856

Trending Articles