Skip to content

Commit 170f4e5

Browse files
committed
app: Add version file and releasing information
- Added version file, which is used in application rollback prevention. - Changed AT#XSMVER to use version file for SM. SM version in format: VERSION_MAJOR.VERSION_MINOR.PATCHLEVEL+VERSION_TWEAK - Added information on how to modify version file and MCUboot monotonic counter for releases. Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no>
1 parent ec2fe6e commit 170f4e5

15 files changed

Lines changed: 115 additions & 114 deletions

app/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,3 @@ target_sources_ifdef(CONFIG_NRF_PROVISIONING app PRIVATE src/sm_at_provisioning.
3737
add_subdirectory_ifdef(CONFIG_SM_CARRIER src/lwm2m_carrier)
3838

3939
zephyr_include_directories(src)
40-
41-
include(cmake/sm_version.cmake)

app/VERSION

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
VERSION_MAJOR = 1
2+
VERSION_MINOR = 99
3+
PATCHLEVEL = 0
4+
VERSION_TWEAK = 0
5+
EXTRAVERSION =

app/cmake/sm_version.cmake

Lines changed: 0 additions & 27 deletions
This file was deleted.

app/cmake/write_sm_version_header.cmake

Lines changed: 0 additions & 44 deletions
This file was deleted.

app/src/sm_at_commands.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "sm_settings.h"
3030
#include "sm_at_host.h"
3131
#include "sm_at_fota.h"
32-
#include "sm_version.h"
32+
#include <zephyr/app_version.h>
3333
#include "sm_at_nrfcloud.h"
3434
#include "sm_log.h"
3535

@@ -75,12 +75,12 @@ STATIC int handle_at_smver(enum at_parser_cmd_type cmd_type, struct at_parser *,
7575

7676
if (cmd_type == AT_PARSER_CMD_TYPE_SET) {
7777
if (strlen(CONFIG_SM_CUSTOMER_VERSION) > 0) {
78-
rsp_send("\r\n#XSMVER: %s,%s,\"%s\"\r\n",
79-
STRINGIFY(SM_VERSION), STRINGIFY(NCS_VERSION_STRING),
78+
rsp_send("\r\n#XSMVER: \"%s\",\"%s\",\"%s\"\r\n",
79+
APP_VERSION_TWEAK_STRING, NCS_VERSION_STRING,
8080
CONFIG_SM_CUSTOMER_VERSION);
8181
} else {
82-
rsp_send("\r\n#XSMVER: %s,%s\r\n",
83-
STRINGIFY(SM_VERSION), STRINGIFY(NCS_VERSION_STRING));
82+
rsp_send("\r\n#XSMVER: \"%s\",\"%s\"\r\n",
83+
APP_VERSION_TWEAK_STRING, NCS_VERSION_STRING);
8484
}
8585
ret = 0;
8686
}

app/tests/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Copied from app/VERSION at CMake configure (see cmake/use_app_version.cmake)
2+
at_commands/VERSION
3+
at_socket/VERSION

app/tests/at_commands/CMakeLists.txt

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,11 @@
44

55
cmake_minimum_required(VERSION 3.20.0)
66

7+
include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/use_app_version.cmake)
8+
79
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
810
project(at_commands)
911

10-
# Generate sm_version.h header
11-
set(GENERATED_DIR "${PROJECT_BINARY_DIR}/generated")
12-
file(MAKE_DIRECTORY "${GENERATED_DIR}")
13-
add_custom_target(
14-
generate_version_header ALL
15-
COMMAND ${CMAKE_COMMAND}
16-
-D OUTPUT_FILE=${GENERATED_DIR}/sm_version.h
17-
-P ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/write_sm_version_header.cmake
18-
BYPRODUCTS ${GENERATED_DIR}/sm_version.h
19-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../..
20-
COMMENT "Regenerating sm_version.h"
21-
)
22-
zephyr_include_directories("${GENERATED_DIR}")
23-
2412
# Compiler options to set configuration values
2513
target_compile_options(app PRIVATE
2614
-DCONFIG_NRF_MODEM_LIB_MEM_DIAG=y

app/tests/at_socket/CMakeLists.txt

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,11 @@
66

77
cmake_minimum_required(VERSION 3.20.0)
88

9+
include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/use_app_version.cmake)
10+
911
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
1012
project(at_socket_test)
1113

12-
# Generate sm_version.h header
13-
set(GENERATED_DIR "${PROJECT_BINARY_DIR}/generated")
14-
file(MAKE_DIRECTORY "${GENERATED_DIR}")
15-
add_custom_target(
16-
generate_version_header ALL
17-
COMMAND ${CMAKE_COMMAND}
18-
-D OUTPUT_FILE=${GENERATED_DIR}/sm_version.h
19-
-P ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/write_sm_version_header.cmake
20-
BYPRODUCTS ${GENERATED_DIR}/sm_version.h
21-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../..
22-
COMMENT "Regenerating sm_version.h"
23-
)
24-
zephyr_include_directories("${GENERATED_DIR}")
25-
2614
# Compiler options to set configuration values
2715
target_compile_options(app PRIVATE
2816
-DCONFIG_NRF_MODEM_LIB_MEM_DIAG=y
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Copyright (c) 2026 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
# Keep app/VERSION as the single source of truth while leaving
8+
# APPLICATION_SOURCE_DIR on the unit-test project (own prj.conf, Kconfig, CMock).
9+
10+
set(SM_APP_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
11+
12+
if(NOT EXISTS "${SM_APP_SOURCE_DIR}/VERSION")
13+
message(FATAL_ERROR "Serial Modem VERSION file not found: ${SM_APP_SOURCE_DIR}/VERSION")
14+
endif()
15+
16+
file(COPY "${SM_APP_SOURCE_DIR}/VERSION" DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}")

doc/app/README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ See the subpages for how to use the application, how to extend it, and informati
7070
sm_build_and_run
7171
sm_logging
7272
sm_configuration
73+
sm_releasing
7374
sm_cellular_modem
7475
sm_data_mode
7576
sm_extending

0 commit comments

Comments
 (0)