I started with a blank, newly formatted 8GB SanDisk microSD card (mkfs.vfat /dev/sdb1). The card was purchased earlier this year. I copied clean versions of config and config-override from my desktop directly to the card (not via Smoothie).
I am working on some new features that demand saving some extra stuff to config-override, as well as writing an auxiliary file to store probed depths. When I write the depths to their own separate file, no problem - what I write is what I read, even after a reset. However, one of the existing lines that gets written to the override is longer by a few variables. I also write a line to enable surface normal and depth-based Z correction:
(this line is made longer - usually it’s only L and R)
;Optional arm solution specific settings:
M665 A0.0000 B1.1665 C0.7814 D-0.1427 E0.6359 F-1.5967 L268.7080 R129.6800
This is new:
; ABC=Shimming data; D=Shimming; E=Depth map; Z=Master enable
M667 A1.2630 B0.6692 C-0.3854 D1 E1 Z1
Now, when I type M503 (dump config to console), I get this:
; config override present: /sd/config-override
;Steps per unit:
M92 X213.33330 Y213.33330 Z213.33330
;Acceleration mm/sec^2:
M204 S1000.00000 Z0.00000
;X- Junction Deviation, Z- Z junction deviation, S - Minimum Planner speed:
M205 X0.01000 Z-1.00000 S0.00000
;Max feedrates in mm/sec, XYZ cartesian, ABC actuator:
M203 X500.00000 Y500.00000 Z500.00000 A468.00000 B468.00000 C468.00000
;Optional arm solution specific settings:
M665 A0.0000 B1.1665 C0.7814 D-0.1427 E0.6359 F-1.5967 L268.7080 R129.6800
;Motor currents:
M907 X1.60000 Y1.60000 Z1.60000 E1.60000
;Home offset (mm):
M206 X0.00 Y0.00 Z0.00
;Trim (mm):
M666 X-1.886 Y-1.431 Z0.000
;Max Z
M665 Z351.422
;E Steps per mm:
M92 E171.3000
;E Filament diameter:
M200 D0.0000
;E retract length, feedrate, zlift length, feedrate:
M207 S3.0000 F2700.0000 Z0.0000 Q6000.0000
;E retract recover length, feedrate:
M208 S0.0000 F480.0000
;E acceleration mm/sec^2:
M204 E2000.0000
;PID settings:
M301 S0 P59.5257 I7.0237 D126.1200
;PID settings:
M301 S1 P1544.0745 I203.8382 D2924.0908
; ABC=Shimming data; D=Shimming; E=Depth map; Z=Master enable
M667 A1.2630 B0.6692 C-0.3854 D1 E1 Z1
That all looks good. However, when I read the file (over USB, or by shutting down the printer and moving it to a card reader), I get this:
0
;Home offset (mm):
M206 X0.00 Y0.00 Z0.00
;Trim (mm):
M666 X-1.886 Y-1.431 Z0.000
;Max Z
M665 Z351.422
;E Steps per mm:
M92 E171.3000
;E Filament diameter:
M200 D0.0000
;E retract length, feedrate, zlift length, feedrate:
M207 S3.0000 F2700.0000 Z0.0000 Q6000.0000
;E retract recover length, feedrate:
M208 S0.0000 F480.0000
;E acceleration mm/sec^2:
M204 E2000.0000
;PID settings:
M301 S0 P59.5257 I7.0237 D126.1200
;PID settings:
M301 S1 P1544.0745 I203.8382 D2924.0908
; ABC=Shimming data; D=Shimming; E=De0.00 Z0.00
;Trim (mm):
M666 X-0.576 Y0.000 Z-0.165
;Max Z
M665 Z351.436
;E Steps per mm:
M92 E171.3000
;E Filament diameter:
M200 D0.0000
;E retract length, feedrate, zlift length, feedrate:
M207 S3.0000 F2700.0000 Z0.0000 Q6000.0000
;E retract recover length, feedrate:
M208 S0.0000 F480.0000
;E acceleration mm/sec^2:
M204 E2000.0000
;PID settings:
M301 S0 P59.5257 I7.0237 D126.1200
;PID settings:
M301 S1 P1544.0745 I203.8382 D2924.0908
; ABC=Shimming data; D=Shimming; E=Depth map; Z=Master enable
M667 A0 Bpth map; Z=Master enable
M667 A1.2630 B0.6692 C-0.3854 D1 E1 Z1
If you look closely, you can see that M665 ABCDEFLR (arm-specific options) is totally missing. Additionally, the comment “ABC=Shimming…” shows up halfway through the file, and then again at the end, and the text itself looks like someone copied and pasted random collections of characters to various places (e.g. “M667 A0 Bpth map; Z=Master enable”, partial text from two lines mixed into one.)
In case it matters, this is the code I use to output the M667 line, in a switch block that looks for M500 and M503:
gcode->stream->printf("; ABC=Shimming data; D=Shimming; E=Depth map; Z=Master enable\nM667 A%1.4f B%1.4f C%1.4f D%d E%d Z%d\n", surface_transform.tri_points[X][Z], surface_transform.tri_points[Y][Z], surface_transform.tri_points[Z][Z], surface_transform.plane_enabled, surface_transform.depth_enabled, surface_transform.active);
At this point, I’m stumped. I’ve been making sure not to edit files via Smoothie, to shut down the printer and move the card to a reader if I want to edit config-override. I don’t think the way I’m emitting g-code for config-override is “wrong” or anything. I just synced my branch to edge, so it’s running edge’s code as of an hour and a half ago, so there are no uncommitted fixes. I do recall seeing a bunch of comments about “fwrite corruption” in the source.
What should I do?
Imported from wikidot