diff --git a/doc/guides/build/build-build-phase-2.svg b/doc/guides/build/build-build-phase-2.svg index 44073f36705..e24e031a8a2 100644 --- a/doc/guides/build/build-build-phase-2.svg +++ b/doc/guides/build/build-build-phase-2.svg @@ -1,3 +1,4 @@ + -
kernel/*.c
[Not supported by viewer]
arch/x86/*.c
arch/x86/*.S
[Not supported by viewer]

Makefile
(various)

[Not supported by viewer]
Build Stage II (make) – First-pass binary
[Not supported by viewer]
Other sources
[Not supported by viewer]

Headers (*.h)
Includes outputs from Configuration Phase and Build Stage I (e.g.,
autoconf.h, syscall_list.h)

[Not supported by viewer]
kernel/*.c.obj
[Not supported by viewer]
arch/x86/*.c.obj
arch/x86/*.S.obj
[Not supported by viewer]
Other *.obj files
[Not supported by viewer]
linker.cmd
[Not supported by viewer]
libkernel.a
[Not supported by viewer]
arch__x86__core.a
[Not supported by viewer]
Other archives
[Not supported by viewer]
GNU ar
GNU ranlib
[Not supported by viewer]
GNU ar
GNU ranlib
[Not supported by viewer]
GNU ar
GNU ranlib
[Not supported by viewer]
GNU cc
(cpp, cc1, as)
[Not supported by viewer]
GNU cc
(cpp, cc1, as)
[Not supported by viewer]
GNU cc
(cpp, cc1, as)
[Not supported by viewer]
*.h
[Not supported by viewer]
*.h
[Not supported by viewer]
GNU ld
[Not supported by viewer]
zephyr_prebuilt.elf
[Not supported by viewer]

Linker scripts (*.ld)
(various, scattered)

[Not supported by viewer]
GNU cpp
[Not supported by viewer]
scripts/gen_app_partitions.py
[Not supported by viewer]
app_smem linker files
[Not supported by viewer]
\ No newline at end of file +
kernel/*.c
kernel/*.c
arch/x86/*.c
arch/x86/*.S
arch/x86/*.c...

Makefile
(various)

Makefile...
Build Stage II - Generation and Compilation 
Build Stage II - Generation and Compilation 
Other sources
Other sources

Headers (*.h)
Includes outputs from Configuration Phase and Build Stage I (e.g.,
autoconf.h, syscall_list.h)

Headers (*.h)...
kernel/*.c.obj
kernel/*.c.obj
arch/x86/*.c.obj
arch/x86/*.S.obj
arch/x86/*.c.obj...
Other *.obj files
Other *.obj files
libkernel.a
libkernel.a
arch__x86__core.a
arch__x86__core.a
Other archives
Other archives
GNU ar
GNU ranlib
GNU ar...
GNU ar
GNU ranlib
GNU ar...
GNU ar
GNU ranlib
GNU ar...
GNU cc
(cpp, cc1, as)
GNU cc...
GNU cc
(cpp, cc1, as)
GNU cc...
GNU cc
(cpp, cc1, as)
GNU cc...
*.h
*.h
*.h
*.h
scripts/gen_app_partitions.py
scripts/gen_app_partitions.py
app_smem_unaligned
linker files
app_smem_unaligned...
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/doc/guides/build/build-build-phase-3.svg b/doc/guides/build/build-build-phase-3.svg index b37bfde83d8..ef1581ab320 100644 --- a/doc/guides/build/build-build-phase-3.svg +++ b/doc/guides/build/build-build-phase-3.svg @@ -1,3 +1,4 @@ + -

Makefile
(various)

[Not supported by viewer]
Build Stage III (make) – Final binary
[Not supported by viewer]
zephyr_prebuilt.elf
[Not supported by viewer]
scripts/gen_kobject_list.py
(Find all kernel objects)
[Not supported by viewer]
kobject_hash.gperf
[Not supported by viewer]

otype-to-str.h
otype-to-size.h
kobj-types-enum.h
driver-validation.h

[Not supported by viewer]
GNU gperf
[Not supported by viewer]
kobject_hash_preprocessed.c
[Not supported by viewer]
scripts/process_gperf.py
(Optimize hashing)
[Not supported by viewer]
kobject_hash.c
[Not supported by viewer]
GNU cc
(cpp, cc1, as)
[Not supported by viewer]
kobject_hash.c.obj
[Not supported by viewer]
kobject_hash_renamed.o
[Not supported by viewer]
GNU objdump
[Not supported by viewer]
linker.cmd
[Not supported by viewer]
GNU ld
[Not supported by viewer]
zephyr.elf
[Not supported by viewer]
Other archives from previous page
[Not supported by viewer]
zephyr.map
[Not supported by viewer]

Linker scripts (*.ld)
(various, scattered)

[Not supported by viewer]
GNU cpp
[Not supported by viewer]
app_smem linker files
[Not supported by viewer]
\ No newline at end of file +

Makefile
(various)

Makefile...
Build Stage III - Intermediate binary
Build Stage III - Intermediate binary
linker.cmd
linker.cmd
libkernel.a
libkernel.a
arch__x86__core.a
arch__x86__core.a
Other archives
Other archives
GNU ld
GNU ld
zephyr_pre0.elf
zephyr_pre0.elf

Linker scripts (*.ld)
(various, scattered)

Linker scripts (*.ld)...
GNU cpp
GNU cpp
app_smem_unaligned linker files
app_smem_unaligned linker file...
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/doc/guides/build/build-build-phase-4.svg b/doc/guides/build/build-build-phase-4.svg index 2b38e432c18..1b742c7c0af 100644 --- a/doc/guides/build/build-build-phase-4.svg +++ b/doc/guides/build/build-build-phase-4.svg @@ -1,3 +1,4 @@ + -

Makefile
(various)

[Not supported by viewer]
Build Stage IV (make) – Post-Processing
[Not supported by viewer]
GNU objdump
[Not supported by viewer]
zephyr.elf
[Not supported by viewer]
zephyr.elf
[Not supported by viewer]
GNU objdump
[Not supported by viewer]
zephyr.bin
[Not supported by viewer]
zephyr.hex
[Not supported by viewer]
\ No newline at end of file +

Makefile
(various)

Makefile...
Build Stage IV - Intermediate binary
Build Stage IV - Intermediate binary
linker.cmd
linker.cmd
libkernel.a
libkernel.a
arch__x86__core.a
arch__x86__core.a
Other archives
Other archives
GNU ld
GNU ld
zephyr_pre1.elf
zephyr_pre1.elf

Linker scripts (*.ld)
(various, scattered)

Linker scripts (*.ld)...
GNU cpp
GNU cpp
app_smem_aligned
linker files
app_smem_aligned...
GNU cc%3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20value%3D%22%26lt%3Bfont%20style%3D%26quot%3Bfont-size%3A16px%3Bfont-family%3ACalibri%3Bcolor%3A%23feffff%3Bdirection%3Altr%3Bletter-spacing%3A0px%3Bline-height%3A120%25%3Bopacity%3A1%26quot%3B%26gt%3BGNU%20cc%26lt%3Bbr%2F%26gt%3B(cpp%2C%20cc1%2C%20as)%26lt%3Bbr%2F%26gt%3B%26lt%3B%2Ffont%26gt%3B%22%20style%3D%22verticalAlign%3Dmiddle%3Balign%3Dcenter%3BvsdxID%3D33%3BfillColor%3D%235b9bd5%3BgradientColor%3Dnone%3Bshape%3Dstencil(nZBLDoAgDERP0z3SIyjew0SURgSD%2BLu9kMZoXLhwN9O%2BtukAlrNpJg1SzDH4QW%2FURgNYgZTkjA4UkwJUgGXng%2B6DX1zLfmoymdXo17xh5zmRJ6Q42BWCfc2oJfdAr%2BYv%2BAP9Cb7OJ3H%2F2JG1HNGz%2F84klThPVCc%3D)%3BstrokeColor%3D%23939393%3BlabelBackgroundColor%3Dnone%3Brounded%3D0%3Bhtml%3D1%3BwhiteSpace%3Dwrap%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22501%22%20y%3D%22229%22%20width%3D%22101%22%20height%3D%2250%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3
GNU cc%3CmxGraphM...
dev_handles.c
dev_handles.c
dev_handles.obj
dev_handles.obj
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/doc/guides/build/build-build-phase-5.svg b/doc/guides/build/build-build-phase-5.svg new file mode 100644 index 00000000000..ad137bed9b7 --- /dev/null +++ b/doc/guides/build/build-build-phase-5.svg @@ -0,0 +1,4 @@ + + + +

Makefile
(various)

Makefile...
Build Stage V - Final binary
Build Stage V - Final binary
linker.cmd
linker.cmd
libkernel.a
libkernel.a
arch__x86__core.a
arch__x86__core.a
Other archives
Other archives
GNU ld
GNU ld
zephyr.elf
zephyr.elf

Linker scripts (*.ld)
(various, scattered)

Linker scripts (*.ld)...
GNU cpp
GNU cpp
app_smem_aligned
linker files
app_smem_aligned...
GNU cc%3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20value%3D%22%26lt%3Bfont%20style%3D%26quot%3Bfont-size%3A16px%3Bfont-family%3ACalibri%3Bcolor%3A%23feffff%3Bdirection%3Altr%3Bletter-spacing%3A0px%3Bline-height%3A120%25%3Bopacity%3A1%26quot%3B%26gt%3BGNU%20cc%26lt%3Bbr%2F%26gt%3B(cpp%2C%20cc1%2C%20as)%26lt%3Bbr%2F%26gt%3B%26lt%3B%2Ffont%26gt%3B%22%20style%3D%22verticalAlign%3Dmiddle%3Balign%3Dcenter%3BvsdxID%3D33%3BfillColor%3D%235b9bd5%3BgradientColor%3Dnone%3Bshape%3Dstencil(nZBLDoAgDERP0z3SIyjew0SURgSD%2BLu9kMZoXLhwN9O%2BtukAlrNpJg1SzDH4QW%2FURgNYgZTkjA4UkwJUgGXng%2B6DX1zLfmoymdXo17xh5zmRJ6Q42BWCfc2oJfdAr%2BYv%2BAP9Cb7OJ3H%2F2JG1HNGz%2F84klThPVCc%3D)%3BstrokeColor%3D%23939393%3BlabelBackgroundColor%3Dnone%3Brounded%3D0%3Bhtml%3D1%3BwhiteSpace%3Dwrap%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22501%22%20y%3D%22229%22%20width%3D%22101%22%20height%3D%2250%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3
GNU cc%3CmxGraphM...
dev_handles.c
dev_handles.c
dev_handles.obj
dev_handles.obj
GNU cc%3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20value%3D%22%26lt%3Bfont%20style%3D%26quot%3Bfont-size%3A16px%3Bfont-family%3ACalibri%3Bcolor%3A%23feffff%3Bdirection%3Altr%3Bletter-spacing%3A0px%3Bline-height%3A120%25%3Bopacity%3A1%26quot%3B%26gt%3BGNU%20cc%26lt%3Bbr%2F%26gt%3B(cpp%2C%20cc1%2C%20as)%26lt%3Bbr%2F%26gt%3B%26lt%3B%2Ffont%26gt%3B%22%20style%3D%22verticalAlign%3Dmiddle%3Balign%3Dcenter%3BvsdxID%3D33%3BfillColor%3D%235b9bd5%3BgradientColor%3Dnone%3Bshape%3Dstencil(nZBLDoAgDERP0z3SIyjew0SURgSD%2BLu9kMZoXLhwN9O%2BtukAlrNpJg1SzDH4QW%2FURgNYgZTkjA4UkwJUgGXng%2B6DX1zLfmoymdXo17xh5zmRJ6Q42BWCfc2oJfdAr%2BYv%2BAP9Cb7OJ3H%2F2JG1HNGz%2F84klThPVCc%3D)%3BstrokeColor%3D%23939393%3BlabelBackgroundColor%3Dnone%3Brounded%3D0%3Bhtml%3D1%3BwhiteSpace%3Dwrap%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22501%22%20y%3D%22229%22%20width%3D%22101%22%20height%3D%2250%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3
GNU cc%3CmxGraphM...
isr_tables.c
isr_tables.c
isr_tables.obj
isr_tables.obj
kobject_hash_renamed.o
kobject_hash_renamed.o
zephyr.map
zephyr.map
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/doc/guides/build/build-build-phase-6.svg b/doc/guides/build/build-build-phase-6.svg new file mode 100644 index 00000000000..55337cd8fd0 --- /dev/null +++ b/doc/guides/build/build-build-phase-6.svg @@ -0,0 +1,4 @@ + + + +

Makefile
(various)

Makefile...
Build Stage VI – Post-Processing
Build Stage VI – Post-Processing
GNU objdump
GNU objdump
zephyr.elf
zephyr.elf
zephyr.elf
zephyr.elf
GNU objdump
GNU objdump
zephyr.bin
zephyr.bin
zephyr.hex
zephyr.hex
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/doc/guides/build/build-postprocess-1.svg b/doc/guides/build/build-postprocess-1.svg new file mode 100644 index 00000000000..39ff6db0aff --- /dev/null +++ b/doc/guides/build/build-postprocess-1.svg @@ -0,0 +1,4 @@ + + + +

Makefile
(various)

Makefile...
App partition grouping
App partition grouping
zephyr_pre0.elf
zephyr_pre0.elf
scripts/gen_app_partitions.py
scripts/gen_app_partitions.py
app_smem_aligned.ld
app_smem_aligned.ld
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/doc/guides/build/build-postprocess-2.svg b/doc/guides/build/build-postprocess-2.svg new file mode 100644 index 00000000000..37b01333f42 --- /dev/null +++ b/doc/guides/build/build-postprocess-2.svg @@ -0,0 +1,4 @@ + + + +

Makefile
(various)

Makefile...
Device handles
Device handles
zephyr_pre0.elf
zephyr_pre0.elf
scripts/gen_handles.py
scripts/gen_handles.py
dev_handles.c
dev_handles.c
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/doc/guides/build/build-postprocess-3.svg b/doc/guides/build/build-postprocess-3.svg new file mode 100644 index 00000000000..b1b584a1d54 --- /dev/null +++ b/doc/guides/build/build-postprocess-3.svg @@ -0,0 +1,4 @@ + + + +

Makefile
(various)

Makefile...
Interrupt tables
Interrupt tables
zephyr_pre1.elf
zephyr_pre1.elf
arch/common/gen_isr_tables.py
arch/common/gen_isr_tables.py
isr_tables.c
isr_tables.c
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/doc/guides/build/build-postprocess-4.svg b/doc/guides/build/build-postprocess-4.svg new file mode 100644 index 00000000000..8e8b42aeed0 --- /dev/null +++ b/doc/guides/build/build-postprocess-4.svg @@ -0,0 +1,4 @@ + + + +

Makefile
(various)

Makefile...
Kernel object hash
Kernel object hash
zephyr_pre1.elf
zephyr_pre1.elf
scripts/gen_kobject_list.py
(Find all kernel objects)
scripts/gen_kobject_list.py...
kobject_hash.gperf
kobject_hash.gperf

otype-to-str.h
otype-to-size.h
kobj-types-enum.h
driver-validation.h

otype-to-str.h...
GNU gperf
GNU gperf
kobject_hash_preprocessed.c
kobject_hash_preprocessed.c
scripts/process_gperf.py
(Optimize hashing)
scripts/process_gperf.py...
kobject_hash.c
kobject_hash.c
GNU cc
(cpp, cc1, as)
GNU cc...
kobject_hash.c.obj
kobject_hash.c.obj
kobject_hash_renamed.o
kobject_hash_renamed.o
GNU objdump
GNU objdump
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/doc/guides/build/index.rst b/doc/guides/build/index.rst index 41e0eb28211..c38e3f06002 100644 --- a/doc/guides/build/index.rst +++ b/doc/guides/build/index.rst @@ -165,14 +165,23 @@ System call boilerplate :figclass: align-center :width: 80% -First-pass binary -+++++++++++++++++ +Intermediate binaries ++++++++++++++++++++++ -Compilation proper begins with the first-pass binary. Source files (C +Compilation proper begins with the first intermediate binary. Source files (C and assembly) are collected from various subsystems (which ones is decided during the configuration phase), and compiled into archives (with reference to header files in the tree, as well as those -generated during the configuration phase and the pre-build stage). +generated during the configuration phase and the pre-build stage(s)). + +.. figure:: build-build-phase-2.svg + :align: center + :alt: Zephyr's build stage II + :figclass: align-center + :width: 80% + +The exact number of intermediate binaries is decided during the configuration +phase. If memory protection is enabled, then: @@ -189,27 +198,79 @@ the configuration process, into a *linker.cmd* file. The compiled archives are then linked with *ld* as specified in the *linker.cmd*. -In some configurations, this is the final binary, and the next stage -is skipped. +Unfixed size binary + The unfixed size intermediate binary is produced when :ref:`usermode_api` + is enabled or :ref:`devicetree` is in use. + It produces a binary where sizes are not fixed and thus it may be used + by post-process steps that will impact the size of the final binary. -.. figure:: build-build-phase-2.svg +.. figure:: build-build-phase-3.svg :align: center - :alt: Zephyr's build stage II + :alt: Zephyr's build stage III :figclass: align-center :width: 80% -Final binary -++++++++++++ +Fixed size binary + The fixed size intermediate binary is produced when :ref:`usermode_api` + is enabled or when generated IRQ tables are used, + :kconfig:`CONFIG_GEN_ISR_TABLES` + It produces a binary where sizes are fixed and thus the size must not change + between the intermediate binary and the final binary. -The binary from the previous stage is incomplete, with empty and/or +.. figure:: build-build-phase-4.svg + :align: center + :alt: Zephyr's build stage IV + :figclass: align-center + :width: 80% + +Intermediate binaries post-processing ++++++++++++++++++++++++++++++++++++++ + +The binaries from the previous stage are incomplete, with empty and/or placeholder sections that must be filled in by, essentially, reflection. +To complete the build procedure the following scripts are executed on the +intermediate binaries to produce the missing pieces needed for the final +binary. + +When :ref:`usermode_api` is enabled: + +Partition alignment + The *gen_app_partitions.py* script scans the unfixed size binary and + generates an app shared memory aligned linker script snippet where the + partitions are sorted in descending order. + +.. figure:: build-postprocess-1.svg + :align: center + :alt: Zephyr's intermediate binary post-process I + :figclass: align-center + :width: 80% + +When :ref:`devicetree` is used: + Device dependencies - The *gen_handles.py* script scans the first-pass binary to determine + The *gen_handles.py* script scans the unfixed size binary to determine relationships between devices that were recorded from devicetree data, and replaces the encoded relationships with values that are optimized to locate the devices actually present in the application. +.. figure:: build-postprocess-2.svg + :align: center + :alt: Zephyr's intermediate binary post-process II + :figclass: align-center + :width: 80% + +When :kconfig:`CONFIG_GEN_ISR_TABLES` is enabled: + The *gen_isr_tables.py* script scant the fixed size binary and creates + an isr_tables.c source file with a hardware vector table and/or software + IRQ table. + +.. figure:: build-postprocess-3.svg + :align: center + :alt: Zephyr's intermediate binary post-process III + :figclass: align-center + :width: 80% + When :ref:`usermode_api` is enabled: Kernel object hashing @@ -219,15 +280,29 @@ Kernel object hashing table of those addresses, then that output is optimized by *process_gperf.py*, using known properties of our special case. -Then, the link from the previous stage is repeated, this time with the -missing pieces populated. - -.. figure:: build-build-phase-3.svg +.. figure:: build-postprocess-4.svg :align: center - :alt: Zephyr's build stage III + :alt: Zephyr's intermediate binary post-process IV :figclass: align-center :width: 80% +When no intermediate binary post-processing is required then the first +intermediate binary will be directly used as the final binary. + +Final binary +++++++++++++ + +The binary from the previous stage is incomplete, with empty and/or +placeholder sections that must be filled in by, essentially, reflection. + +The link from the previous stage is repeated, this time with the missing +pieces populated. + +.. figure:: build-build-phase-5.svg + :align: center + :alt: Zephyr's build final stage + :figclass: align-center + :width: 80% Post processing +++++++++++++++ @@ -236,9 +311,9 @@ Finally, if necessary, the completed kernel is converted from *ELF* to the format expected by the loader and/or flash tool required by the target. This is accomplished in a straightforward manner with *objdump*. -.. figure:: build-build-phase-4.svg +.. figure:: build-build-phase-6.svg :align: center - :alt: Zephyr's build final stage + :alt: Zephyr's build final stage post-process :figclass: align-center :width: 80%