Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7c643b0
Add M115 and M503 reports from stock firmware
wireddown Jun 17, 2023
0c79e80
Add patchset as recommended by pull/1
wireddown Jun 17, 2023
d7f8b77
Add script to fetch and patch firmware for CR-30 PrintMill
wireddown Jun 17, 2023
62f2056
Add M115 and M503 reports from patched v2.1.2.1 firmware
wireddown Jun 17, 2023
155ade5
Add markdown describing the custom firmware
wireddown Jun 17, 2023
144ccc7
Add diff for official Marlin CR-30 configuration
wireddown Jun 24, 2023
92f2c09
Add description of power loss recovery misbehavior
wireddown Jun 24, 2023
bc4b5c6
Add patch to fix power loss recovery
wireddown Jun 25, 2023
89148b0
Use HEAD SHA and current date when patching firmware
wireddown Jul 1, 2023
e6baf9a
Add new prints emitted by the patch script
wireddown Jul 1, 2023
73445dc
Add patches for junction deviation and input shaping
wireddown Jul 6, 2023
687a254
Fix typo and add setting for working folder
wireddown Jul 7, 2023
ae2cea5
Use SHA token and PR number in signpost
wireddown Jul 7, 2023
a6e94e6
Use string token for date patch
wireddown Jul 7, 2023
7cd5c35
Update after enabling junction deviation and input shaping
wireddown Jul 7, 2023
c1c572b
Update after enabling junction deviation and input shaping
wireddown Jul 7, 2023
96f0480
Link to patch file with fix for power loss recovery
wireddown Jul 7, 2023
ca2acf5
Add fixed issue for scrambled bootscreen
wireddown Jul 7, 2023
2c2936b
Fix some typos
wireddown Jul 7, 2023
8213751
Add usage section
wireddown Jul 7, 2023
47304a2
Tidy visuals
wireddown Jul 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions cr30/marlin/get-and-patch-source.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Usage
# PS> Unblock-File .\get-and-patch-source.ps1
# PS> .\get-and-patch-source.ps1


# Settings

$working_folder = "C:/dev/scratch/cr30"

# Select the branch to build from the "Active branches" list
# https://github.com/MarlinFirmware/Marlin/branches
$fw_branch_name = "2.1.x"

# https://github.com/MarlinFirmware/Configurations/branches
$cfg_branch_name = "release-2.1.2.1"


# Constants
$fw_root_folder = "$working_folder/tmp.marlinfw"

$fw_config_folder = "$working_folder/tmp.marlincfg"
$fw_config_printer_folder = "config/examples/Creality/CR-30 PrintMill"

$patch_branch_name = "cr30-stock-with-tuning"
$patch_folder = (Join-Path $PWD "patches") | Resolve-Path
$fw_patch_message_for_folder = [ordered]@{
(Join-Path $patch_folder "02-cr30users") = "Applying CR30-Users improvements";
(Join-Path $patch_folder "03-features") = "Enabling additional Marlin features";
(Join-Path $patch_folder "05-custom") = "Setting machine specific constants and custom identifiers"
}


# Run

# Get firmware source code
Write-Host -ForegroundColor Green "Downloading Marlin firmware source code branch $fw_branch_name"
git clone --branch $fw_branch_name --depth 1 https://github.com/MarlinFirmware/Marlin.git $fw_root_folder

# Get Creality firmware settings
Write-Host -ForegroundColor Green "Downloading Marlin firmware configuration branch $cfg_branch_name"
git clone --branch $cfg_branch_name --depth 1 --sparse https://github.com/MarlinFirmware/Configurations.git $fw_config_folder
Push-Location $fw_config_folder
git sparse-checkout set "config/default" "$fw_config_printer_folder"
Pop-Location

# Patch firmware
Push-Location $fw_root_folder
git switch --create $patch_branch_name

$message = "Official: Copy baseline configuration from Marlin/Configurations/$fw_config_printer_folder"
Write-Host -ForegroundColor Green "$message"
Copy-Item -v -force "$fw_config_folder/$fw_config_printer_folder/*.h" "Marlin"
git add Marlin
git commit -q -m "$message"

# Patch the patches
## Head
$head_sha = git show-ref | grep origin | cut -c 1-9
Write-Host "Upstream baseline is $head_sha"
$head_patch_file = grep -rl "__HEAD__SHA__" "$patch_folder"
$content = [System.IO.File]::ReadAllText($head_patch_file).Replace("__HEAD__SHA__", $head_sha)
[System.IO.File]::WriteAllText($head_patch_file, $content)

## Date
$patch_date = Get-Date -Format "yyyy-MM-dd"
$date_patch_file = grep -rl "__PATCH__DATE__" "$patch_folder"
$content = [System.IO.File]::ReadAllText($date_patch_file).Replace("__PATCH__DATE__", $patch_date)
[System.IO.File]::WriteAllText($date_patch_file, $content)

# Apply the patches
foreach ($folder in $fw_patch_message_for_folder.Keys) {
$message = $($fw_patch_message_for_folder["$folder"])
Write-Host -ForegroundColor Green "$message"
foreach ($file in Get-ChildItem -File -Path "$folder/*" -Include "*.patch") {
git am -3 "$file"
}
}

Pop-Location

Write-Host -ForegroundColor Green "Launching VS Code"
code $fw_root_folder
86 changes: 86 additions & 0 deletions cr30/marlin/patched-firmware.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Firmware after applying patch set

See the specific patches in [./patches](./patches/).

### M115

```
FIRMWARE_NAME:Marlin 09d0b4d15 + pull/2 (Jul 5 2023 18:42:22) SOURCE_CODE_URL:github.com/wireddown/GCode-Machine-Configurations PROTOCOL_VERSION:1.0 MACHINE_TYPE:Camina EXTRUDER_COUNT:1 UUID:CA319A00-0000-0000-0000-00BE174103D4
Cap:SERIAL_XON_XOFF:0
Cap:BINARY_FILE_TRANSFER:0
Cap:EEPROM:1
Cap:VOLUMETRIC:1
Cap:AUTOREPORT_POS:0
Cap:AUTOREPORT_TEMP:1
Cap:PROGRESS:0
Cap:PRINT_JOB:1
Cap:AUTOLEVEL:0
Cap:RUNOUT:1
Cap:Z_PROBE:0
Cap:LEVELING_DATA:0
Cap:BUILD_PERCENT:0
Cap:SOFTWARE_POWER:0
Cap:TOGGLE_LIGHTS:1
Cap:CASE_LIGHT_BRIGHTNESS:0
Cap:EMERGENCY_PARSER:1
Cap:HOST_ACTION_COMMANDS:1
Cap:PROMPT_SUPPORT:0
Cap:SDCARD:1
Cap:MULTI_VOLUME:0
Cap:REPEAT:1
Cap:SD_WRITE:1
Cap:AUTOREPORT_SD_STATUS:0
Cap:LONG_FILENAME:0
Cap:LFN_WRITE:0
Cap:CUSTOM_FIRMWARE_UPLOAD:0
Cap:EXTENDED_M20:0
Cap:THERMAL_PROTECTION:1
Cap:MOTION_MODES:0
Cap:ARCS:1
Cap:BABYSTEPPING:1
Cap:CHAMBER_TEMPERATURE:0
Cap:COOLER_TEMPERATURE:0
Cap:MEATPACK:0
Cap:CONFIG_EXPORT:0
```

### M503

```
echo:; Linear Units:
echo: G21 ; (mm)
echo:; Temperature Units:
echo: M149 C ; Units in Celsius
echo:; Filament settings (Disabled):
echo: M200 S0 D1.75
echo:; Steps per unit:
echo: M92 X80.00 Y80.00 Z1148.40 E138.80
echo:; Max feedrates (units/s):
echo: M203 X300.00 Y300.00 Z10.00 E75.00
echo:; Max Acceleration (units/s2):
echo: M201 X300.00 Y300.00 Z100.00 E5000.00
echo:; Acceleration (units/s2) (P<print-accel> R<retract-accel> T<travel-accel>):
echo: M204 P300.00 R300.00 T600.00
echo:; Advanced (B<min_segment_time_us> S<min_feedrate> T<min_travel_feedrate> J<junc_dev>):
echo: M205 B20000.00 S0.00 T0.00 J0.02
echo:; Home offset:
echo: M206 X0.00 Y0.97 Z0.00
echo:; Material heatup parameters:
echo: M145 S0 H185.00 B55.00 F0
echo: M145 S1 H240.00 B70.00 F0
echo:; Hotend PID:
echo: M301 P21.81 I2.25 D52.78
echo:; Bed PID:
echo: M304 P49.06 I8.87 D180.88
echo:; Controller Fan:
echo: M710 S255 I0 A1 D60 ; (100% 0%)
echo:; Power-loss recovery:
echo: M413 S1 ; ON
echo:; Input Shaping:
echo: M593 X F16.60 D0.15
echo: M593 Y F16.60 D0.15
echo:; Filament load/unload:
echo: M603 L0.00 U100.00 ; (mm)
echo:; Filament runout sensor:
echo: M412 S1 ; Sensor ON
```
Loading