remove printf references, add bootloader script, merge hex files
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
#define DEBUG_UART USART1
|
||||
|
||||
#define DEBUG_LEVEL 1
|
||||
#define DEBUG_LEVEL 0
|
||||
|
||||
#define NON_BLOCK_PRINTING 0
|
||||
|
||||
|
@@ -88,6 +88,10 @@ void device_set_status(int status)
|
||||
__device_status = status;
|
||||
}
|
||||
|
||||
int device_is_button_pressed()
|
||||
{
|
||||
return IS_BUTTON_PRESSED();
|
||||
}
|
||||
|
||||
void delay(uint32_t ms)
|
||||
{
|
||||
@@ -95,7 +99,10 @@ void delay(uint32_t ms)
|
||||
while ((millis() - time) < ms)
|
||||
;
|
||||
}
|
||||
void device_reboot()
|
||||
{
|
||||
|
||||
}
|
||||
void device_init()
|
||||
{
|
||||
hw_init();
|
||||
@@ -111,8 +118,10 @@ void device_init()
|
||||
printf1(TAG_GEN,"hello solo\r\n");
|
||||
}
|
||||
|
||||
void usb_init(void);
|
||||
void usbhid_init()
|
||||
{
|
||||
usb_init();
|
||||
printf1(TAG_GEN,"hello solo\r\n");
|
||||
}
|
||||
int usbhid_recv(uint8_t * msg)
|
||||
@@ -543,7 +552,7 @@ static void authorize_application()
|
||||
ptr = (uint32_t *)AUTH_WORD_ADDR;
|
||||
flash_write((uint32_t)ptr, (uint8_t *)&zero, 4);
|
||||
}
|
||||
static int is_authorized_to_boot()
|
||||
int is_authorized_to_boot()
|
||||
{
|
||||
uint32_t * auth = (uint32_t *)AUTH_WORD_ADDR;
|
||||
return *auth == 0;
|
||||
@@ -558,7 +567,6 @@ int bootloader_bridge(uint8_t klen, uint8_t * keyh)
|
||||
uint8_t * pubkey = (uint8_t*)"\x57\xe6\x80\x39\x56\x46\x2f\x0c\x95\xac\x72\x71\xf0\xbc\xe8\x2d\x67\xd0\x59\x29\x2e\x15\x22\x89\x6a\xbd\x3f\x7f\x27\xf3\xc0\xc6\xe2\xd7\x7d\x8a\x9f\xcc\x53\xc5\x91\xb2\x0c\x9c\x3b\x4e\xa4\x87\x31\x67\xb4\xa9\x4b\x0e\x8d\x06\x67\xd8\xc5\xef\x2c\x50\x4a\x55";
|
||||
const struct uECC_Curve_t * curve = NULL;
|
||||
|
||||
/*printf("bootloader_bridge\n");*/
|
||||
if (req->len > 255-9)
|
||||
{
|
||||
return CTAP1_ERR_INVALID_LENGTH;
|
||||
@@ -573,7 +581,6 @@ int bootloader_bridge(uint8_t klen, uint8_t * keyh)
|
||||
|
||||
switch(req->op){
|
||||
case BootWrite:
|
||||
/*printf("BootWrite 0x%08x\n", addr);*/
|
||||
if ((uint32_t)ptr < APPLICATION_START_ADDR || (uint32_t)ptr >= APPLICATION_END_ADDR)
|
||||
{
|
||||
return CTAP2_ERR_NOT_ALLOWED;
|
||||
@@ -592,13 +599,10 @@ int bootloader_bridge(uint8_t klen, uint8_t * keyh)
|
||||
flash_write((uint32_t)ptr,payload, req->len + (req->len%4));
|
||||
break;
|
||||
case BootDone:
|
||||
// printf("BootDone\n");
|
||||
ptr = (uint32_t *)APPLICATION_START_ADDR;
|
||||
crypto_sha256_init();
|
||||
crypto_sha256_update(ptr, APPLICATION_END_ADDR-APPLICATION_START_ADDR);
|
||||
crypto_sha256_final(hash);
|
||||
// printf("hash: "); dump_hex(hash, 32);
|
||||
// printf("sig: "); dump_hex(payload, 64);
|
||||
curve = uECC_secp256r1();
|
||||
|
||||
if (! uECC_verify(pubkey,
|
||||
@@ -613,11 +617,9 @@ int bootloader_bridge(uint8_t klen, uint8_t * keyh)
|
||||
REBOOT_FLAG = 1;
|
||||
break;
|
||||
case BootCheck:
|
||||
/*printf("BootCheck\n");*/
|
||||
return 0;
|
||||
break;
|
||||
case BootErase:
|
||||
/*printf("BootErase\n");*/
|
||||
erase_application();
|
||||
return 0;
|
||||
break;
|
||||
@@ -627,6 +629,26 @@ int bootloader_bridge(uint8_t klen, uint8_t * keyh)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bootloader_heartbeat()
|
||||
{
|
||||
static int state = 0;
|
||||
static uint32_t val = 0x10;
|
||||
int but = IS_BUTTON_PRESSED();
|
||||
|
||||
if (state)
|
||||
{
|
||||
val--;
|
||||
}
|
||||
else
|
||||
{
|
||||
val++;
|
||||
}
|
||||
|
||||
if (val > 30 || val < 1)
|
||||
{
|
||||
state = !state;
|
||||
}
|
||||
led_rgb((val * 3)<<8 | (val*10) << 16);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include "fifo.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
FIFO_CREATE(debug,4096,1)
|
||||
@@ -16,7 +17,7 @@ void fifo_test()
|
||||
uint8_t data[10][100];
|
||||
uint8_t verif[10][100];
|
||||
|
||||
printf("init\r\n");
|
||||
printf1(TAG_GREEN,"init\r\n");
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
memset(data[i],i,100);
|
||||
@@ -24,43 +25,43 @@ void fifo_test()
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
printf("rhead: %d, whead: %d\r\n", fifo_test_rhead(), fifo_test_whead());
|
||||
printf1(TAG_GREEN,"rhead: %d, whead: %d\r\n", fifo_test_rhead(), fifo_test_whead());
|
||||
ret = fifo_test_add(data[i]);
|
||||
printf("%d\r\n",i);
|
||||
printf1(TAG_GREEN,"%d\r\n",i);
|
||||
if (ret != 0)
|
||||
{
|
||||
printf("fifo_test_add fail\r\n");
|
||||
printf1(TAG_GREEN,"fifo_test_add fail\r\n");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
printf("rhead: %d, whead: %d\r\n", fifo_test_rhead(), fifo_test_whead());
|
||||
printf1(TAG_GREEN,"rhead: %d, whead: %d\r\n", fifo_test_rhead(), fifo_test_whead());
|
||||
ret = fifo_test_take(verif[i]);
|
||||
printf("%d\r\n",i );
|
||||
printf1(TAG_GREEN,"%d\r\n",i );
|
||||
if (ret != 0)
|
||||
{
|
||||
printf("fifo_test_take fail\r\n");
|
||||
printf1(TAG_GREEN,"fifo_test_take fail\r\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (memcmp(verif[i], data[i], 100) != 0)
|
||||
{
|
||||
printf("fifo_test_take result fail\r\n");
|
||||
dump_hex(data[i],100);
|
||||
dump_hex(verif[i],100);
|
||||
printf1(TAG_GREEN,"fifo_test_take result fail\r\n");
|
||||
dump_hex1(TAG_GREEN,data[i],100);
|
||||
dump_hex1(TAG_GREEN,verif[i],100);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
printf("rhead: %d, whead: %d\r\n", fifo_test_rhead(), fifo_test_whead());
|
||||
printf1(TAG_GREEN,"rhead: %d, whead: %d\r\n", fifo_test_rhead(), fifo_test_whead());
|
||||
ret = fifo_test_add(data[i]);
|
||||
if (ret != 0)
|
||||
{
|
||||
printf("fifo_test_add 2 fail\r\n");
|
||||
printf1(TAG_GREEN,"fifo_test_add 2 fail\r\n");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
@@ -68,7 +69,7 @@ void fifo_test()
|
||||
ret = fifo_test_add(data[0]);
|
||||
if (ret == 0)
|
||||
{
|
||||
printf("fifo_test_add should have failed\r\n");
|
||||
printf1(TAG_GREEN,"fifo_test_add should have failed\r\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -76,17 +77,17 @@ void fifo_test()
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
printf("rhead: %d, whead: %d\r\n", fifo_test_rhead(), fifo_test_whead());
|
||||
printf1(TAG_GREEN,"rhead: %d, whead: %d\r\n", fifo_test_rhead(), fifo_test_whead());
|
||||
ret = fifo_test_take(verif[i]);
|
||||
if (ret != 0)
|
||||
{
|
||||
printf("fifo_test_take fail\r\n");
|
||||
printf1(TAG_GREEN,"fifo_test_take fail\r\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (memcmp(verif[i], data[i], 100) != 0)
|
||||
{
|
||||
printf("fifo_test_take result fail\r\n");
|
||||
printf1(TAG_GREEN,"fifo_test_take result fail\r\n");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
@@ -94,11 +95,11 @@ void fifo_test()
|
||||
ret = fifo_test_take(verif[0]);
|
||||
if (ret == 0)
|
||||
{
|
||||
printf("fifo_test_take should have failed\r\n");
|
||||
printf1(TAG_GREEN,"fifo_test_take should have failed\r\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
printf("test pass!\r\n");
|
||||
printf1(TAG_GREEN,"test pass!\r\n");
|
||||
return ;
|
||||
fail:
|
||||
while(1)
|
||||
|
@@ -38,7 +38,6 @@ static void MX_USART1_UART_Init(void);
|
||||
static void MX_TIM2_Init(void);
|
||||
static void MX_TIM6_Init(void);
|
||||
static void MX_RNG_Init(void);
|
||||
static void usb_init();
|
||||
|
||||
#define Error_Handler() _Error_Handler(__FILE__,__LINE__)
|
||||
void _Error_Handler(char *file, int line);
|
||||
@@ -91,7 +90,7 @@ void hw_init(void)
|
||||
__enable_irq();
|
||||
NVIC_EnableIRQ(TIM6_IRQn);
|
||||
#ifndef TEST_SOLO_STM32
|
||||
usb_init();
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -202,7 +201,7 @@ void SystemClock_Config(void)
|
||||
NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0));
|
||||
}
|
||||
|
||||
static void usb_init()
|
||||
void usb_init()
|
||||
{
|
||||
USBD_Init(&Solo_USBD_Device, &Solo_Desc, 0);
|
||||
USBD_RegisterClass(&Solo_USBD_Device, &USBD_HID);
|
||||
|
Reference in New Issue
Block a user