Loading an ELF file above 0x80000000

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
Maximus32
Posts: 40
Joined: Mon Aug 27, 2007 12:28 am
Contact:

Loading an ELF file above 0x80000000

Post by Maximus32 »

Hello, I am currently trying to get linux to run from an regular ELF loader instead of from the RTE (Runtime Environment of the PS2 Linux kit from sony). I know that all IOP functionality will not be available since that is what the RTE provides. I've already built custom kernels and am now trying to get them to boot, showing me proof of life.

The problem is that I can't seem to find a loader that is able to load an ELF file in kernel memory (above 0x80000000). I have tried a very simple example (Dreamtime's PS2DEV Tutorial #1). It works when loading at the normal address (0x00200000 - 2MiB). When I change the address to 0x80010000 (the linux default) it fails to run.

I have tried ps2link (both normal and LOADHIGH) and uLaunchELF, nothing works.

Perhaps this problem is caused by the loader not running in kernel mode, and thus not being able to write to kernel memory?
Or perhaps the memory is not mapped at that location?
JorDy
Posts: 121
Joined: Sun Dec 11, 2005 8:45 am

Post by JorDy »

just write a loader that starts in kernel mod first and copies all the data to/above the kernel then jump to the entrypoint
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

I updated my linux bootloader. Now it resets IOP, loads ps2link module and uses shared memory for printf(). RPC is not used yet. You can download it here:

http://freenet-homepage.de/ps2dev/kernelloader0.2.tgz

It includes also an example kernel which only prints some stuff. I think this is the proof you want.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Or use ps2-packer which has a kmode stub which worries about starting your app in kmode.
Maximus32
Posts: 40
Joined: Mon Aug 27, 2007 12:28 am
Contact:

Post by Maximus32 »

Wow! That's really great stuff Mega Man! Nice font by the way ;-). It loads the kernel perfectly, even tries to load initrd.gz or initrd if they exist.

I will give ps2-packer a try, but I prefer to keep the kernel and the loader separated binaries, as kernelloader from Mega Man does.
Maximus32
Posts: 40
Joined: Mon Aug 27, 2007 12:28 am
Contact:

Post by Maximus32 »

Mega Man, I am having some trouble with the kernel loader.

First I tried version 0.1 of the loader which loads the test kernel perfectly. The linux kernel however didn't want to run. I think it may have something to do with the load addr of kernelloader since it loads at 3MiB. A Linux kernel can easily overwrite that. So I tried changing the linkfile to let it load at 5MiB instead of 3. After that it didn't want to boot at all. Looking in the code I found that it was using a static address for the heap. So I changed the addr to "&_end" as specified in the linkfile. This time it booted, but again the test kernel worked, the linux kernel did not. Could be a problem with the linux kernel also, ofcourse.

I have also tried version 0.2, but that version won't even load the test kernel. Looks like you have made a lot of improvements though. So I'm trying to figure out why it won't load now.

So back to 0.1 I was playing around with the visuals a little, and added a progress bar to the file loading. I think this is very welcome for a kernel loader, since loading a kernel can take a while. Especially from mc/network. Plus it looks nice. Here is the code for it, nothing special. Perhaps an idea for version 0.3?

Code: Select all

