Skip to content

Commit

Permalink
🔨 Newer PlatformIO support
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Apr 16, 2023
1 parent 06a6708 commit bb4a01c
Show file tree
Hide file tree
Showing 34 changed files with 1,225 additions and 244 deletions.
211 changes: 211 additions & 0 deletions Marlin/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
#
# Marlin Firmware
# config.ini - Options to apply before the build
#
[config:base]
ini_use_config = none

# Load all config: sections in this file
;ini_use_config = all
# Load config file relative to Marlin/
;ini_use_config = another.ini
# Download configurations from GitHub
;ini_use_config = example/Creality/Ender-5 Plus @ bugfix-2.1.x
# Download configurations from your server
;ini_use_config = https://me.myserver.com/path/to/configs
# Evaluate config:base and do a config dump
;ini_use_config = base
;config_export = 2

[config:minimal]
motherboard = BOARD_RAMPS_14_EFB
serial_port = 0
baudrate = 250000

use_watchdog = on
thermal_protection_hotends = on
thermal_protection_hysteresis = 4
thermal_protection_period = 40

bufsize = 4
block_buffer_size = 16
max_cmd_size = 96

extruders = 1
temp_sensor_0 = 1

temp_hysteresis = 3
heater_0_mintemp = 5
heater_0_maxtemp = 275
preheat_1_temp_hotend = 180

bang_max = 255
pidtemp = on
pid_k1 = 0.95
pid_max = BANG_MAX
pid_functional_range = 10

default_kp = 22.20
default_ki = 1.08
default_kd = 114.00

x_driver_type = A4988
y_driver_type = A4988
z_driver_type = A4988
e0_driver_type = A4988

x_bed_size = 200
x_min_pos = 0
x_max_pos = X_BED_SIZE

y_bed_size = 200
y_min_pos = 0
y_max_pos = Y_BED_SIZE

z_min_pos = 0
z_max_pos = 200

x_home_dir = -1
y_home_dir = -1
z_home_dir = -1

use_xmin_plug = on
use_ymin_plug = on
use_zmin_plug = on

x_min_endstop_inverting = false
y_min_endstop_inverting = false
z_min_endstop_inverting = false

default_axis_steps_per_unit = { 80, 80, 400, 500 }
axis_relative_modes = { false, false, false, false }
default_max_feedrate = { 300, 300, 5, 25 }
default_max_acceleration = { 3000, 3000, 100, 10000 }

homing_feedrate_mm_m = { (50*60), (50*60), (4*60) }
homing_bump_divisor = { 2, 2, 4 }

x_enable_on = 0
y_enable_on = 0
z_enable_on = 0
e_enable_on = 0

invert_x_dir = false
invert_y_dir = true
invert_z_dir = false
invert_e0_dir = false

invert_e_step_pin = false
invert_x_step_pin = false
invert_y_step_pin = false
invert_z_step_pin = false

disable_x = false
disable_y = false
disable_z = false
disable_e = false

proportional_font_ratio = 1.0
default_nominal_filament_dia = 1.75

junction_deviation_mm = 0.013

default_acceleration = 3000
default_travel_acceleration = 3000
default_retract_acceleration = 3000

default_minimumfeedrate = 0.0
default_mintravelfeedrate = 0.0

minimum_planner_speed = 0.05
min_steps_per_segment = 6
default_minsegmenttime = 20000

