From 6d26ca29b13153a2ea6e00ed91f002b46907750e Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Fri, 25 Dec 2020 19:46:38 -0300 Subject: [PATCH 01/11] add usb flash drive support for native usb host OTG --- Marlin/Configuration_adv.h | 20 ++- Marlin/src/HAL/STM32/usb_host.cpp | 114 ++++++++++++++++++ Marlin/src/HAL/STM32/usb_host.h | 60 +++++++++ Marlin/src/inc/SanityCheck.h | 6 +- .../src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h | 2 + .../sd/usb_flashdrive/Sd2Card_FlashDrive.cpp | 19 ++- .../sd/usb_flashdrive/Sd2Card_FlashDrive.h | 41 ++++--- platformio.ini | 34 +++++- 8 files changed, 267 insertions(+), 29 deletions(-) create mode 100644 Marlin/src/HAL/STM32/usb_host.cpp create mode 100644 Marlin/src/HAL/STM32/usb_host.h diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 1abb48fcb405..c76bd1afcb5e 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1323,9 +1323,6 @@ */ //#define USB_FLASH_DRIVE_SUPPORT #if ENABLED(USB_FLASH_DRIVE_SUPPORT) - #define USB_CS_PIN SDSS - #define USB_INTR_PIN SD_DETECT_PIN - /** * USB Host Shield Library * @@ -1337,6 +1334,16 @@ * [1] This requires USB_INTR_PIN to be interrupt-capable. */ //#define USE_UHS3_USB + + /** + * Native USB Host supported by some boards (USB OTG) + */ + //#define USE_OTG_USB_HOST + + #if DISABLED(USE_OTG_USB_HOST) + #define USB_CS_PIN SDSS + #define USB_INTR_PIN SD_DETECT_PIN + #endif #endif /** @@ -1369,6 +1376,13 @@ */ //#define SDCARD_CONNECTION LCD + #define MULTI_MEDIA_SUPPORT + #if ENABLED(MULTI_MEDIA_SUPPORT) + #define MULTI_MEDIA_SD_ONBOARD + // #define MULTI_MEDIA_SD_LCD + #define MULTI_MEDIA_USB_FLASH_DRIVE + #endif + #endif // SDSUPPORT /** diff --git a/Marlin/src/HAL/STM32/usb_host.cpp b/Marlin/src/HAL/STM32/usb_host.cpp new file mode 100644 index 000000000000..1d69bd34a760 --- /dev/null +++ b/Marlin/src/HAL/STM32/usb_host.cpp @@ -0,0 +1,114 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ + +#include "../../inc/MarlinConfig.h" + +#ifdef USBHOST + +#include "usb_host.h" +#include "../shared/Marduino.h" +#include "usbh_core.h" +#include "usbh_msc.h" + +USBH_HandleTypeDef hUsbHost; +USBHost usb; +BulkStorage bulk(&usb); + +static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id) { + switch(id) { + case HOST_USER_SELECT_CONFIGURATION: + //SERIAL_ECHOLN("APPLICATION_SELECT_CONFIGURATION"); + break; + case HOST_USER_DISCONNECTION: + // SERIAL_ECHOLN("APPLICATION_DISCONNECT"); + // usb.setUsbTaskState(USB_STATE_RUNNING); + break; + case HOST_USER_CLASS_ACTIVE: + // SERIAL_ECHOLN("APPLICATION_READY"); + usb.setUsbTaskState(USB_STATE_RUNNING); + break; + case HOST_USER_CONNECTION: + break; + default: + break; + } +} + +bool USBHost::start() { + if (USBH_Init(&hUsbHost, USBH_UserProcess, TERN(USE_USB_HS_IN_FS, HOST_HS, HOST_FS)) != USBH_OK) { + SERIAL_ECHOLN("Error: USBH_Init"); + return false; + } + if (USBH_RegisterClass(&hUsbHost, USBH_MSC_CLASS) != USBH_OK) { + SERIAL_ECHOLN("Error: USBH_RegisterClass"); + return false; + } + if (USBH_Start(&hUsbHost) != USBH_OK) { + SERIAL_ECHOLN("Error: USBH_Start"); + return false; + } + return true; +} + +void USBHost::Task() { + USBH_Process(&hUsbHost); +} + +uint8_t USBHost::getUsbTaskState() { + return usb_task_state; +} + +void USBHost::setUsbTaskState(uint8_t state) { + usb_task_state = state; + if (usb_task_state == USB_STATE_RUNNING) { + MSC_LUNTypeDef info; + USBH_MSC_GetLUNInfo(&hUsbHost, usb.lun, &info); + capacity = info.capacity.block_nbr / 2000; + block_size = info.capacity.block_size; + block_count = info.capacity.block_nbr; + // SERIAL_ECHOLNPAIR("info.capacity.block_nbr : %ld\n", info.capacity.block_nbr); + // SERIAL_ECHOLNPAIR("info.capacity.block_size: %d\n", info.capacity.block_size); + // SERIAL_ECHOLNPAIR("capacity : %d MB\n", capacity); + } +}; + +bool BulkStorage::LUNIsGood(uint8_t t) { + return USBH_MSC_IsReady(&hUsbHost) && USBH_MSC_UnitIsReady(&hUsbHost, t); +} + +uint32_t BulkStorage::GetCapacity(uint8_t lun) { + return usb->block_count; +} + +uint16_t BulkStorage::GetSectorSize(uint8_t lun) { + return usb->block_size; +} + +uint8_t BulkStorage::Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf) { + return USBH_MSC_Read(&hUsbHost, lun, addr, buf, blocks) != USBH_OK; +} + +uint8_t BulkStorage::Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t * buf) { + return USBH_MSC_Write(&hUsbHost, lun, addr, const_cast (buf), blocks) != USBH_OK; +} + +#endif // USBHOST diff --git a/Marlin/src/HAL/STM32/usb_host.h b/Marlin/src/HAL/STM32/usb_host.h new file mode 100644 index 000000000000..c0001c0d755b --- /dev/null +++ b/Marlin/src/HAL/STM32/usb_host.h @@ -0,0 +1,60 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +#include + +typedef enum { + USB_STATE_INIT, + USB_STATE_ERROR, + USB_STATE_RUNNING, +} usb_state_t; + +class USBHost { +public: + bool start(); + void Task(); + uint8_t getUsbTaskState(); + void setUsbTaskState(uint8_t state); + uint8_t regRd(uint8_t reg) { return 0x0; }; + uint8_t usb_task_state = USB_STATE_INIT; + uint8_t lun = 0; + uint32_t capacity = 0; + uint16_t block_size = 0; + uint32_t block_count = 0; +}; + +class BulkStorage { +public: + BulkStorage(USBHost *usb) : usb(usb) {}; + + bool LUNIsGood(uint8_t t); + uint32_t GetCapacity(uint8_t lun); + uint16_t GetSectorSize(uint8_t lun); + uint8_t Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf); + uint8_t Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t * buf); + + USBHost *usb; +}; + +extern USBHost usb; +extern BulkStorage bulk; diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 0aadeef0eebc..64fde187fe86 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2913,10 +2913,14 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #error "PRINTCOUNTER requires EEPROM_SETTINGS." #endif -#if ENABLED(USB_FLASH_DRIVE_SUPPORT) && !PINS_EXIST(USB_CS, USB_INTR) +#if ENABLED(USB_FLASH_DRIVE_SUPPORT) && !PINS_EXIST(USB_CS, USB_INTR) && DISABLED(USE_OTG_USB_HOST) #error "USB_CS_PIN and USB_INTR_PIN are required for USB_FLASH_DRIVE_SUPPORT." #endif +#if ENABLED(USE_OTG_USB_HOST) && !defined(HAS_OTG_USB_HOST_SUPPORT) + #error "The current board does not support USE_OTG_USB_HOST." +#endif + #if ENABLED(SD_FIRMWARE_UPDATE) && !defined(__AVR_ATmega2560__) #error "SD_FIRMWARE_UPDATE requires an ATmega2560-based (Arduino Mega) board." #endif diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h index 05648cf1207e..48a286c8e13b 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h @@ -362,3 +362,5 @@ #endif // !MKS_MINI_12864 #endif // HAS_SPI_LCD + +#define HAS_OTG_USB_HOST_SUPPORT diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp index 539d31654265..f0e9b195ea05 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp @@ -44,8 +44,10 @@ #include "../../core/serial.h" #include "../../module/temperature.h" -static_assert(USB_CS_PIN != -1, "USB_CS_PIN must be defined"); -static_assert(USB_INTR_PIN != -1, "USB_INTR_PIN must be defined"); +#if DISABLED(USE_OTG_USB_HOST) + static_assert(USB_CS_PIN != -1, "USB_CS_PIN must be defined"); + static_assert(USB_INTR_PIN != -1, "USB_INTR_PIN must be defined"); +#endif #if ENABLED(USE_UHS3_USB) #define NO_AUTO_SPEED @@ -81,6 +83,17 @@ static_assert(USB_INTR_PIN != -1, "USB_INTR_PIN must be defined"); #define UHS_START (usb.Init() == 0) #define UHS_STATE(state) UHS_USB_HOST_STATE_##state +#elif ENABLED(USE_OTG_USB_HOST) + + #if HAS_SD_HOST_DRIVE + #include HAL_PATH(../../HAL, msc_sd.h) + #endif + + #include HAL_PATH(../../HAL, usb_host.h) + + #define UHS_START usb.start() + #define rREVISION 0 + #define UHS_STATE(state) USB_STATE_##state #else #include "lib-uhs2/Usb.h" #include "lib-uhs2/masstorage.h" @@ -250,7 +263,7 @@ bool Sd2Card::isInserted() { return state == MEDIA_READY; } -bool Sd2Card::ready() { +bool Sd2Card::isReady() { return state > DO_STARTUP; } diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h index 8ca95ba7061c..83245168abca 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h @@ -23,26 +23,27 @@ /** * \file - * \brief Sd2Card class for V2 SD/SDHC cards + * \brief Sd2Card class for USB Flash Drive */ - #include "../SdFatConfig.h" #include "../SdInfo.h" -/** - * Define SOFTWARE_SPI to use bit-bang SPI - */ -#if EITHER(MEGA_SOFT_SPI, USE_SOFTWARE_SPI) - #define SOFTWARE_SPI -#endif +#if DISABLED(USE_OTG_USB_HOST) + /** + * Define SOFTWARE_SPI to use bit-bang SPI + */ + #if EITHER(MEGA_SOFT_SPI, USE_SOFTWARE_SPI) + #define SOFTWARE_SPI + #endif -// SPI pin definitions - do not edit here - change in SdFatConfig.h -#if ENABLED(SOFTWARE_SPI) - #warning "Auto-assigning '10' as the SD_CHIP_SELECT_PIN." - #define SD_CHIP_SELECT_PIN 10 // Software SPI chip select pin for the SD -#else - // hardware pin defs - #define SD_CHIP_SELECT_PIN SS_PIN // The default chip select pin for the SD card is SS. + // SPI pin definitions - do not edit here - change in SdFatConfig.h + #if ENABLED(SOFTWARE_SPI) + #warning "Auto-assigning '10' as the SD_CHIP_SELECT_PIN." + #define SD_CHIP_SELECT_PIN 10 // Software SPI chip select pin for the SD + #else + // hardware pin defs + #define SD_CHIP_SELECT_PIN SS_PIN // The default chip select pin for the SD card is SS. + #endif #endif class Sd2Card { @@ -54,22 +55,24 @@ class Sd2Card { public: static bool usbStartup(); - bool init(const uint8_t sckRateID=0, const pin_t chipSelectPin=SD_CHIP_SELECT_PIN); + bool init(const uint8_t sckRateID=0, const pin_t chipSelectPin=TERN(USE_OTG_USB_HOST, 0, SD_CHIP_SELECT_PIN)); static void idle(); - inline bool readStart(const uint32_t block) { pos = block; return ready(); } + inline bool readStart(const uint32_t block) { pos = block; return isReady(); } inline bool readData(uint8_t* dst) { return readBlock(pos++, dst); } inline bool readStop() const { return true; } - inline bool writeStart(const uint32_t block, const uint32_t) { pos = block; return ready(); } + inline bool writeStart(const uint32_t block, const uint32_t) { pos = block; return isReady(); } inline bool writeData(uint8_t* src) { return writeBlock(pos++, src); } inline bool writeStop() const { return true; } bool readBlock(uint32_t block, uint8_t* dst); bool writeBlock(uint32_t blockNumber, const uint8_t* src); + bool readCSD(csd_t* csd) { return true; }; + uint32_t cardSize(); static bool isInserted(); - static bool ready(); + bool isReady(); }; diff --git a/platformio.ini b/platformio.ini index a95647cf4298..2aa2301dd71a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -59,7 +59,7 @@ default_src_filter = + - - + - - - - - - + - - - - - @@ -1391,14 +1391,22 @@ extra_scripts = ${common.extra_scripts} # [env:mks_robin_pro2] platform = ${common_stm32.platform} +platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc.zip extends = common_stm32 -build_flags = ${common_stm32.build_flags} -DHAL_HCD_MODULE_ENABLED -DUSBHOST +build_flags = ${common_stm32.build_flags} + -DHAL_PCD_MODULE_ENABLED + -DUSBHOST + -DHAL_HCD_MODULE_ENABLED + -DUSBH_IRQ_PRIO=3 + -DUSBH_IRQ_SUBPRIO=4 board = genericSTM32F407VET6 board_build.core = stm32 board_build.variant = MARLIN_F4x7Vx board_build.ldscript = ldscript.ld board_build.firmware = firmware.bin -build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC +board_build.offset = 0x0000 +board_upload.offset_address = 0x08000000 +build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC debug_tool = jlink upload_protocol = jlink extra_scripts = ${common.extra_scripts} @@ -1426,6 +1434,26 @@ extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py buildroot/share/PlatformIO/scripts/stm32_bootloader.py +# +# MKS Robin Nano V3 with USB Flash Drive Support +# Currently, using a STM32duino fork, until USB Host get merged +# +[env:mks_robin_nano_v3_usb_flash_drive] +extends = env:mks_robin_nano_v3 +platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc.zip +build_flags = ${common_stm32.build_flags} + -DHAL_PCD_MODULE_ENABLED + -DUSBCON + -DUSBHOST + -DHAL_HCD_MODULE_ENABLED + -DUSE_USBHOST_HS + -DUSBH_IRQ_PRIO=3 + -DUSBH_IRQ_SUBPRIO=4 + -DUSBD_IRQ_PRIO=5 + -DUSBD_IRQ_SUBPRIO=6 + -DUSE_USB_HS_IN_FS + -DUSBD_USE_CDC + ################################# # # # Other Architectures # From 5b62ab697d934ca8a36c0d8f9c3bbd330a84b579 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Fri, 25 Dec 2020 19:50:21 -0300 Subject: [PATCH 02/11] add support for GTR and SKR PRO --- Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h | 2 ++ .../pins/stm32f4/pins_BTT_SKR_PRO_common.h | 2 ++ .../variants/BIGTREE_GTR_V1/hal_conf_extra.h | 2 +- .../BIGTREE_SKR_PRO_1v1/hal_conf_extra.h | 2 +- platformio.ini | 27 +++++++++++++++++++ 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h index bfa4007658db..a641ebbb6424 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -453,3 +453,5 @@ #endif // HAS_WIRED_LCD #undef TP + +#define HAS_OTG_USB_HOST_SUPPORT diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h index 235ed1edcc4c..2fb7d1a9ac54 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -469,3 +469,5 @@ #define ESP_WIFI_MODULE_ENABLE_PIN PG1 #define ESP_WIFI_MODULE_GPIO0_PIN PF14 #define ESP_WIFI_MODULE_GPIO2_PIN PF15 + +#define HAS_OTG_USB_HOST_SUPPORT diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h index e0e8239aac08..a1f5fe7a80d0 100644 --- a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h @@ -44,7 +44,7 @@ #undef HAL_IRDA_MODULE_ENABLED #undef HAL_SMARTCARD_MODULE_ENABLED #undef HAL_WWDG_MODULE_ENABLED -#undef HAL_HCD_MODULE_ENABLED +// #undef HAL_HCD_MODULE_ENABLED #undef HAL_FMPI2C_MODULE_ENABLED #undef HAL_SPDIFRX_MODULE_ENABLED #undef HAL_DFSDM_MODULE_ENABLED diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h index e0e8239aac08..a1f5fe7a80d0 100644 --- a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h @@ -44,7 +44,7 @@ #undef HAL_IRDA_MODULE_ENABLED #undef HAL_SMARTCARD_MODULE_ENABLED #undef HAL_WWDG_MODULE_ENABLED -#undef HAL_HCD_MODULE_ENABLED +// #undef HAL_HCD_MODULE_ENABLED #undef HAL_FMPI2C_MODULE_ENABLED #undef HAL_SPDIFRX_MODULE_ENABLED #undef HAL_DFSDM_MODULE_ENABLED diff --git a/platformio.ini b/platformio.ini index 2aa2301dd71a..f9f8ec805b2e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1277,6 +1277,20 @@ extra_scripts = ${common.extra_scripts} debug_tool = stlink debug_init_break = +# +# BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4) with USB Flash Drive Support +# +[env:BIGTREE_SKR_PRO_usb_flash_drive] +extends = env:BIGTREE_SKR_PRO +platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc.zip +build_flags = ${common_stm32.build_flags} + -DHAL_PCD_MODULE_ENABLED + -DUSBHOST + -DHAL_HCD_MODULE_ENABLED + -DUSBH_IRQ_PRIO=3 + -DUSBH_IRQ_SUBPRIO=4 + + # # Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4) # @@ -1289,6 +1303,19 @@ extra_scripts = ${common.extra_scripts} build_flags = ${common_stm32.build_flags} -DSTM32F407IX -DVECT_TAB_OFFSET=0x8000 +# +# Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4) with USB Flash Drive Support +# +[env:BIGTREE_GTR_V1_0_usb_flash_drive] +extends = env:BIGTREE_GTR_V1_0 +platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc.zip +build_flags = ${common_stm32.build_flags} + -DHAL_PCD_MODULE_ENABLED + -DUSBHOST + -DHAL_HCD_MODULE_ENABLED + -DUSBH_IRQ_PRIO=3 + -DUSBH_IRQ_SUBPRIO=4 + # # BigTreeTech BTT002 V1.0 (STM32F407VGT6 ARM Cortex-M4) # From 709f15c2a8288ccf6288758500bc7e34e22385ec Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Fri, 25 Dec 2020 19:58:19 -0300 Subject: [PATCH 03/11] not yet --- Marlin/Configuration_adv.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index c76bd1afcb5e..f11dfe22bd69 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1376,13 +1376,6 @@ */ //#define SDCARD_CONNECTION LCD - #define MULTI_MEDIA_SUPPORT - #if ENABLED(MULTI_MEDIA_SUPPORT) - #define MULTI_MEDIA_SD_ONBOARD - // #define MULTI_MEDIA_SD_LCD - #define MULTI_MEDIA_USB_FLASH_DRIVE - #endif - #endif // SDSUPPORT /** From 72ba75799da7e087123989cd9dd1de009a184f3c Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Fri, 25 Dec 2020 20:18:18 -0300 Subject: [PATCH 04/11] fix compiling issues --- Marlin/src/HAL/STM32/usb_host.cpp | 7 +++++-- platformio.ini | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Marlin/src/HAL/STM32/usb_host.cpp b/Marlin/src/HAL/STM32/usb_host.cpp index 1d69bd34a760..3683fcfa966d 100644 --- a/Marlin/src/HAL/STM32/usb_host.cpp +++ b/Marlin/src/HAL/STM32/usb_host.cpp @@ -20,9 +20,11 @@ * */ +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) + #include "../../inc/MarlinConfig.h" -#ifdef USBHOST +#if BOTH(USE_OTG_USB_HOST, USBHOST) #include "usb_host.h" #include "../shared/Marduino.h" @@ -111,4 +113,5 @@ uint8_t BulkStorage::Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t b return USBH_MSC_Write(&hUsbHost, lun, addr, const_cast (buf), blocks) != USBH_OK; } -#endif // USBHOST +#endif // BOTH(USE_OTG_USB_HOST, USBHOST) +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC diff --git a/platformio.ini b/platformio.ini index f9f8ec805b2e..ac153b95fcb1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -272,7 +272,7 @@ HAS_DGUS_LCD = src_filter=+ + EXTUI_EXAMPLE = src_filter=+ MALYAN_LCD = src_filter=+ -USB_FLASH_DRIVE_SUPPORT = src_filter=+ +USB_FLASH_DRIVE_SUPPORT = src_filter=+ + AUTO_BED_LEVELING_BILINEAR = src_filter=+ AUTO_BED_LEVELING_(3POINT|(BI)?LINEAR) = src_filter=+ MESH_BED_LEVELING = src_filter=+ + From 4ac8cdd2213a77b729a6a51c33af6988d6076e3d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 27 Dec 2020 22:24:25 -0600 Subject: [PATCH 05/11] Tweaks & fixups --- Marlin/src/HAL/STM32/usb_host.cpp | 16 +++--- .../sd/usb_flashdrive/Sd2Card_FlashDrive.cpp | 5 +- .../variants/BIGTREE_GTR_V1/hal_conf_extra.h | 2 +- .../BIGTREE_SKR_PRO_1v1/hal_conf_extra.h | 2 +- platformio.ini | 51 +++++++------------ 5 files changed, 30 insertions(+), 46 deletions(-) diff --git a/Marlin/src/HAL/STM32/usb_host.cpp b/Marlin/src/HAL/STM32/usb_host.cpp index 3683fcfa966d..ed743361e681 100644 --- a/Marlin/src/HAL/STM32/usb_host.cpp +++ b/Marlin/src/HAL/STM32/usb_host.cpp @@ -38,14 +38,14 @@ BulkStorage bulk(&usb); static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id) { switch(id) { case HOST_USER_SELECT_CONFIGURATION: - //SERIAL_ECHOLN("APPLICATION_SELECT_CONFIGURATION"); + //SERIAL_ECHOLNPGM("APPLICATION_SELECT_CONFIGURATION"); break; case HOST_USER_DISCONNECTION: - // SERIAL_ECHOLN("APPLICATION_DISCONNECT"); - // usb.setUsbTaskState(USB_STATE_RUNNING); + //SERIAL_ECHOLNPGM("APPLICATION_DISCONNECT"); + //usb.setUsbTaskState(USB_STATE_RUNNING); break; case HOST_USER_CLASS_ACTIVE: - // SERIAL_ECHOLN("APPLICATION_READY"); + //SERIAL_ECHOLNPGM("APPLICATION_READY"); usb.setUsbTaskState(USB_STATE_RUNNING); break; case HOST_USER_CONNECTION: @@ -57,15 +57,15 @@ static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id) { bool USBHost::start() { if (USBH_Init(&hUsbHost, USBH_UserProcess, TERN(USE_USB_HS_IN_FS, HOST_HS, HOST_FS)) != USBH_OK) { - SERIAL_ECHOLN("Error: USBH_Init"); + SERIAL_ECHOLNPGM("Error: USBH_Init"); return false; } if (USBH_RegisterClass(&hUsbHost, USBH_MSC_CLASS) != USBH_OK) { - SERIAL_ECHOLN("Error: USBH_RegisterClass"); + SERIAL_ECHOLNPGM("Error: USBH_RegisterClass"); return false; } if (USBH_Start(&hUsbHost) != USBH_OK) { - SERIAL_ECHOLN("Error: USBH_Start"); + SERIAL_ECHOLNPGM("Error: USBH_Start"); return false; } return true; @@ -113,5 +113,5 @@ uint8_t BulkStorage::Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t b return USBH_MSC_Write(&hUsbHost, lun, addr, const_cast (buf), blocks) != USBH_OK; } -#endif // BOTH(USE_OTG_USB_HOST, USBHOST) +#endif // USE_OTG_USB_HOST && USBHOST #endif // ARDUINO_ARCH_STM32 && !STM32GENERIC diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp index f0e9b195ea05..28a18cd9d86b 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp @@ -44,9 +44,8 @@ #include "../../core/serial.h" #include "../../module/temperature.h" -#if DISABLED(USE_OTG_USB_HOST) - static_assert(USB_CS_PIN != -1, "USB_CS_PIN must be defined"); - static_assert(USB_INTR_PIN != -1, "USB_INTR_PIN must be defined"); +#if DISABLED(USE_OTG_USB_HOST) && !PINS_EXIST(USB_CS, USB_INTR) + #error "USB_FLASH_DRIVE_SUPPORT requires USB_CS_PIN and USB_INTR_PIN to be defined." #endif #if ENABLED(USE_UHS3_USB) diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h index a1f5fe7a80d0..f7f9e23e99e7 100644 --- a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h @@ -44,7 +44,7 @@ #undef HAL_IRDA_MODULE_ENABLED #undef HAL_SMARTCARD_MODULE_ENABLED #undef HAL_WWDG_MODULE_ENABLED -// #undef HAL_HCD_MODULE_ENABLED +//#undef HAL_HCD_MODULE_ENABLED #undef HAL_FMPI2C_MODULE_ENABLED #undef HAL_SPDIFRX_MODULE_ENABLED #undef HAL_DFSDM_MODULE_ENABLED diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h index a1f5fe7a80d0..f7f9e23e99e7 100644 --- a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h @@ -44,7 +44,7 @@ #undef HAL_IRDA_MODULE_ENABLED #undef HAL_SMARTCARD_MODULE_ENABLED #undef HAL_WWDG_MODULE_ENABLED -// #undef HAL_HCD_MODULE_ENABLED +//#undef HAL_HCD_MODULE_ENABLED #undef HAL_FMPI2C_MODULE_ENABLED #undef HAL_SPDIFRX_MODULE_ENABLED #undef HAL_DFSDM_MODULE_ENABLED diff --git a/platformio.ini b/platformio.ini index ac153b95fcb1..56f13621cbb4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1277,19 +1277,19 @@ extra_scripts = ${common.extra_scripts} debug_tool = stlink debug_init_break = +[stm32_flash_drive] +platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc.zip +build_flags = ${common_stm32.build_flags} + -DHAL_PCD_MODULE_ENABLED -DHAL_HCD_MODULE_ENABLED + -DUSBHOST -DUSBH_IRQ_PRIO=3 -DUSBH_IRQ_SUBPRIO=4 + # # BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4) with USB Flash Drive Support # [env:BIGTREE_SKR_PRO_usb_flash_drive] -extends = env:BIGTREE_SKR_PRO -platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc.zip -build_flags = ${common_stm32.build_flags} - -DHAL_PCD_MODULE_ENABLED - -DUSBHOST - -DHAL_HCD_MODULE_ENABLED - -DUSBH_IRQ_PRIO=3 - -DUSBH_IRQ_SUBPRIO=4 - +extends = env:BIGTREE_SKR_PRO +platform_packages = ${stm32_flash_drive.platform_packages} +build_flags = ${stm32_flash_drive.build_flags} # # Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4) @@ -1307,14 +1307,9 @@ build_flags = ${common_stm32.build_flags} # Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4) with USB Flash Drive Support # [env:BIGTREE_GTR_V1_0_usb_flash_drive] -extends = env:BIGTREE_GTR_V1_0 -platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc.zip -build_flags = ${common_stm32.build_flags} - -DHAL_PCD_MODULE_ENABLED - -DUSBHOST - -DHAL_HCD_MODULE_ENABLED - -DUSBH_IRQ_PRIO=3 - -DUSBH_IRQ_SUBPRIO=4 +extends = env:BIGTREE_GTR_V1_0 +platform_packages = ${stm32_flash_drive.platform_packages} +build_flags = ${stm32_flash_drive.build_flags} # # BigTreeTech BTT002 V1.0 (STM32F407VGT6 ARM Cortex-M4) @@ -1418,14 +1413,9 @@ extra_scripts = ${common.extra_scripts} # [env:mks_robin_pro2] platform = ${common_stm32.platform} -platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc.zip +platform_packages = ${stm32_flash_drive.platform_packages} extends = common_stm32 -build_flags = ${common_stm32.build_flags} - -DHAL_PCD_MODULE_ENABLED - -DUSBHOST - -DHAL_HCD_MODULE_ENABLED - -DUSBH_IRQ_PRIO=3 - -DUSBH_IRQ_SUBPRIO=4 +build_flags = ${stm32_flash_drive.build_flags} board = genericSTM32F407VET6 board_build.core = stm32 board_build.variant = MARLIN_F4x7Vx @@ -1433,7 +1423,7 @@ board_build.ldscript = ldscript.ld board_build.firmware = firmware.bin board_build.offset = 0x0000 board_upload.offset_address = 0x08000000 -build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC +build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC debug_tool = jlink upload_protocol = jlink extra_scripts = ${common.extra_scripts} @@ -1466,16 +1456,11 @@ extra_scripts = ${common.extra_scripts} # Currently, using a STM32duino fork, until USB Host get merged # [env:mks_robin_nano_v3_usb_flash_drive] -extends = env:mks_robin_nano_v3 -platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc.zip -build_flags = ${common_stm32.build_flags} - -DHAL_PCD_MODULE_ENABLED +extends = env:mks_robin_nano_v3 +platform_packages = ${stm32_flash_drive.platform_packages} +build_flags = ${stm32_flash_drive.build_flags} -DUSBCON - -DUSBHOST - -DHAL_HCD_MODULE_ENABLED -DUSE_USBHOST_HS - -DUSBH_IRQ_PRIO=3 - -DUSBH_IRQ_SUBPRIO=4 -DUSBD_IRQ_PRIO=5 -DUSBD_IRQ_SUBPRIO=6 -DUSE_USB_HS_IN_FS From 0c856cd382b8ececf2bc6d9dcf3306247a0dc464 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Mon, 28 Dec 2020 23:12:30 -0300 Subject: [PATCH 06/11] separe UHS2 and UHS3 to avoid conflit on build --- Marlin/Configuration_adv.h | 1 + Marlin/src/inc/Conditionals_adv.h | 4 ++++ platformio.ini | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index f11dfe22bd69..86eb6d6d0696 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1333,6 +1333,7 @@ * is less tested and is known to interfere with Servos. * [1] This requires USB_INTR_PIN to be interrupt-capable. */ + //#define USE_UHS2_USB //#define USE_UHS3_USB /** diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index f99e363d7b64..0401da7221a6 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -382,6 +382,10 @@ #define POLL_JOG #endif +#if ENABLED(USB_FLASH_DRIVE_SUPPORT) && NONE(USE_OTG_USB_HOST, USE_UHS3_USB) + #define USE_UHS2_USB +#endif + /** * Driver Timings (in nanoseconds) * NOTE: Driver timing order is longest-to-shortest duration. diff --git a/platformio.ini b/platformio.ini index 56f13621cbb4..5c356fb89ece 100644 --- a/platformio.ini +++ b/platformio.ini @@ -272,7 +272,8 @@ HAS_DGUS_LCD = src_filter=+ + EXTUI_EXAMPLE = src_filter=+ MALYAN_LCD = src_filter=+ -USB_FLASH_DRIVE_SUPPORT = src_filter=+ + +USE_UHS2_USB = src_filter=+ +USE_UHS3_USB = src_filter=+ AUTO_BED_LEVELING_BILINEAR = src_filter=+ AUTO_BED_LEVELING_(3POINT|(BI)?LINEAR) = src_filter=+ MESH_BED_LEVELING = src_filter=+ + From fb12768447e8944773b2c74d143f66a9a15567d8 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Mon, 28 Dec 2020 23:54:15 -0300 Subject: [PATCH 07/11] eeprom size --- Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h | 7 ++++--- Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h index e2b3f2c317c6..d41a22e007df 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h @@ -32,12 +32,13 @@ #define BOARD_INFO_NAME "MKS Robin Nano V3" // Avoid conflict with TIMER_TONE -#define STEP_TIMER 10 +#define STEP_TIMER 10 // Use one of these or SDCard-based Emulation will be used //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation //#define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation #define I2C_EEPROM +#define MARLIN_EEPROM_SIZE 0x1000 // 4KB // // Release PB4 (Z_DIR_PIN) from JTAG NRST role @@ -190,10 +191,10 @@ //#define LED_PIN PB2 // Random Info -#define USB_SERIAL -1 //Usb Serial +#define USB_SERIAL -1 //Usb Serial #define WIFI_SERIAL 3 //USART3 #define MKS_WIFI_MODULE_SERIAL 1 //USART1 -#define MKS_WIFI_MODULE_SPI 2 //SPI2 +#define MKS_WIFI_MODULE_SPI 2 //SPI2 #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION ONBOARD diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h index 48a286c8e13b..879b0a4be1f9 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h @@ -30,12 +30,13 @@ #define BOARD_INFO_NAME "MKS Robin PRO V2" // Avoid conflict with TIMER_TONE -#define STEP_TIMER 10 +#define STEP_TIMER 10 // Use one of these or SDCard-based Emulation will be used //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation //#define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation #define I2C_EEPROM +#define MARLIN_EEPROM_SIZE 0x1000 // 4KB // // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role @@ -243,7 +244,7 @@ // // LCD / Controller #define SPI_FLASH -#define HAS_SPI_FLASH 1 +#define HAS_SPI_FLASH 1 #define SPI_DEVICE 2 #define SPI_FLASH_SIZE 0x1000000 #if ENABLED(SPI_FLASH) From 78ab1de10188aefb4cf4ae423b8c624209672062 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 28 Dec 2020 22:50:05 -0600 Subject: [PATCH 08/11] Misc cleanup --- Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h | 8 ++++---- buildroot/tests/STM32F103VE_longer-tests | 5 ++--- platformio.ini | 3 +++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h index d41a22e007df..3995bc030555 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h @@ -191,10 +191,10 @@ //#define LED_PIN PB2 // Random Info -#define USB_SERIAL -1 //Usb Serial -#define WIFI_SERIAL 3 //USART3 -#define MKS_WIFI_MODULE_SERIAL 1 //USART1 -#define MKS_WIFI_MODULE_SPI 2 //SPI2 +#define USB_SERIAL -1 // USB Serial +#define WIFI_SERIAL 3 // USART3 +#define MKS_WIFI_MODULE_SERIAL 1 // USART1 +#define MKS_WIFI_MODULE_SPI 2 // SPI2 #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION ONBOARD diff --git a/buildroot/tests/STM32F103VE_longer-tests b/buildroot/tests/STM32F103VE_longer-tests index c9ef58001523..1c90744c0110 100755 --- a/buildroot/tests/STM32F103VE_longer-tests +++ b/buildroot/tests/STM32F103VE_longer-tests @@ -11,9 +11,8 @@ opt_enable BAUD_RATE_GCODE exec_test $1 $2 "CLASSIC_UI U20 config" "$3" use_example_configs Alfawise/U20 -opt_enable BAUD_RATE_GCODE -opt_enable TFT_COLOR_UI -opt_disable TFT_CLASSIC_UI +opt_enable BAUD_RATE_GCODE TFT_COLOR_UI +opt_disable TFT_CLASSIC_UI CUSTOM_STATUS_SCREEN_IMAGE exec_test $1 $2 "COLOR_UI U20 config" "$3" use_example_configs Alfawise/U20-bltouch diff --git a/platformio.ini b/platformio.ini index 18853b96d002..3e87968eef39 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1279,6 +1279,9 @@ extra_scripts = ${common.extra_scripts} debug_tool = stlink debug_init_break = +# +# USB Flash Drive mix-ins for STM32 +# [stm32_flash_drive] platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc.zip build_flags = ${common_stm32.build_flags} From 87a689cd82e1f43980b64b75e878386a51889333 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 28 Dec 2020 22:59:52 -0600 Subject: [PATCH 09/11] Pins cleanup --- Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h | 2 +- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h | 10 ++++--- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h | 7 +++-- .../src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h | 10 ++++--- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h | 2 +- .../src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h | 27 ++++++++++++------- .../src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h | 18 ++++++------- Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h | 5 +--- 8 files changed, 46 insertions(+), 35 deletions(-) diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h index 68cfe65601d1..6d9d225efffc 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h @@ -189,7 +189,7 @@ // Reduce baud rate to improve software serial reliability #define TMC_BAUD_RATE 19200 -#endif // TMC2208 || TMC2209 +#endif // HAS_TMC_UART // // Temperature Sensors diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h index 93890e9aa777..3118a521bbeb 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h @@ -40,7 +40,6 @@ // // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role // - #define DISABLE_DEBUG // @@ -59,6 +58,11 @@ // #define SPI_DEVICE 2 +// +// Servos +// +#define SERVO0_PIN PA8 // Enable BLTOUCH + // // Limit Switches // @@ -155,7 +159,7 @@ // Reduce baud rate to improve software serial reliability #define TMC_BAUD_RATE 19200 -#endif // TMC2208 || TMC2209 +#endif // HAS_TMC_UART // // Temperature Sensors @@ -200,8 +204,6 @@ #define FIL_RUNOUT_PIN PA4 #endif -#define SERVO0_PIN PA8 // Enable BLTOUCH - //#define LED_PIN PB2 // diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h index c430671b2eff..ea3a7a1eea8e 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h @@ -56,6 +56,11 @@ #define SPI_DEVICE 2 +// +// Servos +// +#define SERVO0_PIN PA8 // Enable BLTOUCH + // // Limit Switches // @@ -148,8 +153,6 @@ #define FIL_RUNOUT2_PIN PE6 #endif -#define SERVO0_PIN PA8 // Enable BLTOUCH support - //#define LED_PIN PB2 // diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h index 063e548a329b..6ef3a0804384 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -43,7 +43,6 @@ // // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role // - #define DISABLE_DEBUG // @@ -62,6 +61,11 @@ // #define SPI_DEVICE 2 +// +// Servos +// +#define SERVO0_PIN PA8 // Enable BLTOUCH + // // Limit Switches // @@ -163,7 +167,7 @@ // Reduce baud rate to improve software serial reliability #define TMC_BAUD_RATE 19200 -#endif // TMC2208 || TMC2209 +#endif // HAS_TMC_UART // // Temperature Sensors @@ -218,8 +222,6 @@ #define FIL_RUNOUT2_PIN PE6 #endif -#define SERVO0_PIN PA8 // Enable BLTOUCH - //#define LED_PIN PB2 // diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h index 65aa5cc39e59..89bb41b1979b 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h @@ -48,7 +48,7 @@ // // Servos // -#define SERVO0_PIN PA8 // BLTOUCH +#define SERVO0_PIN PA8 // Enable BLTOUCH // // Limit Switches diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h index 3995bc030555..6fcf3f514cf2 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h @@ -31,6 +31,9 @@ #define BOARD_INFO_NAME "MKS Robin Nano V3" +// USB Flash Drive support +#define HAS_OTG_USB_HOST_SUPPORT + // Avoid conflict with TIMER_TONE #define STEP_TIMER 10 @@ -41,8 +44,14 @@ #define MARLIN_EEPROM_SIZE 0x1000 // 4KB // -// Release PB4 (Z_DIR_PIN) from JTAG NRST role +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +//#define DISABLE_DEBUG + +// +// Servos // +#define SERVO0_PIN PA8 // Enable BLTOUCH // // Limit Switches @@ -99,8 +108,8 @@ // // Software SPI pins for TMC2130 stepper drivers +// This board only supports SW SPI for stepper drivers // -// This board only support SW SPI for stepper drivers #if HAS_TMC_SPI #define TMC_USE_SW_SPI #endif @@ -180,6 +189,7 @@ #define POWER_LOSS_PIN PW_DET #define PS_ON_PIN PW_OFF + // // Enable MKSPWC support // @@ -187,14 +197,13 @@ //#define KILL_PIN PA2 //#define KILL_PIN_INVERTING true -#define SERVO0_PIN PA8 // Enable BLTOUCH support //#define LED_PIN PB2 // Random Info -#define USB_SERIAL -1 // USB Serial -#define WIFI_SERIAL 3 // USART3 -#define MKS_WIFI_MODULE_SERIAL 1 // USART1 -#define MKS_WIFI_MODULE_SPI 2 // SPI2 +#define USB_SERIAL -1 // USB Serial +#define WIFI_SERIAL 3 // USART3 +#define MKS_WIFI_MODULE_SERIAL 1 // USART1 +#define MKS_WIFI_MODULE_SPI 2 // SPI2 #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION ONBOARD @@ -332,7 +341,7 @@ //#define MKS_LCD12864B //#undef SHOW_BOOTSCREEN - #else // !MKS_MINI_12864 + #else // !MKS_MINI_12864 #define LCD_PINS_D4 PE14 #if ENABLED(ULTIPANEL) @@ -347,5 +356,3 @@ #endif // !MKS_MINI_12864 #endif // HAS_SPI_LCD - -#define HAS_OTG_USB_HOST_SUPPORT diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h index 879b0a4be1f9..877586eb6fbc 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h @@ -160,7 +160,7 @@ // Reduce baud rate to improve software serial reliability #define TMC_BAUD_RATE 19200 -#endif // TMC2208 || TMC2209 +#endif // HAS_TMC_UART // // Temperature Sensors @@ -187,19 +187,19 @@ // // Misc. Functions // -// #define POWER_LOSS_PIN PA2 // PW_DET -// #define PS_ON_PIN PA3 // PW_OFF -// #define SUICIDE_PIN PB2 // Enable MKSPWC support -// #define KILL_PIN PA2 // Enable MKSPWC support -// #define KILL_PIN_INVERTING true // Enable MKSPWC support -#define SERVO0_PIN PA8 // Enable BLTOUCH support +//#define POWER_LOSS_PIN PA2 // PW_DET +//#define PS_ON_PIN PA3 // PW_OFF +//#define SUICIDE_PIN PB2 // Enable MKSPWC support +//#define KILL_PIN PA2 // Enable MKSPWC support +//#define KILL_PIN_INVERTING true // Enable MKSPWC support +#define SERVO0_PIN PA8 // Enable BLTOUCH //#define LED_PIN PB2 #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION ONBOARD #endif -// #define USE_NEW_SPI_API 1 +//#define USE_NEW_SPI_API 1 // // Onboard SD card @@ -317,7 +317,7 @@ #define LCD_READ_ID 0xD3 #define LCD_USE_DMA_SPI - // #define TFT_DRIVER ST7796 + //#define TFT_DRIVER ST7796 #define TFT_BUFFER_SIZE 14400 #elif HAS_SPI_LCD diff --git a/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h b/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h index 90dcfc46e424..466cce565df1 100644 --- a/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h +++ b/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h @@ -36,7 +36,7 @@ // Decrease delays and flash wear by spreading writes across the // 128 kB sector allocated for EEPROM emulation. // Not yet supported on F7 hardware - // #define FLASH_EEPROM_LEVELING + //#define FLASH_EEPROM_LEVELING #endif /** @@ -188,9 +188,6 @@ #define LCD_PINS_RS PF12 // LCD_RS #define LCD_PINS_ENABLE PD15 // LCD_EN #define LCD_PINS_D4 PB13 // LCD_D4 - // #define LCD_PINS_D5 - // #define LCD_PINS_D6 - // #define LCD_PINS_D7 #define BTN_EN1 PF13 // BTN_EN1 #define BTN_EN2 PE9 // BTN_EN2 From 352359a337f35cb5257170e588c1b29309a76fd4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 28 Dec 2020 23:01:03 -0600 Subject: [PATCH 10/11] etc --- Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h index 6fcf3f514cf2..81edff6793cb 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h @@ -44,7 +44,7 @@ #define MARLIN_EEPROM_SIZE 0x1000 // 4KB // -// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// Release PB4 (Z_DIR_PIN) from JTAG NRST role // //#define DISABLE_DEBUG From 0ed0bb8f631650782689461aa076bc7991012744 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 28 Dec 2020 23:04:43 -0600 Subject: [PATCH 11/11] Move HAS_OTG_USB_HOST_SUPPORT --- Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h | 5 +++-- Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h | 5 +++-- Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h index a641ebbb6424..d594e3ca4967 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -35,6 +35,9 @@ #define I2C_EEPROM #define MARLIN_EEPROM_SIZE 0x2000 // 8KB (24C64 ... 64Kb = 8KB) +// USB Flash Drive support +#define HAS_OTG_USB_HOST_SUPPORT + #define TP // Enable to define servo and probe pins // @@ -453,5 +456,3 @@ #endif // HAS_WIRED_LCD #undef TP - -#define HAS_OTG_USB_HOST_SUPPORT diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h index 2fb7d1a9ac54..be05ebcfa9cd 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -44,6 +44,9 @@ #define FLASH_EEPROM_LEVELING #endif +// USB Flash Drive support +#define HAS_OTG_USB_HOST_SUPPORT + // // Servos // @@ -469,5 +472,3 @@ #define ESP_WIFI_MODULE_ENABLE_PIN PG1 #define ESP_WIFI_MODULE_GPIO0_PIN PF14 #define ESP_WIFI_MODULE_GPIO2_PIN PF15 - -#define HAS_OTG_USB_HOST_SUPPORT diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h index 877586eb6fbc..834cc680e527 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h @@ -38,9 +38,13 @@ #define I2C_EEPROM #define MARLIN_EEPROM_SIZE 0x1000 // 4KB +// USB Flash Drive support +#define HAS_OTG_USB_HOST_SUPPORT + // // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role // +//#define DISABLE_DEBUG // // Note: MKS Robin board is using SPI2 interface. @@ -363,5 +367,3 @@ #endif // !MKS_MINI_12864 #endif // HAS_SPI_LCD - -#define HAS_OTG_USB_HOST_SUPPORT