User avatar
flypie
Posts: 5
Joined: Wed Jan 15, 2014 11:07 pm
Location: Liverpool
Contact: Website

Blinker07

Wed Jan 15, 2014 11:18 pm

Hi,

I just been working through dwelch67 examples working through the Blinker examples all is fine till I get to Blinker07 which fails to work. I changed the initial LED state to on, in notmain. So the LED comes on the goes off and never restarts.

Are their any known probleme with this code compiler version.
John

dwelch67
Posts: 967
Joined: Sat May 26, 2012 5:32 pm

Re: Blinker07

Sat Jan 18, 2014 4:49 am

Grabbed the most current bootcode.bin, start.elf, built blinker07.bin copied it to kernel.img on the sd card, cleanly unmounted. blinks just fine.

Are you able to build the other examples?

User avatar
flypie
Posts: 5
Joined: Wed Jan 15, 2014 11:07 pm
Location: Liverpool
Contact: Website

Re: Blinker07

Sun Jan 19, 2014 10:14 pm

Thanks for the reply.

I've just done several rebuilds gone back to the original, got the latest from firmware and still the same. Everything up to Blinker 06 works.
I did rewrite the code just in case the initial installation of the interrupt table was going wrong then the first sections worked but as soon as it had to rely on the interrupts, nothing.
I traced through running a version on QEMU and it seemed to be working fine, just not on the hardware. I've attached a gz of build to see if it works. If you get the chance could you send me you working copy?
I'm about to try again starting minibian as the start image.
Attachments
blinker07.tar.gz
(7.08 KiB) Downloaded 122 times
John

User avatar
flypie
Posts: 5
Joined: Wed Jan 15, 2014 11:07 pm
Location: Liverpool
Contact: Website

Re: Blinker07

Sun Jan 19, 2014 11:02 pm

It turns out the problem is that I am an idiot. I was using the ELF file not the bin, I just swapped to the BIN and all is fine. I assume that in loading the ELF some extra code has been loaded or perhaps more likely the processor mode is being changed.
John

dwelch67
Posts: 967
Joined: Sat May 26, 2012 5:32 pm

Re: Blinker07

Tue Jan 21, 2014 4:26 am

elf, exe, coff, hex, srec, etc. Pretty much most of the "binary" formats include the machine code/binary plus other stuff often a header. They work fine on top of operating systems because the operating system wants to see that header or formatting and use it to know how to load and run the program. But the gpu on the raspi doesnt, it wants raw instructions and data and is going to execute starting with those first bytes. (which are "elf" or something like that in an elf file).

the objcopy -O binary pulls the loadable portions out of the elf and at least attempts to create a binary that you can just execute (it is easy to break this for example link with a few things loaded at 0x00000000 and a few bytes loaded at 0xF0000000 and objcopy will have to create a 0xF0000000+a few byte file, that is almost a 4 gig file, technically with as little as 2 real bytes. I always save the objcopy until after I have an elf, have disassembled the elf (objdump -D) and can verify things are where I want them so that it does not create huge files and chew up my hard disk.

I probably should have but hesitated to have the makefile create a kernel.img as the final step some of those directories I wanted to have multiple .bin variations on the build from the same sources (arm, thumb, gcc, llvm, different optimization levels, etc).

Good to see you have it working, enjoy
David (dwelch67)

User avatar
flypie
Posts: 5
Joined: Wed Jan 15, 2014 11:07 pm
Location: Liverpool
Contact: Website

Re: Blinker07

Tue Jan 21, 2014 6:19 pm

The first 6 of your apps worked fine with the ELF.
John

User avatar
flypie
Posts: 5
Joined: Wed Jan 15, 2014 11:07 pm
Location: Liverpool
Contact: Website

Re: Blinker07

Fri Jan 31, 2014 7:02 pm

What is proving interesting is that if using the QEMU (https://github.com/Torlus/qemu-rpi) it only works with the ELF.
John

Return to “Bare metal, Assembly language”