Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve MKS Robin support #19333

Merged
merged 46 commits into from
Jan 7, 2021
Merged
Changes from 2 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
25b627e
Update pins_MKS_ROBIN.h
Robin-DUBREUIL Sep 10, 2020
a79cbb9
Update pins_MKS_ROBIN.h
Robin-DUBREUIL Sep 10, 2020
4603812
Update pins_MKS_ROBIN.h
Robin-DUBREUIL Sep 10, 2020
f0edf90
Apply auto-format
thinkyhead Sep 10, 2020
ec4da8e
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/19333
thinkyhead Sep 10, 2020
06a6bc8
0xFF
thinkyhead Sep 11, 2020
3267e48
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/19333
thinkyhead Oct 8, 2020
1237a63
Use 0xFF (not 'ff') for byte transfer
thinkyhead Oct 8, 2020
531b402
Move TFT_320x240 pin entries
thinkyhead Oct 8, 2020
5864dd3
Catch undefined SPI_DEVICE
thinkyhead Oct 8, 2020
1e51e45
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/19333
thinkyhead Oct 8, 2020
590076b
Don't fall back to BL24CXX
thinkyhead Oct 8, 2020
52b7721
Allow touch calibration override
thinkyhead Oct 8, 2020
1f0be57
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/19333
thinkyhead Oct 8, 2020
8817ba4
Merge branch 'bugfix-2.0.x' into patch-1
thinkyhead Oct 13, 2020
3c2f121
Merge branch 'bugfix-2.0.x' into patch-1
thinkyhead Oct 16, 2020
ac0dfa7
Update pins_MKS_ROBIN.h
thinkyhead Oct 16, 2020
f845833
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/19333
thinkyhead Oct 23, 2020
7ed6851
Disable TFT_ILI9328 in the pins file
thinkyhead Oct 23, 2020
839298e
Fix a TFT define
thinkyhead Oct 23, 2020
447ce65
Update pins_MKS_ROBIN.h
Robin-DUBREUIL Nov 10, 2020
9c5c3ee
Update pins_MKS_ROBIN.h
Robin-DUBREUIL Nov 10, 2020
ae2eacd
Update pins_MKS_ROBIN.h
Robin-DUBREUIL Nov 10, 2020
d934d2d
Update pins_MKS_ROBIN.h
Robin-DUBREUIL Sep 10, 2020
24e88de
Update pins_MKS_ROBIN.h
Robin-DUBREUIL Sep 10, 2020
5624257
Update pins_MKS_ROBIN.h
Robin-DUBREUIL Sep 10, 2020
3d5802f
Apply auto-format
thinkyhead Sep 10, 2020
8bd5ade
Move TFT_320x240 pin entries
thinkyhead Oct 8, 2020
db77533
Catch undefined SPI_DEVICE
thinkyhead Oct 8, 2020
ddb7fc4
Don't fall back to BL24CXX
thinkyhead Oct 8, 2020
d7c816e
Update pins_MKS_ROBIN.h
thinkyhead Oct 16, 2020
6d5ab56
Disable TFT_ILI9328 in the pins file
thinkyhead Oct 23, 2020
717e6d4
Fix a TFT define
thinkyhead Oct 23, 2020
c76b17a
Update pins_MKS_ROBIN.h
Robin-DUBREUIL Nov 10, 2020
366807a
Update pins_MKS_ROBIN.h
Robin-DUBREUIL Nov 10, 2020
7cee7b7
Align better with upstream changes
sjasonsmith Dec 12, 2020
2eb769c
Rearrange and cleanup
sjasonsmith Dec 12, 2020
569332e
Merge remote-tracking branch 'TheCodeExorcist/patch-1' into PRR/19333…
sjasonsmith Dec 12, 2020
e842cd4
Fix failed tests
sjasonsmith Dec 12, 2020
683a6dc
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/19333
thinkyhead Dec 22, 2020
883ea5e
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into PRR/19333_p…
sjasonsmith Jan 1, 2021
0d227ac
Remove ONBOARD SD from Robin
sjasonsmith Jan 1, 2021
42c1496
outdated spi configs
rhapsodyv Jan 4, 2021
8628b41
outdated TFT changes
rhapsodyv Jan 4, 2021
dfdaa88
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/19333
thinkyhead Jan 7, 2021
067d5be
Revert W25Qxx.cpp changes
thinkyhead Jan 7, 2021
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
265 changes: 169 additions & 96 deletions Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
* MKS Robin (STM32F130ZET6) board pin assignments
*
* https://github.com/makerbase-mks/MKS-Robin/tree/master/MKS%20Robin/Hardware
*
* Note: MKS Robin board is using SPI2 interface. Make sure your stm32duino library is configured accordingly
*/

