Giovanni wrote:Those are problems related to your platform, I never used gentoo so can't help there.
Giovanni
Serial Initialization in Dem Crashes on Nucleo STM32F030R8T6
Moderator: RoccoMarco
Re: Serial Initialization in Dem Crashes on Nucleo STM32F030
But that doesn't explain why not even a signal is sent through Tx. I tried the CodeSourcery GCC 4.8 toolchain and the suggested 4.7 from launchpad, but neither works. Also, did you get the ST-Link one work on linux? I never get anything from /dev/ttyACM0. I will try to write my own UART code to test whether it is because of ChibiOS or not.
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Serial Initialization in Dem Crashes on Nucleo STM32F030
I made the ST-Link 1 work under Ubuntu years ago but it was a mess because you have to put the device into an exclusion list (different from Linux to Linux), there is a small guide in the OpenOCD documentation.
ST-Link 2 was much easier but still there was a setting to do.
Giovanni
ST-Link 2 was much easier but still there was a setting to do.
Giovanni
Re: Serial Initialization in Dem Crashes on Nucleo STM32F030
I believe Nucleo is ST-Link 2. I will try look for the guide, but I am not sure if I can find it.
Giovanni wrote:I made the ST-Link 1 work under Ubuntu years ago but it was a mess because you have to put the device into an exclusion list (different from Linux to Linux), there is a small guide in the OpenOCD documentation.
ST-Link 2 was much easier but still there was a setting to do.
Giovanni
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Serial Initialization in Dem Crashes on Nucleo STM32F030
Nucleo is ST-Link 2-1, I never tried this one under Linux. It has multiple USB devices implemented so it is possible a whole new set of problems....
Giovanni
Giovanni
Re: Serial Initialization in Dem Crashes on Nucleo STM32F030
OK... However, I cannot even get USART1 with and external TTL-USB to work. I am trying to use some standalone code to test the serial out, but not yet successful.
I cannot even measure anything from the Tx pin.
Code: Select all
int uart_open(USART_TypeDef* USARTx, uint32_t baud, uint32_t flags) {
if (USARTx == USART1) {
RCC->AHBENR |= RCC_AHBENR_GPIOAEN;
RCC->APB2ENR |= RCC_APB2ENR_USART1EN;
/* PA2, Tx, AF1 */
GPIOA->MODER &= ~(GPIO_MODER_MODER2);
GPIOA->MODER |= GPIO_MODER_MODER2_1;
GPIOA->PUPDR &= ~(GPIO_PUPDR_PUPDR2);
GPIOA->PUPDR |= (GPIO_PUPDR_PUPDR2_0);
GPIOA->OTYPER &= GPIO_OTYPER_OT_2;
GPIOA->OSPEEDR |= ~GPIO_OSPEEDER_OSPEEDR2;
/* PA3, Rx, In Float */
GPIOA->MODER &= ~(GPIO_MODER_MODER3);
GPIOA->PUPDR &= ~(GPIO_PUPDR_PUPDR3);
/* AF 1 */
GPIOA->AFRL &= ~(GPIO_AFRL_AFRL2 | GPIO_AFRL_AFRL3);
GPIOA->AFRL |= (0b0001 << 8) | (0b0001 << 12);
}
/* Reset */
USARTx->CR1 = 0x0000;
USARTx->CR1 &= ~(USART_CR1_M);
/* Reset */
USARTx->CR2 = 0x0000;
/* Reset */
USARTx->CR3 = 0x0000;
/* Baud */
USARTx->BRR = SYSCLK / baud;
/* Enable */
USARTx->CR1 |= USART_CR1_TE | USART_CR1_RE | USART_CR1_UE;
}
int uart_putc(char c, USART_TypeDef* USARTx)
{
while (!(USARTx->ISR & USART_ISR_TXE));
USARTx->TDR = (c & 0xff);
return 0;
}
I cannot even measure anything from the Tx pin.
Giovanni wrote:Nucleo is ST-Link 2-1, I never tried this one under Linux. It has multiple USB devices implemented so it is possible a whole new set of problems....
Giovanni
Re: Serial Initialization in Dem Crashes on Nucleo STM32F030
OK, I found some very small note saying that PA2 and PA3 as USART1 is 'STM32F030x6/4 only', and on Nucleo, where STM32F030x8 is used, USART1 is connected to PA9 and PA10. This could be the problem.
Re: Serial Initialization in Dem Crashes on Nucleo STM32F030
OK, my own standalone version works now. I reconfigured GPIO to TX->PA9 and RX->PA10,
Code: Select all
int uart_open(USART_TypeDef* USARTx, uint32_t baud, uint32_t flags) {
if (USARTx == USART1) {
RCC->AHBENR |= RCC_AHBENR_GPIOAEN;
RCC->APB2ENR |= RCC_APB2ENR_USART1EN;
/* PA2, Tx, AF1 */
GPIOA->MODER &= ~(GPIO_MODER_MODER9);
GPIOA->MODER |= GPIO_MODER_MODER9_1;
GPIOA->PUPDR &= ~(GPIO_PUPDR_PUPDR9);
GPIOA->PUPDR |= (GPIO_PUPDR_PUPDR9_0);
GPIOA->OTYPER &= GPIO_OTYPER_OT_9;
GPIOA->OSPEEDR |= ~GPIO_OSPEEDER_OSPEEDR9;
/* PA3, Rx, In Float */
GPIOA->MODER &= ~(GPIO_MODER_MODER10);
GPIOA->PUPDR &= ~(GPIO_PUPDR_PUPDR10);
/* AF 1 */
GPIOA->AFRH &= ~(GPIO_AFRH_AFRH1 | GPIO_AFRH_AFRH2);
GPIOA->AFRH |= (0b0001 << 4) | (0b0001 << 8);
}
/* Reset */
USARTx->CR1 = 0x0000;
USARTx->CR1 &= ~(USART_CR1_M);
/* Reset */
USARTx->CR2 = 0x0000;
/* Reset */
USARTx->CR3 = 0x0000;
/* Baud */
USARTx->BRR = SYSCLK / baud;
/* Enable */
USARTx->CR1 |= USART_CR1_TE | USART_CR1_RE | USART_CR1_UE;
}
int uart_putc(char c, USART_TypeDef* USARTx)
{
while (!(USARTx->ISR & USART_ISR_TXE));
USARTx->TDR = (c & 0xff);
return 0;
}
Re: Serial Initialization in Dem Crashes on Nucleo STM32F030
Now I am trying the ChibiOS one:
And nothing shows up. I am still plugging into the same pins now.
Code: Select all
sdStart(&SD1, NULL)
while (TRUE) {
if (!palReadPad(GPIOC, GPIOC_BUTTON))
TestThread(&SD1);
chThdSleepMilliseconds(500);
}
And nothing shows up. I am still plugging into the same pins now.
Re: Serial Initialization in Dem Crashes on Nucleo STM32F030
OK, I solved it. I changed definitions in for the functions of PA9/PA10. BTW, I renamed USART_TX to USART2_TX and USART_RX to USART2_RX, while changing the PA9 and PA10 to USART1_TX and USART1_RX, and along with their functions.
Code: Select all
boards/ST_NUCLEO_F030R8/board.h