Understanding Marlin so I can port it CH32V307 - Page 1
Forum section: electronics / general

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: December 30, 2023, 10:40:01 am
content: Hi,I'm interested in understanding marlin software structure and I'm eager to port it to CH32V307 part,I want to first try it out on a stm32 blue pill and then port it to the new arch, since it's a complex software, I have modified it for STM32F103CB partI have changed the platformio.ini filedefault_envs = STM32F103CB_malyanalso I have copied the Configuration.h and Configuration_adv.h from Configurationsrepo Malyan/M200 folder to marlin folder,The next step is to remove compiler optimization so the code can be debugged with ease, so I have edited line number 798 in the main makefilefromQuotetoQuoteAnd I expected the output flash size to change, But noting would change, so Where should I change to remove the compiler optimization,You can take a look at makefile in the attachment

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: January 01, 2024, 01:04:28 pm
content: Merry christmas, is there a nata gift for me? do you know how to remove compiler optimization?

author: martinribelotta
author_rank: Regular Contributor
timestamp: January 01, 2024, 02:33:05 pm
content: Quote from: ali_asadzadeh on January 01, 2024, 01:04:28 pmTry to useCode:OPT = gThis enable some optimizations but maintain the final executable reasonably near to the source code.And happy new year for you!

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: January 02, 2024, 01:30:27 pm
content: Thanks martinribelotta and happy new year, This is the output size when the OPT = sQuoteand this is the output when the OPT = gQuoteExactly the same, I think there might be some other flags somewhere else And I can not figure it out?this is the marlin github repohttps://github.com/MarlinFirmware/Marlin

author: westfw
author_rank: Super Contributor
timestamp: January 02, 2024, 09:13:17 pm
content: QuoteDid you do a "Make Clean" or equivalent in between? Dependency calculations usually don't take into account changes in the Makefile. so it might have just re-linked all the existing .o files from the previous build.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: January 04, 2024, 10:14:35 am
content: QuoteAbsolutely, and it does not change the output flash or ram size

author: DavidAlfa
author_rank: Super Contributor
timestamp: January 04, 2024, 05:59:53 pm
content: If flash usage is already 81% withOs...O0won't fit by any means!However you can selectively disable optimization with gcc attributes.For example:Code:__attribute__((optimize("O0"))) void do_something(){// This is not optimized}

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: January 06, 2024, 08:37:36 am
content: Thanks David, Do you have any experience with marlin firmware? it's so complicated that doing __attribute__((optimize("O0"))) would not help.

author: DavidAlfa
author_rank: Super Contributor
timestamp: January 06, 2024, 02:42:05 pm
content: You only need to port the lower level functions, those interfacing the hardware.Marlin has several HAL libraries for the different MCUs, see here:https://github.com/MarlinFirmware/Marlin/tree/bugfix-2.1.x/Marlin/src/HALThat's what you need to work on.