Graig99
Posts: 12
Joined: Mon Sep 10, 2012 5:59 pm

Re: Baking Pi

Mon Sep 10, 2012 9:52 pm

Which make produces:
/usr/bin/make
make clean && make produces:
rm -f build/*.o
rm -f build/output.elf
rm -f kernel.img
rm -f kernel.list
rm -f kernel.map
arm-none-eabi-as -I source/ source/drawing.s -o build/drawing.o
make: arm-none-eabi-as: No such file or directory
make: *** [build/drawing.o] Error 1
I have been using the example operating system on the downloads page (Example 01), but I've just tried it with the solution to the first lesson and I get the same result. But I assume neither the lesson nor the example OS would compile if there is an error when I run "arm-none-eabi-gcc --version"? From my limited understanding, the error i receive when running that command indicates the toolchain hasn't installed correctly, is that correct?

User avatar
mister_wavey
Posts: 98
Joined: Sun Sep 02, 2012 8:23 am
Location: Abergavenny, Wales, UK
Contact: Website

Re: Baking Pi

Mon Sep 10, 2012 10:10 pm

your conclusions appear to be correct. What is inside your yagarto installation? Does the PATH match the directory structure in there?

ls -l ~/yagarto

Graig99
Posts: 12
Joined: Mon Sep 10, 2012 5:59 pm

Re: Baking Pi

Mon Sep 10, 2012 10:24 pm

By PATH, do you mean the path specified in the bash file?

Running "ls -l ~/yagarto" yields:
total 0
drwxr-xr-x 23 cwilde99 staff 782 10 Sep 21:53 yagarto-4.7.1
drwxr-xr-x 3 cwilde99 staff 102 29 Feb 2008 yagarto-4.7.1.app
and running "ls -l ~/yagarto/yagarto-4.7.1" yields:
total 368
[email protected] 1 cwilde99 staff 0 10 Sep 21:53 Binutils.webloc
-rw-r--r-- 1 cwilde99 staff 18002 16 Jun 10:16 COPYING
-rw-r--r-- 1 cwilde99 staff 25291 16 Jun 10:16 COPYING.LIB
-rw-r--r-- 1 cwilde99 staff 15251 16 Jun 10:16 COPYING.LIBGLOSS
-rw-r--r-- 1 cwilde99 staff 42144 16 Jun 10:16 COPYING.NEWLIB
-rw-r--r-- 1 cwilde99 staff 35147 16 Jun 10:16 COPYING3
-rw-r--r-- 1 cwilde99 staff 7639 16 Jun 10:16 COPYING3.LIB
[email protected] 1 cwilde99 staff 0 10 Sep 21:53 GCC.webloc
[email protected] 1 cwilde99 staff 0 10 Sep 21:53 GDB.webloc
[email protected] 1 cwilde99 staff 0 10 Sep 21:53 GNU.webloc
[email protected] 1 cwilde99 staff 0 10 Sep 21:53 Newlib.webloc
[email protected] 1 cwilde99 staff 0 10 Sep 21:53 YAGARTO.webloc
drwxr-xr-x 6 cwilde99 staff 204 16 Jun 09:54 arm-none-eabi
drwxr-xr-x 30 cwilde99 staff 1020 16 Jun 10:10 bin
drwxr-xr-x 3 cwilde99 staff 102 16 Jun 10:10 include
drwxr-xr-x 5 cwilde99 staff 170 16 Jun 10:10 lib
drwxr-xr-x 3 cwilde99 staff 102 16 Jun 09:49 libexec
drwxr-xr-x 6 cwilde99 staff 204 16 Jun 10:10 share
-rw-r--r-- 1 cwilde99 staff 86 16 Jun 10:16 source.txt
drwxr-xr-x 4 cwilde99 staff 136 16 Jun 10:16 tools
-rw-r--r-- 1 cwilde99 staff 124 16 Jun 10:16 version.txt
and attached is the directory that yagarto is placed in.

My bash file path appears as such:
export PATH="$PATH:$HOME/yagarto/yagarto-4.7.1/bin"
export PATH="$PATH:$HOME/yagarto/yagarto-4.7.1/tools"
Is this correct so far?

Graig99
Posts: 12
Joined: Mon Sep 10, 2012 5:59 pm

Re: Baking Pi

Mon Sep 10, 2012 10:31 pm

Screenshot.
Attachments
Screen Shot 2012-09-10 at 23.26.48.png
Screen Shot 2012-09-10 at 23.26.48.png (60.65 KiB) Viewed 4129 times

User avatar
mister_wavey
Posts: 98
Joined: Sun Sep 02, 2012 8:23 am
Location: Abergavenny, Wales, UK
Contact: Website

Re: Baking Pi

Mon Sep 10, 2012 10:36 pm

looks fine to me. Most odd. what happens if you type the name of the file directly? ie

Code: Select all

yagarto/yagarto-4.7.1/bin/arm-none-eabi-as
from your home directory?

also, type

Code: Select all

file yagarto/yagarto-4.7.1/bin/arm-none-eabi-as
from your home directory. That should tell us what the OS thinks the file type is.

can you

Code: Select all

 echo $PATH
again? I'd love to get hold of your keyboard and see what the problem is.

Graig99
Posts: 12
Joined: Mon Sep 10, 2012 5:59 pm

Re: Baking Pi

Mon Sep 10, 2012 10:58 pm

I'd be pretty happy for you to take a look too!

When I run "yagarto/yagarto-4.7.1/bin/arm-none-eabi-as" nothing much really happens, except a file called a.out appears in my home folder (see attached).

When I run "file yagarto/yagarto-4.7.1/bin/arm-none-eabi-as" i get:
yagarto/yagarto-4.7.1/bin/arm-none-eabi-as: Mach-O 64-bit executable x86_64
And "echo $PATH" returns:
:/Users/cwilde99/yagarto/yagarto-4.7.1/tools:/usr/X11/bin:/Users/cwilde99/yagarto/yagarto-4.7.1/bin
Attachments
Screen Shot 2012-09-10 at 23.52.59.png
Screen Shot 2012-09-10 at 23.52.59.png (30.84 KiB) Viewed 4125 times

User avatar
mister_wavey
Posts: 98
Joined: Sun Sep 02, 2012 8:23 am
Location: Abergavenny, Wales, UK
Contact: Website

Re: Baking Pi

Mon Sep 10, 2012 11:06 pm

yet with that PATH and that directory layout, you can't type arm-none-eabi-as from your home directory? weirdness. I'm bailing for the night. Happy to help more tomorrow. If you solve it, do please summarise :)

Graig99
Posts: 12
Joined: Mon Sep 10, 2012 5:59 pm

Re: Baking Pi

Mon Sep 10, 2012 11:12 pm

Seriously weird! I really really appreciate the help, I'll keep fiddling to see what I can find!

Cheers for the help! :)

martk20
Posts: 36
Joined: Fri Jan 27, 2012 10:42 am

Re: Baking Pi

Wed Sep 12, 2012 3:09 pm

mister_wavey wrote:yet with that PATH and that directory layout, you can't type arm-none-eabi-as from your home directory? weirdness. I'm bailing for the night. Happy to help more tomorrow. If you solve it, do please summarise :)
Hello it's martk20 again Going back to last week. I have only just got back onto my pi again. I have got lesson 1 working ok. Struggling with lesson 2. The code I wrote matched the answer almost exactly. I have used both my kernel.img and one compiled from the answer. Both give the same result. The ok led flashes a couple of times then goes off and I get the coloured screen as if the pi is starting up.
I am using raspbian wheezy as my base system. In the boot partition there are 2 other files which appear to be img files. Could these be causing the problem?. Any help would be most welcome.

User avatar
mister_wavey
Posts: 98
Joined: Sun Sep 02, 2012 8:23 am
Location: Abergavenny, Wales, UK
Contact: Website

Re: Baking Pi

Wed Sep 12, 2012 3:35 pm

So your toolchain works now? Great.

I just recompiled the model answer for lesson 2 and booted the pi with it. The screen does show the normal coloured pattern, but the OK LED flashes about twice a second in a loop forever.

If you're not seeing this, it could be that you aren't copying the kernel.img to the sd card correctly.

How are you doing the copying?

Can you also do an 'ls -la' on the root of the sdcard to see if there are other files present? I seem to remember something about .Trash from mac causing problems for some.

martk20
Posts: 36
Joined: Fri Jan 27, 2012 10:42 am

Re: Baking Pi

Wed Sep 12, 2012 7:19 pm

mister_wavey wrote:So your toolchain works now? Great.

I just recompiled the model answer for lesson 2 and booted the pi with it. The screen does show the normal coloured pattern, but the OK LED flashes about twice a second in a loop forever.

If you're not seeing this, it could be that you aren't copying the kernel.img to the sd card correctly.

How are you doing the copying?

Can you also do an 'ls -la' on the root of the sdcard to see if there are other files present? I seem to remember something about .Trash from mac causing problems for some.
Thanks for your prompt reply. I use cp /path to kernel.img /media/A1.... (mmcblk0p2) to copy the kernel.img. It comes form my server across a wifi network to a small laptop with an sd card slot.
The output from ls-la on my sd card boot partition is as follows:-
linux-jys7:/media/A1B1-918F # ls -la
total 36584
drwx------ 2 martin users 16384 Jan 1 1970 .
drwxr-xr-x 4 root root 80 Sep 12 19:50 ..
-rw-r--r-- 1 martin users 2458128 Aug 13 22:38 arm128_start.elf
-rw-r--r-- 1 martin users 2458128 Aug 13 22:38 arm192_start.elf
-rw-r--r-- 1 martin users 2458128 Aug 13 22:38 arm224_start.elf
-rw-r--r-- 1 martin users 631184 Aug 13 22:38 arm240_start.elf
-rw-r--r-- 1 martin users 16536 Aug 13 22:38 bootcode.bin
-rw-r--r-- 1 martin users 142 Aug 16 02:22 cmdline.txt
-rw-r--r-- 1 martin users 1180 Aug 16 02:22 config.txt
-rw-r--r-- 1 martin users 137 Aug 16 03:02 issue.txt
-rw-r--r-- 1 martin users 4115364 Aug 13 22:38 kernel_cutdown.img
-rw-r--r-- 1 martin users 16256148 Aug 13 22:38 kernel_emergency.img
-rw-r--r-- 1 martin users 6231036 Aug 13 22:38 kernel.img
-rw-r--r-- 1 martin users 275235 Aug 13 22:38 loader.bin
-rw-r--r-- 1 martin users 2458128 Aug 13 22:38 start.elf
linux-jys7:/media/A1B1-918F #
This is before I inserted the new kernel file
There are 3 kernel image files. I am not sure what to do with the other 2

User avatar
mister_wavey
Posts: 98
Joined: Sun Sep 02, 2012 8:23 am
Location: Abergavenny, Wales, UK
Contact: Website

Re: Baking Pi

Wed Sep 12, 2012 7:36 pm

only kernel.img is loaded by default unless you edit the config.txt to name another kernel file.

But your problem is the size of the kernel.img - look at the size of the kernel in my ok02 build directory:

Code: Select all

[email protected]:~/downloads/ok02$ ls -l
total 32
drwxr-xr-x 2 stuart stuart 4096 Sep 12 16:30 build
-rwxr-xr-x 1 stuart stuart   72 Sep 12 16:30 kernel.img
-rwxr-xr-x 1 stuart stuart  778 Jul  4 17:50 kernel.ld
-rw-r--r-- 1 stuart stuart  799 Sep 12 16:30 kernel.list
-rw-r--r-- 1 stuart stuart 1036 Sep 12 16:30 kernel.map
-rwxr-xr-x 1 stuart stuart 1077 Aug 31 09:41 LICENSE
-rwxr-xr-x 1 stuart stuart 1756 Jul  4 17:49 makefile
drwxr-xr-x 2 stuart stuart 4096 Sep 12 16:30 source
[email protected]:~/downloads/ok02$ 
yours is 6 MB. Check your ok02's build directory kernel.img size and work forwards from there.

User avatar
mister_wavey
Posts: 98
Joined: Sun Sep 02, 2012 8:23 am
Location: Abergavenny, Wales, UK
Contact: Website

Re: Baking Pi

Wed Sep 12, 2012 7:39 pm

oh, just read 'this is before I inserted the new kernel'. What size does it show now?

martk20
Posts: 36
Joined: Fri Jan 27, 2012 10:42 am

Re: Baking Pi

Thu Sep 13, 2012 10:19 am

mister_wavey wrote:oh, just read 'this is before I inserted the new kernel'. What size does it show now?
Sorry I was so long in replying. Lots of things on at the moment. Your last reply prompted to me to do some checking and I notice that the new kernel.img file has zero bytes, an empty file. So it looks as if my compiling still is not working correctly.

martk20
Posts: 36
Joined: Fri Jan 27, 2012 10:42 am

Re: Baking Pi

Thu Sep 13, 2012 10:35 am

martk20 wrote:
mister_wavey wrote:oh, just read 'this is before I inserted the new kernel'. What size does it show now?
Sorry I was so long in replying. Lots of things on at the moment. Your last reply prompted to me to do some checking and I notice that the new kernel.img file has zero bytes, an empty file. So it looks as if my compiling still is not working correctly.
Just done some more checking. If I type make with no main.s file in Source. I get the same output. A kernel.img with no contents. It does not seem to be seeing my main.s file (or the one copied from the solution). Again I am at a loss for a solution.

User avatar
mister_wavey
Posts: 98
Joined: Sun Sep 02, 2012 8:23 am
Location: Abergavenny, Wales, UK
Contact: Website

Re: Baking Pi

Thu Sep 13, 2012 12:30 pm

start with echo $PATH again and paste the output of make -d

inder
Posts: 23
Joined: Wed Aug 22, 2012 7:44 pm

Re: Baking Pi

Thu Sep 13, 2012 3:13 pm

Totally stumped as to what I'm doing wrong; must be something really simple. I created all the needed directories and placed the files (e-mailed them to myself) in proper spots in a top directory called template in my win7 (enterprise) machine. When I run make, I get "No targets specified and no makefile found, Stop.". The makefile is there and seems ok when opened in notepad. Any suggestions welcome.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: Baking Pi

Thu Sep 13, 2012 3:19 pm

inder wrote:Totally stumped as to what I'm doing wrong; must be something really simple. I created all the needed directories and placed the files (e-mailed them to myself) in proper spots in a top directory called template in my win7 (enterprise) machine. When I run make, I get "No targets specified and no makefile found, Stop.". The makefile is there and seems ok when opened in notepad. Any suggestions welcome.
Has your makefile managed to get itself called 'makefile.txt', by any chance?

inder
Posts: 23
Joined: Wed Aug 22, 2012 7:44 pm

Re: Baking Pi

Thu Sep 13, 2012 3:28 pm

Thanks for quick reply. No dir command says makefile only with no extensions. I just carefully made sure that main.s didn't get an extra .txt either.

martk20
Posts: 36
Joined: Fri Jan 27, 2012 10:42 am

Re: Baking Pi

Thu Sep 13, 2012 3:42 pm

mister_wavey wrote:start with echo $PATH again and paste the output of make -d
I think I have found the problem my source directory was Source. The makefile was looking for source.

User avatar
mister_wavey
Posts: 98
Joined: Sun Sep 02, 2012 8:23 am
Location: Abergavenny, Wales, UK
Contact: Website

Re: Baking Pi

Thu Sep 13, 2012 3:46 pm

does the windows yagarto installer provide gnu make? type make -v to see what you're running - also check it is first in your path in case there's another make installed on your machine which expects a different setup. Show us a directory listing too, in case there's something you're missing.

inder
Posts: 23
Joined: Wed Aug 22, 2012 7:44 pm

Re: Baking Pi

Thu Sep 13, 2012 7:38 pm

Thanks mister_wavey. Solved the problem; tried one last thing, copied my template directory to my administrator directory and no error messages! Don't know why it wouldn't work before as I was logged in as admin all the time.

stevendodd
Posts: 14
Joined: Sun Jun 10, 2012 3:11 pm

Re: Baking Pi

Thu Sep 20, 2012 4:53 pm

You could just change the start offset to 0x8000 etc and it will run fine.
What do you mean by this please, I am having the same issue and I would like to understand why the tutorial is now broken. From what I can tell the author of the course already does start at that address?

Also this is the same as all the other lessons which seem to still work and so I am perplexed :?:

The course kernel.ld looks like this:

Code: Select all

/******************************************************************************
*	kernel.ld
*	 by Alex Chadwick
*
*	A linker script for generation of raspberry pi kernel images.
******************************************************************************/

