Skip to content

Commit ba6821d

Browse files
committed
Allocate MBEDTLS in external PSRAM
1 parent c85533a commit ba6821d

37 files changed

+334
-42
lines changed

tools/sdk/esp32/include/config/sdkconfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@
418418
#define CONFIG_LWIP_HOOK_IP6_ROUTE_NONE 1
419419
#define CONFIG_LWIP_HOOK_ND6_GET_GW_NONE 1
420420
#define CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE 1
421-
#define CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC 1
421+
#define CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC 1
422422
#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384
423423
#define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE 1
424424
#define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL 1

tools/sdk/esp32/include/esp-face/include/layer/dl_layer_avg_pool2d.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ namespace dl
5757
const char *name = "AvgPool2D") : Layer(name),
5858
output_exponent(output_exponent),
5959
filter_shape(filter_shape),
60-
padding_type(padding_type),
61-
padding(padding),
6260
stride_y(stride_y),
6361
stride_x(stride_x),
62+
padding_type(padding_type),
63+
padding(padding),
6464
output_shape({})
6565
{
6666
this->output = new Tensor<feature_t>;

tools/sdk/esp32/include/esp-face/include/layer/dl_layer_expand_dims.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ namespace dl
3636
* false: the output will store to a separate memory
3737
*/
3838
ExpandDims(std::vector<int> axis, const char *name = "ExpandDims", bool inplace = false) : Layer(name),
39-
axis(axis), inplace(inplace), output_shape({})
39+
output_shape({}),
40+
axis(axis),
41+
output(NULL),
42+
inplace(inplace)
4043
{
4144
}
4245

tools/sdk/esp32/include/esp-face/include/layer/dl_layer_flatten.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace dl
3232
* @param inplace true: the output will store to input0
3333
* false: the output will store to a separate memory
3434
*/
35-
Flatten(const char *name = "Flatten", bool inplace = false) : Layer(name), inplace(inplace), output_shape({})
35+
Flatten(const char *name = "Flatten", bool inplace = false) : Layer(name), output(NULL), inplace(inplace), output_shape({})
3636
{}
3737

3838
/**

tools/sdk/esp32/include/esp-face/include/layer/dl_layer_max_pool2d.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ namespace dl
5353
const int stride_x = 1,
5454
const char *name = "MaxPool2D") : Layer(name),
5555
filter_shape(filter_shape),
56-
padding_type(padding_type),
57-
padding(padding),
5856
stride_y(stride_y),
5957
stride_x(stride_x),
58+
padding_type(padding_type),
59+
padding(padding),
6060
output_shape({})
6161
{
6262
this->output = new Tensor<feature_t>;

tools/sdk/esp32/include/esp-face/include/layer/dl_layer_relu.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace dl
1818
* - int8_t: stands for operation in int8_t quantize
1919
*/
2020
template <typename feature_t>
21-
class ReLU : public Layer
21+
class Relu : public Layer
2222
{
2323
private:
2424
Tensor<feature_t> *output; /*<! output ptr of relu >*/
@@ -33,7 +33,7 @@ namespace dl
3333
* @param inplace true: the output will store to input0
3434
* false: the output will store to a separate memory
3535
*/
36-
ReLU(const char *name = "ReLU", bool inplace = false) : Layer(name),
36+
Relu(const char *name = "Relu", bool inplace = false) : Layer(name),
3737
output(NULL), inplace(inplace), output_shape({})
3838
{
3939
}
@@ -42,7 +42,7 @@ namespace dl
4242
* @brief Destroy the ReLU object
4343
*
4444
*/
45-
~ReLU()
45+
~Relu()
4646
{
4747
if ((!this->inplace) && (this->output != NULL))
4848
{

tools/sdk/esp32/include/esp-face/include/layer/dl_layer_reshape.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ namespace dl
3535
* false: the output will store to a separate memory
3636
*/
3737
Reshape(std::vector<int> shape, const char *name = "Reshape", bool inplace = false) : Layer(name),
38-
output_shape(shape), inplace(inplace)
38+
output(NULL),
39+
inplace(inplace),
40+
output_shape(shape)
3941
{
4042
}
4143

tools/sdk/esp32/include/esp-face/include/layer/dl_layer_squeeze.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ namespace dl
3535
* @param inplace true: the output will store to input0
3636
* false: the output will store to a separate memory
3737
*/
38-
Squeeze(int axis = INT32_MAX, const char *name = "Squeeze", bool inplace = false) : Layer(name), axis(axis), inplace(inplace), output_shape({})
38+
Squeeze(int axis = INT32_MAX, const char *name = "Squeeze", bool inplace = false) : Layer(name),
39+
output(NULL),
40+
inplace(inplace),
41+
axis(axis),
42+
output_shape({})
3943
{
4044
}
4145

tools/sdk/esp32/include/esp-face/include/layer/dl_layer_sub2d.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ namespace dl
3838
* false: the output will store to a separate memory
3939
*/
4040
Sub2D(const int output_exponent, const Activation<feature_t> *activation = NULL, const char *name = "Sub2D", bool inplace = false) : Layer(name),
41-
output_exponent(output_exponent), activation(activation), output(NULL), inplace(inplace), output_shape({})
41+
output_exponent(output_exponent),
42+
activation(activation),
43+
output(NULL),
44+
inplace(inplace),
45+
output_shape({})
4246
{
4347
}
4448

tools/sdk/esp32/include/esp-face/include/layer/dl_layer_transpose.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ namespace dl
3333
* @param inplace true: the output will store to input
3434
* false: the output will store to a separate memory
3535
*/
36-
Transpose(std::vector<int> perm = {}, const char *name = "Transpose", bool inplace = false) : Layer(name), perm(perm), inplace(inplace), output_shape({})
36+
Transpose(std::vector<int> perm = {}, const char *name = "Transpose", bool inplace = false) : Layer(name),
37+
output(NULL),
38+
inplace(inplace),
39+
perm(perm),
40+
output_shape({})
3741
{
3842
}
3943

tools/sdk/esp32/lib/libapp_update.a

0 Bytes
Binary file not shown.

tools/sdk/esp32/lib/libmbedcrypto.a

-16 Bytes
Binary file not shown.

tools/sdk/esp32/sdkconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,8 +1147,8 @@ CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y
11471147
#
11481148
# mbedTLS
11491149
#
1150-
CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y
1151-
# CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC is not set
1150+
# CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC is not set
1151+
CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
11521152
# CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set
11531153
# CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set
11541154
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=16384

tools/sdk/esp32c3/include/esp-face/include/layer/dl_layer_avg_pool2d.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ namespace dl
5757
const char *name = "AvgPool2D") : Layer(name),
5858
output_exponent(output_exponent),
5959
filter_shape(filter_shape),
60-
padding_type(padding_type),
61-
padding(padding),
6260
stride_y(stride_y),
6361
stride_x(stride_x),
62+
padding_type(padding_type),
63+
padding(padding),
6464
output_shape({})
6565
{
6666
this->output = new Tensor<feature_t>;

tools/sdk/esp32c3/include/esp-face/include/layer/dl_layer_expand_dims.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ namespace dl
3636
* false: the output will store to a separate memory
3737
*/
3838
ExpandDims(std::vector<int> axis, const char *name = "ExpandDims", bool inplace = false) : Layer(name),
39-
axis(axis), inplace(inplace), output_shape({})
39+
output_shape({}),
40+
axis(axis),
41+
output(NULL),
42+
inplace(inplace)
4043
{
4144
}
4245

tools/sdk/esp32c3/include/esp-face/include/layer/dl_layer_flatten.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace dl
3232
* @param inplace true: the output will store to input0
3333
* false: the output will store to a separate memory
3434
*/
35-
Flatten(const char *name = "Flatten", bool inplace = false) : Layer(name), inplace(inplace), output_shape({})
35+
Flatten(const char *name = "Flatten", bool inplace = false) : Layer(name), output(NULL), inplace(inplace), output_shape({})
3636
{}
3737

3838
/**

tools/sdk/esp32c3/include/esp-face/include/layer/dl_layer_max_pool2d.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ namespace dl
5353
const int stride_x = 1,
5454
const char *name = "MaxPool2D") : Layer(name),
5555
filter_shape(filter_shape),
56-
padding_type(padding_type),
57-
padding(padding),
5856
stride_y(stride_y),
5957
stride_x(stride_x),
58+
padding_type(padding_type),
59+
padding(padding),
6060
output_shape({})
6161
{
6262
this->output = new Tensor<feature_t>;

tools/sdk/esp32c3/include/esp-face/include/layer/dl_layer_relu.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace dl
1818
* - int8_t: stands for operation in int8_t quantize
1919
*/
2020
template <typename feature_t>
21-
class ReLU : public Layer
21+
class Relu : public Layer
2222
{
2323
private:
2424
Tensor<feature_t> *output; /*<! output ptr of relu >*/
@@ -33,7 +33,7 @@ namespace dl
3333
* @param inplace true: the output will store to input0
3434
* false: the output will store to a separate memory
3535
*/
36-
ReLU(const char *name = "ReLU", bool inplace = false) : Layer(name),
36+
Relu(const char *name = "Relu", bool inplace = false) : Layer(name),
3737
output(NULL), inplace(inplace), output_shape({})
3838
{
3939
}
@@ -42,7 +42,7 @@ namespace dl
4242
* @brief Destroy the ReLU object
4343
*
4444
*/
45-
~ReLU()
45+
~Relu()
4646
{
4747
if ((!this->inplace) && (this->output != NULL))
4848
{

tools/sdk/esp32c3/include/esp-face/include/layer/dl_layer_reshape.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ namespace dl
3535
* false: the output will store to a separate memory
3636
*/
3737
Reshape(std::vector<int> shape, const char *name = "Reshape", bool inplace = false) : Layer(name),
38-
output_shape(shape), inplace(inplace)
38+
output(NULL),
39+
inplace(inplace),
40+
output_shape(shape)
3941
{
4042
}
4143

tools/sdk/esp32c3/include/esp-face/include/layer/dl_layer_squeeze.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ namespace dl
3535
* @param inplace true: the output will store to input0
3636
* false: the output will store to a separate memory
3737
*/
38-
Squeeze(int axis = INT32_MAX, const char *name = "Squeeze", bool inplace = false) : Layer(name), axis(axis), inplace(inplace), output_shape({})
38+
Squeeze(int axis = INT32_MAX, const char *name = "Squeeze", bool inplace = false) : Layer(name),
39+
output(NULL),
40+
inplace(inplace),
41+
axis(axis),
42+
output_shape({})
3943
{
4044
}
4145

tools/sdk/esp32c3/include/esp-face/include/layer/dl_layer_sub2d.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ namespace dl
3838
* false: the output will store to a separate memory
3939
*/
4040
Sub2D(const int output_exponent, const Activation<feature_t> *activation = NULL, const char *name = "Sub2D", bool inplace = false) : Layer(name),
41-
output_exponent(output_exponent), activation(activation), output(NULL), inplace(inplace), output_shape({})
41+
output_exponent(output_exponent),
42+
activation(activation),
43+
output(NULL),
44+
inplace(inplace),
45+
output_shape({})
4246
{
4347
}
4448

tools/sdk/esp32c3/include/esp-face/include/layer/dl_layer_transpose.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ namespace dl
3333
* @param inplace true: the output will store to input
3434
* false: the output will store to a separate memory
3535
*/
36-
Transpose(std::vector<int> perm = {}, const char *name = "Transpose", bool inplace = false) : Layer(name), perm(perm), inplace(inplace), output_shape({})
36+
Transpose(std::vector<int> perm = {}, const char *name = "Transpose", bool inplace = false) : Layer(name),
37+
output(NULL),
38+
inplace(inplace),
39+
perm(perm),
40+
output_shape({})
3741
{
3842
}
3943

tools/sdk/esp32c3/lib/libapp_update.a

0 Bytes
Binary file not shown.

tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/dcd_attr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
#elif TU_CHECK_MCU(OPT_MCU_LPC18XX, OPT_MCU_LPC43XX)
4646
// TODO USB0 has 6, USB1 has 4
47+
#define DCD_ATTR_CONTROLLER_CHIPIDEA_HS
4748
#define DCD_ATTR_ENDPOINT_MAX 6
4849

4950
#elif TU_CHECK_MCU(OPT_MCU_LPC51UXX)
@@ -58,6 +59,7 @@
5859
#define DCD_ATTR_ENDPOINT_MAX 6
5960

6061
#elif TU_CHECK_MCU(OPT_MCU_MIMXRT10XX)
62+
#define DCD_ATTR_CONTROLLER_CHIPIDEA_HS
6163
#define DCD_ATTR_ENDPOINT_MAX 8
6264

6365
#elif TU_CHECK_MCU(OPT_MCU_MKL25ZXX, OPT_MCU_K32L2BXX)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2021, Ha Thach (tinyusb.org)
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*
24+
* This file is part of the TinyUSB stack.
25+
*/
26+
27+
#ifndef _CI_HS_IMXRT_H_
28+
#define _CI_HS_IMXRT_H_
29+
30+
#include "fsl_device_registers.h"
31+
32+
static const ci_hs_controller_t _ci_controller[] =
33+
{
34+
// RT1010 and RT1020 only has 1 USB controller
35+
#if FSL_FEATURE_SOC_USBHS_COUNT == 1
36+
{ .reg_base = USB_BASE , .irqnum = USB_OTG1_IRQn, .ep_count = 8 }
37+
#else
38+
{ .reg_base = USB1_BASE, .irqnum = USB_OTG1_IRQn, .ep_count = 8 },
39+
{ .reg_base = USB2_BASE, .irqnum = USB_OTG2_IRQn, .ep_count = 8 }
40+
#endif
41+
};
42+
43+
#define CI_DCD_INT_ENABLE(_p) NVIC_EnableIRQ (_ci_controller[_p].irqnum)
44+
#define CI_DCD_INT_DISABLE(_p) NVIC_DisableIRQ(_ci_controller[_p].irqnum)
45+
46+
#define CI_HCD_INT_ENABLE(_p) NVIC_EnableIRQ (_ci_controller[_p].irqnum)
47+
#define CI_HCD_INT_DISABLE(_p) NVIC_DisableIRQ(_ci_controller[_p].irqnum)
48+
49+
50+
#endif

0 commit comments

Comments
 (0)