Homebrew Homebrew Development

  • Thread starter Thread starter aliak11
  • Start date Start date
  • Views Views 1,475,165
  • Replies Replies 6,048
  • Likes Likes 54
If you post your code here we might find the mistake forcyou

Nevermind, I already fixed it, it was a silly error xD

Enable the console on whichever screen you can spare, and print messages to it (eg. successive numbers) between bits of your code so you can see where the crash happens.

Thanks for the tip, I'll do that if I have a bug again.
 
The weird thing is that in Citra it works fine (it doesn't freeze after a while) :wacko:
Citra is good for testing quick changes, but it is very forgiving for bad addresses and hardware configuration issues. Testing on hardware is still best - probably won't change soon - if ever.
 
  • Like
Reactions: Garcia98
Hi guys ;) , I am new to the forums and also to 3ds brew development. I tried to compile default (graphics/helloworld) ctrulib example, did everything like in tutorial, no prob with compilation, everything fine. But when I moved my compiled files (3dsx and smdh) to sd card and then run homebrew, it didn't show up. I tried restarting my 3ds and running again make. What am I doing wrong? Other homebrew apps are showing and working correctly (mgba, mastermind, ironhax installer, ...)
 
'sup mates,
I'm also new here and I've got a question too. Yesterday I found that it's possible to do homebrew on the 3DS, which made me smile instantly. The problem is, I wasn't updating my firmware for a few weeks now and was stuck on 9.6 or something like that, so I decided to update it. But unfortunately then it went straight to 10.0 before I tried to do the homebrew hack (which would be Tubehax). Is there a way to do that directly on the newest firmware? Or at least if not, to downgrade my 3DS to 9.9, since I tried the hack on my current firmware 3DS and it didn't work :(
 
upload_2015-9-14_21-35-43-png.25328

(from gbatemp user jim~)
 
Last edited by ,
What's the simplest way to set up homebrew on a system with 7.2 native/10.0 emunand?

I want to get kernel stuff going for dynarec on gba stuff and the only way I know of right now (launch rxtools, launch devmode on sysnand, launch patched ninjhax) is cumbersome.
 
While doing some heavier stuff in homebrew i noticed that citra goes much slower then a 3DS.
Is this normal or could this be something in my code?
Cause i would expect an emulator of something small like a 3DS to be much faster then an actual device.
 
While doing some heavier stuff in homebrew i noticed that citra goes much slower then a 3DS.
Is this normal or could this be something in my code?
Cause i would expect an emulator of something small like a 3DS to be much faster then an actual device.

The emulator is not finalized in any shape or form. Don't expect it to be accurate even down to running speed for some time.
 
How do I delete posts? I got this now.

Just a thought but maybe you should leave your posts up. Just because your question got answered doesn't mean it's worthless. Maybe someone will have the same question you posted and learn from the answer you received.
 
oh ok. I was having trouble with Tubehax but it's just really touchy. It took a few tries to get it to stop crashing and work, and the "hold down start until it crashes" worked.
 
Is there an opensource homebrew which uses socketing? (Or a sample on how to work with SOC service?)
Here is an example of how pictochat partially works:

There are probably some includes that you can leave out, but i used these:
Code:
#include <3ds.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <malloc.h>
#include <fcntl.h>
#include <errno.h>
Code:
SOC_buffer = memalign(0x1000, 0x100000);
    if(SOC_buffer == NULL)
        return -1;

    Result ret = SOC_Initialize(SOC_buffer, 0x100000);
    if(ret != 0)
    {
        // need to free the shared memory block if something goes wrong
        SOC_Shutdown();
        free(SOC_buffer);
        SOC_buffer = NULL;
        return -1;
    }
    return 0;
if(chatls >= 0) {
closesocket(chatls);
chatls = -1;
}

Result ret = SOC_Shutdown();