SECTIONS {
	/*
	* First and formost we need the .init section, containing the IVT.
	*/
	.init 0x0000 : {
		*(.init)
	}
	
	/* 
	* We allow room for the ATAGs and the stack and then start our code at
	* 0x8000.
	*/
	.text 0x8000 : {
		*(.text)
	}
	
	/* 
	* Next we put the data.
	*/
	.data : {
		*(.data)
	}

	/*
	* Finally comes everything else. A fun trick here is to put all other 
	* sections into this section, which will be discarded by default.
	*/
	/DISCARD/ : {
		*(*)
	}
}
and the main.s file like this:

Code: Select all

.section .init
.globl _start
_start:

b main

.section .text
main:
mov sp,#0x8000

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: Baking Pi

Thu Sep 20, 2012 6:12 pm

stevendodd wrote:
You could just change the start offset to 0x8000 etc and it will run fine.
What do you mean by this please, I am having the same issue and I would like to understand why the tutorial is now broken. From what I can tell the author of the course already does start at that address?

Also this is the same as all the other lessons which seem to still work and so I am perplexed :?:

The course kernel.ld looks like this:

Code: Select all

/******************************************************************************
*	kernel.ld
*	 by Alex Chadwick
*
*	A linker script for generation of raspberry pi kernel images.
******************************************************************************/

