Hello,
Since I have the Nano, I noticed every time the target start running both led’s become active.
I was reading the source code and, at least, in basic-passwdcheck.c are several calls to led_ok() and led_error(), but the state of leds didn’t change.
I noticed this when tried to go beyond the tutorial, I wanted to try with a longer password, to make a noticeable difference I added more ‘grabage’ after the password comparison, some delays, some uart messages and some led action…
But leds didn’t work as expedted.
I wanted to find the root of the problem, and found that always a firmware starts it calls the function trigger_setup() among others.
I found this function is declared on the file /hardware/victims/firmware/hal/stm32f0_nano/stm32f0_hal_nano.c but this function is not only setting up GPIO_PIN_7 as trigger pin, it also power on both leds on the target board declared
void trigger_setup(void)
{
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitTypeDef GpioInit;
GpioInit.Pin = GPIO_PIN_7;
GpioInit.Mode = GPIO_MODE_OUTPUT_PP;
GpioInit.Pull = GPIO_NOPULL;
GpioInit.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOA, &GpioInit);
GpioInit.Pin = GPIO_PIN_4;
GpioInit.Mode = GPIO_MODE_OUTPUT_PP;
GpioInit.Pull = GPIO_NOPULL;
GpioInit.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOA, &GpioInit);
GpioInit.Pin = GPIO_PIN_2;
GpioInit.Mode = GPIO_MODE_OUTPUT_PP;
GpioInit.Pull = GPIO_NOPULL;
GpioInit.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOA, &GpioInit);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_7, RESET);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, SET);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, RESET); //Chaged to test behaviour
}
If I delete the call to trigger_setup() function, leds never power on. if instead I set as you see in the pasted text, the led_ok is powered off and led_error is on, but no matter what I program on the target’s firmware, my leds never change once the boot of the chip starts…
I modified basic-passwdcheck.c to do this after good password input, because also added password length check, and needed bigger difference between ‘failed or granted access’
led_error(0);
led_ok(1);
my_puts("Access granted, Welcome!\n");
led_ok(1);
my_puts("________________________\n");
my_puts("\n");
my_puts("\n");
my_puts("Sistema de venta por correo a tuttiplén\n");
delay_2_ms();
delay_2_ms();
led_ok(0);
my_puts("Arrancando sistemas....\n");
my_puts("\n");
for(int i=0; i<100;i++){
delay_2_ms();
delay_2_ms();
}
led_ok(1);
for(int i=0; i<100;i++){
delay_2_ms();
delay_2_ms();
}
led_ok(0);
my_puts("Sistema de venta cargado.\n");
my_puts("\n");
for(int i=0; i<100;i++){
delay_2_ms();
delay_2_ms();
}