Skip to content

soc: nxp: imrt: clean section definitions in boot header #85634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Raymond0225
Copy link
Contributor

Clean up redundancy boot header sections configuration in cmake file as they have been defined in boot_header.ld very well and already included.

Add new section name macro definitions, use these macro instead of hard code the section name.

@Raymond0225
Copy link
Contributor Author

Verified on RT1180 and RT1170 EVK.

Copy link
Member

@decsny decsny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes look fine generally

there is a typo in the commit message: imrt->imxrt

did you verify it works also with ramloader feature?

@Raymond0225
Copy link
Contributor Author

changes look fine generally

there is a typo in the commit message: imrt->imxrt

did you verify it works also with ramloader feature?

thanks for the feedback.
when you say "ramloader" feature, do you mean to enable CONFIG_NXP_IMX_RT_ROM_RAMLOADER=y ?

I tried to enable this feature on RT1170 evk by adding these lines in Helloworld prj.conf but building failed,
any comment or idea?

CONFIG_XIP=n
CONFIG_NXP_IMX_RT_ROM_RAMLOADER=y

###########################################################################
warning: XIP (defined at
C:/workspace/zephyr_github_nxp_upstream/zephyr/soc/telink/tlsr\tlsr951x\Kconfig.defconfig:15,
C:/workspace/zephyr_github_nxp_upstream/zephyr/soc/snps/nsim/arc_classic/Kconfig.defconfig:6,
C:/workspace/zephyr_github_nxp_upstream/zephyr/soc/sensry\ganymed\sy1xx\Kconfig.defconfig:70,
C:/workspace/zephyr_github_nxp_upstream/zephyr/arch/arm64\core/Kconfig:262, kernel/Kconfig:865) was
assigned the value 'n' but got the value 'y'. See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_XIP and/or look up XIP in the
menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values,
and Kconfig - Tips and Best Practices sections of the manual might be helpful too.C:/workspace/zephyr_github_nxp_upstream/zephyr/samples/hello_world/prj.conf:3: warning: attempt to assign the value 'y' to the undefined symbol NXP_IMX_RT_ROM_RAMLOADER
Parsing c:/workspace/zephyr_github_nxp_upstream/zephyr/Kconfig
Loaded configuration 'C:/workspace/zephyr_github_nxp_upstream/zephyr/boards/nxp/mimxrt1170_evk/mimxrt1170_evk_mimxrt1176_cm7_defconfig'
Merged configuration 'C:/workspace/zephyr_github_nxp_upstream/zephyr/samples/hello_world/prj.conf'

error: Aborting due to Kconfig warnings

CMake Error at C:/workspace/zephyr_github_nxp_upstream/zephyr/cmake/modules/kconfig.cmake:396 (message):
command failed with return code: 1
Call Stack (most recent call first):
C:/workspace/zephyr_github_nxp_upstream/zephyr/cmake/modules/zephyr_default.cmake:133 (include)
C:/workspace/zephyr_github_nxp_upstream/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
C:/workspace/zephyr_github_nxp_upstream/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
CMakeLists.txt:5 (find_package)

-- Configuring incomplete, errors occurred!

@Raymond0225
Copy link
Contributor Author

changes look fine generally

there is a typo in the commit message: imrt->imxrt

did you verify it works also with ramloader feature?

AFAIK, ramloader feature has been removed from main, please double check

@decsny
Copy link
Member

decsny commented Feb 13, 2025

changes look fine generally
there is a typo in the commit message: imrt->imxrt
did you verify it works also with ramloader feature?

AFAIK, ramloader feature has been removed from main, please double check

It's not removed as far as I know, I dont know why would it be, did you change the zephyr,flash

@Raymond0225
Copy link
Contributor Author

changes look fine generally
there is a typo in the commit message: imrt->imxrt
did you verify it works also with ramloader feature?

AFAIK, ramloader feature has been removed from main, please double check

It's not removed as far as I know, I dont know why would it be, did you change the zephyr,flash

yes, I changed Zephyr,flash, the 1st warning disappeared but the error still there. NXP_IMX_RT_ROM_RAMLOADER can't be found. I searched this macro in the whole project, it is not there.

@decsny
Copy link
Member

decsny commented Feb 13, 2025

changes look fine generally
there is a typo in the commit message: imrt->imxrt
did you verify it works also with ramloader feature?

AFAIK, ramloader feature has been removed from main, please double check

It's not removed as far as I know, I dont know why would it be, did you change the zephyr,flash

yes, I changed Zephyr,flash, the 1st warning disappeared but the error still there. NXP_IMX_RT_ROM_RAMLOADER can't be found. I searched this macro in the whole project, it is not there.

I'm not sure where you got that name, I think it's called NXP_FLEXSPI_ROM_RAMLOADER

@Raymond0225
Copy link
Contributor Author

NXP_FLEXSPI_ROM_RAMLOADER

thanks, I think I got the wrong macro name from a commit history.
after enable CONFIG_NXP_FLEXSPI_ROM_RAMLOADER, "helloworld" example works find.

Clean up redundancy boot header sections configuration in cmake file
as they have been defined in boot_header.ld very well and already
included.

Add new section name macro definitions, use these macro instead of hard
code the section name.

Signed-off-by: Raymond Lei <raymond.lei@nxp.com>
@Raymond0225 Raymond0225 force-pushed the clean_boot_header_section_name branch from 3416b93 to 48825c2 Compare February 14, 2025 19:08
decsny
decsny previously approved these changes Feb 17, 2025
Copy link
Contributor

@RobinKastberg RobinKastberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break NXP on IAR and ARMCLANG and using CONFIG_CMAKE_LINKER_GENERATOR=y

Please don't remove things just because you don't think they are being used.

We really need to communicate our strategy for linker scripts moving forward @tejlmand

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is being used in CMAKE_LINKER_GENERATOR

@decsny
Copy link
Member

decsny commented Feb 19, 2025

Please don't remove things just because you don't think they are being used.

I do not agree with this statement. Mistakes might be made but reducing maintenance surface is not a bad thing to try to do. If it had caused a regression it could just be reverted.

We shouldn't discourage contributors from trying to do things like this because they are clearly just trying to improve the quality and maintainability of the project.

When I reviewed this PR I tried also to figure out why the linking description was duplicated in 2 places because something seemed weird about that and I was suspicious at first. But inspecting the git history made it look like it was on accident, and I really couldn't figure out from looking around the tree what it was for. So you've answered now, which is good.

@decsny
Copy link
Member

decsny commented Feb 19, 2025

@RobinKastberg Now my question is do we actually need the .ld file too or is the cmake sufficient in all cases? I also don't want two different ways of doing the same thing if we can avoid it, but I'm not an expert on the build system here, you seem to have strong opinions about this. Having two places where we need to say to do the same thing is a recipe for someone missing one of them when doing a change and having a bug

@RobinKastberg
Copy link
Contributor

@RobinKastberg Now my question is do we actually need the .ld file too or is the cmake sufficient in all cases? I also don't want two different ways of doing the same thing if we can avoid it, but I'm not an expert on the build system here, you seem to have strong opinions about this. Having two places where we need to say to do the same thing is a recipe for someone missing one of them when doing a change and having a bug

100% this is really bad, and we are aware.
The toolchain group is looking at it, and with IAR pushing this we should be able to resolve this in a satisfactory manner.
My dream would be if we could replace the ld skeletons and make them
generated by cmake, one subsystem/module at a time, until such a time that everything is replaced with cmake.

For now. It would be interesting if NXP would start testing with CONFIG_CMAKE_LINKER_GENERATOR=y (either with LD or IAR, but preferably both :)) to verify that their cards are working and keep working.
(I have made sure that mimxrt1060_evk and frdm_mcxn947 is working)

@RobinKastberg
Copy link
Contributor

Please don't remove things just because you don't think they are being used.

I do not agree with this statement. Mistakes might be made but reducing maintenance surface is not a bad thing to try to do. If it had caused a regression it could just be reverted.

We shouldn't discourage contributors from trying to do things like this because they are clearly just trying to improve the quality and maintainability of the project.

When I reviewed this PR I tried also to figure out why the linking description was duplicated in 2 places because something seemed weird about that and I was suspicious at first. But inspecting the git history made it look like it was on accident, and I really couldn't figure out from looking around the tree what it was for. So you've answered now, which is good.

Sorry for being unfriendly. We just got the cmake and ld scripts enough in sync to be able to merge basic IAR support.
I had a commit not that long ago trying to fix exactly this file, 2ce0fd6.

The fact that we have two parallel linking systems without a single source of truth,
is almost too unbelievable bad to be true. From your perspective I would have done the same thing probably.

I really don't want to discourage anyone from cleaning up and fixing things, we really need those things. But I would encourage figuring out why it was like that in the first place.

Reverting regressions is easy, but finding out about them can be really hard in these lesser tested toolchains/configurations/boards.

@decsny decsny dismissed their stale review February 19, 2025 18:19

