1

I'm trying to enable a GPIO pin on raspberry pi 3 B using assembly. I tried to do the same on raspberry pi 1 and it worked, also it worked when I used raspbian command to enable it and then I tried interpreting the Rpi 1 code to Rpi 3 B but it wouldn't work. here is my code

.section ".text.boot"

.global _start

_start:
    ldr X0,=0x3F200000 
    mov X1,#1
    lsl X1,X1,#12
    str X1,[X0,#4]
    mov X1,#1
    lsl X1,X1,#14
    str X1,[X0,#40]
1:  wfe
    b       1b

Also should the kernel image be named 'kernel8.img'

N.B. I'm trying to enable pin 14 with this code

  • Please explain in words what you are trying to do with the assembler line by line. Then someone will point out what you are doing wrong. – joan Mar 22 '18 at 15:21
  • I can't answer your assembly question but I can say that you can name the kernel whatever you like as long as you also put the name in config.txt. However naming it kernel8.img will result it in being loaded and expected as a 64 bit kernel. – John Hawthorne Mar 22 '18 at 15:24
  • And why assembler? C/C++ is too complex? – SBF Mar 22 '18 at 17:38
0

What I was trying is basically debug an assembly code so I needed to know when does the code stop compilation which will be possible if I point it out with an external led using a gpio pin. I fixed my code and now its working correctly.

.section ".text.boot"

.global _start

_start:
    ldr X0,=0x3F200000 
    mov W1,#1
    lsl W1,W1,#12
    str W1,[X0,#4]
    mov W1,#1
    lsl W1,W1,#14
    str W1,[X0,#28]
1:  wfe
    b       1b

I simply set the 3 bits that control pin 14 to 001 which are bit 12,13 and 14 and then enabled pin 14 by putting 1 in it and after that I just sent on which is 28 + the base address, (I looked up the manual for that). Hope that helps

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.