Skip to content
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d8b210c
Increase amount of probes and overall timeout for DHCP. Makes DHCP on…
Oct 12, 2025
d712cf6
Polish up crash handling input options
Oct 12, 2025
43c71c9
Print network config and init network for telnet handling.
Oct 12, 2025
e72d1b1
Telnet handling is too unstable working only sometimes under certain …
Oct 12, 2025
af6d694
Telnet handling is too unstable working only sometimes under certain …
Oct 12, 2025
20cf4fe
simplyify controller handling
Oct 12, 2025
263fb9b
Figured out why telnet was not working reliably - receive was disable…
Oct 14, 2025
af94d2c
Remove undefined reference
Oct 14, 2025
6484919
Re-enable telnet. Add receive echo.
Oct 14, 2025
9d9a8b9
Cleaning up compiler warnings.
Oct 14, 2025
f4e80dc
Finished up telnet debugging. Receive data works as does send. Receiv…
Oct 17, 2025
b623a4c
Finishing up telnet stuff - everything is working, chars in and out.
Oct 17, 2025
c397efb
Further cleanup of telnet after testing. Disabling feedback echo sinc…
Oct 17, 2025
038d0b0
Re-adding telnet after testing locally. A stack dump can now be obtai…
Oct 18, 2025
dbc3418
Final push to this making sure everything works
Oct 18, 2025
8f003ee
Add delay to catch the trace
Oct 19, 2025
ec91b9e
Adding bc for kernel compilation
Oct 19, 2025
d081302
Clean up more compiler warnings
Oct 19, 2025
123edd6
Give every input method a way to reprint the stack trace.
Oct 19, 2025
e22409e
Make UART and Telnet use the original control scheme +p for reprintin…
Oct 20, 2025
02127d5
Change formatting so it displays better on the screen.
Oct 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libxenon.dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM free60/toolchain:latest

RUN apt update && apt install nano && \
RUN apt update && apt install nano bc && \
apt -y clean autoclean autoremove && \
rm -rf /var/lib/{apt,dpkg,cache,log}/

Expand Down
40 changes: 21 additions & 19 deletions libxenon/drivers/console/telnet_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static int session_states = TELNET_DISCONNECTED;

static struct tcp_pcb *tel_pcb;

extern void (*stdout_hook)(const char *buf, int len);
extern void (*stdout_hook)(char *buf, int len);

/**==========================================================================*/
/* Forward Declarations */
Expand Down Expand Up @@ -82,7 +82,7 @@ void telnet_console_close(void) {
}