removing my approval

@nashif nashif assigned dleach02 and unassigned nashif Feb 19, 2025
@dleach02
Copy link
Member

100% this is really bad, and we are aware. The toolchain group is looking at it, and with IAR pushing this we should be able to resolve this in a satisfactory manner. My dream would be if we could replace the ld skeletons and make them generated by cmake, one subsystem/module at a time, until such a time that everything is replaced with cmake.

For now. It would be interesting if NXP would start testing with CONFIG_CMAKE_LINKER_GENERATOR=y (either with LD or IAR, but preferably both :)) to verify that their cards are working and keep working. (I have made sure that mimxrt1060_evk and frdm_mcxn947 is working)

@hakehuang isn't this something we could do against our HW range? Do a twister run with CONFIG_CMAKE_LINKER_GENERATOR=y

@hakehuang
Copy link
Contributor

hakehuang commented Feb 27, 2025

@hakehuang isn't this something we could do against our HW range? Do a twister run with CONFIG_CMAKE_LINKER_GENERATOR=y
anyone knows how to install IAR toolchain for zephyr? in the guide(https://docs.zephyrproject.org/latest/develop/toolchains/iar_arm_toolchain.html) it says.

As of now, a Development version of the IAR build tools for Arm is required to work with Zephyr. It is distributed to selected partners and customers for evaluation. If you are interested in being part of this program, please send a request to the IAR FAE team at [fae.emea@iar.com](mailto:fae.emea%40iar.com).

and how to obtain the BEARER TOKEN?

The IAR Toolchain needs the IAR_LMS_BEARER_TOKEN environment variable to be set to a valid license bearer token.

@RobinKastberg
Copy link
Contributor

@hakehuang NXP via @dleach02 should have received alicense token.
If you need another one for some reason please email the address mention and namedrop me and this issue and we will figure something out.

@hakehuang
Copy link
Contributor

For now. It would be interesting if NXP would start testing with CONFIG_CMAKE_LINKER_GENERATOR=y (either with LD or IAR, but preferably both :)) to verify that their cards are working and keep working.
(I have made sure that mimxrt1060_evk and frdm_mcxn947 is working)

@RobinKastberg , mimxrt1060_evk does not work for me, and the whole boards does not enabled for iar, see below steps

  1. I need update the .yaml to support toolchain first
diff --git a/boards/nxp/mimxrt1060_evk/mimxrt1060_evk_mimxrt1062_qspi_C.yaml b/boards/nxp/mimxrt1060_evk/mimxrt1060_evk_mimxrt1062_qspi_C.yaml
index 2a1c3311647..ed569b05a1c 100644
--- a/boards/nxp/mimxrt1060_evk/mimxrt1060_evk_mimxrt1062_qspi_C.yaml
+++ b/boards/nxp/mimxrt1060_evk/mimxrt1060_evk_mimxrt1062_qspi_C.yaml
@@ -11,6 +11,7 @@ arch: arm
 toolchain:
   - zephyr
   - gnuarmemb
+  - iar
 ram: 32768
 flash: 8192
 supported:
  1. and I meet below failure with below command line
