Skip to content
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

fix sign when CONFIG_KERNEL_BIN_NAME is used #60121

Merged

Conversation

iuliana-prodan
Copy link
Collaborator

This fixes the following build error:

zephyr/zephyr.elf', needed by 'zephyr/zephyr.ri', missing and no known
rule to make it

This appears when CONFIG_KERNEL_BIN_NAME is used.

Therefore, do not use zephyr.elf since some samples might be called
based on CONFIG_KERNEL_BIN_NAME.

De-duplicate the `if target in ('imx8', 'imx8m'):` copy/paste/diverge
before someone updates one and not the other. Also better to define
bootloader always.

Zero functional change.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

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

soc/xtensa/intel_adsp/common/CMakeLists.txt is missing otherwise LGTM!

Earlier discussions in abandoned:

For the record this is probably the easiest way to reproduce:

west build -p always -b nxp_adsp_imx8m samples/hello_world/ -- \
  -DCONFIG_KERNEL_BIN_NAME='"fubar"'

No special configuration, compiler, overlay, zephyr module or source change required, just this command. So maybe worth adding to the commit message?

@@ -16,5 +16,5 @@ add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/zephyr/zephyr.ri
COMMENT "west sign --if-tool-available --tool rimage ..."
COMMAND west sign --if-tool-available --tool rimage --build-dir ${CMAKE_BINARY_DIR}
DEPENDS ${CMAKE_BINARY_DIR}/zephyr/zephyr.elf
DEPENDS ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME}
Copy link
Collaborator

@marc-hb marc-hb Jul 6, 2023

Choose a reason for hiding this comment

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

Can you please update soc/xtensa/intel_adsp/common/CMakeLists.txt too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've check the intel_adsp CMakeLists.txt when I submitted the PR and again, today, and I don't see any dependency on zephyr.elf.
Without any changes to intel, here's an example of compiling hello_world:

nxa06898@lsv15040:~/data/zephyrproject/zephyr$ west build -p always -b intel_adsp_cavs25 samples/hello_world/ -- -DCONFIG_KERNEL_BIN_NAME='"fubar"'
-- west build: making build dir /opt/samba/nxa06898/zephyrproject/zephyr/build pristine
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /home/nxa06898/data/zephyrproject/zephyr/samples/hello_world
-- CMake version: 3.21.1
-- Found Python3: /usr/bin/python3.8 (found suitable exact version "3.8.0") found components: Interpreter 
-- Cache files will be written to: /home/nxa06898/.cache/zephyr
-- Zephyr version: 3.4.99 (/home/nxa06898/data/zephyrproject/zephyr)
-- Found west (found suitable version "0.14.0", minimum required is "0.14.0")
-- Board: intel_adsp_cavs25
-- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Found host-tools: zephyr 0.16.1 (/opt/zephyr-sdk-0.16.1)
-- Found toolchain: zephyr 0.16.1 (/opt/zephyr-sdk-0.16.1)
-- Found Dtc: /opt/zephyr-sdk-0.16.1/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6") 
-- Found BOARD.dts: /home/nxa06898/data/zephyrproject/zephyr/boards/xtensa/intel_adsp_cavs25/intel_adsp_cavs25.dts
-- Generated zephyr.dts: /home/nxa06898/data/zephyrproject/zephyr/build/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/nxa06898/data/zephyrproject/zephyr/build/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: /home/nxa06898/data/zephyrproject/zephyr/build/zephyr/dts.cmake
/home/nxa06898/data/zephyrproject/zephyr/build/zephyr/zephyr.dts:421.26-426.4: Warning (unit_address_format): /memory@0xb0000000: unit name should not have leading "0x"
/home/nxa06898/data/zephyrproject/zephyr/build/zephyr/zephyr.dts:112.16-115.5: Warning (simple_bus_reg): /soc/timer: missing or empty reg/ranges property
Parsing /home/nxa06898/data/zephyrproject/zephyr/Kconfig
Loaded configuration '/home/nxa06898/data/zephyrproject/zephyr/boards/xtensa/intel_adsp_cavs25/intel_adsp_cavs25_defconfig'
Merged configuration '/home/nxa06898/data/zephyrproject/zephyr/samples/hello_world/prj.conf'
Merged configuration '/home/nxa06898/data/zephyrproject/zephyr/build/zephyr/misc/generated/extra_kconfig_options.conf'
Configuration saved to '/home/nxa06898/data/zephyrproject/zephyr/build/zephyr/.config'
Kconfig header saved to '/home/nxa06898/data/zephyrproject/zephyr/build/zephyr/include/generated/autoconf.h'
-- Found GnuLd: /opt/zephyr-sdk-0.16.1/xtensa-intel_tgl_adsp_zephyr-elf/bin/../lib/gcc/xtensa-intel_tgl_adsp_zephyr-elf/12.2.0/../../../../xtensa-intel_tgl_adsp_zephyr-elf/bin/ld.bfd (found version "2.38") 
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /opt/zephyr-sdk-0.16.1/xtensa-intel_tgl_adsp_zephyr-elf/bin/xtensa-intel_tgl_adsp_zephyr-elf-gcc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/nxa06898/data/zephyrproject/zephyr/build
-- west build: building application
[1/159] Preparing syscall dependency handling

