bigtreetech / BIGTREETECH-SKR-mini-E3

BIGTREETECH SKR-mini-E3 motherboard is a ultra-quiet, low-power, high-quality 3D printing machine control board. It is launched by the 3D printing team of Shenzhen BIGTREE technology co., LTD. This board is specially tailored for Ender 3 printer, perfectly replacing the original Ender3 printer motherboard.
2.01k stars 1.97k forks source link

Firmware gets corrupted when storing something to the (virtual) EEPROM like the Z-offset #39

Open fluppie opened 5 years ago

fluppie commented 5 years ago

Old information, scroll down to the part where the EEPROM causes issues.

> Executing task in folder Marlin-2.0.x-SKR-Mini-E3-V1.2: C:\Users\Philippe\.platformio\penv\Scripts\platformio.exe run --environment STM32F103RC_bigtree_USB <

Processing STM32F103RC_bigtree_USB (platform: ststm32; framework: arduino; board: genericSTM32F103RC)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/genericSTM32F103RC.html
PLATFORM: ST STM32 5.6.0 > STM32F103RC (48k RAM. 256k Flash)
HARDWARE: STM32F103RCT6 72MHz, 48KB RAM, 256KB Flash
DEBUG: Current (stlink) External (blackmagic, jlink, stlink)
PACKAGES: toolchain-gccarmnoneeabi 1.70201.0 (7.2.1), framework-arduinoststm32-maple 1.10000.190819 (1.0.0), tool-stm32duino 1.0.1
Converting Marlin.ino
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
LibraryManager: Installing U8glib-HAL
Using cache: C:\Users\Philippe\.platformio\.cache\a7\b7a9b473d1c239d9843ca943887cd0a7
Unpacking...
FileNotFoundError: [Errno 2] No such file or directory: 'c:\\Users\\Philippe\\OneDrive\\3D Printing\\BigTreeTech\\BIGTREETECH-SKR-mini-E3-master\\firmware\\V1.2\\Marlin-2.0.x-SKR-Mini-E3-V1.2\\.pio\\libdeps\\STM32F103RC_bigtree_USB\\_tmp_installing-gi1a573m-package\\U8glib-HAL-bugfix\\src\\clib\\HAL_example_files\\LCD_I2C_routines.c.example':
  File "C:\Users\Philippe\.platformio\penv\lib\site-packages\platformio\builder\main.py", line 126:
    env.SConscript("$BUILD_SCRIPT")
  File "C:\Users\Philippe\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 605:
    return _SConscript(self.fs, *files, **subst_kw)
  File "C:\Users\Philippe\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 286:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "C:\Users\Philippe\.platformio\platforms\ststm32\builder\main.py", line 91:
    target_elf = env.BuildProgram()
  File "C:\Users\Philippe\.platformio\packages\tool-scons\script\..\engine\SCons\Environment.py", line 224:
    return self.method(*nargs, **kwargs)
  File "C:\Users\Philippe\.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py", line 122:
    _build_project_deps(env)
  File "C:\Users\Philippe\.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py", line 47:
    project_lib_builder = env.ConfigureProjectLibBuilder()
  File "C:\Users\Philippe\.platformio\packages\tool-scons\script\..\engine\SCons\Environment.py", line 224:
    return self.method(*nargs, **kwargs)
  File "C:\Users\Philippe\.platformio\penv\lib\site-packages\platformio\builder\tools\piolib.py", line 1043:
    project.install_dependencies()
  File "C:\Users\Philippe\.platformio\penv\lib\site-packages\platformio\builder\tools\piolib.py", line 878:
    lm.install(uri)
  File "C:\Users\Philippe\.platformio\penv\lib\site-packages\platformio\managers\lib.py", line 359:
    force=force)
  File "C:\Users\Philippe\.platformio\penv\lib\site-packages\platformio\managers\package.py", line 701:
    track=True)
  File "C:\Users\Philippe\.platformio\penv\lib\site-packages\platformio\managers\package.py", line 483:
    self.unpack(dlpath, tmp_dir)
  File "C:\Users\Philippe\.platformio\penv\lib\site-packages\platformio\managers\package.py", line 218:
    return fu.unpack(dest_dir, with_progress=False)
  File "C:\Users\Philippe\.platformio\penv\lib\site-packages\platformio\unpacker.py", line 118:
    self._unpacker.extract_item(item, dest_dir)
  File "C:\Users\Philippe\.platformio\penv\lib\site-packages\platformio\unpacker.py", line 38:
    self._afo.extract(item, dest_dir)
  File "C:\Users\Philippe\AppData\Local\Programs\Python\Python37\lib\zipfile.py", line 1599:
    return self._extract_member(member, path, pwd)
  File "C:\Users\Philippe\AppData\Local\Programs\Python\Python37\lib\zipfile.py", line 1670:
    open(targetpath, "wb") as target:
