What's the matter? [usb connection problem inside]

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
blu_eye4
Posts: 37
Joined: Sun Oct 26, 2008 8:41 pm

What's the matter? [usb connection problem inside]

Post by blu_eye4 »

Code: Select all

#include "pspkern.h"
#include <pspkernel.h>
#include <pspiofilemgr.h>
#include <pspctrl.h>
#include "dump.h"
#include <psppower.h>
#include <pspumd.h>
#include <pspdisplay.h>
#include <pspusbstor.h>
#include "usbmy.h"
#include <pspusb.h>



PSP_MODULE_INFO&#40;"DumperXflash", 0, 1, 0&#41;;

#define printf pspDebugScreenPrintf
#define PSP_USBBUS_DRIVERNAME "USBBusDriver"


int sceIoRead&#40;SceUID fd, void *data, SceSize size&#41;;
int sceDisplayWaitVblankStart&#40;&#41;;
int sceIoRemove&#40;const char *file&#41;;
int sceIoRmdir&#40;const char *path&#41;;
int main&#40;void&#41;
&#123;

    int sceDisplayWaitVblankStart&#40;&#41;;
        int sceUsbStart&#40;&#41;;
    int sceUsbActivate&#40;&#41;;
    int scePowerSetClockFrequency&#40;&#41;;
    scePowerSetClockFrequency&#40;100, 100, 50&#41;;
    sceIoUnassign&#40;"flash0&#58;"&#41;;
    sceIoAssign&#40;"flash0&#58;", "lflash0&#58;0,0", "flashfat0&#58;", IOASSIGN_RDWR, NULL, 0&#41;;
    SceCtrlLatch latch;
    pspDebugScreenInit&#40;&#41;;
    pspDebugScreenClear&#40;&#41;;
    SetupCallbacks&#40;&#41;;
    sceIoUnassign&#40;"flash1&#58;"&#41;;
    sceIoAssign&#40;"flash1&#58;", "lflash1&#58;0,1", "flashfat1&#58;", IOASSIGN_RDWR, NULL, 0&#41;;
    printf&#40;"DumperXflash v. 1,1 by blu_eye4\n"&#41;;
    printf&#40;"Ringrazio Dark_alex per il cf, ps2dev.org per il supporto così come psp-ita.com\n"&#41;;
    printf&#40;"Grazie a tyrannid per is suoi esempi del SDK\n"&#41;;
    printf&#40;"premere X per cancellare file config.se dalla flash1"&#41;;
    printf&#40;"premere O per dump flash 1\n"&#41;;
    printf&#40;"premere &#91;&#93; per dump flash 0\n"&#41;;
    printf&#40;"premere triangolo per eliminare il file config.se dalla flash1\n"&#41;;
    printf&#40;"premere HOME per uscire senza effettuare alcuna operazione\n"&#41;;
    printf&#40;"premere R per stabilire la connessione USB\n"&#41;;

    for&#40;;;&#41;&#123;
            sceCtrlReadLatch&#40;&latch&#41;;
    if&#40;latch.uiMake & PSP_CTRL_CIRCLE&#41;
    &#123;
            dump_filesystem&#40;"flash1&#58;/", "ms0&#58;/flash1"&#41;;
			pspDebugScreenClear&#40;&#41;;
            printf&#40;"\n\nFatto\n\n"&#41;;
    printf&#40;"premere X per cancellare file config.se dalla flash1"&#41;;
    printf&#40;"premere O per dump flash 1\n"&#41;;
    printf&#40;"premere &#91;&#93; per dump flash 0\n"&#41;;
    printf&#40;"premere triangolo per eliminare il file config.se dalla flash1\n"&#41;;
    printf&#40;"premere HOME per uscire senza effettuare alcuna operazione\n"&#41;;
    &#125;
    if&#40;latch.uiMake & PSP_CTRL_SQUARE&#41;
    &#123;
        dump_filesystem&#40;"flash0&#58;/", "ms0&#58;/flash0"&#41;;
        pspDebugScreenClear&#40;&#41;;
        printf&#40;"\n\nFatto\n\n"&#41;;
    printf&#40;"premere X per cancellare file config.se dalla flash1"&#41;;
    printf&#40;"premere O per dump flash 1\n"&#41;;
    printf&#40;"premere &#91;&#93; per dump flash 0\n"&#41;;
    printf&#40;"premere triangolo per eliminare il file config.se dalla flash1\n"&#41;;
    printf&#40;"premere HOME per uscire senza effettuare alcuna operazione\n"&#41;;;

    &#125;
    if&#40;latch.uiMake & PSP_CTRL_TRIANGLE&#41;
    &#123;
        int coso;
        printf&#40;"eliminazione file...\n"&#41;;
        sceIoRemove&#40;"flash0&#58;/dic/apotp.dic"&#41;;
        sceIoRemove&#40;"flash0&#58;/dic/atokp.dic"&#41;;
        sceIoRemove&#40;"flash0&#58;/dic/aux0.dic"&#41;;
        sceIoRemove&#40;"flash0&#58;/dic/aux1.dic"&#41;;
        sceIoRemove&#40;"flash0&#58;/dic/aux2.dic"&#41;;
        sceIoRemove&#40;"flash0&#58;/dic/aux3.dic"&#41;;


        coso = sceIoRemove&#40;"flash0&#58;/dic/apotp.dic"&#41;;
        if&#40;coso < 0&#41;&#123;
            printf&#40;"errore!!!\n"&#41;;
            printf&#40;"\n errore &#58; %x\n", sceIoRemove&#40;"flash0&#58;/dic"&#41;&#41;;
        &#125;
        if&#40;coso >= 0&#41;&#123;
        printf&#40;"\nFatto\n"&#41;;
    printf&#40;"premere X per cancellare file config.se dalla flash1\n"&#41;;
    printf&#40;"premere O per dump flash 1\n"&#41;;
    printf&#40;"premere &#91;&#93; per dump flash 0\n"&#41;;
    printf&#40;"premere triangolo per eliminare il file config.se dalla flash1\n"&#41;;
    printf&#40;"premere HOME per uscire senza effettuare alcuna operazione\n"&#41;;
    &#125;
    if&#40;latch.uiMake & PSP_CTRL_CROSS&#41;&#123;
        sceIoRemove&#40;"flash1&#58;/config.se"&#41;;
        if&#40;coso < 0&#41;&#123;
            printf&#40;"errore!!!\n"&#41;;
            printf&#40;"errore numero &#58; %x\n", sceIoRemove&#40;"flash1&#58;/config.se"&#41;&#41;;
    &#125;
    else &#123;
        printf&#40;"\nFatto\n"&#41;;
        printf&#40;"premere O per dump flash 1\n"&#41;;
        printf&#40;"premere &#91;&#93; per dump flash 0\n"&#41;;
        printf&#40;"premere HOME per uscire \n"&#41;;
        printf&#40;"premere triangolo per eliminare il file config.se dalla flash1\n"&#41;;
    &#125;
    while&#40;1&#41; &#123;
      if&#40;latch.uiMake & PSP_CTRL_RTRIGGER&#41; &#123;
         sceUsbStart&#40;PSP_USBBUS_DRIVERNAME, 0, 0&#41;;
         sceUsbStart&#40;PSP_USBSTOR_DRIVERNAME, 0, 0&#41;;
       sceUsbActivate&#40;0x1c8&#41;;
      &#125;
      break;
   &#125;
        int prova = sceUsbStart&#40;PSP_USBBUS_DRIVERNAME, 0, 0&#41;;
        if&#40;prova != 0&#41;&#123;
            printf&#40;"\n errore %x\n", sceUsbStart&#40;PSP_USBBUS_DRIVERNAME, 0, 0&#41;&#41;;
        &#125;
        else
        &#123;
            printf&#40;"Connessione stabilita\n"&#41;;
    &#125;
    &#125;
    &#125;
    &#125;

    sceDisplayWaitVblankStart&#40;&#41;;
    return 0;
