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

[FR] Need fixes for BTT SKR Mini E3 having a different MCU #15254

Closed
sl1pkn07 opened this issue Sep 13, 2019 · 67 comments
Closed

[FR] Need fixes for BTT SKR Mini E3 having a different MCU #15254

sl1pkn07 opened this issue Sep 13, 2019 · 67 comments
Labels
T: Feature Request Features requested by users.

Comments

@sl1pkn07
Copy link
Contributor

sl1pkn07 commented Sep 13, 2019

Hi

I just discover my SKR mini E3 DIP 1.0 have a different model of MCU than the configured in the platformio.ini file

in the platformio.ini

Marlin/platformio.ini

Lines 295 to 300 in f9961dd

# BigTree SKR Mini V1.1 / SKR mini E3 / SKR E3 DIP (STM32F103RCT6 ARM Cortex-M3)
#
[env:STM32F103R_bigtree]
platform = ststm32
framework = arduino
board = genericSTM32F103RC

my physical SKR Mini E3 DIP:

IMG_20190914_010459

STM32F103 RET6 is a 512KB unit

https://www.mouser.es/ProductDetail/STMicroelectronics/STM32F103RET6?qs=tZXS5FmuAdnGL83bu1Xcew==

https://docs.platformio.org/en/latest/boards/ststm32/genericSTM32F103RE.html

but in the platformio is configured as STM32F103 RCT6, which is a 256KB unit

https://www.mouser.es/ProductDetail/STMicroelectronics/STM32F103RCT6?qs=sGAEpiMZZMuoKKEcg8mMKGCsvkp7Jpfjiil20HX4niM%3D

https://docs.platformio.org/en/latest/boards/ststm32/genericSTM32F103RC.html

I'm not sure if the SKR mini 1.1 and the E3 have the same problem

any througths?

greetings

@tpruvot
Copy link
Contributor

tpruvot commented Sep 13, 2019

unsure about the E3, but the mini is RCT6 https://drive.google.com/file/d/13ReQ8lGl8vKstoi3IBOo9YVQePUI_WBr/view?usp=sharing

@tpruvot
Copy link
Contributor

tpruvot commented Sep 13, 2019

else, should not be a problem unless you reach the firmware size, with some costly features like the USB composite. To fix that, remember to change the .ld script too buildroot/share/PlatformIO/ldscripts/STM32F1_SKR_MINI.ld

@sl1pkn07
Copy link
Contributor Author

with some touches

Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [==        ]  22.6% (used 11096 bytes from 49152 bytes)
PROGRAM: [========= ]  88.0% (used 230812 bytes from 262144 bytes)

(from boy in a telegram channel)

@sl1pkn07
Copy link
Contributor Author

cc @bigtreetech

@tpruvot
Copy link
Contributor

tpruvot commented Sep 13, 2019

it look like they have both models on the E3 DIP... cf their shop picture
image

@tpruvot
Copy link
Contributor

tpruvot commented Sep 13, 2019

well, consider you are lucky :p got a free bonus... but unfortunately, platformio cant be changed for all.. for now

@sl1pkn07
Copy link
Contributor Author

from telegram

photo_2019-09-14_01-37-43

yep. seems I have a BTT special edition :O

@mvoss96
Copy link

mvoss96 commented Sep 14, 2019

the entry for mini e3 is also wrong. the physical baord is also ret6.
I cant use eeprom and sd support at the same time for this reason even so the board should have 512k.

how can i change this?

@sl1pkn07
Copy link
Contributor Author

sl1pkn07 commented Sep 14, 2019

not tested. but:

change this

board = genericSTM32F103RC

to this

board = genericSTM32F103RE

and the LD script like said @tpruvot

@sl1pkn07
Copy link
Contributor Author

else, should not be a problem unless you reach the firmware size, with some costly features like the USB composite. To fix that, remember to change the .ld script too buildroot/share/PlatformIO/ldscripts/STM32F1_SKR_MINI.ld

any example of this?

greetings

@mvoss96
Copy link

mvoss96 commented Sep 14, 2019

