Skip to content

Commit 81713a3

Browse files
keybukCQ Bot Account
authored and
CQ Bot Account
committed
pw_boot_cortex_m: Rename pw_boot_armv7m to pw_boot_cortex_m:armv7m
Since the implementation is closer to a generic Cortex-M implementation, rename pw_boot_armv7m to pw_boot_cortex_m, and add a core-specific target named "armv7m". This matches pw_cpu_exception_cortex_m. Toolchain definitions will need ot be changed from: pw_boot_BACKEND = dir_pw_boot_armv7m to pw_boot_BACKEND = "$dir_pw_boot_cortex_m:arm7vm" Change-Id: Id6f4bbf8e6c1ec89afa63de7c93be1f3afa59f09 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/54242 Commit-Queue: Scott James Remnant <keybuk@google.com> Pigweed-Auto-Submit: Scott James Remnant <keybuk@google.com> Reviewed-by: Keir Mierle <keir@google.com>
1 parent fa7f123 commit 81713a3

File tree

22 files changed

+65
-60
lines changed

22 files changed

+65
-60
lines changed

docs/BUILD.gn

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ group("module_docs") {
6666
"$dir_pw_bloat:docs",
6767
"$dir_pw_blob_store:docs",
6868
"$dir_pw_boot:docs",
69-
"$dir_pw_boot_armv7m:docs",
69+
"$dir_pw_boot_cortex_m:docs",
7070
"$dir_pw_build:docs",
7171
"$dir_pw_bytes:docs",
7272
"$dir_pw_checksum:docs",

docs/os_abstraction_layers.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ before any other embOS API.
464464
.. Note::
465465
To get around this one should invoke these initialization functions earlier
466466
and/or delay the static C++ constructors to meet this ordering requirement. As
467-
an example if you were using :ref:`module-pw_boot_armv7m`, then
467+
an example if you were using :ref:`module-pw_boot_cortex_m`, then
468468
``pw_boot_PreStaticConstructorInit()`` would be a great place to invoke kernel
469469
initialization.
470470

modules.gni

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ declare_args() {
2727
dir_pw_bloat = get_path_info("pw_bloat", "abspath")
2828
dir_pw_blob_store = get_path_info("pw_blob_store", "abspath")
2929
dir_pw_boot = get_path_info("pw_boot", "abspath")
30-
dir_pw_boot_armv7m = get_path_info("pw_boot_armv7m", "abspath")
30+
dir_pw_boot_cortex_m = get_path_info("pw_boot_cortex_m", "abspath")
3131
dir_pw_build = get_path_info("pw_build", "abspath")
3232
dir_pw_bytes = get_path_info("pw_bytes", "abspath")
3333
dir_pw_checksum = get_path_info("pw_checksum", "abspath")

pw_boot_armv7m/BUILD.bazel pw_boot_cortex_m/BUILD.bazel

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ package(default_visibility = ["//visibility:public"])
2121
licenses(["notice"])
2222

2323
pw_cc_library(
24-
name = "pw_boot_armv7m",
24+
name = "armv7m",
2525
srcs = [
2626
"core_init.c",
27-
"public/pw_boot_armv7m/boot.h",
27+
"public/pw_boot_cortex_m/boot.h",
2828
],
2929
includes = ["public"],
3030
target_compatible_with = select({

pw_boot_armv7m/BUILD.gn pw_boot_cortex_m/BUILD.gn

+9-9
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,27 @@ import("$dir_pw_docgen/docs.gni")
2222
declare_args() {
2323
# This list should contain the necessary defines for setting pw_boot linker
2424
# script memory regions.
25-
pw_boot_armv7m_LINK_CONFIG_DEFINES = []
25+
pw_boot_cortex_m_LINK_CONFIG_DEFINES = []
2626
}
2727

28-
if (pw_boot_BACKEND == dir_pw_boot_armv7m) {
28+
if (pw_boot_BACKEND == "$dir_pw_boot_cortex_m:armv7m") {
2929
config("default_config") {
3030
include_dirs = [ "public" ]
3131
}
3232

33-
pw_linker_script("armv7m_linker_script") {
34-
# pw_boot_armv7m_LINK_CONFIG_DEFINES is a list of defines provided by the
33+
pw_linker_script("cortex_m_linker_script") {
34+
# pw_boot_cortex_m_LINK_CONFIG_DEFINES is a list of defines provided by the
3535
# target.
36-
defines = pw_boot_armv7m_LINK_CONFIG_DEFINES
37-
linker_script = "basic_armv7m.ld"
36+
defines = pw_boot_cortex_m_LINK_CONFIG_DEFINES
37+
linker_script = "basic_cortex_m.ld"
3838
}
3939

40-
pw_source_set("pw_boot_armv7m") {
40+
pw_source_set("armv7m") {
4141
public_configs = [ ":default_config" ]
42-
public = [ "public/pw_boot_armv7m/boot.h" ]
42+
public = [ "public/pw_boot_cortex_m/boot.h" ]
4343
public_deps = [ "$dir_pw_preprocessor" ]
4444
deps = [
45-
":armv7m_linker_script",
45+
":cortex_m_linker_script",
4646
"$dir_pw_boot:facade",
4747
]
4848
sources = [ "core_init.c" ]

pw_boot_armv7m/basic_armv7m.ld pw_boot_cortex_m/basic_cortex_m.ld

+12-11
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,45 @@
1414
* the License.
1515
*/
1616

17-
/* This relatively simplified linker script will work with many ARMv7-M cores
18-
* that have on-board memory-mapped RAM and FLASH. For more complex projects and
19-
* devices, it's possible this linker script will not be sufficient as-is.
17+
/* This relatively simplified linker script will work with many ARMv7-M and
18+
* ARMv8-M cores that have on-board memory-mapped RAM and FLASH. For more
19+
* complex projects and devices, it's possible this linker script will not be
20+
* sufficient as-is.
2021
*
2122
* This linker script is likely not suitable for a project with a bootloader.
2223
*/
2324

2425
/* Provide useful error messages when required configurations are not set. */
2526
#ifndef PW_BOOT_VECTOR_TABLE_BEGIN
26-
#error "PW_BOOT_VECTOR_TABLE_BEGIN is not defined, and is required to use pw_boot_armv7m"
27+
#error "PW_BOOT_VECTOR_TABLE_BEGIN is not defined, and is required to use pw_boot_cortex_m"
2728
#endif // PW_BOOT_VECTOR_TABLE_BEGIN
2829

2930
#ifndef PW_BOOT_VECTOR_TABLE_SIZE
30-
#error "PW_BOOT_VECTOR_TABLE_SIZE is not defined, and is required to use pw_boot_armv7m"
31+
#error "PW_BOOT_VECTOR_TABLE_SIZE is not defined, and is required to use pw_boot_cortex_m"
3132
#endif // PW_BOOT_VECTOR_TABLE_SIZE
3233

3334
#ifndef PW_BOOT_FLASH_BEGIN
34-
#error "PW_BOOT_FLASH_BEGIN is not defined, and is required to use pw_boot_armv7m"
35+
#error "PW_BOOT_FLASH_BEGIN is not defined, and is required to use pw_boot_cortex_m"
3536
#endif // PW_BOOT_FLASH_BEGIN
3637

3738
#ifndef PW_BOOT_FLASH_SIZE
38-
#error "PW_BOOT_FLASH_SIZE is not defined, and is required to use pw_boot_armv7m"
39+
#error "PW_BOOT_FLASH_SIZE is not defined, and is required to use pw_boot_cortex_m"
3940
#endif // PW_BOOT_FLASH_SIZE
4041

4142
#ifndef PW_BOOT_RAM_BEGIN
42-
#error "PW_BOOT_RAM_BEGIN is not defined, and is required to use pw_boot_armv7m"
43+
#error "PW_BOOT_RAM_BEGIN is not defined, and is required to use pw_boot_cortex_m"
4344
#endif // PW_BOOT_RAM_BEGIN
4445

4546
#ifndef PW_BOOT_RAM_SIZE
46-
#error "PW_BOOT_RAM_SIZE is not defined, and is required to use pw_boot_armv7m"
47+
#error "PW_BOOT_RAM_SIZE is not defined, and is required to use pw_boot_cortex_m"
4748
#endif // PW_BOOT_RAM_SIZE
4849

4950
#ifndef PW_BOOT_HEAP_SIZE
50-
#error "PW_BOOT_HEAP_SIZE is not defined, and is required to use pw_boot_armv7m"
51+
#error "PW_BOOT_HEAP_SIZE is not defined, and is required to use pw_boot_cortex_m"
5152
#endif // PW_BOOT_HEAP_SIZE
5253

5354
#ifndef PW_BOOT_MIN_STACK_SIZE
54-
#error "PW_BOOT_MIN_STACK_SIZE is not defined, and is required to use pw_boot_armv7m"
55+
#error "PW_BOOT_MIN_STACK_SIZE is not defined, and is required to use pw_boot_cortex_m"
5556
#endif // PW_BOOT_MIN_STACK_SIZE
5657

5758

File renamed without changes.

pw_boot_armv7m/core_init.c pw_boot_cortex_m/core_init.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
#include <stdint.h>
5656
#include <string.h>
5757

58-
#include "pw_boot_armv7m/boot.h"
58+
#include "pw_boot_cortex_m/boot.h"
5959
#include "pw_preprocessor/compiler.h"
6060

6161
// Extern symbols provided by linker script.
@@ -113,8 +113,8 @@ void pw_boot_Entry() {
113113
// Call static constructors.
114114
__libc_init_array();
115115

116-
// This function is not provided by pw_boot_armv7m, a platform layer, project,
117-
// or application is expected to implement it.
116+
// This function is not provided by pw_boot_cortex_m, a platform layer,
117+
// project, or application is expected to implement it.
118118
pw_boot_PreMainInit();
119119

120120
// Run main.

pw_boot_armv7m/docs.rst pw_boot_cortex_m/docs.rst

+19-15
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
.. _module-pw_boot_armv7m:
1+
.. _module-pw_boot_cortex_m:
22

3-
--------------
4-
pw_boot_armv7m
5-
--------------
3+
----------------
4+
pw_boot_cortex_m
5+
----------------
66

7-
The ARMv7-M boot module provides a linker script and some early initialization
8-
of static memory regions and C++ constructors. This is enough to get many
9-
ARMv7-M cores booted and ready to run C++ code.
7+
The ARM Cortex-M boot module provides a linker script and some early
8+
initialization of static memory regions and C++ constructors. This is enough to
9+
get many ARMv7-M and ARMv8-M cores booted and ready to run C++ code.
1010

1111
This module is currently designed to support a very minimal device memory layout
1212
configuration:
@@ -25,8 +25,8 @@ a bootloader, as it's relatively opinionated regarding where code is stored.
2525
Sequence
2626
========
2727

28-
The high level pw_boot_armv7m boot sequence looks like the following pseudo-code
29-
invocation of the user-implemented functions:
28+
The high level pw_boot_cortex_m boot sequence looks like the following
29+
pseudo-code invocation of the user-implemented functions:
3030

3131
.. code:: cpp
3232
@@ -44,6 +44,13 @@ invocation of the user-implemented functions:
4444
Setup
4545
=====
4646

47+
Processor Selection
48+
-------------------
49+
Set the ``pw_boot_BACKEND`` variable to the appropriate target for the processor
50+
in use.
51+
52+
- ``pw_boot_cortex_m:armv7m`` for ARMv7-M cores.
53+
4754
User-Implemented Functions
4855
--------------------------
4956
This module expects all of these extern "C" functions to be defined outside this
@@ -101,14 +108,11 @@ error.
101108
Required Configs
102109
----------------
103110
This module has a number of required configuration options that mold the linker
104-
script to fit to a wide variety of ARMv7-M SoCs. The ``pw_boot_armv7m_config``
105-
GN variable has a ``defines`` member that can be used to modify these linker
106-
script options. See the documentation section on configuration for information
107-
regarding which configuration options are required.
111+
script to fit to a wide variety of ARM Cortex-M SoCs.
108112

109113
Vector Table
110114
------------
111-
Targets using ``pw_boot_armv7m`` will need to provide an ARMv7-M interrupt
115+
Targets using ``pw_boot_cortex_m`` will need to provide an ARMv7-M interrupt
112116
vector table (ARMv7-M Architecture Reference Manual DDI 0403E.b section B1.5.2
113117
and B1.5.3). This is done by storing an array into the ``.vector_table``
114118
section, and properly configuring ``PW_BOOT_VECTOR_TABLE_*`` preprocessor
@@ -167,7 +171,7 @@ stack. This might not be the only stack in the system.
167171
Configuration
168172
=============
169173
These configuration options can be controlled by appending list items to
170-
``pw_boot_armv7m_LINK_CONFIG_DEFINES`` as part of a Pigweed target
174+
``pw_boot_cortex_m_LINK_CONFIG_DEFINES`` as part of a Pigweed target
171175
configuration.
172176

173177
``PW_BOOT_HEAP_SIZE`` (required):

pw_sys_io_arduino/BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ pw_cc_library(
2626
srcs = ["sys_io_arduino.cc"],
2727
hdrs = ["public/pw_sys_io_arduino/init.h"],
2828
deps = [
29-
"//pw_boot_armv7m",
3029
"//pw_preprocessor",
3130
"//pw_sys_io",
3231
],

pw_sys_io_baremetal_lm3s6965evb/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pw_cc_library(
3030
"@platforms//os:none",
3131
],
3232
deps = [
33+
"//pw_boot_cortex_m:armv7m",
3334
"//pw_preprocessor",
3435
"//pw_sys_io:facade",
3536
],

pw_sys_io_baremetal_lm3s6965evb/BUILD.gn

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pw_source_set("pw_sys_io_baremetal_lm3s6965evb") {
2525
public_configs = [ ":default_config" ]
2626
public = [ "public/pw_sys_io_baremetal_lm3s6965evb/init.h" ]
2727
public_deps = [
28-
"$dir_pw_boot_armv7m",
28+
"$dir_pw_boot_cortex_m:armv7m",
2929
"$dir_pw_preprocessor",
3030
]
3131
deps = [

pw_sys_io_baremetal_stm32f429/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pw_cc_library(
3030
"@platforms//os:none",
3131
],
3232
deps = [
33-
"//pw_boot_armv7m",
33+
"//pw_boot_cortex_m:armv7m",
3434
"//pw_preprocessor",
3535
"//pw_sys_io",
3636
],

pw_sys_io_baremetal_stm32f429/BUILD.gn

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pw_source_set("pw_sys_io_baremetal_stm32f429") {
2525
public_configs = [ ":default_config" ]
2626
public = [ "public/pw_sys_io_baremetal_stm32f429/init.h" ]
2727
public_deps = [
28-
"$dir_pw_boot_armv7m",
28+
"$dir_pw_boot_cortex_m:armv7m",
2929
"$dir_pw_preprocessor",
3030
]
3131
deps = [

targets/arduino/target_toolchains.gni

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ _target_config = {
3232
get_path_info("arduino_executable.gni", "abspath")
3333

3434
# Path to the bloaty config file for the output binaries.
35-
pw_bloat_BLOATY_CONFIG = "$dir_pw_boot_armv7m/bloaty_config.bloaty"
35+
pw_bloat_BLOATY_CONFIG = "$dir_pw_boot_cortex_m/bloaty_config.bloaty"
3636

3737
if (pw_arduino_use_test_server) {
3838
_test_runner_script =

targets/lm3s6965evb_qemu/target_toolchains.gni

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ _target_config = {
3131
get_path_info("lm3s6965evb_executable.gni", "abspath")
3232

3333
# Path to the bloaty config file for the output binaries.
34-
pw_bloat_BLOATY_CONFIG = "$dir_pw_boot_armv7m/bloaty_config.bloaty"
34+
pw_bloat_BLOATY_CONFIG = "$dir_pw_boot_cortex_m/bloaty_config.bloaty"
3535

3636
pw_unit_test_AUTOMATIC_RUNNER = get_path_info(_test_runner_script, "abspath")
3737

3838
# Facade backends
3939
pw_assert_BACKEND = dir_pw_assert_basic
40-
pw_boot_BACKEND = dir_pw_boot_armv7m
40+
pw_boot_BACKEND = "$dir_pw_boot_cortex_m:armv7m"
4141
pw_log_BACKEND = dir_pw_log_basic
4242
pw_sys_io_BACKEND = dir_pw_sys_io_baremetal_lm3s6965evb
4343
pw_sync_INTERRUPT_SPIN_LOCK_BACKEND =
@@ -51,7 +51,7 @@ _target_config = {
5151
# pw_cpu_exception_ENTRY_BACKEND =
5252
# "$dir_pw_cpu_exception_cortex_m:cpu_exception_armv7m
5353

54-
pw_boot_armv7m_LINK_CONFIG_DEFINES = [
54+
pw_boot_cortex_m_LINK_CONFIG_DEFINES = [
5555
"PW_BOOT_FLASH_BEGIN=0x00000200",
5656
"PW_BOOT_FLASH_SIZE=255K",
5757
"PW_BOOT_HEAP_SIZE=0",

targets/lm3s6965evb_qemu/vector_table.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include <stdbool.h>
1616

17-
#include "pw_boot_armv7m/boot.h"
17+
#include "pw_boot_cortex_m/boot.h"
1818

1919
// Default handler to insert into the ARMv7-M vector table (below).
2020
// This function exists for convenience. If a device isn't doing what you
@@ -27,7 +27,7 @@ static void DefaultFaultHandler(void) {
2727

2828
// This is the device's interrupt vector table. It's not referenced in any
2929
// code because the platform (STM32F4xx) expects this table to be present at the
30-
// beginning of flash. The exact address is specified in the pw_boot_armv7m
30+
// beginning of flash. The exact address is specified in the pw_boot_cortex_m
3131
// configuration as part of the target config.
3232
//
3333
// For more information, see ARMv7-M Architecture Reference Manual DDI 0403E.b

targets/stm32f429i_disc1/boot.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// License for the specific language governing permissions and limitations under
1313
// the License.
1414

15-
#include "pw_boot_armv7m/boot.h"
15+
#include "pw_boot_cortex_m/boot.h"
1616

1717
#include "pw_malloc/malloc.h"
1818
#include "pw_preprocessor/compiler.h"

targets/stm32f429i_disc1/target_docs.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ file. This should produce output similar to the following:
198198
Type "apropos word" to search for commands related to "word"...
199199
Reading symbols from out/stm32f429i_disc1_debug/obj/pw_assert//test/assert_facade_test.elf...
200200
Remote debugging using :3333
201-
pw_BootEntry () at ../pw_boot_armv7m/core_init.c:117
201+
pw_BootEntry () at ../pw_boot_cortex_m/core_init.c:117
202202
117 }
203203
204204
Step 3: Flash, run, and debug

targets/stm32f429i_disc1/target_toolchains.gni

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ _target_config = {
3434
get_path_info("stm32f429i_executable.gni", "abspath")
3535

3636
# Path to the bloaty config file for the output binaries.
37-
pw_bloat_BLOATY_CONFIG = "$dir_pw_boot_armv7m/bloaty_config.bloaty"
37+
pw_bloat_BLOATY_CONFIG = "$dir_pw_boot_cortex_m/bloaty_config.bloaty"
3838

3939
if (pw_use_test_server) {
4040
_test_runner_script = "py/stm32f429i_disc1_utils/unit_test_client.py"
@@ -44,7 +44,7 @@ _target_config = {
4444

4545
# Facade backends
4646
pw_assert_BACKEND = dir_pw_assert_basic
47-
pw_boot_BACKEND = dir_pw_boot_armv7m
47+
pw_boot_BACKEND = "$dir_pw_boot_cortex_m:armv7m"
4848
pw_cpu_exception_ENTRY_BACKEND =
4949
"$dir_pw_cpu_exception_cortex_m:cpu_exception_armv7m"
5050
pw_cpu_exception_HANDLER_BACKEND = "$dir_pw_cpu_exception:basic_handler"
@@ -59,7 +59,7 @@ _target_config = {
5959
"$dir_pigweed/targets/stm32f429i_disc1:system_rpc_server"
6060
pw_malloc_BACKEND = dir_pw_malloc_freelist
6161

62-
pw_boot_armv7m_LINK_CONFIG_DEFINES = [
62+
pw_boot_cortex_m_LINK_CONFIG_DEFINES = [
6363
"PW_BOOT_FLASH_BEGIN=0x08000200",
6464
"PW_BOOT_FLASH_SIZE=1024K",
6565

targets/stm32f429i_disc1/vector_table.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include <stdbool.h>
1616

17-
#include "pw_boot_armv7m/boot.h"
17+
#include "pw_boot_cortex_m/boot.h"
1818

1919
// Default handler to insert into the ARMv7-M vector table (below).
2020
// This function exists for convenience. If a device isn't doing what you
@@ -27,7 +27,7 @@ static void DefaultFaultHandler(void) {
2727

2828
// This is the device's interrupt vector table. It's not referenced in any
2929
// code because the platform (STM32F4xx) expects this table to be present at the
30-
// beginning of flash. The exact address is specified in the pw_boot_armv7m
30+
// beginning of flash. The exact address is specified in the pw_boot_cortex_m
3131
// configuration as part of the target config.
3232
//
3333
// For more information, see ARMv7-M Architecture Reference Manual DDI 0403E.b

0 commit comments

Comments
 (0)