Skip to content

Commit

Permalink
more variant changes needed
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Oct 29, 2024
1 parent 17a1c0a commit 52729d3
Show file tree
Hide file tree
Showing 78 changed files with 230 additions and 28 deletions.
7 changes: 2 additions & 5 deletions Marlin/src/HAL/STM32/pinsDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,9 @@ const XrefInfo pin_xref[] PROGMEM = {
#define HAS_HIGH_ANALOG_PINS 1
#endif
#define NUM_ANALOG_LAST ((NUM_ANALOG_FIRST) + (NUM_ANALOG_INPUTS) - 1)
#define NUMBER_PINS_TOTAL ((NUM_DIGITAL_PINS) + TERN0(HAS_HIGH_ANALOG_PINS, NUM_ANALOG_INPUTS))
#define isValidPin(P) (WITHIN(P, 0, (NUM_DIGITAL_PINS) - 1) || TERN0(HAS_HIGH_ANALOG_PINS, WITHIN(P, NUM_ANALOG_FIRST, NUM_ANALOG_LAST)))
#else
#define NUMBER_PINS_TOTAL (NUM_DIGITAL_PINS)
#define isValidPin(P) WITHIN(P, 0, (NUM_DIGITAL_PINS) - 1)
#endif
#define NUMBER_PINS_TOTAL ((NUM_DIGITAL_PINS) + TERN0(HAS_HIGH_ANALOG_PINS, NUM_ANALOG_INPUTS))
#define isValidPin(P) (WITHIN(P, 0, (NUM_DIGITAL_PINS) - 1) || TERN0(HAS_HIGH_ANALOG_PINS, WITHIN(P, NUM_ANALOG_FIRST, NUM_ANALOG_LAST)))
#define digitalRead_mod(A) extDigitalRead(A) // must use Arduino pin numbers when doing reads
#define printPinNumber(Q)
#define printPinAnalog(P) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(P)); SERIAL_ECHO(buffer); }while(0)
Expand Down
22 changes: 22 additions & 0 deletions Marlin/src/HAL/STM32/platdefs/MARLIN_F103VE_LONGER.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
22 changes: 22 additions & 0 deletions Marlin/src/HAL/STM32/platdefs/MARLIN_F103Vx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
22 changes: 22 additions & 0 deletions Marlin/src/HAL/STM32/platdefs/MARLIN_F103Zx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
22 changes: 22 additions & 0 deletions Marlin/src/HAL/STM32/platdefs/MARLIN_F401RC_CREALITY.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
22 changes: 22 additions & 0 deletions Marlin/src/HAL/STM32/platdefs/MARLIN_F446VE.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
22 changes: 22 additions & 0 deletions Marlin/src/HAL/STM32/platdefs/MARLIN_F4x7Vx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
22 changes: 22 additions & 0 deletions Marlin/src/HAL/STM32/platdefs/MARLIN_TH3D_EZBOARD_V2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
9 changes: 9 additions & 0 deletions buildroot/share/PlatformIO/boards/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Marlin Custom Boards

Boards are specified in the INI files with the `board = board_name` field. If the board doesn't exist in the platform folder downloaded by PlatformIO then it should be defined in this folder.

The board definition JSON files in this folder provide build and upload information about boards that Marlin supports but which are not defined by any platform included with PlatformIO.

## Custom Variants

See the `buildroot/PlatformIO/variants` folder for custom variants referred to by `build.variant` in the JSON.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"ldscript": "ldscript.ld",
"mcu": "stm32f401ret6",
"variant": "MARLIN_CREALITY_STM32F401RE"
"variant": "MARLIN_F401RE_CREALITY"
},
"debug": {
"jlink_device": "STM32F401RE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"ldscript": "ldscript.ld",
"mcu": "stm32f401ret6",
"variant": "MARLIN_STM32F401RE_FREERUNS"
"variant": "MARLIN_F401RE_FREERUNS"
},
"debug": {
"jlink_device": "STM32F401RE",
Expand Down
25 changes: 8 additions & 17 deletions buildroot/share/PlatformIO/scripts/generic_create_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,17 @@
FRAMEWORK_DIR = Path(platform.get_package_dir(platform_name))
assert FRAMEWORK_DIR.is_dir()

#
# Point variants_dir to our variant folder when board_build.variant
# is provided and the variant name begins with "marlin_".
#
board = env.BoardConfig()

#mcu_type = board.get("build.mcu")[:-2]
variant = board.get("build.variant")
#mcu_type = board.get("build.mcu")[:-2]
#series = mcu_type[:7].upper() + "xx"

# Only prepare a new variant if the PlatformIO configuration provides it (board_build.variant).
# This check is important to avoid deleting official board config variants.
# Make sure the local variant sub-folder exists
if marlin_variant_pattern.match(str(variant).lower()):
# Prepare a new empty folder at the destination
variant_dir = FRAMEWORK_DIR / "variants" / variant
if variant_dir.is_dir():
shutil.rmtree(variant_dir)
if not variant_dir.is_dir():
variant_dir.mkdir()

# Source dir is a local variant sub-folder
source_dir = Path("buildroot/share/PlatformIO/variants", variant)
source_dir = Path(f"{pioutil.pio_share}/variants", variant)
assert source_dir.is_dir()

print("Copying variant " + str(variant) + " to framework directory...")

marlin.copytree(source_dir, variant_dir)
board.update("build.variants_dir", f"{pioutil.pio_share}/variants");
2 changes: 2 additions & 0 deletions buildroot/share/PlatformIO/scripts/pioutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# pioutil.py
#

pio_share = "buildroot/share/PlatformIO"

from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,4 @@ SECTIONS
}

