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

[2.0.x] Marlin does not compile to STM32 using default example config #8585

Closed
attilabody opened this issue Nov 28, 2017 · 76 comments
Closed
Labels
C: Build / Toolchain T: HAL & APIs Topic related to the HAL and internal APIs.

Comments

@attilabody
Copy link
Contributor

attilabody commented Nov 28, 2017

Compile Error

When I compile for STM32 with default example configuration the compilation fails:

Marlin\src\HAL\HAL_STM32F1\HAL_spi_Stm32f1.cpp:49:8: error: 'SPISettings' does not name a type

Marlin2_stm32f1_buildlog.txt

@coolio986
Copy link

coolio986 commented Nov 28, 2017

It appears the issue is a failure to call

\.platformio\packages\framework-arduinoavr\libraries\__cores__\arduino\SPI\src\SPI.h

Even doing a #include <SPI.h> In HAL_spi_Stm32f1.cpp has no effect.

c_cpp_properties.json has the includePath set correctly, but yet the standard location cannot be found.

@thinkyhead thinkyhead added C: Build / Toolchain T: HAL & APIs Topic related to the HAL and internal APIs. labels Nov 28, 2017
@thinkyhead
Copy link
Member

Possibly some other file named SPI.h is obscuring the arduino core version…

@coolio986
Copy link

@thinkyhead
I checked the source for the teensy35 since that uses a very similar structure to stm32f1. The teensy35 compiles without issue, while also referencing the same libraries

Differences between the two consist of the stm32f1 having a build_flags for python in platformio.ini and teensy35 using libraries included in its HAL folder.

@coolio986
Copy link

I have continued to look into this issue, but I have yet to find a solution. Since I am newer to platformio, I don't quite know the ins and outs of it like arduino ide. It may be wise to have some of the devs look into this one.

@attilabody
Copy link
Contributor Author

Will STM32 be supported anytime soon?

@victorpv
Copy link
Contributor

victorpv commented Dec 12, 2017

It's supported, I'm printing fine in my custom board.
The issue is because the SPI include was changed in this commit:
60af705#diff-8eb2d10518202d127cc150c0ef73d546

You need to change this line:
https://github.com/MarlinFirmware/Marlin/blob/bugfix-2.0.x/Marlin/src/HAL/HAL_STM32F1/HAL_spi_Stm32f1.cpp#L40

Should read
#include "SPI.h"

I'll try to correct that in my next PR, someway I missed it in my latest PR, I also had the same error that when I rebased a few days ago and got the change.

@victorpv
Copy link
Contributor

@thinkyhead feel free to reference me in any STMF1 issue if I don't happen to reply, some times I may go quite a few days without having enough time check what's going on in general, but if you reference me I should get a flag when I login to github.

@victorpv
Copy link
Contributor

@compihu just so you know, I use Sloeber, not platformio or Arduino IDE, but you find any other error let me know and I'll try to test.
So far I can confirm ADC, steppers, serial, serialUSB, sdcard on SPI1, LCD, i2c1 all work fine.
I printed a 5 hours job the other day from sdcard without a hicup.

victorpv added a commit to victorpv/Marlin that referenced this issue Dec 12, 2017
As reported in this issue:
MarlinFirmware#8585
I have it working fine in my local copy like that change.
@victorpv
Copy link
Contributor

I just sent a PR to fix this:
#8762

@attilabody
Copy link
Contributor Author

attilabody commented Dec 12, 2017

@victorpv I changed SPI.h inclusion to the same as appears in your pull request on top of #c555a214d2cb5704bb323f99b15f0132300336b4
It seems that it did not fix the SPI issue and Timer code got broken meanwhile:

MarlinBuildSTM32.log

@victorpv
Copy link
Contributor

not sure if you need to do it in platformio, but in Sloeber I have the STM32F1/libraries/SPI library, from the stm32duino core files, added to the library list in the project.
Perhaps with that is how it finds SPI.h. Try that, otherwise you could also try <SPI.h> instead of "SPI.h"

@victorpv
Copy link
Contributor

I need to check in the timer error, I think something went wrong with my commits and something is missing, since me local copy compiles and runs fine.

@victorpv
Copy link
Contributor

@compihu I see one of the timer files is not updated.
I'll have to commit that file back to my fork, then send a PR.
Wait for further testing until I can review it this evening. I think someway I mixed files when rebasing, since I got many errors and had to resolve loads of conflicts. At that point I may have left that file out.

@p3p
Copy link
Member

p3p commented Dec 12, 2017

