Author SHA1 Message Date
rehius 1a39e9b46d Update glitch.c 2023-05-26 22:54:08 +00:00
rehius 25d9389924 Update config.h 2023-05-26 22:46:15 +00:00
rehius b3c0af112c Update pio_upload.c 2023-05-26 22:45:56 +00:00
rehius ef474b7f20 Update misc.c 2023-05-26 22:45:24 +00:00
rehius e98219c475 Update emmc.pio 2023-05-26 22:44:53 +00:00
rehius 7ca69d4b76 Update main.c 2023-05-26 22:44:24 +00:00
6 changed files with 28 additions and 29 deletions

No files matched your search

+3 -3
View File
@@ -1,10 +1,10 @@
#include "hardware/flash.h"
#define OFFSET_DIV 10
#define OFFSET_MIN 6200
#define OFFSET_MAX 6900
#define OFFSET_MIN 9200
#define OFFSET_MAX 10300
#define VER_HI 2
#define VER_LO 73
#define VER_LO 74
bool is_configured();
void init_config();
+8 -12
View File
@@ -57,17 +57,13 @@ read_loop:
.program glitch_dat_waiter
.wrap_target
mov x, y ; data length pre-loaded counter (512 + 16 - 1)
wait_for_start_bit:
wait 0 pin, 30
wait 1 pin, 30
jmp pin wait_for_start_bit ; wait for dat start bit of the rising edge
wait 0 pin, 30
skip_loop_dat:
wait 1 pin, 30
;in pins, 1 ; data sniffer (not needed anymore)
wait 0 pin, 30
jmp x-- skip_loop_dat ; skip the required data ticks
mov x, y ; data length pre-loaded counter (512 + 16 - 1) * 8
wait_for_zero_filtered:
jmp pin, wait_for_zero_filtered
jmp pin, wait_for_zero_filtered
jmp pin, wait_for_zero_filtered
wait_for_data_pack:
jmp x-- wait_for_data_pack
irq clear 1 ; 'data transfer done' trigger
.wrap
@@ -84,4 +80,4 @@ wait_for_timing:
jmp x--, wait_for_timing side 0
glitch_en:
jmp y--, glitch_en side 1
.wrap
.wrap
+5 -6
View File
@@ -145,13 +145,12 @@ void inc_tries()
}
// random() for glitch offset array generation
static uint32_t get_random_word() {
static uint32_t get_random_word(int cycles) {
uint32_t byte;
int cycles = 32;
assert(rosc_hw->status & ROSC_STATUS_ENABLED_BITS);
for(int i=0; i < cycles; i++) {
byte = ((byte << 1) | rosc_hw->randombit);
busy_wait_at_least_cycles(100);
byte = ((byte << 1) | rosc_hw->randombit);
}
return byte;
}
@@ -162,7 +161,7 @@ void prepare_random_array()
for(int i = 0; i < OFFSET_CNT; i++)
offsets_array[i] = OFFSET_MIN + OFFSET_DIV*i;
for (int i = OFFSET_CNT - 1; i > 0; i--) {
size_t j = get_random_word() % (i+1);
size_t j = get_random_word(32) % (i+1);
int t = offsets_array[j];
offsets_array[j] = offsets_array[i];
offsets_array[i] = t;
@@ -178,7 +177,7 @@ bool glitch_try_offset(int offset, int * width, int edge_limit) {
inc_tries();
while (1) {
reset_cpu();
int gres = do_glitch(offset, *width, 300, 6);
int gres = do_glitch(offset + get_random_word(3), *width, 300, 6);
if (gres == GLITCH_RESULT_MISSING)
missing_count +=1; // MMC has failed to initialize
else
@@ -211,4 +210,4 @@ bool glitch_try_offset(int offset, int * width, int edge_limit) {
if (edges > edge_limit) // this offset did not work
return false;
}
}
}
+2 -2
View File
@@ -21,10 +21,10 @@
bool write_payload();
// overclock to 200 MHz, pretty stable & enough for the glitch
// overclock to 300 MHz
void init_system() {
vreg_set_voltage(VREG_VOLTAGE_1_30);
set_sys_clock_khz(200000, true);
set_sys_clock_khz(300000, true);
}
// filled within "fast check" on eMMC init
+6 -2
View File
@@ -84,8 +84,12 @@ void halt_with_error(uint32_t err, uint32_t bits)
{
bool is_long = err & (1 << (bits - i - 1));
sleep_ms(is_long ? LONG_PAUSE_TIME : SHORT_PAUSE_TIME);
put_pixel(PIX_yel);
sleep_ms(is_long ? LONG_TIME : SHORT_TIME);
bool success = bits == 1 && is_long == 0;
if (success)
put_pixel(PIX_whi);
else
put_pixel(PIX_yel);
sleep_ms(is_long ? LONG_TIME : success ? SHORT_TIME * 2 : SHORT_TIME);
put_pixel(0);
if (i != bits - 1 || j != CODE_REPEATS - 1)
sleep_ms(is_long ? LONG_PAUSE_TIME : SHORT_PAUSE_TIME);
+4 -4
View File
@@ -43,9 +43,9 @@ void upload_pio()
// MMC DAT sniffer
dsniff_pio_offset = pio_add_program(pio1, &glitch_dat_waiter_program);
pio1->sm[G_DAT0_SM].shiftctrl = c.shiftctrl;
// set y to amount of data ticks to skip (512 + 16 - 1)
val = 527;
for (int i = 2; i >= 0; i--) {
// set y to amount of data ticks to skip
val = 528 * 300 / 25;
for (int i = 5; i >= 0; i--) {
pio_sm_exec(pio1, G_DAT0_SM, pio_encode_set(pio_y, (val >> i*4) & 15));
pio_sm_exec(pio1, G_DAT0_SM, pio_encode_in(pio_y, 4));
}
@@ -58,4 +58,4 @@ void upload_pio()
clk_pio_offset = pio_add_program(pio0, &sd_clk_program);
sdout_pio_offset = pio_add_program(pio0, &out_cmd_or_dat_program);
sdin_pio_offset = pio_add_program(pio0, &in_cmd_or_dat_program);
}
}