arm - Raspberry Pi: Embedded Programming Exercise, Getting Started -


first, following tutorial here (http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/).

in first exercise learn addressing gpio pin responsible turning on green okay led. have rev c of raspberry pi knowledge uses broadcom (bcm2835) micro processor has following datasheet peripherals: (http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/downloads/soc-peripherals.pdf).

i have read pages 89 through 104 of data sheet still lost. program provided author not seem run cross compiler build chain provided. striping comments out of source provided author have:

.section .init .global _start _start:   ldr r0, =0x20200000    /* enable output on 16th pin */   mov r1, #1   lsl r1, #18   str r1, [r0, #4]    /* turn pin off turn led light on */   mov r1,#1   lsl r1,#16   str r1, [r0, #40]  loop$:   /* keep system running */   b loop$ 

where stuck is, in data sheet see nothing address 0x20200000. starting on page 91 in table 6-2 see tables describe first 32 bits. , in table 6-1 see register description. address of first register 0x7e200000. have tried use address in place still had no luck getting light turn on.

bottom line led light not turn on, , can learn, should go information on how debug this? secondly, missing?

if useful, here hexdump of img file dd'ing sd card.

mehoggan@mehoggan-desktop:~/devel/scripts/assembly/raspberry-pi-mini-os/example1$ make clean rm -f build/*.o  rm -f build/output.elf rm -f kernel.img rm -f kernel.list rm -f kernel.map ../arm-2008q3/bin/arm-none-eabi-as -i source/ source/main.s -o build/main.o ../arm-2008q3/bin/arm-none-eabi-ld --no-undefined build/main.o -map kernel.map -o build/output.elf -t kernel.ld ../arm-2008q3/bin/arm-none-eabi-objcopy build/output.elf -o binary kernel.img  ../arm-2008q3/bin/arm-none-eabi-objdump -d build/output.elf > kernel.list mehoggan@mehoggan-desktop:~/devel/scripts/assembly/raspberry-pi-mini-os/example1$   hexdump -c ./kernel.img  00000000  18 00 9f e5 01 10 a0 e3  01 19 a0 e1 04 10 80 e5  |................| 00000010  01 10 a0 e3 01 18 a0 e1  28 10 80 e5 fe ff ff ea  |........(.......| 00000020  00 00 20 20                                       |..  | 

edit
here .list file

00000000 <_start>:    0:   e59f0018    ldr r0, [pc, #24]   ; 20 <loop$+0x4>    4:   e3a01001    mov r1, #1  ; 0x1    8:   e1a01901    lsl r1, r1, #18    c:   e5801004    str r1, [r0, #4]   10:   e3a01001    mov r1, #1  ; 0x1   14:   e1a01801    lsl r1, r1, #16   18:   e5801028    str r1, [r0, #40]  0000001c <loop$>:   1c:   eafffffe    b   1c <loop$>   20:   20200000    .word   0x20200000 

if reverse endianess of hexdump see lines .list file.

e59f0018 e3a01001 e1a01901 e5801004 e3a01001 e1a01801 e5801028 eafffffe 20200000 

from schematic (as page linked found code) gpio 16 connected status led

where stuck is, in data sheet see nothing address 0x20200000

that not true, page 6 of bcm manual:

physical addresses range 0x20000000 0x20ffffff peripherals. bus addresses peripherals set map onto peripheral bus address range starting @ 0x7e000000. peripheral advertised here @ bus address 0x7ennnnnn available @ physical address 0x20nnnnnn.

with take info example program 0x20200000 becomes 0x7e200000 gpio registers,

specifically 0x7e200004 gpfsel1

the description gpfsel1 says bit pattern 001 makes pin output, , shows bits in register gpio 16 bits 18-20 want put bit pattern 001 @ bit 18 1<<18 written 0x7e200004

40 decimal 28 hex second register of interest 0x7e200028 is gpclr0

the gpclrn description says if bit set gpio output cleared. write 1<<16 register pull output zero, turns on led

then go infinite loop nothing else happens (to/from arm).

your hex file (with update/edit) fine. files want on sd card or @ least in root diretory of first partition bootcode.bin , start.elf firmware directory of http://github.com/raspberrypi dont need/get other files there. binary file kernel.img goes on sd card. nothing else. plug in sd card, plug in raspberry pi. if doesnt work right off unplug , replug (there cache thing can happen) , should work second time. if doesnt work, repartition , re-format sd card , try again, have had happen number of times prevents sd card working in raspberry pi.

edit:

down road may run troubles linker script apparently building binary based @ address 0x0000 rather 0x8000. can put config.txt file in root directory on sd card , inside line enables legacy kernel mode or tells gpu load kernel.img address 0x0000 rather 0x8000, or modify linker script such .text (and else) starts @ 0x8000. specific ok01 example program happens position independent can run address, minimal 3 files (bootcode.bin, start.elf, kernel.img) work.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -