Compiling WBFS on Mac OS X

Discussion in 'Wii - Hacking' started by eddanx, Mar 31, 2009.

Mar 31, 2009

Compiling WBFS on Mac OS X by eddanx at 12:08 PM (374,975 Views / 0 Likes) 452 replies

  1. eddanx
    OP

    Newcomer eddanx Member

    Joined:
    Jun 6, 2007
    Messages:
    32
    Country:
    United States
    Update #2: For the latest version of the WBFS GUI Manager for Mac OS X, visit http://wiki.gbatemp.net/wiki/index.php/WBF...s#WBFS_Managers

    Update: We got the wbfs tool to work on Mac OS X. If you want to head right to the action, you can get the diff/patch to wbfs to compile it yourself or get the compiled binary for Mac OS X. The changes have been emailed to Kwiirk who'll include it in the next official release of wbfs.

    First of all, thanks for all the effort that has been put in to making all of this possible.

    I'm trying to compile the WBFS tool under Mac OS X. First, I just tried the naive approach:

    Code:
    Eia:cios_usb2 2 eirikh$ ls -l
    total 720
    -rw-r--r--@ÂÂ1 eiaÂÂstaffÂÂ365312 Mar 30 19:49 cios_dip_usb2_install.dol
    drwxr-xr-x@ 16 eiaÂÂstaffÂÂÂÂ 544 Mar 31 12:56 sources
    drwxr-xr-x@ÂÂ6 eiaÂÂstaffÂÂÂÂ 204 Mar 30 19:49 wbfs_linux
    Eia:cios_usb2 2 eia$ cd sources/wbfs/
    Eia:wbfs eia$ make clean
    rm -f negentig.o scrub.o wbfs.o tools.o bn.o ec.o disc_usage_table.o libwbfs.o libwbfs_linux.o wiidisc.o rijndael.o negentig scrub wbfs 
    Eia:wbfs eia$ make
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c negentig.c -o negentig.o 
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c tools.c -o tools.o 
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c bn.c -o bn.o 
    bn.c:11: warning: 'bn_print' defined but not used
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c ec.c -o ec.o 
    ec.c:28: warning: 'elt_print' defined but not used
    ec.c:189: warning: 'point_is_on_curve' defined but not used
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c disc_usage_table.c -o disc_usage_table.o 
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c libwbfs/libwbfs.c -o libwbfs.o 
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c libwbfs/libwbfs_linux.c -o libwbfs_linux.o 
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c libwbfs/wiidisc.c -o wiidisc.o 
    libwbfs/wiidisc.c:308: warning: unused parameter 'd'
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c libwbfs/rijndael.c -o rijndael.o 
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -m32 -static negentig.o tools.o bn.o ec.o disc_usage_table.o libwbfs.o libwbfs_linux.o wiidisc.o rijndael.o -lcrypto -o negentig
    ld_classic: can't locate file for: -lcrt0.o
    collect2: ld returned 1 exit status
    make: *** [negentig] Error 1
    Eia:wbfs eirikh$
    Ok, the not-so-unusual problem with building static binaries under Mac OS.

    So I removed -static from LDFLAGS in the Makefile and tried again:

    Code:
    Eia:wbfs eia$ vi Makefile 
    Eia:wbfs eia$ make clean
    rm -f negentig.o scrub.o wbfs.o tools.o bn.o ec.o disc_usage_table.o libwbfs.o libwbfs_linux.o wiidisc.o rijndael.o negentig scrub wbfs 
    Eia:wbfs eirikh$ make
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c negentig.c -o negentig.o 
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c tools.c -o tools.o 
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c bn.c -o bn.o 
    bn.c:11: warning: 'bn_print' defined but not used
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c ec.c -o ec.o 
    ec.c:28: warning: 'elt_print' defined but not used
    ec.c:189: warning: 'point_is_on_curve' defined but not used
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c disc_usage_table.c -o disc_usage_table.o 
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c libwbfs/libwbfs.c -o libwbfs.o 
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c libwbfs/libwbfs_linux.c -o libwbfs_linux.o 
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c libwbfs/wiidisc.c -o wiidisc.o 
    libwbfs/wiidisc.c:308: warning: unused parameter 'd'
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c libwbfs/rijndael.c -o rijndael.o 
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -m32 negentig.o tools.o bn.o ec.o disc_usage_table.o libwbfs.o libwbfs_linux.o wiidisc.o rijndael.o -lcrypto -o negentig
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c scrub.c -o scrub.o 
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -m32 scrub.o tools.o bn.o ec.o disc_usage_table.o libwbfs.o libwbfs_linux.o wiidisc.o rijndael.o -lcrypto -o scrub
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c wbfs.c -o wbfs.o 
    gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -m32 wbfs.o tools.o bn.o ec.o disc_usage_table.o libwbfs.o libwbfs_linux.o wiidisc.o rijndael.o -lcrypto -o wbfs
    Undefined symbols:
    ÂÂ"_wbfs_try_open", referenced from:
    ÂÂÂÂÂÂ_main in wbfs.o
    ÂÂ"_wbfs_try_open_partition", referenced from:
    ÂÂÂÂÂÂ_wbfs_applet_create in wbfs.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status
    make: *** [wbfs] Error 1
    Anyone got any further or have any tips?
     


  2. collin

    Newcomer collin Member

    Joined:
    Nov 16, 2006
    Messages:
    24
    Country:
    Heh, that is where I got to before I just gave up and decided to use a virtual machines.
     
  3. eddanx
    OP

    Newcomer eddanx Member

    Joined:
    Jun 6, 2007
    Messages:
    32
    Country:
    United States
    I see [​IMG] Did you use VirtualBox? Which distro did you go for?
     
  4. atomike

    Newcomer atomike Member

    Joined:
    May 13, 2008
    Messages:
    26
    Country:
    Canada
    someone mentionned Wubi. Is it any good?
     
  5. eddanx
    OP

    Newcomer eddanx Member

    Joined:
    Jun 6, 2007
    Messages:
    32
    Country:
    United States
    Wubi is for Windows. This forum topic is about Mac [​IMG] Wubi for Mac (Mubi) is not available at this point
     
  6. collin

    Newcomer collin Member

    Joined:
    Nov 16, 2006
    Messages:
    24
    Country:
    I'm not sure about VirtualBox's usb2 support. Its awkward in Linux, so I never bothered for OS X. I plan to use the old standby's of Ubuntu and Parallels.

    Although compiling on OS X is likely doable if one of the programmers can give advice.
     
  7. eddanx
    OP

    Newcomer eddanx Member

    Joined:
    Jun 6, 2007
    Messages:
    32
    Country:
    United States
    Yes, it should be really easy for someone with a little bit more experience than us ./configure | make | make install guys [​IMG]
     
  8. gibbed

    Newcomer gibbed Member

    Joined:
    Mar 31, 2009
    Messages:
    14
    Country:
    United States
    libwbfs_linux.c has a #ifdef check to explicitly look for __linux__.

    Ideally you would copy libwbfs_linux.c to libwbfs_macosx.c (and update the makefile to include it) and fix any problems in that code that would break macosx support.
     
  9. eddanx
    OP

    Newcomer eddanx Member

    Joined:
    Jun 6, 2007
    Messages:
    32
    Country:
    United States
    Just wanted to update about virtualbox and ubuntu: It works.

    Partition the disk without any partitions in Disk Utility (only free space) and eject the disk from disk utility. Set up usb 2.0 support in virtualbox. Fire up ubuntu, add the disk from the usb device list in virtualbox, open gparted and partition it to have one partition with "unknown" file system type. Use wbfs as described in the readme that comes with it.

    Posts merged

    I see, would look into it. Thanks!
     
  10. gibbed

    Newcomer gibbed Member

    Joined:
    Mar 31, 2009
    Messages:
    14
    Country:
    United States
    I think the largest problem would be fixing get_capacity, since that uses linux ioctl stuff. The rest of it ...should... work.
     
  11. eddanx
    OP

    Newcomer eddanx Member

    Joined:
    Jun 6, 2007
    Messages:
    32
    Country:
    United States
    I got it compiled now, but I'm not sure if I dare to run it..

    Anyone running Mac OS X in a safe environment (e.g. virtual) or have a system they dare to screw up?
     
  12. Mb*

    Newcomer Mb* Member

    Joined:
    Jan 17, 2009
    Messages:
    45
    Location:
    Livingston, Scotland!!
    Country:
    United Kingdom
    what might happen if it goes wrong?
    i may test:S
     
  13. tps2d

    Newcomer tps2d Member

    Joined:
    Mar 31, 2009
    Messages:
    34
    Country:
    United States
    I was able to compile it as well, but I had to manually define BLKSSZGET and BLKGETSIZE for the "get_capacity" function (I copy and pasted it from a random google result, most likely incorrect). So... it doesn't do anything. I can run it, it will output the help, but when I try to init the partition, it doesn't say anything. Just breaks.

    If I try to do a "df" command, it says unsupported by disk or something along those lines. It seems like the get_capacity function is the culprit, as expected.
     
  14. eddanx
    OP

    Newcomer eddanx Member

    Joined:
    Jun 6, 2007
    Messages:
    32
    Country:
    United States
     
  15. tps2d

    Newcomer tps2d Member

    Joined:
    Mar 31, 2009
    Messages:
    34
    Country:
    United States
    I made the same changes you just made (DKIOCGETBLOCKCOUNT, etc), and same results:

    $ sudo ./wbfs -p /dev/rdisk3s2 df
    error reading disc: Operation not supported by device
    $ sudo ./wbfs -p /dev/disk3s2 df
    error reading disc: Operation not supported by device

    $ ./wbfs -p /dev/disk3s2 init
    $
     
  16. tps2d

    Newcomer tps2d Member

    Joined:
    Mar 31, 2009
    Messages:
    34
    Country:
    United States
    I should also say I'm doing this on a disk that hasn't been formatted by USB Loader yet (haven't installed it on my Wii yet), but I was hoping to at least format the disk using this program. The disk has 2 partitions, 1 FAT32 and 1 free space.

    If I run init on the FAT32 partition:

    $ sudo ./wbfs -p /dev/disk3s1 init
    Floating point exception
     
  17. om_nous

    Newcomer om_nous Member

    Joined:
    Mar 31, 2009
    Messages:
    29
    Country:
    United States
    Found this thread trying to fix an error I am getting.

    In linux I can read the partition fine (created in gparted then ripped a disk to it using the wii)
    Code:
    wbfs# ./wbfs -p /dev/sdb1 ls
    RHAE01ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂPARTY PACK for REVOLUTION 0.09G
    I have made similar changes to the source as eddanx but I have been unsuccessful at getting it to work in OS X.

    Code:
    $diskutil list
    /dev/disk3
    ÂÂ #:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ TYPE NAMEÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂSIZEÂÂÂÂÂÂ IDENTIFIER
    ÂÂ 0:ÂÂÂÂ FDisk_partition_schemeÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ*37.3 GiÂÂÂÂdisk3
    ÂÂ 1:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂLinuxÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ 37.3 GiÂÂÂÂdisk3s1
    
    $ ./wbfs -p /dev/disk3s1 ls
    Floating point exception
    Going to try to narrow this down but I am not getting any build errors. Anyone have any ideas?
     
  18. eddanx
    OP

    Newcomer eddanx Member

    Joined:
    Jun 6, 2007
    Messages:
    32
    Country:
    United States
    I realized sector_size and n_sector never was set from the ioctl call, so...

    CODEEia:wbfs eia$ diff -u libwbfs/libwbfs_linux.c libwbfs/libwbfs_macosx.c
    --- libwbfs/libwbfs_linux.cÂÂÂÂ2009-03-28 14:52:50.000000000 +0100
    +++ libwbfs/libwbfs_macosx.cÂÂÂÂ2009-03-31 18:30:43.000000000 +0200
    @@ -1,9 +1,9 @@
    -#ifdef __linux__
    +#ifdef __APPLE__
    #include
    #include
    #include
    #include
    -#include
    +#include
    #include
    #include

    @@ -51,7 +51,9 @@
    ÂÂÂÂÂÂÂÂ if(fd
     
  19. gibbed

    Newcomer gibbed Member

    Joined:
    Mar 31, 2009
    Messages:
    14
    Country:
    United States
    n_sector / sector_size are pointers to their respective values, so what you're doing is telling ioctl to write over the pointer to those values.
     
  20. gibbed

    Newcomer gibbed Member

    Joined:
    Mar 31, 2009
    Messages:
    14
    Country:
    United States
    Apparently DKIOCGETBLOCKCOUNT returns a 64-bit number (long long) not a 32-bit number which is probably why you get a floating point exception.

    Code:
    long long my_n_sector;
    ret = ioctl(fd,DKIOCGETBLOCKCOUNT,&my_n_sector);
    *n_sector = (u32)my_n_sector;
     

Share This Page