.ARM.attributes 0 : { *(.ARM.attributes) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,26 @@ const PinName digitalPin[] = {
PC_4 //D86/A6
};

// Analog (Ax) pin number array
const uint32_t analogInputPin[] = {
3, //D3 //A0
4, //D4 //A1
32, //D32 //A2
33, //D33 //A3
34, //D34 //A4
35, //D35 //A5
36, //D36 //A6
0, //D0 //A7
1, //D1 //A8
2, //D2 //A9
5, //D5 //A10
6, //D6 //A11
7, //D7 //A12
16, //D16 //A13
17, //D17 //A14
37 //D37 //A15
};

#ifdef __cplusplus
}
#endif
Expand Down
20 changes: 20 additions & 0 deletions buildroot/share/PlatformIO/variants/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Marlin Custom Variants

This folder contains Marlin custom variants for both generic and custom boards.

There are two ways that Marlin can specify a board variant:
- With the `board_build.variant = VARIANT_MAME` field, specifying the variant subfolder name.
- With the `board = board_name` field set to a custom board with a `build.variant` field.

## Variant File Naming

With the latest STM32 platform the full names of the `variant.h` and `variant.cpp` files are based on the name of the board. If the variant is based on a generic board definition, not a Marlin custom board, then `variant_generic.h`/`.cpp` should be used. Otherwise, the capitalized name of the `board` should be used.

| board | board file | variant | Variant Files |
|-------|------------|---------|---------------|
|`genericSTM32F103VE`|n/a|`MARLIN_F103Vx`|`variants/MARLIN_F103Vx/variant_generic.*`|
|`marlin_STM32F407ZE`|`marlin_STM32F407ZE.json`|`MARLIN_F407ZE`|`variants/MARLIN_F407ZE/variant_MARLIN_F407ZE.*`|

## Custom Boards

