Skip to content

Commit 61b510e

Browse files
evedonLiyouZhou
authored andcommitted
Removed update-client-hub dependency (ARMmbed#163)
* Removed update-client-hub dependency * Clean up folder structure - move all sources to sources folder - move all dependencies to modules folder Under modules: 1- Folder metadata-header/ is created for files common to bootloader and update client. This folder is duplicated in UC repo . 2- Folder update-client-common: This folder has currently 4 files which are duplicated from update client common/ folder. All files could be modified to include declarations for bootloader only. This can be done at a later stage. 3- Storage folders: Folder paal/ is duplicated in bootloader and UC repositories. Folder pal-blockdevice/ This folder will live in Mbed OS Bootloader repo. Folder pal-flashiap/ This folder will live in Mbed OS Bootloader repo. Duplication of UC folders from commit 2c0ae5f485eaf2ccbb0e364262ddfd4ea19ba6f7 4- minimal printf
1 parent 1d54ec9 commit 61b510e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+4964
-6
lines changed

Jenkinsfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def powerCutTestStep(step_name,
234234
env.RAAS_PYCLIENT_ALLOCATION_QUEUE_TIMEOUT = raas_timeout
235235

236236
execute("mbedgt --grm ${target}:raas_client:liisa.mbedcloudtesting.com:80 -V -v " +
237-
"--test-spec ${test_spec} -e power_cut_test/host_tests/")
237+
"--test-spec ${test_spec} -e source/power_cut_test/host_tests/")
238238
}
239239
}
240240
}
@@ -261,8 +261,8 @@ def sizeTestStepSimple(stepName) {
261261
}
262262

263263
def bootloader_test_config = [
264-
// ["K64F", "ARM", "configs/test_configs/power_cut_test.json", "power_cut_test/test_spec_armcc.json"],
265-
["K64F", "GCC_ARM", "configs/test_configs/power_cut_test.json", "power_cut_test/test_spec_gcc.json"]
264+
// ["K64F", "ARM", "configs/test_configs/power_cut_test.json", "source/power_cut_test/test_spec_armcc.json"],
265+
["K64F", "GCC_ARM", "configs/test_configs/power_cut_test.json", "source/power_cut_test/test_spec_gcc.json"]
266266
]
267267

268268
for (int i = 0; i < bootloader_test_config.size(); i++) {
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
// ----------------------------------------------------------------------------
2+
// Copyright 2016-2017 ARM Ltd.
3+
//
4+
// SPDX-License-Identifier: Apache-2.0
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
// ----------------------------------------------------------------------------
18+
19+
#include "update-client-metadata-header/arm_uc_buffer_utilities.h"
20+
21+
22+
uint32_t arm_uc_crc32(const uint8_t *buffer, uint32_t length)
23+
{
24+
const uint8_t *current = buffer;
25+
uint32_t crc = 0xFFFFFFFF;
26+
27+
while (length--) {
28+
crc ^= *current++;
29+
30+
for (uint32_t counter = 0; counter < 8; counter++) {
31+
if (crc & 1) {
32+
crc = (crc >> 1) ^ 0xEDB88320;
33+
} else {
34+
crc = crc >> 1;
35+
}
36+
}
37+
}
38+
39+
return (crc ^ 0xFFFFFFFF);
40+
}
41+
42+
uint32_t arm_uc_parse_uint32(const uint8_t *input)
43+
{
44+
uint32_t result = 0;
45+
46+
if (input) {
47+
result = input[0];
48+
result = (result << 8) | input[1];
49+
result = (result << 8) | input[2];
50+
result = (result << 8) | input[3];
51+
}
52+
53+
return result;
54+
}
55+
56+
uint64_t arm_uc_parse_uint64(const uint8_t *input)
57+
{
58+
uint64_t result = 0;
59+
60+
if (input) {
61+
result = input[0];
62+
result = (result << 8) | input[1];
63+
result = (result << 8) | input[2];
64+
result = (result << 8) | input[3];
65+
result = (result << 8) | input[4];
66+
result = (result << 8) | input[5];
67+
result = (result << 8) | input[6];
68+
result = (result << 8) | input[7];
69+
}
70+
71+
return result;
72+
}
73+
74+
void arm_uc_write_uint32(uint8_t *buffer, uint32_t value)
75+
{
76+
if (buffer) {
77+
buffer[3] = value;
78+
buffer[2] = (value >> 8);
79+
buffer[1] = (value >> 16);
80+
buffer[0] = (value >> 24);
81+
}
82+
}
83+
84+
void arm_uc_write_uint64(uint8_t *buffer, uint64_t value)
85+
{
86+
if (buffer) {
87+
buffer[7] = value;
88+
buffer[6] = (value >> 8);
89+
buffer[5] = (value >> 16);
90+
buffer[4] = (value >> 24);
91+
buffer[3] = (value >> 32);
92+
buffer[2] = (value >> 40);
93+
buffer[1] = (value >> 48);
94+
buffer[0] = (value >> 56);
95+
}
96+
}
97+
98+
// Constant time binary comparison
99+
uint32_t ARM_UC_BinCompareCT(const arm_uc_buffer_t *a, const arm_uc_buffer_t *b)
100+
{
101+
uint32_t result;
102+
uint32_t i;
103+
const uint32_t bytes = a->size;
104+
105+
// Check sizes
106+
if (a->size != b->size) {
107+
return 1;
108+
}
109+
result = 0;
110+
for (i = 0; i < bytes; i++) {
111+
result = result | (a->ptr[i] ^ b->ptr[i]);
112+
}
113+
// Reduce to 0 or 1 in constant time
114+
return (result | -result) >> 31;
115+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// ----------------------------------------------------------------------------
2+
// Copyright 2016-2017 ARM Ltd.
3+
//
4+
// SPDX-License-Identifier: Apache-2.0
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
// ----------------------------------------------------------------------------
18+
19+
#include "update-client-common/arm_uc_types.h"
20+
#include "update-client-common/arm_uc_error.h"
21+
#include <string.h>
22+
23+
#include "arm_uc_config.h"
24+
#if defined(ARM_UC_FEATURE_CRYPTO_MBEDTLS) && (ARM_UC_FEATURE_CRYPTO_MBEDTLS == 1)
25+
#include "mbedtls/md_internal.h"
26+
27+
arm_uc_error_t ARM_UC_cryptoHMACSHA256(arm_uc_buffer_t *key,
28+
arm_uc_buffer_t *input,
29+
arm_uc_buffer_t *output)
30+
{
31+
arm_uc_error_t result = (arm_uc_error_t) { ARM_UC_CU_ERR_INVALID_PARAMETER };
32+
33+
const mbedtls_md_info_t *md_info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA256);
34+
if (md_info != NULL) {
35+
int8_t rv = mbedtls_md_hmac(md_info,
36+
key->ptr, key->size,
37+
input->ptr, input->size,
38+
output->ptr);
39+
if (rv == 0) {
40+
output->size = ARM_UC_SHA256_SIZE;
41+
result = (arm_uc_error_t) { ERR_NONE };
42+
}
43+
}
44+
45+
return result;
46+
}
47+
48+
#endif

0 commit comments

Comments
 (0)