&#125;

Where do I wrong? I don't understand error... Cygwin compile it without error or warning but when i play it on my psp there is a black display and i can't do nothing... please help me :)
User avatar
Wally
Posts: 663
Joined: Mon Sep 26, 2005 11:25 am

Post by Wally »

add

PSP_HEAP_SIZE_KB(-1024);

Wally
blu_eye4
Posts: 37
Joined: Sun Oct 26, 2008 8:41 pm

Post by blu_eye4 »

Wally4000 wrote:add

PSP_HEAP_SIZE_KB(-1024);

Wally
I'm sorry, it doesn't work... thanks for your time
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Init the debugging FIRST, and do some prints around all the USB setup so you can see where it's hanging.
blu_eye4
Posts: 37
Joined: Sun Oct 26, 2008 8:41 pm

Post by blu_eye4 »

J.F. wrote:Init the debugging FIRST, and do some prints around all the USB setup so you can see where it's hanging.

Code: Select all

#include "pspkern.h"
#include <pspkernel.h>
#include <pspiofilemgr.h>
#include <pspctrl.h>
#include "dump.h"
#include <psppower.h>
#include <pspumd.h>
#include <pspdisplay.h>
#include <pspusbstor.h>
#include "usbmy.h"
#include <pspusb.h>



PSP_MODULE_INFO&#40;"DumperXflash", 0, 1, 0&#41;;