=============================================================================================== [FAILED] Took 1.30 seconds ===============================================================================================

Anyone an idea why?
fluppie commented 5 years ago

OK, this one compiles and works with a BL Touchv3.1 connected to the Z-endstop header.

https://github.com/fluppie/WORKING_Marlin-2.0.x-SKR-Mini-E3-V1.2-BLTouchv3.1

kubik256 commented 5 years ago

At first try to compile FW outside OneDrive, it can cause many strange problems. Also your full path is about 270 chars long, try to make it smaller - Something like C:\Marlin.pio\ - should be good ;) At last if this won't work, try to clone new Marlin at https://github.com/MarlinFirmware/Marlin/tree/bugfix-2.0.x ....modify configs, compile and you're done ;)

fluppie commented 5 years ago

Yes you were right. Inside OneDrive gives big issues. I switched to Documents\Github... and problems were resolved. I also run VS Code as admin to make sure I have enough rights during compile. Only having a EEPROM issue at the moment with this fork: https://github.com/fluppie/BIGTREETECH-SKR-mini-E3 When saving the Z-offset to EEPROM the firmware corrupts and doesn't boot anymore after powering down the printer. So you need to reflash the MCU.

kubik256 commented 5 years ago

EEPROM doesn't work because there is no physical eeprom in the STM chip. There have to be two ways:

1) EEPROM on SDCARD

define VIRTUAL_SD_EEPROM 8

On SD card put empty file called "eeprom.dat" and it should work.

2) Flash-based EEPROM emulation

define EEPROM_SETTINGS

define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation

More info here: https://github.com/MarlinFirmware/Marlin/issues/14684 ...and in many other threads on Marlin with STM chips :)

I don't have tested yet any EEPROM setting, I will test both ways tomorrow. Good luck ;)

kubik256 commented 5 years ago

Sorry, forget the 1st one, it was experimantal way and needs more tweaking than just setting in Configuration.h, FLASH_EEPROM_EMULATION should work.

I can't find the proper way to init EEPROM on SD card, but there could be some.

fluppie commented 5 years ago

Hmmm it's already enabled by default. Maybe the EEPROM offset is wrong or the bootloader is (semi)corrupted?

https://github.com/bigtreetech/BIGTREETECH-SKR-mini-E3/compare/master...fluppie:master?spm=a2g0s.imconversation.0.0.40a53e5f0wDVfM&file=master...fluppie:master

fluppie commented 5 years ago

Looks like this could be the solution:

If your using my STM32F103RE_bigtree_USB build;

you should change the file pins_BIGTREE_SKR_E3_DIP.h

change line 38 that reads

define EEPROM_START_ADDRESS uint32(0x8000000 + 256 1024 - 2 EEPROM_PAGE_SIZE)

to: //#define EEPROM_START_ADDRESS uint32(0x8000000 + 256 1024 - 2 EEPROM_PAGE_SIZE) //use for F103RC

define EEPROM_START_ADDRESS uint32(0x8000000 + 256 2048 - 2 EEPROM_PAGE_SIZE) //use for F103RE

Then eeprom emulation in flash will work, and it will sit at 0x0807D000 rather than 0x0803EA00. You only have to do this if our build is larger than 256KB-28KB-4KB = 224KB If using _USB you probably need it.

Found in: https://github.com/MarlinFirmware/Marlin/issues/15254

fluppie commented 5 years ago

The above changes seem to work for me. After enabling BL Touch the build size is 226 KB which is bigger than the 224 KB stated. Worth noting that my CPU is a 256KB one, a RCT6.

Gummibaer commented 5 years ago

You can try activate #define SLIM_LCD_MENUS

Gummibaer commented 4 years ago

BLTOUCH only useful with AUTO_BED_LEVELING = EEPROM MAX 224Kb = 229376 bytes

