Morpheus-STM32
Morpheus-STM32 copied to clipboard
Work status?
Hi, I'm really interested in this project. Blue pill is a cheap and powerful board, so it's a nice choice for 3d printers. So I want to know is this board complete? Can I make one? Which software works with your board?
Hello. I didn't make one yet, you can make one if you want. Please consider that this project is a work in progress, and it may have some mistake that I didn't see yet. Also this board has no fuses or reverse current protection, please make sure that all cables are connected properly and use an external fuse. As of firmware, I'm waiting for a functional Marlin release (you can track it too here: "https://github.com/MarlinFirmware/Marlin/issues/7076"). I'm hoping that Marlin works with STM32F1 boards since it would be a very cheap upgrade to 32bits, especially for delta machines.
Klipper supports the STM32F103 board.
https://github.com/KevinOConnor/klipper/blob/master/docs/Features.md
Can I clarify if the diode beside the VIN is to guard against reverse polarity?
Also, is there a list of components (capacitors, resistors, MOSFETs, etc.) that is needed? Or do I just RTFM (or in this case, RTFPDF)?
Hi! The diode is needed because when tested with USB voltage input only, there was current on 12V rails, apprently due to how the LM1117 works. Currently it has no reverse polarity or overcurrent protection. Also I found that HW PWM is not working correctly yet on Marlin 2.0 so print fan doesn't work as intended. As for the BOM, I'll make one soon so it's easier for you. @jakep82 I've been reading about Klipper, it's really nice but my goal for now it's to make it work correctly with Marlin. If you want to try it would be nice to see how it performs.
I'm interested in building one as soon as a BOM is available. I have a couple STM32 Dev boards, and I want to test this board with Klipper for a future printer.
Did you manage to get the built-in USB port when compiling Marlin 2.0?
Hi. I got Marlin 2 compiled with Arduino IDE and fully working on my Blue Pill board.
The latest Arduino 1.8.9 with updated boards STM32 Cores ver. 1.6.1 updated using Additional boards in preferences with https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json allowed me to select under tools: Board: Generic STM32F1 Series Board part number: Bluepill F103C8 (128k) U(S)ART support "Enabled (generic 'Serial')" USB support (if available): "CDC (generic 'Serial' supersede U(S)ART"
I copied just the Marlin folder from Marlin-bugfix-2.0.x to my Arduino Projects folder. I opened the .ino file from Ardiuno IDE and selected my board as above. Using the default Configuration files I chose #define SERIAL_PORT 1 #define SERIAL_PORT_2 -1 giving me both Blue Pill Serial 1 on PA 9 and PA10, and USB serial working. I chose #define MOTHERBOARD BOARD_MALYAN_M200 as my motherboard. This compiled without any errors or warnings and uploaded the firmware to my Blue Pill using ST-Link V2 I connected XYZ Min, A15, B4 and B5 to 3.3v and A0 (T0 sensor) to a 10k Potentiometer between gnd and 3.3V to set its voltage for 210 C. This was necessary to stop Marlin from performing a critical Halt for Thermal runaway etc. I then connected via USB to Repetier Host after installing the STM32 VCP serial driver available at https://www.st.com/en/development-tools/stsw-stm32102.html.
I was able to serial connect to Blue Pill from Repetier and load, slice and print a model to it. I checked all the pins with an oscilloscope and all signals were exactly as expected.
Choosing #define MOTHERBOARD BOARD_MORPHEUS gave errors and after editing lines producing errors in the pins_MORPHEUS.h file I managed to compile and upload but the Blue Pill went into a Watchdog reset every 4 seconds. This is because of a pins - timer usage clash.
@pscrespo Please change your pins_MORPHEUS.h file to get a pins combination that doesn't produce a timer clash and if possible make PA9 and PA10 available for a serial WIFI connection.
Your work is much appreciated and I look forward to a final PCB to plug my Blue Pill into and to start printing!
Hi pscrespo Thank you very much for your board and pins update. In order to get a successful build I had to use Arduino IDE with modified MalyanM200 pins to match Morpheus. I would love to use PlatformIO but haven't managed a successful build. Could you please add your platformio.ini, Configuration.h and Configuration_adv.h files to the code section to help me build using PlatformIO.
Here's my recipe for building with PlatformIO:
- Use the latest
2.0.x
branch of Marlin. - Create new environment in
platformio.ini
[env:STM32F103CB_morpheus]
platform = ststm32
board = genericSTM32F103CB
build_flags = !python Marlin/src/HAL/HAL_STM32F1/build_flags.py -ffunction-sections -fdata-sections -Wl,--gc-sections
src_filter = ${common.default_src_filter} +<src/HAL/HAL_STM32F1>
lib_ignore = Adafruit NeoPixel, LiquidCrystal, LiquidTWI2, TMCStepper, U8glib-HAL, SPI
- Optionally modify:
[platformio]
...
default_envs = STM32F103CB_morpheus
- The minimum changes to
Configuration.h
are:
#define SERIAL_PORT -1
and
#define MOTHERBOARD BOARD_MORPHEUS
- Build and flash!
Seems to work, responds correctly in Pronterface. On Windows I had to install the drivers for the Maple USB serial port:
~/.platformio/packages/framework-arduinoststm32-maple/drivers/win/install_drivers.bat
Note that the above configuration builds image for direct flashing (stlink), and not for stm32duino/maple bootloader. It seems that PlatformIO has some hardcoded preferences for the linker script (which determines the type of image to build) according to the name of the board (see ~/.platformio/packages/framework-arduinoststm32-maple/tools/platformio-build-stm32f1.py
).
If you would like to build version for flashing with the bootloader, you have to use env such as this:
[env:STM32F103CB_morpheus]
platform = ststm32
board = bluepill_f103c8_128k
board_build.core = maple
build_flags = !python Marlin/src/HAL/HAL_STM32F1/build_flags.py -ffunction-sections -fdata-sections -Wl,--gc-sections
src_filter = ${common.default_src_filter} +<src/HAL/HAL_STM32F1>
lib_ignore = Adafruit NeoPixel, LiquidCrystal, LiquidTWI2, TMCStepper, U8glib-HAL, SPI
The platformio-build-stm32f1.py
scripts builds bootloader code (code at 0x8002000
) for the bluepill_f103c8_128k
board and raw code (at 0x8000000
) for the genericSTM32F103CB
board.
@Cleric-K Hi. Thanks a stack for the PlatformIO instructions. Worked perfectly! Trying to get OpenOCD in PlatformIO to upload via Stlink to a Blue Pill board with 128k ROM but reporting as 64K . OpenOCD has a size overide option, but I need to find where to do this. Another option is to use STM32CubeProgrammer like Arduino does. Arduino happily programs the board. Would be great if you could help. My IDE environment experience is rather low.
Unfortunately I don't have elegant solution to this one. What I do is to manually edit:
~\.platformio\packages\tool-openocd\scripts\target\stm32f1x.cfg
and replace $_FLASH_SIZE
on the flash bank ...
line with sufficiently large number, for eaxmple 0x1000000
. We are not setting it to 0x20000
(128K) because that would restrict flashing other f1xx MCUs which might have more than that:
flash bank $_FLASHNAME stm32f1x 0x08000000 0x10000000 0 $_TARGETNAME
The above number will allow OpenOCD to try to flash images up to 16MB. It will fail of course, but I don't think this can do any harm (besides leaving the mcu in unworkable state).
Thanks Tiny typo. Used flash bank $_FLASHNAME stm32f1x 0x08000000 0x1000000 0 0 $_TARGETNAME Worked perfectly.
Thanks for spotting the typo.
Just for the record, here's also how to use STLink (no changes in .cfg
scripts needed). This must be added to the [env...]
section:
upload_protocol = custom
upload_command = $PROJECT_PACKAGES_DIR/tool-stm32duino/stlink/ST-LINK_CLI.exe -ME -V -P $SOURCE 0x8000000 -Rst
Thanks. Worked!
Thanks. Did anyone tried enabled sdsupport? Is it fit on 128kb flash?
Quick test with SD enabled caused overflow with about +13KB.
I think I'm missing something. Then I compiled the same config for arduino 128 and the bin is just 66K! I'm not very experienced with the Marlin code but I suspect that the stm32 version compiles unnecessary stuff.
Or maybe ARM code, being 32bit, is simply larger than 8bit AVR code ... I have no idea.
Hi there! First, thanks to everyone, it's great to see users helping others! I apologize for not being around lately, I'm going to make some time to write a (simple and short) tutorial in the wiki, but for now, to save space you can:
- Comment #define ARC_SUPPORT in Configuration_adv.h
- Uncomment #define NO_VOLUMETRICS in Configuration_adv.h
- Uncomment #define SLIM_LCD_MENUS in Configuration.h
That will give enough space for LCD and SD support If you need an extra you can:
- Comment #define SHOW_BOOTSCREEN in Configuration.h (~300B)
- Uncomment #define NO_WORKSPACE_OFFSETS in Configuration_adv.h (~1kB, but will change G92 behavior)
Using latest 2.0.x still overflowed ~3kb after disabled pid and even uncommenting #define NO_LCD_MENUS.
Built using Arduino IDE with SDSUPPORT enabled and it was successful with result: Sketch uses 97576 bytes (74%) of program storage space. Maximum is 131072 bytes. Global variables use 8144 bytes (39%) of dynamic memory, leaving 12336 bytes for local variables. Maximum is 20480 bytes.
Must use different libraries. Takes four times as long to build though!
@Vicbarn could you share what you have done? I failed to compile using Arduino IDE.
See my post on July 8th above. Need to use STM32 Cores ver. 1.6.1. The latest version may result in errors. Modified pins_MALYAN_M200.h below. pins_MALYAN_M200.zip
Rename pins_MALYAN_M200.zip to pins_MALYAN_M200.h.
@Vicbarn thanks it works. Compiled successfully SDSUPPORT enabled without LCD uses 88KB rom. I wonder why compiled with platformio so big binary size.
Hopefully @Cleric-K or @pscrespo will give us a new recipe for PlatformIO that will use the same libraries. I suspect the Arduino build uses custom HAL libraries instead of the STM HAL libraries.
Compile under Arduino IDE getting me serious pain, sometimes hangs or sometimes got filename too long. I manage to setting build flags platformio using arduino build flags. Here my settings
#
# Morpheus (STM32F103CB)
#
[env:STM32F103CB_morpheus]
platform = ststm32
board = genericSTM32F103CB
build_flags = !python Marlin/src/HAL/HAL_STM32F1/build_flags.py -c -w -std=gnu++14 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics -fno-rtti -fno-exceptions -fno-use-cxa-atexit -Wl,--gc-sections
-DMCU_STM32F103CB
-D__STM32F1__=1
-DMOTHERBOARD="BOARD_MORPHEUS"
-DSERIAL_USB
-DENABLE_HWSERIAL3 # enable second serial on i2c pin (PB11, PB10)
-DDEBUG_LEVEL=0 -D__MARLIN_FIRMWARE__
build_unflags = -std=gnu++11
lib_deps =
src_filter = ${common.default_src_filter} +<src/HAL/HAL_STM32F1>
lib_ignore = Adafruit NeoPixel, LiquidCrystal, LiquidTWI2, TMCStepper, U8glib-HAL, SPI
with SDSUPPORT and MESH BED LEVELING enabled give me more than enough space Checking size .pio\build\STM32F103CB_morpheus\firmware.elf Advanced Memory Usage is available via "PlatformIO Home > Project Inspect" DATA: [==== ] 42.2% (used 8648 bytes from 20480 bytes) PROGRAM: [======== ] 75.5% (used 98936 bytes from 131072 bytes) Building .pio\build\STM32F103CB_morpheus\firmware.bin
Hope it helps, thanks.
@pebri86. Thanks, works great! Thanks for adding Serial 3 for Wi-Fi serial. I was able to have USB and Serial 3 connected at the same time and change between them just by changing Com ports in Repetier Host.
On a dual core machine with 4GB RAM Arduino IDE hangs because it uses up all the RAM and then has to page! If left long enough it eventually finishes. Great to be able to use PlatformIO!
Hi everyone, This little board are much capable than expected, i tried work on the software and there is enough memory and pins available (including PC13 so no debug led, PC14, and PC15 disable lse oscillator) for sdcard, i2c oled, and rotary or we have another option to enable second serial on i2c pin which is i2c oled and rotary encoder dropped but we have wifi option to connect esp01 module on those pin with ESP3D firmware.
The flash storage used 98% but the firmware is working great.
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
DATA: [======= ] 66.1% (used 13544 bytes from 20480 bytes)
PROGRAM: [==========] 98.6% (used 129232 bytes from 131072 bytes)
here oled working on my prototype, the board are actually bluepill compatible, they said it "Super Bluepill" but it just the same hardware with added some connector including microsd card socket.
Hi everyone. @pebri86. I see you have I2C oled and encoder working. When i try to activate I2C oled and add U8glib-hal library, i have a lot of error.... Could you please share the right config? (I use PB10 and PB11 // TwoWire Wire (2)).
@paudrat I also use PB10 and PB11 for SCL and SDA pin respectively. latest U8glib-hal has fixed i2c com hal for stm32 but marlin doesn't defined it in HAL_LCD_com_defines.h so you need to modify those file by yourself besides your change of TwoWire Wire (2). I use bugfix-2.0.x branch of Marlin.
Here my configuration
/* configuration.h file */
// uncomment lines
#define SLIM_LCD_MENUS // without this enabled flash storage won't fit 128K
#define U8GLIB_SSD1306
#define OLED_PANEL_TINYBOY2 // enable this to use encoder
/* HAL_LCD_com_defines.h file */
// modify file around line 46
#elif defined(__STM32F1__)
uint8_t u8g_com_HAL_STM32F1_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_stm32duino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
// enable function to use stm32 i2c wire library
uint8_t u8g_com_stm32duino_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
#define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_STM32F1_sw_spi_fn
#define U8G_COM_HAL_HW_SPI_FN u8g_com_stm32duino_hw_spi_fn
#define U8G_COM_ST7920_HAL_SW_SPI u8g_com_std_sw_spi_fn
#define U8G_COM_ST7920_HAL_HW_SPI u8g_com_stm32duino_hw_spi_fn
// enable function to use stm32 i2c wire library
#define U8G_COM_SSD_I2C_HAL u8g_com_stm32duino_ssd_i2c_fn
#endif
and here my platformio.ini file
#
# Morpheus (STM32F103CB)
#
[env:STM32F103CB_morpheus]
platform = ststm32
board = genericSTM32F103CB
build_flags = !python Marlin/src/HAL/HAL_STM32F1/build_flags.py -c -w -std=gnu++14 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics -fno-rtti -fno-exceptions -fno-use-cxa-atexit -Wl,--gc-sections
-DMCU_STM32F103CB
-D__STM32F1__=1
-DMOTHERBOARD="BOARD_MORPHEUS"
-DSERIAL_USB
-DDEBUG_LEVEL=0 -D__MARLIN_FIRMWARE__
build_unflags = -std=gnu++11
src_filter = ${common.default_src_filter} +<src/HAL/HAL_STM32F1>
lib_ignore = Adafruit NeoPixel, LiquidCrystal, LiquidTWI2, TMCStepper, SPI
@pebri86. Many many many thanks... it compiles without error..................