xihan94
Posts: 21
Joined: Sat Jul 23, 2016 5:31 pm

Simple bare metal code on RPi 3 doesn't work

Thu Jul 28, 2016 10:20 pm

My disassembled code is as shown below. Basically, I want to turn on GPIO 16. I used a multimeter to measure voltage between GPIO(BCM) 16 and GND. It was unexpectedly 0V. What could be wrong?

Note: I made the binary using objcopy, so it was a raw binary running on the Pi.

Code: Select all

00008000 <_start>:
    8000:	e59f001c 	ldr	r0, [pc, #28]	; 8024 <hang+0x4>
    8004:	e3a01007 	mov	r1, #7
    8008:	e1a01901 	lsl	r1, r1, #18
    800c:	e5801000 	str	r1, [r0]
    8010:	e59f0010 	ldr	r0, [pc, #16]	; 8028 <hang+0x8>
    8014:	e3a01001 	mov	r1, #1
    8018:	e1a01801 	lsl	r1, r1, #16
    801c:	e5801000 	str	r1, [r0]

00008020 <hang>:
    8020:	eafffffe 	b	8020 <hang>
    8024:	3f200004 	svccc	0x00200004
    8028:	3f20001c 	svccc	0x0020001c

baantonia
Posts: 63
Joined: Fri Feb 06, 2015 2:19 pm

Re: Simple bare metal code on RPi 3 doesn't work

Thu Jul 28, 2016 11:45 pm

With a brief glance, you seem to have set GPIO 16 to mode ALT3 or CTS0 with the 'mov r1, #7' rather than an output. It probably should be 'mov r1, #1' instead setting the mode to output. GPIO 16 should be header pin 36.

xihan94
Posts: 21
Joined: Sat Jul 23, 2016 5:31 pm

Re: Simple bare metal code on RPi 3 doesn't work

Fri Jul 29, 2016 5:35 am

baantonia wrote:With a brief glance, you seem to have set GPIO 16 to mode ALT3 or CTS0 with the 'mov r1, #7' rather than an output. It probably should be 'mov r1, #1' instead setting the mode to output. GPIO 16 should be header pin 36.
Sorry, I regarded the PM button as quoting and replying. I'm new to Raspberry Pi forum, as you may have found ;). Thanks!

Return to “Bare metal, Assembly language”