Official Gitbrew Forums
These forums cover all aspects of the Gitbrew biosphere. If you would like your development project to be based here, ask an admin.

Home » PS3 » OtherOS++ » Linux » BD Drive Enable buffer write with sg_raw (BD Drive Enable buffer write with sg_raw errors)
Re: BD Drive Enable buffer write with sg_raw [message #592 is a reply to message #591] Sun, 05 February 2012 15:07 Go to previous messageGo to next message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
Update programs from my gitbrew page again. Now we don't need CD inserted at all.

http://gitbrew.org/~glevand/ps3/linux/linux-3/bd_write_buffe r.c
http://gitbrew.org/~glevand/ps3/linux/linux-3/bd_enable_buff er_write.c

I added O_NONBLOCK flasg to open syscall and now it works without CD.
First enable buffer writing then write buffer.

glevand@debian-hdd:~$ sudo ./bd_enable_buffer_write -b 4
status 0 host status 0 driver status 0
glevand@debian-hdd:~$ sudo ./bd_write_buffer -b 4 -i buffer4_orig.bin
input length 32768
status 0 host status 0 driver status 0

[Updated on: Sun, 05 February 2012 15:10]

Report message to a moderator

Re: BD Drive Enable buffer write with sg_raw [message #593 is a reply to message #592] Sun, 05 February 2012 15:16 Go to previous messageGo to next message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
But why does it write wrong data. Damn.
Re: BD Drive Enable buffer write with sg_raw [message #594 is a reply to message #593] Sun, 05 February 2012 15:35 Go to previous messageGo to next message
Mark Webber is currently offline  Mark Webber
Messages: 20
Registered: February 2012
Location: Australia
Gitbrew Noob
It must be something I have done wrong on my end.
when trying to write I get:
status 2
host status 0
driver status 8

[Updated on: Sun, 05 February 2012 15:41]

Report message to a moderator

Re: BD Drive Enable buffer write with sg_raw [message #595 is a reply to message #594] Sun, 05 February 2012 15:41 Go to previous messageGo to next message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
Is it a slim you are using ?
Re: BD Drive Enable buffer write with sg_raw [message #596 is a reply to message #595] Sun, 05 February 2012 15:43 Go to previous messageGo to next message
Mark Webber is currently offline  Mark Webber
Messages: 20
Registered: February 2012
Location: Australia
Gitbrew Noob
No, if it was a slim there would be no need for this procedure.
What I have found is all 16meg NOR models ignore all this data.
In those, the HRL on the drive is never changed, but the DRL's are updated.

Ok, really have to get to bed now, almost 1am here Cool
Another 5 hours and I will be back at it again.

Seriously though, in 24 hours you have gone way further then I could in a month Very Happy

[Updated on: Sun, 05 February 2012 15:49]

Report message to a moderator

Re: BD Drive Enable buffer write with sg_raw [message #621 is a reply to message #596] Sat, 11 February 2012 06:21 Go to previous messageGo to next message
Mark Webber is currently offline  Mark Webber
Messages: 20
Registered: February 2012
Location: Australia
Gitbrew Noob
Still no luck this end.
Are you running your new tools inside Linux, or directly from petitboot?
Re: BD Drive Enable buffer write with sg_raw [message #622 is a reply to message #621] Sat, 11 February 2012 11:11 Go to previous messageGo to next message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
Both.
Re: BD Drive Enable buffer write with sg_raw [message #623 is a reply to message #622] Sat, 11 February 2012 11:14 Go to previous messageGo to next message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
But i don't have a PHAT.
Re: BD Drive Enable buffer write with sg_raw [message #631 is a reply to message #623] Sun, 12 February 2012 12:52 Go to previous messageGo to next message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
Coded a small application to read mode sense data.
sg3-utils sucks, returns with error.

http://gitbrew.org/~glevand/ps3/linux/linux-3/bd_mode_sense. c

Page code 0x2f is used by Update Manager to read drive generation = major, minor.

glevand@debian:~$ sudo ./bd_mode_sense -p 0x2f | hexdump -C
00000000  00 0e 00 00 00 00 00 00  2f 06 07 32 00 00 00 00  |......../..2....|
00000010


major = 0x07
minor = 0x32

[Updated on: Sun, 12 February 2012 12:57]

Report message to a moderator

Re: BD Drive Enable buffer write with sg_raw [message #632 is a reply to message #631] Sun, 12 February 2012 13:00 Go to previous messageGo to next message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
Hmm, interesting.

Before enabling buffer write:

glevand@debian:~$ sudo ./bd_mode_sense -p 0x2d | hexdump -C
00000000  00 0e 00 00 00 00 00 00  2d 06 00 00 00 00 00 00  |........-.......|
00000010


Enable write to buffer 4:

glevand@debian:~$ sudo ./bd_enable_buffer_write -b 4


After enabling buffer writing:
glevand@debian:~$ sudo ./bd_mode_sense -p 0x2d | hexdump -C
00000000  00 0e 00 00 00 00 00 00  2d 06 04 00 00 00 00 00  |........-.......|
00000010

[Updated on: Sun, 12 February 2012 13:09]

Report message to a moderator

Re: BD Drive Enable buffer write with sg_raw [message #633 is a reply to message #631] Sun, 12 February 2012 13:03 Go to previous messageGo to next message
Mark Webber is currently offline  Mark Webber
Messages: 20
Registered: February 2012
Location: Australia
Gitbrew Noob
That looks like part of the original cmd that started all of this.

sg_raw /dev/sr0 55 10 00 00 00 00 00 00 10 00 00 0e 00 00 00 00 00 00 2d 06 04 00 00 00 00 00

I wonder if the incorrect gen ID between Grafs and mine is the cause of the problem?
Could it really be that simple, of course not, but it is a nice thought.

Well done again Glevand.
Re: BD Drive Enable buffer write with sg_raw [message #634 is a reply to message #632] Sun, 12 February 2012 13:04 Go to previous messageGo to next message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
Another interesting thing is that UM disables request sense with a vendor specific SCSI command before writing data to buffer.
Re: BD Drive Enable buffer write with sg_raw [message #635 is a reply to message #634] Sun, 12 February 2012 13:39 Go to previous messageGo to next message
Mark Webber is currently offline  Mark Webber
Messages: 20
Registered: February 2012
Location: Australia
Gitbrew Noob
From my PS3 I never get a change in numbers.
It stays at "2d 06 01" before and after enabling mode 10.
Re: BD Drive Enable buffer write with sg_raw [message #636 is a reply to message #635] Sun, 12 February 2012 13:42 Go to previous messageGo to next message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
Hmm, that would explain why you cannot write to the buffer.
Re: BD Drive Enable buffer write with sg_raw [message #637 is a reply to message #636] Sun, 12 February 2012 13:55 Go to previous messageGo to next message
Mark Webber is currently offline  Mark Webber
Messages: 20
Registered: February 2012
Location: Australia
Gitbrew Noob
I am attaching a copy of one of the full MX dumps.
Drive is a BMD-002 from memory.
Re: BD Drive Enable buffer write with sg_raw [message #638 is a reply to message #519] Sun, 12 February 2012 15:40 Go to previous messageGo to next message
Mark Webber is currently offline  Mark Webber
Messages: 20
Registered: February 2012
Location: Australia
Gitbrew Noob
Ok, just checked what page 0x2d was doing since 0x2f was not changing.
It changes from "2d 06 00" to "2d 06 04" after using enable_write_buffer

Edit: My bad, just realised I was checking the wrong page (0x2f) when I first replied.
When checking 0x2d, it changes to whatever buffer I have told to enable writing to.
I still have the same status after trying to write though.
2/0/8

What command did you use to dump the buffer to a file with?
It could be the file I am using (bin file) that is causing the probelms.

[Updated on: Sun, 12 February 2012 15:52]

Report message to a moderator

Re: BD Drive Enable buffer write with sg_raw [message #639 is a reply to message #638] Sun, 12 February 2012 17:55 Go to previous messageGo to next message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
I used bd_read_buffer.c
Re: BD Drive Enable buffer write with sg_raw [message #640 is a reply to message #639] Mon, 13 February 2012 00:10 Go to previous messageGo to next message
Mark Webber is currently offline  Mark Webber
Messages: 20
Registered: February 2012
Location: Australia
Gitbrew Noob
Thanks Wink
I got the output to file, and same result.
Another thing I can cross from my list at least.
Re: BD Drive Enable buffer write with sg_raw [message #641 is a reply to message #640] Mon, 13 February 2012 18:15 Go to previous messageGo to next message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
I'm implementing support for vendor-specific BD commands in ps3rom driver currently.
We will try that too. Will report back when it's finished.

[Updated on: Mon, 13 February 2012 18:22]

Report message to a moderator

Re: BD Drive Enable buffer write with sg_raw [message #642 is a reply to message #641] Mon, 13 February 2012 19:27 Go to previous messageGo to next message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
Cool, i can send vendor specific commands now Smile
Re: BD Drive Enable buffer write with sg_raw [message #643 is a reply to message #642] Mon, 13 February 2012 19:53 Go to previous messageGo to next message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
Not sure which kernel you are using but i made a patch for ps3rom.c which adds support for vendor-specififc commands.

http://gitbrew.org/~glevand/ps3/linux/linux-3/patches/ps3rom -vendor-specific-command.patch

Examples how to use it:

http://gitbrew.org/~glevand/ps3/linux/linux-3/bd_read_profil e.c
http://gitbrew.org/~glevand/ps3/linux/linux-3/bd_set_auto_re q_sense_mode.c

Tested it on Linux kernel 3.2.5

[Updated on: Mon, 13 February 2012 19:55]

Report message to a moderator

Re: BD Drive Enable buffer write with sg_raw [message #645 is a reply to message #643] Mon, 13 February 2012 19:59 Go to previous messageGo to next message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
Before HRL is written to BD buffer, AUTO REQUEST SENSE MODE is disabled with vendor-specific command 0x30.

Like this:

# sudo ./bd_set_auto_req_sense_mode -m 1

After it was written, it's enabled again:

# sudo ./bd_set_auto_req_sense_mode -m 0

[Updated on: Mon, 13 February 2012 20:00]

Report message to a moderator

Re: BD Drive Enable buffer write with sg_raw [message #647 is a reply to message #645] Mon, 13 February 2012 20:12 Go to previous messageGo to next message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
LV1 sets/clears a flag in RBD storage device after AUTO REQUEST SENSE MODE comand was executed.
On 3.55, it's located at address 0x7f5a0+0x3e3.

Simple test
------------

Before disabling AUTO REQUEST SENSE MODE:

glevand@debian:~$ sudo dd if=/dev/ps3physmem bs=1 count=1 skip=$((0x7f5a0+0x3e3)) | hexdump -C
00000000  00                                                |.|
00000001


After disabling AUTO REQUEST SENSE MODE:

glevand@debian:~$ sudo dd if=/dev/ps3physmem bs=1 count=1 skip=$((0x7f5a0+0x3e3)) | hexdump -C
00000000  01                                                |.|
00000001
Re: BD Drive Enable buffer write with sg_raw [message #649 is a reply to message #647] Mon, 13 February 2012 21:09 Go to previous messageGo to next message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
I uploaded the precompiled Linux 3.2.5 version which support BD vendor-specific commands if you want to try it out.

http://gitbrew.org/~glevand/ps3/linux/linux-3/linux-3.2.5-bu ild.tar.bz2
Re: BD Drive Enable buffer write with sg_raw [message #650 is a reply to message #649] Tue, 14 February 2012 00:02 Go to previous messageGo to next message
Mark Webber is currently offline  Mark Webber
Messages: 20
Registered: February 2012
Location: Australia
Gitbrew Noob
I see you really are having fun with the drives.
Just starting to wonder if you sleep Wink

I will give all this a shot and report back all my findings.
Did you have a look through the MX dump?
Quite interesting when you get down to the core of it all Smile
Re: BD Drive Enable buffer write with sg_raw [message #655 is a reply to message #650] Wed, 15 February 2012 19:53 Go to previous messageGo to next message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
I have found another deifference between how the things are done in Lv2diag and on Linux.
Lv2diag writes data to buffer by using PIO mode but we use DMA mode on Linux.
I will test PIO too, maybe that's thge problem why some of written data is currupt on my PS3.
Re: BD Drive Enable buffer write with sg_raw [message #656 is a reply to message #655] Wed, 15 February 2012 20:46 Go to previous messageGo to next message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
No change. data is still corrupted.
Re: BD Drive Enable buffer write with sg_raw [message #657 is a reply to message #656] Thu, 16 February 2012 04:20 Go to previous messageGo to next message
Mark Webber is currently offline  Mark Webber
Messages: 20
Registered: February 2012
Location: Australia
Gitbrew Noob
Could it be that it is expecting a full MKB to extract the info from itself?

Possibly wrting a new HRL directly also causes the drive to expect new AACS keys etc as well since it would be seen by the drve firmware as an update.

When I was messing with the MX and SPI flasher, erasing all the info from 0xE000 on caused the drive to update not only the HRL, but also AACS keys.
Lv2diag would check the drive HRL, then check its own (v1) then if a disc was present check that also. This seems to only be true if the Lv2diag HRL was higher (anything is higher the nothing of course) would it check the disc.
If the drive HRL was higher then the V1 HRL in Lv2diag, it would ignore the disc and carry on.

Edit: In theory all that should be required would be to change the byte that defines the HRL verison to 0x00.
Then Lv2diag should behave as above and overwrite all the info with the new AACS keys and correct HRL from the disc.

[Updated on: Thu, 16 February 2012 04:24]

Report message to a moderator

Re: BD Drive Enable buffer write with sg_raw [message #658 is a reply to message #657] Thu, 16 February 2012 18:29 Go to previous message
glevand is currently offline  glevand
Messages: 955
Registered: July 2011
Location: SONY
Gitbrew God
I don't think so. because if you take a look at lv2diag you will see that after it has written buffer , it immedietly reads the same buffer back with SCSI READ BUFFER and compares the read data with the data which was written. ANd if it doesn't match then it exits with an error.
Previous Topic: SCSI Passthrough Feature
Next Topic: Cross-compiling Linux kernel
Goto Forum:
  


Current Time: Wed Jun 19 00:32:11 CEST 2013

Total time taken to generate the page: 3.30370 seconds