Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino framework for STM32 #76

Closed
sstaub opened this issue Dec 7, 2017 · 48 comments
Closed

Arduino framework for STM32 #76

sstaub opened this issue Dec 7, 2017 · 48 comments
Assignees

Comments

@sstaub
Copy link

sstaub commented Dec 7, 2017

Can you add the Arduino framework port from STM?
Announcement: https://community.st.com/community/stm32-community/blog/2017/07/13/stm32-cores-enabled-in-arduino-ide
Github: https://github.com/stm32duino/Arduino_Core_STM32

@ArnieX
Copy link

ArnieX commented Jan 19, 2018

Is this coming any time soon?

@me21
Copy link

me21 commented Mar 19, 2018

Isn't it already done?

@ArnieX
Copy link

ArnieX commented Mar 19, 2018

@me21 well not really, if I for example want to develop for Nucleo, there is option only for mbed framework not Arduino.

@ubis
Copy link
Contributor

ubis commented Mar 19, 2018

It's in our plan, so it'll come. However, I don't have enough free time to dig in this, right now.
Also I want to finish F1/F3/F4 board support of Maple core first. Oh, and contributions are welcome 😉

@sstaub
Copy link
Author

sstaub commented Mar 29, 2018

I think it make no really sense to support the old st framework. The new STM32 Arduino Core will be more important because there is also support for the nucleo add-on boards, Ethernet and FreeRtos.

@ghent360
Copy link

ghent360 commented Apr 1, 2018

+1 for this feature
@ubis - If I want to help where do I start?

@ubis
Copy link
Contributor

ubis commented Apr 4, 2018

@ghent360 mostly reading boards.txt, platform.txt and then writing remap changes like it's done in stm32f1.py and making a PR 🙂

@Redferne
Copy link

bump

@sstaub
Copy link
Author

sstaub commented May 16, 2018

any news about?

@me21
Copy link

me21 commented May 22, 2018

Now that STM32F3 support has been dropped from rogerclark's Arduino core, I think it would be nice to include various Arduino cores into Platformio, namely:

@ubis
Copy link
Contributor

ubis commented May 30, 2018

In the upcoming few weeks, I will finish with all F1/F4 boards from Roger's core and then green light to the STM's official Arduino core. I can't tell about others, as main target will be more-popular/official cores first.

@ubis
Copy link
Contributor

ubis commented Jun 16, 2018

Successfully ported for the F103C8/BluePill board. From now on, development will be on my forked repo and merged into platform-ststm32 when it's ready.

Right know there's some manual work to-do in order to enable for the F103C8 board and I need to simplify everything so the changes could be pushed and tested by anyone.

@xC0000005
Copy link
Contributor

@me21, I used someone else's builder + a few modifications to get STM32GENERIC running fine with PIO. The biggest problem is that that core doesn't seem to be actively maintained, and there's a few problems with it. Other than figuring out how to get it to download, it wasn't too hard. You can set your development platform to point to my fork of the repo and your framework to arduinostm32generic and it should pull down what's needed and build fine.

@nightvisi0n
Copy link

nightvisi0n commented Jun 28, 2018

@ubis Thank you for your port. I would like to test it, but wasn't successful.
I changed the following things in my platformio.ini:

platform = https://github.com/ubis/platform-ststm32.git#feature/add_stm32_arduino_core
board = genericSTM32F103C8
build_flags=-D STM32_OFFICIAL_CORE

Unfortunately I only got AssertionError [...] assert isdir(FRAMEWORK_DIR), which is reasonable since .pioenvs/ is missing the framework-arduinoststm32. Using the latest release of the ststm32 platform everything works fine, so this should be related to your changes IMHO.
Do you have any idea what could be missing in my test setup?

@ubis
Copy link
Contributor

ubis commented Jun 28, 2018

@nightvisi0n No, it's on my end, because I haven't written anywhere how to use it, since some manual work needs to be done, in order to set up everything.

Now, it doesn't support generic boards at the moment, and we will discuss with Ivan about this, but in the meantime please use BluePill F103C8. Then create a folder called STM32 in the framework-arduinoststm32 folder and download this there.
Now do the same for CMSIS, create CMSIS and download this.
Everything should be ready now and you can try to build it.

@tve
Copy link

tve commented Aug 4, 2018

@ubis, I followed your directions in your last comment but I get the following error:

