Tweaks to 1.0 firmware. Not completely working yet :(

USG_1.0
Robert Fisk 9 years ago
parent e29ef84861
commit 25ff531917

@ -23,18 +23,6 @@
#define PB_JTDO GPIO_PIN_3
#define PB_NJTRST GPIO_PIN_4
#define USB_FS_VBUS_PIN GPIO_PIN_9
#define USB_FS_VBUS_PORT GPIOA
#define USB_FS_VBUSON_PIN GPIO_PIN_10
#define USB_FS_VBUSON_PORT GPIOA
#define USB_FS_FAULT_PIN GPIO_PIN_6
#define USB_FS_FAULT_PORT GPIOB
#define USB_HS_VBUS_PIN GPIO_PIN_13
#define USB_HS_VBUS_PORT GPIOB
#define USB_HS_VBUSON_PIN GPIO_PIN_8
#define USB_HS_VBUSON_PORT GPIOA
#define FAULT_LED_PIN GPIO_PIN_13
#define FAULT_LED_PORT GPIOC
#define FAULT_LED_ON (FAULT_LED_PORT->BSRR = (FAULT_LED_PIN << BSRR_SHIFT_LOW)) //Fault LED is active-low
@ -57,13 +45,13 @@
#define UPSTREAM_TX_REQUEST_DEASSERT (UPSTREAM_TX_REQUEST_PORT->BSRR = (UPSTREAM_TX_REQUEST_PIN << BSRR_SHIFT_HIGH))
#define DBGMCU_IDCODE_DEV_ID_405_407_415_417 0x413
#define DBGMCU_IDCODE_DEV_ID_401xB_xC 0x423
#define DBGMCU_IDCODE_DEV_ID_401xB_xC 0x423
#define BOARD_REV_PIN_MASK 0x07
#define BOARD_ID_PIN_MASK 0x08
#define BOARD_REV_ID_PORT GPIOC
#define BOARD_REV_PIN_MASK 0x07
#define BOARD_ID_PIN_MASK 0x08
#define BOARD_REV_ID_PORT GPIOC
#define BOARD_REV_1_0_BETA 0
#define BOARD_REV_1_0_BETA 0
#endif /* INC_BOARD_CONFIG_H_ */

@ -99,7 +99,7 @@
* (when HSE is used as system clock source, directly or through the PLL).
*/
#if !defined (HSE_VALUE)
#define HSE_VALUE ((uint32_t)12000000) /*!< Value of the External oscillator in Hz */
#define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */
#if !defined (HSE_STARTUP_TIMEOUT)

@ -79,31 +79,31 @@ int main(void)
void CheckFirmwareMatchesHardware(void)
{
//Check we are running on the expected hardware:
//STM32F407 on an Olimex dev board
//STM32F401RC on USG v1.0 beta
GPIO_InitTypeDef GPIO_InitStruct;
if ((*(uint32_t*)DBGMCU_BASE & DBGMCU_IDCODE_DEV_ID) == DBGMCU_IDCODE_DEV_ID_401xB_xC)
{
//Read in board revision and ID on port C
__HAL_RCC_GPIOC_CLK_ENABLE();
GPIO_InitStruct.Pin = BOARD_REV_PIN_MASK | BOARD_ID_PIN_MASK;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
GPIO_InitStruct.Alternate = 0;
HAL_GPIO_Init(BOARD_REV_ID_PORT, &GPIO_InitStruct);
//Correct board revision?
if ((BOARD_REV_ID_PORT->IDR & BOARD_REV_PIN_MASK) == BOARD_REV_1_0_BETA)
{
//Correct board ID: downstream?
if (!(BOARD_REV_ID_PORT->IDR & BOARD_ID_PIN_MASK))
{
return;
}
}
}
if ((*(uint32_t*)DBGMCU_BASE & DBGMCU_IDCODE_DEV_ID) == DBGMCU_IDCODE_DEV_ID_401xB_xC)
{
//Read in board revision and ID on port C
__HAL_RCC_GPIOC_CLK_ENABLE();
GPIO_InitStruct.Pin = BOARD_REV_PIN_MASK | BOARD_ID_PIN_MASK;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
GPIO_InitStruct.Alternate = 0;
HAL_GPIO_Init(BOARD_REV_ID_PORT, &GPIO_InitStruct);
//Correct board revision?
if ((BOARD_REV_ID_PORT->IDR & BOARD_REV_PIN_MASK) == BOARD_REV_1_0_BETA)
{
//Correct board ID: downstream?
if (!(BOARD_REV_ID_PORT->IDR & BOARD_ID_PIN_MASK))
{
return;
}
}
}
//This is not the hardware we expected, so turn on our fault LED(s) and die in a heap.
GPIO_InitStruct.Pin = FAULT_LED_PIN | H405_FAULT_LED_PIN;
@ -159,13 +159,12 @@ void GPIO_Init(void)
GPIO_InitTypeDef GPIO_InitStruct;
/* GPIO Ports Clock Enable */
//__GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOE_CLK_ENABLE();
/* GPIO Ports Clock Enable */
//__GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
//Bulk initialise all ports as inputs with pullups active,
//excluding JTAG pins which must remain as AF0!
@ -180,36 +179,18 @@ void GPIO_Init(void)
GPIO_InitStruct.Pin = GPIO_PIN_All;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
//USB VBUS pins are analog input
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pin = USB_FS_VBUS_PIN;
HAL_GPIO_Init(USB_FS_VBUS_PORT, &GPIO_InitStruct);
GPIO_InitStruct.Pin = USB_HS_VBUS_PIN;
HAL_GPIO_Init(USB_HS_VBUS_PORT, &GPIO_InitStruct);
//Enable USB_FS power
USB_FS_VBUSON_PORT->BSRR = (USB_FS_VBUSON_PIN << BSRR_SHIFT_HIGH);
//Fault LED is output
GPIO_InitStruct.Pin = FAULT_LED_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Pin = USB_FS_VBUSON_PIN;
HAL_GPIO_Init(USB_FS_VBUSON_PORT, &GPIO_InitStruct);
//Disable USB_HS power
USB_HS_VBUSON_PORT->BSRR = (USB_HS_VBUSON_PIN << BSRR_SHIFT_LOW);
GPIO_InitStruct.Pin = USB_HS_VBUSON_PIN;
HAL_GPIO_Init(USB_HS_VBUSON_PORT, &GPIO_InitStruct);
//STAT_LED is output
FAULT_LED_OFF;
GPIO_InitStruct.Pin = FAULT_LED_PIN;
HAL_GPIO_Init(FAULT_LED_PORT, &GPIO_InitStruct);
FAULT_LED_OFF;
//SPI_INT_ACTIVE indicator
GPIO_InitStruct.Pin = INT_ACTIVE_PIN;
HAL_GPIO_Init(INT_ACTIVE_PORT, &GPIO_InitStruct);
INT_ACTIVE_OFF;
// //SPI_INT_ACTIVE indicator
// GPIO_InitStruct.Pin = INT_ACTIVE_PIN;
// HAL_GPIO_Init(INT_ACTIVE_PORT, &GPIO_InitStruct);
// INT_ACTIVE_OFF;
}

@ -22,16 +22,13 @@
#define PB_JTDO GPIO_PIN_3
#define PB_NJTRST GPIO_PIN_4
#define USB_P_PIN GPIO_PIN_4
#define USB_P_PORT GPIOC
#define FAULT_LED_PIN GPIO_PIN_13
#define FAULT_LED_PORT GPIOC
#define FAULT_LED_ON (FAULT_LED_PORT->BSRR = (FAULT_LED_PIN << BSRR_SHIFT_LOW)) //Fault LED is active-low
#define FAULT_LED_OFF (FAULT_LED_PORT->BSRR = (FAULT_LED_PIN << BSRR_SHIFT_HIGH))
#define H405_FAULT_LED_PIN GPIO_PIN_12 //Fault LED on Olimex H405 board
#define H405_FAULT_LED_ON (FAULT_LED_PORT->BSRR = (H405_FAULT_LED_PIN << BSRR_SHIFT_LOW))
#define H405_FAULT_LED_PIN GPIO_PIN_12 //Fault LED on Olimex H405 board
#define H405_FAULT_LED_ON (FAULT_LED_PORT->BSRR = (H405_FAULT_LED_PIN << BSRR_SHIFT_LOW))
#define INT_ACTIVE_PIN GPIO_PIN_5 //Temporary indicator of SPI (or whatever) activity
#define INT_ACTIVE_PORT GPIOB
@ -48,13 +45,13 @@
#define DOWNSTREAM_TX_OK_ACTIVE (!(DOWNSTREAM_TX_OK_PORT->IDR & DOWNSTREAM_TX_OK_PIN))
#define DBGMCU_IDCODE_DEV_ID_405_407_415_417 0x413
#define DBGMCU_IDCODE_DEV_ID_401xB_xC 0x423
#define DBGMCU_IDCODE_DEV_ID_401xB_xC 0x423
#define BOARD_REV_PIN_MASK 0x07
#define BOARD_ID_PIN_MASK 0x08
#define BOARD_REV_ID_PORT GPIOC
#define BOARD_REV_PIN_MASK 0x07
#define BOARD_ID_PIN_MASK 0x08
#define BOARD_REV_ID_PORT GPIOC
#define BOARD_REV_1_0_BETA 0
#define BOARD_REV_1_0_BETA 0
#endif /* INC_BOARD_CONFIG_H_ */

@ -74,16 +74,16 @@ void OTG_FS_IRQHandler(void)
void DMA2_Stream2_IRQHandler(void)
{
INT_ACTIVE_ON;
// INT_ACTIVE_ON;
HAL_DMA_IRQHandler(&spiRxDmaHandle);
INT_ACTIVE_OFF;
// INT_ACTIVE_OFF;
}
void DMA2_Stream3_IRQHandler(void)
{
INT_ACTIVE_ON;
// INT_ACTIVE_ON;
HAL_DMA_IRQHandler(&spiTxDmaHandle);
INT_ACTIVE_OFF;
// INT_ACTIVE_OFF;
}
void EXTI3_IRQHandler(void)

@ -84,40 +84,40 @@ int main(void)
void CheckFirmwareMatchesHardware(void)
{
//Check we are running on the expected hardware:
//STM32F405 on an Olimex dev board
//STM32F401RC on USG v1.0 beta
GPIO_InitTypeDef GPIO_InitStruct;
if ((*(uint32_t*)DBGMCU_BASE & DBGMCU_IDCODE_DEV_ID) == DBGMCU_IDCODE_DEV_ID_401xB_xC)
{
//Read in board revision and ID on port C
__HAL_RCC_GPIOC_CLK_ENABLE();
GPIO_InitStruct.Pin = BOARD_REV_PIN_MASK | BOARD_ID_PIN_MASK;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
GPIO_InitStruct.Alternate = 0;
HAL_GPIO_Init(BOARD_REV_ID_PORT, &GPIO_InitStruct);
//Correct board revision?
if ((BOARD_REV_ID_PORT->IDR & BOARD_REV_PIN_MASK) == BOARD_REV_1_0_BETA)
{
//Correct board ID: upstream?
if ((BOARD_REV_ID_PORT->IDR & BOARD_ID_PIN_MASK))
{
return;
}
}
}
//This is not the hardware we expected, so turn on our fault LED(s) and die in a heap.
GPIO_InitStruct.Pin = FAULT_LED_PIN | H405_FAULT_LED_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(FAULT_LED_PORT, &GPIO_InitStruct);
FAULT_LED_ON;
H405_FAULT_LED_ON;
while (1);
if ((*(uint32_t*)DBGMCU_BASE & DBGMCU_IDCODE_DEV_ID) == DBGMCU_IDCODE_DEV_ID_401xB_xC)
{
//Read in board revision and ID on port C
__HAL_RCC_GPIOC_CLK_ENABLE();
GPIO_InitStruct.Pin = BOARD_REV_PIN_MASK | BOARD_ID_PIN_MASK;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
GPIO_InitStruct.Alternate = 0;
HAL_GPIO_Init(BOARD_REV_ID_PORT, &GPIO_InitStruct);
//Correct board revision?
if ((BOARD_REV_ID_PORT->IDR & BOARD_REV_PIN_MASK) == BOARD_REV_1_0_BETA)
{
//Correct board ID: upstream?
if ((BOARD_REV_ID_PORT->IDR & BOARD_ID_PIN_MASK))
{
return;
}
}
}
//This is not the hardware we expected, so turn on our fault LED(s) and die in a heap.
GPIO_InitStruct.Pin = FAULT_LED_PIN | H405_FAULT_LED_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(FAULT_LED_PORT, &GPIO_InitStruct);
FAULT_LED_ON;
H405_FAULT_LED_ON;
while (1);
}
@ -191,24 +191,19 @@ void GPIO_Init(void)
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
//USB_P is analog input
GPIO_InitStruct.Pin = USB_P_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_Init(USB_P_PORT, &GPIO_InitStruct);
//STAT_LED is output
//Fault LED is output
GPIO_InitStruct.Pin = FAULT_LED_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(FAULT_LED_PORT, &GPIO_InitStruct);
FAULT_LED_OFF;
//SPI_INT_ACTIVE indicator
GPIO_InitStruct.Pin = INT_ACTIVE_PIN;
//GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
//GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(INT_ACTIVE_PORT, &GPIO_InitStruct);
INT_ACTIVE_OFF;
// //SPI_INT_ACTIVE indicator
// GPIO_InitStruct.Pin = INT_ACTIVE_PIN;
// //GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
// //GPIO_InitStruct.Pull = GPIO_NOPULL;
// HAL_GPIO_Init(INT_ACTIVE_PORT, &GPIO_InitStruct);
// INT_ACTIVE_OFF;
}
/* USER CODE BEGIN 4 */

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="ilg.gnuarmeclipse.debug.gdbjtag.openocd.launchConfigurationType">
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.PERIPHERALS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;peripherals/&gt;&#10;"/>
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.PERIPHERALS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;peripherals&gt;&#10;&lt;peripheral name=&quot;DMA2&quot;/&gt;&#10;&lt;/peripherals&gt;&#10;"/>
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doContinue" value="true"/>
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doDebugInRam" value="false"/>
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doFirstReset" value="true"/>

Loading…
Cancel
Save