[3/159] Generating include/generated/version.h
-- Zephyr version: 3.4.99 (/home/nxa06898/data/zephyrproject/zephyr), build: zephyr-v3.4.0-755-g664e526a14c1
[157/159] Linking C executable zephyr/fubar.elf
Memory region         Used Size  Region Size  %age Used
vector_base_text:         362 B        376 B     96.28%
 vector_int2_lit:          0 GB          8 B      0.00%
vector_int2_text:          41 B         56 B     73.21%
 vector_int3_lit:          0 GB          8 B      0.00%
vector_int3_text:          41 B         56 B     73.21%
 vector_int4_lit:          0 GB          8 B      0.00%
vector_int4_text:          41 B         56 B     73.21%
 vector_int5_lit:          0 GB          8 B      0.00%
vector_int5_text:          41 B         56 B     73.21%
 vector_int6_lit:          0 GB          8 B      0.00%
vector_int6_text:          41 B         56 B     73.21%
 vector_int7_lit:          0 GB          8 B      0.00%
vector_int7_text:          41 B         56 B     73.21%
vector_kernel_lit:          0 GB          8 B      0.00%
vector_kernel_text:           3 B         56 B      5.36%
 vector_user_lit:          0 GB          8 B      0.00%
vector_user_text:          18 B         56 B     32.14%
vector_double_lit:          0 GB          8 B      0.00%
vector_double_text:           6 B         56 B     10.71%
             imr:        1815 B         1 MB      0.17%
             RAM:       36224 B      2879 KB      1.23%
           ucram:       40792 B      2879 KB      1.38%
        IDT_LIST:          0 GB         8 KB      0.00%
           lpram:          0 GB        64 KB      0.00%
          noload:         240 B         1 MB      0.02%
[159/159] west sign --if-tool-available --tool rimage ...
Signing with tool /opt/samba/nxa06898/sof/build-rimage/rimage
Signing for SOC target tgl
/opt/samba/nxa06898/sof/build-rimage/rimage -o /home/nxa06898/data/zephyrproject/zephyr/build/zephyr/fubar.ri -e -k /opt/samba/nxa06898/zephyrproject/modules/audio/sof/keys/otc_private_key_3k.pem -c /opt/samba/nxa06898/zephyrproject/modules/audio/sof/rimage/config/tgl.toml /home/nxa06898/data/zephyrproject/zephyr/build/zephyr/boot.mod /home/nxa06898/data/zephyrproject/zephyr/build/zephyr/main.mod