framework-arduinoststm32/STM32/system/Drivers/CMSIS/Device/ST/STM32L0xx/Include/stm32l053xx.h:129:10: fatal error: core_cm0plus.h: No such file or directory

In the gcc command line I see: -I/home/tve/.platformio/packages/framework-arduinoststm32/STM32/CMSIS/CMSIS/Core/Include but the Core directory seems to have vanished. Instead:

# find . -name core_cm0plus.h
./packages/framework-arduinoststm32/STM32/CMSIS/CMSIS/Include/core_cm0plus.h

I can track the source of that -I down, but am I on the right track?

Update: I removed "Core" from https://github.com/ubis/platform-ststm32/blob/feature/add_stm32_arduino_core/builder/frameworks/arduino/stm32core.py#L142 and it's a lot happier.

The next error is: framework-arduinoststm32/STM32/cores/arduino/stm32/clock.c:39:10: fat al error: stm32yyxx_ll_cortex.h: No such file or directory. I added join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "LL"), to get past that and now I'm stuck with a bunch if missing linker references like

/home/tve/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/libc_nano.a(lib_a-abort.o): In function abort':
abort.c:(.text.abort+0xa): undefined reference to _exit'

I'm a bit stumped, _exit is defined in STM32/cores/arduino/syscalls_stm32.c and I see that getting compiled and included in libFrameworkArduino.a and that is part of the linker commandline. So I'm not sure why all the symbols defined in syscalls_stm32.c end up missing at link time.

Am I off-track?

@ubis
Copy link
Contributor

ubis commented Aug 4, 2018

@tve Sorry, i made a typo and posted a link of CMSIS4 instead of CMSIS5. Please use this: https://github.com/ARM-software/CMSIS_5 . I've edited my previous post already.

You shouldn't need to edit anything, as everything should work out-of-the-box, except preparing that package with core + CMSIS.

@tve
Copy link

tve commented Aug 4, 2018

Well, it doesn't "just work". I still get:

/home/tve/.platformio/packages/framework-arduinoststm32/STM32/cores/arduino/stm32/clock.c:39:10: fatal error: stm32yyxx_ll_cortex.h: No such file or directory

due to a missing join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "LL"), in the builder script.

Also, the stuff in syscalls_stm32.c still doesn't get linked in.

@ubis
Copy link
Contributor

ubis commented Aug 4, 2018

It seems that core has been updated a few days ago and made some changes about LL wrapper. I will update builder script now, thanks.

EDIT:
I've updated the script, take a look in here.

@tve
Copy link

tve commented Aug 4, 2018

Yup, that does it! Thanks for the super-quick turn-around!

@boristomas
Copy link

boristomas commented Sep 7, 2018

@ubis i still have issues with STM32L432.

I have tried it on 3 PC with fresh install of VS code (one is portable).
and it doesn't work

platformio.ini:

[env:nucleo_l432kc] platform = ststm32 framework = arduino board = nucleo_l432kc

error:

Processing nucleo_l432kc (platform: ststm32; board: nucleo_l432kc; framework: arduino)