scripts/twister  -p mimxrt1060_evk@C/mimxrt1062/qspi -T samples/hello_world/ --build-only -x=CONFIG_CMAKE_LINKER_GENERATOR=y
FAILED: zephyr/CMakeFiles/zephyr.dir/lib/utils/rb.c.o
ccache /home/ubuntu/nxp/iarsystems/arm/bin/iccarm  --silent /home/ubuntu/zephyrproject/zephyr/lib/utils/rb.c -DBOARD_FLASH_SIZE="CONFIG_FLASH_SIZE*1024" -DCPU_MIMXRT1062DVL6A -DKERNEL -DK_HEAP_MEM_POOL_SIZE=0 -DNDEBUG -DXIP_BOOT_HEADER_DCD_ENABLE=1 -DXIP_BOOT_HEADER_ENABLE=1 -DXIP_EXTERNAL_FLASH -D__PROGRAM_START -D__ZEPHYR__=1 -I/home/ubuntu/zephyrproject/zephyr/kernel/include -I/home/ubuntu/zephyrproject/zephyr/arch/arm/include -I/home/ubuntu/zephyrproject/zephyr/drivers/memc -I/home/ubuntu/zephyrproject/zephyr/twister-out/mimxrt1060_evk@C_mimxrt1062_qspi/iar/samples/hello_world/sample.basic.helloworld/zephyr/include/generated/zephyr -I/home/ubuntu/zephyrproject/zephyr/include -I/home/ubuntu/zephyrproject/zephyr/twister-out/mimxrt1060_evk@C_mimxrt1062_qspi/iar/samples/hello_world/sample.basic.helloworld/zephyr/include/generated -I/home/ubuntu/zephyrproject/zephyr/soc/nxp/imxrt -I/home/ubuntu/zephyrproject/zephyr/soc/nxp/imxrt/imxrt10xx/. -I/home/ubuntu/zephyrproject/zephyr/soc/nxp/imxrt/. -I/home/ubuntu/zephyrproject/zephyr/soc/nxp/imxrt/imxrt10xx -I/home/ubuntu/zephyrproject/modules/hal/cmsis/CMSIS/Core/Include -I/home/ubuntu/zephyrproject/zephyr/modules/cmsis/. -I/home/ubuntu/zephyrproject/modules/hal/nxp/mcux/mcux-sdk/devices/MIMXRT1062 -I/home/ubuntu/zephyrproject/modules/hal/nxp/mcux/mcux-sdk/devices/MIMXRT1062/drivers -I/home/ubuntu/zephyrproject/modules/hal/nxp/mcux/mcux-sdk/devices/MIMXRT1062/xip -I/home/ubuntu/zephyrproject/modules/hal/nxp/mcux/mcux-sdk/drivers/common -I/home/ubuntu/zephyrproject/modules/hal/nxp/mcux/mcux-sdk/drivers/lpuart -I/home/ubuntu/zephyrproject/modules/hal/nxp/mcux/mcux-sdk/drivers/igpio -I/home/ubuntu/zephyrproject/modules/hal/nxp/mcux/mcux-sdk/drivers/cache/armv7-m7 -I/home/ubuntu/zephyrproject/zephyr/modules/hal_nxp/. -I/home/ubuntu/zephyrproject/zephyr/lib/libc/minimal/include -I/home/ubuntu/zephyrproject/zephyr/lib/libc/common/include --warnings_are_errors -Ohz --preinclude /home/ubuntu/zephyrproject/zephyr/twister-out/mimxrt1060_evk@C_mimxrt1062_qspi/iar/samples/hello_world/sample.basic.helloworld/zephyr/include/generated/zephyr/autoconf.h --debug --preinclude /home/ubuntu/zephyrproject/zephyr/include/zephyr/toolchain/iar/iar_missing_defs.h -e --language gnu --do_explicit_init_in_named_sections --macro_positions_in_diagnostics --no_wrap_diagnostics --endian=little --cpu=Cortex-M7 -DRTT_USE_ASM=0 --diag_suppress=Ta184 --vla --aeabi --thumb --diag_error=Pe223 --diag_warning=Pe054 --diag_warning=Pe144 --diag_warning=Pe167 --diag_suppress=Pe1675 --diag_suppress=Pe111 --diag_suppress=Pe1143 --diag_suppress=Pe068 -D__IAR_CSTD_c17 -e --dependencies=ns zephyr/CMakeFiles/zephyr.dir/lib/utils/rb.c.o.d -o zephyr/CMakeFiles/zephyr.dir/lib/utils/rb.c.o

        return ((uintptr_t)n->children[0]) & 1UL;
               ^
"/home/ubuntu/zephyrproject/zephyr/lib/utils/rb.c",50  Error[Pe188]: enumerated type mixed with another type
[18/157] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf.c.o
[19/157] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/sem.c.o
[20/157] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/assert.c.o
[21/157] Building C object zephyr/CMakeFiles/zephyr.dir/lib/utils/ring_buffer.c.o
[22/157] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/thread_entry.c.o
[23/157] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/printk.c.o
[24/157] Building C object zephyr/CMakeFiles/zephyr.dir/lib/heap/heap.c.o
[25/157] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf_complete.c.o
[26/157] Building C object zephyr/CMakeFiles/zephyr.dir/lib/utils/bitarray.c.o
ninja: build stopped: subcommand failed.

@RobinKastberg
Copy link
Contributor

@hakehuang I have not understood why toolchain needs to be enabled per test. Since we are aiming for gnu compatiblity I have gone the other way around and blacklisted failing tests instead. Maybe testing WG can help us with proper twister integration. So far we have just used --force-toolchain with twister.

We also have not cleaned up warnings completely yet, see #86002. So we need --disable-warnings-as-errors or -W.
In summary: command-line should be something like
scripts/twister -p mimxrt1060_evk@C/mimxrt1062/qspi -T samples/hello_world/ --build-only --force-toolchain --disable-warnings-as-errors

