Fix calling flash_erase_all_and_exec
[gnuk/neug.git] / ChangeLog
index 6e3e366..0a049cb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,521 @@
+2013-08-19  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/main.c (vcom_string3): Updated.
+       [DFU_SUPPORT] (main): Fix calling flash_erase_all_and_exec.
+
+       * src/neug.c (repetition_count_test_word)
+       (adaptive_proportion_64_test_word)
+       (adaptive_proportion_4096_test_word)
+       (noise_source_continuous_test_word): New.
+       (ep_fill_wbuf_v): Use noise_source_continuous_test_word.
+
+2013-08-17  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/main.c (main): Fix locking of USB_MTX.
+
+       * src/adc_stm32f103.c (adc_wait_completion): Fix race condition.
+       Clear (FLAGS & ~1) only, not all of possible interrupts.
+
+2013-08-16  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/main.c (bDeviceState, fsij_device_state, connected): Protect
+       by USB_MTX.
+       (usb_cb_ctrl_write_finish): Use USB_MTX to access protected vars.
+       Update CONNECTED here.
+       (vcom_port_data_setup): Check length.
+       Don't update CONNECTED here.
+       (usb_cb_setup): Use USB_MTX to access protected vars.
+       (usb_cb_handle_event): Likewise.
+       (main): Mutual exclusion by USB_MTX.
+
+       * src/usb_lld.h (bDeviceState): Remove.
+
+       * src/adc_stm32f103.c (NEUG_DMA_MODE): Merge NEUG_DMA_MODE_SAMPLE
+       and NEUG_DMA_MODE_CRC32 which are same value now.
+       (adc_start_conversion_internal): Remove.
+       (adc_start_conversion): Remove MODE, it's not SIZE but COUNT now.
+
+       * src/neug.c (ep_init, ep_process): Follow the change of
+       adc_start_conversion.
+
+       * chopstx: New version of Chopstx.
+
+2013-08-13  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/main.c (struct line_coding): Add packed attribute.
+       (usb_cb_ctrl_write_finish): Wake up main thread if it wait
+       on condition variable.
+       (main): Call neug_mode_select in the loop of waiting_connection.
+       Call neug_mode_select in the main loop to allow changing mode
+       while connected.
+
+       * tool/neug_check.py (neug.get_mode): Change the explanation of
+       filter "CRC32 filter".
+
+       * src/neug.c (adc_buf): Remove.
+       (ep_fill_initial_string): Call noise_source_continuous_test.
+       (ep_init): Follow the change of adc_start_conversion.
+       (ep_fill_wbuf_v): New name and new argument V, remove FLIP.
+       (ep_process): Access CRC unit from here.  Correct calling
+       noise_source_continuous_test for the last byte of output.
+       (rng): Handle error of ADC.
+
+       * src/adc_stm32f103.c (adc_mode, adc_ptr, adc_size): Remove.
+       (adc_buf): Make it public.
+       (adc_start_conversion): Change arguments.
+       (adc_lld_serve_rx_interrupt, adc_wait): Remove.
+       (adc_wait_completion): New with error code.
+
+2013-08-12  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/sys.c (reset): Remove unneeded & for FT0, FT1, and FT2.
+
+2013-06-21  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/neug.ld.in: Change the placement of stacks.
+
+       * src/neug.c (rng): Handle interrupt by this thread.
+       (neug_mode_select): Mutual exclusion for mode change.
+
+       * src/adc_stm32f103.c (adc_wait): New.
+       (adc_start): Don't create thread.
+       (adc_intr_thread): Remove.
+
+       * src/neug.c: Rename from random.c.
+
+2013-06-19  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/main.c (usb_intr): Avoid interrupt masking by application.
+
+2013-06-18  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/random.c: Update for Chopstx.
+
+       * src/sys.c: Portable version (not for ChibiOS).  Version 2.0.
+       * src/sys.h (clock_init, gpio_init): New.
+
+       * src/stm32f103.h: New.
+
+       * src/neug.ld.in: Declare stack sizes.
+
+       * src/main.c: Update for Chopstx.
+       (usb_intr): Thread for interrupt handling.
+       (Vector90): Remove.
+       (EP1_IN_Callback): Use mutex and cond.
+       (event_flag_init, event_flag_waitone, event_flag_signal): New.
+       (led_blinker): Use event flag of our own.
+       (main): Use mutex and cond.  Use cancel and join.
+
+       * src/configure: Update for Chopstx.
+       (target): Defaults to FST_01.
+
+       * src/adc_stm32f103.c (STM32_ADC_ADC1_IRQ_PRIORITY): Remove.
+       (NEUG_DMA_MODE_CRC32): Add MINC, memory address increment.
+       (adc_init): Handle RCC initialization for ADC.
+       (adc_intr_thread): New.
+       (adc_start): Create a thread for interrupt handling.
+       (adc_start_conversion): Add DMA handling.
+       (adc_stop): Cancel a thread for interrupt handling.
+       (adc_lld_serve_rx_interrupt): Use bigger buffer (256-byte long).
+
+       * src/aes-constant-ft.c: Add comments.  Use stdint.h.
+
+       * src/config.h.in (FLASH_PAGE_SIZE): Remove.
+
+       * src/adc.h: Declare mutex and cond for Chopstx.
+
+       * chopstx: New, Chopstx RT Thread Library.
+       * chibios: Remove.
+       * src/Makefile.in: Update for Chopstx.
+
+       * src/usb_stm32f103.c (TRUE, FALSE): Defined here.
+
+2013-03-15  Niibe Yutaka  <gniibe@fsij.org>
+
+       * Version 0.06.
+
+       * src/main.c (vcom_string3): Updated.
+
+       Support relocatable reGNUal.
+
+       * src/neug.ld.in (_regnual_start): Now, it's just '.'.
+       * src/main.c (calculate_regnual_entry_address): New.
+       (main): Use calculate_regnual_entry_address for entry point.
+
+       New USB stack.
+
+       * src/main.c (device_desc, config_desc, string_descs): Remove.
+       (neug_device_reset, neug_ctrl_write_finish, neug_setup)
+       (neug_get_descriptor, neug_usb_event, usb_cb_interface): Rename to
+       usb_cb_*.
+       (Device_Method): Remove.
+       (main): Use vcom_configuration_desc.
+
+       * src/usb_lld.h, src/usb_stm32f103.c: Updated from Gnuk.
+
+2013-02-18  Niibe Yutaka  <gniibe@fsij.org>
+
+       * boards/STM32_PRIMER2/board.c, boards/STM32_PRIMER2/board.h:
+       Update for ChibiOS/RT 2.4.x.
+
+       * boards/FST_01/board.h: Use AN0 and AN9.
+
+       * src/random.c (noise_source_cnt_max_reset, noise_source_error):
+       Remove LED I/O.
+
+       * src/adc_stm32f103.c (ADC_SMPR2_SMP_AN9, ADC_CHANNEL_IN9): New.
+
+       * src/neug.h (neug_prng_reseed): Remove.
+
+       * chibios: Update.
+
+2013-02-07  Niibe Yutaka  <gniibe@fsij.org>
+
+       * Version 0.05.
+
+       * src/main.c (vcom_string3): Updated.
+
+2013-01-25  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/sha256.c (memcpy_bswap32): New function.
+       (bswap32_buf): Removed.
+       (sha256_finish): Use memcpy_bswap32.
+
+2013-01-24  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/sha256.c (v_cycle0): New.  Special case of v_cycle(i,j)
+       where j == 0.  Do byte order swapping here.
+       (v_cycle): Assume j != 0.
+       (sha256_process): Use v_cycle0 and v_cycle.
+       (sha256_update): Don't do byte order swapping.
+       (sha256_finish): Follow the change of sha256_process does byte
+       order swapping.
+
+2012-12-17  Niibe Yutaka  <gniibe@fsij.org>
+
+       * boards/FST_01_00: Added.
+
+2012-10-30  Niibe Yutaka  <gniibe@fsij.org>
+
+       * Version 0.04.
+
+       * src/main.c (vcom_string3): Updated.
+
+2012-10-26  Niibe Yutaka  <gniibe@fsij.org>
+
+       * NEUG_USB_DEVICE_ID (Product_STRING): Rename to NeuG True RNG.
+
+2012-10-23  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/random.c (neug_consume_random): New.
+
+       * src/main.c (copy_to_tx): New.
+       (main): Call neug_consume_random.
+
+2012-10-17  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/main.c (main): Wait for random number generation (instead of
+       sleeping).
+
+2012-10-16  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/random.c (neug_get_nonblock): New function.
+
+       * src/main.c (RANDOM_BYTES_LENGTH): Now, it's 64 to fill Tx
+       buffer.
+       (main): Fill 64-byte Tx buffer if possible.
+
+2012-10-15  Niibe Yutaka  <gniibe@fsij.org>
+
+       * tool/neug_check.py (main): Display USB strings.
+
+2012-10-13  Niibe Yutaka  <gniibe@fsij.org>
+
+       * boards/STBEE_MINI/board.c [!DFU_SUPPORT] (boardInit): Don't run
+       when "user switch" is pushed.  This is for JTAG/SWD debugger.
+
+2012-10-12  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/main.c (neug_setup): Support neug_*_max.
+
+       * src/random.c (ep_process): Enable health tests for
+       NEUG_MODE_RAW.
+       (rng): Don't use the result on error for NEUG_MODE_RAW.
+       (neug_rc_max, neug_p64_max, neug_p4k_max): New.
+       (repetition_count_test, adaptive_proportion_64_test)
+       (adaptive_proportion_4096_test): Record maximum counts.
+       (noise_source_cnt_max_reset): New.
+       (neug_mode_select): Call noise_source_cnt_max_reset on mode
+       change.
+
+       * tool/neug_check.py (get_info): Rename.
+       (main): Support max counts.
+
+2012-10-11  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/random.c (EP_ROUND_RAW_DATA_INPUTS): Set it to 32.
+
+       * tool/dfuse.py: Update from Gnuk 1.0.1.
+
+       * src/chconf.h (CORTEX_VTOR_INIT): Define.
+
+       * src/neug.ld.in (.sys): Follow the change of file layout.
+
+       * src/halconf.h (HAL_USE_EXT, HAL_USE_RTC): Define.
+       (ADC_USE_WAIT, ADC_USE_MUTUAL_EXCLUSION, SERIAL_BUFFERS_SIZE):
+       Remove.
+
+       * boards/FST_01/mcuconf.h (STM32_RTCSEL): Define.
+       (STM32_USBPRE, STM32_MCO): Remove.
+       * boards/STBEE/mcuconf.h: Likewise.
+       * boards/STM8S_DISCOVERY/mcuconf.h: Likewise.
+       * boards/OLIMEX_STM32_H103/mcuconf.h: Likewise.
+       * boards/STBEE_MINI/mcuconf.h: Likewise.
+       * boards/CQ_STARM/mcuconf.h: Likewise.
+       * boards/STM32_PRIMER2/mcuconf.h: Likewise.
+
+       * boards/common/mcuconf-common.h (STM32_NO_INIT)
+       (STM32_HSI_ENABLED, STM32_LSI_ENABLED, STM32_HSE_ENABLED)
+       (STM32_LSE_ENABLED, STM32_USB_CLOCK_REQUIRED, STM32_USBPRE)
+       (STM32_MCOSEL, STM32_PVD_ENABLE, STM32_PLS): Define.
+
+       * chibios: Updated to 2.4.3.
+
+       * src/usb_stm32f103.c: Rename (was: usb-lld.c).
+       * src/Makefile.in (CSRC): Follow the rename.
+
+2012-10-10  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/random.c (rng_gen): Remove.
+       (rng): Merge rng_gen, avoiding bigger lock.
+       (neug_mode_select): Better synchronization to rng thread.
+
+2012-10-09  Niibe Yutaka  <gniibe@fsij.org>
+
+       * Version 0.03.
+
+       * src/main.c (vcom_string3): Updated.
+
+2012-10-05  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/main.c (neug_state): Remove.
+       (neug_ctrl_write_finish, vcom_port_data_setup, EP1_IN_Callback)
+       (main): Use ->p_state (was: neug_state).
+       (main): Call chThdSleep (was: chEvtWaitOneTimeout).
+
+2012-10-03  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/main.c (USB_NEUG_GET_INFO): New.
+
+       * tool/neug_check.py: Show mode and errors.
+
+       * src/adc_stm32f103.c (adc_lld_serve_rx_interrupt)
+       (adc_start_conversion): Filter by CRC32.
+       * src/random.c (ep_init, ep_fill_wbuf, ep_process): Filter by CRC32.
+       (neug_init): CRC32 initialization.
+
+2012-10-02  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/random.c: Use our own ADC driver.
+
+       * src/halconf.h (HAL_USE_ADC): Set FALSE.
+       (STM32_DMA_REQUIRED): Define here.
+
+       * src/chconf.h (CH_USE_SEMAPHORES): Set FALSE.
+
+       * src/Makefile.in (CSRC): Add adc_stm32f103.c.
+
+       * src/adc.h, src/adc_stm32f103.c: New.
+
+       * src/random.c (NEUG_ADC_SETTING1_SMPR1): Tweak.
+
+2012-10-01  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/random.c (adc2_start): Add SCAN for ADC2.
+       (adcgrpcfg, NEUG_ADC_SETTING1_SMPR1, NEUG_ADC_SETTING2_SMPR1):
+       ADC1 three channels and ADC2 two channels, one same channel.
+
+       * boards/FST_01/board.h: Use default ADC settings.
+       * boards/OLIMEX_STM32_H103/board.h (NEUG_ADC_SETTING2_SMPR1)
+       (NEUG_ADC_SETTING2_SMPR2, NEUG_ADC_SETTING2_SQR3)
+       (NEUG_ADC_SETTING2_NUM_CHANNELS): Define.
+
+       * tool/neug_check.py: New.
+       * src/main.c (neug_setup, USB_NEUG_GET_ERR_COUNT): New.
+
+2012-09-28  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/random.c (neug_mode_select): Rename (was: neug_select).
+       Implement raw sample data output mode (with NEUG_MODE_RAW_DATA),
+       raw lsb data (before conditioning) is with NEUG_MODE_RAW_LSB.
+
+2012-09-27  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/random.c (ep_process): Feedback "additiona input" is now
+       half of previous output.
+
+       * boards/STBEE_MINI/board.h (NEUG_NON_DEFAULT_ADC_CHANNEL): New.
+       (VAL_GPIOACRL): Use PA1 and PA2 for NeuG's analog input.
+       (VAL_GPIOCCRL): Revert previous change.
+       * boards/STBEE_MINI/mcuconf.h (STM32_PPRE2, STM32_ADCPRE): Revert.
+
+       * src/main.c (RANDOM_BYTES_LENGTH): 32 is best for SHA-256
+       construct.
+
+       * src/random.c (adc2_stop, ep_process): New.
+       (rng_gen): Call ep_process.
+
+2012-09-26  Niibe Yutaka  <gniibe@fsij.org>
+
+       * boards/STM8S_DISCOVERY/mcuconf.h (STM32_PPRE2, STM32_ADCPRE):
+       12MHz ADC clock gives us more speed.
+       * boards/STM8S_DISCOVERY/board.h (VAL_GPIOCCRL): Digital push pull
+       output 50MHz gives us more entropy.
+
+       * boards/STBEE/mcuconf.h (STM32_PPRE2, STM32_ADCPRE): Ditto.
+       * boards/STBEE/board.h (VAL_GPIOCCRL): Ditto.
+
+       * boards/STBEE_MINI/mcuconf.h (STM32_PPRE2, STM32_ADCPRE): Ditto.
+       * boards/STBEE_MINI/board.h (VAL_GPIOCCRL): Ditto.
+
+       * boards/OLIMEX_STM32_H103/mcuconf.h (STM32_PPRE2, STM32_ADCPRE):
+       Ditto.
+       * boards/OLIMEX_STM32_H103/board.h (VAL_GPIOCCRL): Ditto.
+
+       * boards/FST_01/mcuconf.h (STM32_PPRE2, STM32_ADCPRE): Ditto.
+       * boards/FST_01/board.h (VAL_GPIOCCRL): Ditto.
+
+       * boards/CQ_STARM/mcuconf.h (STM32_PPRE2, STM32_ADCPRE): Ditto.
+       * boards/CQ_STARM/board.h (VAL_GPIOCCRL): Ditto.
+
+2012-09-25  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/random.c (adc2_start): New function.
+       (adcgrpcfg): Dual fast interleaved mode.
+       (rng_gen): Four-byte at a time.
+       (rng): Override DMA settings for 32-bit, and call adc2_start.
+
+       * src/random.c (adcgrpcfg): To acquire more entropy and more speed,
+       our choice is IN10 and IN11 (which is unconnected).
+
+2012-09-20  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/main.c (main): Call neug_select.
+       * src/random.c (neug_select): New.
+       (rng_gen): Implement Raw output.
+       (hash_df_initial_string): Fix (was: 32, no of bytes).
+       (rng): Implement error recovery.
+
+2012-09-19  Niibe Yutaka  <gniibe@fsij.org>
+
+       * tool/neug_upgrade.py: New.
+
+       * src/main.c (main): Support reGNUal.
+       * src/neug.ld.in (__ram_end__): Define.
+       * src/random.c (rng): Finish upon request of termination.
+       (neug_fini): New.
+       * src/neug.h (neug_fini): New.
+
+2012-09-18  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/random.c (NUM_NOISE_INPUTS, REPITITION_COUNT_TEST_CUTOFF)
+       (ADAPTIVE_PROPORTION_64_TEST_CUTOFF)
+       (ADAPTIVE_PROPORTION_4096_TEST_CUTOFF): Change for draft SP 800-90b,
+       the section 6.2 "Full Entropy Source Requirements".
+
+2012-09-13  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/aes-constant-ft.c: New (from Gnuk).
+
+2012-09-12  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/sha256.c, src/sha256.h: New (from Gnuk).
+
+       * boards/STBEE/board.h (GPIOD_USB_ENABLE): Fix.
+
+2012-09-11  Niibe Yutaka  <gniibe@fsij.org>
+
+       Health tests (SP 800-90b).
+       * src/random.c (repetition_count_test)
+       (adaptive_proportion_64_test, adaptive_proportion_4096_test): New.
+
+2012-09-10  Niibe Yutaka  <gniibe@fsij.org>
+
+       * NEUG_USB_DEVICE_ID: New file.
+
+       * src/main.c: Include usb-vid-pid-ver.c.inc and usb-strings.c.inc.
+
+       * src/configure (vidpid): New.
+
+2012-08-30  Niibe Yutaka  <gniibe@fsij.org>
+
+       * Version 0.02.
+
+2012-08-27  Niibe Yutaka  <gniibe@fsij.org>
+
+       Use WELL random number generator to whiten noise input.
+       * src/random.c (NUM_NOISE_INPUTS): Now, it's 6.
+       (tmt_init, tmt_one_step, tmt_value): Remove.
+       (well512a_step): New function.  WELL random number generator.
+       (neug_prng_reseed): Remove.
+
+       * src/main.c (main): Call neug_flash with time interval 2500ms,
+       while disconnected.
+       Don't call neug_prng_reseed.
+       More blinks.
+
+       * src/neug.h (NEUG_PRE_LOOP): It's 64 now (was: 32).
+
+2012-08-13  Niibe Yutaka  <gniibe@fsij.org>
+
+       * src/main.c (RANDOM_BYTES_LENGTH): It's now 60 (was: 32).
+       (neug_device_reset, neug_ctrl_write_finish)
+       (vcom_port_data_setup, neug_setup, neug_get_descriptor)
+       (neug_setup_endpoints_for_interface, neug_usb_event)
+       (neug_interface, Vector90, EP1_IN_Callback, EP2_IN_Callback)
+       (EP3_OUT_Callback): New.
+       (main): Now use usb_lld_* functions (was: ChibiOS SDU driver).
+
+       * boards/*/board.c (USB_Cable_Config, set_led): Remove.
+       , boards/*/board.h (SET_USB_CONDITION, SET_LED_CONDITION)
+       (GPIO_USB, IOPORT_USB, GPIO_LED, IOPORT_LED): Define.
+
+       * boards/common/board-common.c [DFU_SUPPORT] (__early_init): Don't
+       set SCB->VTOR here (it's done in reset in src/sys.c).
+
+       * src/halconf.h (HAL_USE_SERIAL_USB, HAL_USE_USB): Not define.
+       * src/Makefile.in (CSRC): Add sys.c and usb_lld.c
+       * src/sys.h, src/sys.c: New files (from Gnuk).
+       * src/usb_lld.h, src/usb_lld.c: New files (from Gnuk).
+
+2011-11-14  Niibe Yutaka  <gniibe@fsij.org>
+
+       * Version 0.01.
+
+       * src/Makefile.in (MCFLAGS): Override MCFLAGS option for newer
+       GCC of summon-arm-toolchain to add -mfix-cortex-m3-ldrd.
+       NOTE: This should not be needed (as -mcpu=cortex-m3 defaults
+       to -mfix-cortex-m3-ldrd for GCC-proper), but it is needed
+       to select arm-none-eabi/lib/thumb2/libc.a correctly.
+
+       * boards/common/board-common.c (__early_init): Revert change of
+       2011-10-05.
+
+       * boards/FST_01/{mcuconf.h,board.h,board.c}: New.
+
+       * src/main.c (my_sduRequestsHook): New.
+       (LED_ONESHOT_SHORT, LED_ONESHOT_LONG): New.
+       (led_blinker): Support LED_ONESHOT_SHORT and LED_ONESHOT_LONG.
+       (main): Call neug_prng_reseed for each new connection.
+
+2011-10-07  NIIBE Yutaka  <gniibe@fsij.org>
+
+       * src/random.c (neug_wait_full): New (from Gnuk).
+
 2011-10-06  NIIBE Yutaka  <gniibe@fsij.org>
 
        * src/random.c (neug_flush): New.
        (neug_prng_reseed): Call neug_flush.
-       (wa_rng): 64 is enough for working area.
 
 2011-10-05  NIIBE Yutaka  <gniibe@fsij.org>
 
        * boards/CQ_STARM: Added.
 
        * Version 0.00.
-