ROM Hack sky3ds diskwriter python clone (for linux & osx)

  • Thread starter Thread starter lukas_2511
  • Start date Start date
  • Views Views 48,218
  • Replies Replies 180
  • Likes Likes 8
Hello.
UPDATE : if i use sudo to launch python, i don't have the Permission denied anymore but I have a 0 byte problem...


Okay, thank you for reporting this. I still need to find a reliable way to tell the disksize on osx...

Dear Internet, any ideas on this? ;)
 
Dear Lukas,

Is it possible to bypass the disksize check and enter the disksize manualy ? (in the code or by prompt ?)

Update : http://kemstack.org/wordpress/zachary/2014/12/15/find-free-disk-space-in-python-on-osx/


Yes you can hardcode the size. Currently you'd need to edit sky3ds/disk.py, look for __init__, there will be a line self.get_disk_size(), replace that with self.disk_size = 12345 (where 12345 is the size of your sdcard in bytes).

I had a look at that link. os.statvfs works on filesystems, but not on the raw disks, so when I run it on "/dev/sdd" for example (on linux, or "/dev/diskwhatever" on osx) it will give the size of /dev, but not of the sdcard.

I'm currently thinking about building a wrapper around diskutil, but since I currently don't have an OSX machine for testing it would mostly be guesswork...

Edit: Just noticed that there is more than one possible solution on that page, but none seem to be the right thing
 
Sooo, I just added a different function for getting the blockdevice size. It's even uglier than the last one, but I really hope it now works on OSX too... Can someone please try?
 
i'm still having that :

Found updated template.txt. Converting...
Traceback (most recent call last):
File "/Users/****/Downloads/sky3ds.py-master/sky3ds/disk.py", line 37, in __init__
self.get_disk_size()
File "/Users/****/Downloads/sky3ds.py-master/sky3ds/disk.py", line 76, in get_disk_size
raise Exception("0 byte disk?!")
Exception: 0 byte disk?!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "sky3ds.py", line 51, in <module>
disk = disk.Sky3DS_Disk(args.disk)
File "/Users/****/Downloads/sky3ds.py-master/sky3ds/disk.py", line 39, in __init__

raise Exception("Couldn't get disksize, will not continue.")
 
i'm still having that :
[...]
Exception: 0 byte disk?!
[...]


That is weird. This shouldn't even happen anymore. You sure you got the updated version? Currently it should end up either in an endless loop, or just report completely wrong sizes. But it shouldn't return zero bytes... Did you try running this with sudo?
 
sorry I used the wrong file... silly me...

now it hangs after "converting...." not 0 bytes statement anymore.

Update : python appears to run an infinite loop ??
 
I like this. I know my way around python and I have a hackintosh to test it on in osx. However, I do not yet have a Sky3DS card. I'll get one as soon as I'm done with all of the games that I have installed via cia on 4.5. So I can test read/write/format/whatever, just not the actual playing the games part :/

If you guys get something working I'm happy to throw together a gui for it. I've been playing around in tkinter/ttk lately and I've got a pretty good handle on it.
 
I like this. I know my way around python and I have a hackintosh to test it on in osx. However, I do not yet have a Sky3DS card. I'll get one as soon as I'm done with all of the games that I have installed via cia on 4.5. So I can test read/write/format/whatever, just not the actual playing the games part :/

If you guys get something working I'm happy to throw together a gui for it. I've been playing around in tkinter/ttk lately and I've got a pretty good handle on it.


Hey, this thing is actually completely working, am using this under linux myself, the only thing missing is a function to detect the size of an sdcard on osx (some people reported that hardcoding the size makes this tool fully working under osx).

I've been reorganizing the codebase to work of a single class, there are a few things that i still need to change, after that it should be really easy to use the class as backend for a gui application.
 
Cool, I think I have a method somewhere that will give you the size of a disk that works on a mac. I've never attempted it on an sd card (I have with usb flash drives and it works), so I'll take a crack at it later and report back.

edit:
Here it is in case someone wants to play with it while I:m at work:

Code:
import os
 
def disk_size(path):
    st = os.statvfs(path)
    return st.f_blocks * st.f_frsize

Code:
>>> import os
>>>
>>> def disk_size(path):
...    st = os.statvfs(path)
...    return st.f_blocks * st.f_frsize
...
>>> disk_size('/Volumes/UNTITLED')
3996684288
 
  • Like
Reactions: cearp
sooooooooooo... i've written yet another alternative function to get the disk size on osx, can somebody please test it?
 
python hangs after converting... in osx (with the super dupper uggly alternative method...)
Infinite loop making python use 99% of CPU...

update : while disk_jump_size >= min_jump_size: this is always true ? no ?

update 2 : [solved] when I use the -l argument in sky3ds.py, i always have ??? in title
just needed to do a sky3ds.py -u... sorry works now...


PS : I confirm that with the size of the card hardcoded in disk.py, sky3ds works fine on OSX
 
python hangs after converting... in osx (with the super dupper uggly alternative method...)
Infinite loop making python use 99% of CPU...
[...]
update : while disk_jump_size >= min_jump_size: this is always true ? no ?
[...]
PS : I confirm that with the size of the card hardcoded in disk.py, sky3ds works fine on OSX


I tried another thing to break out of the infinite loop, can you test if it works with the new version? It shouldn't even got into a loop anyway... but you never know...

disk_jump_size is used in the following way:

jump from disk_size to disk_size+disk_jump_size, read 1 byte, write it back to disk (this is so dirty, i hate it so much), if successful store new disk_size
if jump fails, disk_jump_size is set to half the value it was before and it tries to jump with the new size
it repeats until disk_jump_size is smaller than 32MB

this way it basically goes like this on a card that would be slightly less than 4GB: 1024 2048 3072 3584 3840 3968 4032 4064

edit:

now i added two commits: one added a check that len(tmp) is actually 1 byte, the other one checks in the loop head that max_disk_size (130GB) is never reached.

if it aborts with the disk_size>130GB error could you please have a look at what tmp contains while the loop is working outside of the disks boundaries?
 

Site & Scene News

Popular threads in this forum