@hakehuang
Copy link
Contributor

hakehuang commented Mar 5, 2025

I have not understood why toolchain needs to be enabled per test.

it is not enabled per test, it is a logic that every platform need specify its supported tool-chain. I tries with your command which works basically, and let me do more test with. Thanks a lot for your supporting, @RobinKastberg

mimxrt11xx series have below issue:

FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map /home/jenkins/agent/workspace/zephyr_test_pipe/zephyr/twister-out/mimxrt1170_evk@B_mimxrt1176_cm7/iar/samples/hello_world/sample.basic.helloworld/zephyr/zephyr_pre0.map
: && ccache /home/jenkins/agent/workspace/zephyr_test_pipe/iarsystems/arm/bin/ilinkarm --no-wrap-diagnostics  --log modules,libraries,initialization,redirects,sections  CMakeFiles/app.dir/./src/main.c.o  zephyr/CMakeFiles/zephyr.dir/./lib/heap/heap.c.o  zephyr/CMakeFiles/zephyr.dir/./lib/os/cbprintf_packaged.c.o  zephyr/CMakeFiles/zephyr.dir/./lib/os/printk.c.o  zephyr/CMakeFiles/zephyr.dir/./lib/os/sem.c.o  zephyr/CMakeFiles/zephyr.dir/./lib/os/thread_entry.c.o  zephyr/CMakeFiles/zephyr.dir/./lib/os/cbprintf_complete.c.o  zephyr/CMakeFiles/zephyr.dir/./lib/os/cbprintf.c.o  zephyr/CMakeFiles/zephyr.dir/./lib/os/assert.c.o  zephyr/CMakeFiles/zephyr.dir/./lib/utils/dec.c.o  zephyr/CMakeFiles/zephyr.dir/./lib/utils/hex.c.o  zephyr/CMakeFiles/zephyr.dir/./lib/utils/rb.c.o  zephyr/CMakeFiles/zephyr.dir/./lib/utils/timeutil.c.o  zephyr/CMakeFiles/zephyr.dir/./lib/utils/bitarray.c.o  zephyr/CMakeFiles/zephyr.dir/./lib/utils/ring_buffer.c.o  zephyr/CMakeFiles/zephyr.dir/./misc/generated/configs.c.o  zephyr/CMakeFiles/zephyr.dir/./soc/nxp/imxrt/imxrt11xx/soc.c.o  zephyr/CMakeFiles/zephyr.dir/./soc/nxp/imxrt/mpu_regions.c.o  zephyr/CMakeFiles/zephyr.dir/./subsys/mem_mgmt/mem_attr.c.o  zephyr/CMakeFiles/zephyr.dir/./subsys/tracing/tracing_none.c.o  zephyr/arch/common/CMakeFiles/arch__common.dir/./sw_isr_common.c.o  zephyr/arch/arch/arm/core/CMakeFiles/arch__arm__core.dir/./fatal.c.o  zephyr/arch/arch/arm/core/CMakeFiles/arch__arm__core.dir/./nmi.c.o  zephyr/arch/arch/arm/core/CMakeFiles/arch__arm__core.dir/./nmi_on_reset.S.obj  zephyr/arch/arch/arm/core/cortex_m/CMakeFiles/arch__arm__core__cortex_m.dir/./exc_exit.c.o  zephyr/arch/arch/arm/core/cortex_m/CMakeFiles/arch__arm__core__cortex_m.dir/./fault.c.o  zephyr/arch/arch/arm/core/cortex_m/CMakeFiles/arch__arm__core__cortex_m.dir/./fault_s.S.obj  zephyr/arch/arch/arm/core/cortex_m/CMakeFiles/arch__arm__core__cortex_m.dir/./fpu.c.o  zephyr/arch/arch/arm/core/cortex_m/CMakeFiles/arch__arm__core__cortex_m.dir/./reset.S.obj  zephyr/arch/arch/arm/core/cortex_m/CMakeFiles/arch__arm__core__cortex_m.dir/./scb.c.o  zephyr/arch/arch/arm/core/cortex_m/CMakeFiles/arch__arm__core__cortex_m.dir/./thread_abort.c.o  zephyr/arch/arch/arm/core/cortex_m/CMakeFiles/arch__arm__core__cortex_m.dir/./vector_table.S.obj  zephyr/arch/arch/arm/core/cortex_m/CMakeFiles/arch__arm__core__cortex_m.dir/./swap_helper.S.obj  zephyr/arch/arch/arm/core/cortex_m/CMakeFiles/arch__arm__core__cortex_m.dir/./irq_manage.c.o  zephyr/arch/arch/arm/core/cortex_m/CMakeFiles/arch__arm__core__cortex_m.dir/./prep_c.c.o  zephyr/arch/arch/arm/core/cortex_m/CMakeFiles/arch__arm__core__cortex_m.dir/./thread.c.o  zephyr/arch/arch/arm/core/cortex_m/CMakeFiles/arch__arm__core__cortex_m.dir/./cpu_idle.c.o  zephyr/arch/arch/arm/core/cortex_m/CMakeFiles/arch__arm__core__cortex_m.dir/./irq_init.c.o  zephyr/arch/arch/arm/core/cortex_m/CMakeFiles/arch__arm__core__cortex_m.dir/./isr_wrapper.c.o  zephyr/arch/arch/arm/core/cortex_m/CMakeFiles/arch__arm__core__cortex_m.dir/./cache.c.o  zephyr/arch/arch/arm/core/mpu/CMakeFiles/arch__arm__core__mpu.dir/./arm_core_mpu.c.o  zephyr/arch/arch/arm/core/mpu/CMakeFiles/arch__arm__core__mpu.dir/./arm_mpu.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/stdlib/atoi.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/stdlib/strtol.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/stdlib/strtoul.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/stdlib/strtoll.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/stdlib/strtoull.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/stdlib/bsearch.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/stdlib/exit.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/stdlib/qsort.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/string/strerror.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/string/strncasecmp.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/string/strstr.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/string/string.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/string/strspn.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/stdout/stdout_console.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/stdout/sprintf.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/stdout/fprintf.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/math/sqrtf.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/math/sqrt.c.o  zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/./source/time/gmtime.c.o  zephyr/lib/libc/common/CMakeFiles/lib__libc__common.dir/./source/stdlib/abort.c.o  zephyr/lib/libc/common/CMakeFiles/lib__libc__common.dir/./source/time/asctime.c.o  zephyr/lib/libc/common/CMakeFiles/lib__libc__common.dir/./source/time/gmtime_r.c.o  zephyr/lib/libc/common/CMakeFiles/lib__libc__common.dir/./source/time/localtime_r_utc.c.o  zephyr/lib/libc/common/CMakeFiles/lib__libc__common.dir/./source/time/ctime.c.o  zephyr/lib/libc/common/CMakeFiles/lib__libc__common.dir/./source/stdlib/malloc.c.o  zephyr/lib/libc/common/CMakeFiles/lib__libc__common.dir/./source/string/strnlen.c.o  zephyr/boards/nxp/mimxrt1170_evk/CMakeFiles/boards__nxp__mimxrt1170_evk.dir/./home/jenkins/agent/workspace/zephyr_test_pipe/modules/hal/nxp/mcux/mcux-sdk/boards/evkbmimxrt1170/xip/evkbmimxrt1170_flexspi_nor_config.c.o  zephyr/boards/nxp/mimxrt1170_evk/CMakeFiles/boards__nxp__mimxrt1170_evk.dir/./home/jenkins/agent/workspace/zephyr_test_pipe/modules/hal/nxp/mcux/mcux-sdk/boards/evkbmimxrt1170/xmcd/xmcd.c.o  zephyr/drivers/clock_control/CMakeFiles/drivers__clock_control.dir/./clock_control_mcux_ccm_rev2.c.o  zephyr/drivers/console/CMakeFiles/drivers__console.dir/./uart_console.c.o  zephyr/drivers/gpio/CMakeFiles/drivers__gpio.dir/./gpio_mcux_igpio.c.o  zephyr/drivers/memc/CMakeFiles/drivers__memc.dir/./memc_nxp_flexram.c.o  zephyr/drivers/pinctrl/CMakeFiles/drivers__pinctrl.dir/./common.c.o  zephyr/drivers/pinctrl/CMakeFiles/drivers__pinctrl.dir/./pinctrl_imx.c.o  zephyr/drivers/serial/CMakeFiles/drivers__serial.dir/./uart_mcux_lpuart.c.o  zephyr/drivers/timer/CMakeFiles/drivers__timer.dir/./sys_clock_init.c.o  zephyr/drivers/timer/CMakeFiles/drivers__timer.dir/./cortex_m_systick.c.o  modules/hal_nxp/hal_nxp/CMakeFiles/..__modules__hal__nxp.dir/./mcux/mcux-sdk/devices/MIMXRT1176/drivers/fsl_clock.c.o  modules/hal_nxp/hal_nxp/CMakeFiles/..__modules__hal__nxp.dir/./mcux/mcux-sdk/devices/MIMXRT1176/drivers/fsl_romapi.c.o  modules/hal_nxp/hal_nxp/CMakeFiles/..__modules__hal__nxp.dir/./mcux/mcux-sdk/devices/MIMXRT1176/drivers/fsl_pmu.c.o  modules/hal_nxp/hal_nxp/CMakeFiles/..__modules__hal__nxp.dir/./mcux/mcux-sdk/devices/MIMXRT1176/drivers/fsl_dcdc.c.o  modules/hal_nxp/hal_nxp/CMakeFiles/..__modules__hal__nxp.dir/./mcux/mcux-sdk/devices/MIMXRT1176/drivers/fsl_anatop_ai.c.o  modules/hal_nxp/hal_nxp/CMakeFiles/..__modules__hal__nxp.dir/./mcux/mcux-sdk/drivers/common/fsl_common.c.o  modules/hal_nxp/hal_nxp/CMakeFiles/..__modules__hal__nxp.dir/./mcux/mcux-sdk/drivers/common/fsl_common_arm.c.o  modules/hal_nxp/hal_nxp/CMakeFiles/..__modules__hal__nxp.dir/./mcux/mcux-sdk/devices/MIMXRT1176/system_MIMXRT1176_cm7.c.o  modules/hal_nxp/hal_nxp/CMakeFiles/..__modules__hal__nxp.dir/./mcux/mcux-sdk/drivers/lpuart/fsl_lpuart.c.o  modules/hal_nxp/hal_nxp/CMakeFiles/..__modules__hal__nxp.dir/./mcux/mcux-sdk/drivers/igpio/fsl_gpio.c.o  modules/hal_nxp/hal_nxp/CMakeFiles/..__modules__hal__nxp.dir/./mcux/mcux-sdk/drivers/cache/armv7-m7/fsl_cache.c.o  zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.o  --config=/home/jenkins/agent/workspace/zephyr_test_pipe/zephyr/twister-out/mimxrt1170_evk@B_mimxrt1176_cm7/iar/samples/hello_world/sample.basic.helloworld/zephyr/linker_zephyr_pre0.cmd  --map=/home/jenkins/agent/workspace/zephyr_test_pipe/zephyr/twister-out/mimxrt1170_evk@B_mimxrt1176_cm7/iar/samples/hello_world/sample.basic.helloworld/zephyr/zephyr_pre0.map  --log_file=/home/jenkins/agent/workspace/zephyr_test_pipe/zephyr/twister-out/mimxrt1170_evk@B_mimxrt1176_cm7/iar/samples/hello_world/sample.basic.helloworld/zephyr/zephyr_pre0.map.log  zephyr/arch/common/libisr_tables.a  zephyr/kernel/libkernel.a  --entry=__start  --diag_suppress=Lt056  -f /home/jenkins/agent/workspace/zephyr_test_pipe/zephyr/twister-out/mimxrt1170_evk@B_mimxrt1176_cm7/iar/samples/hello_world/sample.basic.helloworld/zephyr/linker_zephyr_pre0.cmd.xcl zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.o -o zephyr/zephyr_pre0.elf && cd /home/jenkins/agent/workspace/zephyr_test_pipe/zephyr/twister-out/mimxrt1170_evk@B_mimxrt1176_cm7/iar/samples/hello_world/sample.basic.helloworld/zephyr && /usr/bin/cmake -E true

   IAR ELF Linker V9.70.1-alpha.5118/LNX [NIGHTLY BUILD ** NOT FOR DISTRIBUTION **] for ARM
   Copyright 2007-2025 IAR Systems AB.