#if !defined(STM32F1) && !defined(STM32F1xx)
Expand All @@ -41,24 +43,22 @@
#define DISABLE_JTAG

//
// Enable SD EEPROM to prevent infinite boot loop
// EEPROM
//
#ifdef ARDUINO_ARCH_STM32
#define FLASH_EEPROM_EMULATION
#define EEPROM_PAGE_SIZE (0x800U) // 2KB
#define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL)
#define MARLIN_EEPROM_SIZE (EEPROM_PAGE_SIZE)
#else
#define SDCARD_EEPROM_EMULATION
#if NO_EEPROM_SELECTED
#define IIC_EEPROM_SDA PB7
#define IIC_EEPROM_SCL PB6
thinkyhead marked this conversation as resolved.
Show resolved Hide resolved
#define MARLIN_EEPROM_SIZE 0x800 // 2KB
#undef NO_EEPROM_SELECTED
#endif

//
// Servos
//
#define SERVO0_PIN PC3 // XS1 - 5
#define SERVO1_PIN PA1 // XS1 - 6
#define SERVO2_PIN PF9 // XS2 - 5
#define SERVO3_PIN PF8 // XS2 - 6
#define SERVO0_PIN PA1 // XS1 - 6 (BLTOUCH)
#define SERVO1_PIN PC3 // XS1 - 5
#define SERVO2_PIN PF8 // XS2 - 6
#define SERVO3_PIN PF9 // XS2 - 5
thinkyhead marked this conversation as resolved.
Show resolved Hide resolved

//
// Limit Switches
Expand Down Expand Up @@ -101,117 +101,190 @@
#define TEMP_BED_PIN PC0 // TB1

//
// Heaters / Fans
// Heaters
//
#define HEATER_0_PIN PC7 // HEATER1
#define HEATER_1_PIN PA6 // HEATER2
#define HEATER_BED_PIN PC6 // HOT BED

//
// Fan
//
#define FAN_PIN PA7 // FAN

/**
* Note: MKS Robin board is using SPI2 interface. Make sure your stm32duino library is configured accordingly
*/
//
// Thermocouples
//
//#define MAX6675_SS_PIN PE5 // TC1 - CS1
//#define MAX6675_SS_PIN PE6 // TC2 - CS2

//
// Filament runout sensor
//
#define FIL_RUNOUT_PIN PF11 // MT_DET

//
// Power loss detection
//
#define POWER_LOSS_PIN PA2 // PW_DET

//
// Power supply control
//
#define PS_ON_PIN PA3 // PW_OFF
#define FIL_RUNOUT_PIN PF11 // MT_DET

#ifdef ARDUINO_ARCH_STM32F1
#define BEEPER_PIN PC13
#else
#define BEEPER_PIN -1
#endif
//
// Piezzoelectric speaker
//
#define BEEPER_PIN PC13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why this was -1 when using the STM32 HAL?

This might introduce a timer conflict for mks_robin_stm32, but I'm not too worried about that. If that happens a little extra work will be needed to possibly move the TONE_TIMER, but that would be the right thing to do.

I verified that PC13 isn't attached to any timer pins. The Maple framework will take over any timer attached to BEEPER_PIN if SPEAKER is enabled, which can make enabling it risky for some boards. It seems ok for this board.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The beeper works fine when compiled with mks_robin on my board, i should try compiling with mks_robin_stm32 to see if everything is still fine but for now i have other issues to solve to make marlin compile on this framework with my config...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why this was -1 when using the STM32 HAL?

There was a bug that caused Marlin with HAL STM32 hangs when speaker enabled.
I have not tested this for a while, so I can't tell if this bug still present.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you tested before I upgraded to ststm32 8.0 that might be fixed. I think I remember TONE not working on one timers, but it worked with the newer framework.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only problem in BEEPER_PIN that I know is when SPEAKER is enabled. I'm using the BEEPER in a STM32F4, on HAL STM32 with no problem, in the current version.


//
// Activity LED
//
#define LED_PIN PB2

#ifdef HAS_GRAPHICAL_TFT
#define TFT_RESET_PIN PF6
#define TFT_BACKLIGHT_PIN PG11
#define TFT_CS_PIN PG12 // NE4
#define TFT_RS_PIN PF0 // A0
#else
/**
* Note: MKS Robin TFT screens use various TFT controllers
* Supported screens are based on the ILI9341, ST7789V and ILI9328 (320x240)
* ILI9488 is not supported
* Define init sequences for other screens in u8g_dev_tft_320x240_upscale_from_128x64.cpp
*
* If the screen stays white, disable 'LCD_RESET_PIN'
* to let the bootloader init the screen.
*
* Setting an 'LCD_RESET_PIN' may cause a flicker when entering the LCD menu
* because Marlin uses the reset as a failsafe to revive a glitchy LCD.
*/
//#define LCD_RESET_PIN PF6
#define LCD_BACKLIGHT_PIN PG11
#define FSMC_CS_PIN PG12 // NE4
#define FSMC_RS_PIN PF0 // A0
//
// ESP12-S Wi-Fi module
//
#define WIFI_IO0_PIN PG1

//
// SD Card
//
#ifndef SDCARD_CONNECTION
// Set ONBOARD connection even if you use MKS SLOT.
#define SDCARD_CONNECTION ONBOARD
#endif

#define SDIO_SUPPORT
#define SDIO_CLOCK 4500000 // 4.5 MHz
#define SD_DETECT_PIN -1
#define ONBOARD_SD_CS_PIN PC11

//
// LCD screen
//
#if HAS_FSMC_TFT
#define FSMC_CS_PIN PG12 // NE4
#define FSMC_RS_PIN PF0 // A0
#define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT
#define FSMC_DMA_DEV DMA2
#define FSMC_DMA_CHANNEL DMA_CH5
#endif
#define FSMC_DMA_CHANNEL DMA_CH5

#if NEED_TOUCH_PINS
#define TOUCH_CS_PIN PB1 // SPI2_NSS
#define TOUCH_CS_PIN PB1 // SPI2_NSS
#define TOUCH_SCK_PIN PB13 // SPI2_SCK
#define TOUCH_MISO_PIN PB14 // SPI2_MISO
#define TOUCH_MOSI_PIN PB15 // SPI2_MOSI
#define TOUCH_INT_PIN -1
#define TOUCH_BUTTONS_HW_SPI
#define TOUCH_BUTTONS_HW_SPI_DEVICE 2

// The screen may stay white or flicker on entering some menus by setting an LCD_RESET_PIN.
#define LCD_RESET_PIN PF6 // FSMC_RST
#define LCD_BACKLIGHT_PIN PG11
#endif

// SPI1(PA7) & SPI3(PB5) not available
#define ENABLE_SPI2
// Config for Classic UI (emulated DOGM) and Color UI
#if ENABLED(TFT_320x240)
#define TFT_RESET_PIN PF6 // FSMC_RST
#define TFT_BACKLIGHT_PIN PG11
#define TFT_CS_PIN PG12 // NE4
#define TFT_RS_PIN PF0 // A0

// MKS Robin TFT with ILI9328
#define TFT_ILI9328
#if ENABLED(TFT_ILI9328)
#define TFT_DRIVER ILI9328
#define TFT_BUFFER_SIZE 14400
#define ILI9328_COLOR_RGB

// YV for normal screen mounting
//#define ILI9328_ORIENTATION ILI9328_MADCTL_MY | ILI9328_MADCTL_MV
// XV for 180° rotated screen mounting
#define ILI9328_ORIENTATION ILI9328_MADCTL_MX | ILI9328_MADCTL_MV
#endif

// MKS Robin TFT with R61505
//#define TFT_R61505
#if ENABLED(TFT_R61505)
#define TFT_DRIVER R61505
#define TFT_BUFFER_SIZE 14400
#define R61505_COLOR_RGB

