3

I would like to comprehend lesson 2 of Baking Pi, but I am not able to get the LED blinking.

I am using Windows and have installed Cygwin and the ARM tool chain. As explained in the requirements, I have downloaded the latest Raspbian, which works fine. I was able to use the serial cable with Putty to login and to do a apt-get update && apt-get dist-upgrade.

Now I downloaded the lesson 2 code and compiled it, which works also fine.

~/Downloads/ok02$ make
arm-none-eabi-as -I source/ source/main.s -o build/main.o
arm-none-eabi-ld --no-undefined build/main.o -Map kernel.map -o build/output.elf -T kernel.ld
arm-none-eabi-objcopy build/output.elf -O binary kernel.img
arm-none-eabi-objdump -d build/output.elf > kernel.list

I have renamed the original kernel and copied the new kernel.img file to the SD card.

~/Downloads/ok02$ ls -l /cygdrive/l
total 9856
-rw-r--r-- 1 Sascha None   18974 Sep 25  2013 LICENSE.oracle
-rw-r--r-- 1 Sascha None   17840 Sep  8 21:24 bootcode.bin
-rw-r--r-- 1 Sascha None     120 Sep  8 22:26 cmdline.txt
-rw-r--r-- 1 Sascha None     265 Dec 24 11:00 config.txt
-rw-r--r-- 1 Sascha None    6115 Sep  8 21:24 fixup.dat
-rw-r--r-- 1 Sascha None    2324 Sep  8 21:24 fixup_cd.dat
-rw-r--r-- 1 Sascha None    9166 Sep  8 21:24 fixup_x.dat
-rw-r--r-- 1 Sascha None     137 Sep  9 10:10 issue.txt
-rw-r--r-- 1 Sascha None      72 Dec 24 11:02 kernel.img
-rw-r--r-- 1 Sascha None 3232856 Sep  8 21:24 kernel.img.orig
-rw-r--r-- 1 Sascha None 2615064 Sep  8 21:24 start.elf
-rw-r--r-- 1 Sascha None  533080 Sep  8 21:24 start_cd.elf
-rw-r--r-- 1 Sascha None 3572200 Sep  8 21:24 start_x.elf

But when I boot the modified SD card nothing starts blinking. And I have no idea why. I tried already kernel_old in config.txt but this does not have any effect and I do not think that this is necessary, because the listing shows that the code starts at 0x8000.

While comparing the listing with the hex dump of the kernel.img file I can see a difference in the endianness. The listing starts with e59f003c.

~/Downloads/ok02$ cat kernel.list

build/output.elf:     file format elf32-littlearm


Disassembly of section .init:

00008000 :
    8000:       e59f003c        ldr     r0, [pc, #60]   ; 8044 
    8004:       e3a01001        mov     r1, #1
    8008:       e1a01901        lsl     r1, r1, #18
    800c:       e5801004        str     r1, [r0, #4]
    8010:       e3a01001        mov     r1, #1
    8014:       e1a01801        lsl     r1, r1, #16

00008018 :
    8018:       e5801028        str     r1, [r0, #40]   ; 0x28
    801c:       e3a0283f        mov     r2, #4128768    ; 0x3f0000

00008020 :
    8020:       e2422001        sub     r2, r2, #1
    8024:       e3520000        cmp     r2, #0
    8028:       1afffffc        bne     8020 
    802c:       e580101c        str     r1, [r0, #28]
    8030:       e3a0283f        mov     r2, #4128768    ; 0x3f0000

00008034 :
    8034:       e2422001        sub     r2, r2, #1
    8038:       e3520000        cmp     r2, #0
    803c:       1afffffc        bne     8034 
    8040:       eafffff4        b       8018 
    8044:       20200000        .word   0x20200000

But the hex dump starts with 003ce59f.

~/Downloads/ok02$ hexdump -x kernel.img
0000000    003c    e59f    1001    e3a0    1901    e1a0    1004    e580
0000010    1001    e3a0    1801    e1a0    1028    e580    283f    e3a0
0000020    2001    e242    0000    e352    fffc    1aff    101c    e580
0000030    283f    e3a0    2001    e242    0000    e352    fffc    1aff
0000040    fff4    eaff    0000    2020
0000048

Is this correct or wrong?

And if it is correct, what else could be the reason why the code from lesson 2 does not work?

1 Answer 1

8

The root problem is that the activity LED moved from being attached to gpio 16 to being attached to gpio 47 on the B+. You need to update the code to reflect that change.

There are a number of changes you need to make. It is more than just changing 16 to 47. Gpio 47 is controlled by different registers.

See this thread on raspberrypi.org which covers the same problem,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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