Welcome! Log In Create A New Profile

Advanced

Unable to connect to printer via serial port

Posted by jpff 
Unable to connect to printer via serial port
June 21, 2025 02:42PM
Hi

I've compiled marlin with what I deem are all necessary modifications to the code to make it work for my printer's setup. My printer is a CR-200B with a BOARD_CREALITY_V425 with an added BLtouch sensor which did not come stock.

However I'm unable to connect to my printer via serial port through octoprint, I'm unsure if this is whether the serial port configuration is incorrect for the board I'm using or if the MCU flashing process is failing, as I most often get the error "Core is locked up" in STM32CubeProgrammer, although I compare the MCU's flash memory after flashing with the original bin file and everything checks as OK.

I feel the serial port should be set to 0, however marlin does not compile so...

I've attached the entire code onto this message, it's compressed and split into 6x 7.9MB volumes so that I could upload it directly here.

If anyone could help me in understanding why the code isn't working I'd be incredibly thankful
Attachments:
open | download - Marlin-2.1.2.5.zip.001 (7.8 MB)
open | download - Marlin-2.1.2.5.zip.002 (7.8 MB)
open | download - Marlin-2.1.2.5.zip.003 (7.8 MB)
open | download - Marlin-2.1.2.5.zip.004 (7.8 MB)
open | download - Marlin-2.1.2.5.zip.005 (7.8 MB)
open | download - Marlin-2.1.2.5.zip.006 (6.98 MB)
Re: Unable to connect to printer via serial port
June 21, 2025 08:19PM
stm32 based board do not have a serial port 0. The error message even tells you #error "SERIAL_PORT must be from 1 to 9.""

This Creality board use serial port 1 for the USB port


You have to be really careful when you upload firmware using a programmer. They presume you know what your doing. It is way safer to put firmware on sdcard and let the bootloader load it

This board has custom bootloader code from 0x08000000 to 0x08006FFF and the firmware is built to be 0x08007000 on wards. The bootloader jumps to the firmware.

If you over wrote the bootloader or did not upload the new firmware to 0x08007000 the board will not boot at all.

Edited 7 time(s). Last edit at 06/21/2025 08:36PM by Dust.
Re: Unable to connect to printer via serial port
June 22, 2025 01:31AM
Alright! Thank you for letting me know Dust!

I did indeed wipe out the bootloader, as I've hit erase chip more than once before flashing with STM32CubeProgrammer.

After reading I've thought of using the following bootloader implementation for STM32F103's:
[github.com]

But then I thought, I have STM32duino framework installed on my Arduino installation, so maybe I can compile Marlin there for STM32F103RETx and use the upload bootloader function to flash the bootloader first..?

I've been trying to compile my previously uploaded project in Arduino IDE but many multiple errors show up.

Maybe it'd work if I flash the bootloader with Arduino IDE first, see where it ends in the flash memory in STM32CubeProgrammer, and then flash Marlin FW from the address right afterwards forward from where the bootloader ends...?
Re: Unable to connect to printer via serial port
June 22, 2025 09:31AM
In creality file Marlin2.0.1-HW-V4.2.5-SW-V1.0.8-SC-V1.0.2-nine languages-CRTouch is a file BiSun_BootLoader_V0.1.hex

Which if your very lucky is the original bootloader (it looks good)

This is the hex from the archive BiSun_BootLoader_V0.1.hex
I converted it to a bin for you using "objcopy --input-target=ihex --output-target=binary BiSun_BootLoader_V0.1.hex BiSun_BootLoader_V0.1.bin"
BiSun_BootLoader_V0.1.bin

Flash this to 0x08000000 and put the firmware.bin on a sdcard (or flash to 0x08007000 and cross your fingers.

I would also strongly recommend you upgrade to vscode + platformio and forget about Arduino ide

Edited 5 time(s). Last edit at 06/22/2025 10:16AM by Dust.
Re: Unable to connect to printer via serial port
June 22, 2025 01:41PM
Hi Dust!

I must say that from the moment that I began trying these bootloaders on the board I've never again had the "Core is locked up" error again, but then I also had the option "run after programming" enabled on STM32CubeProgrammer so maybe that didn't help either.

I've been using Platformio to compile everything, the Arduino IDE was just an idea to check whether it'd work (it doesn't, STM32duino doesn't even bundle any bootloader, so that option from Arduino IDE doesn't work).

Printer seems to remain unresponsive, I tried both flashing with ST-LINK the firmware at position 0x08007000, as well as using the SD Card method, I'm unsure whether it's a bootloader issue or the compiled marlin firmware... I don't have a screen attached to my printer to be able to tell if there's any sign on life in it.

I've also tried another bootloader, specifically this one:

[github.com]

I created a Platformio project of it that I've upload here, together with the compiled .bin.

For this last bootloader I flashed the marlin firmware from position 0X08002000 onwards.

Is there a way to debug code in Platformio to check whether it's looping or hanging somewhere?
Attachments:
open | download - STM32duino-bootloader Platformio Project.zip (361.4 KB)
open | download - bootloader.bin (7.1 KB)
Re: Unable to connect to printer via serial port
June 22, 2025 01:56PM
I have a feeling this is an issue with the marlin firmware code hanging up somewhere and not the bootloader.

I knew a bootloader was required when not using a native programming method, non-native like USB, UART, SD CARD, CAN (e.g. like TI MCU's), etc.

Is there any particular reason why these STM32 MCUs explicitly require a bootloader if flashing the main firmware via an ST-LINK?

I know this question is beyond the scope of this forum, but is there any way to debug, line by line, code in Platformio?
Re: Unable to connect to printer via serial port
June 23, 2025 02:09AM
After some tinkering with the code of both the bootloader and marlinfw within these last 2 hours before heading off to work, I actually fixed my printer, it connects to marlin and displays temperatures and all.

I did some modifications to the bootloader STM32duino-bootloader, and flashed it with STM32CubeProgrammer to position 0x08000000.

Then there was an issue with uploading with st-link with platformio the marlin firmware because it was renaming the firmware.bin file to something else, so I commented out the line in ini/stm32f1.ini:

#
# Creality (STM32F103Rx)
#
[STM32F103Rx_creality]
extends                     = stm32_variant
board_build.variant         = MARLIN_F103Rx
board_build.offset          = 0x7000
#board_build.rename          = firmware-{date}-{time}.bin
board_upload.offset_address = 0x08007000
build_flags                 = ${stm32_variant.build_flags}
                              -DMCU_STM32F103RE -DHAL_SD_MODULE_ENABLED
                              -DSS_TIMER=4 -DTIMER_SERVO=TIM5
                              -DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8
build_unflags               = ${stm32_variant.build_unflags}
                              -DUSBCON -DUSBD_USE_CDC
monitor_speed               = 115200
debug_tool                  = jlink
upload_protocol             = jlink

Then I added the lines to upload and debug with st-link:

#
# Creality 512K (STM32F103RE)
#
[envconfused smileyTM32F103RE_creality]
extends = STM32F103Rx_creality
board   = genericSTM32F103RE
debug_tool = stlink
upload_protocol = stlink

And flashed the board, which already flashes from address board_upload.offset_address = 0x08007000 onwards.

And printer seems to be functional.

I upload the bootloader Platformio project (it was thrown together quick and dirty without respecting the file structure of the original project) with the modified files here together with the bootloader .bin.

EDIT: However, I do have to reconfigure Marlin because the axes seem to be inverted when homing.

Edited 1 time(s). Last edit at 06/23/2025 02:26AM by jpff.
Attachments:
open | download - STM32duino-bootloader Platformio Project.zip (361.4 KB)
open | download - bootloader.bin (7.2 KB)
Sorry, only registered users may post in this forum.

Click here to login