SECTIONS {
	/*
	* First and formost we need the .init section, containing the IVT.
	*/
	.init 0x0000 : {
		*(.init)
	}
	
	/* 
	* We allow room for the ATAGs and the stack and then start our code at
	* 0x8000.
	*/
	.text 0x8000 : {
		*(.text)
	}
	
	/* 
	* Next we put the data.
	*/
	.data : {
		*(.data)
	}

	/*
	* Finally comes everything else. A fun trick here is to put all other 
	* sections into this section, which will be discarded by default.
	*/
	/DISCARD/ : {
		*(*)
	}
}
and the main.s file like this:

Code: Select all

.section .init
.globl _start
_start:

b main

.section .text
main:
mov sp,#0x8000
To understand whats going on, you need understand absolute address and relative address.

absolute address:
Effective PC address = address

relative address:
Effective PC address = next instruction address + offset, offset may be negative

So if the code users relative address the code will run fine, as it just a offset from the next instruction
jmp 8 bytes from here.

But if its absolute address eg: jump 0x8010
But instead of the kernel been loaded to offset zero
See
/*
* First and formost we need the .init section, containing the IVT.
*/
.init 0x0000 : {
*(.init)
}
Its loaded to 0x8000
Which the latest boot loaders do, then everything will be in the wrong place.

