Skip to content

Commit 0f0a461

Browse files
Merge pull request #4832 from OpenNuvoton/nuvoton
NUC472/M453: Fix several startup and hal bugs
2 parents 069b253 + 6b8724b commit 0f0a461

File tree

43 files changed

+232
-281
lines changed

Some content is hidden

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

43 files changed

+232
-281
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2015-2016 Nuvoton
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#ifndef MBEDTLS_DEVICE_H
17+
#define MBEDTLS_DEVICE_H
18+
19+
#define MBEDTLS_DES_ALT
20+
21+
#define MBEDTLS_SHA1_ALT
22+
#define MBEDTLS_SHA256_ALT
23+
24+
#define MBEDTLS_AES_ALT
25+
#define MBEDTLS_AES_SETKEY_ENC_ALT
26+
#define MBEDTLS_AES_SETKEY_DEC_ALT
27+
#define MBEDTLS_AES_ENCRYPT_ALT
28+
#define MBEDTLS_AES_DECRYPT_ALT
29+
30+
#endif /* MBEDTLS_DEVICE_H */

targets/TARGET_NUVOTON/TARGET_NUC472/crypto/aes/aes_alt.c renamed to features/mbedtls/targets/TARGET_NUVOTON/TARGET_NUC472/aes/aes_alt.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
* http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf
2222
*/
2323

24-
/* Compatible with mbed OS 2 which doesn't support mbedtls */
25-
#if MBED_CONF_RTOS_PRESENT
26-
2724
#if !defined(MBEDTLS_CONFIG_FILE)
2825
#include "mbedtls/config.h"
2926
#else
@@ -591,5 +588,3 @@ int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
591588

592589

593590
#endif /* MBEDTLS_AES_C */
594-
595-
#endif /* MBED_CONF_RTOS_PRESENT */

targets/TARGET_NUVOTON/TARGET_NUC472/crypto/aes/aes_alt.h renamed to features/mbedtls/targets/TARGET_NUVOTON/TARGET_NUC472/aes/aes_alt.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@
2121
* This file is part of mbed TLS (https://tls.mbed.org)
2222
*/
2323

24+
#ifndef MBEDTLS_AES_ALT_H
25+
#define MBEDTLS_AES_ALT_H
26+
27+
#if !defined(MBEDTLS_CONFIG_FILE)
28+
#include "mbedtls/config.h"
29+
#else
30+
#include MBEDTLS_CONFIG_FILE
31+
#endif
32+
33+
#if defined(MBEDTLS_AES_C)
2434
#if defined(MBEDTLS_AES_ALT)
2535
// Regular implementation
2636
//
@@ -270,5 +280,6 @@ void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
270280

271281

272282
#endif /* MBEDTLS_AES_ALT */
283+
#endif /* MBEDTLS_AES_C */
273284

274-
285+
#endif /* aes_alt.h */

targets/TARGET_NUVOTON/TARGET_NUC472/crypto/des/des_alt.c renamed to features/mbedtls/targets/TARGET_NUVOTON/TARGET_NUC472/des/des_alt.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
/* Compatible with mbed OS 2 which doesn't support mbedtls */
18-
#if MBED_CONF_RTOS_PRESENT
19-
2017
#if !defined(MBEDTLS_CONFIG_FILE)
2118
#include "mbedtls/config.h"
2219
#else
@@ -348,7 +345,7 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
348345

349346
uint32_t rmn = length;
350347
const unsigned char *in_pos = input;
351-
const unsigned char *out_pos = output;
348+
unsigned char *out_pos = output;
352349

353350
while (rmn) {
354351
uint32_t data_len = (rmn <= MAXSIZE_DMABUF) ? rmn : MAXSIZE_DMABUF;
@@ -411,5 +408,3 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
411408

412409
#endif /* MBEDTLS_DES_ALT */
413410
#endif /* MBEDTLS_DES_C */
414-
415-
#endif /* MBED_CONF_RTOS_PRESENT */

targets/TARGET_NUVOTON/TARGET_NUC472/crypto/des/des_alt.h renamed to features/mbedtls/targets/TARGET_NUVOTON/TARGET_NUC472/des/des_alt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include MBEDTLS_CONFIG_FILE
2424
#endif
2525

26+
#if defined(MBEDTLS_DES_C)
2627
#if defined(MBEDTLS_DES_ALT)
2728

2829
#include <stddef.h>
@@ -276,5 +277,6 @@ void mbedtls_des_setkey( uint32_t SK[32],
276277
#endif
277278

278279
#endif /* MBEDTLS_DES_ALT */
280+
#endif /* MBEDTLS_DES_C */
279281

280282
#endif /* des_alt.h */

targets/TARGET_NUVOTON/TARGET_NUC472/crypto/des/des_alt_sw.c renamed to features/mbedtls/targets/TARGET_NUVOTON/TARGET_NUC472/des/des_alt_sw.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
* http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf
2626
*/
2727

28-
/* Compatible with mbed OS 2 which doesn't support mbedtls */
29-
#if MBED_CONF_RTOS_PRESENT
30-
3128
#if !defined(MBEDTLS_CONFIG_FILE)
3229
#include "mbedtls/config.h"
3330
#else
@@ -798,5 +795,3 @@ int mbedtls_des3_sw_crypt_cbc( mbedtls_des3_sw_context *ctx,
798795

799796
#endif /* MBEDTLS_DES_ALT */
800797
#endif /* MBEDTLS_DES_C */
801-
802-
#endif /* MBED_CONF_RTOS_PRESENT */

targets/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha1_alt.c renamed to features/mbedtls/targets/TARGET_NUVOTON/TARGET_NUC472/sha/sha1_alt.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
/* Compatible with mbed OS 2 which doesn't support mbedtls */
18-
#if MBED_CONF_RTOS_PRESENT
19-
2017
#if !defined(MBEDTLS_CONFIG_FILE)
2118
#include "mbedtls/config.h"
2219
#else
@@ -139,5 +136,3 @@ void mbedtls_sha1_process(mbedtls_sha1_context *ctx, const unsigned char data[64
139136

140137
#endif /* MBEDTLS_SHA1_ALT */
141138
#endif /* MBEDTLS_SHA1_C */
142-
143-
#endif /* MBED_CONF_RTOS_PRESENT */

0 commit comments

Comments
 (0)