See the `buildroot/PlatformIO/boards` folder for Marlin custom boards.
1 change: 1 addition & 0 deletions ini/stm32f1-maple.ini
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ monitor_speed = 115200
[env:STM32F103RC_meeb_maple]
extends = env:STM32F103RC_maple
board = marlin_maple_MEEB_3DP
platform_packages = platformio/tool-dfuutil@~1.11.0
build_flags = ${env:STM32F103RC_maple.build_flags}
-DDEBUG_LEVEL=0
-DSS_TIMER=4
Expand Down
14 changes: 11 additions & 3 deletions ini/stm32f4.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ build_flags = ${common_stm32_latest.build_flags}
#
[env:FYSETC_CHEETAH_V20]
extends = stm32_variant_latest
platform_packages = platformio/tool-dfuutil@~1.11.0
board = marlin_FYSETC_CHEETAH_V20
board_build.offset = 0x8000
build_flags = ${stm32_variant_latest.build_flags} -DSTM32F401xC
Expand All @@ -43,6 +44,7 @@ upload_command = dfu-util -a 0 -s 0x08008000:leave -D "$SOURCE"
#
[env:FYSETC_CHEETAH_V30]
extends = stm32_variant_latest
platform_packages = platformio/tool-dfuutil@~1.11.0
board = marlin_FYSETC_CHEETAH_V30
build_flags = ${stm32_variant_latest.build_flags} -DHAL_PCD_MODULE_ENABLED
debug_tool = stlink
Expand All @@ -54,6 +56,7 @@ upload_command = dfu-util -a 0 -s 0x08000000:leave -D "$SOURCE"
#
[env:FLYF407ZG]
extends = stm32_variant_latest
platform_packages = platformio/tool-dfuutil@~1.11.0
board = marlin_STM32F407ZGT6
board_build.variant = MARLIN_FLY_F407ZG
board_build.offset = 0x8000
Expand All @@ -66,6 +69,7 @@ upload_protocol = dfu
#
[env:FYSETC_S6]
extends = stm32_variant_latest
platform_packages = platformio/tool-dfuutil@~1.11.0
board = marlin_fysetc_s6
board_build.offset = 0x10000
board_upload.offset_address = 0x08010000
Expand All @@ -89,6 +93,7 @@ upload_command = dfu-util -a 0 -s 0x08008000:leave -D "$SOURCE"
#
[env:FYSETC_SPIDER_KING407]
extends = stm32_variant_latest
platform_packages = platformio/tool-dfuutil@~1.11.0
board = marlin_STM32F407ZGT6
board_build.variant = MARLIN_FYSETC_SPIDER_KING407
board_build.offset = 0x8000
Expand Down Expand Up @@ -426,6 +431,7 @@ build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags}
#
[env:rumba32]
extends = stm32_variant_latest
platform_packages = platformio/tool-dfuutil@~1.11.0
board = rumba32_f446ve
board_build.variant = MARLIN_F446VE
board_build.offset = 0x0000
Expand Down Expand Up @@ -701,11 +707,11 @@ extra_scripts = ${common_stm32_latest.extra_scripts}
[STM32F401RC_creality_base]
extends = stm32_variant_latest
board = genericSTM32F401RC
board_build.variant = MARLIN_CREALITY_STM32F401RC
board_build.variant = MARLIN_F401RC_CREALITY
build_flags = ${stm32_variant_latest.build_flags} -DMCU_STM32F401RC -DSTM32F4
-DSS_TIMER=4 -DTIMER_SERVO=TIM5
-DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8
-D_STM32_PLATDEFS=MARLIN_CREALITY_STM32F401RC
-D_STM32_PLATDEFS=MARLIN_F401RC_CREALITY
build_unflags = ${stm32_variant_latest.build_unflags} -DUSBCON -DUSBD_USE_CDC
monitor_speed = 115200

Expand Down Expand Up @@ -737,7 +743,7 @@ upload_protocol = stlink
#
[env:STM32F401RE_creality]
extends = stm32_variant_latest
board = marlin_CREALITY_STM32F401RE
board = marlin_STM32F401RE_creality
board_build.offset = 0x10000
board_upload.offset_address = 0x08010000
board_build.rename = firmware-{date}-{time}.bin
Expand Down Expand Up @@ -823,6 +829,7 @@ board_build.rename = mks_skipr.bin

[env:mks_skipr_v1_nobootloader]
extends = env:mks_skipr_v1
platform_packages = platformio/tool-dfuutil@~1.11.0
board_build.rename = firmware.bin
board_build.offset = 0x0000
board_upload.offset_address = 0x08000000
Expand Down Expand Up @@ -879,6 +886,7 @@ upload_protocol = stlink
#
[env:BLACKBEEZMINI_V1]
platform = ststm32
platform_packages = platformio/tool-dfuutil@~1.11.0
extends = common_stm32_latest
board = blackpill_f401cc
board_build.offset = 0x0000
Expand Down

0 comments on commit 52729d3

Please sign in to comment.