Topics

SOC_DIR not populated


Dan Kalowsky <dank@...>
 

Hey Zephyr team,

Long time no talk.

Short version:  Using the latest HEAD, I am finding that the kconfig SOC_DIR is not being populated for an out of tree SOC build.  This causes a compilation failure and makes everyone a sad panda.  As this was something that worked perfectly in 2.3 (and for the most part earlier), I was a little surprised to see this no longer working on HEAD.  Was it intentional to remove support for out of tree SOCs, or is this an oversight?  I could not find any documentation supporting either statement in the mailing list or meeting minutes.

Longer version:

I have a Zephyr application with a lot of out of tree pieces.  It kind of looks like the following simplified layout:

application/
- board/
- soc/
-- Kconfig
-- arm/
--- product/
--- Kconfig
--- Kconfig.defconfig
--- Kconfig.soc
--- CMakeLists.txt
---- soc_a/
---- soc_b/
- dts/
- src/
zephyr/
modules/

Overall this has worked great in 2.3 (and was functional in 2.2 with some fixes).  Given some of the recent work by Andrew and Tomasz (thanks and hi btw) I was motivated to upgrade to HEAD.  At this point, while building I get informed that the path $(SOC_DIR)/$(ARCH) has some unset variables, which causes the initial setup for cmake/kconfig to fail.  Sure enough, there are empty variables being used.  While investigating, it looks like the current HEAD has three issues for out of tree SOC usage, but I've only been able to "resolve" two of them.  Almost all of it seems to have originated from commit 5f7cc8ded9138b773012b9ffedc744b9475927db.

Issues found:
1) The file cmake/kconfig.cmake no longer sets up to export the SOC_DIR as it used to.  Thus when setting a custom SOC_DIR, nothing is there for the python script to add.  Adding back lines 44 and 88 solves the variables now being set, although the value of SOC_DIR is still nil.  You will need to resolve issue 2 as well to finish this fix.

2) The file cmake/app/boilerplate.cmake has relocated lines of code that set the SOC_DIR variable to a after a section of code that has requirements for them to be set.  Specifically the chunk at 527-541 needs to happen BEFORE the inclusion of kconfig.cmake on line 515.  It is not clear why these lines were moved from the commit or Pull Request, but it does expose a dependency chain that does not seem to be tested/validated in the scripts.  Moving this section alone is not enough, you still need issue 1 resolved for the variables to show up in the kconfig.py script.

3) Even with these changes, which allow me to get further along the compile, there is still one last issue I have not been able to rootcause.   I end up seeing the following error, which appears to munge some of the path:
CMake Error at /home/dkalowsky/product_dev/zephyr/CMakeLists.txt:376 (message):
  Could not find linker script:
  '/home/dkalowsky/product_dev/application/soc/arm//linker.ld'.

Note the // before linker.ld. 

Which brings us to the questions part...

Is Zephyr looking to drop out of tree SOC?  I certainly hope not, but some of the change directions in the commit above give a bit of concern that it might be true.  Note this is tea leaf reading, and I am bad at it.
If not, is there a new layout that should be utilized for out of tree SOC usage?  The documentation still points to the previously existing behavior as being correct.  If it is changing, is there a document that I can reference to update my local application?
If this is all oversight and just bugs, any ideas on what could be causing issue 3?



--
"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."


Carles Cufi
 

Hi Dan,

 

Assuming you have the latest upstream master, then this might be a regression introduced by:

https://github.com/zephyrproject-rtos/zephyr/pull/26715

 

We are certainly not dropping support for out-of-tree SoCs, in fact we just discussed this recently with Torsten (on copy). He should be able to give more info on the subject.

 

Thanks,

 

Carles

 

From: devel@... <devel@...> On Behalf Of Dan Kalowsky via lists.zephyrproject.org
Sent: 06 August 2020 19:19
To: devel@...
Subject: [Zephyr-devel] SOC_DIR not populated

 

Hey Zephyr team,

 

Long time no talk.

 

Short version:  Using the latest HEAD, I am finding that the kconfig SOC_DIR is not being populated for an out of tree SOC build.  This causes a compilation failure and makes everyone a sad panda.  As this was something that worked perfectly in 2.3 (and for the most part earlier), I was a little surprised to see this no longer working on HEAD.  Was it intentional to remove support for out of tree SOCs, or is this an oversight?  I could not find any documentation supporting either statement in the mailing list or meeting minutes.

 

Longer version:

 

I have a Zephyr application with a lot of out of tree pieces.  It kind of looks like the following simplified layout:

 

application/

- board/

- soc/

-- Kconfig

-- arm/

--- product/

--- Kconfig

--- Kconfig.defconfig

--- Kconfig.soc

--- CMakeLists.txt

---- soc_a/

---- soc_b/

- dts/

- src/

zephyr/

modules/

 

Overall this has worked great in 2.3 (and was functional in 2.2 with some fixes).  Given some of the recent work by Andrew and Tomasz (thanks and hi btw) I was motivated to upgrade to HEAD.  At this point, while building I get informed that the path $(SOC_DIR)/$(ARCH) has some unset variables, which causes the initial setup for cmake/kconfig to fail.  Sure enough, there are empty variables being used.  While investigating, it looks like the current HEAD has three issues for out of tree SOC usage, but I've only been able to "resolve" two of them.  Almost all of it seems to have originated from commit 5f7cc8ded9138b773012b9ffedc744b9475927db.

 

Issues found:

1) The file cmake/kconfig.cmake no longer sets up to export the SOC_DIR as it used to.  Thus when setting a custom SOC_DIR, nothing is there for the python script to add.  Adding back lines 44 and 88 solves the variables now being set, although the value of SOC_DIR is still nil.  You will need to resolve issue 2 as well to finish this fix.

 

2) The file cmake/app/boilerplate.cmake has relocated lines of code that set the SOC_DIR variable to a after a section of code that has requirements for them to be set.  Specifically the chunk at 527-541 needs to happen BEFORE the inclusion of kconfig.cmake on line 515.  It is not clear why these lines were moved from the commit or Pull Request, but it does expose a dependency chain that does not seem to be tested/validated in the scripts.  Moving this section alone is not enough, you still need issue 1 resolved for the variables to show up in the kconfig.py script.

 

3) Even with these changes, which allow me to get further along the compile, there is still one last issue I have not been able to rootcause.   I end up seeing the following error, which appears to munge some of the path:

CMake Error at /home/dkalowsky/product_dev/zephyr/CMakeLists.txt:376 (message):
  Could not find linker script:
  '/home/dkalowsky/product_dev/application/soc/arm//linker.ld'.

 

Note the // before linker.ld. 

 

Which brings us to the questions part...

 

Is Zephyr looking to drop out of tree SOC?  I certainly hope not, but some of the change directions in the commit above give a bit of concern that it might be true.  Note this is tea leaf reading, and I am bad at it.

If not, is there a new layout that should be utilized for out of tree SOC usage?  The documentation still points to the previously existing behavior as being correct.  If it is changing, is there a document that I can reference to update my local application?

If this is all oversight and just bugs, any ideas on what could be causing issue 3?

 

 


--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."


Rasmussen, Torsten
 

Hi Dan,

 

Sorry for any trouble the latest changes is causing you.

With https://github.com/zephyrproject-rtos/zephyr/pull/26715 it is now possible to provide multiple SoC roots, allowing for greater flexibility.

 

This can be seen here:

https://github.com/zephyrproject-rtos/zephyr/blob/master/cmake/app/boilerplate.cmake#L543-L548

 

and as you see, the `SOC_DIR` is still populated, but because there can only be a single SOC_DIR, we need to decide on the correct SOC_DIR to use.
To do so, we check for the existence of the SoC under its corresponding arch.

 

All SoCs in Zephyr are grouped under `soc/${ARCH}/` and this could be the root cause in your case.

Looking again at the code, I suspect you have your SoCs located directly under:

```

${YOUR_PRIVATE_REPO}/soc/your_soc

```

If you can move your SoC into an `${ARCH}` folder, for example:

```

${YOUR_PRIVATE_REPO}/soc/arm/your_soc

```

Then things should work again.

 

If your repo is defined as a Zephyr module, you even have the possibility of adding this into the nodule.yml file:

https://docs.zephyrproject.org/latest/guides/modules.html#build-settings

 

Best regards

 

Torsten

 

From: Dan Kalowsky <dank@...>
Sent: 6 August, 2020 20:04
To: Cufi, Carles <Carles.Cufi@...>
Cc: devel@...; Rasmussen, Torsten <Torsten.Rasmussen@...>
Subject: Re: [Zephyr-devel] SOC_DIR not populated

 

Charles,

 

Thanks for the prompt response.  Do please keep me CC'd on this as I am not on the mailing list. 

 

Torsten the longer version might provide some background context for the debug.  Happy to help where I can.

 

 

On Thu, Aug 6, 2020 at 10:40 AM Cufi, Carles <Carles.Cufi@...> wrote:

Hi Dan,

 

Assuming you have the latest upstream master, then this might be a regression introduced by:

https://github.com/zephyrproject-rtos/zephyr/pull/26715

 

We are certainly not dropping support for out-of-tree SoCs, in fact we just discussed this recently with Torsten (on copy). He should be able to give more info on the subject.

 

Thanks,

 

Carles

 

From: devel@... <devel@...> On Behalf Of Dan Kalowsky via lists.zephyrproject.org
Sent: 06 August 2020 19:19
To: devel@...
Subject: [Zephyr-devel] SOC_DIR not populated

 

Hey Zephyr team,

 

Long time no talk.

 