if(ret < 0) {
return -1;
}
return 0;
Code:
int n;
    struct sockaddr_in serv_addr;
 
    //initialise shit
    memset(&serv_addr, '0', sizeof(serv_addr));
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = inet_addr("172.0.0.1"); //ip adress of server
    serv_addr.sin_port = htons(5000); //port

    // create listening socket on all addresses on NETLOADER_PORT
    chatls = socket(AF_INET, SOCK_STREAM, 0);
    if(chatls < 0)
    {
        //printf("Error opening socket\n");
        return -1;
    }
    n = connect(chatls, (struct sockaddr*)&serv_addr, sizeof(serv_addr));
    if (n < 0)
    {
       //printf("ERROR connecting\n");
       return -2;
    }
    if(set_socket_nonblocking(chatls) == -1) {
        return -3;
    }
I copied this one from smealum, i use this because so that i can do other stuff instead of waiting for a message
Code:
static int set_socket_nonblocking(int sock) {
    int flags = fcntl(sock, F_GETFL);

    if(flags == -1) return -1;

    int rc = fcntl(sock, F_SETFL, flags | O_NONBLOCK);

    if(rc != 0) return -1;

    return 0;
}

Then you can use functions to send and receive stuff, an example function used in pictochat to send a message:
In this function i used the socket function sendto, (send causes some problems and write didn't work for me)
Code:
int sock_send(char* message, size_t size) {
    int n = sendto(chatls, message, size, 0, NULL, 0);
    if (n == -1)
    {
       printf("ERROR writing to socket");
       return -1;
    }
    return 0;
}
Code:
static int sock_receive(char* message, size_t size) {
    int len;
    len = recv(chatls, message, size, 0);
  
    if (len == -1) {
        if (errno != EAGAIN && errno != EWOULDBLOCK) {
            return -1;
        }
    }
    return len;
}

Hope this helps

--------------------- MERGED ---------------------------

Is there an opensource homebrew which uses socketing? (Or a sample on how to work with SOC service?)
Are you including sockets in lpp-3ds?
 
  • Like
Reactions: Rinnegatamante
Here is an example of how pictochat partially works:

There are probably some includes that you can leave out, but i used these:
Code:
#include <3ds.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <malloc.h>
#include <fcntl.h>
#include <errno.h>
Code:
SOC_buffer = memalign(0x1000, 0x100000);
    if(SOC_buffer == NULL)
        return -1;

    Result ret = SOC_Initialize(SOC_buffer, 0x100000);
    if(ret != 0)
    {
        // need to free the shared memory block if something goes wrong
        SOC_Shutdown();
        free(SOC_buffer);
        SOC_buffer = NULL;
        return -1;
    }
    return 0;
if(chatls >= 0) {
closesocket(chatls);
chatls = -1;
}

Result ret = SOC_Shutdown();

if(ret < 0) {
return -1;
}
return 0;
Code:
int n;
    struct sockaddr_in serv_addr;

    //initialise shit
    memset(&serv_addr, '0', sizeof(serv_addr));
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = inet_addr("172.0.0.1"); //ip adress of server
    serv_addr.sin_port = htons(5000); //port

    // create listening socket on all addresses on NETLOADER_PORT
    chatls = socket(AF_INET, SOCK_STREAM, 0);
    if(chatls < 0)
    {
        //printf("Error opening socket\n");
        return -1;
    }
    n = connect(chatls, (struct sockaddr*)&serv_addr, sizeof(serv_addr));
    if (n < 0)
    {
       //printf("ERROR connecting\n");
       return -2;
    }
    if(set_socket_nonblocking(chatls) == -1) {
        return -3;
    }
I copied this one from smealum, i use this because so that i can do other stuff instead of waiting for a message
Code:
static int set_socket_nonblocking(int sock) {
    int flags = fcntl(sock, F_GETFL);

    if(flags == -1) return -1;

    int rc = fcntl(sock, F_SETFL, flags | O_NONBLOCK);

    if(rc != 0) return -1;

    return 0;
}

Then you can use functions to send and receive stuff, an example function used in pictochat to send a message:
In this function i used the socket function sendto, (send causes some problems and write didn't work for me)
Code:
int sock_send(char* message, size_t size) {
    int n = sendto(chatls, message, size, 0, NULL, 0);
    if (n == -1)
    {
       printf("ERROR writing to socket");
       return -1;
    }
    return 0;
}
Code:
static int sock_receive(char* message, size_t size) {
    int len;
    len = recv(chatls, message, size, 0);
 
    if (len == -1) {
        if (errno != EAGAIN && errno != EWOULDBLOCK) {
            return -1;
        }
    }
    return len;
}

Hope this helps

--------------------- MERGED ---------------------------


Are you including sockets in lpp-3ds?

Yeah, i'm porting all socketing features provided by lpp-c++ to lpp-3ds ( https://github.com/Rinnegatamante/lua-player-plus/blob/master/lpp-c++/Lua/Wlan.c )
 
Here is an example of how pictochat partially works:

There are probably some includes that you can leave out, but i used these:
Code:
#include <3ds.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <malloc.h>
#include <fcntl.h>
#include <errno.h>
Code:
SOC_buffer = memalign(0x1000, 0x100000);
    if(SOC_buffer == NULL)
        return -1;

    Result ret = SOC_Initialize(SOC_buffer, 0x100000);
    if(ret != 0)
    {
        // need to free the shared memory block if something goes wrong
        SOC_Shutdown();
        free(SOC_buffer);
        SOC_buffer = NULL;
        return -1;
    }
    return 0;
if(chatls >= 0) {
closesocket(chatls);
chatls = -1;
}

Result ret = SOC_Shutdown();

if(ret < 0) {
return -1;
}
return 0;
Code:
int n;
    struct sockaddr_in serv_addr;

    //initialise shit
    memset(&serv_addr, '0', sizeof(serv_addr));
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = inet_addr("172.0.0.1"); //ip adress of server
    serv_addr.sin_port = htons(5000); //port

    // create listening socket on all addresses on NETLOADER_PORT
    chatls = socket(AF_INET, SOCK_STREAM, 0);
    if(chatls < 0)
    {
        //printf("Error opening socket\n");
        return -1;
    }
    n = connect(chatls, (struct sockaddr*)&serv_addr, sizeof(serv_addr));
    if (n < 0)
    {
       //printf("ERROR connecting\n");
       return -2;
    }
    if(set_socket_nonblocking(chatls) == -1) {
        return -3;
    }
I copied this one from smealum, i use this because so that i can do other stuff instead of waiting for a message
Code:
static int set_socket_nonblocking(int sock) {
    int flags = fcntl(sock, F_GETFL);

    if(flags == -1) return -1;

    int rc = fcntl(sock, F_SETFL, flags | O_NONBLOCK);

    if(rc != 0) return -1;

    return 0;
}

Then you can use functions to send and receive stuff, an example function used in pictochat to send a message:
In this function i used the socket function sendto, (send causes some problems and write didn't work for me)
Code:
int sock_send(char* message, size_t size) {
    int n = sendto(chatls, message, size, 0, NULL, 0);
    if (n == -1)
    {
       printf("ERROR writing to socket");
       return -1;
    }
    return 0;
}
Code:
static int sock_receive(char* message, size_t size) {
    int len;
    len = recv(chatls, message, size, 0);
 
    if (len == -1) {
        if (errno != EAGAIN && errno != EWOULDBLOCK) {
            return -1;
        }
    }
    return len;
}

Hope this helps

--------------------- MERGED ---------------------------


Are you including sockets in lpp-3ds?

Thanks for your tips, i ported the entire socket module, now i need only to test it.
Anyway, about send bug, sendto last arguments need to be leaved NULL and 0 or they may refer to an existent server?
 

Site & Scene News

Popular threads in this forum