MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.14k stars 19.2k forks source link

[FR] Use external SD for EEPROM storage (DUE) #10473

Open rockman256 opened 6 years ago

rockman256 commented 6 years ago

Hellow! I have arduino due + ramps fd V1. I can compile marlin 2.0 and all works fine. SD card work. But I cant save eeprom on sd card. Helm me please. My config:

//
// EEPROM
//
#define EEPROM_SETTINGS // Enable for M500 and M501 commands
//#define DISABLE_M503    // Saves ~2700 bytes of PROGMEM. Disable for release!
#define EEPROM_CHITCHAT // Give feedback on EEPROM commands. Disable to save PROGMEM.
My pins: ```cpp /** * Marlin 3D Printer Firmware * Copyright (C) 2016 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 . * */ /** * RAMPS-FD * * No EEPROM * Use 4k7 thermistor tables */ #ifndef __SAM3X8E__ #error "Oops! Make sure you have 'Arduino Due' selected from the 'Tools -> Boards' menu." #endif #ifndef BOARD_NAME #define BOARD_NAME "RAMPS-FD" #endif #define HEATER_0_INVERTING true #define HEATER_BED_INVERTING true // // Servos // #define SERVO0_PIN 7 #define SERVO1_PIN 6 #define SERVO2_PIN 5 #define SERVO3_PIN 3 // // Limit Switches // #define X_MIN_PIN 22 #define X_MAX_PIN 30 #define Y_MIN_PIN 24 #define Y_MAX_PIN 38 #define Z_MIN_PIN 26 #define Z_MAX_PIN 34 // // Steppers // #define X_STEP_PIN 63 #define X_DIR_PIN 62 #define X_ENABLE_PIN 48 #ifndef X_CS_PIN #define X_CS_PIN 68 #endif #define Y_STEP_PIN 65 #define Y_DIR_PIN 64 #define Y_ENABLE_PIN 46 #ifndef Y_CS_PIN #define Y_CS_PIN 60 #endif #define Z_STEP_PIN 67 #define Z_DIR_PIN 66 #define Z_ENABLE_PIN 44 #ifndef Z_CS_PIN #define Z_CS_PIN 58 #endif #define E0_STEP_PIN 36 #define E0_DIR_PIN 28 #define E0_ENABLE_PIN 42 #ifndef E0_CS_PIN #define E0_CS_PIN 67 #endif #define E1_STEP_PIN 43 #define E1_DIR_PIN 41 #define E1_ENABLE_PIN 39 #ifndef E1_CS_PIN #define E1_CS_PIN 61 #endif #define E2_STEP_PIN 32 #define E2_DIR_PIN 47 #define E2_ENABLE_PIN 45 #ifndef E2_CS_PIN #define E2_CS_PIN 59 #endif // // Temperature Sensors // #define TEMP_0_PIN 1 // Analog Input #define TEMP_1_PIN 0 // Analog Input #define TEMP_2_PIN 3 // Analog Input #define TEMP_3_PIN -1 // fewer compiler warnings #define TEMP_4_PIN -1 // fewer compiler warnings #define TEMP_BED_PIN 2 // Analog Input // SPI for Max6675 or Max31855 Thermocouple #if DISABLED(SDSUPPORT) #define MAX6675_SS 53 #else #define MAX6675_SS 49 #endif // // Heaters / Fans // #define HEATER_0_PIN 8 //#define HEATER_1_PIN 11 //#define HEATER_2_PIN 11 #define HEATER_BED_PIN 10 #define CASE_LIGHT_PIN 11 #define FAN_PIN 2 //#define FAN1_PIN 12 //#define E0_FAN_PIN 12 #define E0_AUTO_FAN_PIN 12 //#undef FAN_PIN //#define FAN_PIN -1 // // Misc. Functions // #define SDSS 4 #define LED_PIN 13 // // LCD / Controller // #if ENABLED(ULTRA_LCD) // ramps-fd lcd adaptor #define BEEPER_PIN 37 #define BTN_EN1 33 #define BTN_EN2 31 #define BTN_ENC 35 #define SD_DETECT_PIN 49 #if ENABLED(NEWPANEL) #define LCD_PINS_RS 16 #define LCD_PINS_ENABLE 17 #define LCD_PINS_D4 23 #define LCD_PINS_D5 25 #define LCD_PINS_D6 27 #define LCD_PINS_D7 29 #endif #if ENABLED(MINIPANEL) #define DOGLCD_CS 25 #define DOGLCD_A0 27 #endif #endif // ULTRA_LCD #if ENABLED(HAVE_TMC2208) /** * TMC2208 stepper drivers * * Hardware serial communication ports. * If undefined software serial is used according to the pins below */ //#define X_HARDWARE_SERIAL Serial1 //#define X2_HARDWARE_SERIAL Serial1 //#define Y_HARDWARE_SERIAL Serial1 //#define Y2_HARDWARE_SERIAL Serial1 //#define Z_HARDWARE_SERIAL Serial1 //#define Z2_HARDWARE_SERIAL Serial1 //#define E0_HARDWARE_SERIAL Serial1 //#define E1_HARDWARE_SERIAL Serial1 //#define E2_HARDWARE_SERIAL Serial1 //#define E3_HARDWARE_SERIAL Serial1 //#define E4_HARDWARE_SERIAL Serial1 #endif // // M3/M4/M5 - Spindle/Laser Control // #if ENABLED(SPINDLE_LASER_ENABLE) && !PIN_EXISTS(SPINDLE_LASER_ENABLE) #if HOTENDS < 3 #define SPINDLE_LASER_ENABLE_PIN 9 #define SPINDLE_LASER_PWM_PIN 45 #define SPINDLE_DIR_PIN 47 #endif #endif ```
cjsoong commented 6 years ago

