1

I have been struggling to light an LED using my raspberry pi 4 model b but have not been able to find a solution.

My assembly code :

.section .init
.globl _start
_start:

mov r0, #0xF0000000
orr r0, #0x0E000000
orr r0, #0x00200000
orr r0, #0x00000004
mov r1, #1
lsl r1, #18
str r1, [r0]

mov r0, #0xF0000000
orr r0, #0x0E000000
orr r0, #0x00200000
orr r0, #0x0000001C
mov r1, #1
lsl r1, #16
str r1, [r0]

loop$:
b loop$

I am trying to light up the LED through GPIO 16. A post on the raspberry pi forums suggests that the peripheral memory base has changed to 0xFE000000 instead of 0x20000000 + the GPIO offset; neither of those memory addresses worked to light the LED.

I also installed NOOBS on a different SD card and wrote a python script to light the LED and that worked.

To learn about the bare metals of raspberry pi, I have been reading the Baking Pi tutorial by the University of Cambridge.

Any help would be great.

  • I skimmed Baking Pi's first two lessons and found this tutorial very good for newbies. I would rate it top 1% of the 100+ online tutorials I have read all these years. Lesson 1 actually shows every step to turn on GPIO 16 LED. Is there a step you could not follow or got stuck? – tlfong01 Sep 28 at 1:15
  • I skimmed the Troubleshooint section and read the following: Troubleshooting: cl.cam.ac.uk/projects/raspberrypi/tutorials/os/… "This course has not yet been updated to work with the Raspberry Pi models B+ and A+. Some elements may not work, in particular the first few lessons about the LED. It has also not been updated for Raspberry Pi v2" ... In other words, the tutorials is perhaps 5 years out of date! – tlfong01 Sep 28 at 2:18
  • So you know how to use python to turn on a LED. But why now diving deep down to ARM assembly/machine language? – tlfong01 Sep 28 at 2:32
  • Question - I used apt-get to install the toolchain, but got errors "unable to find some archives, ..." Did you get the same error? – tlfong01 Sep 28 at 3:39
  • Hi @Rahul Wadhwani, I am catching up. I just finished reading Lesson1 and so can more or less understand your turn-on-LED program. I will try to copy a similar demo code from Lesson 1 and hopefully assembled it and run it. – tlfong01 Sep 28 at 14:53

Your Answer

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

Browse other questions tagged or ask your own question.