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]STM32F4 L6470 error #12824

Closed
ffnull opened this issue Jan 5, 2019 · 137 comments
Closed

[2.0.x]STM32F4 L6470 error #12824

ffnull opened this issue Jan 5, 2019 · 137 comments

Comments

@ffnull
Copy link

ffnull commented Jan 5, 2019

Im write my own board variant for STEVAL-3DP001V1. All compiles fine. But in my board SPI drivers L6470.
When i use it in configuration - doesnt compile with errors.

c:\users\ffnul\appdata\local\temp\arduino_build_575834\sketch\src\core\drivers.h:30:29: error: expected identifier before numeric constant

 #define L6470               0x105

                             ^

D:\Documents\Arduino\libraries\Arduino-L6470-master\src/L6470.h:238:7: note: in expansion of macro 'L6470'

 class L6470 {

       ^~~~~

c:\users\ffnul\appdata\local\temp\arduino_build_575834\sketch\src\core\drivers.h:30:29: error: expected unqualified-id before numeric constant

 #define L6470               0x105

                             ^

D:\Documents\Arduino\libraries\Arduino-L6470-master\src/L6470.h:238:7: note: in expansion of macro 'L6470'

 class L6470 {

       ^~~~~

c:\users\ffnul\appdata\local\temp\arduino_build_575834\sketch\src\core\drivers.h:30:29: error: expected unqualified-id before numeric constant

 #define L6470               0x105

                             ^

c:\users\ffnul\appdata\local\temp\arduino_build_575834\sketch\src\module\stepper_indirection.h:86:10: note: in expansion of macro 'L6470'

   extern L6470 stepperX;

          ^~~~~

c:\users\ffnul\appdata\local\temp\arduino_build_575834\sketch\src\core\drivers.h:30:29: error: expected unqualified-id before numeric constant

 #define L6470               0x105

                             ^

c:\users\ffnul\appdata\local\temp\arduino_build_575834\sketch\src\module\stepper_indirection.h:121:10: note: in expansion of macro 'L6470'

   extern L6470 stepperY;

          ^~~~~

c:\users\ffnul\appdata\local\temp\arduino_build_575834\sketch\src\core\drivers.h:30:29: error: expected unqualified-id before numeric constant

 #define L6470               0x105

                             ^

c:\users\ffnul\appdata\local\temp\arduino_build_575834\sketch\src\module\stepper_indirection.h:156:10: note: in expansion of macro 'L6470'

   extern L6470 stepperZ;

          ^~~~~

c:\users\ffnul\appdata\local\temp\arduino_build_575834\sketch\src\core\drivers.h:30:29: error: expected unqualified-id before numeric constant

 #define L6470               0x105

                             ^
@Bob-the-Kuhn
Copy link
Contributor

Please attach your platformio.ini and configuration files & I'll see if I can reproduce it.

I've been playing with some L6470 drivers the last week. What hardware are you using?

@ffnull
Copy link
Author

ffnull commented Jan 5, 2019

Please attach your platformio.ini and configuration files & I'll see if I can reproduce it.

I've been playing with some L6470 drivers the last week. What hardware are you using?

Im doesnt use platformio becouse im use Arduino_Core_STM32. Im compile in arduino
Im attach my board variant for Arduino_Core_STM32 and project itself
steval.zip
ST3DP_EVAL.zip

@Bob-the-Kuhn
Copy link
Contributor

What firmware are you using?

The first one is ST's modified version of Marlin.

The second one is the "official" Marlin. That's the one you'll find on this site.

I'm 99.9% sure that the second one doesn't support the STEVAL-3DP001V1. Your ZIP has a pins_STEVAL.h file in it but that file isn't in the official Marlin.

I'll take a look in more detail at your ZIP and see what else is different.

@ffnull
Copy link
Author

ffnull commented Jan 5, 2019

Im using Marlin 2.0 files im wrote by my self. im try make port for this board. but stuck on motor drivers

@Bob-the-Kuhn
Copy link
Contributor

Now I understand.

I've been doing basically the same thing the last two weeks but for a Due based system.

The STEVAL-3DP001V1 schematics show that this board uses SPI daisy chaining. Neither Marlin nor the Arduino L6470 library support this.

My software is mostly functional but is an UGLY RAT'S NEST. If you want I can modify it so you can spin steppers with your board. The wife wants me to do some things so it'll be a couple of hours before I can make the mods and post them.

@ffnull
Copy link
Author

ffnull commented Jan 5, 2019

I canty change motor drivers so if you can help - its will be great! Then i can move to future
)

@Bob-the-Kuhn
Copy link
Contributor

Do you know how SPI daisy chaining works?

@ffnull
Copy link
Author

ffnull commented Jan 5, 2019

Do you know how SPI daisy chaining works?

Nope

@Bob-the-Kuhn
Copy link
Contributor

Bob-the-Kuhn commented Jan 5, 2019

There's one slave select that's tied to the chip select on all the drivers.

MOSI from the CPU is tied to SDI on the first driver. SDO on the first driver is tied to SDI on the second driver. SDO on the second driver is tied to SDI on the third driver. On the last driver in the chain the SDO is tied to MISO on the CPU.

Since you have 6 drivers all SPI transfers will be 6 bytes long.

When select is low (active), each device echoes what it saw on it's SDI on the NEXT byte.. The result is each byte is passed along the chain sort of like a bucket line. Data/commands for driver 6 (the one with it's SDO tied to MISO) is the first byte transmitted. The last byte transmitted is for the first device in the chain (the one with its SDI tied to MOSI). When select goes high each driver acts on the byte it last saw. Select stays low from start to finish.

