Traumflug / Teacup_Firmware

Firmware for RepRap and other 3D printers
http://forums.reprap.org/read.php?147
GNU General Public License v2.0
312 stars 199 forks source link

Porting to stm32f103 #313

Closed Laczen closed 5 years ago

Laczen commented 5 years ago

Hi, I would like to port Teacup to a stm32f103 processor (blue pill). I am not experienced with the stm32 devices. Has anyone already ported Teacup? If it has not been ported yet, what are the steps required? Based on the stm32f411 that is supported, I think that I would need to add cmsis files, but where can I find these?

Thanks and kind regards,

Jehudi

Wurstnase commented 5 years ago

Hi @Laczen,

I have some bluepills and could help you with this. My start with the port was very hard learning and I guess I would make today a lot of things differently.

Unfortunately the F103 and the F411/F446 are not very similar.

However. First you should get the CMSIS files for the STM and a linker file. I've got mine from mbed.

You could also take a look into arm-port-starts-here. This is a good way how you could go step by step.

Laczen commented 5 years ago

Hi @Wurstnase, thanks for the reply.

I have been looking for the cmsis files and could not find them from mbed. I have found them (I think) on https://github.com/stm32duino/Arduino_Core_STM32 but I am unsure if this is all I need.

Also I have seen that these files have been changed, but I do not know exactly how they have been changed.

Wurstnase commented 5 years ago

Yes this is also ok for a start. This file https://github.com/stm32duino/Arduino_Core_STM32/blob/master/system/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103x6.h is the most important.

ryannining commented 5 years ago

you can try look at my firmware, some teacup code live in there (gcode parser, serial log) but with different approach on motion planning, to accomodate even without using hardware timer, forward and backward planning, path segmentation (non linear drive) in inner motion loop.

Currently its support bluepill and wemos esp8266 for CNC and 3D printer.

https://github.com/ryannining/karyacontroller

Laczen commented 5 years ago

Hi @ryannining, thanks for pointing me in the direction of karyacontroller. It seems you have done a lot of work on this. I guess your code still needs some cleaning up. I have seen that you had some issues with speed, has this been resolved ?

Laczen commented 5 years ago

@Wurstnase, I have been able to get the cmsis-files in the source tree, I have created a new board, and modified the makefile. I have included the changes in a zip file below. stm32f103.zip

I know I will have to make changes to several files but I first tried to make and I got the following errors: LINK build/teacup.elf build/cmsis-system_lpc11xx.o (symbol from plugin): In function SystemInit': (.text+0x0): multiple definition ofSystemCoreClockUpdate' build/cmsis-system_stm32f1xx.o (symbol from plugin):(.text+0x0): first defined here build/cmsis-system_lpc11xx.o (symbol from plugin): In function SystemInit': (.text+0x0): multiple definition ofSystemCoreClock' build/cmsis-system_stm32f1xx.o (symbol from plugin):(.text+0x0): first defined here build/cmsis-system_lpc11xx.o (symbol from plugin): In function SystemInit': (.text+0x0): multiple definition ofSystemInit' build/cmsis-system_stm32f1xx.o (symbol from plugin):(.text+0x0): first defined here collect2: error: ld returned 1 exit status Makefile-common:93: recipe for target 'build/teacup.elf' failed

I don't know why it tries to link both lpc11xx and stm32f1xx

Traumflug commented 5 years ago

@Laczen, I've just added you as a collaborator, welcome to Teacup Firmware. Rules are simple: create as many branches as you feel a need for, work on branches made by others only after asking.

Here's a write up of my personal Git strategies (and a hint on a project I'm currently more active on): http://jump-ing.com/traumflugs/github_best_practices

Laczen commented 5 years ago

Hi, I figured out what the error was: I had to wrap my cmsis-system file in a define #ifdef __ARM_STM32F103__.

Laczen commented 5 years ago

Hi, after further study of the next steps to take to port teacup to stm32f103 I have decided that it would take me to long to get the port done (the stm32f103 is quite different from the stm32f411) and that I wouldn't be happy with it. It would just be a messy port trying to get everything in the code. Teacup is a nice piece of software (with a very nice config tool) but it has not been written to be easy portable (which is to be expected from something so close to the hardware). Maybe I will try to modify teacup to use some kind of layer between hardware and Teacup (e.g. the layer that is used in klipper).

adichell commented 5 years ago

Hi guys, I ported and I am porting GRBL 0.9 to some stm32 microcontroller (that are cheap and really powerful), knowing a bit of these microcontrollers, but knowing not much about GRBL. So I guess the same thing may be done or has been done with teacup somewhere, BUT there are fundamentally 2 issues to take in account:

1) Input line interrupts muxing (expecially if you want to use driver motor shields compatible with arduino) 2) Only Flash memory is available on these MCUs, there is NO EEPROM :( This is a pain in the... brain, I solved it with a working solution, but I am still trying to find something better.

So, it's not an easy job, I found some solution to these main issues in my project, and right now I am using the ported GRBL on a Nucleo-F410, that is moving a CNC machine a friend has built and is using. Here is my code:

grbl_opencm3

If anyone wants to port teacup that would be nice, and he may use the libopencm3, instead of using HALs or similar, and try to adopt a structure similar to mine (I have copied something of that from the libopencm3 examples project), that allows to have the logic of the firmware in a common source folder, and then compile the specific files for the different microcontrollers in separate folder.

triffid commented 5 years ago

but it has not been written to be easy portable

Heh try your hand at Smoothie or Marlin sometime if you think teacup isn't easily portable ;)