void
setProgressBar(int perc)
{
  if(perc > 100)
    perc = 100;

  // Light grey border
  g2_set_color(192, 192, 192);
  g2_rect(20, (maxy/2)-6, maxx-20, (maxy/2)+6);
  // Black background
  g2_set_fill_color(0, 0, 0);
  g2_fill_rect(21, (maxy/2)-5, maxx-21, (maxy/2)+5);
  // Blue filling
  g2_set_fill_color(64, 64, 128);
  g2_fill_rect(21, (maxy/2)-5, (((maxx-42)*perc)/100)+21, (maxy/2)+5);
}
I also added configuration to the loader, so the only thing the loader loads is the config file. Then from that it will load all appropriate files. Not giving errors on initrd and stuff, and also being able specify the filenames (so I could use vmlinux instead of kernel.elf for instance) and so I could choose what irx files I want to load (only thing is 0.1 doesn't load IRX files). If you would like the code also I could post/send it.
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

I removed graphic support in version 0.2, because of 4 reasons:

1. The graphic functions are taken from the tutorials and I wanted something better (e.g. a graphic library).
2. I wanted to include it in existing loaders like LaunchELF.
3. My test kernel relies on special graphic setup. Test kernel should be rewritten.
4. Graphic support was for debugging only. I found a better way to debug it using printf and ps2link.

The code is not yet finished and I currently thinking about what is the best strategy (standalone or included in some other loader).

Version 0.2 don't prints anything on the screen, everything is printed out using ps2link.

When you mean with heap my mempool, then I think it is a good idea to use &_end instead of static address.

Did you install my linux patch included in kernelloader archive?
I needed to patch the exception handler of linux, because the first exception raised must be ignored. I don't know the reason for this exception. Previously I thought this was caused by graphic setup, but it can also caused by a DMA still running or a misinterpreted IRQ. I deactivated the timer interrupts, but this doesn't help.
The exception is raised before graphic setup, so you can't see this exception on the screen. But when you use version 0.2 with ps2link and install my linux patches, you can see the whole start process.
Can you please post the messages printed over ps2link?

Note: I have a PAL console and I never tested it on NTSC.
Maximus32
Posts: 40
Joined: Mon Aug 27, 2007 12:28 am
Contact:

Post by Maximus32 »

When I first tried version 0.2 of the loader I had an old version of ps2link. It didn't work but I could see all the irx files, bsios and kernel being loaded. After that, nothing happened
So I thought maybe with a new ps2link it could work, so I compiled the latest ps2link (1.51) in both high and low version (looking at the linkfiles I should be able to use them both, but you never know). Now when I try it, nothing happens at all:

Code: Select all

playstation@ps2dev:~/development/linux/kernelloader$ make test
make -C loader test
make[1]: Entering directory `/home/playstation/development/linux/kernelloader/loader'
for file in ioptrap.irx iomanX.irx ps2dev9.irx ps2ip.irx ps2smap.irx poweroff.irx ps2link.irx; do cp /usr/local/ps2dev/ps2sdk/iop/irx/$file .; done
ps2client -h 192.168.1.10 execee host:loader.elf
It just does nothing at all. You may notice the other ip addr, I've changed it in both the Makefile and loader.c, but it never gets to loading ps2smap.irx so it really shouldn't matter. I am also using a PAL console so that shouldn't be the problem then. What version of ps2link are you using to run the loader from?

Using version 0.1 of the loader does work with this version of ps2link. I can see the kernel being loaded. I installed the patch from 0.1 but nothing shows up here either. So I included a simple demo inside the kernel just to see if it runs... and it worked! So the kernel is already running using 0.1 but I don't see any debugging yet. Looking at the patch I see most of it involves initrd... and I don't have an initrd... Is this required for to see anything at all?

EDIT: I now tried ps2link versions 1.22, 1.24 and 1.46 from ps2dev, none of them load version 0.2. I don't even get the message "Started loader", which looking at the code should be the first message. I'm using the latest ps2dev source and gcc version 3.2.2 from ps2dev.

EDIT2: Results at last! In a desperate action I tried loading it from windows using InLink and it worked!!! I used the exact same files I used before. So what is the difference between InLink and ps2client? Why doesn't ps2client load the files? I will start looking at it right away.

Code: Select all

[NET] : Executing host:C:\Documents and Settings\...\kernelloader\loader.elf ...
Setting Curent Directory to C:\Documents and Settings\...\kernelloader\.
Executing Elf host:C:\Documents and Settings\...\kernelloader\loader.elf...
loadelf: fname host:C:\Documents and Settings\...\kernelloader\loader.elf secname all
loadelf version 3.30
Input ELF format filename = host:C:\Documents and Settings\...\kernelloader\loader.elf
0 00500000 0000948c .
Loaded, host:C:\Documents and Settings\...\kernelloader\loader.elf
start address 0x5000e0
gp address 00000000
Started loader
Load kernel......
Stack 0x01ffed10
open name host:sbios.elf flag 1 data 44278
open fd = 2
open name host:kernel.elf flag 1 data 44278
open fd = 2
open name host:ioptrap.irx flag 1 data 44278
open fd = 2
open name host:iomanX.irx flag 1 data 44278
open fd = 2
open name host:ps2dev9.irx flag 1 data 44278
open fd = 2
open name host:ps2ip.irx flag 1 data 44278
open fd = 2
open name host:ps2smap.irx flag 1 data 44278
open fd = 2
open name host:poweroff.irx flag 1 data 44278
open fd = 2
open name host:ps2link.irx flag 1 data 44278
open fd = 2
open name host:sharedmem.irx flag 1 data 44278
open fd = 2
open name host:initrd.gz flag 1 data 44278
[FILE] : Cannot Open initrd.gz #0
open fd = -1
Error cannot open elf file "host:initrd.gz".
open name host:initrd flag 1 data 44278
[FILE] : Cannot Open initrd #0
open fd = -1
Error cannot open elf file "host:initrd".
initrd_start 0x00000000 0x00000000
RebootGet Reboot Request From EE
Maximus32
Posts: 40
Joined: Mon Aug 27, 2007 12:28 am
Contact:

Post by Maximus32 »

Ok, so I feel a little stupid. Turns out the problem was not ps2link, ps2client or the loader, but my router. It wasn't giving my linux machine an ip address so I was working with a random address. I still don't understand why some applications did load and others didn't, but at least the problem is solved now. I was already using a static ip on windows, so that's why it worked in windows. I've now got a static ip for linux as well, so it won't happen again.

Back to the loader I got results:

Code: Select all

playstation@ps2dev:~/development/linux/kernelloader$ make test
make -C loader test
make[1]: Entering directory `/home/playstation/development/linux/kernelloader/loader'
for file in ioptrap.irx iomanX.irx ps2dev9.irx ps2ip.irx ps2smap.irx poweroff.irx ps2link.irx; do cp /usr/local/ps2dev/ps2sdk/iop/irx/$file .; done
ps2client -h 192.168.1.10 execee host:loader.elf
loadelf: fname host:loader.elf secname all
loadelf version 3.30
Input ELF format filename = host:loader.elf
0 00500000 0000948c .
Loaded, host:loader.elf
start address 0x5000e0
gp address 00000000
Started loader
Load kernel......
Stack 0x01ffed10
open name host:sbios.elf flag 1 data 44278
open fd = 2
open name host:kernel.elf flag 1 data 44278
open fd = 2
open name host:ioptrap.irx flag 1 data 44278
open fd = 2
open name host:iomanX.irx flag 1 data 44278
open fd = 2
open name host:ps2dev9.irx flag 1 data 44278
open fd = 2
open name host:ps2ip.irx flag 1 data 44278
open fd = 2
open name host:ps2smap.irx flag 1 data 44278
open fd = 2
open name host:poweroff.irx flag 1 data 44278
open fd = 2
open name host:ps2link.irx flag 1 data 44278
open fd = 2
open name host:sharedmem.irx flag 1 data 44278
open fd = 2
open name host:initrd.gz flag 1 data 44278
open fd = -1
Error cannot open elf file "host:initrd.gz".
open name host:initrd flag 1 data 44278
open fd = -1
Error cannot open elf file "host:initrd".
initrd_start 0x00000000 0x00000000
RebootGet Reboot Request From EE
I can see everything being loaded but there is no output from the kernel. I've also tried the test kernel and it looks exactly the same. Trying the kernel that worked with version 0.1 still doesn't work. Also showing the exact same output. What kernel are you using and how is it set up? I've got the default 2.4.17-mvl21 with the 2 patches and set the 2 options as mentioned in the readme.
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

My ps2client and ps2sdk version is from 1.7.2007 or the day before (svn).
My ps2link version is from 21.7.2007 (svn).

I used the setup which is described in the README file of kernelloader 0.2.

I detected that ps2link seems to ignore the ip address configuration parameter. So after iop reset and reloading, it sends information not to the ip address. Instead it sends to a broadcast address, but messages are still received by my ps2client version.

When you don't have installed the exception patch, you should see the following:

Code: Select all

ps2client -h 192.168.0.23 execee host:loader.elf
loadelf: fname host:loader.elf secname all
loadelf version 3.30
Input ELF format filename = host:loader.elf
0 00300000 0000948c .
Loaded, host:loader.elf
start address 0x3000e0
gp address 00000000
Started loader
Load kernel......
Stack 0x01ffed10
open name host:sbios.elf flag 1 data 45a78
open fd = 2
open name host:kernel.elf flag 1 data 45a78
open fd = 2
open name host:ioptrap.irx flag 1 data 45a78
open fd = 2
open name host:iomanX.irx flag 1 data 45a78
open fd = 2
open name host:ps2dev9.irx flag 1 data 45a78
open fd = 2
open name host:ps2ip.irx flag 1 data 45a78
open fd = 2
open name host:ps2smap.irx flag 1 data 45a78
open fd = 2
open name host:poweroff.irx flag 1 data 45a78
open fd = 2
open name host:ps2link.irx flag 1 data 45a78
open fd = 2
open name host:sharedmem.irx flag 1 data 45a78
open fd = 2
open name host:initrd.gz flag 1 data 45a78
open fd = -1
Error cannot open elf file "host:initrd.gz".
open name host:initrd flag 1 data 45a78
open fd = -1
Error cannot open elf file "host:initrd".
initrd_start 0x00000000 0x00000000
RebootGet Reboot Request From EE
ps2ip_ShutDown: Shutting down ps2ip-module
tty mounted
host: mounted
IOP cmd thread started
Naplink thread started
loadbuffer: id 34, ret 0
loadbuffer: addrres 79900 args 0 arg
Hello World from IOP!
sharedMem = 0x00
Started io thread
loadbuffer: id 35, ret 0
Started modules
Jump to kernel!
sbios 00000000
PlayStation 2 SIF BIOS: 0666
use boot information at 81fff000(old style)
boot option string at 803084f0: crtmode=pal
CPU revision is: 00002e31
FPU revision is: 00002e30
  Branch Prediction  : on
  Double Issue       : on
Primary instruction cache 16kb, linesize 64 bytes.
Primary data cache 8kb, linesize 64 bytes.
Number of TLB entries 48.
Linux version 2.4.17_mvl21 (jur@sheridan) (gcc version 2.95.2 19991024 (release)) #4 So Jul 22 00:12:25 CEST 2007
Determined physical RAM map:
 memory: 01fff000 @ 00000000 (usable)
On node 0 totalpages: 8191
zone(0): 8191 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: crtmode=pal
Console: colour dummy device 80x25
Delay loop... 392.39 BogoMIPS
MIPS CPU counter frequency is fixed at 294912000 Hz
Memory: 29948k/32764k available (1909k kernel code, 2816k reserved, 78k data, 68k init)
Dentry-cache hash table entries: 4096 (order: 3, 32768 bytes)
<1>Data bus error, epc == 801f3804, ra == 801f37d4
Oops in traps.c&#58;default_be_board_handler, line 468&#58;
$0 &#58; 00000000 10010c00 81ff0000 10010c00 90000008 fe3fe000 00000001 80227334
$8 &#58; 07200720 07200720 fffffff8 00000000 80217116 fffffff7 80017db4 ffffffff
$16&#58; 00000000 00000003 00001000 80410000 00000000 00000000 00000000 00000000
$24&#58; 0000000a 00000004                   80016000 80017f20 000d07e0 801f37d4
Hi &#58; 00000000
Lo &#58; 000000a0
epc  &#58; 801f3804    Not tainted
Status&#58; 10011c03
Cause &#58; 7000001c
Process swapper &#40;pid&#58; 0, stackpage=80016000&#41;
Stack&#58; 801c5ce0 00001000 00000003 00008000 8fed01b8 00000000 00000000 00000000
       00001fff 80010490 80000000 801f38f4 801c3500 000074fc 00007ffc 00000775
       00000000 00000000 80000000 80410000 00001fff 801ee778 80000000 801ee750
       801c1ce0 8021440c 80206fe4 00213fff 00000ee0 00000000 00000000 00000000
       80000000 801efae4 00000000 00000000 801c2b4c 00002e30 00000001 00000001
       800104dc ...  &#91;<80022930>&#58;&#93;
        sp&#58;80017bd0    fp&#58;000d07e0
  &#91;<80022920>&#58;&#93; called by &#91;<8001c608>&#58;&#93;
        sp&#58;80017bf0    fp&#58;000d07e0
  &#91;<8001c600>&#58;&#93; called by &#91;<8001c86c>&#58;&#93;
        sp&#58;80017c10    fp&#58;000d07e0
  &#91;<8001c838>&#58;&#93; called by &#91;<8001c93c>&#58;&#93;
        sp&#58;80017c30    fp&#58;000d07e0
  &#91;<8001c898>&#58;&#93; called by &#91;<8001c9ac>&#58;&#93;
        sp&#58;80017c50    fp&#58;000d07e0
  &#91;<8001c9c0>&#58;&#93; called by exception.
    EPC   &#58; 00000042&#58;
    RA    &#58; 0000000a&#58;
    GP    &#58; 00000000    Status&#58; 00000000
    Cause &#58; 80016000    ExcCode&#58;Int&#40;0&#41;
  &#91;<00000042>&#58;&#93;
        sp&#58;00000000    fp&#58;00000000
<1>Unable to handle kernel paging request at virtual address 000001e0, epc == 800228bc, ra == 800228c4
When you ignore this exception, linux will start and try to mount something. The initrd is not required until this point.
Last edited by Mega Man on Mon Sep 03, 2007 1:24 am, edited 1 time in total.
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

I've done a trace with ethereal and I see that the ip configuration is changed to use 192.168.0.80 as source address and 255.255.255.255 as destination address.

So parameters are wrong and need to be changed from:

Code: Select all

const char ifcfg&#91;&#93; = "192.168.0.23 255.255.255.0 192.168.0.254";
into

Code: Select all

const char ifcfg&#91;&#93; = "192.168.0.23\000255.255.255.0\000192.168.0.254";
The parameters need to be seperated by 0 instead of space.
Maximus32
Posts: 40
Joined: Mon Aug 27, 2007 12:28 am
Contact:

Post by Maximus32 »

Perhaps I am not receiving the broadcast?

I've been playing with version 0.1 in the meantime. I added support for on-screen printk by using the prints from the kernel included in version 0.1 of the loader. So currently I am seeing lots of linux messages on screen from the ps2, really cool. It gets to enabling the interrupts and then I see the message "<1>Unable to handle kernel paging request at ...", right after "Kernel command line: crtmode=pal". I don't get to see where it faults since the prints function doesn't wrap around at the end of the line. But I am really happy to see it booting so far.
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

I remember the error right after "Kernel command line: crtmode=pal". I had this before as I tried the same. The problem is that the graphical printk uses memory which is removed when system is initialized. It is installed later again. You can't print anything while graphic is initialized. When you print after it, you can't see it, because displayed memory is in a different area than your print is.
My idea this time was to print only something if an error happens (e.g. exception handler).
Maximus32
Posts: 40
Joined: Mon Aug 27, 2007 12:28 am
Contact:

Post by Maximus32 »

Still isn't working. I'm testing with the included testkernel by the way. I've tried every possible ifcfg string. Isn't the string 3*16 char long? 15 chars plus null for each part of the config? Anyways, I am beginning to get a little confused about all the parameters:
1 - addr of ps2
2 - mask
3 - default gateway? or is it the destination? pc?
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

You need to count "\000" as one char. String has same size as before change, because space is also counted as one char. Size includes the last 0 which is not seen.
13 + 14 + 14 = 41 in my example.

Third parameter is default gateway. You should use ethereal and check which ip addresses on your net.

I believe that your router throws away broadcast ip packets.

One solution is to put the ip address directly into the ps2link code by changing remote_pc_addr in "iop/net_fio.c". But I think you need to set it in network byte order (big endian), mips is little endian.

example:
IP 192.168.1.2
unsigned int remote_pc_addr = 0x0201a8c0;
Maximus32
Posts: 40
Joined: Mon Aug 27, 2007 12:28 am
Contact:

Post by Maximus32 »

WOW! I got linux running up to the point where it can't continue without a root fs. Giving me the message "<0>Kernel panic: I have no root and I want t...".
Image
Next I need to make an initrd so I can see if it really continues to boot!
Maximus32
Posts: 40
Joined: Mon Aug 27, 2007 12:28 am
Contact:

Post by Maximus32 »

Even more good news, I just enabled the ps2 frame buffer in the config and it works! I also added an initrd image. The image gets loaded so the kernel doesn't panic anymore. But when it tries to run something off the initrd it fails. I guess the initrd I am using is no good, but other than that everything seems to work fine!

Image
Maximus32
Posts: 40
Joined: Mon Aug 27, 2007 12:28 am
Contact:

Post by Maximus32 »

ok, so I have been trying to figure out the paging errors. As you mentioned it probably being the initialization of hardware before entering the kernel I ran some tests on how the RTE initializes it's registers.

I did this by copying the registers as one of the first things in the kernel boot process, and then printing them as soon as the graphics are running.

I think the results may be usefull for you as well so here they are:
http://www.bricks-os.org/shared/initial_regs2.txt
http://www.bricks-os.org/shared/REGS_RTE.JPG

The screen dump looks a little messy so I created a more readable txt file.
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

I have already checked the cop0 registers. When I look at your list, my setup is not so different, that it should lead to such errors.
By the way I noticed that sometimes my kernelloader 0.2 can't start the linux kernel on my ps2. I have seen bus errors. Often the bus errors are at places where the address register is used also as destination register, Bus errors happen very late, so I can't say what the address was that leads to an error. When I change something in linux the error jumps to a different code location.
I wanted to know what you needed to change that you get the linux kernel running.
Now I tried to disable INTC and DMA. This doesn't help. I have noticed that the tlb entry of DMA channel 5 is protected. This channel is used for RPC.
I think to debug this error I need a hardware debugger. Did anybody know if there is JTAG interface in the ps2 and where are the connections?
Maximus32
Posts: 40
Joined: Mon Aug 27, 2007 12:28 am
Contact:

Post by Maximus32 »

To get it to boot I disabled almost everything that is ps2 related in menuconfig. I think the only enabled ps2 thing is the console driver (as you can see). I also changed the page fault fix to allow only one error to be ignored because I got endless messages of page faults in the end. Other than that there is nothing special about the kernel.

As for the loader, I am still using 0.1 since I can't get 0.2 to boot my kernel. I think perhaps the changed video setup could be the problem, so I'll modify the kernel to properly initialize the video, instead of the loader. I'll post the results as soon as I've tested it.

I'm using the tx79architecture.pdf document as a reference to the ee processor. It also mentions bus error problems and possible solutions (page 54++).
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

This explains why we see strange page faults. It is caused by an bus error, which is sometimes seen. So we need to fix the bus error to get rid of the random page faults.
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

I found in tx79architecture.pdf, that the first 2 instructions of the exception handler are sometimes interpreted as nop.
So I put 2 nops at the beginning of my exception handler (entry.S in kernelloader 0.2).
Now suddenly the bus errors disapear and linux started.
This is strange, because the exception handler is never called and would stop the system.
First I was thinking that this has something to do with a not working cache flush function, but then I tested a little bit.
I detected that the second instruction must be a nop and the remaining stuff can be any garbage with any length. I mean a completely wrong exception handler using illegal assembler instructions.
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

I am able to start an unpatched linux kernel without any exceptions. Initrd is not yet tested.

Here is the new version:
http://freenet-homepage.de/ps2dev/kernelloader0.3.tgz
Maximus32
Posts: 40
Joined: Mon Aug 27, 2007 12:28 am
Contact:

Post by Maximus32 »

This is great! I just had the time to try out the new loader, and it works great! I also was able to load an unmodified kernel, initrd also started and worked!!! Prety cool to see a busybox environment running!
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

I found out that there must be a nop at address 0x80000204 before starting linux or you will see random exceptions. Now I know why. Linux installs the V_INTERRUPT handler the following way:

Code: Select all

static inline void __init set_intr_vector&#40;void *addr&#41;
&#123;
        unsigned handler = &#40;unsigned long&#41; addr;
        *&#40;volatile u32 *&#41;&#40;KSEG0+0x200&#41; = 0x08000000 |
                                         &#40;0x03ffffff & &#40;handler >> 2&#41;&#41;;
        flush_icache_range&#40;KSEG0+0x200, KSEG0 + 0x204&#41;;
&#125;
The result is that a jump is patched at address 0x80000200 and the cache is also flushed (which is required, because the instruction is in data cache, but should be in instruction cache). The problem is that mips has a branch delay and execute the command after this jump instruction also.
When the instruction changes anything then the behaviour is unpredictable and can lead to random exceptions, because interrupt timing is not always the same. My original 2. instruction was writing on the stack, which will lead to random changes of local variables.

There are 2 bugs in the linux exception handler:
1. At the beginning there must be 2 nop instructions.
2. After the jump must be a nop instruction.

Also the other exception handlers require the 2 nop instructions at the beginning.
rafael2k
Posts: 18
Joined: Sun Jan 14, 2007 2:41 am

USB not working in PS2 Slim

Post by rafael2k »

USB is not working here. (loader 1.0, test kernel from the site, PS2 Slim).

The error kernel gives me is:

usb.c: USB device not accepting new address=1 (error=-145)
usb.c: failed adding a new device. Address=1

then this message appears many times, w/ 'address' being incresed by 1, each message.
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

I've seen this message when interrupts were not working. The module "host:TGE/intrelay.irx" must be activated to get interrupts working. When you use the binary on my web site, this should be the default. When you activate ps2link in the menu, the module is deactivated, but you can reenable it and it should work.
I don't have a PS2 Slim edition. So I can't test it.
I have the following questions:
I want to know which boot method did you use?
I tested with ps2client/ps2link, LaunchELF started by mc exploit and Action Replay Media Player. The mc exploit is not working on PS2 Slim, so I believe you dont't use this.
Did your PS2 immediately reset when you press the reset button (in kernelloader)?
If it not immediately resets, then there is something loaded before, which could change the system behaviour.
Did USB work in the kernelloader (before linux is started), so you can select files from a USB memory stick?

It is also possible that you need to disconnect all USB devices before PS2 Linux is started. When system is started, you can plug in the USB devices. (I saw this effect with the RTE sbios).
rafael2k
Posts: 18
Joined: Sun Jan 14, 2007 2:41 am

usb and ps2 slim

Post by rafael2k »

Hi megaman,

First I tried w/ Action Replay Max, then the loader gets loaded, but when I try to acess my usb storage, the loader freezes.

Then I tried w/ ps2link, the loader then got loaded ok and could see the usb storage, select a kernel and initrd from the usb storage, and boot.

I did not tested the reset button inside the loader, I'll try it on sunday (when I'll be near a PS2 Slim again).

On sunday I'll do more testing, so any advise is very welcome ;)

Thanks a lot!
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

I detected that ps2link always generates reset problems. You need to enable the poweroff.irx module when kernelloader was loaded by ps2link. I think ps2link doesn't restore the exception vector. The different ps2link versions behave in a different way. I tested it with the newest version and a older version v1.46.

You should try my new kernelloader version. I've updated to new ps2sdk. You can also see IOP debug messages on screen.

http://mitglied.lycos.de/ps2dev/kernell ... loader.elf

Image
ps2devman
Posts: 259
Joined: Mon Oct 09, 2006 3:56 pm

Post by ps2devman »

Wow! Very nice!
Thanks for your amazing work!
Post Reply