@rockman256 Ramps fd V1 does not have built-in EEPROM. Ramps-FD external EEPROM https://www.thingiverse.com/thing:1691247 8d2b0c7e296e35f572c38a0481a59f09_preview_featured

rockman256 commented 6 years ago

I know that ramps fdv1 have not chip eeprom. I need to save eeprom data on SD card.

thinkyhead commented 6 years ago

At this time the EEPROM functions for DUE write to an EEPROM, and do not support writing the data to SD. In fact, none of the platforms support using an external SD card for this purpose. The ARM platforms all use the onboard SD card that contains the FIRMWARE.CUR.

rockman256 commented 6 years ago

Bad for me, mk4duo have this function..

thinkyhead commented 6 years ago

We'll just call this a feature request, then!

ejtagle commented 6 years ago

But, on Arduino Due I did implement EEPROM emulation using the internal Flash... So, there is a way to save configuration... ;)

Bob-the-Kuhn commented 6 years ago

Here's the DUE EEPROM emulation requirements:

#if ENABLED(EEPROM_SETTINGS) && DISABLED(I2C_EEPROM) && DISABLED(SPI_EEPROM)
thinkyhead commented 6 years ago

These boards all define I2C_EEPROM by default:

Is it correct that they all do this?

Perhaps we should make it possible to override I2C_EEPROM from configurations, as in:

#define I2C_EEPROM false

Then in the aforementioned pins files…

#ifndef I2C_EEPROM
  #define I2C_EEPROM
#endif
Bob-the-Kuhn commented 6 years ago

I can verify the first three have on-board EEPROMs, I have not found any schematics for the RURAMPS4D.

rockman256 commented 6 years ago

schematics for the RURAMPS4D a6a6790510c7db42bbddf7f821e34885 RURAMPS_pinout.pdf

Bob-the-Kuhn commented 6 years ago

U2 looks like it could be an EEPROM. We'd need the schematic to be sure.

Roxy-3D commented 6 years ago

U2 looks like it could be an EEPROM. We'd need the schematic to be sure.

Can we use the I^2C chain to ask what is there? It would seem an EEPROM chip should be willing to identify itself.

robustini commented 5 years ago

MK4Duo have this function and work really fine, also with some 8 bit boards. A myriad of parameters can be configured in the eeprom, it is hardly necessary to recompile to change something. This is the eeprom map with MK4duo version 4.3.7ß of my Kossel MAX detected with Repetier Server (with the Host is the same), there is almost everything, and the eeprom on my RuRamps V1.3 is saved in the SD inserted in the LCD display without any issue. Especially in calibration and tuning it's great to be able to change many things without recompiling each time. If I want to change any parameter just that I do and click "save", everything is automatically stored on SD. I hope that in the future with Marlin we can do the same.

immagine immagine immagine immagine

thinkyhead commented 5 years ago

Here's our current EEPROM map for comparison.