Error[Li005]: no definition for "soc_reset_hook" [referenced from /home/jenkins/agent/workspace/zephyr_test_pipe/zephyr/twister-out/mimxrt1170_evk@B_mimxrt1176_cm7/iar/samples/hello_world/sample.basic.helloworld/zephyr/arch/arch/arm/core/cortex_m/CMakeFiles/arch__arm__core__cortex_m.dir/reset.S.obj]

  17'676 bytes of readonly  code memory
  23'828 bytes of readonly  data memory
   6'963 bytes of readwrite data memory

Errors: 1
Warnings: none

Link time:   0.21 (CPU)   0.22 (elapsed)
ninja: build stopped: subcommand failed.

also there are issues with S32 paltform in cmsis-build

out/s32z2xxdc2@D_s32z270_rtu0/iar/samples/hello_world/sample.basic.helloworld/zephyr/include/generated/zephyr/autoconf.h' 
-- Found C Compiler /home/jenkins/agent/workspace/bitbucket_build_platform/iarsystems/arm/bin/iccarm 
-- Found assembler /opt/toolchains/zephyr-sdk-0.17.0/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc 
-- The C compiler identification is IAR ARM 9.70.1 
-- The CXX compiler identification is IAR ARM 9.70.1 
-- The ASM compiler identification is GNU -- Found assembler: /opt/toolchains/zephyr-sdk-0.17.0/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc Load components for S32Z270: driver_common component is included. driver_reset component is included. device_CMSIS component is included. device_system component is included