#if ENABLED(SDIO_SUPPORT)
#define SCK_PIN PB13 // SPI2
#define MISO_PIN PB14 // SPI2
#define MOSI_PIN PB15 // SPI2
#define SD_DETECT_PIN PF12 // SD_CD
#else
// SD as custom software SPI (SDIO pins)
#define SCK_PIN PC12
#define MISO_PIN PC8
#define MOSI_PIN PD2
#define SS_PIN -1
#define ONBOARD_SD_CS_PIN PC11
#define SDSS PD2
#define SD_DETECT_PIN -1
// YV for normal screen mounting
//#define R61505_ORIENTATION R61505_MADCTL_MY | R61505_MADCTL_MV
// XV for 180° rotated screen mounting
#define R61505_ORIENTATION R61505_MADCTL_MX | R61505_MADCTL_MV
#endif

// MKS Robin TFT with ST7789V
//#define ST7789V
#if ENABLED(ST7789V)
#define TFT_DRIVER ST7789V
#define TFT_BUFFER_SIZE 14400
#define ST7789V_COLOR_RGB

// YV for normal screen mounting
//#define ST7789V_ORIENTATION ST7789V_MADCTL_MY | ST7789V_MADCTL_MV
// XV for 180° rotated screen mounting
#define ST7789V_ORIENTATION ST7789V_MADCTL_MX | ST7789V_MADCTL_MV
#endif
#endif

//
// SPI
//
#define ENABLE_SPI2
#define SCK_PIN PB13
#define MISO_PIN PB14
#define MOSI_PIN PB15
// SPI2 is already shared by LCD touch driver and flash
// SPI2 MOSI (PB15) can be retrieved by soldering job on R17
// SPI1(PA7) & SPI3(PB5) are not available


//
// Trinamic TMC2208/2209 UART
//
#if HAS_TMC_UART
/**
* TMC2208/TMC2209 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

// Unused servo pins may be repurposed with SoftwareSerialM
//#define X_SERIAL_TX_PIN PF8 // SERVO3_PIN -- XS2 - 6
//#define Y_SERIAL_TX_PIN PF9 // SERVO2_PIN -- XS2 - 5
//#define Z_SERIAL_TX_PIN PA1 // SERVO1_PIN -- XS1 - 6
//#define E0_SERIAL_TX_PIN PC3 // SERVO0_PIN -- XS1 - 5
//#define X_SERIAL_RX_PIN X_SERIAL_TX_PIN
//#define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN
//#define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN
//#define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN

// Reduce baud rate for software serial reliability
#if HAS_TMC_SW_SERIAL
#define TMC_BAUD_RATE 19200
// Hardware serial on Serial 1
#define TMC_HARDWARE_SERIAL
#if ENABLED(TMC_HARDWARE_SERIAL)
#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

// Software serial on unused servo pins
#define TMC_SOFTWARE_SERIAL
thinkyhead marked this conversation as resolved.
Show resolved Hide resolved
#if ENABLED(TMC_SOFTWARE_SERIAL)
sjasonsmith marked this conversation as resolved.
Show resolved Hide resolved
#define X_SERIAL_TX_PIN PF8 // SERVO3_PIN -- XS2 - 6
#define Y_SERIAL_TX_PIN PF9 // SERVO2_PIN -- XS2 - 5
#define Z_SERIAL_TX_PIN PA1 // SERVO1_PIN -- XS1 - 6
#define E0_SERIAL_TX_PIN PC3 // SERVO0_PIN -- XS1 - 5
#define X_SERIAL_RX_PIN X_SERIAL_TX_PIN
#define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN
#define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN
#define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN
#define TMC_BAUD_RATE 19200
#endif
#endif

//
// W25Q64 64Mb (8MB) SPI flash
//
#define HAS_SPI_FLASH 1
#if HAS_SPI_FLASH
#define SPI_FLASH_SIZE 0x800000 // 8MB
#define W25QXX_CS_PIN PG9
#define W25QXX_MOSI_PIN PB15
#define W25QXX_MISO_PIN PB14
#define W25QXX_SCK_PIN PB13
#endif