length param sweeping

This commit is contained in:
Triss 2022-03-03 23:44:50 +01:00
parent 829c665e23
commit c36edac371
2 changed files with 17 additions and 8 deletions

View File

@ -20,7 +20,7 @@ void cli_tool78_glitch_paramsearch(void);
void cli_tool78_glitch_ocd_dump(void);
#define DUMP_OFFSET 0/*0xef000*/
#define DUMP_SIZE 4096
#define DUMP_SIZE 65536
// test with decoupling caps: length in 20..500(..1500) -> ok
// testing on ocd lock: length: 5..35

View File

@ -46,18 +46,25 @@ static void CORE1_FUNC(pcg32_fast_init)(uint64_t seed) {
(void)pcg32_fast();
}
// ADC value is in low 12 bits of adc_read()
// FIXME: length_min_us = -1 => adc breaks? | oops was signedness bug
#define CORE1_PRE_CALC() /* BIG TODO HERE! */ \
uint32_t off = param_cur.offset_min_us + \
bool sweep = param_cur.offset_min_us == param_cur.offset_max_us \
&& param_cur.length_min_us >= 0; \
uint32_t len, off = param_cur.offset_min_us + \
(pcg32_fast() % (param_cur.offset_max_us - param_cur.offset_min_us)), \
len = (param_cur.length_min_us < 0) \
? (((uint32_t)adc_read() * param_cur.length_max_us) >> 12) \
iom = 1u << param_cur.glitch_out_pin; \
do { \
if (sweep) { \
if (len_prev == param_cur.length_max_us) len_prev = (len = param_cur.length_min_us); \
else len = (len_prev = (len_prev + 1));\
} else { \
len = (param_cur.length_min_us < 0) \
? (((uint32_t)adc_read() * param_cur.length_max_us) >> 12) \
: (param_cur.length_min_us + (pcg32_fast() % \
(param_cur.length_max_us - param_cur.length_min_us))), \
iom = 1u << param_cur.glitch_out_pin \
(param_cur.length_max_us - param_cur.length_min_us))); \
} \
} while (0) \
#define CORE1_DO_GLITCH() \
do { \
@ -74,6 +81,8 @@ static void CORE1_FUNC(glitch_core1_thread)(void) {
// SRAM 5 to avoid bus contention
pcg32_fast_init(random());
int32_t len_prev = param_cur.length_min_us - 1;
__disable_irq();
if (param_cur.trigger_in_pin < 0) {