Skip to content

Commit

Permalink
grey panda detection
Browse files Browse the repository at this point in the history
  • Loading branch information
geohot committed Jan 24, 2018
1 parent b68957e commit f415c9a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions board/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ int has_external_debug_serial = 0;
int is_giant_panda = 0;
int is_entering_bootmode = 0;
int revision = PANDA_REV_AB;
int is_grey_panda = 0;

int detect_with_pull(GPIO_TypeDef *GPIO, int pin, int mode) {
set_gpio_mode(GPIO, pin, MODE_INPUT);
Expand Down Expand Up @@ -45,9 +46,14 @@ void detect() {

// check if the ESP is trying to put me in boot mode
is_entering_bootmode = !detect_with_pull(GPIOB, 0, PULL_UP);

// check if it's a grey panda by seeing if the SPI lines are floating
// TODO: is this reliable?
is_grey_panda = !(detect_with_pull(GPIOA, 4, PULL_DOWN) | detect_with_pull(GPIOA, 5, PULL_DOWN) | detect_with_pull(GPIOA, 6, PULL_DOWN) | detect_with_pull(GPIOA, 7, PULL_DOWN));
#else
// need to do this for early detect
is_giant_panda = 0;
is_grey_panda = 0;
revision = PANDA_REV_AB;
is_entering_bootmode = 0;
#endif
Expand Down
1 change: 1 addition & 0 deletions board/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ int main() {
#endif
puts(has_external_debug_serial ? " real serial\n" : " USB serial\n");
puts(is_giant_panda ? " GIANTpanda detected\n" : " not GIANTpanda\n");
puts(is_grey_panda ? " gray panda detected!\n" : " white panda\n");
puts(is_entering_bootmode ? " ESP wants bootmode\n" : " no bootmode\n");
gpio_init();

Expand Down

0 comments on commit f415c9a

Please sign in to comment.