5

I'm trying to run some bare-metal code on my raspi 3. This is my first time doing any sort of bare-metal programming, so first things first I want to turn on my ACT led as a kind of hello-world type program but I can't for the life of me get it to turn on.

From what I've gathered:

  • the act led is on gpio pin 47
  • I need to set this pin to an output using gpio function select
  • this pin is active low so to turn it on I need to clear it

My sd card is a raspbian image but I replaced the kernel.img with my own. Also the config.txt is completely empty at the moment.Below is the assembly code I'm running, my linker sets .init to be 0x8000

.section .init
.global _start

GPIO_BASE = 0x3F200000
GPFSEL4 = 0x10
GPSET1 = 0x20
GPCLR1 = 0x2C

_start:
    ldr r0,=GPIO_BASE

    //set ACT led to output
    mov r1,#1
    lsl r1,#21 //gpio 47 = 21-23
    str r1,[r0,#GPFSEL4] 

    //turn on ACT led
    mov r1,#1
    lsl r1,#16
    str r1,[r0,#GPCLR1]
loop:
    b loop
5

Models A and B

  • The green activity LED (GPIO 16) may be written.

Models A+ and B+

  • The green activity LED (GPIO 47) may be written.
  • The red power LED (GPIO 35) may be written.
  • The high USB power mode (GPIO 38) may be written.

Pi Zero and Pi Zero W

  • The green activity LED (GPIO 47) may be written.

Pi2B

  • The green activity LED (GPIO 47) may be written.
  • The red power LED (GPIO 35) may be written.
  • The high USB power mode (GPIO 38) may be written.

Pi3B

  • The green activity LED and the red power LED are not directly writeable. They are not connected to the GPIO. On the Pi3 the LEDs are connected to an I2C port expander. There is a method to write the LEDs but I think it uses the mailbox interface to the GPU.
  • The USB power mode is fixed at 1.2 amps (high power).
1

Expanding joan's answer:

Raspberry Pi 3 B+ (1 GiB RAM) and A+ (512 MiB RAM)

  • The green activity LED (GPIO 29) may be written

    • The red power LED is connected to MXL7704 power management IC and is not available to software
  • The USB power mode is fixed at high power

0

You are shifting the r1 register 16 bits left, this clears the 16th pin. You should instead shift the r1 register 47 bits left to clear pin 47(the ACT LED). As posted above, you cannot access the ACT LED through the GPIO controller, but you can on the RPI Zero/RPI Zero W, so your code should work on those.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.