nRF Connect SDK API 2.8.99
Loading...
Searching...
No Matches
pcd_common.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
17#ifndef PCD_COMMON_H__
18#define PCD_COMMON_H__
19
20#ifndef CONFIG_SOC_SERIES_NRF53X
21#error "PCD is only supported on nRF53 series"
22#endif
23
24#ifdef CONFIG_PCD_CMD_ADDRESS
25/* PCD command block location is static. */
26#define PCD_CMD_ADDRESS CONFIG_PCD_CMD_ADDRESS
27
28#else
29/* PCD command block location is configured with Partition Manager. */
30#include <pm_config.h>
31
32#ifdef PM_PCD_SRAM_ADDRESS
33/* PCD command block is in this domain, we are compiling for application core. */
34#define PCD_CMD_ADDRESS PM_PCD_SRAM_ADDRESS
35#else
36/* PCD command block is in a different domain, we are compiling for network core.
37 * Extra '_' since its in a different domain.
38 */
39#define PCD_CMD_ADDRESS PM__PCD_SRAM_ADDRESS
40#endif /* PM_PCD_SRAM_ADDRESS */
41
42#endif /* CONFIG_PCD_CMD_ADDRESS */
43
45#define PCD_CMD_MAGIC_COPY 0xb5b4b3b6
47#define PCD_CMD_MAGIC_LOCK_DEBUG 0xb6f249ec
49#define PCD_CMD_MAGIC_FAIL 0x25bafc15
51#define PCD_CMD_MAGIC_DONE 0xf103ce5d
53#define PCD_CMD_MAGIC_READ_VERSION 0xdca345ea
54
55struct pcd_cmd {
56 uint32_t magic; /* Magic value to identify this structure in memory */
57 const void *data; /* Data to copy*/
58 size_t len; /* Number of bytes to copy */
59 __INTPTR_TYPE__ offset; /* Offset to store the flash image in */
60} __aligned(4);
61
62#define PCD_CMD ((volatile struct pcd_cmd * const)(PCD_CMD_ADDRESS))
63
64static inline void pcd_write_cmd_lock_debug(void)
65{
66 *PCD_CMD = (struct pcd_cmd){
68 };
69}
70
71static inline bool pcd_read_cmd_done(void)
72{
73 return PCD_CMD->magic == PCD_CMD_MAGIC_DONE;
74}
75
76static inline bool pcd_read_cmd_lock_debug(void)
77{
78 return PCD_CMD->magic == PCD_CMD_MAGIC_LOCK_DEBUG;
79}
80
81#endif /* PCD_COMMON_H__ */
82
static bool pcd_read_cmd_done(void)
Definition pcd_common.h:71
#define PCD_CMD
Definition pcd_common.h:62
static bool pcd_read_cmd_lock_debug(void)
Definition pcd_common.h:76
static void pcd_write_cmd_lock_debug(void)
Definition pcd_common.h:64
#define PCD_CMD_MAGIC_LOCK_DEBUG
Definition pcd_common.h:47
#define PCD_CMD_MAGIC_DONE
Definition pcd_common.h:51
const void * data
Definition pcd_common.h:57
__INTPTR_TYPE__ offset
Definition pcd_common.h:59
uint32_t magic
Definition pcd_common.h:56
size_t len
Definition pcd_common.h:58
Definition pcd_common.h:55