Verbose mode can be enabled via -v, --verbose option
PLATFORM: ST STM32 > ST Nucleo L432KC
SYSTEM: STM32L432KCU6 80MHz 64KB RAM (256KB Flash)
DEBUG: CURRENT(stlink) ON-BOARD(stlink) EXTERNAL(blackmagic, jlink)
AssertionError: :
File "C:\Users\boris.platformio\penv\lib\site-packages\platformio\builder\main.py", line 169:
env.SConscript("$BUILD_SCRIPT")
File "C:\Users\boris.platformio\packages\tool-scons\script..\engine\SCons\Script\SConscript.py", line 541:
return _SConscript(self.fs, *files, **subst_kw)
File "C:\Users\boris.platformio\packages\tool-scons\script..\engine\SCons\Script\SConscript.py", line 250:
exec file in call_stack[-1].globals
File "C:\Users\boris.platformio\platforms\ststm32\builder\main.py", line 88:
target_elf = env.BuildProgram()
File "C:\Users\boris.platformio\packages\tool-scons\script..\engine\SCons\Environment.py", line 224:
return self.method(*nargs, **kwargs)
File "C:\Users\boris.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py", line 107:
env.BuildFrameworks(env.get("PIOFRAMEWORK"))
File "C:\Users\boris.platformio\packages\tool-scons\script..\engine\SCons\Environment.py", line 224:
return self.method(*nargs, **kwargs)
File "C:\Users\boris.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py", line 314:
SConscript(env.GetFrameworkScript(f), exports="env")
File "C:\Users\boris.platformio\packages\tool-scons\script..\engine\SCons\Script\SConscript.py", line 604:
return method(*args, **kw)
File "C:\Users\boris.platformio\packages\tool-scons\script..\engine\SCons\Script\SConscript.py", line 541:
return _SConscript(self.fs, *files, **subst_kw)
File "C:\Users\boris.platformio\packages\tool-scons\script..\engine\SCons\Script\SConscript.py", line 250:
exec file in call_stack[-1].globals
File "C:\Users\boris.platformio\platforms\ststm32\builder\frameworks\arduino\stm32duino.py", line 56:
env.SConscript("stm32core.py")
File "C:\Users\boris.platformio\packages\tool-scons\script..\engine\SCons\Script\SConscript.py", line 541:
return _SConscript(self.fs, *files, **subst_kw)
File "C:\Users\boris.platformio\packages\tool-scons\script..\engine\SCons\Script\SConscript.py", line 250:
exec file in call_stack[-1].globals
File "C:\Users\boris.platformio\platforms\ststm32\builder\frameworks\arduino\stm32core.py", line 38:
assert isdir(FRAMEWORK_DIR)
The terminal process terminated with exit code: 1

@ubis
Copy link
Contributor

ubis commented Sep 7, 2018

@boristomas Have you created STM32 folder in .platformio/packages/framework-arduinoststm32 and placed this inside it?

@boristomas
Copy link

i created STM32, STM32L4,... you name it. error is the same

@ubis
Copy link
Contributor

ubis commented Sep 9, 2018

I've changed main branch in my repo, so everyone can directly use it, instead of replacing platform files. However, package still needs to have STM32 and CMSIS contents. platformio.ini file looks like this:

[env:nucleo_l432kc]
platform = https://github.com/ubis/platform-ststm32.git
board = nucleo_l432kc
framework = arduino

@boristomas why I asked about STM32 folder, because error happens at 38 line, which is assert isdir(FRAMEWORK_DIR) and it fails because there is no STM32 folder inside framework-arduinoststm32.

@sstaub
Copy link
Author

sstaub commented Oct 27, 2018

There is some development on supporting Arduino STM32Core, but I don't know when there is a release.

@ubis
Copy link
Contributor

ubis commented Oct 29, 2018

Yes, there's official STM32 core support in develop branch. However, currently we support the exact boards (so different boards with same mcu's won't work, at the moment). Take a look in here to get a full supported board list. So in @vivian-ng's case, none of generic boards are supported, but STM32F407G-DISC1 is, so use that instead.

@ivankravets
Copy link
Member

Thanks, @ubis and @valeros for adding support for official STm32 Core for Arduino.

We are going to make a public release this week. Please re-test the latest upstream version https://docs.platformio.org/en/latest/platforms/ststm32.html#upstream

Does it work for you?

@sstaub
Copy link
Author

sstaub commented Dec 12, 2018

Tested with Nucleo 429ZI, yes it works. Thank you very much. 👍

@qu1ck
Copy link

qu1ck commented Dec 23, 2018

