Author Topic: Understanding Marlin so I can port it CH32V307  (Read 1552 times)

0 Members and 1 Guest are viewing this topic.

Online ali_asadzadehTopic starter

  • Super Contributor
  • ***
  • Posts: 1906
  • Country: ca
Understanding Marlin so I can port it CH32V307
« on: December 30, 2023, 10:40:01 am »
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 part

I have changed the platformio.ini file  default_envs = STM32F103CB_malyan also I have copied the Configuration.h and Configuration_adv.h from Configurations
 repo 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 makefile

from
Quote
OPT = s

to
Quote
OPT = 0

And 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
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Online ali_asadzadehTopic starter

  • Super Contributor
  • ***
  • Posts: 1906
  • Country: ca
Re: Understanding Marlin so I can port it CH32V307
« Reply #1 on: January 01, 2024, 01:04:28 pm »
Merry christmas  ^-^ ^-^ ^-^, is there a nata gift for me? do you know how to remove compiler optimization?
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline martinribelotta

  • Regular Contributor
  • *
  • Posts: 56
  • Country: ar
  • A camel is a horse designed by a committee
    • Martin Ribelotta design services
Re: Understanding Marlin so I can port it CH32V307
« Reply #2 on: January 01, 2024, 02:33:05 pm »
Merry christmas  ^-^ ^-^ ^-^, is there a nata gift for me? do you know how to remove compiler optimization?

Try to use

Code: [Select]
OPT = g
This enable some optimizations but maintain the final executable reasonably near to the source code.

And happy new year for you!
 

Online ali_asadzadehTopic starter

  • Super Contributor
  • ***
  • Posts: 1906
  • Country: ca
Re: Understanding Marlin so I can port it CH32V307
« Reply #3 on: January 02, 2024, 01:30:27 pm »
Thanks martinribelotta and happy new year, This is the output size when the OPT = s
Quote
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [====      ]  43.7% (used 8956 bytes from 20480 bytes)
Flash: [========  ]  81.1% (used 99684 bytes from 122880 bytes)

and this is the output when the OPT = g
Quote
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [====      ]  43.7% (used 8956 bytes from 20480 bytes)
Flash: [========  ]  81.1% (used 99684 bytes from 122880 bytes)

Exactly the same, I think there might be some other flags somewhere else And I can not figure it out?
this is the marlin github repo
https://github.com/MarlinFirmware/Marlin
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Understanding Marlin so I can port it CH32V307
« Reply #4 on: January 02, 2024, 09:13:17 pm »
Quote
This is the output size when the OPT = s
    :
and this is the output when the OPT = g
    :
Exactly the same,
Did 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.
 

Online ali_asadzadehTopic starter

  • Super Contributor
  • ***
  • Posts: 1906
  • Country: ca
Re: Understanding Marlin so I can port it CH32V307
« Reply #5 on: January 04, 2024, 10:14:35 am »
Quote
Did 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.
Absolutely, and it does not change the output flash or ram size
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5912
  • Country: es
Re: Understanding Marlin so I can port it CH32V307
« Reply #6 on: January 04, 2024, 05:59:53 pm »
If flash usage is already 81% with Os... O0 won't fit by any means!

However you can selectively disable optimization with gcc attributes.
For example:
Code: [Select]
__attribute__((optimize("O0"))) void do_something()
{
    // This is not optimized
}
« Last Edit: January 04, 2024, 06:02:26 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Online ali_asadzadehTopic starter

  • Super Contributor
  • ***
  • Posts: 1906
  • Country: ca
Re: Understanding Marlin so I can port it CH32V307
« Reply #7 on: January 06, 2024, 08:37:36 am »
Thanks David, Do you have any experience with marlin firmware? it's so complicated that doing __attribute__((optimize("O0"))) would not help.
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5912
  • Country: es
Re: Understanding Marlin so I can port it CH32V307
« Reply #8 on: January 06, 2024, 02:42:05 pm »
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/HAL

That's what you need to work on.
« Last Edit: January 06, 2024, 02:52:29 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf