Skip to content

Commit

Permalink
OTP dumping
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyquagsire23 committed Apr 25, 2023
1 parent e250124 commit 07afb41
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
11 changes: 6 additions & 5 deletions pico_defuse/miniterm_defuse.py
Expand Up @@ -512,12 +512,13 @@ def reader(self):
# read all that is there or wait for one byte
data = self.serial.read(self.serial.in_waiting or 1)
if data:
self.serial_data_nowipe += list(data)
self.serial_data_nowipe = self.serial_data_nowipe[-16:]
for b in list(data):
self.serial_data_nowipe += [b]
self.serial_data_nowipe = self.serial_data_nowipe[-16:]

#print (self.serial_data_nowipe[-12:], self.serial_data_nowipe[-12:] == MAGIC_UPLD)
if self.serial_data_nowipe[-12:] == MAGIC_UPLD:
self.upload_file_by_name("/Users/maxamillion/workspace/minute_minute/fw.img")
#print (self.serial_data_nowipe[-12:], self.serial_data_nowipe[-12:] == MAGIC_UPLD)
if self.serial_data_nowipe[-12:] == MAGIC_UPLD:
self.upload_file_by_name("/Users/maxamillion/workspace/minute_minute/fw.img")
if self.raw:
self.console.write_bytes(data)
else:
Expand Down
39 changes: 27 additions & 12 deletions pico_defuse/src/pico_defuse.c
Expand Up @@ -119,7 +119,7 @@ const uint8_t MONITOR_SERIAL_DATA_MAGIC[12] = {0x55, 0xAA, 0x55, 0xAA, 0x55, 0xA
const uint8_t MONITOR_SERIAL_TEXT_MAGIC[12] = {0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0xF0, 0x0F, 0xCA, 0xFE};
const uint8_t MONITOR_PARALLEL_DATA_MAGIC[12] = {0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0xBE, 0xEF, 0xBE, 0xEF};
const uint8_t MONITOR_RESET_MAGIC[12] = {0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x4E, 0x52, 0x53, 0x54};

const uint8_t MONITOR_RESET_PRSHHAX_MAGIC[12] = {0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x50, 0x52, 0x53, 0x48};

char text_buffer[2048];
int text_buffer_pos = 0;
Expand Down Expand Up @@ -245,6 +245,24 @@ void slow_one_time_init()
channel_config_set_dreq(&debug_gpio_monitor_dmacfg, pio_get_dreq(pio, debug_gpio_monitor_parallel_sm, false));
}

void do_normal_reset()
{
// Disable NRST sensing and take control of the line.
nrst_sense_set(false);

gpio_put(PIN_NRST, false);
for(int i = 0; i < 0x100; i++)
{
__asm volatile ("\n");
}
gpio_put(PIN_NRST, true);
for(int i = 0; i < 0x100; i++)
{
__asm volatile ("\n");
}
next_wiiu_state = WIIU_STATE_NORMAL_BOOT;
}

void de_fuse()
{
// Disable NRST sensing and take control of the line.
Expand Down Expand Up @@ -398,17 +416,7 @@ void de_fuse()
// If no SD card is inserted, or an invalid one is inserted, boot0 stalls.
if (!winner && error_code == 0x00 && !only_zeros) {
printf("SD card not valid or not inserted, doing a normal boot.\n");
gpio_put(PIN_NRST, false);
for(int i = 0; i < 0x100; i++)
{
__asm volatile ("\n");
}
gpio_put(PIN_NRST, true);
for(int i = 0; i < 0x100; i++)
{
__asm volatile ("\n");
}
next_wiiu_state = WIIU_STATE_NORMAL_BOOT;
do_normal_reset();
}

if (!winner && only_zeros) {
Expand Down Expand Up @@ -462,6 +470,13 @@ void wiiu_serial_monitor()
printf("[Pico] Console requested reset...\n");
sleep_ms(500); // give it a delay
}
else if (!memcmp(last_16_bytes+4, MONITOR_RESET_PRSHHAX_MAGIC, 12))
{
printf("[Pico] Console requested prshhax prshhax reset...\n");
do_normal_reset();
sleep_ms(3000); // give it a delay
next_wiiu_state = WIIU_STATE_NEEDS_DEFUSE;
}
else if (!memcmp(last_16_bytes+4, MONITOR_PARALLEL_DATA_MAGIC, 12)) {
debug_gpio_monitor_parallel_program_init(pio, debug_gpio_monitor_parallel_sm, debug_gpio_monitor_parallel_offset, PIN_DEBUGLED_BASE, PIN_SERIALOUT_BASE, 1.0);
current_mode = MONITOR_SERIAL_DATA;
Expand Down

0 comments on commit 07afb41

Please sign in to comment.