/*===========================================================================*/
void telnet_console_tx_print(const char *buf, int bc) {
void telnet_console_tx_print(char *buf, int bc) {
TEL_TXST *st;

if (session_states != TELNET_CONNECTED) {
Expand Down Expand Up @@ -140,36 +140,39 @@ static void telnet_send(struct tcp_pcb *pcb, TEL_TXST *st) {
}

//recv buffer ...
int recv_len;
unsigned char recv_buf[512];
int telnet_recv_len;
unsigned char telnet_recv_buf[512];

/*===========================================================================*/
static err_t telnet_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) {

#if 0
if (err == ERR_OK && p != NULL) {
unsigned char * payload = (unsigned char*) p->payload;

tcp_recved(pcb, p->tot_len); /* some recieved data */

//caractere par caractere
if (p->tot_len == 1) {
recv_buf[recv_len] = payload[0];
recv_len++;
telnet_recv_buf[telnet_recv_len] = payload[0];
telnet_recv_len++;
}//par block
else {
memcpy(recv_buf + recv_len, payload, p->tot_len);
recv_len += p->tot_len;
memcpy(telnet_recv_buf + telnet_recv_len, payload, p->tot_len);
telnet_recv_len += p->tot_len;
}

if (recv_len > 2) {
if ((recv_buf[recv_len - 2] == '\r')&(recv_buf[recv_len - 1] == '\n')) {
ParseArgs(recv_buf, recv_len);
//DebugBreak();
//tel_tx_str(recv_buf, recv_len);
//efface
recv_len = 0;
memset(recv_buf, 0, 512);
if (telnet_recv_len > 2) {
if ((telnet_recv_buf[telnet_recv_len - 2] == '\r')&(telnet_recv_buf[telnet_recv_len - 1] == '\n')) {
// ParseArgs(telnet_recv_buf, telnet_recv_len);
// DebugBreak();
// tel_tx_str(telnet_recv_buf, telnet_recv_len);
// efface

// Echo char - optional feedback for the user. All receive buffers will be echoed on a new line.
// telnet_console_tx_print(telnet_recv_buf, telnet_recv_len);

telnet_recv_len = 0;
memset(telnet_recv_buf, 0, 512);
}
}
}
Expand All @@ -178,7 +181,6 @@ static err_t telnet_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t e
if (err == ERR_OK && p == NULL) {
telnet_close(pcb);
}
#endif

return ERR_OK;
}
Expand All @@ -203,4 +205,4 @@ static err_t telnet_accept(void *arg, struct tcp_pcb *pcb, err_t err) {
}

/*===========================================================================*/
/* End of Module */
/* End of Module */
6 changes: 5 additions & 1 deletion libxenon/drivers/console/telnet_console.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ extern "C" {
#endif

void telnet_console_init();
void telnet_console_tx_print(const char *buf, int bc);
void telnet_console_tx_print(char *buf, int bc);
void telnet_console_close();

// Use these in LibXenon programs to get chars or strings from the telnet buffer.
extern int telnet_recv_len;
extern unsigned char telnet_recv_buf[512];

#ifdef __cplusplus
};
#endif
Expand Down
1 change: 1 addition & 0 deletions libxenon/drivers/elf/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
#include <time/time.h>
#include <unistd.h>
#include <xenon_soc/xenon_power.h>
#include <console/console.h>

#include "elf.h"
#include "elf_abi.h"
Expand Down
4 changes: 2 additions & 2 deletions libxenon/drivers/network/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ void network_init()

dhcp_wait=mftb();
int i = 0;
while (netif.ip_addr.addr==0 && i < 60) {
while (netif.ip_addr.addr==0 && i < 90) {
network_poll();
now2=mftb();
if (tb_diff_msec(now2, dhcp_wait) >= 250){
if (tb_diff_msec(now2, dhcp_wait) >= 300){
dhcp_wait=mftb();
i++;
if (i % 2)
Expand Down
94 changes: 85 additions & 9 deletions libxenon/drivers/ppc/c_except.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <console/console.h>
#include <console/telnet_console.h>
#include <input/input.h>
#include <ppc/cache.h>
#include <ppc/register.h>
#include <stdio.h>
Expand All @@ -9,6 +11,8 @@
#include <xenon_uart/xenon_uart.h>
#include <xenos/xenos.h>
#include <xetypes.h>
#include <usb/usbmain.h>
#include <network/network.h>

#define CPU_STACK_TRACE_DEPTH 10

Expand Down Expand Up @@ -76,46 +80,118 @@ void crashdump(u32 exception,u64 * context)
console_set_colors(0x000080ff, 0xffffffff);
console_init();
console_clrscr();

printf("Program crashed - reinitializing hardware in this context...\n");
network_init();
usb_init();
network_print_config();
telnet_console_init();

// Give some extra time to catch the trace
mdelay(3000);

// In case the trace is missed, print it again exactly as it was.
reprint:

if (exception){
sprintf(text,"\nException vector! (%p)\n\n",exception);
}else{
strcpy(text,"\nSegmentation fault!\n\n");
}


printf(text);
flush_console();

sprintf(text,"%spir=%016llx dar=%016llx\nsr0=%016llx sr1=%016llx lr=%016llx\n\n",
text,context[39],context[38],context[36],context[37],context[32]);

printf(text);
flush_console();

int i;
for(i=0;i<8;++i)
sprintf(text,"%s%02d=%016llx %02d=%016llx %02d=%016llx %02d=%016llx\n",
text,i,context[i],i+8,context[i+8],i+16,context[i+16],i+24,context[i+24]);

printf(text);
flush_console();

_cpu_print_stack((void*)(u32)context[36],(void*)(u32)context[32],(void*)(u32)context[1]);

strcat(text,"\n\nOn uart: 'x'=Xell, 'h'=Halt, 'r'=Reboot\n\n");

strcat(text,"\n\nOn controller, UART or telnet: 'x'=Xell, 'y'=Halt, 'b'=Reboot, 'a'=Reprint stack trace.\n");
printf(text);
flush_console();

// Initialize 360 controller - taken from XeLL kbootconf.c
struct controller_data_s ctrl;
struct controller_data_s old_ctrl;

// For telnet handling.
unsigned char latest_telnet_char;

for(;;){
switch(getch()){
case 'x':
// Handle controller
if (get_controller_data(&ctrl, 0)) {
if (ctrl.x){
exit(0);
for(;;);
break;
case 'h':
} if (ctrl.y){
xenon_smc_power_shutdown();
for(;;);
break;
case 'r':
} if (ctrl.b){
xenon_smc_power_reboot();
for(;;);
break;
} if (ctrl.a){
goto reprint;
}
old_ctrl=ctrl;
}

// Controller update
usb_do_poll();

// Telnet update
network_poll();
latest_telnet_char = telnet_recv_buf[0];

// Handle UART
if(kbhit()){
switch(getch()){
case 'x':
// Try reloading XeLL from NAND. (1f, 2f, gggggg)
// Platform specific functioanlity defined in libxenon/drivers/newlib/xenon_syscalls.c
exit(0);
break;
case 'y':
xenon_smc_power_shutdown();
for(;;);
break;
case 'b':
xenon_smc_power_reboot();
for(;;);
break;
case 'a':
goto reprint;
}
}

// Handle telnet
if(latest_telnet_char == 'x'){
exit(0);
for(;;);
break;
} else if(latest_telnet_char == 'y'){
xenon_smc_power_shutdown();
for(;;);
break;
} else if(latest_telnet_char == 'b'){
xenon_smc_power_reboot();
for(;;);
break;
} else if(latest_telnet_char == 'a'){
goto reprint;
}
}
}
1 change: 1 addition & 0 deletions libxenon/drivers/xenon_nand/xenon_sfcx.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <fcntl.h>
#include <time/time.h>
#include <xb360/xb360.h>
#include <string.h>
#include "xenon_sfcx.h"

struct sfc sfc = {0};
Expand Down
3 changes: 2 additions & 1 deletion libxenon/drivers/xenon_soc/xenon_power.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ void xenon_thread_startup(void);
#define XENON_SPEED_FULL 1

void xenon_make_it_faster(int speed);
int xenon_run_thread_task(int thread, void *stack, void *task);
int xenon_run_thread_task(int thread, void *stack, void *task);
int xenon_is_thread_task_running(int thread);
void xenon_sleep_thread(int thread);
void xenon_set_single_thread_mode();
int xenon_get_speed();

#ifdef __cplusplus
};
Expand Down