Skip to content

Commit f10541b

Browse files
author
Wayne Ren
committed
example: openthread: fix the compile error caused by the update of mbedtls
fix the compile error caused by the update of mbedtls. Just compile ok, no verificaiton on hardware Signed-off-by: Wayne Ren <[email protected]>
1 parent 06e3850 commit f10541b

File tree

7 files changed

+707
-4
lines changed

7 files changed

+707
-4
lines changed

example/baremetal/openthread/cli/mbedtls-config.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <openthread/config.h>
3434
#include <openthread/platform/logging.h>
3535
#include <openthread/platform/memory.h>
36+
#include <stdio.h>
3637

3738
#if defined(_WIN32)
3839
#include <stdarg.h>
@@ -189,7 +190,7 @@ __inline int windows_kernel_snprintf(char * s, size_t n, const char * format, ..
189190
//#define MBEDTLS_PLATFORM_TIME_ALT
190191
//#define MBEDTLS_PLATFORM_FPRINTF_ALT
191192
//#define MBEDTLS_PLATFORM_PRINTF_ALT
192-
//#define MBEDTLS_PLATFORM_SNPRINTF_ALT
193+
#define MBEDTLS_PLATFORM_SNPRINTF_ALT
193194
//#define MBEDTLS_PLATFORM_NV_SEED_ALT
194195

195196
/**
@@ -2557,7 +2558,7 @@ __inline int windows_kernel_snprintf(char * s, size_t n, const char * format, ..
25572558
//#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */
25582559
//#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */
25592560
/* Note: your snprintf must correclty zero-terminate the buffer! */
2560-
//#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use, can be undefined */
2561+
#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use, can be undefined */
25612562
//#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS 0 /**< Default exit value to use, can be undefined */
25622563
//#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE 1 /**< Default exit value to use, can be undefined */
25632564
//#define MBEDTLS_PLATFORM_STD_NV_SEED_READ mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to use, can be undefined */

example/baremetal/openthread/ncp/mbedtls-config.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <openthread/config.h>
3434
#include <openthread/platform/logging.h>
3535
#include <openthread/platform/memory.h>
36+
#include <stdio.h>
3637

3738
#if defined(_WIN32)
3839
#include <stdarg.h>
@@ -189,7 +190,7 @@ __inline int windows_kernel_snprintf(char * s, size_t n, const char * format, ..
189190
//#define MBEDTLS_PLATFORM_TIME_ALT
190191
//#define MBEDTLS_PLATFORM_FPRINTF_ALT
191192
//#define MBEDTLS_PLATFORM_PRINTF_ALT
192-
//#define MBEDTLS_PLATFORM_SNPRINTF_ALT
193+
#define MBEDTLS_PLATFORM_SNPRINTF_ALT
193194
//#define MBEDTLS_PLATFORM_NV_SEED_ALT
194195

195196
/**
@@ -2557,7 +2558,7 @@ __inline int windows_kernel_snprintf(char * s, size_t n, const char * format, ..
25572558
//#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */
25582559
//#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */
25592560
/* Note: your snprintf must correclty zero-terminate the buffer! */
2560-
//#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use, can be undefined */
2561+
#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use, can be undefined */
25612562
//#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS 0 /**< Default exit value to use, can be undefined */
25622563
//#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE 1 /**< Default exit value to use, can be undefined */
25632564
//#define MBEDTLS_PLATFORM_STD_NV_SEED_READ mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to use, can be undefined */

example/fatfs_test/main.c

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/* ------------------------------------------
2+
* Copyright (c) 2017, Synopsys, Inc. All rights reserved.
3+
4+
* Redistribution and use in source and binary forms, with or without modification,
5+
* are permitted provided that the following conditions are met:
6+
7+
* 1) Redistributions of source code must retain the above copyright notice, this
8+
* list of conditions and the following disclaimer.
9+
10+
* 2) Redistributions in binary form must reproduce the above copyright notice,
11+
* this list of conditions and the following disclaimer in the documentation and/or
12+
* other materials provided with the distribution.
13+
14+
* 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may
15+
* be used to endorse or promote products derived from this software without
16+
* specific prior done permission.
17+
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*
29+
--------------------------------------------- */
30+
#include "embARC.h"
31+
#include "embARC_debug.h"
32+
33+
#define DATA_SIZE 8192
34+
static FIL file;
35+
36+
uint8_t data_write[DATA_SIZE];
37+
uint8_t data_read[DATA_SIZE];
38+
39+
40+
/**
41+
* \brief Test hardware board without any peripheral
42+
*/
43+
int main(void)
44+
{
45+
uint8_t res;
46+
uint32_t i;
47+
uint32_t rw_counter;
48+
uint32_t done;
49+
uint8_t *buf;
50+
51+
EMBARC_PRINTF("test start\r\n");
52+
53+
for (i = 0; i < DATA_SIZE; i++) {
54+
data_write[i] = 'a' + i % 26;
55+
}
56+
57+
res = f_open(&file, "test1.txt", FA_WRITE | FA_CREATE_ALWAYS);
58+
59+
if (res) {
60+
EMBARC_PRINTF("file open err\r\n");
61+
while (1);
62+
}
63+
64+
rw_counter = DATA_SIZE;
65+
buf = data_write;
66+
67+
while (rw_counter) {
68+
res = f_write(&file, buf, rw_counter, &done);
69+
70+
if (res) {
71+
EMBARC_PRINTF("file write error :%d\r\n", res);
72+
while (1);
73+
}
74+
rw_counter -= done;
75+
buf += done;
76+
EMBARC_PRINTF("%d bytes are written\r\n", done);
77+
}
78+
f_close(&file);
79+
80+
res = f_open(&file, "test1.txt", FA_READ | FA_OPEN_EXISTING);
81+
82+
if (res) {
83+
EMBARC_PRINTF("file open err\r\n");
84+
while (1);
85+
}
86+
87+
rw_counter = DATA_SIZE;
88+
buf = data_read;
89+
90+
while (rw_counter) {
91+
res = f_read(&file, buf, rw_counter, &done);
92+
93+
if (res) {
94+
EMBARC_PRINTF("file read error :%d\r\n", res);
95+
while (1);
96+
}
97+
rw_counter -= done;
98+
buf += done;
99+
EMBARC_PRINTF("%d bytes are read\r\n", done);
100+
}
101+
102+
while (1);
103+
}

example/fatfs_test/makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Application name
2+
APPL ?= fatfs_test
3+
4+
BOARD = iotdk
5+
#
6+
# root dir of embARC
7+
#
8+
EMBARC_ROOT = ../..
9+
10+
MID_SEL = common fatfs
11+
12+
# application source dirs
13+
APPL_CSRC_DIR = .
14+
APPL_ASMSRC_DIR = .
15+
16+
# application include dirs
17+
APPL_INC_DIR = .
18+
19+
# include current project makefile
20+
COMMON_COMPILE_PREREQUISITES += makefile
21+
22+
### Options above must be added before include options.mk ###
23+
# include key embARC build system makefile
24+
include $(EMBARC_ROOT)/options/options.mk
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
FreeRTOS V8.0.0 - Copyright (C) 2014 Real Time Engineers Ltd.
3+
All rights reserved
4+
5+
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
6+
7+
***************************************************************************
8+
* *
9+
* FreeRTOS provides completely free yet professionally developed, *
10+
* robust, strictly quality controlled, supported, and cross *
11+
* platform software that has become a de facto standard. *
12+
* *
13+
* Help yourself get started quickly and support the FreeRTOS *
14+
* project by purchasing a FreeRTOS tutorial book, reference *
15+
* manual, or both from: http://www.FreeRTOS.org/Documentation *
16+
* *
17+
* Thank you! *
18+
* *
19+
***************************************************************************
20+
21+
This file is part of the FreeRTOS distribution.
22+
23+
FreeRTOS is free software; you can redistribute it and/or modify it under
24+
the terms of the GNU General Public License (version 2) as published by the
25+
Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
26+
27+
>>! NOTE: The modification to the GPL is included to allow you to distribute
28+
>>! a combined work that includes FreeRTOS without being obliged to provide
29+
>>! the source code for proprietary components outside of the FreeRTOS
30+
>>! kernel.
31+
32+
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
33+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
34+
FOR A PARTICULAR PURPOSE. Full license text is available from the following
35+
link: http://www.freertos.org/a00114.html
36+
37+
1 tab == 4 spaces!
38+
39+
***************************************************************************
40+
* *
41+
* Having a problem? Start by reading the FAQ "My application does *
42+
* not run, what could be wrong?" *
43+
* *
44+
* http://www.FreeRTOS.org/FAQHelp.html *
45+
* *
46+
***************************************************************************
47+
48+
http://www.FreeRTOS.org - Documentation, books, training, latest versions,
49+
license and Real Time Engineers Ltd. contact details.
50+
51+
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
52+
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
53+
compatible FAT file system, and our tiny thread aware UDP/IP stack.
54+
55+
http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
56+
Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
57+
licenses offer ticketed support, indemnification and middleware.
58+
59+
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
60+
engineered and independently SIL3 certified version for use in safety and
61+
mission critical applications that require provable dependability.
62+
63+
1 tab == 4 spaces!
64+
*/
65+
66+
#ifndef FREERTOS_CONFIG_H
67+
#define FREERTOS_CONFIG_H
68+
69+
#include <stdio.h>
70+
/*-----------------------------------------------------------
71+
* Application specific definitions.
72+
*
73+
* These definitions should be adjusted for your particular hardware and
74+
* application requirements.
75+
*
76+
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
77+
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
78+
*
79+
* See http://www.freertos.org/a00110.html.
80+
*----------------------------------------------------------*/
81+
82+
#define configUSE_PREEMPTION 1
83+
#define configUSE_IDLE_HOOK 0
84+
#define configUSE_TICK_HOOK 0
85+
#define configCPU_CLOCK_HZ ( ( unsigned long ) BOARD_CPU_CLOCK )
86+
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
87+
#define configMAX_PRIORITIES ( 4 )
88+
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 104 )
89+
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 18 * 1024 ) )
90+
#define configMAX_TASK_NAME_LEN ( 10 )
91+
#define configUSE_TRACE_FACILITY 0
92+
#define configUSE_16_BIT_TICKS 0
93+
#define configIDLE_SHOULD_YIELD 1
94+
#define configUSE_MUTEXES 1
95+
96+
/* Co-routine definitions. */
97+
#define configUSE_CO_ROUTINES 0
98+
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
99+
100+
101+
/* Set the following definitions to 1 to include the API function, or zero
102+
to exclude the API function. */
103+
104+
#define INCLUDE_vTaskPrioritySet 1
105+
#define INCLUDE_uxTaskPriorityGet 1
106+
#define INCLUDE_vTaskDelete 1
107+
#define INCLUDE_vTaskCleanUpResources 0
108+
#define INCLUDE_vTaskSuspend 1
109+
#define INCLUDE_vTaskDelayUntil 1
110+
#define INCLUDE_vTaskDelay 1
111+
#define INCLUDE_xTaskGetCurrentTaskHandle 1
112+
113+
#endif /* FREERTOS_CONFIG_H */

0 commit comments

Comments
 (0)