...

/home/jenkins/agent/workspace/bitbucket_build_platform/zephyr/include/zephyr/toolchain/iar/iar_missing_defs.h -e --language gnu --do_explicit_init_in_named_sections --macro_positions_in_diagnostics --no_wrap_diagnostics --endian=little --cpu=Cortex-R52 -DRTT_USE_ASM=0 --diag_suppress=Ta184 --vla --aeabi --fpu=VFPv5_D16 --diag_error=Pe223 --diag_warning=Pe054 --diag_warning=Pe144 --diag_warning=Pe167 --diag_suppress=Pe1675 --diag_suppress=Pe111 --diag_suppress=Pe1143 --diag_suppress=Pe068 -D__IAR_CSTD_c17 -e --dependencies=ns zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.o.d -o zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.o #include "cmsis_iccarm.h" ^ "/home/jenkins/agent/workspace/bitbucket_build_platform/modules/hal/cmsis/CMSIS/Core_R/Include/cmsis_compiler.h",55 Fatal error[Pe1696]: cannot open source file "cmsis_iccarm.h" searched: 

@Raymond0225
Copy link
Contributor Author

Please don't remove things just because you don't think they are being used.

I do not agree with this statement. Mistakes might be made but reducing maintenance surface is not a bad thing to try to do. If it had caused a regression it could just be reverted.
We shouldn't discourage contributors from trying to do things like this because they are clearly just trying to improve the quality and maintainability of the project.
When I reviewed this PR I tried also to figure out why the linking description was duplicated in 2 places because something seemed weird about that and I was suspicious at first. But inspecting the git history made it look like it was on accident, and I really couldn't figure out from looking around the tree what it was for. So you've answered now, which is good.

