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

[FR] Update toolchains to support compiling on Raspberry Pi #27486

Open
thijstriemstra opened this issue Oct 20, 2024 · 4 comments
Open

[FR] Update toolchains to support compiling on Raspberry Pi #27486

thijstriemstra opened this issue Oct 20, 2024 · 4 comments
Labels
C: Build / Toolchain T: Feature Request Features requested by users.

Comments

@thijstriemstra
Copy link

thijstriemstra commented Oct 20, 2024

When I try to compile Marlin on a Raspberry Pi 3b+ (debian bookworm, 64bit) it fails with:

Processing STM32F446ZE_btt (board: marlin_BTT_Octopus_v1; platform: ststm32@~12.1; framework: arduino)
----------------------------------------------------------------------------------------------------------------
Platform Manager: Installing ststm32 @ ~12.1
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Platform Manager: [email protected] has been installed!
Tool Manager: Installing platformio/toolchain-gccarmnoneeabi @ ~1.90201.0
UnknownPackageError: Could not find the package with 'platformio/toolchain-gccarmnoneeabi @ ~1.90201.0' requirements for your system 'linux_aarch64'

Describe the feature you want

I would like to be able to compile Marlin on a 32 and 64-bit Raspberry Pi.

Additional context

This issue was raised before (#23815) but it was closed with rather vague comment about it being a platfomio issue. What issue specifically? I think it's more an issue with Marlin using an ancient ststm32@~12.1 (released in june 2021) which doesn't support linux_aarch64?

@thijstriemstra thijstriemstra added the T: Feature Request Features requested by users. label Oct 20, 2024
@The-EG
Copy link
Contributor

The-EG commented Oct 20, 2024

It's a platformio issue because it depends on the compiler toolchain that platformio provides. As your error message indicates, platformio does not provide the proper toolchain for aarch64, which is needed for an arm64 such as a raspberry pi.

This isn't something Marlin can address directly. It might be possible to update to another version of ststm32, which presumably might offer aarch64 support, but that would also likely require fixing up all the different variants and such along with it. It's not just a trivial version bump.

#25327 is a good example of this.

@thijstriemstra
Copy link
Author

thijstriemstra commented Oct 20, 2024

platformio does not provide the proper toolchain for aarch64, which is needed for an arm64 such as a raspberry pi.

I see there's an alternative platformio/toolchain-gccarmnoneeabi that presumably has linux_aarch64 support: platformio/platform-ststm32@2429457 That commit also references a Marlin-related platformio ticket that the pr closed: platformio/platform-ststm32#605

that would also likely require fixing up all the different variants and such along with it.

maybe there's a way to use ststm32 12.1 with this toolchain-gccarmnoneeabi ~1.100301.0 so these variants don't have to change? And what does it entail, "fixing up the different variants"?

It's not just a trivial version bump.

Just thinking out loud, not much experience with this. But I was a bit surprised to see Marlin cannot compile on a (64-bit; haven't tested 32-bit) Raspberry Pi OS (and how this, again, makes it different vs Klipper).

This isn't something Marlin can address directly.

I hope it is!

@thisiskeithb thisiskeithb changed the title [FR] Support for compiling on Raspberry Pi [FR] Update toolchains to support compiling on Raspberry Pi Oct 24, 2024
@classicrocker883
Copy link
Contributor

wasnt this added here?
d876b5e
or #24042

@thijstriemstra
Copy link
Author

thijstriemstra commented Nov 9, 2024

maybe there's a way to use ststm32 12.1 with this toolchain-gccarmnoneeabi ~1.100301.0 so these variants don't have to change? And what does it entail, "fixing up the different variants"?

Well turned out that was simple.... Tested on RPI5 bookworm 12 with patch:

diff --git a/ini/stm32-common.ini b/ini/stm32-common.ini
index ec058d1..e3cabbd 100644
--- a/ini/stm32-common.ini
+++ b/ini/stm32-common.ini
@@ -30,6 +30,7 @@ custom_marlin.TFT_TOUCH_DEVICE_GT911 = build_src_filter=+<src/HAL/STM32/tft/gt91
 # STM32 board based on a variant.
 #
 [stm32_variant]
+platform_packages = toolchain-gccarmnoneeabi@~1.100301.0
 extends       = common_stm32
 extra_scripts = ${common_stm32.extra_scripts}
                 pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py

Result without patch:

Processing STM32F446ZE_btt (board: marlin_BTT_Octopus_v1; platform: ststm32@~12.1; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Tool Manager: Installing platformio/toolchain-gccarmnoneeabi @ ~1.90201.0
UnknownPackageError: Could not find the package with 'platformio/toolchain-gccarmnoneeabi @ ~1.90201.0' requirements for your system 'linux_aarch64'

Result with patch:

Checking size .pio/build/STM32F446ZE_btt/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   8.2% (used 10696 bytes from 131072 bytes)
Flash: [===       ]  34.1% (used 178696 bytes from 524288 bytes)
Building .pio/build/STM32F446ZE_btt/firmware.bin
================================================================= [SUCCESS] Took 145.02 seconds =================================================================

Environment      Status    Duration
---------------  --------  ------------
STM32F446ZE_btt  SUCCESS   00:02:25.022

update: also tried with the latest [email protected], but this fails:

Processing STM32F446ZE_btt (board: marlin_BTT_Octopus_v1; platform: ststm32@~12.1; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Tool Manager: Installing platformio/toolchain-gccarmnoneeabi @ ^1.120301.0
Downloading  [####################################]  100%          
Unpacking  [####################################]  100%          
Tool Manager: [email protected] has been installed!
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/marlin_BTT_Octopus_v1.html
PLATFORM: ST STM32 (12.1.1) > STM32F446ZE (128k RAM. 512k Flash)
HARDWARE: STM32F446ZET6 180MHz, 128KB RAM, 512KB Flash
DEBUG: Current (stlink) External (blackmagic, jlink, stlink)
PACKAGES: 
 - framework-arduinoststm32 @ 4.10900.200819 (1.9.0) 
 - framework-cmsis @ 2.50501.200527 (5.5.1) 
 - toolchain-gccarmnoneeabi @ 1.120301.0 (12.3.1)
Converting Marlin.ino
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 15 compatible libraries
Scanning dependencies...
Dependency Graph
|-- TMCStepper @ 0.7.3
|-- Adafruit NeoPixel @ 1.12.3
|-- U8glib-HAL @ 0.5.4
|-- SlowSoftI2CMaster @ 1.0.0
|-- SlowSoftWire @ 0.0.0+20241109210547
|-- IWatchdog @ 1.0.0
|-- SPI @ 1.0
|-- EEPROM @ 2.0.1
|-- SoftwareSerial @ 1.0
|-- Wire @ 1.0
|-- Servo @ 1.1.2
Building in release mode
Compiling .pio/build/STM32F446ZE_btt/FrameworkArduinoVariant/PeripheralPins.c.o
Compiling .pio/build/STM32F446ZE_btt/FrameworkArduinoVariant/variant.cpp.o
Compiling .pio/build/STM32F446ZE_btt/FrameworkArduino/HardwareSerial.cpp.o
Compiling .pio/build/STM32F446ZE_btt/FrameworkArduino/HardwareTimer.cpp.o
Compiling .pio/build/STM32F446ZE_btt/FrameworkArduino/IPAddress.cpp.o
Compiling .pio/build/STM32F446ZE_btt/FrameworkArduino/Print.cpp.o
In member function 'void HardwareSerial::setRx(uint32_t)',
    inlined from 'HardwareSerial::HardwareSerial(void*, HalfDuplexMode_t)' at /home/thijs/.platformio/packages/framework-arduinoststm32/cores/arduino/HardwareSerial.cpp:128:10:
/home/thijs/.platformio/packages/framework-arduinoststm32/cores/arduino/HardwareSerial.cpp:490:18: warning: array subscript 'HardwareSerial[0]' is partly outside array bounds of 'USBSerial [1]' [-Warray-bounds]
  490 |   _serial.pin_rx = digitalPinToPinName(_rx);
In file included from /home/thijs/.platformio/packages/framework-arduinoststm32/cores/arduino/WSerial.h:6,
                 from /home/thijs/.platformio/packages/framework-arduinoststm32/cores/arduino/wiring.h:47,
                 from /home/thijs/.platformio/packages/framework-arduinoststm32/cores/arduino/Arduino.h:36,
                 from /home/thijs/.platformio/packages/framework-arduinoststm32/cores/arduino/HardwareSerial.cpp:26:
/home/thijs/.platformio/packages/framework-arduinoststm32/cores/arduino/USBSerial.h: In constructor 'HardwareSerial::HardwareSerial(void*, HalfDuplexMode_t)':
/home/thijs/.platformio/packages/framework-arduinoststm32/cores/arduino/USBSerial.h:70:18: note: object 'SerialUSB' of size 16
   70 | extern USBSerial SerialUSB;
      |                  ^~~~~~~~~
In member function 'void HardwareSerial::setTx(uint32_t)',
    inlined from 'HardwareSerial::HardwareSerial(void*, HalfDuplexMode_t)' at /home/thijs/.platformio/packages/framework-arduinoststm32/cores/arduino/HardwareSerial.cpp:130:10:
/home/thijs/.platformio/packages/framework-arduinoststm32/cores/arduino/HardwareSerial.cpp:495:18: warning: array subscript 'HardwareSerial[0]' is partly outside array bounds of 'USBSerial [1]' [-Warray-bounds]
  495 |   _serial.pin_tx = digitalPinToPinName(_tx);
/home/thijs/.platformio/packages/framework-arduinoststm32/cores/arduino/USBSerial.h: In constructor 'HardwareSerial::HardwareSerial(void*, HalfDuplexMode_t)':
/home/thijs/.platformio/packages/framework-arduinoststm32/cores/arduino/USBSerial.h:70:18: note: object 'SerialUSB' of size 16
   70 | extern USBSerial SerialUSB;
      |                  ^~~~~~~~~
Compiling .pio/build/STM32F446ZE_btt/FrameworkArduino/RingBuffer.cpp.o
Compiling .pio/build/STM32F446ZE_btt/FrameworkArduino/Stream.cpp.o
Compiling .pio/build/STM32F446ZE_btt/FrameworkArduino/Tone.cpp.o
Compiling .pio/build/STM32F446ZE_btt/FrameworkArduino/USBSerial.cpp.o
Compiling .pio/build/STM32F446ZE_btt/FrameworkArduino/VirtIOSerial.cpp.o
Compiling .pio/build/STM32F446ZE_btt/FrameworkArduino/WInterrupts.cpp.o
Compiling .pio/build/STM32F446ZE_btt/FrameworkArduino/WMath.cpp.o
Compiling .pio/build/STM32F446ZE_btt/FrameworkArduino/WSerial.cpp.o
Compiling .pio/build/STM32F446ZE_btt/FrameworkArduino/WString.cpp.o
Compiling .pio/build/STM32F446ZE_btt/FrameworkArduino/abi.cpp.o
Compiling .pio/build/STM32F446ZE_btt/FrameworkArduino/avr/dtostrf.c.o
/home/thijs/.platformio/packages/framework-arduinoststm32/cores/arduino/avr/dtostrf.c: In function 'dtostrf':
/home/thijs/.platformio/packages/framework-arduinoststm32/cores/arduino/avr/dtostrf.c:34:3: error: unknown type name 'uint8_t'
   34 |   uint8_t negative = 0;
      |   ^~~~~~~
/home/thijs/.platformio/packages/framework-arduinoststm32/cores/arduino/avr/dtostrf.c:24:1: note: 'uint8_t' is defined in header '<stdint.h>'; did you forget to '#include <stdint.h>'?
   23 | #include <string.h>
  +++ |+#include <stdint.h>
   24 | 
*** [.pio/build/STM32F446ZE_btt/FrameworkArduino/avr/dtostrf.c.o] Error 1
================================================================== [FAILED] Took 31.04 seconds ==================================================================

Environment      Status    Duration
---------------  --------  ------------
STM32F446ZE_btt  FAILED    00:00:31.042

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Build / Toolchain T: Feature Request Features requested by users.
Projects
None yet
Development

No branches or pull requests

4 participants