Is there a way to explicitly specify which core I want to use? I have a project built using legacy (rogerclark's) core that is based on maple and upgrading stm32 platform to 4.6.0 caused a switch to new stm32 core, which broke my build.
For now I found a workaround: add
board_build.variant = custom
in platformio.ini but that workaround is dependent on logic in this file:
https://github.com/platformio/platform-ststm32/blob/master/builder/frameworks/arduino.py
which there is no guarantee that it won't change. I would prefer if there was explicit option to specify a core.

@Alteregoxxx
Copy link

Alteregoxxx commented Dec 23, 2018

Is there a way to explicitly specify which core I want to use? I have a project built using legacy (rogerclark's) core that is based on maple and upgrading stm32 platform to 4.6.0 caused a switch to new stm32 core, which broke my build.
For now I found a workaround: add
board_build.variant = custom
in platformio.ini but that workaround is dependent on logic in this file:
https://github.com/platformio/platform-ststm32/blob/master/builder/frameworks/arduino.py
which there is no guarantee that it won't change. I would prefer if there was explicit option to specify a core.

Same problem here...

@qu1ck
Please, would you be so kind to explain your workaround in more detail? The new core do not support USBSerial on the Bluepill and I need it.... :-(

Alternatively, if it's possible, Can anyone suggest a way to downgrade STM32 platform from 4.6.0 back to 4.5.0 version?
UPDATE: Found a way to do choose a specific core version to use for the compiling, looking in the PlatformIO docs, here:
http://docs.platformio.org/en/latest/projectconf/section_env_general.html#platform

Thank you !

@ivankravets
Copy link
Member

Yes, if you need old version of dev/platform, please use platform = ststm32@~4.5.0

@me21
Copy link

me21 commented Dec 23, 2018

@ivankravets I hope your solution is only temporary, because using older version of the platform cuts us off future updates of core and compiler.

@qu1ck
Copy link

qu1ck commented Dec 24, 2018

@Alteregoxxx see this commit:
openscopeproject/HP34401a-OLED-FW@d7cab8e

It works right now because ststm32 platform build file (linked it above) checks if the board variant is one of the explicit variants that are configured in the framework-arduinoststm32 package. Since "custom" isn't one of them, it reverts to legacy (unless board mcu is one of stm32f1 or stm32f4 in which case there is a hail mary fallback to new stm32 core).

I am aware that you can "pin" the version of the platform for the project in ini file but that is unworkable solution. If I have more than 1 projects using different cores I can't keep downloading different versions all the time when I switch between them.

@sstaub
Copy link
Author

sstaub commented Dec 24, 2018

Maybe the Maple boards and clones should have a seperate platform.

@me21
Copy link

me21 commented Dec 24, 2018

Can it be made possible to choose core (official or rogerclarkmelbourne) in the platform?

@ivankravets
Copy link
Member

@valeros is it possible to add support for -D PIO_FRAMEWORK_ARDUINO_LEGACY (forcing build process to rogerclarkmelbourne core )?

@aster94
Copy link

aster94 commented Jan 3, 2019

Now that STM32F3 support has been dropped from rogerclark's Arduino core, I think it would be nice to include various Arduino cores into Platformio, namely:

agree with this
any of them have pro and cons. It isn't a good idea to choose just one, for example:

  • [Steve's/Roger Libmaple cores] for now this is the best option but not always perfectly compliant with the arduino API
  • [Danieleff generic] not very active, not very user-friendly (i wouldn't port it really)
  • [STM's official core] maybe it would be the best in the next couple of years but for now it lack of various features

so the possibility to choose which one to use would be very useful :)
also, I think it is not very clear how to chose which package (https://docs.platformio.org/en/latest/platforms/ststm32.html#packages) is used, could you clarify it in the docs?

@fpistm
Copy link

fpistm commented Jan 3, 2019

* STM's official core] maybe it would be the best in the next couple of years but for now it lack of various features

Well, do not hesitate to contribute or submit a request ;)

@rzr
Copy link

rzr commented Jan 5, 2019

@fpistm, I suppose that f767zi will get arduino support in next stm32diuno release ? or should I patch anything ?

@hasenbanck
Copy link

@rzr The "official" core already supports the Nucleo F767ZI board in the current version 1.4

@rzr
Copy link

rzr commented Jan 5, 2019

So I should add arduino framework to platformio board defs, until 1.5 is released (with a couple of patches from me)

@sstaub
Copy link
Author

sstaub commented Jan 5, 2019

Yes, please add the Nucleo-F767ZI to the board defs. I got a board last week and so I'm missing the support. :)

noisymime added a commit to noisymime/speeduino that referenced this issue Jan 8, 2019
@ivankravets
Copy link
Member

Yes, please add the Nucleo-F767ZI to the board defs

Added, see https://github.com/platformio/platform-ststm32/blob/develop/boards/nucleo_f767zi.json

until 1.5 is released

Added support for 1.5 in the latest upstream version of dev/platform. See docs https://docs.platformio.org/en/latest/platforms/ststm32.html#stable-and-upstream-versions

Please re-test.

P.S: Switching between Arduino cores: https://docs.platformio.org/en/latest/platforms/ststm32.html#switching-between-arduino-cores

@andhieSetyabudi
Copy link

has anybody try to use ladybug-L432KC in platformio??

even the mcu is same with nucleo-L432kc but i can't upload my .hex to board..

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests