Skip to content

Commit

Permalink
update E9 bug replication with additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DESKTOP-M9CCUTI\ian committed Aug 28, 2024
1 parent b55516c commit e621c44
Showing 1 changed file with 48 additions and 11 deletions.
59 changes: 48 additions & 11 deletions commands/global/bug.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,33 @@ static const struct ui_help_options options[] = {
{ 0, "-h", T_HELP_FLAG },
};

void bug_e9 (bool pullup){
printf("Disabling Bus Pirate pull-ups\r\n");
pullup_disable();
printf("Making IO0 buffer and GPIO input\r\n");
bio_input(BIO0);
busy_wait_ms(10);
printf("Making IO0 buffer an output\r\n");
bio_buf_output(BIO0);
busy_wait_ms(10);
printf("GPIO pin should be 0: %d\r\n", bio_get(BIO0));
printf("Making IO0 buffer and GPIO input\r\n");
bio_input(BIO0);
if(pullup){
printf("Enabling Bus Pirate pull-ups\r\n");
pullup_enable();
}
printf("Making IO0 buffer an output\r\n");
bio_buf_output(BIO0);
printf("Disabling Bus Pirate pull-ups\r\n");
pullup_disable();
busy_wait_ms(10);
printf("GPIO pin should be 0: %d\r\n", bio_get(BIO0));
if(bio_get(BIO0)){
printf("GPIO is 1, E9 found\r\n");
}
}

void bug_handler(struct command_result* res) {
if (ui_help_show(res->help_flag, usage, count_of(usage), options, count_of(options))) {
return;
Expand All @@ -36,27 +63,37 @@ void bug_handler(struct command_result* res) {

if(verb_e9) {

printf("Repeat bug E9\r\n");
printf("Replicate bug E9\r\n");
uint32_t vout, isense, vreg;
bool fuse;
psu_measure(&vout, &isense, &vreg, &fuse);
if(vout<800){
printf("Enable a power supply with the 'W' command.\r\n");
return;
}
//gpio_disable_pulls(pin_scl);
printf("Making IO0 buffer and GPIO input\r\n");
bio_input(BIO0);
printf("Enabling Bus Pirate pull-ups\r\n");
pullup_enable();
printf("Making IO0 buffer an output\r\n");
bio_buf_output(BIO0);
printf("Disabling Bus Pirate pull-ups\r\n");
pullup_disable();
printf("\r\nTest 1:\r\n");
printf("Pull-down disabled...\r\n");
gpio_disable_pulls(bio2bufiopin[BIO0]);
bug_e9(true);

printf("\r\nTest 2:\r\n");
printf("Set pulls disabled...\r\n");
gpio_set_pulls(bio2bufiopin[BIO0], false, false);
bug_e9(true);

printf("\r\nTest 3:\r\n");
bug_e9(true);
printf("GPIO.IE = false...\r\n");
gpio_set_input_enabled(bio2bufiopin[BIO0], false);
busy_wait_ms(10);
printf("GPIO pin should be 0: %d\r\n", bio_get(BIO0));
if(bio_get(BIO0)){
printf("GPIO is 1, E9 found\n");
printf("GPIO is 1, E9 found\r\n");
}

printf("\r\nTest 4:\r\n");
printf("Strong low test...\r\n");
gpio_set_input_enabled(bio2bufiopin[BIO0], true);
bug_e9(false);
}
}

0 comments on commit e621c44

Please sign in to comment.