@victorpv I know it's a little annoying having to support a build chain you don't use yourself, I use Eclipse myself for development, but we are trying to standardise on platformio for all platforms (not the painful Atom IDE plugin, you can ignore that as long as the command line build works), you can also add a simple default build test for your platform to Travis just to make sure there aren't any silent build issues introduced later.

@alexxy
Copy link
Contributor

alexxy commented Dec 12, 2017

@victorpv btw

Since only 1 file needs change in the stm32duino core, it's preferable over making changes to Marlin.


After these lines:
<>
#else
#define ASSERT_FAULT(exp) (void)((0))
#endif
<>

Add the following 3 lines:
<>
#undef DEBUG_NONE
#undef DEBUG_FAULT
#undef DEBUG_ALL
<>

This part dont needed anymore...

@victorpv
Copy link
Contributor

Thanks p3p, I'll try to learn how to use Travis.
I used platformio with the Re-Arm, but I find so much easier Eclipse that I keep using it for the STM.
But I think the errors @compihu is having are due to some mess up I did while rebasing to the latest 2.0, not due to plaformio or Sloeber.

@victorpv
Copy link
Contributor

@compihu replace the file in your disk with this one:
https://github.com/victorpv/Marlin/blob/bugfix-2.0.x_multihost/Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.h

That has the latest changes. Don't download that whole branch, it's a merge to add multiserial support from TCM but not tested yet. You can download if you want to test it, but I haven't tested anything other than compilation.

@p3p
Copy link
Member

p3p commented Dec 12, 2017