i tried to change it to genericSTM32F103RE and the256k to 512k in STM32F1_SKR_MINI.ld.
It does compile, but the board doesnt flash the firmware

@tpruvot
Copy link
Contributor

tpruvot commented Sep 14, 2019

i see, maybe they didnt update their bootloader code... which do the SD update. So it could be more complicated, requires a stflash and.. basically you have to comment the .py script in the platformio.ini but... well a full backup of the chip may be required first... to rollback.

To note, the stflash should use the 3.3V wire, not 5V (SWD connector)

@sjasonsmith
Copy link
Contributor

I have both a Mini and a DIP that I received about a week ago. Both have the same RET6 controller.
Maybe they chose to upgrade their design, but it might also just be a drop-in-replacement based and they will buy whichever is cheaper or more available on any given day.

@tpruvot
Copy link
Contributor

tpruvot commented Sep 14, 2019

yep i dont know, i dont even see a comment on their multiple shops, they all show RCT6 for now.

@sl1pkn07
Copy link
Contributor Author

My unit has been purchased in BTT Ali official store in 26 Aug

@sjasonsmith
Copy link
Contributor

My unit has been purchased in BTT Ali official store in 26 Aug

Mine were ordered from "BIG TREE TECH Store" on Aug 20.
I believe that is the official store, but it can be hard to tell on AliExpress.

@tpruvot
Copy link
Contributor

tpruvot commented Sep 15, 2019

you dont need to build it separately... Its included in normal Marlin build/firmware by default (without .py script)

@anm8tor
Copy link

anm8tor commented Sep 22, 2019

@tpruvot the USB composite you refer to, is that using the USB environment in VSCODE to build the firmware, so that you can communicate properly between the SKR Mini boards and say, a RPi (4 in my case) properly?

@tpruvot
Copy link
Contributor

tpruvot commented Sep 22, 2019

niuuuu.... USB composite i refer to is usb pins without dedicated usb to serial chip (ftdi/ch340cg/... whatever, its not a real problem)

But since a week, its one, i receive at least twice or twelve spams per day regarding a card i dont even own... the E3... dip or not.... which exist since a month or 2 ??

@thinkyhead
Copy link
Member

thinkyhead commented Sep 24, 2019

Is it worth adding a special entry to platformio.ini (and extra LD script) for the boards that have a RET6?

@tpruvot
Copy link
Contributor

tpruvot commented Sep 25, 2019

it might be, but its not so simple as they didnt update their bootloader to allow to flash a bigger firmware via the SD... means you need a stflash if doing that and stop using the custom .py... i do that on my longer3D here to avoid manual copies to a SD.. to the remote printer.

What could be interesting is a generic F103RE entry (64 pins/512kb), without .py, and without .ld so

@SSPW
Copy link

SSPW commented Sep 26, 2019

it might be, but its not so simple as they didnt update their bootloader to allow to flash a bigger firmware via the SD...

Bootloader seems to work fine when build using RE (512K), with either STM32F103R_bigtree or STM32F103R_bigtree_USB with genericSTM32F103RE.

I also made a new new environment;
STM32F103RE_bigtree_USB based on STM32F103R_bigtree_USB
with
board = genericSTM32F103RE
extra_scripts = buildroot/share/PlatformIO/scripts/STM32F1RE_SKR_MINI.py

copy STM32F1_SKR_MINI.py to STM32F1RE_SKR_MINI.py
change last line to
env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/STM32F1RE_SKR_MINI.ld")

STM32F1RE_SKR_MINI.id to STM32F1_SKR_MINI.id
change rom line to
rom (rx) : ORIGIN = 0x08007000, LENGTH = 512K - 28K

Builds fine
Flashes fine either manually putting bin on SD or dragging it to USB drive.

However, i when i get the firmware and reboot, the firmware.bin file is left on SD. It reflashes every reboot. The FIRMWARE.CUR is missing sometimes. Sometimes its there. But firmware.bin is never deleted.

I don't think this is related. It happens in any ENV i have managed to build.

@tpruvot
Copy link
Contributor

tpruvot commented Sep 26, 2019

