diff --git a/Marlin/src/HAL/STM32F1/eeprom_spi_w25q.cpp b/Marlin/src/HAL/STM32F1/eeprom_spi_w25q.cpp index aab4593bfe..6e9bf622ca 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_spi_w25q.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom_spi_w25q.cpp @@ -12,10 +12,12 @@ U5 W25Q64BV, 16K SERIAL EEPROM: //W25QXXFlash W25QXX; uint8_t spi_eeprom[MARLIN_EEPROM_SIZE]; +void eeprom_test(void); void eeprom_init(void){ DEBUG("Start EEPROM"); W25QXX.init(SPI_QUARTER_SPEED); + //eeprom_test(); W25QXX.SPI_FLASH_BufferRead((uint8_t *)spi_eeprom,SPI_EEPROM_OFFSET,MARLIN_EEPROM_SIZE); } @@ -56,4 +58,46 @@ void eeprom_update_block(const void *__src, void *__dst, size_t __n){ ERROR("Call to missing function"); }; +void eeprom_test(void){ + uint16_t chip_id=0; + + chip_id=W25QXX.W25QXX_ReadID(); + DEBUG("SPI Flash ID %0X",chip_id); + + DEBUG("Read FLASH:"); + for(uint32_t i=0; i < 50 ; ){ + memset(spi_eeprom,0,10); + W25QXX.SPI_FLASH_BufferRead((uint8_t *)spi_eeprom,SPI_EEPROM_OFFSET+i,10); + DEBUG("%d %0X %0X %0X %0X %0X %0X %0X %0X %0X %0X",i,spi_eeprom[0],spi_eeprom[1],spi_eeprom[2],spi_eeprom[3],spi_eeprom[4],spi_eeprom[5],spi_eeprom[6],spi_eeprom[7],spi_eeprom[8],spi_eeprom[9]); + i=i+10; + } + + DEBUG("Erase flash"); + W25QXX.SPI_FLASH_WriteEnable(); + W25QXX.SPI_FLASH_SectorErase(SPI_EEPROM_OFFSET); + + DEBUG("Read FLASH:"); + for(uint32_t i=0; i < 50 ; ){ + memset(spi_eeprom,0,10); + W25QXX.SPI_FLASH_BufferRead((uint8_t *)spi_eeprom,SPI_EEPROM_OFFSET+i,10); + DEBUG("%d %0X %0X %0X %0X %0X %0X %0X %0X %0X %0X",i,spi_eeprom[0],spi_eeprom[1],spi_eeprom[2],spi_eeprom[3],spi_eeprom[4],spi_eeprom[5],spi_eeprom[6],spi_eeprom[7],spi_eeprom[8],spi_eeprom[9]); + i=i+10; + } + + DEBUG("Read/write FLASH:"); + for(uint32_t i=0; i < 50 ; ){ + + memset(spi_eeprom,0x0B,10); + + W25QXX.SPI_FLASH_WriteEnable(); + W25QXX.SPI_FLASH_BufferWrite((uint8_t *)spi_eeprom,SPI_EEPROM_OFFSET+i,10); + + W25QXX.SPI_FLASH_BufferRead((uint8_t *)spi_eeprom,SPI_EEPROM_OFFSET+i,10); + DEBUG("%d %0X %0X %0X %0X %0X %0X %0X %0X %0X %0X",i,spi_eeprom[0],spi_eeprom[1],spi_eeprom[2],spi_eeprom[3],spi_eeprom[4],spi_eeprom[5],spi_eeprom[6],spi_eeprom[7],spi_eeprom[8],spi_eeprom[9]); + i=i+10; + } + +} + + #endif // SPI_EEPROM_W25Q diff --git a/Marlin/src/HAL/STM32F1/eeprom_wired.cpp b/Marlin/src/HAL/STM32F1/eeprom_wired.cpp index b4699d00dc..f4bb2f6b7c 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_wired.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom_wired.cpp @@ -36,7 +36,12 @@ #endif size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } -bool PersistentStore::access_finish() { return true; } +bool PersistentStore::access_finish() { + #if ENABLED(EEPROM_W25Q) + eeprom_hw_deinit(); + #endif + return true; + } bool PersistentStore::access_start() { eeprom_init(); diff --git a/Marlin/src/HAL/shared/eeprom_if.h b/Marlin/src/HAL/shared/eeprom_if.h index e44da801df..44bc0c719c 100644 --- a/Marlin/src/HAL/shared/eeprom_if.h +++ b/Marlin/src/HAL/shared/eeprom_if.h @@ -27,3 +27,7 @@ void eeprom_init(); void eeprom_write_byte(uint8_t *pos, unsigned char value); uint8_t eeprom_read_byte(uint8_t *pos); + +#if ENABLED(EEPROM_W25Q) +void eeprom_hw_deinit(void); +#endif \ No newline at end of file diff --git a/Marlin/src/libs/Segger/log.h b/Marlin/src/libs/Segger/log.h index 3fc5dc468d..28978e22b9 100644 --- a/Marlin/src/libs/Segger/log.h +++ b/Marlin/src/libs/Segger/log.h @@ -1,43 +1,37 @@ #ifndef LOG_H #define LOG_H -#include "SEGGER_RTT.h" -#include "../../module/mks_wifi/debug_to_uart.h" - -//#define DEBUG_MSG -//#define INFO_MSG -//#define WARNING_MSG -//#define ERROR_MSG - -//#define COLOR_LOG_RTT //#define DEBUG_TO_UART -#define DEBUG_TO_SEGGER_RTT +//#define DEBUG_TO_SEGGER_RTT -#ifdef COLOR_LOG_RTT +#ifdef DEBUG_TO_UART + #include + #include "../../module/mks_wifi/debug_to_uart.h" + #define DEBUG_MSG + #define INFO_MSG + #define WARNING_MSG + #define ERROR_MSG +#endif - #ifdef DEBUG_MSG - #define DEBUG(fmt, args...) SEGGER_RTT_printf(0,"%sDEBUG %-20s:%-4d [%d]:" fmt "%s\r\n",RTT_CTRL_TEXT_BLUE, __func__, __LINE__,dwt_get_tick_in_sec(), ## args, RTT_CTRL_RESET) - #else +#ifdef DEBUG_TO_SEGGER_RTT + #include "SEGGER_RTT.h" + #define DEBUG_MSG + #define INFO_MSG + #define WARNING_MSG + #define ERROR_MSG +#endif + +#ifndef DEBUG_TO_SEGGER_RTT + #ifndef DEBUG_TO_UART + #include #define DEBUG(fmt, args...) - #endif - #ifdef INFO_MSG - #define INFO(fmt, args...) SEGGER_RTT_printf(0,"%s[I] %-20s:%-4d [%d]:" fmt "%s\r\n",RTT_CTRL_TEXT_WHITE, __func__, __LINE__,dwt_get_tick_in_sec(), ## args,RTT_CTRL_RESET) - #else #define INFO(fmt, args...) - #endif - #ifdef WARNING_MSG - #define WARNING(fmt, args...) SEGGER_RTT_printf(0,"%s[W] %-20s:%-4d [%d]:" fmt "%s\r\n",RTT_CTRL_TEXT_BRIGHT_YELLOW, __func__, __LINE__,dwt_get_tick_in_sec(), ## args,RTT_CTRL_RESET) - #else #define WARNING(fmt, args...) - #endif - #ifdef ERROR_MSG - #define ERROR(fmt, args...) SEGGER_RTT_printf(0,"%s[E] %-20s:%-4d [%d]:" fmt "%s\r\n",RTT_CTRL_TEXT_RED, __func__, __LINE__,dwt_get_tick_in_sec(),## args,RTT_CTRL_RESET) - #else #define ERROR(fmt, args...) #endif -#else - #ifdef DEBUG_TO_UART +#endif +#ifdef DEBUG_TO_UART #ifdef DEBUG_MSG #define DEBUG(fmt, args...) debug_to_uart((char*)"[D] %-20s:%-4d :" fmt "\n", __func__, __LINE__, ## args) #else @@ -59,9 +53,9 @@ #define ERROR(fmt, args...) #endif - #endif +#endif - #ifdef DEBUG_TO_SEGGER_RTT +#ifdef DEBUG_TO_SEGGER_RTT #ifdef DEBUG_MSG #define DEBUG(fmt, args...) SEGGER_RTT_printf(0,"[D] %-20s:%-4d :" fmt "\r\n", __func__, __LINE__, ## args) @@ -88,4 +82,3 @@ #endif -#endif diff --git a/Marlin/src/module/mks_wifi/debug_to_uart.cpp b/Marlin/src/module/mks_wifi/debug_to_uart.cpp index 79be0b201a..d42e53465d 100644 --- a/Marlin/src/module/mks_wifi/debug_to_uart.cpp +++ b/Marlin/src/module/mks_wifi/debug_to_uart.cpp @@ -25,7 +25,5 @@ void debug_to_uart(char *fmt,...){ } - } - #endif diff --git a/Marlin/src/module/mks_wifi/debug_to_uart.h b/Marlin/src/module/mks_wifi/debug_to_uart.h index eacf46d3b5..7621525c4b 100644 --- a/Marlin/src/module/mks_wifi/debug_to_uart.h +++ b/Marlin/src/module/mks_wifi/debug_to_uart.h @@ -1,11 +1,11 @@ #ifndef DEBUG_UART_H #define DEBUG_UART_H -#ifdef DEBUG_TO_UART - #include "../../MarlinCore.h" #include "../../inc/MarlinConfig.h" +#ifdef DEBUG_TO_UART + void debug_to_uart(char *fmt,...); #endif diff --git a/firmware/all_drv_2208/Robin_nano35.bin b/firmware/all_drv_2208/Robin_nano35.bin index 681084fa54..993379fd61 100644 Binary files a/firmware/all_drv_2208/Robin_nano35.bin and b/firmware/all_drv_2208/Robin_nano35.bin differ diff --git a/firmware/fb_4s/Robin_nano35.bin b/firmware/fb_4s/Robin_nano35.bin index 9076241ec8..1cfa975dd1 100644 Binary files a/firmware/fb_4s/Robin_nano35.bin and b/firmware/fb_4s/Robin_nano35.bin differ diff --git a/firmware/fb_5/Robin_nano35.bin b/firmware/fb_5/Robin_nano35.bin index 7f1c8e00ac..3521fd5a79 100644 Binary files a/firmware/fb_5/Robin_nano35.bin and b/firmware/fb_5/Robin_nano35.bin differ