NUCLEO-F070RB Arduino core?

The official STMicroelectronics Arduino core
Post Reply
joelcrouch
Posts: 2
Joined: Thu Jun 08, 2017 12:13 pm

NUCLEO-F070RB Arduino core?

Post by joelcrouch » Thu Jun 08, 2017 7:56 pm

I recently purchased a NUCLEO-F070RB board with the Arduino UNO connectors on the board, but I have yet to find an Arduino board support package for it. Does one exist? If not, is it relatively easy to port an existing support package?

fpiSTM
Posts: 224
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: NUCLEO-F070RB Arduino core?

Post by fpiSTM » Thu Jun 08, 2017 8:29 pm

Hi @joelcrouch

As far as I know there is no one which include the variant for it.
This core include the support of F0: https://github.com/stm32duino/Arduino_Core_STM32
You should be able to add the variant for your board. It already incudes a variant for a Nucleo F091RC.
You could use it as an example.

Hereafter a link to genpinmap. A tool used to generate the pin mapping of the MCU (PeripheralPins.c file in variant folder).
https://github.com/fpistm/stm32_tools

User avatar
Rick Kimball
Posts: 1038
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: NUCLEO-F070RB Arduino core?

Post by Rick Kimball » Fri Jun 09, 2017 3:18 pm

Are there any instructions for step by step on how to create a new core, using this tool as a starting point? I would like to use the NUCLEO-F030R8 board I have.
-rick

User avatar
Rick Kimball
Posts: 1038
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: NUCLEO-F070RB Arduino core?

Post by Rick Kimball » Fri Jun 09, 2017 5:59 pm

This is the approach I took. It probably isn't optimal but it got me headed in the general direction of having something working. If there is a better way to be doing this, I'd appreciate any hints.

So here is the general approach I took to get something to compile for the NUCLEO-F030R8.

o Install STM32CubeMX and create a HAL blinky project for the board and SW4STM32 toolchain target, make sure you can blink the boards LED.
too many steps for me to explain here, you need to figure that out. The main thing you want to end up with is the ldscript.ld, the stm32f0xx_hal_conf.h, and the SystemClock_Config() function from main.c file the STM32CubeMX tool creates

o Find the right XML file for the chip you are using (I had already installed the STM32CubeMX java program)

Code: Select all

$ find ~/STM32CubeMX/ -iname '*.xml'  | grep STM32F030R
/home/kimballr/STM32CubeMX/db/mcu/STM32F030RCTx.xml
/home/kimballr/STM32CubeMX/db/mcu/STM32F030R8Tx.xml
seems like I want the STM32F030R8Tx.xml file.

o create a new board called 'NUCLEO_F030R8' and PeripheralPins.c file using the python script (I had already checked out the stm32_tools github repo)

Code: Select all

$ cd ~/github/stm32_tools/genpinmap/
$ python genpinmap_arduino.py NUCLEO_F030R8 "STM32F030R8Tx.xml"
$ find Arduino/
Arduino/
Arduino/NUCLEO_F030R8
Arduino/NUCLEO_F030R8/PeripheralPins.c
o copy the new variant to the my Arduino install

Code: Select all

$ cp -rv NUCLEO_F030R8/ ~/Arduino/hardware/st/Arduino_Core_STM32/variants/
o copy some starter files and then hack them up to match your chip

Code: Select all

$ cd ~/Arduino/hardware/st/Arduino_Core_STM32/variants/NUCLEO_F091RC/
$ ls
ldscript.ld  PeripheralPins.c  stm32f0xx_hal_conf.h  variant.cpp  variant.h
$ cp variant.cpp variant.h ../NUCLEO_F030R8
$ cd ../NUCLEO_F030R8/
$ cp [i]YOURCUBEMX_PROJECT_DIR[/i]/stm32f0xx_hal_conf.h .
$ cp [i]YOURCUBEMX_PROJECT_DIR[/i]/*.ld .
o edit variant.cpp and replace the SystemClock_Config() function in there with the function STM32CubeMX created in main.c.

o edit ~/Arduino/hardware/st/Arduino_Core_STM32/boards.txt and copy the section of one that is close, then paste and change the names to match your board

Code: Select all

I started with the NUCLEO_F091RC and changed all 091RC to 030R8
o edit cores/arduino/stm32/stm32_def_build.h add a new startupfile

Code: Select all

 #if defined(STM32F091xC)
 #define CMSIS_STARTUP_FILE "startup_stm32f091xc.s"
+#elif defined(STM32F030x8)
+#define CMSIS_STARTUP_FILE "startup_stm32f030x8.s"
Crank up arduino and see if you can compile. I hit a bunch of snags and worked though each one. Although I'm sure I'm a long way from making all the peripherals work. I encountered issues with my chip and either dealt with them or just commented them out until i could get a blinky program working.

o Timer issues in core/stm32/timer.c , the chip I copied has more advanced timer peripherals, I wasn't sure how to handle it so I just substituted a different one.

o DAC issues in he core/stm32/analog.c, this code doesn't degrade gracefully when it encounters a chip that doesn't have a DAC. It is using defines my chip doesn't have. I used the HAL config define 'HAL_DAC_MODULE_ENABLED' to turn off big chunks of code there that can't be used.
There is one thing that seems missing when a DAC is defined, it seems to be missing a guard around the DAC_CHANNEL_1
+#ifdef DAC_CHANNEL_1
case 1:
channel = DAC_CHANNEL_1;
break;
+#endif


In the end I did get my board led blinking and then I wrote this up before I forgot what I did.
-rick

fpiSTM
Posts: 224
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: NUCLEO-F070RB Arduino core?

Post by fpiSTM » Fri Jun 09, 2017 8:37 pm

Hi Rick,
I have to write all steps in the wiki and try to simplify them as far as possible.
Thanks for your posts.
About yours issues do not hesitate to submit an issue and/or submit your variant.
It still lot of work to enhance this repo but it is on the right way ;)

User avatar
Rick Kimball
Posts: 1038
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: NUCLEO-F070RB Arduino core?

Post by Rick Kimball » Sat Jun 10, 2017 5:26 pm

So further testing revealed all my digital pins seem to work properly using the F091RC variant.cpp as a template.

I also tested the USART2 connected to Serial and that works.

I ran into a snag when I started to look into the timers. I used the toneMelody app to test. It revealed to me that I'm missing a variable called

Code: Select all

const TimerMap TimerMap_CONFIG = { .. }
Is genpinmap_arduino.py supposed to be generating that in my PeriphalPins.c, or do I have to cobble that together for myself?
-rick

fpiSTM
Posts: 224
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: NUCLEO-F070RB Arduino core?

Post by fpiSTM » Mon Jun 12, 2017 7:03 am

No genpinmap do not generate it but I will remove it.
In fact it should be possible to have this array generic. I have to perform this.
Done
Last edited by fpiSTM on Thu Jun 22, 2017 9:03 pm, edited 1 time in total.

User avatar
Rick Kimball
Posts: 1038
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: NUCLEO-F070RB Arduino core?

Post by Rick Kimball » Fri Jun 16, 2017 4:16 pm

joelcrouch wrote:I recently purchased a NUCLEO-F070RB board with the Arduino UNO connectors on the board, but I have yet to find an Arduino board support package for it. Does one exist? If not, is it relatively easy to port an existing support package?
@joelcrouch the source code in github has been updated to support the STM32F030R8. This board has less memory and flash than your F070RB, however it might work for you in a slightly crippled fashion. Your chip has more 2x the ram and 2x the flash. So the IDE would complain if you wrote anything larger than the limits of the R030F8.

You should at least be able to blink an led and maybe get the Serial ports working.

Note: If I had a NUCELO-F070RB I'd give it a whirl, but I don't
-rick

Post Reply