[config:basic]
bed_overshoot = 10
busy_while_heating = on
default_ejerk = 5.0
default_keepalive_interval = 2
default_leveling_fade_height = 0.0
disable_inactive_extruder = on
display_charset_hd44780 = JAPANESE
eeprom_boot_silent = on
eeprom_chitchat = on
endstoppullups = on
extrude_maxlength = 200
extrude_mintemp = 170
host_keepalive_feature = on
hotend_overshoot = 15
jd_handle_small_segments = on
lcd_info_screen_style = 0
lcd_language = en
max_bed_power = 255
mesh_inset = 0
min_software_endstops = on
max_software_endstops = on
min_software_endstop_x = on
min_software_endstop_y = on
min_software_endstop_z = on
max_software_endstop_x = on
max_software_endstop_y = on
max_software_endstop_z = on
preheat_1_fan_speed = 0
preheat_1_label = "PLA"
preheat_1_temp_bed = 70
prevent_cold_extrusion = on
prevent_lengthy_extrude = on
printjob_timer_autostart = on
probing_margin = 10
show_bootscreen = on
soft_pwm_scale = 0
string_config_h_author = "(none, default config)"
temp_bed_hysteresis = 3
temp_bed_residency_time = 10
temp_bed_window = 1
temp_residency_time = 10
temp_window = 1
validate_homing_endstops = on
xy_probe_feedrate = (133*60)
z_clearance_between_probes = 5
z_clearance_deploy_probe = 10
z_clearance_multi_probe = 5

[config:advanced]
arc_support = on
auto_report_temperatures = on
autotemp = on
autotemp_oldweight = 0.98
bed_check_interval = 5000
default_stepper_deactive_time = 120
default_volumetric_extruder_limit = 0.00
disable_inactive_e = true
disable_inactive_x = true
disable_inactive_y = true
disable_inactive_z = true
e0_auto_fan_pin = -1
encoder_100x_steps_per_sec = 80
encoder_10x_steps_per_sec = 30
encoder_rate_multiplier = on
extended_capabilities_report = on
extruder_auto_fan_speed = 255
extruder_auto_fan_temperature = 50
fanmux0_pin = -1
fanmux1_pin = -1
fanmux2_pin = -1
faster_gcode_parser = on
homing_bump_mm = { 5, 5, 2 }
max_arc_segment_mm = 1.0
min_arc_segment_mm = 0.1
min_circle_segments = 72
n_arc_correction = 25
serial_overrun_protection = on
slowdown = on
slowdown_divisor = 2
temp_sensor_bed = 0
thermal_protection_bed_hysteresis = 2
thermocouple_max_errors = 15
tx_buffer_size = 0
watch_bed_temp_increase = 2
watch_bed_temp_period = 60
watch_temp_increase = 2
watch_temp_period = 20
38 changes: 23 additions & 15 deletions Marlin/src/HAL/LPC1768/upload_extra_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
target_filename = "FIRMWARE.CUR"
target_drive = "REARM"

import os,getpass,platform
import platform

current_OS = platform.system()
Import("env")
Expand All @@ -26,6 +26,7 @@ def print_error(e):

def before_upload(source, target, env):
try:
from pathlib import Path
#
# Find a disk for upload
#
Expand All @@ -38,6 +39,7 @@ def before_upload(source, target, env):
# Windows - doesn't care about the disk's name, only cares about the drive letter
import subprocess,string
from ctypes import windll
from pathlib import PureWindowsPath

# getting list of drives
# https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python
Expand All @@ -49,7 +51,7 @@ def before_upload(source, target, env):
bitmask >>= 1

for drive in drives:
final_drive_name = drive + ':\\'
final_drive_name = drive + ':'
# print ('disc check: {}'.format(final_drive_name))
try:
volume_info = str(subprocess.check_output('cmd /C dir ' + final_drive_name, stderr=subprocess.STDOUT))
Expand All @@ -59,29 +61,33 @@ def before_upload(source, target, env):
else:
if target_drive in volume_info and not target_file_found: # set upload if not found target file yet
target_drive_found = True
upload_disk = final_drive_name
upload_disk = PureWindowsPath(final_drive_name)
if target_filename in volume_info:
if not target_file_found:
upload_disk = final_drive_name
upload_disk = PureWindowsPath(final_drive_name)
target_file_found = True

elif current_OS == 'Linux':
#
# platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive'
#
drives = os.listdir(os.path.join(os.sep, 'media', getpass.getuser()))
import getpass
user = getpass.getuser()
mpath = Path('/media', user)
drives = [ x for x in mpath.iterdir() if x.is_dir() ]
if target_drive in drives: # If target drive is found, use it.
target_drive_found = True
upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), target_drive) + os.sep
upload_disk = mpath / target_drive
else:
for drive in drives:
try:
files = os.listdir(os.path.join(os.sep, 'media', getpass.getuser(), drive))
fpath = mpath / drive
filenames = [ x.name for x in fpath.iterdir() if x.is_file() ]
except:
continue
else:
if target_filename in files:
upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), drive) + os.sep
if target_filename in filenames:
upload_disk = mpath / drive
target_file_found = True
break
#
Expand All @@ -97,26 +103,28 @@ def before_upload(source, target, env):
#
# platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive'
#
drives = os.listdir('/Volumes') # human readable names
dpath = Path('/Volumes') # human readable names
drives = [ x for x in dpath.iterdir() if x.is_dir() ]
if target_drive in drives and not target_file_found: # set upload if not found target file yet
target_drive_found = True
upload_disk = '/Volumes/' + target_drive + '/'
upload_disk = dpath / target_drive
for drive in drives:
try:
filenames = os.listdir('/Volumes/' + drive + '/') # will get an error if the drive is protected
fpath = dpath / drive # will get an error if the drive is protected
filenames = [ x.name for x in fpath.iterdir() if x.is_file() ]
except:
continue
else:
if target_filename in filenames:
if not target_file_found:
upload_disk = '/Volumes/' + drive + '/'
upload_disk = dpath / drive
target_file_found = True
break

#
# Set upload_port to drive if found
#
if target_file_found or target_drive_found:
env.Replace(UPLOAD_PORT=upload_disk)
env.Replace(UPLOAD_PORT=str(upload_disk))
print('\nUpload disk: ', upload_disk, '\n')
else:
print_error('Autodetect Error')
Expand Down
1 change: 0 additions & 1 deletion buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import pioutil
if pioutil.is_pio_build():

import os
Import("env", "projenv")

flash_size = 0
Expand Down
1 change: 0 additions & 1 deletion buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#
import pioutil
if pioutil.is_pio_build():
import os
from os.path import join
from os.path import expandvars
Import("env")
Expand Down
27 changes: 13 additions & 14 deletions buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,29 @@
#
import pioutil
if pioutil.is_pio_build():
import os,shutil,marlin
from SCons.Script import DefaultEnvironment
from platformio import util
import shutil,marlin
from pathlib import Path

env = DefaultEnvironment()
Import("env")
platform = env.PioPlatform()
board = env.BoardConfig()

FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32-maple")
assert os.path.isdir(FRAMEWORK_DIR)
FRAMEWORK_DIR = Path(platform.get_package_dir("framework-arduinoststm32-maple"))
assert FRAMEWORK_DIR.is_dir()

source_root = os.path.join("buildroot", "share", "PlatformIO", "variants")
assert os.path.isdir(source_root)
source_root = Path("buildroot/share/PlatformIO/variants")
assert source_root.is_dir()

variant = board.get("build.variant")
variant_dir = os.path.join(FRAMEWORK_DIR, "STM32F1", "variants", variant)
variant_dir = FRAMEWORK_DIR / "STM32F1/variants" / variant

source_dir = os.path.join(source_root, variant)
assert os.path.isdir(source_dir)
source_dir = source_root / variant
assert source_dir.is_dir()

if os.path.isdir(variant_dir):
if variant_dir.is_dir():
shutil.rmtree(variant_dir)

if not os.path.isdir(variant_dir):
os.mkdir(variant_dir)
if not variant_dir.is_dir():
variant_dir.mkdir()

marlin.copytree(source_dir, variant_dir)
Loading

0 comments on commit bb4a01c

Please sign in to comment.