Short version:  Using the latest HEAD, I am finding that the kconfig SOC_DIR is not being populated for an out of tree SOC build.  This causes a compilation failure and makes everyone a sad panda.  As this was something that worked perfectly in 2.3 (and for the most part earlier), I was a little surprised to see this no longer working on HEAD.  Was it intentional to remove support for out of tree SOCs, or is this an oversight?  I could not find any documentation supporting either statement in the mailing list or meeting minutes.

 

Longer version:

 

I have a Zephyr application with a lot of out of tree pieces.  It kind of looks like the following simplified layout:

 

application/

- board/

- soc/

-- Kconfig

-- arm/

--- product/

--- Kconfig

--- Kconfig.defconfig

--- Kconfig.soc

--- CMakeLists.txt

---- soc_a/

---- soc_b/

- dts/

- src/

zephyr/

modules/

 

Overall this has worked great in 2.3 (and was functional in 2.2 with some fixes).  Given some of the recent work by Andrew and Tomasz (thanks and hi btw) I was motivated to upgrade to HEAD.  At this point, while building I get informed that the path $(SOC_DIR)/$(ARCH) has some unset variables, which causes the initial setup for cmake/kconfig to fail.  Sure enough, there are empty variables being used.  While investigating, it looks like the current HEAD has three issues for out of tree SOC usage, but I've only been able to "resolve" two of them.  Almost all of it seems to have originated from commit 5f7cc8ded9138b773012b9ffedc744b9475927db.

 

Issues found:

1) The file cmake/kconfig.cmake no longer sets up to export the SOC_DIR as it used to.  Thus when setting a custom SOC_DIR, nothing is there for the python script to add.  Adding back lines 44 and 88 solves the variables now being set, although the value of SOC_DIR is still nil.  You will need to resolve issue 2 as well to finish this fix.

 

2) The file cmake/app/boilerplate.cmake has relocated lines of code that set the SOC_DIR variable to a after a section of code that has requirements for them to be set.  Specifically the chunk at 527-541 needs to happen BEFORE the inclusion of kconfig.cmake on line 515.  It is not clear why these lines were moved from the commit or Pull Request, but it does expose a dependency chain that does not seem to be tested/validated in the scripts.  Moving this section alone is not enough, you still need issue 1 resolved for the variables to show up in the kconfig.py script.

 

3) Even with these changes, which allow me to get further along the compile, there is still one last issue I have not been able to rootcause.   I end up seeing the following error, which appears to munge some of the path:

CMake Error at /home/dkalowsky/product_dev/zephyr/CMakeLists.txt:376 (message):
  Could not find linker script:
  '/home/dkalowsky/product_dev/application/soc/arm//linker.ld'.

 

Note the // before linker.ld. 

 

Which brings us to the questions part...

 

Is Zephyr looking to drop out of tree SOC?  I certainly hope not, but some of the change directions in the commit above give a bit of concern that it might be true.  Note this is tea leaf reading, and I am bad at it.

If not, is there a new layout that should be utilized for out of tree SOC usage?  The documentation still points to the previously existing behavior as being correct.  If it is changing, is there a document that I can reference to update my local application?

If this is all oversight and just bugs, any ideas on what could be causing issue 3?

 

 


--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."



--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."


Rasmussen, Torsten
 

Note, I will also look into a fix that allows out of tree socs to be located directly under the `${SOC_ROOT}/soc` folder.

 

/torsten

 

From: devel@... <devel@...> On Behalf Of Rasmussen, Torsten via lists.zephyrproject.org
Sent: 6 August, 2020 20:49
To: Dan Kalowsky <dank@...>; Cufi, Carles <Carles.Cufi@...>
Cc: devel@...
Subject: Re: [Zephyr-devel] SOC_DIR not populated

 

Hi Dan,

 

Sorry for any trouble the latest changes is causing you.

With https://github.com/zephyrproject-rtos/zephyr/pull/26715 it is now possible to provide multiple SoC roots, allowing for greater flexibility.

 

This can be seen here:

https://github.com/zephyrproject-rtos/zephyr/blob/master/cmake/app/boilerplate.cmake#L543-L548

 

and as you see, the `SOC_DIR` is still populated, but because there can only be a single SOC_DIR, we need to decide on the correct SOC_DIR to use.
To do so, we check for the existence of the SoC under its corresponding arch.

 

All SoCs in Zephyr are grouped under `soc/${ARCH}/` and this could be the root cause in your case.

Looking again at the code, I suspect you have your SoCs located directly under:

```

${YOUR_PRIVATE_REPO}/soc/your_soc

```

If you can move your SoC into an `${ARCH}` folder, for example:

```

${YOUR_PRIVATE_REPO}/soc/arm/your_soc

```

Then things should work again.

 

If your repo is defined as a Zephyr module, you even have the possibility of adding this into the nodule.yml file:

https://docs.zephyrproject.org/latest/guides/modules.html#build-settings

 

Best regards

 

Torsten

 

From: Dan Kalowsky <dank@...>
Sent: 6 August, 2020 20:04
To: Cufi, Carles <Carles.Cufi@...>
Cc: devel@...; Rasmussen, Torsten <Torsten.Rasmussen@...>
Subject: Re: [Zephyr-devel] SOC_DIR not populated

 

Charles,

 

Thanks for the prompt response.  Do please keep me CC'd on this as I am not on the mailing list. 

 

Torsten the longer version might provide some background context for the debug.  Happy to help where I can.

 

 

On Thu, Aug 6, 2020 at 10:40 AM Cufi, Carles <Carles.Cufi@...> wrote:

Hi Dan,

 

Assuming you have the latest upstream master, then this might be a regression introduced by:

https://github.com/zephyrproject-rtos/zephyr/pull/26715

 

We are certainly not dropping support for out-of-tree SoCs, in fact we just discussed this recently with Torsten (on copy). He should be able to give more info on the subject.

 

Thanks,

 

Carles

 

From: devel@... <devel@...> On Behalf Of Dan Kalowsky via lists.zephyrproject.org
Sent: 06 August 2020 19:19
To: devel@...
Subject: [Zephyr-devel] SOC_DIR not populated

 

Hey Zephyr team,

 

Long time no talk.

 

Short version:  Using the latest HEAD, I am finding that the kconfig SOC_DIR is not being populated for an out of tree SOC build.  This causes a compilation failure and makes everyone a sad panda.  As this was something that worked perfectly in 2.3 (and for the most part earlier), I was a little surprised to see this no longer working on HEAD.  Was it intentional to remove support for out of tree SOCs, or is this an oversight?  I could not find any documentation supporting either statement in the mailing list or meeting minutes.

 

Longer version:

 

I have a Zephyr application with a lot of out of tree pieces.  It kind of looks like the following simplified layout:

 

application/

- board/

- soc/

-- Kconfig

-- arm/

--- product/

--- Kconfig

--- Kconfig.defconfig

--- Kconfig.soc

--- CMakeLists.txt

---- soc_a/

---- soc_b/

- dts/

- src/

zephyr/

modules/

 

Overall this has worked great in 2.3 (and was functional in 2.2 with some fixes).  Given some of the recent work by Andrew and Tomasz (thanks and hi btw) I was motivated to upgrade to HEAD.  At this point, while building I get informed that the path $(SOC_DIR)/$(ARCH) has some unset variables, which causes the initial setup for cmake/kconfig to fail.  Sure enough, there are empty variables being used.  While investigating, it looks like the current HEAD has three issues for out of tree SOC usage, but I've only been able to "resolve" two of them.  Almost all of it seems to have originated from commit 5f7cc8ded9138b773012b9ffedc744b9475927db.

 

Issues found:

1) The file cmake/kconfig.cmake no longer sets up to export the SOC_DIR as it used to.  Thus when setting a custom SOC_DIR, nothing is there for the python script to add.  Adding back lines 44 and 88 solves the variables now being set, although the value of SOC_DIR is still nil.  You will need to resolve issue 2 as well to finish this fix.

 

2) The file cmake/app/boilerplate.cmake has relocated lines of code that set the SOC_DIR variable to a after a section of code that has requirements for them to be set.  Specifically the chunk at 527-541 needs to happen BEFORE the inclusion of kconfig.cmake on line 515.  It is not clear why these lines were moved from the commit or Pull Request, but it does expose a dependency chain that does not seem to be tested/validated in the scripts.  Moving this section alone is not enough, you still need issue 1 resolved for the variables to show up in the kconfig.py script.

 

3) Even with these changes, which allow me to get further along the compile, there is still one last issue I have not been able to rootcause.   I end up seeing the following error, which appears to munge some of the path:

CMake Error at /home/dkalowsky/product_dev/zephyr/CMakeLists.txt:376 (message):
  Could not find linker script:
  '/home/dkalowsky/product_dev/application/soc/arm//linker.ld'.

 

Note the // before linker.ld. 

 

Which brings us to the questions part...

 

Is Zephyr looking to drop out of tree SOC?  I certainly hope not, but some of the change directions in the commit above give a bit of concern that it might be true.  Note this is tea leaf reading, and I am bad at it.

If not, is there a new layout that should be utilized for out of tree SOC usage?  The documentation still points to the previously existing behavior as being correct.  If it is changing, is there a document that I can reference to update my local application?

If this is all oversight and just bugs, any ideas on what could be causing issue 3?

 

 


--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."

 



--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."


Rasmussen, Torsten
 

Hi,

 

> Please re-read the original message.  You have a hidden dependency that has been overlooked that causes completely out of tree SOCs to not work.  The setup works fine for in-tree and within the Zephyr source SOCs because of other assumptions in the code.

 

Seems I was a bit too fast I my reply.

 

 

The SOC_DIR shall no longer be exported to Kconfig, cause when Kconfig is executed the first time, then we need ALL soc roots present.

Otherwise we cannot decide the correct SOC to use for the given board.

 

Thus, a Kconfig file is generated at the build directory here:

https://github.com/zephyrproject-rtos/zephyr/blob/master/cmake/kconfig.cmake#L9-L22

 

and then sourced into Kconfig here:

https://github.com/zephyrproject-rtos/zephyr/blob/master/soc/Kconfig#L6

https://github.com/zephyrproject-rtos/zephyr/blob/master/soc/Kconfig#L11

 

So the `SOC_DIR` must no longer be exported cause Kconfig cannot hanled a list of dirs..

This is the reason for generating Kconfig files that can then be sourced into Kconfig.

 

Could you verify the content of:

${CMAKE_BINARY_DIR}/Kconfig/Kconfig.soc.defconfig

${CMAKE_BINARY_DIR}/Kconfig/Kconfig.soc

${CMAKE_BINARY_DIR}/Kconfig/Kconfig.soc.arch

 

One question:

> Thus when setting a custom SOC_DIR

 

Are you setting the `SOC_DIR` yourself ?

The `SOC_DIR` is for the Zephyr build system, the correct way to do this is to set `SOC_ROOT` as described:

https://docs.zephyrproject.org/latest/application/index.html#soc-definitions

 

as: `cmake -DSOC_ROOT=<path> ….`

 

 

/torsten

 

From: Dan Kalowsky <dank@...>
Sent: 6 August, 2020 21:20
To: Rasmussen, Torsten <Torsten.Rasmussen@...>
Cc: Cufi, Carles <Carles.Cufi@...>; devel@...
Subject: Re: [Zephyr-devel] SOC_DIR not populated

 

Torsten,

 

 

On Thu, Aug 6, 2020 at 11:48 AM Rasmussen, Torsten <Torsten.Rasmussen@...> wrote:

Hi Dan,

 

Sorry for any trouble the latest changes is causing you.

With https://github.com/zephyrproject-rtos/zephyr/pull/26715 it is now possible to provide multiple SoC roots, allowing for greater flexibility.

 

Please re-read the original message.  You have a hidden dependency that has been overlooked that causes completely out of tree SOCs to not work.  The setup works fine for in-tree and within the Zephyr source SOCs because of other assumptions in the code.

 

 

and as you see, the `SOC_DIR` is still populated, but because there can only be a single SOC_DIR, we need to decide on the correct SOC_DIR to use.
To do so, we check for the existence of the SoC under its corresponding arch.

 

All SoCs in Zephyr are grouped under `soc/${ARCH}/` and this could be the root cause in your case.

Looking again at the code, I suspect you have your SoCs located directly under:

```

${YOUR_PRIVATE_REPO}/soc/your_soc

```

If you can move your SoC into an `${ARCH}` folder, for example:

```

${YOUR_PRIVATE_REPO}/soc/arm/your_soc

```

Then things should work again.

 

 

Again, I will encourage you to re-read the original message.  The layout you are requesting to be followed is what has been followed.

 

 

 

If your repo is defined as a Zephyr module, you even have the possibility of adding this into the nodule.yml file:

https://docs.zephyrproject.org/latest/guides/modules.html#build-settings

 

The values of *_ROOT are all defined in cmake variables.  They have been confirmed to be correctly populated via calls to cmake messages() at the first time of parsing in the boilerplate.cmake file.  If we can focus more on why SOC_DIR is not populated at the time of consumption by kconfig.cmake it would be appreciated. 

 

 

Best regards

 

Torsten

 

From: Dan Kalowsky <dank@...>
Sent: 6 August, 2020 20:04
To: Cufi, Carles <Carles.Cufi@...>
Cc: devel@...; Rasmussen, Torsten <Torsten.Rasmussen@...>
Subject: Re: [Zephyr-devel] SOC_DIR not populated

 

Charles,

 

Thanks for the prompt response.  Do please keep me CC'd on this as I am not on the mailing list. 

 

Torsten the longer version might provide some background context for the debug.  Happy to help where I can.

 

 

On Thu, Aug 6, 2020 at 10:40 AM Cufi, Carles <Carles.Cufi@...> wrote:

Hi Dan,

 

Assuming you have the latest upstream master, then this might be a regression introduced by:

https://github.com/zephyrproject-rtos/zephyr/pull/26715

 

We are certainly not dropping support for out-of-tree SoCs, in fact we just discussed this recently with Torsten (on copy). He should be able to give more info on the subject.

 

Thanks,

 

Carles

 

From: devel@... <devel@...> On Behalf Of Dan Kalowsky via lists.zephyrproject.org
Sent: 06 August 2020 19:19
To: devel@...
Subject: [Zephyr-devel] SOC_DIR not populated

 

Hey Zephyr team,

 

Long time no talk.

 

Short version:  Using the latest HEAD, I am finding that the kconfig SOC_DIR is not being populated for an out of tree SOC build.  This causes a compilation failure and makes everyone a sad panda.  As this was something that worked perfectly in 2.3 (and for the most part earlier), I was a little surprised to see this no longer working on HEAD.  Was it intentional to remove support for out of tree SOCs, or is this an oversight?  I could not find any documentation supporting either statement in the mailing list or meeting minutes.

 

Longer version:

 

I have a Zephyr application with a lot of out of tree pieces.  It kind of looks like the following simplified layout:

 

application/

- board/

- soc/

-- Kconfig

-- arm/

--- product/

--- Kconfig

--- Kconfig.defconfig

--- Kconfig.soc

--- CMakeLists.txt

---- soc_a/

---- soc_b/

- dts/

- src/

zephyr/

modules/

 

Overall this has worked great in 2.3 (and was functional in 2.2 with some fixes).  Given some of the recent work by Andrew and Tomasz (thanks and hi btw) I was motivated to upgrade to HEAD.  At this point, while building I get informed that the path $(SOC_DIR)/$(ARCH) has some unset variables, which causes the initial setup for cmake/kconfig to fail.  Sure enough, there are empty variables being used.  While investigating, it looks like the current HEAD has three issues for out of tree SOC usage, but I've only been able to "resolve" two of them.  Almost all of it seems to have originated from commit 5f7cc8ded9138b773012b9ffedc744b9475927db.

 

Issues found:

1) The file cmake/kconfig.cmake no longer sets up to export the SOC_DIR as it used to.  Thus when setting a custom SOC_DIR, nothing is there for the python script to add.  Adding back lines 44 and 88 solves the variables now being set, although the value of SOC_DIR is still nil.  You will need to resolve issue 2 as well to finish this fix.

 

2) The file cmake/app/boilerplate.cmake has relocated lines of code that set the SOC_DIR variable to a after a section of code that has requirements for them to be set.  Specifically the chunk at 527-541 needs to happen BEFORE the inclusion of kconfig.cmake on line 515.  It is not clear why these lines were moved from the commit or Pull Request, but it does expose a dependency chain that does not seem to be tested/validated in the scripts.  Moving this section alone is not enough, you still need issue 1 resolved for the variables to show up in the kconfig.py script.

 

3) Even with these changes, which allow me to get further along the compile, there is still one last issue I have not been able to rootcause.   I end up seeing the following error, which appears to munge some of the path:

CMake Error at /home/dkalowsky/product_dev/zephyr/CMakeLists.txt:376 (message):
  Could not find linker script:
  '/home/dkalowsky/product_dev/application/soc/arm//linker.ld'.

 

Note the // before linker.ld. 

 

Which brings us to the questions part...

 

Is Zephyr looking to drop out of tree SOC?  I certainly hope not, but some of the change directions in the commit above give a bit of concern that it might be true.  Note this is tea leaf reading, and I am bad at it.

If not, is there a new layout that should be utilized for out of tree SOC usage?  The documentation still points to the previously existing behavior as being correct.  If it is changing, is there a document that I can reference to update my local application?

If this is all oversight and just bugs, any ideas on what could be causing issue 3?

 

 


--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."



--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."



--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."


Dan Kalowsky <dank@...>
 

Charles,

Thanks for the prompt response.  Do please keep me CC'd on this as I am not on the mailing list. 

Torsten the longer version might provide some background context for the debug.  Happy to help where I can.


On Thu, Aug 6, 2020 at 10:40 AM Cufi, Carles <Carles.Cufi@...> wrote:

Hi Dan,

 

Assuming you have the latest upstream master, then this might be a regression introduced by:

https://github.com/zephyrproject-rtos/zephyr/pull/26715

 

We are certainly not dropping support for out-of-tree SoCs, in fact we just discussed this recently with Torsten (on copy). He should be able to give more info on the subject.

 

Thanks,

 

Carles

 

From: devel@... <devel@...> On Behalf Of Dan Kalowsky via lists.zephyrproject.org
Sent: 06 August 2020 19:19
To: devel@...
Subject: [Zephyr-devel] SOC_DIR not populated

 

Hey Zephyr team,

 

Long time no talk.

 

Short version:  Using the latest HEAD, I am finding that the kconfig SOC_DIR is not being populated for an out of tree SOC build.  This causes a compilation failure and makes everyone a sad panda.  As this was something that worked perfectly in 2.3 (and for the most part earlier), I was a little surprised to see this no longer working on HEAD.  Was it intentional to remove support for out of tree SOCs, or is this an oversight?  I could not find any documentation supporting either statement in the mailing list or meeting minutes.

 

Longer version:

 

I have a Zephyr application with a lot of out of tree pieces.  It kind of looks like the following simplified layout:

 

application/

- board/

