Homebrew Homebrew Development

Garcia98

Hey! Listen!
Member
Joined
Sep 8, 2015
Messages
361
Trophies
0
Location
Salamanca
Website
github.com
XP
267
Country
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.
 

slu

Member
Newcomer
Joined
Sep 14, 2015
Messages
7
Trophies
0
Age
32
XP
52
Country
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, ...)
 

Breacky_p

New Member
Newbie
Joined
Sep 14, 2015
Messages
1
Trophies
0
Age
29
XP
51
Country
Australia
'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 :(
 
D

Deleted User

Guest
upload_2015-9-14_21-35-43-png.25328

(from gbatemp user jim~)
 
Last edited by ,

doctorgoat

Well-Known Member
Member
Joined
Jun 3, 2015
Messages
694
Trophies
0
Age
35
XP
560
Country
United States
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.
 

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
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.
 

DiscostewSM

Well-Known Member
Member
Joined
Feb 10, 2009
Messages
5,484
Trophies
2
Location
Sacramento, California
Website
lazerlight.x10.mx
XP
5,508
Country
United States
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.
 

ChicagoMel

Well-Known Member
Member
Joined
Sep 1, 2015
Messages
524
Trophies
0
Age
42
XP
875
Country
United States
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.
 

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
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

Rinnegatamante

Well-Known Member
Member
Joined
Nov 24, 2014
Messages
3,162
Trophies
2
Age
29
Location
Bologna
Website
rinnegatamante.it
XP
4,857
Country
Italy
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 )
 

Rinnegatamante

Well-Known Member
Member
Joined
Nov 24, 2014
Messages
3,162
Trophies
2
Age
29
Location
Bologna
Website
rinnegatamante.it
XP
4,857
Country
Italy
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

General chit-chat
Help Users
    AncientBoi @ AncientBoi: Hilarious :rofl2: