Skip to content

Commit

Permalink
Update SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins authored and GwendalRaoul committed Nov 9, 2023
1 parent ccb14f6 commit db31168
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 31 deletions.
6 changes: 3 additions & 3 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ app_name=custom_app
target_board=

# Version of the SDK
sdk_major=1
sdk_minor=4
sdk_maintenance=1
sdk_major=0
sdk_minor=0
sdk_maintenance=0
sdk_development=0


Expand Down
4 changes: 2 additions & 2 deletions libraries/provisioning/provisioning.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ provisioning_res_e process_data_packet(void)
}
}

else if (m_conf.method == PROV_METHOD_SECURED)
else if (m_conf.method == PROV_METHOD_SECURED || m_conf.method == PROV_METHOD_EXTENDED_UID)
{
if (pdu->data.key_index == 1)
{
Expand Down Expand Up @@ -415,7 +415,7 @@ static uint32_t state_idle(void)
/* Generate IV for Secured method. The same IV will be used even
* for retries.
*/
if (m_conf.method == PROV_METHOD_SECURED)
if (m_conf.method == PROV_METHOD_SECURED || m_conf.method == PROV_METHOD_EXTENDED_UID)
{
for(int i=0; i < AES_128_KEY_BLOCK_SIZE; i++)
{
Expand Down
1 change: 1 addition & 0 deletions libraries/provisioning/provisioning.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ typedef enum
{
PROV_METHOD_UNSECURED = 0, /**< Unsecured provisioning method. */
PROV_METHOD_SECURED = 1, /**< Secured provisioning method. */
PROV_METHOD_EXTENDED_UID = 3 /**< Extended UID provisioning method. */
} provisioning_method_e;

/**
Expand Down
8 changes: 7 additions & 1 deletion libraries/provisioning/provisioning_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@
#define PROV_DATA_MAX_USER_ID 255

/** Network address for sending and receiving joining beacons */
#define JOINING_NETWORK_ADDRESS 0x89d3b8 // "JBTX"
#define JOINING_NETWORK_ADDRESS 0x9E4ADC // "JBTX"

/** Network channel for sending and receiving joining beacons */
// For Massive, joining network channel is 36
#ifdef MAC_PROFILE_ISM24
#define JOINING_NETWORK_CHANNEL 36
// For other mac profile (SubGhz and 5G Mesh), channel 4 is used
#else
#define JOINING_NETWORK_CHANNEL 4
#endif

/** Time to scan for joining beacons, in milliseconds.
* \ref JOINING_RX_TIMEOUT and \ref JOINING_TX_INTERVAL needs to
Expand Down
5 changes: 5 additions & 0 deletions makefile_app.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ endif
# And version numbers
CFLAGS += -DVER_MAJOR=$(app_major) -DVER_MINOR=$(app_minor) -DVER_MAINT=$(app_maintenance) -DVER_DEV=$(app_development)

# Mac profile
ifeq ("$(mac_profile)","ism_24_ghz")
CFLAGS += -DMAC_PROFILE_ISM24
endif

# Include board init part
-include board/makefile

Expand Down
2 changes: 2 additions & 0 deletions makefile_common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,5 @@ BOOTLOADER_UPDATER_DATA_BIN := $(BUILDPREFIX)bootloader_updater/bootloader_updat
STACK_HEX := $(BUILDPREFIX_STACK)$(FIRMWARE_NAME).hex

APP_HEX := $(BUILDPREFIX_APP)$(APP_NAME).hex

mac_profile?=ism_24_ghz
1 change: 0 additions & 1 deletion makefile_stack.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ include makefile_common.mk


stack_mode?=normal
mac_profile?=ism_24_ghz

$(STACK_HEX): FORCE
# Get the right stack from the image folder
Expand Down
2 changes: 1 addition & 1 deletion source/reference_apps/dualmcu_app/gencustomscratchpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
SCRATCHPAD_V1_TAG = b"SCR1\232\223\060\202\331\353\012\374\061\041\343\067"

# Maximum number of bytes in an input file
MAX_NUM_BYTES_PER_FILE = (8 * 1024 * 1024) # Eight megabytes
MAX_NUM_BYTES_PER_FILE = (1024 * 1024) # One megabyte

# Special CMAC tag constant value that marks a custom readable scratchpad
CMAC_TAG_CONSTANT = b"\xff" * 16
Expand Down
20 changes: 15 additions & 5 deletions source/unitary_apps/provisioning_joining_node/config.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
# This is an example file to customize a node running the provisioning joining node appliation
# using the ExtendedUID method.

# Hex array must start with 0x otherwise it is treated as a string.

# Format is:
#
# provisioning :
# uid : Ex: test_node
# factory_key : (32 bytes string, [0:15 Auth key][16:31 Enc Key]) Needed for sercured method.
# method : (Unsecured:0 or Secured:1) Ex: 0
# device_uid: (16 bytes string, Representing the UID of the device to be provisioned)
# device_uid_type: (1 byte string, Representing the UID type of device_uid)
# authenticator_uid: (16 bytes string, Representing the UID of the authenticator)
# authenticator_uid_type: (1 byte string, Representing the UID type of authenticator_uid)
# Instead of specifying uid components individually, you can specify the whole uid as follows:
# uid: (34 bytes string, [0:1 device_uid_type][1:16 device_uid][16:17 authenticator_uid_type][17:33 authenticator_uid])
# factory_key : (32 bytes string, [0:15 Auth key][16:31 Enc Key]) Needed for secured method.
# method : (Unsecured:0, Secured:1, Extended:3) Ex: 0

provisioning:
uid: test_node
uid: 0x01 0xb3 0x43 0x33 0x00 0x93 0x81 0x08 0x4a 0x8d 0xb3 0xaa 0x9e 0x53 0xd2 0x2a 0x1e 0x01 0x7e 0x71 0xe5 0xd7 0x22 0xef 0x0f 0x4b 0xa8 0x7d 0x44 0xd4 0xe0 0xe5 0xb5 0x7d
node_uid: 0x7e 0x71 0xe5 0xd7 0x22 0xef 0x0f 0x4b 0xa8 0x7d 0x44 0xd4 0xe0 0xe5 0xb5 0x7d
node_uid_type: 0x01
authenticator_uid: 0xb3 0x43 0x33 0x00 0x93 0x81 0x08 0x4a 0x8d 0xb3 0xaa 0x9e 0x53 0xd2 0x2a 0x1e
authenticator_uid_type: 0x01
factory_key : 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0X09 0X0A 0X0B 0X0C 0X0D 0X0E 0X0F 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0X09 0X0A 0X0B 0X0C 0X0D 0X0E 0X0F
method: 1
method: 0x03
14 changes: 14 additions & 0 deletions source/unitary_apps/provisioning_joining_node/config_insecure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This is an example file to customize a node running the provisioning joining node appliation
# using the insecure method.

# Hex array must start with 0x otherwise it is treated as a string.

# Format is:
#
# provisioning :
# uid: (bytes string, less than 79 bytes long)
# method : (Unsecured:0, Secured:1, Extended:3) Ex: 0

provisioning:
uid: 0x41 0xb1 0x85 0x7a 0x0f 0xb6 0xb1 0x48 0xa5 0xe4 0xb9 0xb6 0x03 0x53 0x1b 0x3b
method: 0x00
16 changes: 16 additions & 0 deletions source/unitary_apps/provisioning_joining_node/config_secure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This is an example file to customize a node running the provisioning joining node appliation
# using the secure method.

# Hex array must start with 0x otherwise it is treated as a string.

# Format is:
#
# provisioning :
# uid: (bytes string, less than 79 bytes long)
# factory_key : (32 bytes string, [0:15 Auth key][16:31 Enc Key]) Needed for secured method.
# method : (Unsecured:0, Secured:1, Extended:3) Ex: 0

provisioning:
uid: 0x58 0xc8 0x12 0xad 0x37 0xe8 0x36 0x4a 0xa1 0x1f 0x1c 0xbc 0x63 0x3e 0x8e 0x34
factory_key : 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0X09 0X0A 0X0B 0X0C 0X0D 0X0E 0X0F 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0X09 0X0A 0X0B 0X0C 0X0D 0X0E 0X0F
method: 0x01
31 changes: 19 additions & 12 deletions source/unitary_apps/provisioning_joining_node/genConfigHex.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def to_bytes(param):
else:
param = bytes(param, 'utf-8')
elif type(param) is int:
param.to_bytes((param.bit_length() + 7) // 8, byteorder='big')
param = param.to_bytes(max(1, (param.bit_length() + 7) // 8), byteorder='big')
else:
if type(param) is str:
if param.upper().startswith("0X"):
Expand Down Expand Up @@ -79,7 +79,7 @@ def main():
provisioning."))

parser.add_argument("infilespec",
metavar="INFILESPEC", help="yml personalization file")
metavar="INFILESPEC", default="config.yml", help="yml personalization file")
parser.add_argument("--output", "-o",
metavar="OUTFILESPEC",
help="The output file")
Expand Down Expand Up @@ -116,7 +116,17 @@ def main():
return -1

try:
uid = to_bytes(cfg['provisioning']['uid'])
if "uid" in cfg['provisioning'].keys():
uid = to_bytes(cfg['provisioning']["uid"])
elif cfg['provisioning']["method"] == 3:
node_uid = to_bytes(cfg['provisioning']['node_uid'])
node_uid_type = to_bytes(cfg['provisioning']['node_uid_type'])
authenticator_uid = to_bytes(cfg['provisioning']['authenticator_uid'])
authenticator_uid_type = to_bytes(cfg['provisioning']['authenticator_uid_type'])
uid = authenticator_uid_type + authenticator_uid + node_uid_type + node_uid
else:
raise KeyError

method = to_bytes(cfg['provisioning']['method'])
except KeyError:
sys.stdout.write("%s: UID and Method are mandatory\n" % (pgmname))
Expand All @@ -126,14 +136,14 @@ def main():
except KeyError:
key = b''

sys.stdout.write("%s - UID: %s (len: %d)\n" % (pgmname, uid, len(uid)))
sys.stdout.write("%s - UID: %s (len: %d)\n" % (pgmname, uid.hex(), len(uid)))
sys.stdout.write(
"%s - KEY: %s (len: %d)\n" % (pgmname,
"".join("{:02X}".format(to_int(x)) for x in key), len(key)))
sys.stdout.write("%s - Method: %d\n" % (pgmname, method))
sys.stdout.write("%s - Method: %d\n" % (pgmname, int.from_bytes(method, byteorder='big')))

data = struct.pack("<I", STORAGE_MAGIC) + \
struct.pack("B", method) + \
method + \
struct.pack("B", len(uid)) + \
uid + \
struct.pack("B", len(key)) + \
Expand All @@ -148,12 +158,9 @@ def main():
hextool.save_intel_hex(memory, filename=args.output)
sys.stdout.write("%s - Output file: %s\n" % (pgmname, args.output))
else:
hextool.save_intel_hex(memory,
filename=os.path.splitext(args.infilespec)[0] +
".hex")
sys.stdout.write("%s - Output file: %s\n" %
(pgmname,
os.path.splitext(args.infilespec)[0] + ".hex"))
filename = os.path.splitext(args.infilespec)[0] + ".hex"
hextool.save_intel_hex(memory, filename=filename)
sys.stdout.write("%s - Output file: %s\n" % (pgmname, filename))


# Run main.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#define OFFSET_KEY_LEN (m_uid_len + 6)
#define OFFSET_KEY (m_uid_len + 7)

#define MAX_UID_LEN 32
#define MAX_UID_LEN 79
#define MAX_KEY_LEN 32

#define STORAGE_AREA_ID 0x8AE573BA
Expand Down Expand Up @@ -94,14 +94,15 @@ bool Storage_init()
if (!read(STORAGE_AREA_ID, &magic, OFFSET_MAGIC, 4) ||
magic != STORAGE_MAGIC)
{
LOG(LVL_DEBUG, "Error Magic");
return false;
}

/* Read Method. */
if (!read(STORAGE_AREA_ID, &m_method, OFFSET_METHOD, 1) ||
(m_method != PROV_METHOD_UNSECURED && m_method != PROV_METHOD_SECURED))
(m_method != PROV_METHOD_UNSECURED && m_method != PROV_METHOD_SECURED && m_method != PROV_METHOD_EXTENDED_UID))
{

LOG(LVL_DEBUG, "Error Method");
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion tools/genscratchpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class InFile(object):
'''An input file'''

# Maximum number of bytes in an input file
MAX_NUM_BYTES_PER_FILE = (8 * 1024 * 1024) # Eight megabytes
MAX_NUM_BYTES_PER_FILE = (1024 * 1024) # One megabyte

# Data block length, in bytes
BLOCK_LENGTH = 16
Expand Down
2 changes: 0 additions & 2 deletions version.txt

This file was deleted.

0 comments on commit db31168

Please sign in to comment.