The Maxim app notehas a good diagram of the data movement. Just be aware that it's talking about 16 bit devices.

The very first data transmitted by each device is the response to the command it received in the previous 6 byte transfer. After that it echoes the SDI input.

The CPU always transmits commands. If the CPU has no command for a particular device then the NOOP command (data 0x00) is transmitted in that slot.

@ffnull
Copy link
Author

ffnull commented Jan 5, 2019

I'm not so good at programming. I'm just learning. Can you help me with porting? My board is on the list, but it appears to be not tested as the developers have no board yet. So I decided to help. But stuck with the engines because there is not enough knowledge. If the fee is working, I will send my code to the developers.

@Bob-the-Kuhn
Copy link
Contributor

Shoot - I was hoping that you would clean up my mess. I'm in awe at how the big boys can make C++ sing. My code is like fingernails scraping on a chalkboard.

I just got up from a nap. I should be able to post a copy in the hour. It'll take longer to write up what I've done.

@ffnull
Copy link
Author

ffnull commented Jan 5, 2019

thank you very much

@Bob-the-Kuhn
Copy link
Contributor

My software isn't sophisticated enough to handle a 6 device chain of which only 4 are active. The work around is to assign the unused drivers to Y2 and Z2. I think that's better than assigning them to E1 7 E2 (lfewer configuration options to set).

Here's your config added to my code.

As feared, the STM environment/libraries are causing compile errors. That's been an ongoing headache for the Marlin community. I'll see what I can do after another nap.

Marlin-Bob-2.zip

@Bob-the-Kuhn
Copy link
Contributor

First some real top level items:

  • I had to modify the Arduino L6470 library. I couldn't figure out how to use the modified code as a library so it's now buried within Marlin as \Marlin-Bob-2\Marlin\src\module\bob_L6470.cpp and \Marlin-Bob-2\Marlin\src\module\bob_L6470.h.
  • Most of the base code is in the directory \Marlin\src\module\6470
  • I've written some utilities to help tune the system. They're in Marlin-Bob-2\Marlin\src\gcode\feature\L6470
  • I've hardwired in a special software SPI transfer routine. to do the 6 byte transfers. You may be able to use \Marlin-Bob-2\Marlin\src\HAL\HAL_DUE\HAL_spi_L6470_Due.cpp as is
  • Creation of the stepper objects is done starting at line 792 in the file Marlin-Bob-2\Marlin\src\module\stepper_indirection.cpp
  • Don't push the drivers yet. Mine went up in smoke when I had them all very near the max power before an over temperature warning happened. I need to write a routine similar to TMC_Monitor that'll get the status several times a second and reduce the power if the warning flag is set too often.

@ffnull
Copy link
Author

ffnull commented Jan 5, 2019

@Bob-the-Kuhn
Copy link
Contributor

I've managed to confuse myself trying various platformio options.

I've run into an older issue on the same topic (issue #10739 ). There's a comment towards the end that someone got it to compile but by then the person with the board had lost interest. I'll try that & see what happens.

FYI - here's an updated pins file. I've added the E1 & E2 socket definitions.

pins_STEVAL.h.txt

@Bob-the-Kuhn
Copy link
Contributor

Sorry - I just realized that you were the initiator of the earlier issue.

@Bob-the-Kuhn
Copy link
Contributor

@xC0000005 - your help would be appreciated.

@Bob-the-Kuhn
Copy link
Contributor

I've tried compiling the example STM32F4 config with platformio and Arduino 1.9.0 beta with equally disappointing results.

Time to wait until someone that knows the STM32 HAL joins the conversation.