This is more likely to effect calls or read/writes to memory.
The code is made to be loaded at offset zero with a jump to 0x8000, that means it as a jump address instruction and 0x8000 - jump instruction of zeros, then the code.

May try this;

Code: Select all

/******************************************************************************
*   kernel.ld
*    by Alex Chadwick
*
*   A linker script for generation of raspberry pi kernel images.
******************************************************************************/

SECTIONS {
   /*
   * First and formost we need the .init section, containing the IVT.
   */
   .init 0x8000 : {
      *(.init)
   }
   
   /*
   * We allow room for the ATAGs and the stack and then start our code at
   * 0x8000.
   */
   .text 0x8080 : {
      *(.text)
   }
   
   /*
   * Next we put the data.
   */
   .data : {
      *(.data)
   }

   /*
   * Finally comes everything else. A fun trick here is to put all other
   * sections into this section, which will be discarded by default.
   */
   /DISCARD/ : {
      *(*)
   }
}
See if that works
But note, i use a different assembler.
Batteries not included, Some assembly required.

hcother
Posts: 1
Joined: Thu Sep 20, 2012 7:04 pm

Re: Baking Pi

Thu Sep 20, 2012 7:22 pm

I read a few posts about black screens for the screen lessons. I am experiencing the same issue. I am using the composite video out... maybe that is the problem? I will try and check the manual though I'm not quite expert at hardware-level stuff. I changed the LED on/off stuff in screen01 slightly so that I turn the LED off first and then turn it on only at the end of the render$ loop. The LED stayed off so I assume that I'm waiting on that initialization. I added the kernel_old=1 and that didn't solve the problem. I tried HDMI and that worked fine so I am guessing it's a problem with using composite video.

Thanks for the great tutorial!

Return to “Bare metal, Assembly language”