typedef struct SettingsDataStruct {
  char      version[4];                                 // Vnn\0
  uint16_t  crc;                                        // Data Checksum

  //
  // DISTINCT_E_FACTORS
  //
  uint8_t   esteppers;                                  // XYZE_N - XYZ

  planner_settings_t planner_settings;

  float planner_max_jerk[XYZE],                         // M205 XYZE  planner.max_jerk[XYZE]
        planner_junction_deviation_mm;                  // M205 J     planner.junction_deviation_mm

  float home_offset[XYZ];                               // M206 XYZ / M665 TPZ

  #if HAS_HOTEND_OFFSET
    float hotend_offset[XYZ][HOTENDS - 1];              // M218 XYZ
  #endif

  //
  // ENABLE_LEVELING_FADE_HEIGHT
  //
  float planner_z_fade_height;                          // M420 Zn  planner.z_fade_height

  //
  // MESH_BED_LEVELING
  //
  float mbl_z_offset;                                   // mbl.z_offset
  uint8_t mesh_num_x, mesh_num_y;                       // GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y
  #if ENABLED(MESH_BED_LEVELING)
    float mbl_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; // mbl.z_values
  #else
    float mbl_z_values[3][3];
  #endif

  //
  // HAS_BED_PROBE
  //

  float zprobe_zoffset;

  //
  // ABL_PLANAR
  //
  matrix_3x3 planner_bed_level_matrix;                  // planner.bed_level_matrix

  //
  // AUTO_BED_LEVELING_BILINEAR
  //
  uint8_t grid_max_x, grid_max_y;                       // GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y
  int bilinear_grid_spacing[2],
      bilinear_start[2];                                // G29 L F
  #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
    float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; // G29
  #else
    float z_values[3][3];
  #endif

  //
  // AUTO_BED_LEVELING_UBL
  //
  bool planner_leveling_active;                         // M420 S  planner.leveling_active
  int8_t ubl_storage_slot;                              // ubl.storage_slot

  //
  // SERVO_ANGLES
  //
  uint16_t servo_angles[NUM_SERVOS][2];                 // M281 P L U

  //
  // DELTA / [XYZ]_DUAL_ENDSTOPS
  //
  #if ENABLED(DELTA)
    float delta_height,                                 // M666 H
          delta_endstop_adj[ABC],                       // M666 XYZ
          delta_radius,                                 // M665 R
          delta_diagonal_rod,                           // M665 L
          delta_segments_per_second,                    // M665 S
          delta_calibration_radius,                     // M665 B
          delta_tower_angle_trim[ABC];                  // M665 XYZ
  #elif ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
    float x2_endstop_adj,                               // M666 X
          y2_endstop_adj,                               // M666 Y
          z2_endstop_adj,                               // M666 Z (S2)
          z3_endstop_adj;                               // M666 Z (S3)
  #endif

  //
  // ULTIPANEL
  //
  int16_t lcd_preheat_hotend_temp[2],                   // M145 S0 H
          lcd_preheat_bed_temp[2];                      // M145 S0 B
  uint8_t lcd_preheat_fan_speed[2];                     // M145 S0 F

  //
  // PIDTEMP
  //
  PIDC_t hotendPID[HOTENDS];                            // M301 En PIDC / M303 En U
  int16_t lpq_len;                                      // M301 L

  //
  // PIDTEMPBED
  //
  PID_t bedPID;                                         // M304 PID / M303 E-1 U

  //
  // HAS_LCD_CONTRAST
  //
  int16_t lcd_contrast;                                 // M250 C

  //
  // FWRETRACT
  //
  fwretract_settings_t fwretract_settings;              // M207 S F Z W, M208 S F W R
  bool autoretract_enabled;                             // M209 S

  //
  // !NO_VOLUMETRIC
  //
  bool parser_volumetric_enabled;                       // M200 D  parser.volumetric_enabled
  float planner_filament_size[EXTRUDERS];               // M200 T D  planner.filament_size[]

  //
  // HAS_TRINAMIC
  //
  tmc_stepper_current_t tmc_stepper_current;            // M906 X Y Z X2 Y2 Z2 Z3 E0 E1 E2 E3 E4 E5
  tmc_hybrid_threshold_t tmc_hybrid_threshold;          // M913 X Y Z X2 Y2 Z2 Z3 E0 E1 E2 E3 E4 E5
  tmc_sgt_t tmc_sgt;                                    // M914 X Y Z

  //
  // LIN_ADVANCE
  //
  float planner_extruder_advance_K[EXTRUDERS];          // M900 K  planner.extruder_advance_K

  //
  // HAS_MOTOR_CURRENT_PWM
  //
  uint32_t motor_current_setting[3];                    // M907 X Z E

  //
  // CNC_COORDINATE_SYSTEMS
  //
  float coordinate_system[MAX_COORDINATE_SYSTEMS][XYZ]; // G54-G59.3

  //
  // SKEW_CORRECTION
  //
  skew_factor_t planner_skew_factor;                    // M852 I J K  planner.skew_factor

  //
  // ADVANCED_PAUSE_FEATURE
  //
  fil_change_settings_t fc_settings[EXTRUDERS];         // M603 T U L

  //
  // SINGLENOZZLE toolchange values
  //
  #if EXTRUDERS > 1
    toolchange_settings_t toolchange_settings;                // M217 S P R
  #endif

} SettingsData;
thinkyhead commented 5 years ago

I'm considering an overhaul to the EEPROM to make it easier to re-use old data. Namely, storing all settings in IFF format. But that will have to wait for some other tasks higher on my list.

boelle commented 5 years ago

@rockman256 is this still relavant?

pinchies commented 5 years ago

It looks like there is some support for SD as EEPROM in the HAL folders... but I couldn't get it to work. Also interested in a status update.

pinchies commented 5 years ago

SD as settings storage location (EEPROM emulation) should be working now on STM32F1 (#13475).