bigtreetech / BIGTREETECH-S42B-V1.0

The closed-loop drive is to feedback the rotation angle of the stepping motor to the control panel, compare the distance that needs to be rotated with the distance of the actual rotation, calculate the error value, and then compensate, so as to prevent the problem of multi-step and lost step. The closed-loop drive can completely overcome the lost step of the open-loop stepping motor, and can also significantly improve the performance of the motor at high speed
109 stars 53 forks source link

Make project compilable with latest PlatformIO and STM32 platform 11 #38

Closed maxgerhardt closed 1 year ago

maxgerhardt commented 3 years ago

Since version 10 of https://github.com/platformio/platform-ststm32/, custom board JSON files need to have a product_line value with which the startup script is selected.

Without that, compiling this project gives

Processing BIGTREE_S42B_V1_0 (platform: ststm32; framework: stm32cube; board: STM32F030C8)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/STM32F030C8.html
PLATFORM: ST STM32 (11.0.0) > STM32F030C8 (8k RAM. 64k Flash)
HARDWARE: STM32F030C8T6 48MHz, 8KB RAM, 64KB Flash
DEBUG: Current (blackmagic) External (blackmagic, cmsis-dap, jlink, stlink)
PACKAGES:
 - framework-stm32cubef0 1.11.1
 - tool-ldscripts-ststm32 0.1.0
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
AssertionError: Missing MCU or Product Line field:
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38\Lib\site-packages\platformio\builder\main.py", line 170:
    env.SConscript("$BUILD_SCRIPT")
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py", line 287:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "C:\Users\Max\.platformio\platforms\ststm32\builder\main.py", line 99:
    target_elf = env.BuildProgram()
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38\Lib\site-packages\platformio\builder\tools\platformio.py", line 61:
    env.ProcessProgramDeps()
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38\Lib\site-packages\platformio\builder\tools\platformio.py", line 127:
    env.BuildFrameworks(env.get("PIOFRAMEWORK"))
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38\Lib\site-packages\platformio\builder\tools\platformio.py", line 342:
    SConscript(env.GetFrameworkScript(f), exports="env")
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py", line 661:
    return method(*args, **kw)
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py", line 287:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "C:\Users\Max\.platformio\platforms\ststm32\builder\frameworks\stm32cube.py", line 43:
    assert PRODUCT_LINE, "Missing MCU or Product Line field"
========================================================================================== [FAILED] Took 0.76 seconds ==========================================================================================

After correcting that, more errors arise during compilation


Compiling .pioenvs\BIGTREE_S42B_V1_0\src\src\Libraries\Stm32F0_lib\Src\stm32f0xx_ll_utils.o
Compiling .pioenvs\BIGTREE_S42B_V1_0\src\src\User\main.o
Compiling .pioenvs\BIGTREE_S42B_V1_0\src\src\User\stm32f0xx_it.o
Compiling .pioenvs\BIGTREE_S42B_V1_0\src\src\User\system_stm32f0xx.o
In file included from Close_loop\src\Libraries\cmsis/stm32f030x8.h:125:0,
                 from Close_loop\src\Libraries\cmsis/stm32f0xx.h:135,
                 from Close_loop\src\Libraries\Stm32F0_lib\Inc/stm32f0xx_ll_spi.h:45,
                 from Close_loop\src\Libraries\Stm32F0_lib\Src\stm32f0xx_ll_spi.c:38:
Close_loop\src\Libraries\cmsis/core_cm0.h:163:10: fatal error: core_cmInstr.h: No such file or directory

because this project includes its own CMSIS library but there is no core_cmInstr.h file. That was added.

Finally, the value of the ldscript path is corrected.

Please note that iap.py is still wrong, it does a env.Replace(LDSCRIPT_PATH="buildroot/ldscripts/BIGTREE_S42B_V1.ld") and that file doesn't exist anywhere in this repo. But since that extra_scripts directive is commented out, it is not used anyways.

You should be able to reproduce the errors if you update your PlatformIO core (pio upgrade --dev) and platforms (pio platforms update) in the CLI.

Another way of fixing would be of course to correct the line

platform = ststm32

to include the exact version with which it compiled, e.g. ststm32@9.0.0. Since I don't know which versions you used, I fixed it by updating.

Note that I only tested that the firmware compiled, not that it runs. Someone else would have to verify that, since I don't have the hardware.

EduardoVillanova commented 3 years ago

please i need some help, i installed the Bigtreetech s42b v1.1 drives on a tevo tarantula pro on the x and y axes i didn’t change the belt or pulias but the x axis got smaller, can you solve this? the most amazing thing is that the y-axis is correct, I have already replaced the x-axis motors with the y-axis and the x-axis remains smaller no matter what I do, below is the code if you can help me I am extremely grateful
Default Axis Steps Per Unit (steps/mm)

/**

/**

NZ-Nitro commented 3 years ago

Have a look for the post I put up on inaccuracies with the stepper

maxgerhardt commented 3 years ago

What do the comments in this PR have to do with the actual PR? o_o