Module Reading /home/nxa06898/data/zephyrproject/zephyr/build/zephyr/boot.mod
info: ignore .bss section for bootloader module
  Found 6 sections, listing valid sections......
	No	LMA		VMA		End		Size	Type	Name
	0	0x00000000	0x00000000	0x00000000	0x0
	1	0xb0038000	0xb0038000	0xb0038717	0x717	TEXT	.imr

 module: input size 1815 (0x717) bytes 1 sections
 module: text 1815 (0x717) bytes
    data 0 (0x0) bytes
    bss  0 (0x0) bytes


Module Reading /home/nxa06898/data/zephyrproject/zephyr/build/zephyr/main.mod
  Found 38 sections, listing valid sections......
	No	LMA		VMA		End		Size	Type	Name
	1	0xbe010000	0xbe010000	0xbe01016a	0x16a	TEXT	.WindowVectors.text
	2	0xbe010180	0xbe010180	0xbe0101a9	0x29	TEXT	.Level2InterruptVector.text
	3	0xbe0101c0	0xbe0101c0	0xbe0101e9	0x29	TEXT	.Level3InterruptVector.text
	4	0xbe010200	0xbe010200	0xbe010229	0x29	TEXT	.Level4InterruptVector.text
	5	0xbe010240	0xbe010240	0xbe010269	0x29	TEXT	.Level5InterruptVector.text
	6	0xbe010280	0xbe010280	0xbe0102a9	0x29	TEXT	.DebugExceptionVector.text
	7	0xbe0102c0	0xbe0102c0	0xbe0102e9	0x29	TEXT	.NMIExceptionVector.text
	8	0xbe010300	0xbe010300	0xbe010303	0x3	TEXT	.KernelExceptionVector.text
	9	0xbe010340	0xbe010340	0xbe010352	0x12	TEXT	.UserExceptionVector.text
	10	0xbe0103c0	0xbe0103c0	0xbe0103c6	0x6	TEXT	.DoubleExceptionVector.text
	11	0xbe010400	0xbe010400	0xbe01426e	0x3e6e	TEXT	.text
	12	0xbe015000	0xbe015000	0xbe015338	0x338	DATA	.rodata
	13	0xbe015338	0xbe015338	0xbe0153a0	0x68	DATA	initlevel
	14	0xbe0153a0	0xbe0153a0	0xbe015454	0xb4	DATA	device_area
	15	0xbe015454	0xbe015454	0xbe015474	0x20	DATA	log_const_area
	16	0xbe015480	0xbe015480	0xbe0154a0	0x20	DATA	.data
	17	0xbe0154a0	0xbe0154a0	0xbe015948	0x4a8	DATA	sw_isr_table
	18	0xbe015948	0xbe015948	0xbe01595a	0x12	DATA	device_states
	19	0xbe015980	0xbe015980	0xbe019180	0x3800	DATA	.cached
	20	0xbe01a000	0xbe01a000	0xbe01a358	0x358	BSS	.bss

 module: input size 33335 (0x8237) bytes 20 sections
 module: text 16617 (0x40e9) bytes
    data 16718 (0x414e) bytes
    bss  856 (0x358) bytes

Module Write: /home/nxa06898/data/zephyrproject/zephyr/build/zephyr/boot.mod
 Manifest module metadata section at index 2
 Entry point 0xb0038000

	Totals	Start		End		Size
	TEXT	0xb0038000	0xb0038717	0x717
	DATA	0xffffffff	0x00000000	0x1
	BSS	0x00000000	0x00000000	0x0

 	No	Address		Size		File	Type
	1	0xb0038000	0x717		0x8000	TEXT

 Total pages text 1 data 1 bss 0 module file limit: 0x9000

