Introducing the new Arduino core for STM32

The official STMicroelectronics Arduino core
ChrisMicro
Posts: 316
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: Introducing the new Arduino core for STM32

Post by ChrisMicro » Sat Jun 10, 2017 8:11 am

Hi Together,

I just tried the repo with the SM32F746 discovery.
The SD-Card examples work, but the TFT examples did not.

In the STM32GENERIC repo the TFT examples are working including touch.

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

Re: Introducing the new Arduino core for STM32

Post by fpiSTM » Sat Jun 10, 2017 11:01 am

Hi Chris,

it is a known issue.
https://github.com/stm32duino/Arduino_C ... 2/issues/2
I have to change the name of the modified SD library (SD.h) in order to use the default one through SPI (when you use th SD from the TFT shield).
And make some correction to the modified SD lib to be able to use the onboard SD with TFT shield (TFT lib pass the File opende by copy and in this implementation the copy reset the fp, so it read always from the beginning)

Note: the LCD from the F746 is not supported at this time

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

Re: Introducing the new Arduino core for STM32

Post by Rick Kimball » Sat Jun 10, 2017 3:06 pm

fpiSTM wrote: All pins are available based on mbed pinmap feature.
PeripheralPins.c automatically generated from stm32cube mcu xml file. This avoid issue on pins definition.
Python script to generate it, is available here:
https://github.com/fpistm/stm32_tools
Pins capabilities are configurable through this file by commenting or not pin description.
When you say it is using the mbed pinmap feature, do you mean the same structure?

I noticed at least for the NUCLEO boards I looked at, the pins are named PPORT_NUM. Whereas you have PPORTNUM. That means mbed uses PA_5 and you use PA5. Did you plan to track their names or just their structure? I'm not advocating for the mbed style, just trying to clarify what you mean about the pinmap feature.


For the user the pin names in your core can't be used as a pin number directly as they can be with the maple core. Just something to keep in mind when using this core.


const int ledPin = pinNametoPinNumber(PA5); //13;// the number of the LED pin

The comment above is no longer true since https://github.com/stm32duino/Arduino_C ... 32/pull/83
-rick

danieleff
Posts: 336
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: Introducing the new Arduino core for STM32

Post by danieleff » Sun Jun 11, 2017 3:59 am

fpiSTM wrote:Hi Chris,

it is a known issue.
https://github.com/stm32duino/Arduino_C ... 2/issues/2
I have to change the name of the modified SD library (SD.h) in order to use the default one through SPI (when you use th SD from the TFT shield).
And make some correction to the modified SD lib to be able to use the onboard SD with TFT shield (TFT lib pass the File opende by copy and in this implementation the copy reset the fp, so it read always from the beginning)

Note: the LCD from the F746 is not supported at this time
But still, how to access the touch chip on I2C3(PH8/PH7)? It is commented out: https://github.com/stm32duino/Arduino_C ... ins.c#L112
(Slightly unrelated, how to access non-first peripherals in general, SPI2, SPI3, I2C2, I2C3, UART2, ...)

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

Re: Introducing the new Arduino core for STM32

Post by fpiSTM » Sun Jun 11, 2017 9:35 am

Rick Kimball wrote: When you say it is using the mbed pinmap feature, do you mean the same structure?
Yes, the same way to define the pins and access to pins info, stored in a u32.
Rick Kimball wrote: I noticed at least for the NUCLEO boards I looked at, the pins are named PPORT_NUM. Whereas you have PPORTNUM. That means mbed uses PA_5 and you use PA5. Did you plan to track their names or just their structure? I'm not advocating for the mbed style, just trying to clarify what you mean about the pinmap feature.
Yes mbed use PY_X for compatibility with high layer. For arduino it does not need to keep this naming. Same for the instance DAC_X , SPI_X.
Rick Kimball wrote: For the user the pin names in your core can't be used as a pin number directly as they can be with the maple core. Just something to keep in mind when using this core.

Code: Select all

const int ledPin =  pinNametoPinNumber(PA5); //13;// the number of the LED pin
Right.

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

Re: Introducing the new Arduino core for STM32

Post by fpiSTM » Sun Jun 11, 2017 3:07 pm

danieleff wrote: But still, how to access the touch chip on I2C3(PH8/PH7)? It is commented out: https://github.com/stm32duino/Arduino_C ... ins.c#L112
(Slightly unrelated, how to access non-first peripherals in general, SPI2, SPI3, I2C2, I2C3, UART2, ...)
Currently, only the Arduino pins are available. As it is a first enabler.

To enable it, uncomment the pins you want in PeripheralPins.c and:
Add them to the digital_arduino[] array:
https://github.com/stm32duino/Arduino_C ... nt.cpp#L26

Code: Select all

  PI11, //D22 User btn
  PH8, //D23
  PH8  //D224
};
And declare them in the enum:
https://github.com/stm32duino/Arduino_C ... iant.h#L60

Code: Select all

  D20, D21, D22, D23, D24,
DEND
finally, declare the instance:

Code: Select all

TwoWire Wire2 = TwoWire(23, 24);
Same way for any peripherals you want.

rmbult01
Posts: 2
Joined: Fri Jun 16, 2017 6:57 pm
Location: Louisville, KY

Re: Introducing the new Arduino core for STM32

Post by rmbult01 » Sat Jun 17, 2017 12:23 pm

fpiSTM wrote: PeripheralPins.c automatically generated from stm32cube mcu xml file. This avoid issue on pins definition.
Hi,

I'm trying to provide support for the Nucleo 446RE board. I can't find the associated xml file for use with the Python script. I've generated a project using the STM32CubeMX software and I didn't see it in there. I also downloaded the STM32CubeF4 zip but I don't see an obvious xml file, although there are some xml file in there. What should I be looking for?

Thanks,
Rob

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

Re: Introducing the new Arduino core for STM32

Post by fpiSTM » Sat Jun 17, 2017 8:33 pm

Hi, it seems this is the following file: STM32F446R(C-E)Tx.xml

The call command should be:
genpinmap_arduino.py NUCLEO_F446RE "STM32F446R(C-E)Tx.xml"

Xml file should be in <STM32CubeMX install dir>\db\mcu

The script expect to find the cubemx in default install dir:

Code: Select all

if sys.platform.startswith('win32'):
    #print ("Windows env")
    cubemxdir = 'C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeMX\db\mcu'
    cubemxdirIP = cubemxdir+"\\IP\\"
    input_file_name = cubemxdir+"\\" + sys.argv[2]
    out_path = cur_dir+'\\Arduino\\_'+sys.argv[1]
    output_filename = out_path+"\\"+out_filename
else:
    #print ("Linux env")
    if sys.platform.startswith('linux'):
        cubemxdir = os.getenv("HOME")+'/STM32CubeMX/db/mcu'
        cubemxdirIP = cubemxdir+"/IP/"
        input_file_name = cubemxdir+'/'+ sys.argv[2]
        out_path = cur_dir+'/Arduino/'+sys.argv[1]
        output_filename = out_path+'/'+out_filename
So if you have changed the default install dir change it in the script

rmbult01
Posts: 2
Joined: Fri Jun 16, 2017 6:57 pm
Location: Louisville, KY

Re: Introducing the new Arduino core for STM32

Post by rmbult01 » Sun Jun 18, 2017 10:03 am

I found it, thank you.

Since the utility did not support Mac OSX, I added support and created a pull request.

Regards,
Rob

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

Re: Introducing the new Arduino core for STM32

Post by fpiSTM » Tue Jun 20, 2017 6:38 am

Hi @rmbult01,

thanks I will add it.

Post Reply