Added configure and DFU support.

This commit is contained in:
NIIBE Yutaka
2010-10-14 17:08:09 +09:00
parent 1f2721a493
commit 7ea6e2089a
12 changed files with 184 additions and 40 deletions

View File

@@ -1,8 +1,6 @@
# Makefile for Gnuk
#
ENABLE_DEBUG=1
@DEBUG_MAKE_OPTION@
ifneq ($(ENABLE_DEBUG),)
ENABLE_VCOMPORT=1
endif
@@ -73,7 +71,7 @@ include $(CHIBIOS)/os/kernel/kernel.mk
include stmusb.mk
include vcomport.mk
include crypt.mk
include ../boards/OLIMEX_STM32_H103/board.mk
include @BOARD_MAKEFILE@
# C sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
@@ -151,11 +149,7 @@ CPPWARN = -Wall -Wextra
#
# List all default C defines here, like -D_DEBUG=1
ifeq ($(ENABLE_DEBUG),)
DDEFS = -DCORTEX_USE_BASEPRI=TRUE
else
DDEFS = -DCORTEX_USE_BASEPRI=TRUE -DDEBUG
endif
# List all default ASM defines here, like -D_DEBUG=1
DADEFS =
@@ -218,3 +212,6 @@ random-data.o: random_bits
$@
$(PROJECT).elf: random-data.o
distclean: clean
-rm -f Makefile gnuk.ld config.h

View File

@@ -1,3 +1,4 @@
@DEBUG_DEFINE@
#ifdef DEBUG
#define ENABLE_VIRTUAL_COM_PORT 1
#endif
@@ -11,3 +12,5 @@
#endif
#define SERIAL_NUMBER_IN_AID 0x00, 0x00, 0x00, 0x01
@DFU_DEFINE@

113
src/configure vendored Executable file
View File

@@ -0,0 +1,113 @@
#! /bin/sh
#
# This file is *NOT* generated by GNU Autoconf, but written by NIIBE Yutaka
#
# Copyright (C) 2010 Free Software Initiative of Japan
#
# This file is a part of Gnuk, a GnuPG USB Token implementation.
# Gnuk 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 3 of the License, or
# (at your option) any later version.
#
# Gnuk is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Default settings
help=no
target=OLIMEX_STM32_H103
verbose=no
with_dfu=no
debug=no
# Process each option
for option; do
case $option in
*=*) optarg=`expr "X$option" : '[^=]*=\(.*\)'` ;;
*) optarg=yes ;;
esac
case $option in
-h | --help)
help=yes ;;
--target=*)
target=$optarg ;;
-v | --verbose)
verbose=yes ;;
--enable-debug)
debug=yes;;
--disable-debug)
debug=no;;
--with-dfu)
with_dfu=yes ;;
--without-dfu)
with_dfu=no ;;
*)
echo "Unrecognized option \`$option'" >&2
echo "Try \`$0 --help' for more information." >&2
exit 1
;;
esac
done
if test "$help" = "yes"; then
cat <<EOF
Usage: $0 [OPTION]...
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit [no]
--target=TARGET specify target [OLIMEX_STM32_H103]
supported targes are:
OLIMEX_STM32_H103
STM32_PRIMER2
--enable-debug debug with virtual COM port [no]
--with-dfu build image for DFU [no]
EOF
exit 0
fi
BOARD_MAKEFILE=../boards/$target/board.mk
if test -f $BOARD_MAKEFILE; then
echo "Configured for target: $target"
else
echo "Unsupported target \`$target'" >&2
exit 1
fi
if test "$debug" = "yes"; then
DEBUG_MAKE_OPTION="ENABLE_DEBUG=1"
DEBUG_DEFINE="#define DEBUG 1"
else
DEBUG_MAKE_OPTION="# ENABLE_DEBUG=1"
DEBUG_DEFINE="#undef DEBUG"
fi
if test "$with_dfu" = "yes"; then
echo "Configured for DFU"
ORIGIN=0x08003000
FLASH_SIZE=116k
DFU_DEFINE="#define DFU_SUPPORT 1"
else
echo "Configured for bare system (no-DFU)"
ORIGIN=0x08000000
FLASH_SIZE=128k
DFU_DEFINE="#undef DFU_SUPPORT"
fi
sed -e "s%@BOARD_MAKEFILE@%$BOARD_MAKEFILE%" \
-e "s%@DEBUG_MAKE_OPTION@%$DEBUG_MAKE_OPTION%" \
< Makefile.in > Makefile
sed -e "s/@ORIGIN@/$ORIGIN/" -e "s/@FLASH_SIZE@/$FLASH_SIZE/" \
< gnuk.ld.in > gnuk.ld
sed -e "s/@DEBUG_DEFINE@/$DEBUG_DEFINE/" \
-e "s/@DFU_DEFINE@/$DFU_DEFINE/" \
< config.h.in > config.h
exit 0

View File

@@ -32,7 +32,7 @@ __stacks_total_size__ = __main_stack_size__;
MEMORY
{
flash : org = 0x08000000, len = 128k
flash : org = @ORIGIN@, len = @FLASH_SIZE@
ram : org = 0x20000000, len = 20k
}