Module Write: /home/nxa06898/data/zephyrproject/zephyr/build/zephyr/main.mod
 Manifest module metadata section at index 21
 Entry point 0xbe010400

	Totals	Start		End		Size
	TEXT	0xbe010000	0xbe01426e	0x426e
	DATA	0xbe015000	0xbe019180	0x4180
	BSS	0xbe01a000	0xbe01a358	0x358

 	No	Address		Size		File	Type
	1	0xbe010000	0x16a		0x9000	TEXT
	2	0xbe010180	0x29		0x9180	TEXT
	3	0xbe0101c0	0x29		0x91c0	TEXT
	4	0xbe010200	0x29		0x9200	TEXT
	5	0xbe010240	0x29		0x9240	TEXT
	6	0xbe010280	0x29		0x9280	TEXT
	7	0xbe0102c0	0x29		0x92c0	TEXT
	8	0xbe010300	0x3		0x9300	TEXT
	9	0xbe010340	0x12		0x9340	TEXT
	10	0xbe0103c0	0x6		0x93c0	TEXT
	11	0xbe010400	0x3e6e		0x9400	TEXT
	12	0xbe015000	0x338		0xe000	DATA
	13	0xbe015338	0x68		0xe338	DATA
	14	0xbe0153a0	0xb4		0xe3a0	DATA
	15	0xbe015454	0x20		0xe454	DATA
	16	0xbe015480	0x20		0xe480	DATA
	17	0xbe0154a0	0x4a8		0xe4a0	DATA
	18	0xbe015948	0x12		0xe948	DATA
	19	0xbe015980	0x3800		0xe980	DATA

 Total pages text 5 data 5 bss 1 module file limit: 0x13000

Firmware completing manifest v2.5
 meta: completing ADSP manifest
 meta: limit is 0x14ac0
 auth: completing authentication manifest
 cse: ri_css_v2_5_hdr_create completing CSS manifest
 css: set build date to 2023:06:07
 cse: completing CSE V2.5 manifest
 cse: cse checksum e25f22d2
Firmware file size 0x19000 page count 19
 rimage_read_key: read key '/opt/samba/nxa06898/zephyrproject/modules/audio/sof/keys/otc_private_key_3k.pem'
 pkcs: RSA private key is valid.
 pkcs: digest for manifest is c038f50ccc6d85c699e734919552be7fd7ab96316afc045d24382f2aa7694c1f8dd68089766e9dd66466b00b7c8ab487
Firmware manifest and signing completed !
Extended manifest saved to file /home/nxa06898/data/zephyrproject/zephyr/build/zephyr/fubar.ri.xman size 0x0010 (16) bytes

Prefixing /home/nxa06898/data/zephyrproject/zephyr/build/zephyr/fubar.ri with manifest /home/nxa06898/data/zephyrproject/zephyr/build/zephyr/fubar.ri.xman

Copy link
Collaborator

Choose a reason for hiding this comment

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

My bad I forgot about the boot.mod / main.mod split and other differences in intel_adsp. Ignore.

Thanks for testing it!

This fixes the following build error:
```
zephyr/zephyr.elf', needed by 'zephyr/zephyr.ri', missing and no known
rule to make it
```
This appears when CONFIG_KERNEL_BIN_NAME is used.

Therefore, do not use zephyr.elf since some samples might be called
based on CONFIG_KERNEL_BIN_NAME.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
@@ -16,5 +16,5 @@ add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/zephyr/zephyr.ri
COMMENT "west sign --if-tool-available --tool rimage ..."
COMMAND west sign --if-tool-available --tool rimage --build-dir ${CMAKE_BINARY_DIR}
DEPENDS ${CMAKE_BINARY_DIR}/zephyr/zephyr.elf
DEPENDS ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME}
Copy link
Collaborator

Choose a reason for hiding this comment

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

My bad I forgot about the boot.mod / main.mod split and other differences in intel_adsp. Ignore.

Thanks for testing it!

@carlescufi carlescufi merged commit dc49a31 into zephyrproject-rtos:main Jul 10, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants