When building CP for SAMD21 I have noticed a duplicated directories with config files that differ in meaning but almost identical content wise (sometimes to the line number).
I mean:/home/vagrant/source/circuitpython-bb/ports/atmel-samd/asf4/samd21/config and
/home/vagrant/source/circuitpython-bb/ports/atmel-samd/asf4_conf/samd21
It is confusing when full-text searching the sources and all the time test compilation attempt is needed to figure out which setting will be considered for compilation.
Experimentally I have figured out that /home/vagrant/source/circuitpython-bb/ports/atmel-samd/asf4/samd21/config could be thrown away.
So, if you take for example RTC clock source definition and full-text search for CONF_GCLK_RTC_SRC (used later on for RTC initialization in common-hal/rtc/RTC.c ) you get:
Code: Select all
asf4_conf/samd21/peripheral_clk_config.h:323:#ifndef CONF_GCLK_RTC_SRC
asf4_conf/samd21/peripheral_clk_config.h:324:#define CONF_GCLK_RTC_SRC GCLK_CLKCTRL_GEN_GCLK2_Val
asf4_conf/samd51/peripheral_clk_config.h:591:#ifndef CONF_GCLK_RTC_SRC
asf4_conf/samd51/peripheral_clk_config.h:592:#define CONF_GCLK_RTC_SRC RTC_CLOCK_SOURCE
asf4/samd21/config_/peripheral_clk_config.h:323:#ifndef CONF_GCLK_RTC_SRC
asf4/samd21/config_/peripheral_clk_config.h:324:#define CONF_GCLK_RTC_SRC GCLK_CLKCTRL_GEN_GCLK0_Val
asf4/samd51/config/peripheral_clk_config.h:591:#ifndef CONF_GCLK_RTC_SRC
asf4/samd51/config/peripheral_clk_config.h:592:#define CONF_GCLK_RTC_SRC RTC_CLOCK_SOURCE
I don't mention the samd51 stuff blended in here - that is a sad story on its own and separate discussion topic.
So, how I usually figure out what the right value is: I ignore samd51 stuff, which leaves us with
Code: Select all
asf4_conf/samd21/peripheral_clk_config.h:323:#ifndef CONF_GCLK_RTC_SRC
asf4_conf/samd21/peripheral_clk_config.h:324:#define CONF_GCLK_RTC_SRC GCLK_CLKCTRL_GEN_GCLK2_Val
asf4/samd21/config_/peripheral_clk_config.h:323:#ifndef CONF_GCLK_RTC_SRC
asf4/samd21/config_/peripheral_clk_config.h:324:#define CONF_GCLK_RTC_SRC GCLK_CLKCTRL_GEN_GCLK0_Val
That is how I navigate through all the settings. This exercise tires me and makes my customer impatient :)
Another advantage of getting read of that duplicated stuff is making it a bit easier for the version control. Less code for pushing/pulling changes all the time. Not a game changer, I agree, but still.
Would that be possible to remove /home/vagrant/source/circuitpython-bb/ports/atmel-samd/asf4/samd21/config from the source tree in the next release?
Unless there is a reason that stuff is in. I would be curious to know every consideration about the firmware source tree in general and code settings - in particular.
Regards