- soc/

-- Kconfig

-- arm/

--- product/

--- Kconfig

--- Kconfig.defconfig

--- Kconfig.soc

--- CMakeLists.txt

---- soc_a/

---- soc_b/

- dts/

- src/

zephyr/

modules/

 

Overall this has worked great in 2.3 (and was functional in 2.2 with some fixes).  Given some of the recent work by Andrew and Tomasz (thanks and hi btw) I was motivated to upgrade to HEAD.  At this point, while building I get informed that the path $(SOC_DIR)/$(ARCH) has some unset variables, which causes the initial setup for cmake/kconfig to fail.  Sure enough, there are empty variables being used.  While investigating, it looks like the current HEAD has three issues for out of tree SOC usage, but I've only been able to "resolve" two of them.  Almost all of it seems to have originated from commit 5f7cc8ded9138b773012b9ffedc744b9475927db.

 

Issues found:

1) The file cmake/kconfig.cmake no longer sets up to export the SOC_DIR as it used to.  Thus when setting a custom SOC_DIR, nothing is there for the python script to add.  Adding back lines 44 and 88 solves the variables now being set, although the value of SOC_DIR is still nil.  You will need to resolve issue 2 as well to finish this fix.

 

2) The file cmake/app/boilerplate.cmake has relocated lines of code that set the SOC_DIR variable to a after a section of code that has requirements for them to be set.  Specifically the chunk at 527-541 needs to happen BEFORE the inclusion of kconfig.cmake on line 515.  It is not clear why these lines were moved from the commit or Pull Request, but it does expose a dependency chain that does not seem to be tested/validated in the scripts.  Moving this section alone is not enough, you still need issue 1 resolved for the variables to show up in the kconfig.py script.

 

3) Even with these changes, which allow me to get further along the compile, there is still one last issue I have not been able to rootcause.   I end up seeing the following error, which appears to munge some of the path:

CMake Error at /home/dkalowsky/product_dev/zephyr/CMakeLists.txt:376 (message):
  Could not find linker script:
  '/home/dkalowsky/product_dev/application/soc/arm//linker.ld'.

 

Note the // before linker.ld. 

 

Which brings us to the questions part...

 

Is Zephyr looking to drop out of tree SOC?  I certainly hope not, but some of the change directions in the commit above give a bit of concern that it might be true.  Note this is tea leaf reading, and I am bad at it.

If not, is there a new layout that should be utilized for out of tree SOC usage?  The documentation still points to the previously existing behavior as being correct.  If it is changing, is there a document that I can reference to update my local application?

If this is all oversight and just bugs, any ideas on what could be causing issue 3?

 

 


--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."



--
"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."


Dan Kalowsky <dank@...>
 

Torsten,


On Thu, Aug 6, 2020 at 11:48 AM Rasmussen, Torsten <Torsten.Rasmussen@...> wrote:

Hi Dan,

 

Sorry for any trouble the latest changes is causing you.

With https://github.com/zephyrproject-rtos/zephyr/pull/26715 it is now possible to provide multiple SoC roots, allowing for greater flexibility.


Please re-read the original message.  You have a hidden dependency that has been overlooked that causes completely out of tree SOCs to not work.  The setup works fine for in-tree and within the Zephyr source SOCs because of other assumptions in the code.

 

and as you see, the `SOC_DIR` is still populated, but because there can only be a single SOC_DIR, we need to decide on the correct SOC_DIR to use.
To do so, we check for the existence of the SoC under its corresponding arch.

 

All SoCs in Zephyr are grouped under `soc/${ARCH}/` and this could be the root cause in your case.

Looking again at the code, I suspect you have your SoCs located directly under:

```

${YOUR_PRIVATE_REPO}/soc/your_soc

```

If you can move your SoC into an `${ARCH}` folder, for example:

```

${YOUR_PRIVATE_REPO}/soc/arm/your_soc

```

Then things should work again.



Again, I will encourage you to re-read the original message.  The layout you are requesting to be followed is what has been followed.

 

 

If your repo is defined as a Zephyr module, you even have the possibility of adding this into the nodule.yml file:

https://docs.zephyrproject.org/latest/guides/modules.html#build-settings


The values of *_ROOT are all defined in cmake variables.  They have been confirmed to be correctly populated via calls to cmake messages() at the first time of parsing in the boilerplate.cmake file.  If we can focus more on why SOC_DIR is not populated at the time of consumption by kconfig.cmake it would be appreciated. 

 

Best regards

 

Torsten

 

From: Dan Kalowsky <dank@...>
Sent: 6 August, 2020 20:04
To: Cufi, Carles <Carles.Cufi@...>
Cc: devel@...; Rasmussen, Torsten <Torsten.Rasmussen@...>
Subject: Re: [Zephyr-devel] SOC_DIR not populated

 

Charles,

 

Thanks for the prompt response.  Do please keep me CC'd on this as I am not on the mailing list. 

 

Torsten the longer version might provide some background context for the debug.  Happy to help where I can.

 

 

On Thu, Aug 6, 2020 at 10:40 AM Cufi, Carles <Carles.Cufi@...> wrote:

Hi Dan,

 

Assuming you have the latest upstream master, then this might be a regression introduced by:

https://github.com/zephyrproject-rtos/zephyr/pull/26715

 

We are certainly not dropping support for out-of-tree SoCs, in fact we just discussed this recently with Torsten (on copy). He should be able to give more info on the subject.

 

Thanks,

 

Carles

 

From: devel@... <devel@...> On Behalf Of Dan Kalowsky via lists.zephyrproject.org
Sent: 06 August 2020 19:19
To: devel@...
Subject: [Zephyr-devel] SOC_DIR not populated

 

Hey Zephyr team,

 

Long time no talk.

 

Short version:  Using the latest HEAD, I am finding that the kconfig SOC_DIR is not being populated for an out of tree SOC build.  This causes a compilation failure and makes everyone a sad panda.  As this was something that worked perfectly in 2.3 (and for the most part earlier), I was a little surprised to see this no longer working on HEAD.  Was it intentional to remove support for out of tree SOCs, or is this an oversight?  I could not find any documentation supporting either statement in the mailing list or meeting minutes.

 

Longer version:

 

I have a Zephyr application with a lot of out of tree pieces.  It kind of looks like the following simplified layout:

 

application/

- board/

- soc/

-- Kconfig

-- arm/

--- product/

--- Kconfig

--- Kconfig.defconfig

--- Kconfig.soc

--- CMakeLists.txt

---- soc_a/

---- soc_b/

- dts/

- src/

zephyr/

modules/

 

Overall this has worked great in 2.3 (and was functional in 2.2 with some fixes).  Given some of the recent work by Andrew and Tomasz (thanks and hi btw) I was motivated to upgrade to HEAD.  At this point, while building I get informed that the path $(SOC_DIR)/$(ARCH) has some unset variables, which causes the initial setup for cmake/kconfig to fail.  Sure enough, there are empty variables being used.  While investigating, it looks like the current HEAD has three issues for out of tree SOC usage, but I've only been able to "resolve" two of them.  Almost all of it seems to have originated from commit 5f7cc8ded9138b773012b9ffedc744b9475927db.

 

Issues found:

1) The file cmake/kconfig.cmake no longer sets up to export the SOC_DIR as it used to.  Thus when setting a custom SOC_DIR, nothing is there for the python script to add.  Adding back lines 44 and 88 solves the variables now being set, although the value of SOC_DIR is still nil.  You will need to resolve issue 2 as well to finish this fix.

 

2) The file cmake/app/boilerplate.cmake has relocated lines of code that set the SOC_DIR variable to a after a section of code that has requirements for them to be set.  Specifically the chunk at 527-541 needs to happen BEFORE the inclusion of kconfig.cmake on line 515.  It is not clear why these lines were moved from the commit or Pull Request, but it does expose a dependency chain that does not seem to be tested/validated in the scripts.  Moving this section alone is not enough, you still need issue 1 resolved for the variables to show up in the kconfig.py script.

 

3) Even with these changes, which allow me to get further along the compile, there is still one last issue I have not been able to rootcause.   I end up seeing the following error, which appears to munge some of the path:

CMake Error at /home/dkalowsky/product_dev/zephyr/CMakeLists.txt:376 (message):
  Could not find linker script:
  '/home/dkalowsky/product_dev/application/soc/arm//linker.ld'.

 

Note the // before linker.ld. 

 

Which brings us to the questions part...

 

Is Zephyr looking to drop out of tree SOC?  I certainly hope not, but some of the change directions in the commit above give a bit of concern that it might be true.  Note this is tea leaf reading, and I am bad at it.

If not, is there a new layout that should be utilized for out of tree SOC usage?  The documentation still points to the previously existing behavior as being correct.  If it is changing, is there a document that I can reference to update my local application?

If this is all oversight and just bugs, any ideas on what could be causing issue 3?

 

 


--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."



--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."



--
"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."


Rasmussen, Torsten
 

Hi,

 

I have retested the functionality by relocating SoCs from ${ZEPHYR_BASE}/soc into modules, and this worked as expected.

Both when using `zephyr/module.yml` and `-DSOC_ROOT=<path>`.

 

So I took one more look at your folder structure and compared to the code, and I noticed you wrote:

--- product/

--- Kconfig

--- Kconfig.defconfig

--- Kconfig.soc

I notice that both the folder `product` and the files Kconfig.* has `---` (3) dashes in front of them, so I just want to verify that those files are located in the `product` dir and not directly in `arm` dir ?

 

If they are placed directly in the `arm` dir, then that could explain the behavior, due to this:

osource \"${root}/soc/$(ARCH)/*/Kconfig.defconfig

 

where you see it will source the files one folder further down from the arch folder.

 

/torsten

 

 

 

 

From: devel@... <devel@...> On Behalf Of Rasmussen, Torsten via lists.zephyrproject.org
Sent: 6 August, 2020 21:46
To: Dan Kalowsky <dank@...>
Cc: Cufi, Carles <Carles.Cufi@...>; devel@...
Subject: Re: [Zephyr-devel] SOC_DIR not populated

 

Hi,

 

> Please re-read the original message.  You have a hidden dependency that has been overlooked that causes completely out of tree SOCs to not work.  The setup works fine for in-tree and within the Zephyr source SOCs because of other assumptions in the code.

 

Seems I was a bit too fast I my reply.

 

 

The SOC_DIR shall no longer be exported to Kconfig, cause when Kconfig is executed the first time, then we need ALL soc roots present.

Otherwise we cannot decide the correct SOC to use for the given board.

 

Thus, a Kconfig file is generated at the build directory here:

https://github.com/zephyrproject-rtos/zephyr/blob/master/cmake/kconfig.cmake#L9-L22

 

and then sourced into Kconfig here:

https://github.com/zephyrproject-rtos/zephyr/blob/master/soc/Kconfig#L6

https://github.com/zephyrproject-rtos/zephyr/blob/master/soc/Kconfig#L11

 

So the `SOC_DIR` must no longer be exported cause Kconfig cannot hanled a list of dirs..

This is the reason for generating Kconfig files that can then be sourced into Kconfig.

 

Could you verify the content of:

${CMAKE_BINARY_DIR}/Kconfig/Kconfig.soc.defconfig

${CMAKE_BINARY_DIR}/Kconfig/Kconfig.soc

${CMAKE_BINARY_DIR}/Kconfig/Kconfig.soc.arch

 

One question:

> Thus when setting a custom SOC_DIR

 

Are you setting the `SOC_DIR` yourself ?

The `SOC_DIR` is for the Zephyr build system, the correct way to do this is to set `SOC_ROOT` as described:

https://docs.zephyrproject.org/latest/application/index.html#soc-definitions

 

as: `cmake -DSOC_ROOT=<path> ….`

 

 

/torsten

 

From: Dan Kalowsky <dank@...>
Sent: 6 August, 2020 21:20
To: Rasmussen, Torsten <Torsten.Rasmussen@...>
Cc: Cufi, Carles <Carles.Cufi@...>; devel@...
Subject: Re: [Zephyr-devel] SOC_DIR not populated

 

Torsten,

 

 

On Thu, Aug 6, 2020 at 11:48 AM Rasmussen, Torsten <Torsten.Rasmussen@...> wrote:

Hi Dan,

 

Sorry for any trouble the latest changes is causing you.

With https://github.com/zephyrproject-rtos/zephyr/pull/26715 it is now possible to provide multiple SoC roots, allowing for greater flexibility.

 

Please re-read the original message.  You have a hidden dependency that has been overlooked that causes completely out of tree SOCs to not work.  The setup works fine for in-tree and within the Zephyr source SOCs because of other assumptions in the code.

 

 

and as you see, the `SOC_DIR` is still populated, but because there can only be a single SOC_DIR, we need to decide on the correct SOC_DIR to use.
To do so, we check for the existence of the SoC under its corresponding arch.

 

All SoCs in Zephyr are grouped under `soc/${ARCH}/` and this could be the root cause in your case.

Looking again at the code, I suspect you have your SoCs located directly under:

```

${YOUR_PRIVATE_REPO}/soc/your_soc

```

If you can move your SoC into an `${ARCH}` folder, for example:

```

${YOUR_PRIVATE_REPO}/soc/arm/your_soc

```

Then things should work again.

 

 

Again, I will encourage you to re-read the original message.  The layout you are requesting to be followed is what has been followed.

 

 

 

If your repo is defined as a Zephyr module, you even have the possibility of adding this into the nodule.yml file:

https://docs.zephyrproject.org/latest/guides/modules.html#build-settings

 

The values of *_ROOT are all defined in cmake variables.  They have been confirmed to be correctly populated via calls to cmake messages() at the first time of parsing in the boilerplate.cmake file.  If we can focus more on why SOC_DIR is not populated at the time of consumption by kconfig.cmake it would be appreciated. 

 

 

Best regards

 

Torsten

 

From: Dan Kalowsky <dank@...>
Sent: 6 August, 2020 20:04
To: Cufi, Carles <Carles.Cufi@...>
Cc: devel@...; Rasmussen, Torsten <Torsten.Rasmussen@...>
Subject: Re: [Zephyr-devel] SOC_DIR not populated

 

Charles,

 

Thanks for the prompt response.  Do please keep me CC'd on this as I am not on the mailing list. 

 

Torsten the longer version might provide some background context for the debug.  Happy to help where I can.

 

 

On Thu, Aug 6, 2020 at 10:40 AM Cufi, Carles <Carles.Cufi@...> wrote:

Hi Dan,

 

Assuming you have the latest upstream master, then this might be a regression introduced by:

https://github.com/zephyrproject-rtos/zephyr/pull/26715

 

We are certainly not dropping support for out-of-tree SoCs, in fact we just discussed this recently with Torsten (on copy). He should be able to give more info on the subject.

 

Thanks,

 

Carles

 

From: devel@... <devel@...> On Behalf Of Dan Kalowsky via lists.zephyrproject.org
Sent: 06 August 2020 19:19
To: devel@...
Subject: [Zephyr-devel] SOC_DIR not populated

 

Hey Zephyr team,

 

Long time no talk.

 

Short version:  Using the latest HEAD, I am finding that the kconfig SOC_DIR is not being populated for an out of tree SOC build.  This causes a compilation failure and makes everyone a sad panda.  As this was something that worked perfectly in 2.3 (and for the most part earlier), I was a little surprised to see this no longer working on HEAD.  Was it intentional to remove support for out of tree SOCs, or is this an oversight?  I could not find any documentation supporting either statement in the mailing list or meeting minutes.

 

Longer version:

 

I have a Zephyr application with a lot of out of tree pieces.  It kind of looks like the following simplified layout:

 

application/

- board/

- soc/

-- Kconfig

-- arm/

--- product/

--- Kconfig

--- Kconfig.defconfig

--- Kconfig.soc

--- CMakeLists.txt

---- soc_a/

---- soc_b/

- dts/

- src/

zephyr/

modules/

 

Overall this has worked great in 2.3 (and was functional in 2.2 with some fixes).  Given some of the recent work by Andrew and Tomasz (thanks and hi btw) I was motivated to upgrade to HEAD.  At this point, while building I get informed that the path $(SOC_DIR)/$(ARCH) has some unset variables, which causes the initial setup for cmake/kconfig to fail.  Sure enough, there are empty variables being used.  While investigating, it looks like the current HEAD has three issues for out of tree SOC usage, but I've only been able to "resolve" two of them.  Almost all of it seems to have originated from commit 5f7cc8ded9138b773012b9ffedc744b9475927db.

 

Issues found:

1) The file cmake/kconfig.cmake no longer sets up to export the SOC_DIR as it used to.  Thus when setting a custom SOC_DIR, nothing is there for the python script to add.  Adding back lines 44 and 88 solves the variables now being set, although the value of SOC_DIR is still nil.  You will need to resolve issue 2 as well to finish this fix.

 

2) The file cmake/app/boilerplate.cmake has relocated lines of code that set the SOC_DIR variable to a after a section of code that has requirements for them to be set.  Specifically the chunk at 527-541 needs to happen BEFORE the inclusion of kconfig.cmake on line 515.  It is not clear why these lines were moved from the commit or Pull Request, but it does expose a dependency chain that does not seem to be tested/validated in the scripts.  Moving this section alone is not enough, you still need issue 1 resolved for the variables to show up in the kconfig.py script.

 

3) Even with these changes, which allow me to get further along the compile, there is still one last issue I have not been able to rootcause.   I end up seeing the following error, which appears to munge some of the path:

CMake Error at /home/dkalowsky/product_dev/zephyr/CMakeLists.txt:376 (message):
  Could not find linker script:
  '/home/dkalowsky/product_dev/application/soc/arm//linker.ld'.

 

Note the // before linker.ld. 

 

Which brings us to the questions part...

 

Is Zephyr looking to drop out of tree SOC?  I certainly hope not, but some of the change directions in the commit above give a bit of concern that it might be true.  Note this is tea leaf reading, and I am bad at it.

If not, is there a new layout that should be utilized for out of tree SOC usage?  The documentation still points to the previously existing behavior as being correct.  If it is changing, is there a document that I can reference to update my local application?

If this is all oversight and just bugs, any ideas on what could be causing issue 3?

 

 


--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."

 



--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."



--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."


Dan Kalowsky <dank@...>
 

Trying to respond to both replies in the same email here...

On Thu, Aug 6, 2020 at 1:44 PM Rasmussen, Torsten <Torsten.Rasmussen@...> wrote:

Hi,

 

I have retested the functionality by relocating SoCs from ${ZEPHYR_BASE}/soc into modules, and this worked as expected.

Both when using `zephyr/module.yml` and `-DSOC_ROOT=<path>`.

 

So I took one more look at your folder structure and compared to the code, and I noticed you wrote:

--- product/

--- Kconfig

--- Kconfig.defconfig

--- Kconfig.soc

I notice that both the folder `product` and the files Kconfig.* has `---` (3) dashes in front of them, so I just want to verify that those files are located in the `product` dir and not directly in `arm` dir ?


Sorry if the crudely generated ascii art was not clear enough.  The Kconfig* files are in the product directory.
 

 

> Please re-read the original message.  You have a hidden dependency that has been overlooked that causes completely out of tree SOCs to not work.  The setup works fine for in-tree and within the Zephyr source SOCs because of other assumptions in the code.

 

Seems I was a bit too fast I my reply.

 

 

The SOC_DIR shall no longer be exported to Kconfig, cause when Kconfig is executed the first time, then we need ALL soc roots present.

Otherwise we cannot decide the correct SOC to use for the given board.


I will not claim to know what problem you were encountering or trying to solve.  From my limited viewpoint, the above statement feels like it is based on an incorrect assumption.  If, as the application developer, I provide an SOC_ROOT value, I do not care about any of the other possible soc directories that can be encountered.  The code for the soc I want selected and used is in the directory I specified by setting the SOC_ROOT value.  Again, I do not know what issue you were trying to solve (it was not clear to me from the pull request) or where the new functionality is needed, but I do ask that you please not break the behavior that has been working for sometime in 2.2 and 2.3.
 

 

Thus, a Kconfig file is generated at the build directory here:

https://github.com/zephyrproject-rtos/zephyr/blob/master/cmake/kconfig.cmake#L9-L22

 

and then sourced into Kconfig here:

https://github.com/zephyrproject-rtos/zephyr/blob/master/soc/Kconfig#L6

https://github.com/zephyrproject-rtos/zephyr/blob/master/soc/Kconfig#L11

 

So the `SOC_DIR` must no longer be exported cause Kconfig cannot hanled a list of dirs..

This is the reason for generating Kconfig files that can then be sourced into Kconfig.


I agree that Kconfig cannot handle a list of dirs.  That was not a problem previously, as a SOC_DIR was selected BEFORE kconfig was called to generate everything.  By moving the selection of the SOC_DIR to a later position in the code, specifically after including the kconfig.cmake file, you introduce the problem you cite.  From my examination, there appears to be no technical reason for the relocation of the code to select the SOC_DIR. 
 

 Could you verify the content of:

${CMAKE_BINARY_DIR}/Kconfig/Kconfig.soc.defconfig

${CMAKE_BINARY_DIR}/Kconfig/Kconfig.soc

${CMAKE_BINARY_DIR}/Kconfig/Kconfig.soc.arch


I'll do one better.  You may recreate the issue yourself and validate all the data you want.


This will not ever compile as I have hastily thrown together bits from the Zephyr tree and wrote some quick hackish kconfigs.  Those typos and errors are not of interest to fix for this discussion.  But this does re-create the error I am raising in parsing the kconfig files even on just running menuconfig.  See the README for details on the steps needed to reproduce it.

 

One question:

> Thus when setting a custom SOC_DIR

 

Are you setting the `SOC_DIR` yourself ?

The `SOC_DIR` is for the Zephyr build system, the correct way to do this is to set `SOC_ROOT` as described:

https://docs.zephyrproject.org/latest/application/index.html#soc-definitions

 

as: `cmake -DSOC_ROOT=<path> ….`


That would be a typo on my part.  Everything is set via the *_ROOT values, set in the application/src/CMakeLists.txt file. 


 

 

/torsten

 

From: Dan Kalowsky <dank@...>
Sent: 6 August, 2020 21:20
To: Rasmussen, Torsten <Torsten.Rasmussen@...>
Cc: Cufi, Carles <Carles.Cufi@...>; devel@...
Subject: Re: [Zephyr-devel] SOC_DIR not populated

 

Torsten,

 

 

On Thu, Aug 6, 2020 at 11:48 AM Rasmussen, Torsten <Torsten.Rasmussen@...> wrote:

Hi Dan,

 

Sorry for any trouble the latest changes is causing you.

With https://github.com/zephyrproject-rtos/zephyr/pull/26715 it is now possible to provide multiple SoC roots, allowing for greater flexibility.

 

Please re-read the original message.  You have a hidden dependency that has been overlooked that causes completely out of tree SOCs to not work.  The setup works fine for in-tree and within the Zephyr source SOCs because of other assumptions in the code.

 

 

and as you see, the `SOC_DIR` is still populated, but because there can only be a single SOC_DIR, we need to decide on the correct SOC_DIR to use.
To do so, we check for the existence of the SoC under its corresponding arch.

 

All SoCs in Zephyr are grouped under `soc/${ARCH}/` and this could be the root cause in your case.

Looking again at the code, I suspect you have your SoCs located directly under:

```

${YOUR_PRIVATE_REPO}/soc/your_soc

```

If you can move your SoC into an `${ARCH}` folder, for example:

```

${YOUR_PRIVATE_REPO}/soc/arm/your_soc

```

Then things should work again.

 

 

Again, I will encourage you to re-read the original message.  The layout you are requesting to be followed is what has been followed.

 

 

 

If your repo is defined as a Zephyr module, you even have the possibility of adding this into the nodule.yml file:

https://docs.zephyrproject.org/latest/guides/modules.html#build-settings

 

The values of *_ROOT are all defined in cmake variables.  They have been confirmed to be correctly populated via calls to cmake messages() at the first time of parsing in the boilerplate.cmake file.  If we can focus more on why SOC_DIR is not populated at the time of consumption by kconfig.cmake it would be appreciated. 

 

 

Best regards

 

Torsten

 

From: Dan Kalowsky <dank@...>
Sent: 6 August, 2020 20:04
To: Cufi, Carles <Carles.Cufi@...>
Cc: devel@...; Rasmussen, Torsten <Torsten.Rasmussen@...>
Subject: Re: [Zephyr-devel] SOC_DIR not populated

 

Charles,

 

Thanks for the prompt response.  Do please keep me CC'd on this as I am not on the mailing list. 

 

Torsten the longer version might provide some background context for the debug.  Happy to help where I can.

 

 

On Thu, Aug 6, 2020 at 10:40 AM Cufi, Carles <Carles.Cufi@...> wrote:

Hi Dan,

 

Assuming you have the latest upstream master, then this might be a regression introduced by:

https://github.com/zephyrproject-rtos/zephyr/pull/26715

 

We are certainly not dropping support for out-of-tree SoCs, in fact we just discussed this recently with Torsten (on copy). He should be able to give more info on the subject.

 

Thanks,

 

Carles

 

From: devel@... <devel@...> On Behalf Of Dan Kalowsky via lists.zephyrproject.org
Sent: 06 August 2020 19:19
To: devel@...
Subject: [Zephyr-devel] SOC_DIR not populated

 

Hey Zephyr team,

 

Long time no talk.

 

Short version:  Using the latest HEAD, I am finding that the kconfig SOC_DIR is not being populated for an out of tree SOC build.  This causes a compilation failure and makes everyone a sad panda.  As this was something that worked perfectly in 2.3 (and for the most part earlier), I was a little surprised to see this no longer working on HEAD.  Was it intentional to remove support for out of tree SOCs, or is this an oversight?  I could not find any documentation supporting either statement in the mailing list or meeting minutes.

 

Longer version:

 

I have a Zephyr application with a lot of out of tree pieces.  It kind of looks like the following simplified layout:

 

application/

- board/

- soc/

-- Kconfig

-- arm/

--- product/

--- Kconfig

--- Kconfig.defconfig

--- Kconfig.soc

--- CMakeLists.txt

---- soc_a/

---- soc_b/

- dts/

- src/

zephyr/

modules/

 

Overall this has worked great in 2.3 (and was functional in 2.2 with some fixes).  Given some of the recent work by Andrew and Tomasz (thanks and hi btw) I was motivated to upgrade to HEAD.  At this point, while building I get informed that the path $(SOC_DIR)/$(ARCH) has some unset variables, which causes the initial setup for cmake/kconfig to fail.  Sure enough, there are empty variables being used.  While investigating, it looks like the current HEAD has three issues for out of tree SOC usage, but I've only been able to "resolve" two of them.  Almost all of it seems to have originated from commit 5f7cc8ded9138b773012b9ffedc744b9475927db.

 

Issues found:

1) The file cmake/kconfig.cmake no longer sets up to export the SOC_DIR as it used to.  Thus when setting a custom SOC_DIR, nothing is there for the python script to add.  Adding back lines 44 and 88 solves the variables now being set, although the value of SOC_DIR is still nil.  You will need to resolve issue 2 as well to finish this fix.

 

2) The file cmake/app/boilerplate.cmake has relocated lines of code that set the SOC_DIR variable to a after a section of code that has requirements for them to be set.  Specifically the chunk at 527-541 needs to happen BEFORE the inclusion of kconfig.cmake on line 515.  It is not clear why these lines were moved from the commit or Pull Request, but it does expose a dependency chain that does not seem to be tested/validated in the scripts.  Moving this section alone is not enough, you still need issue 1 resolved for the variables to show up in the kconfig.py script.

 

3) Even with these changes, which allow me to get further along the compile, there is still one last issue I have not been able to rootcause.   I end up seeing the following error, which appears to munge some of the path:

CMake Error at /home/dkalowsky/product_dev/zephyr/CMakeLists.txt:376 (message):
  Could not find linker script:
  '/home/dkalowsky/product_dev/application/soc/arm//linker.ld'.

 

Note the // before linker.ld. 

 

Which brings us to the questions part...

 

Is Zephyr looking to drop out of tree SOC?  I certainly hope not, but some of the change directions in the commit above give a bit of concern that it might be true.  Note this is tea leaf reading, and I am bad at it.

If not, is there a new layout that should be utilized for out of tree SOC usage?  The documentation still points to the previously existing behavior as being correct.  If it is changing, is there a document that I can reference to update my local application?

If this is all oversight and just bugs, any ideas on what could be causing issue 3?

 

 


--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."

 



--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."



--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."



--
"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."


Rasmussen, Torsten
 

Hi,

 

Find answers inline.

And for convenience, a link to the fix: https://github.com/dkalowsk/broked_zephyr/pull/1

 

/torsten

 

From: Dan Kalowsky <dank@...>
Sent: 7 August, 2020 1:10
To: Rasmussen, Torsten <Torsten.Rasmussen@...>
Cc: Cufi, Carles <Carles.Cufi@...>; devel@...
Subject: Re: [Zephyr-devel] SOC_DIR not populated

 

Trying to respond to both replies in the same email here...

 

On Thu, Aug 6, 2020 at 1:44 PM Rasmussen, Torsten <Torsten.Rasmussen@...> wrote:

Hi,

 

I have retested the functionality by relocating SoCs from ${ZEPHYR_BASE}/soc into modules, and this worked as expected.

Both when using `zephyr/module.yml` and `-DSOC_ROOT=<path>`.

 

So I took one more look at your folder structure and compared to the code, and I noticed you wrote:

--- product/

--- Kconfig

--- Kconfig.defconfig

--- Kconfig.soc

I notice that both the folder `product` and the files Kconfig.* has `---` (3) dashes in front of them, so I just want to verify that those files are located in the `product` dir and not directly in `arm` dir ?

 

> Sorry if the crudely generated ascii art was not clear enough.  The Kconfig* files are in the product directory.

 

No problem. Just wanted to rule out any such issues.

 

 

 

> Please re-read the original message.  You have a hidden dependency that has been overlooked that causes completely out of tree SOCs to not work.  The setup works fine for in-tree and within the Zephyr source SOCs because of other assumptions in the code.

 

Seems I was a bit too fast I my reply.

 

 

The SOC_DIR shall no longer be exported to Kconfig, cause when Kconfig is executed the first time, then we need ALL soc roots present.

Otherwise we cannot decide the correct SOC to use for the given board.

 

> I will not claim to know what problem you were encountering or trying to solve.  From my limited viewpoint, the above statement feels like it is based on an incorrect assumption. 

> If, as the application developer, I provide an SOC_ROOT value, I do not care about any of the other possible soc directories that can be encountered.

> The code for the soc I want selected and used is in the directory I specified by setting the SOC_ROOT value.  Again, I do not know what issue you were trying to solve

> (it was not clear to me from the pull request) or where the new functionality is needed, but I do ask that you please not break the behavior that has been working for sometime in 2.2 and 2.3.

 

Ok, a little bit of history.

Originally, all ROOTs where a single root only, including BOARD_ROOT.

Now, this for sure has its limitation, as people would like to be able to specify more than one root in order to support both in- and out-of-tree BOARDS, SOC, DTS, and so on.

So BOARD_ROOT was the first to be cleaned up.

https://github.com/zephyrproject-rtos/zephyr/pull/10267

 

so there has been request for other ROOTs to be extended to support multiple roots.

https://github.com/zephyrproject-rtos/zephyr/issues/25215

 

There are also several users with out-of-tree SoCs, who are using both Zephyr SoCs and out-of-tree SoCs, and everyone must make there own way of ensuring that their SOC_ROOT gets set correctly.

I have seen this as a common approach:

if(BOARD STREQUAL my_custom_soc_board)
  set(BOARD_ROOT some/out/of/tree/soc/path)
endif()

 

With https://github.com/zephyrproject-rtos/zephyr/pull/26715 all ROOTs have been unified on how they are used.

Also, the Zephyr module `module.yml` file has been updated to support those roots directly.

 

This allows to place SoCs out-of-tree in a common way and have that SoC available together with all other SoCs.

 

I have posted a fix for your code here:

https://github.com/dkalowsk/broked_zephyr/pull/1

 

Let me know if there are still issues with the linker script location. 

 

Thus, a Kconfig file is generated at the build directory here:

https://github.com/zephyrproject-rtos/zephyr/blob/master/cmake/kconfig.cmake#L9-L22

 

and then sourced into Kconfig here:

https://github.com/zephyrproject-rtos/zephyr/blob/master/soc/Kconfig#L6

https://github.com/zephyrproject-rtos/zephyr/blob/master/soc/Kconfig#L11

 

So the `SOC_DIR` must no longer be exported cause Kconfig cannot hanled a list of dirs..

This is the reason for generating Kconfig files that can then be sourced into Kconfig.

 

I agree that Kconfig cannot handle a list of dirs.  That was not a problem previously, as a SOC_DIR was selected BEFORE kconfig was called to generate everything.  By moving the selection of the SOC_DIR to a later position in the code, specifically after including the kconfig.cmake file, you introduce the problem you cite.  From my examination, there appears to be no technical reason for the relocation of the code to select the SOC_DIR. 

 

 Could you verify the content of:

${CMAKE_BINARY_DIR}/Kconfig/Kconfig.soc.defconfig

${CMAKE_BINARY_DIR}/Kconfig/Kconfig.soc

${CMAKE_BINARY_DIR}/Kconfig/Kconfig.soc.arch

 

> I'll do one better.  You may recreate the issue yourself and validate all the data you want.

> This will not ever compile as I have hastily thrown together bits from the Zephyr tree and wrote some quick hackish kconfigs. 

> Those typos and errors are not of interest to fix for this discussion.  But this does re-create the error I am raising in parsing

> the kconfig files even on just running menuconfig.  See the README for details on the steps needed to reproduce it.

 

Thanks. Much easier to spot the issue, and others can see the fix if they have a similar setup.

https://github.com/dkalowsk/broked_zephyr/pull/1

 

 

One question:

> Thus when setting a custom SOC_DIR

 

Are you setting the `SOC_DIR` yourself ?

The `SOC_DIR` is for the Zephyr build system, the correct way to do this is to set `SOC_ROOT` as described:

https://docs.zephyrproject.org/latest/application/index.html#soc-definitions

 

as: `cmake -DSOC_ROOT=<path> ….`

 

> That would be a typo on my part.  Everything is set via the *_ROOT values, set in the application/src/CMakeLists.txt file. 

 

Also what I assumed.

But good to get such things ruled out early.

 

 

 

/torsten

 

From: Dan Kalowsky <dank@...>
Sent: 6 August, 2020 21:20
To: Rasmussen, Torsten <Torsten.Rasmussen@...>
Cc: Cufi, Carles <Carles.Cufi@...>; devel@...
Subject: Re: [Zephyr-devel] SOC_DIR not populated

 

Torsten,

 

 

On Thu, Aug 6, 2020 at 11:48 AM Rasmussen, Torsten <Torsten.Rasmussen@...> wrote:

Hi Dan,

 

Sorry for any trouble the latest changes is causing you.

With https://github.com/zephyrproject-rtos/zephyr/pull/26715 it is now possible to provide multiple SoC roots, allowing for greater flexibility.

 

Please re-read the original message.  You have a hidden dependency that has been overlooked that causes completely out of tree SOCs to not work.  The setup works fine for in-tree and within the Zephyr source SOCs because of other assumptions in the code.

 

 

and as you see, the `SOC_DIR` is still populated, but because there can only be a single SOC_DIR, we need to decide on the correct SOC_DIR to use.
To do so, we check for the existence of the SoC under its corresponding arch.

 

All SoCs in Zephyr are grouped under `soc/${ARCH}/` and this could be the root cause in your case.

Looking again at the code, I suspect you have your SoCs located directly under:

```

${YOUR_PRIVATE_REPO}/soc/your_soc

```

If you can move your SoC into an `${ARCH}` folder, for example:

```

${YOUR_PRIVATE_REPO}/soc/arm/your_soc

```

Then things should work again.

 

 

Again, I will encourage you to re-read the original message.  The layout you are requesting to be followed is what has been followed.

 

 

 

If your repo is defined as a Zephyr module, you even have the possibility of adding this into the nodule.yml file:

https://docs.zephyrproject.org/latest/guides/modules.html#build-settings

 

The values of *_ROOT are all defined in cmake variables.  They have been confirmed to be correctly populated via calls to cmake messages() at the first time of parsing in the boilerplate.cmake file.  If we can focus more on why SOC_DIR is not populated at the time of consumption by kconfig.cmake it would be appreciated. 

 

 

Best regards

 

Torsten

 

From: Dan Kalowsky <dank@...>
Sent: 6 August, 2020 20:04
To: Cufi, Carles <Carles.Cufi@...>
Cc: devel@...; Rasmussen, Torsten <Torsten.Rasmussen@...>
Subject: Re: [Zephyr-devel] SOC_DIR not populated

 

Charles,

 

Thanks for the prompt response.  Do please keep me CC'd on this as I am not on the mailing list. 

 

Torsten the longer version might provide some background context for the debug.  Happy to help where I can.

 

 

On Thu, Aug 6, 2020 at 10:40 AM Cufi, Carles <Carles.Cufi@...> wrote:

Hi Dan,

 

Assuming you have the latest upstream master, then this might be a regression introduced by:

https://github.com/zephyrproject-rtos/zephyr/pull/26715

 

We are certainly not dropping support for out-of-tree SoCs, in fact we just discussed this recently with Torsten (on copy). He should be able to give more info on the subject.

 

Thanks,

 

Carles

 

From: devel@... <devel@...> On Behalf Of Dan Kalowsky via lists.zephyrproject.org
Sent: 06 August 2020 19:19
To: devel@...
Subject: [Zephyr-devel] SOC_DIR not populated

 

Hey Zephyr team,

 

Long time no talk.

 

