Version 1.0.9.
[gnuk/neug.git] / src / configure
index ed3aa44..dcd2ee3 100755 (executable)
@@ -6,7 +6,7 @@ nl=$'\n'
 #
 # This file is *NOT* generated by GNU Autoconf, but written by NIIBE Yutaka
 #
-# Copyright (C) 2010, 2011, 2012, 2013, 2015, 2016, 2017
+# Copyright (C) 2010, 2011, 2012, 2013, 2015, 2016, 2017, 2018
 #               Free Software Initiative of Japan
 #
 # This file is a part of NeuG, a Random Number Generator implementation.
@@ -41,6 +41,7 @@ verbose=no
 with_dfu=default
 debug=no
 sys1_compat=yes
+ackbtn_support=no
 with_fraucheky=no
 with_index=none
 # For emulation
@@ -127,6 +128,7 @@ Configuration:
                        supported targets are:
                           FST_01
                           FST_01G
+                          FST_01SZ
                           STM8S_DISCOVERY
                           OLIMEX_STM32_H103
                           MAPLE_MINI
@@ -173,6 +175,8 @@ BOARD_HEADER_FILE=board-$(echo $target | tr '_[:upper:]' '-[:lower:]').h
 echo "Header file is: $BOARD_HEADER_FILE"
 ln -sf "../chopstx/board/$BOARD_HEADER_FILE" board.h
 
+# Frequency
+MHZ=72
 # Flash page size in byte
 FLASH_PAGE_SIZE=1024
 # Flash memory size in KiB
@@ -199,7 +203,15 @@ STBEE)
     with_dfu=yes;
   fi  ;;
 BLUE_PILL|STM8S_DISCOVERY)
-  FLASH_SIZE=64
+  # It's 64KB version of STM32F103, but actually has 128KB
+  flash_override="-DSTM32F103_OVERRIDE_FLASH_SIZE_KB=128"
+  ;;
+BLUE_PILL_G)
+  MHZ=96
+  ;;
+FST_01SZ)
+  MHZ=96
+  ackbtn_support=yes
   ;;
 *)
   ;;
@@ -208,21 +220,21 @@ esac
 if test "$target" = "GNU_LINUX"; then
   ldscript=""
   chip="gnu-linux"
-  use_sys="yes"
   emulation="yes"
   cross=""
   mcu="none"
   def_emulation="-DGNU_LINUX_EMULATION"
+  def_mhz=""
   enable_hexoutput=""
   libs="-lpthread"
 else
   ldscript="neug.ld"
   chip="stm32f103"
-  use_sys="yes"
   emulation=""
   cross="arm-none-eabi-"
   mcu="cortex-m3"
   def_emulation=""
+  def_mhz="-DMHZ=$MHZ"
   enable_hexoutput=yes
   libs=""
 fi
@@ -260,6 +272,15 @@ else
   DFU_DEFINE="#undef DFU_SUPPORT"
 fi
 
+# Acknowledge button support
+if test "$ackbtn_support" = "yes"; then
+  ACKBTN_DEFINE="#define ACKBTN_SUPPORT 1"
+  echo "Acknowledge button is supported"
+else
+  ACKBTN_DEFINE="#undef ACKBTN_SUPPORT"
+  echo "Acknowledge button is not supported"
+fi
+
 ### !!! Replace following string of "FSIJ" to yours !!! ####
 SERIALNO="FSIJ-$(sed -e 's%^[^/]*/%%' <../VERSION)-"
 
