From 172fcfac17f203c3a3ac1c6ef64f35a3db965b77 Mon Sep 17 00:00:00 2001 From: Alexander Efimov Date: Fri, 5 Jun 2020 20:37:44 +0300 Subject: [PATCH 1/4] Bugfixes from Marlin --- .gitignore | 3 + Marlin/Configuration.h | 16 +- Marlin/src/HAL/LPC1768/upload_extra_script.py | 0 Marlin/src/HAL/STM32F1/build_flags.py | 0 Marlin/src/HAL/STM32F1/sdio.h | 4 +- Marlin/src/HAL/shared/eeprom_i2c_at24.cpp | 189 ------------------ Marlin/src/libs/fatfs/diskio.cpp | 0 Marlin/src/libs/fatfs/diskio.h | 0 Marlin/src/libs/fatfs/integer.h | 0 platformio.ini | 5 +- 10 files changed, 18 insertions(+), 199 deletions(-) mode change 100755 => 100644 .gitignore mode change 100755 => 100644 Marlin/src/HAL/LPC1768/upload_extra_script.py mode change 100755 => 100644 Marlin/src/HAL/STM32F1/build_flags.py delete mode 100644 Marlin/src/HAL/shared/eeprom_i2c_at24.cpp mode change 100755 => 100644 Marlin/src/libs/fatfs/diskio.cpp mode change 100755 => 100644 Marlin/src/libs/fatfs/diskio.h mode change 100755 => 100644 Marlin/src/libs/fatfs/integer.h diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 index c6bfe84c5f..fd48b1f2ae --- a/.gitignore +++ b/.gitignore @@ -190,3 +190,6 @@ ozone.jdebug ozone.jdebug.user *.txt + +# Windows users need this to prevent adding build tree to git +buildroot/* \ No newline at end of file diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 6800797d49..e9f6e0207e 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -480,7 +480,7 @@ //#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay //#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders) // Set/get with gcode: M301 E[extruder number, 0-2] - #define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature + #define PID_FUNCTIONAL_RANGE 15 // If the temperature difference between the target temperature and the actual temperature // is more than PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max. // If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it @@ -763,11 +763,12 @@ * Override with M201 * X, Y, Z, E0 [, E1[, E2...]] */ -#define DEFAULT_MAX_ACCELERATION { 1000, 1000, 100, 1000 } +// @efim-a-efim - decreased E0 acceleration to make it less noisy (yes, even with TMC2208 drivers) +#define DEFAULT_MAX_ACCELERATION { 1000, 1000, 100, 800 } -//#define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2 +#define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2 #if ENABLED(LIMITED_MAX_ACCEL_EDITING) - #define MAX_ACCEL_EDIT_VALUES { 1000, 1000, 100, 1000 } // ...or, set your own edit limits + #define MAX_ACCEL_EDIT_VALUES { 2000, 2000, 100, 1000 } // ...or, set your own edit limits #endif /** @@ -778,8 +779,9 @@ * M204 R Retract Acceleration * M204 T Travel Acceleration */ +// @efim-a-efim - decreased E0 acceleration to make it less noisy (yes, even with TMC2208 drivers) #define DEFAULT_ACCELERATION 1000 // X, Y, Z and E acceleration for printing moves -#define DEFAULT_RETRACT_ACCELERATION 1000 // E acceleration for retracts +#define DEFAULT_RETRACT_ACCELERATION 800 // E acceleration for retracts #define DEFAULT_TRAVEL_ACCELERATION 1000 // X, Y, Z acceleration for travel (non printing) moves /** @@ -1077,7 +1079,7 @@ // For direct drive extruder v9 set to true, for geared extruder set to false. #define INVERT_E0_DIR true -#define INVERT_E1_DIR false +#define INVERT_E1_DIR true #define INVERT_E2_DIR false #define INVERT_E3_DIR false #define INVERT_E4_DIR false @@ -1094,7 +1096,7 @@ #define Z_HOMING_HEIGHT 2 // (mm) Minimal Z height before homing (G28) for Z clearance above the bed, clamps, ... // Be sure to have this much clearance over your Z_MAX_POS to prevent grinding. -//#define Z_AFTER_HOMING 10 // (mm) Height to move to after homing Z +#define Z_AFTER_HOMING 10 // (mm) Height to move to after homing Z // Direction of endstops when homing; 1=MAX, -1=MIN // :[-1,1] diff --git a/Marlin/src/HAL/LPC1768/upload_extra_script.py b/Marlin/src/HAL/LPC1768/upload_extra_script.py old mode 100755 new mode 100644 diff --git a/Marlin/src/HAL/STM32F1/build_flags.py b/Marlin/src/HAL/STM32F1/build_flags.py old mode 100755 new mode 100644 diff --git a/Marlin/src/HAL/STM32F1/sdio.h b/Marlin/src/HAL/STM32F1/sdio.h index f51ba6d0a6..6aeac15247 100644 --- a/Marlin/src/HAL/STM32F1/sdio.h +++ b/Marlin/src/HAL/STM32F1/sdio.h @@ -100,7 +100,9 @@ #define SDIO_DATA_TIMEOUT 100U /* Read data transfer timeout */ #define SDIO_WRITE_TIMEOUT 200U /* Write data transfer timeout */ -#define SDIO_CLOCK 18000000 /* 18 MHz */ +// #define SDIO_CLOCK 18000000 /* 18 MHz */ +// Setting SDIO_CLOCK to 4.5 MHz fixes random print interruptions with moving to endstops +#define SDIO_CLOCK 4500000 /* 4.5 MHz */ // ------------------------ // Types diff --git a/Marlin/src/HAL/shared/eeprom_i2c_at24.cpp b/Marlin/src/HAL/shared/eeprom_i2c_at24.cpp deleted file mode 100644 index 790fd45f4f..0000000000 --- a/Marlin/src/HAL/shared/eeprom_i2c_at24.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/** - -AT24C16, 16K SERIAL EEPROM: -Internally organized with 128 pages of 16 bytes each (2048 bytes) - -16K requires an 11-bit data word address for random word addressing. - -The 16K does not use any device address bits but instead the 3 bits are used for mem- -ory page addressing. These page addressing bits on the 4K, 8K and 16K devices -should be considered the most significant bits of the data word address which follows. -The A0, A1 and A2 pins are no connect. - -*/ -#include "../../inc/MarlinConfig.h" - -#if ENABLED(I2C_EEPROM_AT24C16) - -#include "../HAL.h" -#include "../../module/mks_wifi/small_cmsis.h" -#include "../../module/mks_wifi/dwt.h" - -#define DEV_ADDR 0xA0 -#define FSMC_DISABLE RCC->AHBENR &= ~RCC_AHBENR_FSMCEN //Конфликт на ноге FSMC_NADV с I2C. На время передачи приходится отключать FSMC -#define FSMC_RESTORE RCC->AHBENR |= RCC_AHBENR_FSMCEN; - -#define I2C_TIMEOUT 2000 //таймаут на ожидание опереций I2C. - -#define CHECK_TIMEOUT do{if(dwt_get_timeout() == 0){ERROR("Timeout");return 0;}}while(0) - -static bool waitSRBitSet(uint32_t Bit); -static uint8_t i2c_write(const uint8_t hw_adr, uint8_t *data, uint32_t len); -static uint8_t i2c_read(const uint8_t hw_adr, uint16_t addr, uint8_t *data, uint32_t len); - - -void eeprom_hw_init(void){ -/* -PB6 SCL Alternate function open drain -PB7 SDA Alternate function open drain -*/ - dwt_init(); - - RCC->APB2ENR |= RCC_APB2ENR_IOPBEN|RCC_APB2ENR_AFIOEN; - PORTB->CRL |= (GPIO_CRL_MODE6|GPIO_CRL_MODE7|GPIO_CRL_CNF6|GPIO_CRL_CNF7); - - AFIO->MAPR2 |= AFIO_MAPR2_FSMC_NADV_REMAP; //Remap по факту не работает, бит не устанавливается. - RCC->APB1ENR|= RCC_APB1ENR_I2C1EN; - - I2C1->CR1 = I2C_CR1_SWRST; - I2C1->CR1 = 0; - - //Тактовая 72Mhz, PCLK 36Mhz - I2C1->CCR = (180 << I2C_CCR_CCR_Pos); - I2C1->CR2 = (36 << I2C_CR2_FREQ_Pos); - I2C1->TRISE = 37; - I2C1->CR1 = I2C_CR1_PE; -} - -void eeprom_write_byte(uint16_t *pos, unsigned char value) { - uint8_t data[2]; - - //DEBUG("EEPROM write to pos: %d val %0X",pos,value); - FSMC_DISABLE; - - data[0]=(uint8_t)((unsigned)pos % 256); - data[1]=(uint8_t)(value); - - if(!i2c_write((DEV_ADDR+(uint8_t)(((unsigned)pos/256)<<1)),data,2)){ - ERROR("write failed"); - } - safe_delay(20); //Задержка на время пока eeprom пишет. - FSMC_RESTORE; -} - -uint8_t eeprom_read_byte(uint16_t *pos) { - uint8_t data; - - //DEBUG("EEPROM read from pos: %d",pos); - FSMC_DISABLE; - - if(!i2c_read(DEV_ADDR, (uint16_t)((unsigned)pos), &data, 1)){ - ERROR("read failed"); - data=0; - } - - safe_delay(1); //небольшая пауза перед включением FSMC, чтобы состояние STOP успело выставиться на линии. - FSMC_RESTORE; - return data; -} - - -static uint8_t i2c_write(const uint8_t hw_adr, uint8_t *data, uint32_t len){ - - DEBUG("i2c write at %d val %0X",data[0],data[1]); - - dwt_settimeout(I2C_TIMEOUT); - DEBUG("Wait busy"); - while(I2C1->SR2 & I2C_SR2_BUSY) {CHECK_TIMEOUT;}; - - - I2C1->CR1 = I2C_CR1_PE | I2C_CR1_START; - dwt_settimeout(I2C_TIMEOUT); - DEBUG("Wait SB"); - while(!(I2C1->SR1 & I2C_SR1_SB)) {CHECK_TIMEOUT;}; - I2C1->DR = (hw_adr & 0xFE); - - if(!waitSRBitSet(I2C_SR1_ADDR)) return false; - (void)I2C1->SR2; - - while(len--){ - if(!waitSRBitSet(I2C_SR1_TXE)) return false; - I2C1->DR = *data++; - } - - dwt_settimeout(I2C_TIMEOUT); - DEBUG("Wait BTF"); - while(!((I2C1->SR1 & I2C_SR1_TXE) && (I2C1->SR1 & I2C_SR1_BTF))) {CHECK_TIMEOUT;}; - I2C1->CR1 = I2C_CR1_PE | I2C_CR1_STOP; - - return 1; - } - -static uint8_t i2c_read(const uint8_t hw_adr, uint16_t addr, uint8_t *data, uint32_t len){ - - dwt_settimeout(I2C_TIMEOUT); - DEBUG("Wait busy"); - while(I2C1->SR2 & I2C_SR2_BUSY) {CHECK_TIMEOUT;}; - - //Запись адреса - I2C1->CR1 = I2C_CR1_PE | I2C_CR1_START; - - dwt_settimeout(I2C_TIMEOUT); - DEBUG("Wait SB"); - while(!(I2C1->SR1 & I2C_SR1_SB)) {CHECK_TIMEOUT;}; //Условие старт - - - I2C1->DR = ((hw_adr & 0xFE) + ((addr/256) << 1)); - if(!waitSRBitSet(I2C_SR1_ADDR)) return false; //i2c адрес отправлен - I2C1->SR2; - - if(!waitSRBitSet(I2C_SR1_TXE)) return false; - I2C1->DR = addr%256; //адрес в памяти отправлен - - dwt_settimeout(I2C_TIMEOUT); - DEBUG("Wait BTF"); - while(!((I2C1->SR1 & I2C_SR1_TXE) && (I2C1->SR1 & I2C_SR1_BTF))) {CHECK_TIMEOUT;}; - - //Чтение - I2C1->CR1 = I2C_CR1_PE | I2C_CR1_START | I2C_CR1_ACK; - - dwt_settimeout(I2C_TIMEOUT); - DEBUG("Wait SB"); - while(!(I2C1->SR1 & I2C_SR1_SB)) {CHECK_TIMEOUT;}; - I2C1->DR = hw_adr|1; - - if(!waitSRBitSet(I2C_SR1_ADDR)) return false; - I2C1->SR2; - I2C1->CR1 = I2C_CR1_PE | I2C_CR1_STOP; - - if(!waitSRBitSet(I2C_SR1_RXNE)) return false; - *data = I2C1->DR; - - return true; - } - - -static bool waitSRBitSet(uint32_t Bit){ - uint32_t sr; - - dwt_settimeout(I2C_TIMEOUT); - do{ - sr = I2C1->SR1; - if(sr & ( I2C_SR1_AF | I2C_SR1_ARLO | I2C_SR1_BERR)){ - I2C1->CR1 = I2C_CR1_PE | I2C_CR1_STOP; - I2C1->SR1 = 0; - ERROR("I2C Error flag %0X",sr); - return false; - } - if(dwt_get_timeout() == 0){ - ERROR("Timeout %0X",Bit); - return false; - } - - }while(!(sr & Bit)); - - return true; -}; - - -#endif // I2C_EEPROM diff --git a/Marlin/src/libs/fatfs/diskio.cpp b/Marlin/src/libs/fatfs/diskio.cpp old mode 100755 new mode 100644 diff --git a/Marlin/src/libs/fatfs/diskio.h b/Marlin/src/libs/fatfs/diskio.h old mode 100755 new mode 100644 diff --git a/Marlin/src/libs/fatfs/integer.h b/Marlin/src/libs/fatfs/integer.h old mode 100755 new mode 100644 diff --git a/platformio.ini b/platformio.ini index 8605e9329c..d01ddb7981 100644 --- a/platformio.ini +++ b/platformio.ini @@ -27,9 +27,10 @@ build_flags = -fmax-errors=5 -g -D__MARLIN_FIRMWARE__ -fmerge-all-constants lib_deps = LiquidCrystal TMCStepper@>=0.6.2,<1.0.0 - Adafruit NeoPixel + Adafruit NeoPixel@1.4.0 U8glib-HAL=https://github.com/MarlinFirmware/U8glib-HAL/archive/bugfix.zip - Adafruit_MAX31865=https://github.com/adafruit/Adafruit_MAX31865/archive/master.zip + # Adafruit_MAX31865 has broken backward compatibility after 1.1.0 version + Adafruit_MAX31865=https://github.com/adafruit/Adafruit_MAX31865/archive/1.1.0.zip LiquidTWI2=https://github.com/lincomatic/LiquidTWI2/archive/master.zip Arduino-L6470=https://github.com/ameyer/Arduino-L6470/archive/0.8.0.zip SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip From 2544b24e43d4f0e24a7e6d9745eea3656875bbec Mon Sep 17 00:00:00 2001 From: Alexander Efimov Date: Fri, 5 Jun 2020 20:57:44 +0300 Subject: [PATCH 2/4] One more fix to SDIO --- Marlin/src/HAL/STM32F1/sdio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/HAL/STM32F1/sdio.cpp b/Marlin/src/HAL/STM32F1/sdio.cpp index da6beda85c..838316b4f4 100644 --- a/Marlin/src/HAL/STM32F1/sdio.cpp +++ b/Marlin/src/HAL/STM32F1/sdio.cpp @@ -121,7 +121,7 @@ bool SDIO_ReadBlock_DMA(uint32_t blockAddress, uint8_t *data) { } bool SDIO_ReadBlock(uint32_t blockAddress, uint8_t *data) { - uint32_t retries = 3; + uint32_t retries = 10; while (retries--) if (SDIO_ReadBlock_DMA(blockAddress, data)) return true; return false; } From d01b5e1dc053cb507c96794955a90fdfa5b130e3 Mon Sep 17 00:00:00 2001 From: Alexander Efimov Date: Sat, 6 Jun 2020 21:37:37 +0300 Subject: [PATCH 3/4] Fixing extrusion --- Marlin/Configuration_adv.h | 5 +++-- Marlin/src/feature/runout.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index eb4f184690..0605cf1616 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2238,7 +2238,8 @@ */ #define STEALTHCHOP_XY #define STEALTHCHOP_Z - #define STEALTHCHOP_E + // @efim-a-efim: Vendor recommends disabling stealthchop on extruder + // #define STEALTHCHOP_E /** * Optimize spreadCycle chopper parameters by using predefined parameter sets @@ -2340,7 +2341,7 @@ * Beta feature! * Create a 50/50 square wave step pulse optimal for stepper drivers. */ - //#define SQUARE_WAVE_STEPPING + #define SQUARE_WAVE_STEPPING /** * Enable M122 debugging command for TMC stepper drivers. diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index b975551c6e..ce431dd40b 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -43,7 +43,7 @@ //#define FILAMENT_RUNOUT_SENSOR_DEBUG #ifndef FILAMENT_RUNOUT_THRESHOLD - #define FILAMENT_RUNOUT_THRESHOLD 5 + #define FILAMENT_RUNOUT_THRESHOLD 10 #endif void event_filament_runout(); From 4f3ff119295480d388c37da5ccd54add78669f3b Mon Sep 17 00:00:00 2001 From: Alexander Efimov Date: Sat, 6 Jun 2020 23:59:14 +0300 Subject: [PATCH 4/4] 24v settings for SpreadCycle --- Marlin/Configuration_adv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 0605cf1616..9ada7dc375 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2255,7 +2255,7 @@ * Define you own with * { , , hysteresis_start[1..8] } */ - #define CHOPPER_TIMING CHOPPER_DEFAULT_12V + #define CHOPPER_TIMING CHOPPER_DEFAULT_24V /** * Monitor Trinamic drivers for error conditions,