From f769ebe05c78aa0a95eb0c444c46196f86bde502 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Thu, 10 Feb 2011 13:57:23 +0900 Subject: [PATCH] Version 0.10 --- AUTHORS | 7 +- ChangeLog | 14 ++++ NEWS | 23 ++++++- README | 102 ++++++++++++++++++++++++----- boards/CQ_STARM/board.mk | 6 -- boards/CQ_STARM/mcuconf.h | 95 +-------------------------- boards/OLIMEX_STM32_H103/board.mk | 6 -- boards/OLIMEX_STM32_H103/mcuconf.h | 95 +-------------------------- boards/STBEE/board.mk | 6 -- boards/STBEE/mcuconf.h | 95 +-------------------------- boards/STBEE_MINI/board.mk | 6 -- boards/STBEE_MINI/mcuconf.h | 95 --------------------------- boards/STM32_PRIMER2/board.mk | 6 -- boards/STM32_PRIMER2/mcuconf.h | 95 +-------------------------- boards/STM8S_DISCOVERY/board.mk | 6 -- boards/STM8S_DISCOVERY/mcuconf.h | 95 +-------------------------- boards/common/mcuconf-common.h | 94 ++++++++++++++++++++++++++ src/Makefile.in | 10 +-- src/configure | 6 +- 19 files changed, 229 insertions(+), 633 deletions(-) delete mode 100644 boards/CQ_STARM/board.mk delete mode 100644 boards/OLIMEX_STM32_H103/board.mk delete mode 100644 boards/STBEE/board.mk delete mode 100644 boards/STBEE_MINI/board.mk delete mode 100644 boards/STM32_PRIMER2/board.mk delete mode 100644 boards/STM8S_DISCOVERY/board.mk create mode 100644 boards/common/mcuconf-common.h diff --git a/AUTHORS b/AUTHORS index 393c3dc..f9cb335 100644 --- a/AUTHORS +++ b/AUTHORS @@ -2,7 +2,6 @@ Kaz Kojima: Added STM32 Primer2 support: boards/STM32_PRIMER2/board.c boards/STM32_PRIMER2/board.h - boards/STM32_PRIMER2/board.mk boards/STM32_PRIMER2/mcuconf.h NIIBE Yutaka: @@ -10,22 +9,18 @@ NIIBE Yutaka: Added STBee support: boards/STBEE/board.c boards/STBEE/board.h - boards/STBEE/board.mk boards/STBEE/mcuconf.h Added STM8S Discovery Kit support: boards/STM8S_DISCOVERY/board.c boards/STM8S_DISCOVERY/board.h - boards/STM8S_DISCOVERY/board.mk - boards/STM8S_DISCOVERY/mcuconf.mk + boards/STM8S_DISCOVERY/mcuconf.h Added STBee Mini support: boards/STBEE_MINI/board.c boards/STBEE_MINI/board.h - boards/STBEE_MINI/board.mk boards/STBEE_MINI/mcuconf.h Added CQ STARM support: boards/CQ_STARM/board.c boards/CQ_STARM/board.h - boards/CQ_STARM/board.mk boards/CQ_STARM/mcuconf.h Wrote tools for DfuSe: tool/dfuse.py diff --git a/ChangeLog b/ChangeLog index 0fa43d4..0cd6c47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2011-02-10 NIIBE Yutaka + + * Version 0.10. + + * src/configure, src/Makefile.in (BOARD_DIR): New. + + * boards/CQ_STARM/board.mk, boards/OLIMEX_STM32_H103/board.mk: + Removed. + * boards/STBEE/board.mk, boards/STBEE_MINI/board.mk: Removed. + * boards/STM32_PRIMER2/board.mk, boards/STM8S_DISCOVERY/board.mk: + Removed. + + * src/Makefile.in (OUTFILES): Don't include random_bits. + 2011-02-09 NIIBE Yutaka * src/usb_prop.c (gnukStringSerial): Updated. diff --git a/NEWS b/NEWS index 2329bea..ef5e2f5 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,24 @@ Gnuk NEWS - User visible changes +* Major changes in Gnuk 0.10 + + Released 2011-02-10, by NIIBE Yutaka + +** The executable can be installed to multiple devices. +So far, users of Gnuk should have not shared single executable among +multiple devices because the executable includes random bits (or +fixed serial number). Now, random_bits and fixed serial number are +configured *after* compilation, we can install single executable image +to multiple devices. Note that we need to configure random_bits for +each device. + +** Removed configure option: --with-fixed-serial +It is not compile time option any more. After installation, we can +modify serial number in AID by tool/gnuk_put_binary.py. Modification +is possible only once. If you don't modify, Gnuk uses unique chip ID +of STM32 processor for AID. + + * Major changes in Gnuk 0.9 Released 2011-02-01, by NIIBE Yutaka @@ -15,8 +34,8 @@ changes in Gnuk, it could be relatively easily possible to support Gnuk Token by OpenSC with a few changes to libopensc/card-openpgp.c, and libopensc/pkcs15-openpgp.c. -** New board support "STBEE" -STBEE is a board by Strawberry Linux Co., Ltd., and it has +** New board support "STBee" +STBee is a board by Strawberry Linux Co., Ltd., and it has STM32F103VET6 on the board. The chip is High Density CPU with 512KB flash memory and many I/O. If you want to connect sensor, display, etc., this board would be a good candidate. diff --git a/README b/README index e576604..77e665d 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ Gnuk - software for GPG USB Token - Version 0.9 - 2011-02-01 + Version 0.10 + 2011-02-10 Niibe Yutaka Free Software Initiative of Japan @@ -26,8 +26,11 @@ USB Token by Gnuk everywhere. Release notes ============= -This is tenth release of Gnuk. While it works well for specific -usages, it is still experimental. +This is eleventh release of Gnuk. While it works well for specific +usages, it is still experimental. Note that you need to write random +bits after installation of gnuk executable to the chip from this +release. This procedure is required to share a single executable +among multiple devices. Tested features are: @@ -72,6 +75,7 @@ Not supported feature(s): * Overriding key import. You need to remove all keys first. + * Key generation Targets ======= @@ -185,18 +189,11 @@ Type: $ make -In the make process, it takes time for the command of - - dd if=/dev/random bs=1 of=random_bits count=1024 - -Don't just wait, but do some other work on your PC. -/dev/random needs entropy to finish. - Then, we will have "gnuk.elf". -How to run -========== +How to install +============== Olimex STM32-H103 board ----------------------- @@ -222,9 +219,21 @@ If you are using FTDI-2232D module and the connection is standard, type: $ openocd -f interface/openocd-usb.cfg -f target/stm32.cfg -Then, invoke telnet to connect OpenCD and write image as above example -of Olimex STM32-H103. - +Initially, the flash ROM of the chip is protected. you need to do: + + $ telnet localhost 4444 + > reset halt + > stm32x unlock 0 + > reset + > shutdown + $ + +and re-connect the board. Note that power-off / power-on sequence is +required to reset flash ROM. + +Then, invoke OpenOCD again and telnet to connect OpenCD and write +image as above example of Olimex STM32-H103. + CQ STARM -------- @@ -249,6 +258,67 @@ to flash: Then, reset the board. +How to protect flash ROM +======================== + +Invoke your OpenOCD and type: + + $ telnet localhost 4444 + > reset halt + > stm32x lock 0 + > reset + > shutdown + +After power-off / power-on sequence, the contents of flash ROM cannot +be accessible from JTAG debugger. + +Note that it would be still possible for some implementation of DfuSe +to access the contents. If you want to protect, killing DfuSe and +accessing by JTAG debugger is recommended. + + +How to configure +================ + +You need python and PyUSB (python-usb package in Debian). + +(1) In the 'src' directory, type + + $ make random_bits + +In this process, it takes time for the command of + + dd if=/dev/random bs=1 of=random_bits count=1024 + +Don't just wait, but do some other works on your PC. +/dev/random needs entropy to finish. + +(2) Stop the pcsc daemon. + + # /etc/init.d/pcscd stop + +(3) Write the random bits to the device + +Connect your board to USB port of your PC. And invoke gnuk_put_binary.py: + + # ../tool/gnuk_put_binary.py -r random_bits random_bits: 1024 + +(4) [Optional] Write fixed serial number + +If you use fixed serial number in the file 'GNUK_SERIAL_NUMBER', you can do: + + # EMAIL= ../tool/gnuk_put_binary.py -s ../GNUK_SERIAL_NUMBER + +(5) [Optional] Write card holder certificate + +If you have card holder certificate binary file, you can do: + + # ../tool/gnuk_put_binary.py ../../.bin + + +How to run +========== + Debug enabled ------------- diff --git a/boards/CQ_STARM/board.mk b/boards/CQ_STARM/board.mk deleted file mode 100644 index d15f7db..0000000 --- a/boards/CQ_STARM/board.mk +++ /dev/null @@ -1,6 +0,0 @@ -# List of all the board related files. -BOARDSRC = ../boards/CQ_STARM/board.c \ - ../boards/common/hw_config.c - -# Required include directories -BOARDINC = ../boards/CQ_STARM diff --git a/boards/CQ_STARM/mcuconf.h b/boards/CQ_STARM/mcuconf.h index c862cf9..9b670b0 100644 --- a/boards/CQ_STARM/mcuconf.h +++ b/boards/CQ_STARM/mcuconf.h @@ -1,43 +1,3 @@ -/* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. - - This file is part of ChibiOS/RT. - - ChibiOS/RT 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. - - ChibiOS/RT 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 . - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. -*/ - -/* - * STM32 drivers configuration. - * The following settings override the default settings present in - * the various device driver implementation headers. - * Note that the settings for each driver only have effect if the driver - * is enabled in halconf.h. - * - * IRQ priorities: - * 15...0 Lowest...Highest. - * - * DMA priorities: - * 0...3 Lowest...Highest. - */ - /* * HAL driver system settings. */ @@ -51,57 +11,4 @@ #define STM32_ADCPRE STM32_ADCPRE_DIV4 #define STM32_MCO STM32_MCO_NOCLOCK -/* - * ADC driver system settings. - */ -#define USE_STM32_ADC1 TRUE -#define STM32_ADC1_DMA_PRIORITY 3 -#define STM32_ADC1_IRQ_PRIORITY 5 -#define STM32_ADC1_DMA_ERROR_HOOK() chSysHalt() - -/* - * CAN driver system settings. - */ -#define USE_STM32_CAN1 TRUE -#define STM32_CAN1_IRQ_PRIORITY 11 - -/* - * PWM driver system settings. - */ -#define USE_STM32_PWM1 TRUE -#define USE_STM32_PWM2 FALSE -#define USE_STM32_PWM3 FALSE -#define USE_STM32_PWM4 FALSE -#define STM32_PWM1_IRQ_PRIORITY 7 -#define STM32_PWM2_IRQ_PRIORITY 7 -#define STM32_PWM3_IRQ_PRIORITY 7 -#define STM32_PWM4_IRQ_PRIORITY 7 - -/* - * SERIAL driver system settings. - */ -#define USE_STM32_USART1 FALSE -#define USE_STM32_USART2 TRUE -#define USE_STM32_USART3 FALSE -#if defined(STM32F10X_HD) || defined(STM32F10X_CL) -#define USE_STM32_UART4 FALSE -#define USE_STM32_UART5 FALSE -#endif -#define STM32_USART1_PRIORITY 12 -#define STM32_USART2_PRIORITY 12 -#define STM32_USART3_PRIORITY 12 -#if defined(STM32F10X_HD) || defined(STM32F10X_CL) -#define STM32_UART4_PRIORITY 12 -#define STM32_UART5_PRIORITY 12 -#endif - -/* - * SPI driver system settings. - */ -#define USE_STM32_SPI1 TRUE -#define USE_STM32_SPI2 TRUE -#define STM32_SPI1_DMA_PRIORITY 2 -#define STM32_SPI2_DMA_PRIORITY 2 -#define STM32_SPI1_IRQ_PRIORITY 10 -#define STM32_SPI2_IRQ_PRIORITY 10 -#define STM32_SPI1_DMA_ERROR_HOOK() chSysHalt() +#include "mcuconf-common.h" diff --git a/boards/OLIMEX_STM32_H103/board.mk b/boards/OLIMEX_STM32_H103/board.mk deleted file mode 100644 index 8b13624..0000000 --- a/boards/OLIMEX_STM32_H103/board.mk +++ /dev/null @@ -1,6 +0,0 @@ -# List of all the board related files. -BOARDSRC = ../boards/OLIMEX_STM32_H103/board.c \ - ../boards/common/hw_config.c - -# Required include directories -BOARDINC = ../boards/OLIMEX_STM32_H103 diff --git a/boards/OLIMEX_STM32_H103/mcuconf.h b/boards/OLIMEX_STM32_H103/mcuconf.h index c862cf9..9b670b0 100644 --- a/boards/OLIMEX_STM32_H103/mcuconf.h +++ b/boards/OLIMEX_STM32_H103/mcuconf.h @@ -1,43 +1,3 @@ -/* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. - - This file is part of ChibiOS/RT. - - ChibiOS/RT 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. - - ChibiOS/RT 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 . - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. -*/ - -/* - * STM32 drivers configuration. - * The following settings override the default settings present in - * the various device driver implementation headers. - * Note that the settings for each driver only have effect if the driver - * is enabled in halconf.h. - * - * IRQ priorities: - * 15...0 Lowest...Highest. - * - * DMA priorities: - * 0...3 Lowest...Highest. - */ - /* * HAL driver system settings. */ @@ -51,57 +11,4 @@ #define STM32_ADCPRE STM32_ADCPRE_DIV4 #define STM32_MCO STM32_MCO_NOCLOCK -/* - * ADC driver system settings. - */ -#define USE_STM32_ADC1 TRUE -#define STM32_ADC1_DMA_PRIORITY 3 -#define STM32_ADC1_IRQ_PRIORITY 5 -#define STM32_ADC1_DMA_ERROR_HOOK() chSysHalt() - -/* - * CAN driver system settings. - */ -#define USE_STM32_CAN1 TRUE -#define STM32_CAN1_IRQ_PRIORITY 11 - -/* - * PWM driver system settings. - */ -#define USE_STM32_PWM1 TRUE -#define USE_STM32_PWM2 FALSE -#define USE_STM32_PWM3 FALSE -#define USE_STM32_PWM4 FALSE -#define STM32_PWM1_IRQ_PRIORITY 7 -#define STM32_PWM2_IRQ_PRIORITY 7 -#define STM32_PWM3_IRQ_PRIORITY 7 -#define STM32_PWM4_IRQ_PRIORITY 7 - -/* - * SERIAL driver system settings. - */ -#define USE_STM32_USART1 FALSE -#define USE_STM32_USART2 TRUE -#define USE_STM32_USART3 FALSE -#if defined(STM32F10X_HD) || defined(STM32F10X_CL) -#define USE_STM32_UART4 FALSE -#define USE_STM32_UART5 FALSE -#endif -#define STM32_USART1_PRIORITY 12 -#define STM32_USART2_PRIORITY 12 -#define STM32_USART3_PRIORITY 12 -#if defined(STM32F10X_HD) || defined(STM32F10X_CL) -#define STM32_UART4_PRIORITY 12 -#define STM32_UART5_PRIORITY 12 -#endif - -/* - * SPI driver system settings. - */ -#define USE_STM32_SPI1 TRUE -#define USE_STM32_SPI2 TRUE -#define STM32_SPI1_DMA_PRIORITY 2 -#define STM32_SPI2_DMA_PRIORITY 2 -#define STM32_SPI1_IRQ_PRIORITY 10 -#define STM32_SPI2_IRQ_PRIORITY 10 -#define STM32_SPI1_DMA_ERROR_HOOK() chSysHalt() +#include "mcuconf-common.h" diff --git a/boards/STBEE/board.mk b/boards/STBEE/board.mk deleted file mode 100644 index 1d5c6e0..0000000 --- a/boards/STBEE/board.mk +++ /dev/null @@ -1,6 +0,0 @@ -# List of all the board related files. -BOARDSRC = ../boards/STBEE/board.c \ - ../boards/common/hw_config.c - -# Required include directories -BOARDINC = ../boards/STBEE diff --git a/boards/STBEE/mcuconf.h b/boards/STBEE/mcuconf.h index c2bc654..6b90b26 100644 --- a/boards/STBEE/mcuconf.h +++ b/boards/STBEE/mcuconf.h @@ -1,43 +1,3 @@ -/* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. - - This file is part of ChibiOS/RT. - - ChibiOS/RT 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. - - ChibiOS/RT 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 . - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. -*/ - -/* - * STM32 drivers configuration. - * The following settings override the default settings present in - * the various device driver implementation headers. - * Note that the settings for each driver only have effect if the driver - * is enabled in halconf.h. - * - * IRQ priorities: - * 15...0 Lowest...Highest. - * - * DMA priorities: - * 0...3 Lowest...Highest. - */ - /* * HAL driver system settings. */ @@ -51,57 +11,4 @@ #define STM32_ADCPRE STM32_ADCPRE_DIV4 #define STM32_MCO STM32_MCO_NOCLOCK -/* - * ADC driver system settings. - */ -#define USE_STM32_ADC1 FALSE -#define STM32_ADC1_DMA_PRIORITY 3 -#define STM32_ADC1_IRQ_PRIORITY 5 -#define STM32_ADC1_DMA_ERROR_HOOK() chSysHalt() - -/* - * CAN driver system settings. - */ -#define USE_STM32_CAN1 FALSE -#define STM32_CAN1_IRQ_PRIORITY 11 - -/* - * PWM driver system settings. - */ -#define USE_STM32_PWM1 FALSE -#define USE_STM32_PWM2 FALSE -#define USE_STM32_PWM3 FALSE -#define USE_STM32_PWM4 FALSE -#define STM32_PWM1_IRQ_PRIORITY 7 -#define STM32_PWM2_IRQ_PRIORITY 7 -#define STM32_PWM3_IRQ_PRIORITY 7 -#define STM32_PWM4_IRQ_PRIORITY 7 - -/* - * SERIAL driver system settings. - */ -#define USE_STM32_USART1 FALSE -#define USE_STM32_USART2 FALSE -#define USE_STM32_USART3 FALSE -#if defined(STM32F10X_HD) || defined(STM32F10X_CL) -#define USE_STM32_UART4 FALSE -#define USE_STM32_UART5 FALSE -#endif -#define STM32_USART1_PRIORITY 12 -#define STM32_USART2_PRIORITY 12 -#define STM32_USART3_PRIORITY 12 -#if defined(STM32F10X_HD) || defined(STM32F10X_CL) -#define STM32_UART4_PRIORITY 12 -#define STM32_UART5_PRIORITY 12 -#endif - -/* - * SPI driver system settings. - */ -#define USE_STM32_SPI1 FALSE -#define USE_STM32_SPI2 FALSE -#define STM32_SPI1_DMA_PRIORITY 2 -#define STM32_SPI2_DMA_PRIORITY 2 -#define STM32_SPI1_IRQ_PRIORITY 10 -#define STM32_SPI2_IRQ_PRIORITY 10 -#define STM32_SPI1_DMA_ERROR_HOOK() chSysHalt() +#include "mcuconf-common.h" diff --git a/boards/STBEE_MINI/board.mk b/boards/STBEE_MINI/board.mk deleted file mode 100644 index 7f05e87..0000000 --- a/boards/STBEE_MINI/board.mk +++ /dev/null @@ -1,6 +0,0 @@ -# List of all the board related files. -BOARDSRC = ../boards/STBEE_MINI/board.c \ - ../boards/common/hw_config.c - -# Required include directories -BOARDINC = ../boards/STBEE_MINI diff --git a/boards/STBEE_MINI/mcuconf.h b/boards/STBEE_MINI/mcuconf.h index c2bc654..f7020ff 100644 --- a/boards/STBEE_MINI/mcuconf.h +++ b/boards/STBEE_MINI/mcuconf.h @@ -1,43 +1,3 @@ -/* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. - - This file is part of ChibiOS/RT. - - ChibiOS/RT 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. - - ChibiOS/RT 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 . - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. -*/ - -/* - * STM32 drivers configuration. - * The following settings override the default settings present in - * the various device driver implementation headers. - * Note that the settings for each driver only have effect if the driver - * is enabled in halconf.h. - * - * IRQ priorities: - * 15...0 Lowest...Highest. - * - * DMA priorities: - * 0...3 Lowest...Highest. - */ - /* * HAL driver system settings. */ @@ -50,58 +10,3 @@ #define STM32_PPRE2 STM32_PPRE2_DIV2 #define STM32_ADCPRE STM32_ADCPRE_DIV4 #define STM32_MCO STM32_MCO_NOCLOCK - -/* - * ADC driver system settings. - */ -#define USE_STM32_ADC1 FALSE -#define STM32_ADC1_DMA_PRIORITY 3 -#define STM32_ADC1_IRQ_PRIORITY 5 -#define STM32_ADC1_DMA_ERROR_HOOK() chSysHalt() - -/* - * CAN driver system settings. - */ -#define USE_STM32_CAN1 FALSE -#define STM32_CAN1_IRQ_PRIORITY 11 - -/* - * PWM driver system settings. - */ -#define USE_STM32_PWM1 FALSE -#define USE_STM32_PWM2 FALSE -#define USE_STM32_PWM3 FALSE -#define USE_STM32_PWM4 FALSE -#define STM32_PWM1_IRQ_PRIORITY 7 -#define STM32_PWM2_IRQ_PRIORITY 7 -#define STM32_PWM3_IRQ_PRIORITY 7 -#define STM32_PWM4_IRQ_PRIORITY 7 - -/* - * SERIAL driver system settings. - */ -#define USE_STM32_USART1 FALSE -#define USE_STM32_USART2 FALSE -#define USE_STM32_USART3 FALSE -#if defined(STM32F10X_HD) || defined(STM32F10X_CL) -#define USE_STM32_UART4 FALSE -#define USE_STM32_UART5 FALSE -#endif -#define STM32_USART1_PRIORITY 12 -#define STM32_USART2_PRIORITY 12 -#define STM32_USART3_PRIORITY 12 -#if defined(STM32F10X_HD) || defined(STM32F10X_CL) -#define STM32_UART4_PRIORITY 12 -#define STM32_UART5_PRIORITY 12 -#endif - -/* - * SPI driver system settings. - */ -#define USE_STM32_SPI1 FALSE -#define USE_STM32_SPI2 FALSE -#define STM32_SPI1_DMA_PRIORITY 2 -#define STM32_SPI2_DMA_PRIORITY 2 -#define STM32_SPI1_IRQ_PRIORITY 10 -#define STM32_SPI2_IRQ_PRIORITY 10 -#define STM32_SPI1_DMA_ERROR_HOOK() chSysHalt() diff --git a/boards/STM32_PRIMER2/board.mk b/boards/STM32_PRIMER2/board.mk deleted file mode 100644 index 1648041..0000000 --- a/boards/STM32_PRIMER2/board.mk +++ /dev/null @@ -1,6 +0,0 @@ -# List of all the board related files. -BOARDSRC = ../boards/STM32_PRIMER2/board.c \ - ../boards/common/hw_config.c - -# Required include directories -BOARDINC = ../boards/STM32_PRIMER2 diff --git a/boards/STM32_PRIMER2/mcuconf.h b/boards/STM32_PRIMER2/mcuconf.h index 4db6cf6..449e5c8 100644 --- a/boards/STM32_PRIMER2/mcuconf.h +++ b/boards/STM32_PRIMER2/mcuconf.h @@ -1,43 +1,3 @@ -/* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. - - This file is part of ChibiOS/RT. - - ChibiOS/RT 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. - - ChibiOS/RT 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 . - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. -*/ - -/* - * STM32 drivers configuration. - * The following settings override the default settings present in - * the various device driver implementation headers. - * Note that the settings for each driver only have effect if the driver - * is enabled in halconf.h. - * - * IRQ priorities: - * 15...0 Lowest...Highest. - * - * DMA priorities: - * 0...3 Lowest...Highest. - */ - /* * HAL driver system settings. */ @@ -51,57 +11,4 @@ #define STM32_ADCPRE STM32_ADCPRE_DIV4 #define STM32_MCO STM32_MCO_NOCLOCK -/* - * ADC driver system settings. - */ -#define USE_STM32_ADC1 TRUE -#define STM32_ADC1_DMA_PRIORITY 3 -#define STM32_ADC1_IRQ_PRIORITY 5 -#define STM32_ADC1_DMA_ERROR_HOOK() chSysHalt() - -/* - * CAN driver system settings. - */ -#define USE_STM32_CAN1 TRUE -#define STM32_CAN1_IRQ_PRIORITY 11 - -/* - * PWM driver system settings. - */ -#define USE_STM32_PWM1 TRUE -#define USE_STM32_PWM2 FALSE -#define USE_STM32_PWM3 FALSE -#define USE_STM32_PWM4 FALSE -#define STM32_PWM1_IRQ_PRIORITY 7 -#define STM32_PWM2_IRQ_PRIORITY 7 -#define STM32_PWM3_IRQ_PRIORITY 7 -#define STM32_PWM4_IRQ_PRIORITY 7 - -/* - * SERIAL driver system settings. - */ -#define USE_STM32_USART1 FALSE -#define USE_STM32_USART2 FALSE -#define USE_STM32_USART3 FALSE -#if defined(STM32F10X_HD) || defined(STM32F10X_CL) -#define USE_STM32_UART4 FALSE -#define USE_STM32_UART5 FALSE -#endif -#define STM32_USART1_PRIORITY 12 -#define STM32_USART2_PRIORITY 12 -#define STM32_USART3_PRIORITY 12 -#if defined(STM32F10X_HD) || defined(STM32F10X_CL) -#define STM32_UART4_PRIORITY 12 -#define STM32_UART5_PRIORITY 12 -#endif - -/* - * SPI driver system settings. - */ -#define USE_STM32_SPI1 TRUE -#define USE_STM32_SPI2 TRUE -#define STM32_SPI1_DMA_PRIORITY 2 -#define STM32_SPI2_DMA_PRIORITY 2 -#define STM32_SPI1_IRQ_PRIORITY 10 -#define STM32_SPI2_IRQ_PRIORITY 10 -#define STM32_SPI1_DMA_ERROR_HOOK() chSysHalt() +#include "mcuconf-common.h" diff --git a/boards/STM8S_DISCOVERY/board.mk b/boards/STM8S_DISCOVERY/board.mk deleted file mode 100644 index 8e9699d..0000000 --- a/boards/STM8S_DISCOVERY/board.mk +++ /dev/null @@ -1,6 +0,0 @@ -# List of all the board related files. -BOARDSRC = ../boards/STM8S_DISCOVERY/board.c \ - ../boards/common/hw_config.c - -# Required include directories -BOARDINC = ../boards/STM8S_DISCOVERY diff --git a/boards/STM8S_DISCOVERY/mcuconf.h b/boards/STM8S_DISCOVERY/mcuconf.h index 5d16d78..9b670b0 100644 --- a/boards/STM8S_DISCOVERY/mcuconf.h +++ b/boards/STM8S_DISCOVERY/mcuconf.h @@ -1,43 +1,3 @@ -/* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. - - This file is part of ChibiOS/RT. - - ChibiOS/RT 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. - - ChibiOS/RT 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 . - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. -*/ - -/* - * STM32 drivers configuration. - * The following settings override the default settings present in - * the various device driver implementation headers. - * Note that the settings for each driver only have effect if the driver - * is enabled in halconf.h. - * - * IRQ priorities: - * 15...0 Lowest...Highest. - * - * DMA priorities: - * 0...3 Lowest...Highest. - */ - /* * HAL driver system settings. */ @@ -51,57 +11,4 @@ #define STM32_ADCPRE STM32_ADCPRE_DIV4 #define STM32_MCO STM32_MCO_NOCLOCK -/* - * ADC driver system settings. - */ -#define USE_STM32_ADC1 FALSE -#define STM32_ADC1_DMA_PRIORITY 3 -#define STM32_ADC1_IRQ_PRIORITY 5 -#define STM32_ADC1_DMA_ERROR_HOOK() chSysHalt() - -/* - * CAN driver system settings. - */ -#define USE_STM32_CAN1 FALSE -#define STM32_CAN1_IRQ_PRIORITY 11 - -/* - * PWM driver system settings. - */ -#define USE_STM32_PWM1 FALSE -#define USE_STM32_PWM2 FALSE -#define USE_STM32_PWM3 FALSE -#define USE_STM32_PWM4 FALSE -#define STM32_PWM1_IRQ_PRIORITY 7 -#define STM32_PWM2_IRQ_PRIORITY 7 -#define STM32_PWM3_IRQ_PRIORITY 7 -#define STM32_PWM4_IRQ_PRIORITY 7 - -/* - * SERIAL driver system settings. - */ -#define USE_STM32_USART1 FALSE -#define USE_STM32_USART2 FALSE -#define USE_STM32_USART3 FALSE -#if defined(STM32F10X_HD) || defined(STM32F10X_CL) -#define USE_STM32_UART4 FALSE -#define USE_STM32_UART5 FALSE -#endif -#define STM32_USART1_PRIORITY 12 -#define STM32_USART2_PRIORITY 12 -#define STM32_USART3_PRIORITY 12 -#if defined(STM32F10X_HD) || defined(STM32F10X_CL) -#define STM32_UART4_PRIORITY 12 -#define STM32_UART5_PRIORITY 12 -#endif - -/* - * SPI driver system settings. - */ -#define USE_STM32_SPI1 FALSE -#define USE_STM32_SPI2 FALSE -#define STM32_SPI1_DMA_PRIORITY 2 -#define STM32_SPI2_DMA_PRIORITY 2 -#define STM32_SPI1_IRQ_PRIORITY 10 -#define STM32_SPI2_IRQ_PRIORITY 10 -#define STM32_SPI1_DMA_ERROR_HOOK() chSysHalt() +#include "mcuconf-common.h" diff --git a/boards/common/mcuconf-common.h b/boards/common/mcuconf-common.h new file mode 100644 index 0000000..fd286e7 --- /dev/null +++ b/boards/common/mcuconf-common.h @@ -0,0 +1,94 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT 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. + + ChibiOS/RT 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 . + + --- + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes ChibiOS/RT, without being obliged to provide + the source code for any proprietary components. See the file exception.txt + for full details of how and when the exception can be applied. +*/ + +/* + * STM32 drivers configuration. + * The following settings override the default settings present in + * the various device driver implementation headers. + * Note that the settings for each driver only have effect if the driver + * is enabled in halconf.h. + * + * IRQ priorities: + * 15...0 Lowest...Highest. + * + * DMA priorities: + * 0...3 Lowest...Highest. + */ + +/* + * ADC driver system settings. + */ +#define USE_STM32_ADC1 FALSE +#define STM32_ADC1_DMA_PRIORITY 3 +#define STM32_ADC1_IRQ_PRIORITY 5 +#define STM32_ADC1_DMA_ERROR_HOOK() chSysHalt() + +/* + * CAN driver system settings. + */ +#define USE_STM32_CAN1 FALSE +#define STM32_CAN1_IRQ_PRIORITY 11 + +/* + * PWM driver system settings. + */ +#define USE_STM32_PWM1 FALSE +#define USE_STM32_PWM2 FALSE +#define USE_STM32_PWM3 FALSE +#define USE_STM32_PWM4 FALSE +#define STM32_PWM1_IRQ_PRIORITY 7 +#define STM32_PWM2_IRQ_PRIORITY 7 +#define STM32_PWM3_IRQ_PRIORITY 7 +#define STM32_PWM4_IRQ_PRIORITY 7 + +/* + * SERIAL driver system settings. + */ +#define USE_STM32_USART1 FALSE +#define USE_STM32_USART2 FALSE +#define USE_STM32_USART3 FALSE +#if defined(STM32F10X_HD) || defined(STM32F10X_CL) +#define USE_STM32_UART4 FALSE +#define USE_STM32_UART5 FALSE +#endif +#define STM32_USART1_PRIORITY 12 +#define STM32_USART2_PRIORITY 12 +#define STM32_USART3_PRIORITY 12 +#if defined(STM32F10X_HD) || defined(STM32F10X_CL) +#define STM32_UART4_PRIORITY 12 +#define STM32_UART5_PRIORITY 12 +#endif + +/* + * SPI driver system settings. + */ +#define USE_STM32_SPI1 FALSE +#define USE_STM32_SPI2 FALSE +#define STM32_SPI1_DMA_PRIORITY 2 +#define STM32_SPI2_DMA_PRIORITY 2 +#define STM32_SPI1_IRQ_PRIORITY 10 +#define STM32_SPI2_IRQ_PRIORITY 10 +#define STM32_SPI1_DMA_ERROR_HOOK() chSysHalt() diff --git a/src/Makefile.in b/src/Makefile.in index 155043f..134cf18 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,5 +1,6 @@ # Makefile for Gnuk +BOARD_DIR=@BOARD_DIR@ @PINPAD_MAKE_OPTION@ @DEBUG_MAKE_OPTION@ ifneq ($(ENABLE_DEBUG),) @@ -72,7 +73,6 @@ include $(CHIBIOS)/os/kernel/kernel.mk include stmusb.mk include vcomport.mk include crypt.mk -include @BOARD_MAKEFILE@ # C sources that can be compiled in ARM or THUMB mode depending on the global # setting. @@ -81,6 +81,8 @@ CSRC = $(PORTSRC) \ $(HALSRC) \ $(PLATFORMSRC) \ $(BOARDSRC) \ + ../boards/common/hw_config.c \ + $(BOARD_DIR)/board.c \ $(CHIBIOS)/os/various/evtimer.c \ $(CHIBIOS)/os/various/syscalls.c \ $(STMUSBSRC) \ @@ -105,7 +107,7 @@ ASMSRC = $(PORTASM) \ INCDIR = $(CRYPTINCDIR) $(STMUSBINCDIR) $(VCOMDIR) \ $(PORTINC) $(KERNINC) $(TESTINC) \ - $(HALINC) $(PLATFORMINC) $(BOARDINC) \ + $(HALINC) $(PLATFORMINC) ../boards/common $(BOARD_DIR) \ $(CHIBIOS)/os/various # @@ -204,10 +206,8 @@ endif include $(CHIBIOS)/os/ports/GCC/ARM/rules.mk -OUTFILES += random_bits - random_bits: dd if=/dev/random bs=1 of=random_bits count=1024 distclean: clean - -rm -f Makefile gnuk.ld config.h + -rm -f Makefile gnuk.ld config.h random_bits diff --git a/src/configure b/src/configure index 5a15035..dea3fa4 100755 --- a/src/configure +++ b/src/configure @@ -93,8 +93,8 @@ EOF exit 0 fi -BOARD_MAKEFILE=../boards/$target/board.mk -if test -f $BOARD_MAKEFILE; then +BOARD_DIR=../boards/$target +if test -d $BOARD_DIR; then echo "Configured for target: $target" else echo "Unsupported target \`$target'" >&2 @@ -170,7 +170,7 @@ else echo "PIN pad option enabled ($pinpad)" fi -sed -e "s%@BOARD_MAKEFILE@%$BOARD_MAKEFILE%" \ +sed -e "s%@BOARD_DIR@%$BOARD_DIR%" \ -e "s%@DEBUG_MAKE_OPTION@%$DEBUG_MAKE_OPTION%" \ -e "s%@PINPAD_MAKE_OPTION@%$PINPAD_MAKE_OPTION%" \ < Makefile.in > Makefile