Running Demo code on STM32F0 discovery

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
JohnL
Posts: 16
Joined: Mon Nov 11, 2013 12:49 am

Running Demo code on STM32F0 discovery

Post by JohnL »

Hey,
I'm new to both chibios and ARM programming, Im wondering about all the steps necessary to run and load the stm32f1 demo code on a stm32f0 board. Right now I have ubuntu with the gcc cross compiler and st-util. I have just compiled the F1 board and targeted it to the f0 discovery which started loading but didn't finish(understandable), and I think I need some guidance as to which files I need to change.

Thanks

John
beaming
Posts: 11
Joined: Sun Nov 10, 2013 9:27 pm

Re: Running Demo code on STM32F0 discovery

Post by beaming »

To flash I use the following line

Code: Select all

st-flash write  build/ch.bin  0x8000000

I work with stm32l1, but I thinkthe flashing directive is the same for stm32f0 as well.

I find that I cannot work with openocd reliably, but st-flash works.
JohnL
Posts: 16
Joined: Mon Nov 11, 2013 12:49 am

Re: Running Demo code on STM32F0 discovery

Post by JohnL »

I think? I just need to point the make file to the f0 appropriate places:include $(CHIBIOS)/boards/ST_STM32VL_DISCOVERY/board.mk

Code: Select all

include $(CHIBIOS)/os/hal/platforms/STM32F1xx/platform.mk
include $(CHIBIOS)/os/hal/hal.mk
include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F1xx/port.mk


I changed these, but my make is still tossing errors,
I removed the include stm32f10x.h from stm32.h, now Im getting more fundamental issues:

Code: Select all

Compiling test.c
In file included from ../../os/hal/include/hal.h:43:0,
                 from ../../test/test.c:26:
../../os/hal/platforms/STM32F0xx/hal_lld.h:393:2: error: #error "Using a wrong mcuconf.h file, STM32F0xx_MCUCONF not defined"
In file included from ../../os/hal/platforms/STM32F0xx/hal_lld.h:766:0,
                 from ../../os/hal/include/hal.h:43,
                 from ../../test/test.c:26:
../../os/hal/platforms/STM32F0xx/stm32_dma.h:183:3: error: unknown type,
../../os/hal/platforms/STM32F0xx/stm32_dma.h:183:3: error: unknown type name 'DMA_Channel_TypeDef'
In file included from ../../os/hal/include/hal.h:53:0,
                 from ../../test/test.c:26:
../../os/hal/include/tm.h:77:3: error: unknown type name 'halrtcnt_t'
../../os/hal/include/tm.h:78:3: error: unknown type name 'halrtcnt_t'
../../os/hal/include/tm.h:79:3: error: unknown type name 'halrtcnt_t'
In file included from ../../os/hal/include/adc.h:94:0,
                 from ../../os/hal/include/hal.h:55,
                 from ../../test/test.c:26:
../../os/hal/platforms/STM32F0xx/adc_lld.h:286:3: error: unknown type name 'ADC_TypeDef'
In file included from ../../os/hal/include/pwm.h:103:0,
                 from ../../os/hal/include/hal.h:62,
                 from ../../test/test.c:26:
../../os/hal/platforms/STM32/TIMv1/pwm_lld.h:258:2: error: #error "Invalid IRQ priority assigned to TIM3"
In file included from ../../os/hal/include/serial.h:111:0,
                 from ../../os/hal/include/hal.h:64,
                 from ../../test/test.c:26:
../../os/hal/platforms/STM32/USARTv2/serial_lld.h:175:2: error: #error "Invalid IRQ priority assigned to USART1"
In file included from ../../os/hal/include/hal.h:64:0,
                 from ../../test/test.c:26:
../../os/hal/include/serial.h:138:3: error: unknown type name 'USART_TypeDef'
In file included from ../../os/hal/include/spi.h:93:0,
                 from ../../os/hal/include/hal.h:66,
                 from ../../test/test.c:26:
../../os/hal/platforms/STM32/SPIv2/spi_lld.h:222:2: error: #error "Invalid IRQ priority assigned to SPI1"
../../os/hal/platforms/STM32/SPIv2/spi_lld.h:252:2: error: #error "invalid DMA stream associated to SPI1 RX"
../../os/hal/platforms/STM32/SPIv2/spi_lld.h:257:2: error: #error "invalid DMA stream associated to SPI1 TX"
../../os/hal/platforms/STM32/SPIv2/spi_lld.h:363:3: error: unknown type name 'SPI_TypeDef'


Obviously commenting out that stm32f10x.h from stm32.h was a mistake. Does anyone have a working make/ demo for stmf0 discovery?
beaming
Posts: 11
Joined: Sun Nov 10, 2013 9:27 pm

Re: Running Demo code on STM32F0 discovery

Post by beaming »

I would suggest to start from either of the directories in the
testhal/STM32F0xx
They have known to work code samples. You will just need to trace appropriate pins to the ones at your board.

Most importantly they have a proper Makefile which compiles, just fill it with needed extras.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Running Demo code on STM32F0 discovery

Post by Giovanni »

The key part is this one:

JohnL wrote:#error "Using a wrong mcuconf.h file, STM32F0xx_MCUCONF not defined"


You need to take the file mcuconf.h from an F0 demo, they are different for each family. I suggest you start from an F0 demo then add what you need.

Giovanni
JohnL
Posts: 16
Joined: Mon Nov 11, 2013 12:49 am

Re: Running Demo code on STM32F0 discovery

Post by JohnL »

Thanks! I didn't realize there was other demos in the TEST folders

Ive got code running!

No to figure out how to use chibios! Best regards

John
Post Reply