mvoss96 commented 12 days ago

i tried to change it to genericSTM32F103RE and the256k to 512k in STM32F1_SKR_MINI.ld.It does compile, but the board doesnt flash the firmware

the .ld/.py is not required at all, its just made to match the "original" customized bootloaders/firmwares to allow SD updates.

Marlin pio builds can do the whole thing without these custom entries

@sjasonsmith
Copy link
Contributor

However, i when i get the firmware and reboot, the firmware.bin file is left on SD. It reflashes every reboot. The FIRMWARE.CUR is missing sometimes. Sometimes its there. But firmware.bin is never deleted.

I have noticed some similar behavior on both E3 Mini and E3 DIP boards this morning, where the firmware.bin and FIRMWARE.CUR files are updated inconsistently. I don't know whether the firmware update actually occured properly in those cases, although it looked like it at least tried to update.

I'm building with the default bf2 environments, nothing modified for RE.

@tpruvot
Copy link
Contributor

tpruvot commented Sep 26, 2019

FIRMWARE.CUR is not used by marlin ... at all

@SSPW
Copy link

SSPW commented Sep 26, 2019

However, i when i get the firmware and reboot, the firmware.bin file is left on SD. It reflashes every reboot. The FIRMWARE.CUR is missing sometimes. Sometimes its there. But firmware.bin is never deleted.

I have noticed some similar behavior on both E3 Mini and E3 DIP boards this morning, where the firmware.bin and FIRMWARE.CUR files are updated inconsistently. I don't know whether the firmware update actually occured properly in those cases, although it looked like it at least tried to update.

I'm building with the default bf2 environments, nothing modified for RE.

i am using E3 Dip also.
i tried BigTreeTech fork, genericSTMF1 env, and the SKR, and my modded RE versions.
The firmware flashes, manual copy or drag and drop.
But the cleanup of firmware.bin and FIRMWARE.CUR is not reliable or repeatable.

@sl1pkn07
Copy link
Contributor Author

sl1pkn07 commented Sep 26, 2019

rom (rx) : ORIGIN = 0x08007000, LENGTH = 512K - 28K

this is all OK? 0x08007000 or 28K not to be also changed?

@tpruvot
Copy link
Contributor

tpruvot commented Sep 26, 2019

all marlin stm32 firmwares include a "bootloader" code inside... these bootloader customisations are not even required... on the 256k chips, its understandable to save a few KBs.. not on 512k ones

@totalretribution
Copy link

it might be, but its not so simple as they didnt update their bootloader to allow to flash a bigger firmware via the SD...

Bootloader seems to work fine when build using RE (512K), with either STM32F103R_bigtree or STM32F103R_bigtree_USB with genericSTM32F103RE.

This is surprising to me as I did the same and all though the build was successful it would not boot.
In the end I got a StLink and once I removed the python script from platform.ini the SKR would boot just fine.

@TimoBre
Copy link

TimoBre commented Sep 28, 2019

Hello The work around from sl1pkn07 works for my E3 DIP (E Model) fine.

Here is a pic from my MCU of my SKR E3 DIP version
IMG_20190928_072211567

The following don't works for me, but it can be a lag of knowledge :-(

STM32F1RE_SKR_MINI.id

#if defined(STMF103RC)
  MEMORY
{
  ram (rwx) : ORIGIN = 0x20000000, LENGTH = 48K - 40
  rom (rx)  : ORIGIN = 0x08007000, LENGTH = 256K - 28K
}
#elif defined(STMF103RE)
  MEMORY
{
  ram (rwx) : ORIGIN = 0x20000000, LENGTH = 48K - 40
  rom (rx)  : ORIGIN = 0x08007000, LENGTH = 512K - 28K
}
#endif

I changed it in

MEMORY
{
 ram (rwx) : ORIGIN = 0x20000000, LENGTH = 48K - 40
 rom (rx)  : ORIGIN = 0x08007000, LENGTH = 512K - 28K
}

So it fits and i habe 512K :-)

Thank you all!

@tpruvot
Copy link
Contributor