--- platformio.ini ---

( -fno-tree-scev-cprop -fno-split-wide-types -finline-limit=3 -ffast-math )

--- Configuration.h ---

--- Configuration_adv.h ---

Notes TMC_DEBUG is no longer needed in Marlin 2.0.x, but enabling it produces an extended report

ADD

define VIRTUAL_SD_EEPROM 8

DATA: [== ] 21.9% (used 10752 bytes from 49152 bytes) PROGRAM: [======== ] 80.2% (used 210276 bytes from 262144 bytes)

Fit on Flash :D Good Luck

JuhlTurner commented 4 years ago

Looks like this could be the solution:

If your using my STM32F103RE_bigtree_USB build; you should change the file pins_BIGTREE_SKR_E3_DIP.h change line 38 that reads

define EEPROM_START_ADDRESS uint32(0x8000000 + 256 1024 - 2 EEPROM_PAGE_SIZE)

to: //#define EEPROM_START_ADDRESS uint32(0x8000000 + 256 1024 - 2 EEPROM_PAGE_SIZE) //use for F103RC

define EEPROM_START_ADDRESS uint32(0x8000000 + 256 2048 - 2 EEPROM_PAGE_SIZE) //use for F103RE

Then eeprom emulation in flash will work, and it will sit at 0x0807D000 rather than 0x0803EA00. You only have to do this if our build is larger than 256KB-28KB-4KB = 224KB If using _USB you probably need it.

Found in: MarlinFirmware/Marlin#15254

Changing EEPROM_START_ADDRESS worked for me.

Grayzone233 commented 4 years ago

OK, this one compiles and works with a BL Touchv3.1 connected to the Z-endstop header.

https://github.com/fluppie/WORKING_Marlin-2.0.x-SKR-Mini-E3-V1.2-BLTouchv3.1

Get error 404 on your link.

bojanpotocnik commented 4 years ago

@Grayzone233 looks like he changed the repository, based on the commits BLTouch v3.1 is activated in this repository: https://github.com/fluppie/BIGTREETECH-SKR-mini-E3/commits/master

Grayzone233 commented 4 years ago

@bojanpotocnik was looking for the compiled bin file, but I can get there from what he documented in the repository. Thanks! The only bins were the original which is good to save as a backup in case the compiled does not work.

bojanpotocnik commented 4 years ago

Good to hear that. Additionally, my fork of the Marlin also contains binary files for BLTouch configuration.

in case the compiled does not work.

If you happen to run into problems with booting the board using firmware.bin compiled on your machine, check MarlinFirmware/Marlin issue 15767 where we discussed the solutions.

fluppie commented 4 years ago

@bojanpotocnik was looking for the compiled bin file, but I can get there from what he documented in the repository. Thanks! The only bins were the original which is good to save as a backup in case the compiled does not work.

There is a bin file: https://github.com/fluppie/BIGTREETECH-SKR-mini-E3/tree/master/firmware/V1.2 Only check/change your E-steps after flashing the FW.

davidcgu commented 4 years ago

After changing the start write point on the Eeprom emulation (Changing EEPROM_START_ADDRESS) it not crashes anymore after using Eeprom function however seems not to be working, I mean if a value is changed and after Eeprom save, after reboot the value is gone, is it working for you guys?

Thanks in advance

fartplume001 commented 4 years ago

I've had this problem, but my corruption happned mid print. It would just stop printing. I power cycled the board and no boot. After I reloaded the firmware I clicked restore failsafe defaults. We'll see if that works.

fartplume001 commented 4 years ago

Did it again. Trying running the print through mattercontrol.

fartplume001 commented 4 years ago

Works fine through mattercontrol. I suspect running the file through the sd card is over writing the firmware space.

dburr commented 4 years ago

I haven't been able to get flash EEPROM emulation to work at all. Have tried all of the fixes (changing start address, etc.) The best that I can get is that it no longer crashes, but I am unable to save any values to the (emulated) EEPROM. I gave up and switched to SD_EEPROM_EMULATION. Means I have to keep an SD card in the printer 24/7, but I normally do that anyway, and I normally don't print from SD so I never remove/change the SD card anyway. It means the SD gets more writes so it wears out faster, but that doesn't matter to me since I regularly make note of the EEPROM settings that I need to change, and I have tons of SD cards so can always switch to another.