@@ -281,8 +302,32 @@ else
 fi
 
 output_vid_pid_version () {
-  echo "$VIDPID" | sed -n -e "s%^\([0-9a-f][0-9a-f]\)\([0-9a-f][0-9a-f]\):\([0-9a-f][0-9a-f]\)\([0-9a-f][0-9a-f]\)$%  0x\2, 0x\1, /* idVendor  */\\${nl}  0x\4, 0x\3, /* idProduct */%p"
-  echo "$VERSION" | sed -n -e "s%^\([0-9a-f][0-9a-f]\)\([0-9a-f][0-9a-f]\)$%  0x\2, 0x\1, /* bcdDevice */%p"
+  echo "$VIDPID" | \
+  sed -n -e "s%^\([0-9a-f][0-9a-f]\)\([0-9a-f][0-9a-f]\):\([0-9a-f][0-9a-f]\)\([0-9a-f][0-9a-f]\)$%\1\t\2\t\3\t\4%p" | \
+  while read -r FIRST SECOND THIRD FOURTH; do
+    if test $FIRST != 00; then
+      echo replace_vid_msb $FIRST
+    fi
+    if test $SECOND != 00; then
+      echo replace_vid_lsb $SECOND
+    fi
+    if test $THIRD != 00; then
+      echo replace_pid_msb $THIRD
+    fi
+    if test $FOURTH != 00; then
+      echo replace_pid_lsb $FOURTH
+    fi
+  done
+  echo "$VERSION" | \
+  sed -n -e "s%^\([0-9a-f][0-9a-f]\)\([0-9a-f][0-9a-f]\)$%\1\t\2%p" | \
+  while read -r FIRST SECOND; do
+    if test $FIRST != 00; then
+      echo replace_bcd_device_msb $FIRST
+    fi
+    if test $SECOND != 00; then
+      echo replace_bcd_device_lsb $SECOND
+    fi
+  done
 }
 
 output_vendor_product_serial_strings () {
@@ -334,14 +379,22 @@ output_vendor_product_serial_strings () {
   fi
 }
 
+(echo "#! /bin/bash"
+ echo
+ echo 'source "binary-edit.sh"') > put-vid-pid-ver.sh
+
 if !(IFS="     "
   while read -r VIDPID VERSION PRODUCT VENDOR; do
     if test "$vidpid" = "$VIDPID"; then
-      output_vid_pid_version > usb-vid-pid-ver.c.inc
+      echo                       >> put-vid-pid-ver.sh
+      echo 'addr=$file_off_ADDR' >> put-vid-pid-ver.sh
+      output_vid_pid_version     >> put-vid-pid-ver.sh
       output_vendor_product_serial_strings neug_ >usb-strings.c.inc
       exit 0
     elif test "$with_fraucheky" = "$VIDPID"; then
-      output_vid_pid_version > fraucheky-vid-pid-ver.c.inc
+      echo                                 >> put-vid-pid-ver.sh
+      echo 'addr=$file_off_fraucheky_ADDR' >> put-vid-pid-ver.sh
+      output_vid_pid_version               >> put-vid-pid-ver.sh
       output_vendor_product_serial_strings >fraucheky-usb-strings.c.inc
     fi
   done; exit 1) < ../NEUG_USB_DEVICE_ID
@@ -364,15 +417,17 @@ fi
 
 
 (echo "CHIP=$chip";
- echo "USE_SYS=$use_sys";
  echo "EMULATION=$emulation";
  echo "CROSS=$cross";
  echo "MCU=$mcu";
- echo "DEFS=$use_sys3 $flash_override $def_emulation";
+ echo "DEFS=$use_sys3 $flash_override $def_emulation $def_mhz";
  echo "LDSCRIPT=$ldscript";
  echo "LIBS=$libs";
  echo "ENABLE_FRAUCHEKY=$enable_fraucheky";
  echo "ENABLE_OUTPUT_HEX=$enable_hexoutput"
+ if test "$ackbtn_support" = "yes"; then
+   echo "USE_ACKBTN=yes"
+ fi
  if test "$emulation" = "yes"; then
    echo "prefix=$prefix"
    echo "exec_prefix=$exec_prefix"
@@ -387,5 +442,6 @@ sed -e "s/@DFU_DEFINE@/$DFU_DEFINE/" \
     -e "s/@SERIALNO_STR_LEN_DEFINE@/$SERIALNO_STR_LEN_DEFINE/" \
     -e "s/@FRAUCHEKY_DEFINE@/$FRAUCHEKY_DEFINE/" \
     -e "s/@FRAUCHEKY_MSC_DEFINE@/$FRAUCHEKY_MSC_DEFINE/" \
+    -e "s/@ACKBTN_DEFINE@/$ACKBTN_DEFINE/" \
        < config.h.in > config.h
 exit 0