Sorry for being unfriendly. We just got the cmake and ld scripts enough in sync to be able to merge basic IAR support. I had a commit not that long ago trying to fix exactly this file, 2ce0fd6.

The fact that we have two parallel linking systems without a single source of truth, is almost too unbelievable bad to be true. From your perspective I would have done the same thing probably.

I really don't want to discourage anyone from cleaning up and fixing things, we really need those things. But I would encourage figuring out why it was like that in the first place.

Reverting regressions is easy, but finding out about them can be really hard in these lesser tested toolchains/configurations/boards.

As these duplicated linking scripts are used for different tool-chains, is there a way to make it more clear:
a) Use a macro to separate that some part of scripts only used by IAR tool chain and some of them are used by GNU.
b) Add more comments to make sure developer/maintainer know they are duplicated in purpose.

@dleach02
Copy link
Member

dleach02 commented May 5, 2025

@Raymond0225 @RobinKastberg What should we do with this PR?

#define _IMX_BOOT_DCD_SECTION_NAME .boot_hdr.dcd_data
#define _IMX_BOOT_CONTAINER_SECTION_NAME .boot_hdr.container
#define _IMX_BOOT_FLASH_CONF_SECTION_NAME .flash_conf
#define _IMX_BOOT_XMCD_SECTION_NAME .boot_hdr.xmcd_data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you changed the whitespace practice used in the rest of this file from tabs to spaces.

@dleach02
Copy link
Member

100% this is really bad, and we are aware. The toolchain group is looking at it, and with IAR pushing this we should be able to resolve this in a satisfactory manner. My dream would be if we could replace the ld skeletons and make them generated by cmake, one subsystem/module at a time, until such a time that everything is replaced with cmake.

@RobinKastberg is there any update from IAR side on this?

@RobinKastberg
Copy link
Contributor

@RobinKastberg is there any update from IAR side on this?

Yes. I am working on a cmake linker generator refactoring right now. As a part of this I will investigate how hard this kind of snippet generation would be.
However I have many other things on my todo-list as well.

If anyone wants to help I will gladly accept it. Also I should create a separate issue for this.

Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants