forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Strange PSP behaviour when connected via USB under Ubuntu

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Barts_706



Joined: 24 Jan 2006
Posts: 38

PostPosted: Mon Jul 03, 2006 3:57 am    Post subject: Strange PSP behaviour when connected via USB under Ubuntu Reply with quote

I have finally managed to install newest pspsdk under Dapper Drake Ubuntu. I have configured the paths, compiled a few examples from the gu part of sdk. So far so good.

The problem starts when I connect my PSP to my laptop (old Dell Latitude) via USB 1.1 (I said it is old).

It is detected, automounted, but when I copy anything to memory stick from my PC, the files are not copied instantly (as under Windows XP on the same machine). Instead, they show in file browser (console, mc, nautilus) as if they were copied on the memory stick, but if I disconnect the PSP - they are not there. If, on the other hand, I wait 5-10 minutes, they eventually get copied at some (more or less random) point. It is not very slow transfer, rather as if the data was cached somewhere and then flushed to USB when my Ubuntu thinks the time is right.

I quite frankly do not know why it happens so. It is not like that under Windows XP. I have googled, but not found anything similar. I have searched this forums, neither. So I post a description of a problem here, maybe someone will have an idea what to do about it.
Back to top
View user's profile Send private message Visit poster's website
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Mon Jul 03, 2006 4:24 am    Post subject: Reply with quote

You have to unmount the drive.... ffs people, you are supposed to do the same thing in windows too, but since windows uses sync writes instead of the faster async batch writes, chances are as long as the light isn't flashing the file has been written, but the drive still isn't in a clean state to be removed..
_________________
Shoot Pixels Not People!
Makeshift Development
Back to top
View user's profile Send private message Visit poster's website
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Mon Jul 03, 2006 4:56 am    Post subject: Reply with quote

If you really really want the slower synchronous writes so you can pull the PSP at any time, you should be able to add a rule to /etc/hal/fdi/policy/preferences.fdi to add the "sync" option; this is untested but it's something like
Code:

  <device>
    <match key="block.is_volume" bool="true">
        <match key="@block.storage_device:storage.removable" bool="true">
          <merge key="volume.policy.mount_option.sync" type="bool">true</merge>
        </match>
    </match>
  </device>
Back to top
View user's profile Send private message
zilt



Joined: 21 Feb 2006
Posts: 45
Location: Ontario, Canada

PostPosted: Mon Jul 03, 2006 5:05 am    Post subject: Reply with quote

Or just type 'sync' after you do the copy. It flushes the file system buffers
Back to top
View user's profile Send private message Visit poster's website
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Mon Jul 03, 2006 5:53 am    Post subject: Reply with quote

...and it still leaves the filesystem in a dirty state. Seriously, just unmount the stuff, otherwise you are begging for filesystem corruption.
_________________
Shoot Pixels Not People!
Makeshift Development
Back to top
View user's profile Send private message Visit poster's website
zilt



Joined: 21 Feb 2006
Posts: 45
Location: Ontario, Canada

PostPosted: Mon Jul 03, 2006 10:56 am    Post subject: Reply with quote

Drakonite wrote:
...and it still leaves the filesystem in a dirty state.


Then you must have a broken 'sync' command. I use it all the time without issue. From the 'info sync':

Quote:
The kernel keeps data in memory to avoid doing (relatively slow) disk
reads and writes. This improves performance, but if the computer
crashes, data may be lost or the file system corrupted as a result.
The `sync' command ensures everything in memory is written to disk.


A umount ends up calling the same sync system call to flush the buffers to disk. However, if you want to disconnect the PSP, you _should_ be calling umount anyways, so the sync command is unneeded.
Back to top
View user's profile Send private message Visit poster's website
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Mon Jul 03, 2006 11:29 am    Post subject: Reply with quote

zilt wrote:
Drakonite wrote:
...and it still leaves the filesystem in a dirty state.


Then you must have a broken 'sync' command. I use it all the time without issue. From the 'info sync':



It has nothing to do with the sync command. Until a filesystem is unmounted it's marked as dirty, regardless of how many times you call 'sync' it doesn't guarentee the filesystem is clean when you pull it, as anything could access the drive at any time; not to mention any filesystem with a global dirty flag is still marked dirty.

Pulling a drive with a syncronous (or just sync'd) filesystem _tends_ to work, as the data tends to be there, and then when the filesystem driver sees the filesystem is dirty and checks it, it typically shows up as okay or the only inconsistencies are quietly fixed. But it's not guarenteed to be so. Pulling a drive without unmounting is playing russian roulette.

And besides, it's as you say.. if you are running anything, you should be running umount, not just running sync. Running a sync command instead of unmounting is idiotic at best... And in the case of mounting with the sync option, the possibility of catching it in a corrupt state is even larger.
_________________
Shoot Pixels Not People!
Makeshift Development
Back to top
View user's profile Send private message Visit poster's website
groepaz



Joined: 01 Sep 2005
Posts: 305

PostPosted: Mon Jul 03, 2006 12:00 pm    Post subject: Reply with quote

depending on your setup (kernel/udev/hotplug/etc) actually funny things may occur if you dont unmount before running something...because the kernel doesnt know the device was unmounted, it may see another device the next time the psp initializes its drivers. i even managed to get some kernel-ooops (in the usb driver) when playing with pspinside too much :=)
_________________
http://www.hitmen-console.org
http://hitmen.c02.at/files/yapspd/
Back to top
View user's profile Send private message Visit poster's website
Barts_706



Joined: 24 Jan 2006
Posts: 38

PostPosted: Mon Jul 03, 2006 3:41 pm    Post subject: Reply with quote

Thank you for your quick replies. I haven't replied earlier, because I went to sleep (well, you just need to sometimes).

But how come the automount connects my PSP in asynchronous mode?

Well, never mind, I'll play with that. At least I have a bunch of new google keywords to search for (this sometimes is the main problem - I can describe the problem, but don't know what keywords to type...).

Still, do I understand it well that /etc/hal/fdi/policy/preferences.fdi contains the rules concerning additional mounting options (this whole sync thing)?
Back to top
View user's profile Send private message Visit poster's website
groepaz



Joined: 01 Sep 2005
Posts: 305

PostPosted: Mon Jul 03, 2006 7:07 pm    Post subject: Reply with quote

i'd disable automount completely for developing, it only causes weird problems :)
_________________
http://www.hitmen-console.org
http://hitmen.c02.at/files/yapspd/
Back to top
View user's profile Send private message Visit poster's website
Barts_706



Joined: 24 Jan 2006
Posts: 38

PostPosted: Mon Jul 03, 2006 10:12 pm    Post subject: Reply with quote

I have been thinking about it (purely theoretically for the time being, as I am at work now and could not check it here) and more questions arose :

- does umount _always_ call the sync?
Even if there is a lot waiting to be copied (like a file of, say, 950Mb, umm, a hypothetical file of a kind that we do not talk about in this forums)? If I call umount in such a situation, will it go for a looong copy (USB 1.1, mind you) and then unmount system?

- if I draw proper conclusions, is it okay to :
a) copy eboots to PSP;
b) then use 'sync' command;
c) then use 'umount'?

Sorry for the trouble, but you seem to have a good knowledge of the subject, so maybe I can learn something from you.
Back to top
View user's profile Send private message Visit poster's website
zilt



Joined: 21 Feb 2006
Posts: 45
Location: Ontario, Canada

PostPosted: Mon Jul 03, 2006 10:39 pm    Post subject: Reply with quote

Yes - umount always does a sync. If I copy a video file over to the psp, the cp generally returns immediately, then I do a umount and it can take a minute of two till the umount command ends while it flushes the buffer (by umount calling the sync system call ). There's no feedback from the umount call - it'll just sit there for a while till it's done. Do not unplug your cable till it returns.
Back to top
View user's profile Send private message Visit poster's website
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Tue Jul 04, 2006 3:45 am    Post subject: Reply with quote

Barts_706 wrote:

- does umount _always_ call the sync?

The entire purpose of umount is to commit everything, prepare a filesystem for removal, and then remove it.... so yes, it always syncs the buffer to the filesystem.
_________________
Shoot Pixels Not People!
Makeshift Development
Back to top
View user's profile Send private message Visit poster's website
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Tue Jul 04, 2006 11:03 pm    Post subject: Reply with quote

It seems that the PSP manages this by itself anyway. If you press circle to stop the USB connection, even when writing a file, it won't corrupt the stick (IIRC).
_________________
Sorry for my bad english
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
Arwin



Joined: 12 Jul 2005
Posts: 426

PostPosted: Tue Jul 04, 2006 11:19 pm    Post subject: Reply with quote

Brunni wrote:
It seems that the PSP manages this by itself anyway. If you press circle to stop the USB connection, even when writing a file, it won't corrupt the stick (IIRC).


Not necessarily true, in my experience. I've had a few times that the file I copied ended up corrupt - doesn't happen a lot, but it can be really annoying. Like Drakonite says, it's just a really bad idea anyway and you're just waiting for your memorystick to end up corrupt.

So I always properly unmount my USB device from windows (XP) as well. It's not like it's that much work, clicking it twice ...
Back to top
View user's profile Send private message
ooPo
Site Admin


Joined: 17 Jan 2004
Posts: 2032
Location: Canada

PostPosted: Tue Jul 04, 2006 11:54 pm    Post subject: Reply with quote

In ubuntu, right-click on the icon on your desktop and select 'unmount'.
Back to top
View user's profile Send private message Visit poster's website
groepaz



Joined: 01 Sep 2005
Posts: 305

PostPosted: Wed Jul 05, 2006 2:39 pm    Post subject: Reply with quote

just add a little script thingy to your makefile that does mount/copy/unmount. easiest for me anyways :)
_________________
http://www.hitmen-console.org
http://hitmen.c02.at/files/yapspd/
Back to top
View user's profile Send private message Visit poster's website
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Wed Jul 05, 2006 5:06 pm    Post subject: Reply with quote

Arwin wrote:
Brunni wrote:
It seems that the PSP manages this by itself anyway. If you press circle to stop the USB connection, even when writing a file, it won't corrupt the stick (IIRC).


Not necessarily true, in my experience. I've had a few times that the file I copied ended up corrupt - doesn't happen a lot, but it can be really annoying. Like Drakonite says, it's just a really bad idea anyway and you're just waiting for your memorystick to end up corrupt.

So I always properly unmount my USB device from windows (XP) as well. It's not like it's that much work, clicking it twice ...

What do you mean by memory stick corruption? Are there cases where the entire stick becomed unaccessable because of corruption, or is it just for one file?
_________________
Sorry for my bad english
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group