-
-
Notifications
You must be signed in to change notification settings - Fork 190
Version Upgrade and how to keep the stored settings
If you are wondering whether you can simply update a firmware version or lose your settings during the update, there is a very clear answer: It depends.
With every new release I point out that the default settings of the firmware must first be loaded and then saved to the EEPROM so that this is initialized. But why all this? Why is there no update/upgrade?
The problem lies in the allocation of memory in microcontrollers. There is...
- ROM (read-only-memory), meaning a memory that can only be read. However, this refers to the runtime, i.e. when the printer is switched on and the mainboard is normally supplied with power. This area contains the firmware including all standard settings. You can write to this memory - but this always requires external access, since this memory is protected and cannot/may not change itself.
- RAM (random-access-memory is a volatile memory in which data can be stored, i.e. written and read, at runtime. This is a right fast memory, which is emptied when the power supply is interrupted. The firmware stores everything that is currently needed and set here. The gcode to be printed is also temporarily stored here.
- EEPROM (electrically erasable programmable read-only memory) is a memory that can be written to at runtime and that retains its state even when the power is turned off . This is where settings are saved that were not previously in ROM or were changed. For example the mesh level data or the E-Steps.
Now you might think: "Yeah great. Then I just change the ROM and read the stuff out of the EEPROM again".
It also sounds like a good idea, but the EEPROM is so tiny (only 4 kilobytes) that there is no room for a file system. Without a file system, there is only the possibility of directly accessing the addresses of the memory, because it is numbered consecutively.
For example, if you want to read the value for the E-Steps, you have to know the address and the length of the area in which this number can be found. If something else is there or if the number is in a format that you do not expect, the entire program, i.e. the firmware, can crash and behave unexpectedly. It is therefore absolutely essential that the structure matches the expected structure. There must be no more and no less in the EEPROM than exactly what is expected.
This is where the update problem comes in.
If the new firmware expects even a single character in the EEPROM to be in a different place, the whole concept no longer works and it is necessary to rather remap the entire memory to be sure that everything is in place .
"But with some firmwares, the settings are retained despite the update, how can that be? I was able to update from 1.2.0 to 1.3.1 without having to initialize the EEPROM."
Yeah right. The reason for this is that the "substructure" of the firmware has remained the same and only a few things have changed functionally. So it was possible to keep the settings across multiple firmware versions. However, it should be noted here that some of the basic settings have also changed over time and the adopted settings may not have been ideal for the printer. However, it worked.
Which firmware can I update now without losing the settings? Can I find out?
Yes, you can. Each firmware version has a file that contains the required EEPROM version. This version is in the EEPROM and in the firmware, and if both are identical, the settings can be read and written without having to initialize anything beforehand.
The file can be found under the path /Marlin/src/module/settings.cpp
and contains all functions for the EEPROM and relatively high up the entry EEPROM_VERSION
with a number behind it. This number is the version number, for example V87
, i.e. version 87. Each time the EEPROM structure is changed, this number is incremented and the firmware in the ROM thus knows when it is compatible and when it is not.
An example of version 1.5.1 can be found here (click me)
You only have to look at this point in the source code after a release to know whether the EEPROM is compatible or not.
If the new firmware uses a new EEPROM , there is no way around a new initialization (Load FW Defaults + Save EEPROM). However, you can have all saved values output as a test on the console and thus receive GCODE commands, which you can simply import again after flashing the new firmware.
The magic command for this is M503 - Report Settings
An excerpt from an I3 MEGA S with BLTouch looks like this:
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 Z400.00 E393.00
echo:; Max feedrates (units/s):
echo: M203 X500.00 Y500.00 Z6.00 E40.00
echo:; Max Acceleration (units/s2):
echo: M201 X3000.00 Y2000.00 Z60.00 E10000.00
echo:; Acceleration (units/s2) (P<print-accel> R T):
echo: M204 P1500.00 R1500.00 T3000.00
echo:; Advanced (B S T X Y Z E):
echo: M205 B20000.00 S0.00 T0.00 X8.00 Y8.00 Z0.40 E10.00
echo:; Home offset:
echo: M206 X0.00 Y0.00 Z0.00
echo:; Auto Bed Leveling:
echo: M420 S1 Z0.00 ; Leveling ON
echo: G29 W I0 J0 Z-0.13250
echo: G29 W I1 J0 Z-0.20000
echo: G29 W I2 J0 Z0.08750
echo: G29 W I3 J0 Z-0.12250
echo: G29 W I4 J0 Z-0.17250
echo: G29 W I0 J1 Z0.21250
echo: G29 W I1 J1 Z-0.15750
echo: G29 W I2 J1 Z-0.06000
echo: G29 W I3 J1 Z0.03250
echo: G29 W I4 J1 Z0.16500
echo: G29 W I0 J2 Z0.20000
echo: G29 W I1 J2 Z-0.19750
echo: G29 W I2 J2 Z-0.12000
echo: G29 W I3 J2 Z-0.02250
echo: G29 W I4 J2 Z0.27250
echo: G29 W I0 J3 Z0.10000
echo: G29 W I1 J3 Z-0.27250
echo: G29 W I2 J3 Z-0.08500
echo: G29 W I3 J3 Z0.07000
echo: G29 W I4 J3 Z0.11500
echo: G29 W I0 J4 Z-0.19250
echo: G29 W I1 J4 Z-0.12500
echo: G29 W I2 J4 Z0.14750
echo: G29 W I3 J4 Z0.03500
echo: G29 W I4 J4 Z0.19250
echo:; Endstop adjustment:
echo: M666 Z0.00
echo:; Hotend PID:
echo: M301 P12.28 I0.75 D50.06
echo:; Bed PID:
echo: M304 P251.78 I49.57 D319.73
echo:; Z-Probe Offset:
echo: M851 X-2.00 Y-25.00 Z-0.40 ; (mm)
echo:; Linear Advance:
echo: M900 K0.00
echo:; Filament load/unload:
echo: M603 L538.00 U555.00 ; (mm)
echo:; Filament runout sensor:
echo: M412 S1 ; Sensor ON
ok
As you can see, there are not only headings for the individual values, but also a completely correct GCODE line, which you can take over directly.
The example of the E-Steps can be found here:
echo:; Steps per unit:
echo: M92 X80.00 Y80.00 Z400.00 E393.00
We can simply take this line and...
M92 X80.00 Y80.00 Z400.00 E393.00
..copy and paste directly after flashing the new firmware. The same goes for all other points. Even the mesh consists only of a series of G29 commands (one for each point on the bed), which you can save.
This also works, by the way, by only querying individual commands! For example, if you know exactly that you only want to read the Z offset of your BLTouch sensor, you can simply enter M851
and you will only get this one specific line:
echo: M851 X-2.00 Y-25.00 Z-0.40 ; (mm)
So we don't have to rummage through the entire EEPROM. You can also simply look for a few required values and save them for later versions.
When all values have been transferred back to the printer, they only have to be saved with M500 - Save Settings and are then also in the printer after a restart available and are read out and used again and again at the start.
*Es muss jetzt keine großzügige Spende sein. Ein paar Cent reichen um mir zu zeigen, wer überhaupt Interesse daran hat und wem die Weiterentwicklung wichtig ist. So bleibt die Motivation da und ich weiß einfach, dass ich nicht für die Tonne programmiere ;)
*It doesn't have to be a generous donation. A few cents are enough to show me who is interested in further development. So the motivation stays and I just know that I am not programming for the bin ;)