#define printf pspDebugScreenPrintf
#define PSP_USBBUS_DRIVERNAME "USBBusDriver"
#define PSP_USB_ACTIVATED 0x200


int sceIoRead&#40;SceUID fd, void *data, SceSize size&#41;;
int sceDisplayWaitVblankStart&#40;&#41;;
int sceIoRemove&#40;const char *file&#41;;
int sceIoRmdir&#40;const char *path&#41;;
int main&#40;void&#41;
&#123;
    pspDebugScreenInit&#40;&#41;;
    pspDebugScreenClear&#40;&#41;;
    SetupCallbacks&#40;&#41;;
    int sceDisplayWaitVblankStart&#40;&#41;;
    int scePowerSetClockFrequency&#40;&#41;;
    scePowerSetClockFrequency&#40;100, 100, 50&#41;;
    sceIoUnassign&#40;"flash0&#58;"&#41;;
    sceIoAssign&#40;"flash0&#58;", "lflash0&#58;0,0", "flashfat0&#58;", IOASSIGN_RDWR, NULL, 0&#41;;
    SceCtrlLatch latch;
    sceIoUnassign&#40;"flash1&#58;"&#41;;
    sceIoAssign&#40;"flash1&#58;", "lflash1&#58;0,1", "flashfat1&#58;", IOASSIGN_RDWR, NULL, 0&#41;;
    printf&#40;"DumperXflash v. 1,1 by blu_eye4\n"&#41;;
    printf&#40;"Ringrazio Dark_alex per il cf, ps2dev.org per il supporto così come psp-ita.com\n"&#41;;
    printf&#40;"Grazie a tyrannid per is suoi esempi del SDK\n"&#41;;
    printf&#40;"premere X per cancellare file config.se dalla flash1"&#41;;
    printf&#40;"premere O per dump flash 1\n"&#41;;
    printf&#40;"premere &#91;&#93; per dump flash 0\n"&#41;;
    printf&#40;"premere triangolo per eliminare il file config.se dalla flash1\n"&#41;;
    printf&#40;"premere HOME per uscire senza effettuare alcuna operazione\n"&#41;;
    printf&#40;"premere R per stabilire la connessione USB\n"&#41;;

    for&#40;;;&#41;&#123;
            sceCtrlReadLatch&#40;&latch&#41;;
    if&#40;latch.uiMake & PSP_CTRL_CIRCLE&#41;
    &#123;
            dump_filesystem&#40;"flash1&#58;/", "ms0&#58;/flash1"&#41;;
			pspDebugScreenClear&#40;&#41;;
            printf&#40;"\n\nFatto\n\n"&#41;;
    printf&#40;"premere X per cancellare file config.se dalla flash1"&#41;;
    printf&#40;"premere O per dump flash 1\n"&#41;;
    printf&#40;"premere &#91;&#93; per dump flash 0\n"&#41;;
    printf&#40;"premere triangolo per eliminare il file config.se dalla flash1\n"&#41;;
    printf&#40;"premere HOME per uscire senza effettuare alcuna operazione\n"&#41;;
    &#125;
    if&#40;latch.uiMake & PSP_CTRL_SQUARE&#41;
    &#123;
        dump_filesystem&#40;"flash0&#58;/", "ms0&#58;/flash0"&#41;;
        pspDebugScreenClear&#40;&#41;;
        printf&#40;"\n\nFatto\n\n"&#41;;
    printf&#40;"premere X per cancellare file config.se dalla flash1"&#41;;
    printf&#40;"premere O per dump flash 1\n"&#41;;
    printf&#40;"premere &#91;&#93; per dump flash 0\n"&#41;;
    printf&#40;"premere triangolo per eliminare il file config.se dalla flash1\n"&#41;;
    printf&#40;"premere HOME per uscire senza effettuare alcuna operazione\n"&#41;;;

    &#125;
    if&#40;latch.uiMake & PSP_CTRL_TRIANGLE&#41;
    &#123;
        int coso;
        printf&#40;"eliminazione file...\n"&#41;;
        sceIoRemove&#40;"flash0&#58;/dic/apotp.dic"&#41;;
        sceIoRemove&#40;"flash0&#58;/dic/atokp.dic"&#41;;
        sceIoRemove&#40;"flash0&#58;/dic/aux0.dic"&#41;;
        sceIoRemove&#40;"flash0&#58;/dic/aux1.dic"&#41;;
        sceIoRemove&#40;"flash0&#58;/dic/aux2.dic"&#41;;
        sceIoRemove&#40;"flash0&#58;/dic/aux3.dic"&#41;;


        coso = sceIoRemove&#40;"flash0&#58;/dic/apotp.dic"&#41;;
        if&#40;coso < 0&#41;&#123;
            printf&#40;"errore!!!\n"&#41;;
            printf&#40;"\n errore &#58; %x\n", sceIoRemove&#40;"flash0&#58;/dic"&#41;&#41;;
        &#125;
        if&#40;coso >= 0&#41;&#123;
        printf&#40;"\nFatto\n"&#41;;
    printf&#40;"premere X per cancellare file config.se dalla flash1\n"&#41;;
    printf&#40;"premere O per dump flash 1\n"&#41;;
    printf&#40;"premere &#91;&#93; per dump flash 0\n"&#41;;
    printf&#40;"premere triangolo per eliminare il file config.se dalla flash1\n"&#41;;
    printf&#40;"premere HOME per uscire senza effettuare alcuna operazione\n"&#41;;
    &#125;
    if&#40;latch.uiMake & PSP_CTRL_CROSS&#41;&#123;
        sceIoRemove&#40;"flash1&#58;/config.se"&#41;;
        if&#40;coso < 0&#41;&#123;
            printf&#40;"errore!!!\n"&#41;;
            printf&#40;"errore numero &#58; %x\n", sceIoRemove&#40;"flash1&#58;/config.se"&#41;&#41;;
    &#125;
    else &#123;
        printf&#40;"\nFatto\n"&#41;;
        printf&#40;"premere O per dump flash 1\n"&#41;;
        printf&#40;"premere &#91;&#93; per dump flash 0\n"&#41;;
        printf&#40;"premere HOME per uscire \n"&#41;;
        printf&#40;"premere triangolo per eliminare il file config.se dalla flash1\n"&#41;;
    &#125;
                    if&#40;latch.uiMake & PSP_CTRL_RTRIGGER&#41;
                            &#123;
                                int sceUsbStart&#40;&#41;;
                                int sceUsbActivate&#40;&#41;;
                                sceUsbStart&#40;PSP_USBBUS_DRIVERNAME, 0, 0&#41;;
                                sceUsbStart&#40;PSP_USBSTOR_DRIVERNAME, 0, 0&#41;;
                                sceUsbActivate&#40;0x1c8&#41;;
      &#125;

        int prova = sceUsbStart&#40;PSP_USBBUS_DRIVERNAME, 0, 0&#41;;
        if&#40;prova != 0&#41;&#123;
            printf&#40;"\n errore %x\n", sceUsbStart&#40;PSP_USBBUS_DRIVERNAME, 0, 0&#41;&#41;;
        &#125;
        else
        &#123;
            printf&#40;"Connessione stabilita\n"&#41;;
    &#125;
    &#125;
    &#125;
    &#125;

    sceDisplayWaitVblankStart&#40;&#41;;
    return 0;
&#125;
I've changed some things but homebrew doesn't work... I don'y know what I have to do... please help me and excuse me but I'm a noob in c language :)
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Try something simple first then. Why does everyone try to do an XBox 360 emulator (or equivalent) as their FIRST program? Whatever happened to "Hello World"? :D

Until you figure out from the samples and existing apps how the PSP apps work, I wouldn't bother trying to write anything specific.
PosX100
Posts: 98
Joined: Wed Aug 15, 2007 1:02 am

Post by PosX100 »

So this is the brand-new universal-multi-bricker? cool...

The first thing i've noticed , is that you're declaring functions inside main,
and i was about to "hit" "backspace" , but i decided to give it one last chance.

HINT : You're updating the screen surface outside main loop , and to be exact , just before
the program quits.
Post Reply