mirror of
git://projects.qi-hardware.com/antorcha.git
synced 2024-11-22 06:54:40 +02:00
fw/: move secrets to secret.c; rename reset secret to maintenance secret
This commit is contained in:
parent
1a8bfd4684
commit
6fac517d48
@ -31,7 +31,7 @@ OBJCOPY = $(AVR_PREFIX)objcopy
|
|||||||
SIZE = $(AVR_PREFIX)size
|
SIZE = $(AVR_PREFIX)size
|
||||||
|
|
||||||
OBJS = $(NAME).o accel.o dispatch.o hash.o image.o param.o \
|
OBJS = $(NAME).o accel.o dispatch.o hash.o image.o param.o \
|
||||||
reset.o sample.o sweep.o \
|
reset.o sample.o secret.o sweep.o \
|
||||||
$(COMMON_OBJS)
|
$(COMMON_OBJS)
|
||||||
BOOT_OBJS = boot.o flash.o fw.o $(COMMON_OBJS)
|
BOOT_OBJS = boot.o flash.o fw.o $(COMMON_OBJS)
|
||||||
COMMON_OBJS = rf.o spi.o
|
COMMON_OBJS = rf.o spi.o
|
||||||
|
@ -15,12 +15,11 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
|
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include "dispatch.h"
|
#include "dispatch.h"
|
||||||
|
#include "secret.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
|
||||||
|
|
||||||
@ -32,11 +31,6 @@ static bool failed;
|
|||||||
const struct line *image = images[0];
|
const struct line *image = images[0];
|
||||||
|
|
||||||
|
|
||||||
const uint8_t image_secret[2*PAYLOAD] PROGMEM = {
|
|
||||||
#include "image-secret.inc"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#define MAP(port, value, group) ( \
|
#define MAP(port, value, group) ( \
|
||||||
((value) & 1 ? MASK(port, LED_##group##1) : 0) | \
|
((value) & 1 ? MASK(port, LED_##group##1) : 0) | \
|
||||||
((value) & 2 ? MASK(port, LED_##group##2) : 0) | \
|
((value) & 2 ? MASK(port, LED_##group##2) : 0) | \
|
||||||
|
@ -14,13 +14,8 @@
|
|||||||
#ifndef IMAGE_H
|
#ifndef IMAGE_H
|
||||||
#define IMAGE_H
|
#define IMAGE_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
|
|
||||||
#include "proto.h"
|
|
||||||
|
|
||||||
|
|
||||||
struct line {
|
struct line {
|
||||||
uint8_t d; /* port D0-D7 */
|
uint8_t d; /* port D0-D7 */
|
||||||
@ -29,6 +24,5 @@ struct line {
|
|||||||
|
|
||||||
|
|
||||||
extern const struct line *image;
|
extern const struct line *image;
|
||||||
extern const uint8_t image_secret[2*PAYLOAD] PROGMEM;
|
|
||||||
|
|
||||||
#endif /* !IMAGE_H */
|
#endif /* !IMAGE_H */
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
#include "sweep.h"
|
#include "sweep.h"
|
||||||
#include "image.h"
|
#include "secret.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include "dispatch.h"
|
#include "dispatch.h"
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include "dispatch.h"
|
#include "dispatch.h"
|
||||||
|
#include "secret.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -34,14 +35,10 @@
|
|||||||
* intercept the secret(s) either way.
|
* intercept the secret(s) either way.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const uint8_t reset_secret[PAYLOAD] PROGMEM = {
|
|
||||||
#include "unlock-secret.inc"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static bool reset_first(uint8_t limit, const uint8_t *payload)
|
static bool reset_first(uint8_t limit, const uint8_t *payload)
|
||||||
{
|
{
|
||||||
if (memcmp_P(payload, reset_secret, PAYLOAD))
|
if (memcmp_P(payload, maint_secret, PAYLOAD))
|
||||||
return 0;
|
return 0;
|
||||||
WDTCSR = 1 << WDE;
|
WDTCSR = 1 << WDE;
|
||||||
return 1;
|
return 1;
|
||||||
|
29
fw/secret.c
Normal file
29
fw/secret.c
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* fw/secret.c - Shared authentication secrets
|
||||||
|
*
|
||||||
|
* Written 2012 by Werner Almesberger
|
||||||
|
* Copyright 2012 Werner Almesberger
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
|
#include "proto.h"
|
||||||
|
#include "secret.h"
|
||||||
|
|
||||||
|
|
||||||
|
const uint8_t maint_secret[PAYLOAD] PROGMEM = {
|
||||||
|
#include "unlock-secret.inc"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const uint8_t image_secret[2*PAYLOAD] PROGMEM = {
|
||||||
|
#include "image-secret.inc"
|
||||||
|
};
|
27
fw/secret.h
Normal file
27
fw/secret.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* fw/secret.h - Shared authentication secrets
|
||||||
|
*
|
||||||
|
* Written 2012 by Werner Almesberger
|
||||||
|
* Copyright 2012 Werner Almesberger
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef SECRET_H
|
||||||
|
#define SECRET_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
|
#include "proto.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern const uint8_t maint_secret[PAYLOAD] PROGMEM;
|
||||||
|
extern const uint8_t image_secret[2*PAYLOAD] PROGMEM;
|
||||||
|
|
||||||
|
#endif /* !SECRET_H */
|
Loading…
Reference in New Issue
Block a user