From 9ad6c6461d4885c20edfec955fd61194b3fdf7e0 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 6 Jul 2012 08:26:20 +0900 Subject: [PATCH] SPI flash support starts for FST-01 --- ChangeLog | 5 +++++ boards/FST_01/board.h | 6 +++++- tool/stlinkv2.py | 11 +++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 44b7562..7fcd9d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-07-06 Niibe Yutaka + + * boards/FST_01/board.h (VAL_GPIOACRL): Change for SPI flash. + * tool/stlinkv2.py (stlinkv2.setup_gpio): Likewise. + 2012-07-05 Niibe Yutaka * src/call-rsa.c (rsa_sign, rsa_decrypt): Don't need to setup N. diff --git a/boards/FST_01/board.h b/boards/FST_01/board.h index cf911a3..7b78e93 100644 --- a/boards/FST_01/board.h +++ b/boards/FST_01/board.h @@ -97,12 +97,16 @@ * PA0 - input with pull-up (TIM2_CH1) * PA1 - input with pull-down (TIM2_CH2) * PA2 - input with pull-up (TIM2_CH3) + * PA4 - Push pull output (SPI1_NSS) + * PA5 - Alternate Push pull output (SPI1_SCK) + * PA6 - Alternate Push pull output (SPI1_MISO) + * PA7 - Alternate Push pull output (SPI1_MOSI) * PA11 - input with pull-up (USBDM) * PA12 - input with pull-up (USBDP) * Everything input with pull-up except: * PA10 - Push pull output (USB 1:ON 0:OFF) */ -#define VAL_GPIOACRL 0x88888888 /* PA7...PA0 */ +#define VAL_GPIOACRL 0xBBB38888 /* PA7...PA0 */ #define VAL_GPIOACRH 0x88888388 /* PA15...PA8 */ #define VAL_GPIOAODR 0xFFFFFFFD diff --git a/tool/stlinkv2.py b/tool/stlinkv2.py index e99c80e..ff0e676 100755 --- a/tool/stlinkv2.py +++ b/tool/stlinkv2.py @@ -217,19 +217,22 @@ class stlinkv2(object): # For FST-01-00 and FST-01: LED on, USB off def setup_gpio(self): apb2enr = self.read_memory_u32(0x40021018) - apb2enr = apb2enr | 4 | 8 # Enable port A and B - self.write_memory_u32(0x40021018, apb2enr) # RCC->APB2ENR - self.write_memory_u32(0x4002100c, 4|8) # RCC->APB2RSTR + apb2enr = apb2enr | 4 | 8 | 0x1000 # Enable port A, port B, and SPI1 + self.write_memory_u32(0x40021018, apb2enr) # RCC->APB2ENR + self.write_memory_u32(0x4002100c, 4|8|0x1000) # RCC->APB2RSTR self.write_memory_u32(0x4002100c, 0) self.write_memory_u32(GPIOA+0x0c, 0xfffffbff) # ODR self.write_memory_u32(GPIOA+0x04, 0x88888383) # CRH - self.write_memory_u32(GPIOA+0x00, 0x88888888) # CRL + self.write_memory_u32(GPIOA+0x00, 0xBBB38888) # CRL self.write_memory_u32(GPIOB+0x0c, 0xffffffff) # ODR self.write_memory_u32(GPIOB+0x04, 0x88888883) # CRH self.write_memory_u32(GPIOB+0x00, 0x88888888) # CRL # For FST-01-00 and FST-01: LED off, USB off def finish_gpio(self): + apb2enr = self.read_memory_u32(0x40021018) + apb2enr = apb2enr & ~(4 | 8 | 0x1000) + self.write_memory_u32(0x40021018, apb2enr) # RCC->APB2ENR self.write_memory_u32(GPIOA+0x0c, 0xfffffaff) # ODR self.write_memory_u32(GPIOB+0x0c, 0xfffffffe) # ODR