Short version:  Using the latest HEAD, I am finding that the kconfig SOC_DIR is not being populated for an out of tree SOC build.  This causes a compilation failure and makes everyone a sad panda.  As this was something that worked perfectly in 2.3 (and for the most part earlier), I was a little surprised to see this no longer working on HEAD.  Was it intentional to remove support for out of tree SOCs, or is this an oversight?  I could not find any documentation supporting either statement in the mailing list or meeting minutes.

 

Longer version:

 

I have a Zephyr application with a lot of out of tree pieces.  It kind of looks like the following simplified layout:

 

application/

- board/

- soc/

-- Kconfig

-- arm/

--- product/

--- Kconfig

--- Kconfig.defconfig

--- Kconfig.soc

--- CMakeLists.txt

---- soc_a/

---- soc_b/

- dts/

- src/

zephyr/

modules/

 

Overall this has worked great in 2.3 (and was functional in 2.2 with some fixes).  Given some of the recent work by Andrew and Tomasz (thanks and hi btw) I was motivated to upgrade to HEAD.  At this point, while building I get informed that the path $(SOC_DIR)/$(ARCH) has some unset variables, which causes the initial setup for cmake/kconfig to fail.  Sure enough, there are empty variables being used.  While investigating, it looks like the current HEAD has three issues for out of tree SOC usage, but I've only been able to "resolve" two of them.  Almost all of it seems to have originated from commit 5f7cc8ded9138b773012b9ffedc744b9475927db.

 

Issues found:

1) The file cmake/kconfig.cmake no longer sets up to export the SOC_DIR as it used to.  Thus when setting a custom SOC_DIR, nothing is there for the python script to add.  Adding back lines 44 and 88 solves the variables now being set, although the value of SOC_DIR is still nil.  You will need to resolve issue 2 as well to finish this fix.

 

2) The file cmake/app/boilerplate.cmake has relocated lines of code that set the SOC_DIR variable to a after a section of code that has requirements for them to be set.  Specifically the chunk at 527-541 needs to happen BEFORE the inclusion of kconfig.cmake on line 515.  It is not clear why these lines were moved from the commit or Pull Request, but it does expose a dependency chain that does not seem to be tested/validated in the scripts.  Moving this section alone is not enough, you still need issue 1 resolved for the variables to show up in the kconfig.py script.

 

3) Even with these changes, which allow me to get further along the compile, there is still one last issue I have not been able to rootcause.   I end up seeing the following error, which appears to munge some of the path:

CMake Error at /home/dkalowsky/product_dev/zephyr/CMakeLists.txt:376 (message):
  Could not find linker script:
  '/home/dkalowsky/product_dev/application/soc/arm//linker.ld'.

 

Note the // before linker.ld. 

 

Which brings us to the questions part...

 

Is Zephyr looking to drop out of tree SOC?  I certainly hope not, but some of the change directions in the commit above give a bit of concern that it might be true.  Note this is tea leaf reading, and I am bad at it.

If not, is there a new layout that should be utilized for out of tree SOC usage?  The documentation still points to the previously existing behavior as being correct.  If it is changing, is there a document that I can reference to update my local application?

If this is all oversight and just bugs, any ideas on what could be causing issue 3?

 

 


--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."

 



--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."



--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."



--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."


Dan Kalowsky <dank@...>
 

Sorry for the delay in response, got pulled into other duties and was not able to follow up on this in the immediate time frame.



On Thu, Aug 6, 2020 at 11:27 PM Rasmussen, Torsten <Torsten.Rasmussen@...> wrote:

Hi,

 

Find answers inline.

And for convenience, a link to the fix: https://github.com/dkalowsk/broked_zephyr/pull/1


Thank you for this PR.  More importantly, thank you for fixing the documentation in the follow up PR and pointing out that this is a breaking change for others.

One additional note that should be added here, when using the files as corrected to build, they fail to find the linker.ld file found in the soc_a in the example.

The fix is to change the arm/product/CMakeLists.txt file like so:

- add_subdirectory(${SOC_SERIES})
+ add_subdirectory(${CONFIG_SOC_SERIES})

This seems to allow everything to work correctly in the compile time frame.  You may want to include that detail as well if it is correct.  Note the demo repo needs to be cleaned up to compile anything at all, don't trust it.  This seems odd because I believed that Zephyr dropped the CONFIG_ prefix from everything internally before using it, yet in this case the variable has data only when prefixed.
 

Ok, a little bit of history.

Originally, all ROOTs where a single root only, including BOARD_ROOT.

Now, this for sure has its limitation, as people would like to be able to specify more than one root in order to support both in- and out-of-tree BOARDS, SOC, DTS, and so on.

So BOARD_ROOT was the first to be cleaned up.

https://github.com/zephyrproject-rtos/zephyr/pull/10267

 

so there has been request for other ROOTs to be extended to support multiple roots.

https://github.com/zephyrproject-rtos/zephyr/issues/25215

 

There are also several users with out-of-tree SoCs, who are using both Zephyr SoCs and out-of-tree SoCs, and everyone must make there own way of ensuring that their SOC_ROOT gets set correctly.

I have seen this as a common approach:

if(BOARD STREQUAL my_custom_soc_board)
  set(BOARD_ROOT some/out/of/tree/soc/path)
endif()


Thank you for the history.  From my island, I don't see this as a correct usage/behavior, but I am clearly in the minority. 
 
 

Let me know if there are still issues with the linker script location.


See note above.
 

--
"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."


Rasmussen, Torsten
 

Hi,

 

Thanks for the confirmation of the patch.

And thanks for the update.

 

I was waiting for confirmation before sending update on mailing list.

 

See more comments below.

 

/Torsten

 

 

From: Dan Kalowsky <dank@...>
Sent: 11 August, 2020 0:37
To: Rasmussen, Torsten <Torsten.Rasmussen@...>
Cc: Cufi, Carles <Carles.Cufi@...>; devel@...
Subject: Re: [Zephyr-devel] SOC_DIR not populated

 

Sorry for the delay in response, got pulled into other duties and was not able to follow up on this in the immediate time frame.

 

 

 

On Thu, Aug 6, 2020 at 11:27 PM Rasmussen, Torsten <Torsten.Rasmussen@...> wrote:

Hi,

 

Find answers inline.

And for convenience, a link to the fix: https://github.com/dkalowsk/broked_zephyr/pull/1

 

Thank you for this PR.  More importantly, thank you for fixing the documentation in the follow up PR and pointing out that this is a breaking change for others.

 

One additional note that should be added here, when using the files as corrected to build, they fail to find the linker.ld file found in the soc_a in the example.

 

The fix is to change the arm/product/CMakeLists.txt file like so:

 

- add_subdirectory(${SOC_SERIES})

+ add_subdirectory(${CONFIG_SOC_SERIES})

 

This seems to allow everything to work correctly in the compile time frame.  You may want to include that detail as well if it is correct.  Note the demo repo needs to be cleaned up to compile anything at all, don't trust it.  This seems odd because I believed that Zephyr dropped the CONFIG_ prefix from everything internally before using it, yet in this case the variable has data only when prefixed.

 

No, all Kconfig settings in CMake must be accessed using `CONFIG_<name>`.
Only the `SOC_SERIES` is a little special, as that is copied into a local variable (history goes before my time).

https://github.com/zephyrproject-rtos/zephyr/blob/master/cmake/app/boilerplate.cmake#L532

I would discourage using `SOC_SERIES` directly and instead do the proper `CONFIG_SOC_SERIES` but I will not remove `SOC_SERIES` possibility without a good reason, cause users may depend on it.


But using `SOC_SERIES` should work for files included as part of Zephyr CMake boilerplate (everything that is happening as part of `find_package(Zephyr)`).

Which is the case for `SOC_ROOT/arch/soc` included CMake files.

 

For other usage, such as if a CMakeLists.txt file is included as a `add_subdirectory()` after `find_package(Zephyr)` then `SOC_SERIES` cannot be used due to CMake scoping, and `CONFIG_SOC_SERIES` must be used.

That has not changed, so I would like to know how you get those CMake files included, to understand if there is an issue hidden somewhere.

This should not have changed behavior with the changes introduced by https://github.com/zephyrproject-rtos/zephyr/pull/26715 .

 

I had no problem with linking when building for nrf52840dk_nrf52840 board, but I had to set `import:true` in the west.yml to get Nordic hal headers.

But you might be looking at code that you have not pushed to the repo.

At least I don’t see any board using the `soc_a` SoC.

 

Ok, a little bit of history.

Originally, all ROOTs where a single root only, including BOARD_ROOT.

Now, this for sure has its limitation, as people would like to be able to specify more than one root in order to support both in- and out-of-tree BOARDS, SOC, DTS, and so on.

So BOARD_ROOT was the first to be cleaned up.

https://github.com/zephyrproject-rtos/zephyr/pull/10267

 

so there has been request for other ROOTs to be extended to support multiple roots.

https://github.com/zephyrproject-rtos/zephyr/issues/25215

 

There are also several users with out-of-tree SoCs, who are using both Zephyr SoCs and out-of-tree SoCs, and everyone must make there own way of ensuring that their SOC_ROOT gets set correctly.

I have seen this as a common approach:

if(BOARD STREQUAL my_custom_soc_board)
  set(BOARD_ROOT some/out/of/tree/soc/path)
endif()

 

Thank you for the history.  From my island, I don't see this as a correct usage/behavior, but I am clearly in the minority. 

 

 

Let me know if there are still issues with the linker script location.

 

See note above.

 

 

--

"Do you expect me to talk?"
"No Mr. Bond, I expect you to die."