My response wasn't directly related to this issue, I had just seen a few comments scroll past about build issues and you responding that you build with Sloeber so I was just making sure you knew it was recommended that all platforms do build with platformio, Adding a default config Travis test should be pretty painless (one day we will run the whole test suite against each platform but that's not possible yet), you can just modify the LPC1768 one (https://github.com/MarlinFirmware/Marlin/blob/bugfix-2.0.x/.travis.yml#L422)

@victorpv
Copy link
Contributor

I thought your comment was referring to both, this case and in general. I need to check how Travis works and hopefully get it set for autobuilding the STM HAL. Thanks for the pointer.

@victorpv
Copy link
Contributor

@compihu btw just tested the multihost branch I linked above and seems to work, using SerialUSB + usart 1
Usart1 connected to an ESP01 with ESP3d Firmware. There are things to iron out with the ESP communication.

thinkyhead added a commit that referenced this issue Dec 13, 2017
[2.0.x] STM32F1 HAL: Fix issue #8585. Updates to readme.
@victorpv
Copy link
Contributor

@alexxy seems like you have more experience with platformio. Can you check if updating the file metioned above from the multi-serial branch compiles in platformio?
And would you be able to help with the Travis integration?
One last question, what F1 board do you have?

@alexxy
Copy link
Contributor

alexxy commented Dec 13, 2017

@victorpv latest changes doesnt compiles for me with PIO
Where StepperTimer and TempTimer were defined?
PS I have stm32f103RET board...

Compiling .pioenvs/STM32F1/src/src/HAL/HAL_LPC1768/include/digipot_mcp4451_I2C_routines.o
In file included from Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL_STM32F1/HAL_Stm32f1.h:61:0,
from Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL.h:50,
from Marlin/src/HAL/HAL_LPC1768/../../inc/MarlinConfig.h:28,
from Marlin/src/HAL/HAL_LPC1768/LPC1768_Servo.cpp:63:
Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL_STM32F1/HAL_timers_Stm32f1.h: In function 'void HAL_timer_set_count(uint8_t, hal_timer_t)':                                                                                                                                 
Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL_STM32F1/HAL_timers_Stm32f1.h:120:5: error: 'StepperTimer' was not declared in this scope                                                                                                                                    
StepperTimer.pause();
^
Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL_STM32F1/HAL_timers_Stm32f1.h:126:5: error: 'TempTimer' was not declared in this scope
TempTimer.pause();
^
Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL_STM32F1/HAL_timers_Stm32f1.h: In function 'hal_timer_t HAL_timer_get_count(uint8_t)':
Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL_STM32F1/HAL_timers_Stm32f1.h:140:12: error: 'StepperTimer' was not declared in this scope                                                                                                                                   
temp = StepperTimer.getCompare(STEP_TIMER_CHAN);
^
Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL_STM32F1/HAL_timers_Stm32f1.h:143:12: error: 'TempTimer' was not declared in this scope
temp = TempTimer.getCompare(TEMP_TIMER_CHAN);
^
Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL_STM32F1/HAL_timers_Stm32f1.h: In function 'void HAL_timer_set_current_count(uint8_t, hal_timer_t)':                                                                                                                         
Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL_STM32F1/HAL_timers_Stm32f1.h:154:26: error: 'StepperTimer' was not declared in this scope                                                                                                                                   
case STEP_TIMER_NUM: StepperTimer.setCount(count); break;
^
Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL_STM32F1/HAL_timers_Stm32f1.h:155:26: error: 'TempTimer' was not declared in this scope
case TEMP_TIMER_NUM: TempTimer.setCount(count); break;
^
Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL_STM32F1/HAL_timers_Stm32f1.h: In function 'hal_timer_t HAL_timer_get_current_count(uint8_t)':                                                                                                                               
Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL_STM32F1/HAL_timers_Stm32f1.h:163:12: error: 'StepperTimer' was not declared in this scope                                                                                                                                   
temp = StepperTimer.getCount();
^
Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL_STM32F1/HAL_timers_Stm32f1.h:166:12: error: 'TempTimer' was not declared in this scope
temp = TempTimer.getCount();
^
Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL_STM32F1/HAL_timers_Stm32f1.h: In function 'void HAL_timer_isr_prologue(uint8_t)':
Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL_STM32F1/HAL_timers_Stm32f1.h:180:5: error: 'StepperTimer' was not declared in this scope                                                                                                                                    
StepperTimer.pause();
^
Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL_STM32F1/HAL_timers_Stm32f1.h:186:5: error: 'TempTimer' was not declared in this scope
TempTimer.pause();
^
In file included from Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL.h:50:0,
from Marlin/src/HAL/HAL_LPC1768/../../inc/MarlinConfig.h:28,
from Marlin/src/HAL/HAL_LPC1768/LPC1768_Servo.cpp:63:
Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL_STM32F1/HAL_Stm32f1.h: At global scope:
Marlin/src/HAL/HAL_LPC1768/../../inc/../HAL/HAL_STM32F1/HAL_Stm32f1.h:157:12: warning: 'int freeMemory()' defined but not used [-Wunused-function]                                                                                                                          
static int freeMemory() {
^
Compiling .pioenvs/STM32F1/src/src/HAL/HAL_LPC1768/main.o
*** [.pioenvs/STM32F1/src/src/HAL/HAL_LPC1768/LPC1768_Servo.o] Error 1

@victorpv
Copy link
Contributor

@alexxy you would have to replace this file in your folder with this copy:
https://github.com/victorpv/Marlin/blob/bugfix-2.0.x_multihost/Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.h

I tried Travis CI in my branch, but platformio apparently doesn't have board definition for MCUs with more than 64 pins (RxT6).

@thinkyhead
Copy link
Member

I've given up for tonight. I can't find any non-hackish way to get the "gccarmnoneeabi" compiler to like C++11. I'll need to get well-acquainted with building for all our targets and make sure they can all be built from my environment … not just for my own testing but also to be able to write up understandable build instructions for end-users. I don't want anyone to have to deal with the kinds of pitfalls we devs seem to enjoy so much.

@thinkyhead
Copy link
Member

That build platform is going to be awesome. I could do something similar with the bits and pieces I have lying around here. Hmm…

@youprint
Copy link

I just tried with sloeber (eclipse Arduino plug in) and it’s working too with my modded code. If I use the code from the repo it doesn’t work, still a pb with spi.
I’m going to work on a simple configuration for a 4 axis laser CNC for STM32 (blue pill) since I found I working HAL.
I’m going to test the STMF7 HAL too...

@thinkyhead
Copy link
Member

If I use the code from the repo it doesn’t work

Same include path issue? I will patch that later today.

@youprint
Copy link

Already did it but some spi timer issues. I really think we need to focus compiling with Arduino with stm32duino libs since it is written to natively work with it. The other choice is to import these libs into platformio

@attilabody
Copy link
Contributor Author

Does this mean that STM32 HAL is based on arduino framework? Please, please, please say no.... Pretty please with sugar on top...

@youprint
Copy link

The STM32F1 Hal was written by Victor who is an active member of the STM32duino community. All his work is based on these special modded libs. But I don’t think it’s difficult to get it work with platformio but it need some work. The STMF7 hal use a special core created by Danieleff, it seems using standard STM libs, i’m just waiting for my dev board to try it.

@thinkyhead
Copy link
Member

thinkyhead commented Feb 23, 2018

I did a patch to deal with some bad paths, but it only improved the LPC1768 situation. I still need to mess around more to resolve the same issue with STM32F1. I have hesitated because if it's supposed to be possible to build for STM32F1 in Arduino IDE, the kinds of changes I would make could break that compatibility.

Word has it that carefully placed platform.local.txt files can provide additional build arguments for the compiler on a per-target basis. If we can get those set up and working within the latest Arduino IDE then we have a universal solution that will allow both Arduino IDE and PlatformIO compatibility from the same code-base, without having to use stub headers and other ugly methods.

@thinkyhead
Copy link
Member

Getting close to being able to build for STM32F1, but there are now some new compile issues that need working out. https://github.com/thinkyhead/Marlin/tree/bf2_stm32f1_fixup

@youprint
Copy link

Good job 👍 i’m going to test this weekend. I think we could improve the compatibility with Arduino IDE in the near future but it’s important for everyone to use the same program to compile.

@youprint
Copy link

@thinkyhead Just tried to compile your work and you're right we are close but still a lot of error. i will try to help improve the compatibility.
I'm going to create a repo with arduino 1.8.5 compatibility with STM32bootloader. I think i'm going to start from Victor repo because he get it work and there is no reason why we couldn't get it work now.

@thinkyhead
Copy link
Member

Good luck. If you get it compiling, please submit a PR with the solution.

@attilabody
Copy link
Contributor Author

@youprint , @thinkyhead:

Any progress on it?

@youprint
Copy link

No I let it down after a week of try, I’m using Arduino 1.9 beta now, and I recommend to use it for AVR, F1 and F7 Hal.

@attilabody
Copy link
Contributor Author

@alexxy
Copy link
Contributor

alexxy commented Apr 1, 2018

check config changes in previos commit

@alexxy
Copy link
Contributor

alexxy commented Apr 1, 2018

Compiles for me with current platformio and current frameworks and platforms versions.

cp Marlin/src/config/examples/stm32f103ret6/Configuration.h Marlin/
~/.local/bin/pio run -e STM32F1

However display will not work. And some other disabled modules

@attilabody
Copy link
Contributor Author

Yes, I was trying to compile that way

MarlinBuildSTM32_e6042a7c52bbe06e28ad3485cada530a32249f57.log

@alexxy
Copy link
Contributor

alexxy commented Apr 4, 2018

Did you update to recent bugfix-2.0.x branch? And are you pio packages up to date?
In you're case u8g_Hal cannot compile

@attilabody
Copy link
Contributor Author

you can see the commit hash in the name of the log file (it is there for this reason) PIO packages/platforms/libs are up to date.

@pscrespo
Copy link
Contributor

pscrespo commented Apr 25, 2018

Hi there! I was able to compile (on a Linux VM, I can't make Atom work on Windows) until commit c1e5ebb. Since that commit I'm getting an error:

Compiling .pioenvs/STM32F1/src/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.cpp.o
In file included from Marlin/src/HAL/HAL_STM32F1/HAL.h:62:0,
from Marlin/src/HAL/HAL_STM32F1/HAL_spi_Stm32f1.cpp:39:
Marlin/src/HAL/HAL_STM32F1/HAL_spi_Stm32f1.cpp: In function 'void spiBegin()':
Marlin/src/HAL/HAL_STM32F1/fastio_Stm32f1.h:35:115: error: 'v' was not declared in this scope
#define WRITE(IO,V)           (PIN_MAP[IO].gpio_device->regs->BSRR = (1U << PIN_MAP[IO].gpio_bit) << 
(16 * !(bool)v))

Edit: I'm adding a build log, in case it helps. build log.txt

@victorpv
Copy link
Contributor

Just checked that commit you mention, and there is a couple of inconsistencies in the case for v and io, lines 37 and 39 I believe, in the fastio file in the f1 hal. Edit it amd make sure that io and v amd always upper case or lower case within each macro line, but not lower case in one part and upper case in another part of the same line.

@thinkyhead
Copy link
Member

thinkyhead commented Apr 26, 2018

We've put more time into cleaning up the fastio headers, so remaining typos should now be fixed.

@pscrespo
Copy link
Contributor

Now it compiles. Thanks!

@eli76z
Copy link

eli76z commented Jun 19, 2020

Hello, i'm having an include issue but for something else and would like to know if there is a fix for it
under the includePath list of directories i have this line
"c:/Ender-5 3D Printer/Marlin Firmware/Marlin 2.0.x/include",
and compilation stops as the software can find it, when looking in the marlin firmware zip files
i can't see any directory called "include"

does any one knows how to fix this?

many thanks, Eli.

@thinkyhead
Copy link
Member

@eli76z — This Issue Queue is for Marlin bug reports and development-related issues, and we prefer not to handle user-support questions here. (As noted on this page.) For best results getting help with configuration and troubleshooting, please use the following resources:

@MarlinFirmware MarlinFirmware locked as resolved and limited conversation to collaborators Jun 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: Build / Toolchain T: HAL & APIs Topic related to the HAL and internal APIs.
Projects
None yet
Development

No branches or pull requests