tpruvot commented Sep 28, 2019

fyi, the RET6 has also more ram (64KB vs 48KB)

@sl1pkn07
Copy link
Contributor Author

sl1pkn07 commented Sep 28, 2019

@TimoBre because is a idea, is not a real code :)

@thinkyhead
Copy link
Member

We can use preprocessor in the ld files. Huh. Makes sense, I guess!

@brianredbeard
Copy link

brianredbeard commented Sep 30, 2019

I just tried a slightly different tactic. After reading through the Platform.io scripting guide I quickly threw in an print(env.Dump()) to see what environment variables were available to achieve something functionally equivalent to what @sl1pkn07 proposed.

I found that the variable BOARD_MCU gets populated. So i threw this together to handle it in that pre-processor stage:

buildroot/share/PlatformIO/scripts/STM32F103RC_SKR_MINI.py:

if (env['BOARD_MCU'] == 'stm32f103rct6'):
    env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/STM32F103RC_SKR_MINI.ld")
elif (env['BOARD_MCU'] == 'stm32f103ret6'):
    env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/STM32F103RE_SKR_MINI.ld")

Not a big change but it got the job done. If folks want/need me to submit a PR, I can do that... Otherwise one more contribution to the thought process.

@thinkyhead thinkyhead changed the title [FR] Some units (new batch) of BTT SKR Mini E3 , and SKR Mini E3 DIP have different MCU model than original, needs update Marlin/PIO config for cover it [FR] Need fixes for BTT SKR Mini E3 having a different MCU Oct 24, 2019
@thinkyhead
Copy link
Member

@brianredbeard — Does that change to the build script allow the build to work with no other changes? Or, will it only work if platformio.ini is also modified to use a different MCU for this board?

@brianredbeard
Copy link

@thinkyhead Great question...

I'm back tracking through because things have been rapidly developing with this board ;)

I found that after #15476 (specifically 82027d1) and #15398 my local copy is working but could use a bit of a rework.

I presently have another definition ([env:STM32F103RE_bigtree]) which is identical to the original with the exception of setting board = genericSTM32F103RE.

I'll need to spin this around in my head, because given the flexibility of PlatformIO there are a number of good ways to solve this.

Does Marlin have any expressed minimum version of PlatformIO? If not (or if it's >= 4.1) then the best option would be to use the extends = option (Documentation) which would allow this to be broken down better making the config a bit more DRY.

mhcerri added a commit to mhcerri/Marlin that referenced this issue Nov 6, 2019
mhcerri added a commit to mhcerri/Marlin that referenced this issue Nov 8, 2019
@thinkyhead
Copy link
Member

thinkyhead commented Nov 14, 2019

Does Marlin have any expressed minimum version of PlatformIO?

Let's say, 4.1, for now. The specific version requirement will get updated on each point-release.

@wisesokol
Copy link

Hi. I want replace RCT to RET chip on my skr mini e3 v1.2. I will use stlink and TFT port for recording.
As far as I understand, bootloader will work with BTT_SKR_E3_DIP. The entry address is 0x08000000. Next, I compile the firmware for skr mini e3 with 512 flash. Did I miss anything?

@sl1pkn07
Copy link
Contributor Author

The stock bootloader not work with firmwares >256k

@wisesokol
Copy link

I’m understand, thanks. So I make a firmware greater than 256 kb and write it using stlink? What is the recording address? 0x080000(remove bootloader) or 0x0807000?

@sl1pkn07
Copy link
Contributor Author

sl1pkn07 commented Jun 19, 2020

you can do the two methods, but you need configure marlin for start in one or other address (modify the LD/.py scripts) (if you start from 0x080000 you lost the stock bootloader)

greetings

@wisesokol
Copy link

I'm good at soldering and electronics, but unfortunately I'm not good at programming. What script do I need to edit in marlin? Perhaps the one who has already made a modification will write a small guide.

@sjasonsmith
Copy link
Contributor

Closing this, as the PIO file has both RC and RE environments that can be used with these boards.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T: Feature Request Features requested by users.
Projects
None yet
Development

No branches or pull requests