@xC0000005
Copy link
Contributor

xC0000005 commented Jan 6, 2019 via email

@xC0000005
Copy link
Contributor

Your explanation of how this works is perfect. I'll see if I can get it to compile on the ST hal tomorrow, since this is something I'd actually like to do for the lerdge boards now that Marlin is nearly running on them (they don't have individual SPI select pins, either).

@Bob-the-Kuhn
Copy link
Contributor

Thanks

@Bob-the-Kuhn
Copy link
Contributor

What do they have that is SPI daisy chained?

@ffnull
Copy link
Author

ffnull commented Jan 6, 2019

@Bob-the-Kuhn dont use platformio. Install latest arduino.ua and Install on it Arduino_Core_STM32 library. Platformio use old broken library

@Bob-the-Kuhn
Copy link
Contributor

The latest Arduino 1.9 came with a virus. How Nice.

When compiling the example I get:
**panic: interface conversion: error is exec.Error, not exec.ExitError

Looks like the tool chain is having problems.

@Bob-the-Kuhn
Copy link
Contributor

Here's my updated L6470 library.
L6470.zip

And here is my image that uses them,
Marlin.zip

They are not tested. I'm hoping to get in new hardware Wednesday ot Thursday so it'll be the weekend before i can have them tested.


This code will use an internal soft SPI or your external SPI, depending on how you initialize it.

@xC0000005
Copy link
Contributor

xC0000005 commented Jan 7, 2019

Here's what I'm seeing regarding @ffnull's error.

In file included from /var/folders/2w/45wss0310nbfs7dbvg2mv01c0000gn/T/arduino_build_388469/sketch/src/inc/MarlinConfigPre.h:37:0,
                 from /var/folders/2w/45wss0310nbfs7dbvg2mv01c0000gn/T/arduino_build_388469/sketch/src/inc/MarlinConfig.h:28,
                 from /var/folders/2w/45wss0310nbfs7dbvg2mv01c0000gn/T/arduino_build_388469/sketch/src/Marlin.h:24,
                 from /var/folders/2w/45wss0310nbfs7dbvg2mv01c0000gn/T/arduino_build_388469/sketch/src/Marlin.cpp:31:
/var/folders/2w/45wss0310nbfs7dbvg2mv01c0000gn/T/arduino_build_388469/sketch/src/inc/../core/drivers.h:30:29: error: expected identifier before numeric constant
 #define L6470               0x105
                             ^
/var/folders/2w/45wss0310nbfs7dbvg2mv01c0000gn/T/arduino_build_388469/sketch/src/module/L6470.h:241:7: note: in expansion of macro 'L6470'
 class L6470 {
       ^~~~~

I think this error is sort of teling us the truth.
In drivers.h, we have the line:
#define L6470 0x105
In l6740.h we have:
class L6470 {

Which should expand in the preprocessor to
class 0x105 {

I renamed the driver class to L6470Driver and was able to successfully compile (though I don't know if it works).

@xC0000005
Copy link
Contributor

What do they have that is SPI daisy chained?

Nothing - I was thinking of SPI daisy chaining some drivers since the Lerdge-X can't use SPI due to not having a separate chip select. I had no idea daisy chaining existed, but the moment I saw it, I thought "Hmm. I could definitely use that to hook the pins up."

@Bob-the-Kuhn
Copy link
Contributor

Bob-the-Kuhn commented Jan 7, 2019

That's strange.

I can compile in PlatformIO for the Due as is.

@Bob-the-Kuhn
Copy link
Contributor

I could have sworn I gave him ZIP with that fixed.

Please try this one. It's the one I'm doing all the L6470 development & testing with. I've added the pins & board definitions for his card.

There's also a newer Arduino-L6470 library in it. You'll get compile errors without it.

This code is based on a bugfix 2.snapshot taken about a month ago.

Marlin_L6470.zip

@ffnull
Copy link
Author

ffnull commented Dec 18, 2019

On Platformio get error.
https://pastebin.com/BBFkKG6a
On arduino with yours L6470 fix compiles. Board boots. Motors doesnt work.
M43
https://pastebin.com/G5Du479n
M43 I1
https://pastebin.com/CE564Kvk

@ffnull
Copy link
Author

ffnull commented Dec 18, 2019

i dont know why. but mcu hot. its get 150mA

@Bob-the-Kuhn
Copy link
Contributor

Bob-the-Kuhn commented Dec 19, 2019

Mostly good news. The M43 commands showed all are correct except for SD_DETECT_PIN. That pin should be 25, not 66. That line should read: //#define SD_DETECT_PIN 25 // PA15 SD_CA

Hot MCU probably means it is driving at least one pin it shouldn't which implies the pin map isn't correct. Please use the M42 and M43 commands to do some sanity checks.

No motor movement - what does M122 and M906 report? Are the SPI chain bypass resistors for E2 and E3 (R16 & R17) installed? I've setup configuration.h and configuration_adv.h assuming they are not installed. Is power being applied to the steppers after issuing a movement command like G0 or G1.

Do you have a logic analyzer? Looking at the SPI pins would be fantastic.

@Bob-the-Kuhn
Copy link
Contributor

The "Platformio get error" is being caused by using the released/default Arduino_L6470 library instead of the one I provided.

@Bob-the-Kuhn
Copy link
Contributor

Bob-the-Kuhn commented Dec 20, 2019

Any updates on how much of the board is functional?


If the only thing that isn't functional are the motors then try reversing the SPI chain positions in Configuration_adv.h. There's been a couple of times where I had made that mistake. Maybe I've done it again.


I've been playing with a couple of things:

I can compile the following image using either Arduino or PlatformIO.
https://www.dropbox.com/s/h84jss6nq87joox/Marlin-Bob-2%20L6470%20only.zip?dl=0

Please compile & download this image. I think the easiest way to do this is to use the Auto Build menu in PlatformIO. If you use Arduino then you'll probably need to revert to the standard Arduino-L6470 library.

This image works (responds to console commands) with a mega2560 and an LPC1768 but on a Due board goes into a WDT loop when a L6470 is enabled.

@Bob-the-Kuhn
Copy link
Contributor

FYI - I changed the board name to STEVAL_3DP001V1 in the new image.

@ffnull
Copy link
Author

ffnull commented Dec 20, 2019

@Bob-the-Kuhn Hello BOB. Once again, many thanks for the help. I have a lot of work at the moment. I can check no earlier than Sunday. Logic analyzer i have

@Bob-the-Kuhn
Copy link
Contributor

Be nice to yourself. Eventually your fantasies about something being more important than your 3D printer will pass.

😉

@Bob-the-Kuhn
Copy link
Contributor

Bob-the-Kuhn commented Dec 22, 2019

I've finally been able to download Marlin to an STM32 based board!.

I've verified that code runs on 2560, LPC1768 & STM32F103 but not on DUE.

Please give the following a try.
https://www.dropbox.com/s/bngkqatw8nqay11/Marlin-Bob-2%2022DEC.zip?dl=0
https://www.dropbox.com/s/usa8zgclmaqs6wh/Marlin-Bob-2%2022DEC%20B.zip?dl=0

@Bob-the-Kuhn
Copy link
Contributor

I now have a STEVAL_3DP001V1 board. Don't tell my wife.

This image appears to be fully functional until any L6470 driver is enabled. When I enable a L6470 the J20 USB port dies.

https://www.dropbox.com/s/tq96071u5atgoev/Marlin-Bob-2%2025%20DEC%20L6470%20doesn%27t%20work.zip?dl=0

This image should allow you to check out everything except the stepper motors.

Here's how I've been using the board

  1. Install J22 jumper
  2. Attach USB cable to STLINK connector
  3. Attach USB cable to J20 connector (Host functions go through this port)
  4. Compile using PlatformIO (won't compile on Arduino for me)
  5. Using STLINK utility connect to target
  6. Using STLINK utility download .pio\build\STM32F401VE_STEVAL\firmware.bin. I have to actually browse to this file everytime or else it programs an old image.
  7. Disconnect in STLINK utility
  8. Reset the board
  9. Use Repetier Host (or equivalent) to talk to the board via the J20 USB port.

@ffnull
Copy link
Author

ffnull commented Dec 25, 2019

@Bob-the-Kuhn You are the best! As for me, by buying a board, you made me a New Year's gift. I’m sorry that I don’t answer, because on the nose of the new year and on the 31st day I have a wedding, and the work is sea.

@Bob-the-Kuhn
Copy link
Contributor

A wedding - WONDERFULL!!!!!

I moved the pin map and Platformio stuff over to my newer L4xx code base. As best I can tell I have SPI communications. The L6474 has different register mapping and bit definitions than currently in my code base. Adding the L6474 as an option should be straight forward but tedious.

@Bob-the-Kuhn
Copy link
Contributor

I have movement!

@ffnull
Copy link
Author

ffnull commented Dec 28, 2019

@Bob-the-Kuhn wow! but i can test only 29 in the evening

@Bob-the-Kuhn
Copy link
Contributor

Here's a mostly functional image. You'll need to modify the configuration files to match your system.

https://www.dropbox.com/s/44sf8fr21hyydxw/Marlin-Bob-2_L6474_2019-12-20.zip?dl=0

There is something strange going on with the SPI system. I'm sort of hoping that my board has problems. Let me know how it works for you.

What I'm seeing is the M906 command is reporting different information than in the configuration_adv.h file. What M906 is reporting is what my logic analyzer is showing was written to and received from the L6474 chips. The only thing I can test directly is the microstep settings. Stepper performance matches what M906 is reporting.

I've had some success using the ST-LINK to watch program execution. I can see the correct data being handed off to the ST SPI library but what shows up on my logic analyzer is sometimes different. So far this has happened only to the last two chips in the chain. X, Y, Z & E1 are rock solid. E2 & E3 both have the issue. For example I'll set the microsteps to 4 which should result in a 0x9A being sent to the step register. What actually shows up on the SPI hardware bus is 9A for X, Y, Z & E1 but 9F for E2. 9F results in M906 reporting 128 microsteps. The L6474 can only go to 16 microsteps. 16 microsteps is what is actually happening.

Let me know how it works for you.

@Bob-the-Kuhn
Copy link
Contributor

I've fixed my soft SPI "problem". Just needed to add some delay because the CPU was faster than what I had played with on other boards.

I still have my "9F" problem with the last chip.

Please use this image.

https://www.dropbox.com/s/48ujcdqrdvyuqb5/Marlin-Bob-2_L6474_2019-12-31.zip?dl=0

@Bob-the-Kuhn
Copy link
Contributor

Here's the latest image. If I remember correctly it's just polishing up M916, M917 & M918.

https://www.dropbox.com/s/qatg0x6ldohvhih/Marlin-Bob-2%202020-01-03.zip?dl=0

I've managed (through great skill and perseverance ### 😉 ) to damage my board. I think I have 3 fully functional L6474 chips.

@Bob-the-Kuhn
Copy link
Contributor

@Bob-the-Kuhn
Copy link
Contributor

FYI - code is now in PR #16452.

@ffnull
Copy link
Author

ffnull commented Jan 4, 2020

@Bob-the-Kuhn I just got married) To be more precise, 12/31/2019)) Finally, there was free time. I start testing. Since in a couple of days I'm leaving for my honeymoon. Thank you very much for the work you have done. Happy New Year!

@Bob-the-Kuhn
Copy link
Contributor

Congratulations!!

Talk to you in a month.

@ffnull
Copy link
Author

ffnull commented Jan 4, 2020

Maybe im doing something wrong. Using your latest image and latest library. But, cant compile
https://pastebin.com/C7H0g4AN

@Bob-the-Kuhn
Copy link
Contributor

Strange - Z2_ENABLE_PIN should have been automatically created by the macros in pins.h

Please post your configuration files and, if you've made any changes, your pins_STEVAL_3DP001V1.h file.

@ffnull
Copy link
Author

ffnull commented Jan 4, 2020

only #define X_DRIVER_TYPE L6474
#define Y_DRIVER_TYPE L6474
#define Z_DRIVER_TYPE L6474
//#define X2_DRIVER_TYPE A4988
//#define Y2_DRIVER_TYPE L6474
//#define Z2_DRIVER_TYPE L6474
//#define Z3_DRIVER_TYPE A4988
#define E0_DRIVER_TYPE L6474
//#define E1_DRIVER_TYPE A4988
//#define E2_DRIVER_TYPE A4988
//#define E3_DRIVER_TYPE A4988
//#define E4_DRIVER_TYPE A4988
//#define E5_DRIVER_TYPE A4988

@Bob-the-Kuhn
Copy link
Contributor

Please post the files. That way there is no doubt I'm accurately reproducing the issue.

@ffnull
Copy link
Author

ffnull commented Jan 4, 2020

@Bob-the-Kuhn
Copy link
Contributor

I was able to reproduce the problem. In configuration_adv.h, dual_Z_steppers was enabled but configuration.h didn't have Z2 defined as L6474. Another issue with configuration_adv.h was that the SPI chain didn't match your board.

Here's a ZIP with the corrected configuration_adv.h along with the .ELF and .BIN files created when I compiled it. To use it you'll need to install jumpers at R16 & R17 to make the board functional.
Config.zip

Here's another ZIP that doesn't require R16 & R17 to be installed. It also has the USB port enabled.
Config 6 steppers.zip

@Bob-the-Kuhn
Copy link
Contributor

The latest bugfix-2.0.x now fully supports this board.

The WIFI interface isn't functional. I doubt it ever will.

@github-actions
Copy link

github-actions bot commented Jul 3, 2020

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants