Added FSIJ serial number support.

This commit is contained in:
NIIBE Yutaka 2010-10-20 13:34:04 +09:00
parent 73a5065c93
commit 0fb4c91db3
4 changed files with 36 additions and 2 deletions

View File

@ -1,5 +1,9 @@
2010-10-20 NIIBE Yutaka <gniibe@fsij.org> 2010-10-20 NIIBE Yutaka <gniibe@fsij.org>
* FSIJ_SERIAL_NUMBER: New.
* src/configure (with_fsij): Added FSIJ serial number support.
* src/config.h.in (@FSIJ_DEFINE@, @SERIAL_NUMBER_FOUR_BYTES@): New.
* src/configure: Added CQ STARM target. * src/configure: Added CQ STARM target.
* boards/CQ_STARM/mcuconf.h: New. * boards/CQ_STARM/mcuconf.h: New.
* boards/CQ_STARM/board.mk: New. * boards/CQ_STARM/board.mk: New.

2
FSIJ_SERIAL_NUMBER Normal file
View File

@ -0,0 +1,2 @@
# Email # 4-byte serial number, separated by ':'
gniibe@fsij.org 00:00:00:01

View File

@ -3,7 +3,8 @@
#define ENABLE_VIRTUAL_COM_PORT 1 #define ENABLE_VIRTUAL_COM_PORT 1
#endif #endif
#if 0 @FSIJ_DEFINE@
#ifdef WITH_FSIJ_SERIAL_NUMBER
/* FSIJ */ /* FSIJ */
#define MANUFACTURER_IN_AID 0xf5, 0x17 #define MANUFACTURER_IN_AID 0xf5, 0x17
#else #else
@ -11,6 +12,6 @@
#define MANUFACTURER_IN_AID 0xff, 0xfe #define MANUFACTURER_IN_AID 0xff, 0xfe
#endif #endif
#define SERIAL_NUMBER_IN_AID 0x00, 0x00, 0x00, 0x01 #define SERIAL_NUMBER_IN_AID @SERIAL_NUMBER_FOUR_BYTES@
@DFU_DEFINE@ @DFU_DEFINE@

27
src/configure vendored
View File

@ -24,8 +24,15 @@ help=no
target=OLIMEX_STM32_H103 target=OLIMEX_STM32_H103
verbose=no verbose=no
with_dfu=default with_dfu=default
with_fsij=no
debug=no debug=no
# check /dev/random
if test ! -e /dev/random; then
echo "/dev/random is required." >&2
exit 1
fi
# Process each option # Process each option
for option; do for option; do
case $option in case $option in
@ -48,6 +55,10 @@ for option; do
with_dfu=yes ;; with_dfu=yes ;;
--without-dfu) --without-dfu)
with_dfu=no ;; with_dfu=no ;;
--with-fsij)
with_fsij=yes ;;
--without-fsij)
with_fsij=no ;;
*) *)
echo "Unrecognized option \`$option'" >&2 echo "Unrecognized option \`$option'" >&2
echo "Try \`$0 --help' for more information." >&2 echo "Try \`$0 --help' for more information." >&2
@ -71,6 +82,7 @@ Configuration:
CQ_STARM CQ_STARM
--enable-debug debug with virtual COM port [no] --enable-debug debug with virtual COM port [no]
--with-dfu build image for DFU [<target specific>] --with-dfu build image for DFU [<target specific>]
--with-fsij Use FSIJ serial number [no: random number]
EOF EOF
exit 0 exit 0
fi fi
@ -95,6 +107,19 @@ CQ_STARM)
fi ;; fi ;;
esac esac
# --with-fsij option
if test "$with_fsij" = "no"; then
FSIJ_DEFINE="#undef WITH_FSIJ_SERIAL_NUMBER"
SERIAL_NUMBER_FOUR_BYTES=`od -t u1 -N 4 /dev/random | sed -n -e '/^0000000/s/^0000000 *//' -e 's/ */,/gp'`
else
if test "x$MAIL" = "x"; then
echo "Please set MAIL shell variable to select FSIJ serial number." >&2
exit 1
fi
FSIJ_DEFINE="#define WITH_FSIJ_SERIAL_NUMBER 1"
SERIAL_NUMBER_FOUR_BYTES=`sed -n -e "/^$MAIL/s/^.* \(..\):\(..\):\(..\):\(..\)/0x\1, 0x\2, 0x\3, 0x\4/p" ../FSIJ_SERIAL_NUMBER`
fi
if test "$debug" = "yes"; then if test "$debug" = "yes"; then
DEBUG_MAKE_OPTION="ENABLE_DEBUG=1" DEBUG_MAKE_OPTION="ENABLE_DEBUG=1"
DEBUG_DEFINE="#define DEBUG 1" DEBUG_DEFINE="#define DEBUG 1"
@ -122,5 +147,7 @@ sed -e "s/@ORIGIN@/$ORIGIN/" -e "s/@FLASH_SIZE@/$FLASH_SIZE/" \
< gnuk.ld.in > gnuk.ld < gnuk.ld.in > gnuk.ld
sed -e "s/@DEBUG_DEFINE@/$DEBUG_DEFINE/" \ sed -e "s/@DEBUG_DEFINE@/$DEBUG_DEFINE/" \
-e "s/@DFU_DEFINE@/$DFU_DEFINE/" \ -e "s/@DFU_DEFINE@/$DFU_DEFINE/" \
-e "s/@FSIJ_DEFINE@/$FSIJ_DEFINE/" \
-e "s/@SERIAL_NUMBER_FOUR_BYTES@/$SERIAL_NUMBER_FOUR_BYTES/" \
< config.h.in > config.h < config.h.in > config.h
exit 0 exit 0