xiaoxiang781216 commented on a change in pull request #566:
URL: 
https://github.com/apache/incubator-nuttx-apps/pull/566#discussion_r563443006



##########
File path: crypto/mbedtls/Make.defs
##########
@@ -0,0 +1,33 @@
+############################################################################
+# apps/crypto/mbedtls/Make.defs
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+ifeq ($(CONFIG_CRYPTO_MBEDTLS),y)
+CONFIGURED_APPS += $(APPDIR)/crypto/mbedtls
+
+# Allows `<mbedtls/<>.h>` import.
+
+CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" 
$(APPDIR)/crypto/mbedtls/mbedtls/include}
+CXXFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" 
$(APPDIR)/crypto/mbedtls/mbedtls/include}
+
+CFLAGS += -DMBEDTLS_CONFIG_FILE="<crypto/mbedtls_config.h>"

Review comment:
       should we use $(DEIFNE) like $(INCDIR)?

##########
File path: crypto/mbedtls/Kconfig
##########
@@ -0,0 +1,25 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+menuconfig CRYPTO_MBEDTLS
+       bool "Mbed TLS Cryptography Library"
+       default n
+       ---help---
+               Enable support for Mbed TLS.
+
+if CRYPTO_MBEDTLS
+
+config MBEDTLS_VERSION
+       string "MBEDTLS Version"
+       default "2.25.0"
+
+config MBEDTLS_DEFAULT_TASK_STACKSIZE
+       int "Mbed TLS app default stack size"
+       default 8192
+
+source "$APPSDIR/crypto/mbedtls/apps/benchmark/Kconfig"
+source "$APPSDIR/crypto/mbedtls/apps/selftest/Kconfig"

Review comment:
       can we remove $APPSDIR/? since other location uses the relative path.

##########
File path: crypto/mbedtls/Makefile
##########
@@ -0,0 +1,61 @@
+############################################################################
+# apps/crypto/mbedtls/Makefile
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+include $(APPDIR)/Make.defs
+
+# Mbed TLS crypto library
+
+# Set up build configuration and environment
+
+WD := ${shell echo $(CURDIR) | sed -e 's/ /\\ /g'}

Review comment:
       remove WD, nobody use it now.

##########
File path: crypto/mbedtls/Kconfig
##########
@@ -0,0 +1,25 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+menuconfig CRYPTO_MBEDTLS
+       bool "Mbed TLS Cryptography Library"
+       default n
+       ---help---
+               Enable support for Mbed TLS.
+
+if CRYPTO_MBEDTLS
+
+config MBEDTLS_VERSION
+       string "MBEDTLS Version"
+       default "2.25.0"
+
+config MBEDTLS_DEFAULT_TASK_STACKSIZE
+       int "Mbed TLS app default stack size"
+       default 8192

Review comment:
       can we use the small stack size or DEFAULT_TASK_STACKSIZE?

##########
File path: crypto/mbedtls/apps/selftest/Makefile
##########
@@ -0,0 +1,33 @@
+############################################################################
+# apps/crypto/mbedtls/apps/selftest/Makefile
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+include $(APPDIR)/Make.defs
+include ../Makefile
+
+# mbedtls built-in benchmark application info
+
+PROGNAME  = "mbedselftest"
+PRIORITY  = $(CONFIG_MBEDTLS_APP_SELFTEST_PRIORITY)
+STACKSIZE = $(CONFIG_MBEDTLS_APP_SELFTEST_STACKSIZE)
+MODULE    = $(CONFIG_MBEDTLS_APP_SELFTEST)
+
+MAINSRC = $(MBEDPROGDIR)/test/selftest.c

Review comment:
       why not use the relative path? So we can remove MBEDPROGDIR and  
crypto/mbedtls/apps/Makefile.

##########
File path: crypto/mbedtls/Kconfig
##########
@@ -0,0 +1,25 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+menuconfig CRYPTO_MBEDTLS
+       bool "Mbed TLS Cryptography Library"
+       default n
+       ---help---
+               Enable support for Mbed TLS.
+
+if CRYPTO_MBEDTLS
+
+config MBEDTLS_VERSION
+       string "MBEDTLS Version"
+       default "2.25.0"
+
+config MBEDTLS_DEFAULT_TASK_STACKSIZE
+       int "Mbed TLS app default stack size"
+       default 8192
+
+source "$APPSDIR/crypto/mbedtls/apps/benchmark/Kconfig"
+source "$APPSDIR/crypto/mbedtls/apps/selftest/Kconfig"

Review comment:
       Ok, let's keep APPDIR

##########
File path: crypto/mbedtls/apps/selftest/Makefile
##########
@@ -0,0 +1,33 @@
+############################################################################
+# apps/crypto/mbedtls/apps/selftest/Makefile
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+include $(APPDIR)/Make.defs
+include ../Makefile
+
+# mbedtls built-in benchmark application info
+
+PROGNAME  = "mbedselftest"
+PRIORITY  = $(CONFIG_MBEDTLS_APP_SELFTEST_PRIORITY)
+STACKSIZE = $(CONFIG_MBEDTLS_APP_SELFTEST_STACKSIZE)
+MODULE    = $(CONFIG_MBEDTLS_APP_SELFTEST)
+
+MAINSRC = $(MBEDPROGDIR)/test/selftest.c

Review comment:
       I know your problem, both selftest.c and benchmark.c put in 
crypto/mbedtls/programs/test, but you put Makefile under:
   crypto/mbedtls/apps/selftest/Makefile
   crypto/mbedtls/apps/benchmark/Makefile
   Why not put Makfile to:
   crypto/mbedtls/programs
   and merge two apps into one Mafile?

##########
File path: crypto/mbedtls/apps/selftest/Makefile
##########
@@ -0,0 +1,33 @@
+############################################################################
+# apps/crypto/mbedtls/apps/selftest/Makefile
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+include $(APPDIR)/Make.defs
+include ../Makefile
+
+# mbedtls built-in benchmark application info
+
+PROGNAME  = "mbedselftest"
+PRIORITY  = $(CONFIG_MBEDTLS_APP_SELFTEST_PRIORITY)
+STACKSIZE = $(CONFIG_MBEDTLS_APP_SELFTEST_STACKSIZE)
+MODULE    = $(CONFIG_MBEDTLS_APP_SELFTEST)
+
+MAINSRC = $(MBEDPROGDIR)/test/selftest.c

Review comment:
       but you can specify multiple apps in PROGNAME and MAINSRC like zmodem:
   
https://github.com/apache/incubator-nuttx-apps/blob/master/system/zmodem/Makefile#L38
   
https://github.com/apache/incubator-nuttx-apps/blob/master/system/zmodem/Makefile#L45

##########
File path: crypto/mbedtls/apps/selftest/Makefile
##########
@@ -0,0 +1,33 @@
+############################################################################
+# apps/crypto/mbedtls/apps/selftest/Makefile
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+include $(APPDIR)/Make.defs
+include ../Makefile
+
+# mbedtls built-in benchmark application info
+
+PROGNAME  = "mbedselftest"
+PRIORITY  = $(CONFIG_MBEDTLS_APP_SELFTEST_PRIORITY)
+STACKSIZE = $(CONFIG_MBEDTLS_APP_SELFTEST_STACKSIZE)
+MODULE    = $(CONFIG_MBEDTLS_APP_SELFTEST)
+
+MAINSRC = $(MBEDPROGDIR)/test/selftest.c

Review comment:
       > You cannot call `include $(APPDIR)/Application.mk` twice in the same 
make file which is they need to be in there own folders. But I don't think that 
is related to this path issue.
   
   but you can specify multiple apps in PROGNAME and MAINSRC like zmodem:
   
https://github.com/apache/incubator-nuttx-apps/blob/master/system/zmodem/Makefile#L38
   
https://github.com/apache/incubator-nuttx-apps/blob/master/system/zmodem/Makefile#L45
   
   > also careful with your paths.
   > `crypto/mbedtls/programs/test` does not exist. 
`crypto/mbedtls/mbedtls/programs/test` does, but that is inside the downloaded 
source.
   
   Yes, we can't put into the download folder, crypto/mbedtls/Makefile may a 
better location for apps too.

##########
File path: crypto/mbedtls/apps/selftest/Makefile
##########
@@ -0,0 +1,33 @@
+############################################################################
+# apps/crypto/mbedtls/apps/selftest/Makefile
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+include $(APPDIR)/Make.defs
+include ../Makefile
+
+# mbedtls built-in benchmark application info
+
+PROGNAME  = "mbedselftest"
+PRIORITY  = $(CONFIG_MBEDTLS_APP_SELFTEST_PRIORITY)
+STACKSIZE = $(CONFIG_MBEDTLS_APP_SELFTEST_STACKSIZE)
+MODULE    = $(CONFIG_MBEDTLS_APP_SELFTEST)
+
+MAINSRC = $(MBEDPROGDIR)/test/selftest.c

Review comment:
       > You cannot call `include $(APPDIR)/Application.mk` twice in the same 
make file which is they need to be in there own folders. But I don't think that 
is related to this path issue.
   
   but you can specify multiple apps in PROGNAME and MAINSRC like zmodem:
   
https://github.com/apache/incubator-nuttx-apps/blob/master/system/zmodem/Makefile#L38
   
https://github.com/apache/incubator-nuttx-apps/blob/master/system/zmodem/Makefile#L45
   
   > also careful with your paths.
   > `crypto/mbedtls/programs/test` does not exist. 
`crypto/mbedtls/mbedtls/programs/test` does, but that is inside the downloaded 
source.
   
   Yes, we can't put into the download folder, crypto/mbedtls/Makefile may a 
better location for apps too with the multiple apps trick.

##########
File path: crypto/mbedtls/Makefile
##########
@@ -0,0 +1,91 @@
+############################################################################
+# apps/crypto/mbedtls/Makefile
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+include $(APPDIR)/Make.defs
+
+# Mbed TLS crypto library
+
+# Set up build configuration and environment
+
+MBEDTLS_URL ?= "https://github.com/ARMmbed/mbedtls/archive";
+
+MBEDTLS_VERSION = $(patsubst "%",%,$(strip $(CONFIG_MBEDTLS_VERSION)))
+MBEDTLS_ZIP = v$(MBEDTLS_VERSION).zip
+
+MBEDTLS_UNPACKNAME = mbedtls
+UNPACK ?= unzip -q -o
+
+MBEDTLS_UNPACKLIBDIR = $(MBEDTLS_UNPACKNAME)$(DELIM)library
+MBEDTLS_UNPACKPROGDIR = $(MBEDTLS_UNPACKNAME)$(DELIM)programs
+
+# This lets Mbed TLS better use some of the POSIX features we have
+CFLAGS += ${shell $(DEFINE) "$(CC)" __unix__}
+
+CSRCS = $(wildcard $(MBEDTLS_UNPACKLIBDIR)$(DELIM)*.c)
+
+
+$(MBEDTLS_ZIP):
+       @echo "Downloading: $(MBEDTLS_URL)/$(MBEDTLS_ZIP)"
+       $(Q) curl -O -L $(MBEDTLS_URL)/$(MBEDTLS_ZIP)
+
+$(MBEDTLS_UNPACKNAME): $(MBEDTLS_ZIP)
+       @echo "Unpacking: $(MBEDTLS_ZIP) -> $(MBEDTLS_UNPACKNAME)"
+       $(Q) $(UNPACK) $(MBEDTLS_ZIP)
+       $(Q) mv mbedtls-$(MBEDTLS_VERSION) $(MBEDTLS_UNPACKNAME)
+       $(Q) touch $(MBEDTLS_UNPACKNAME)
+
+context:: $(MBEDTLS_UNPACKNAME)
+
+distclean::
+       $(call DELDIR, $(MBEDTLS_UNPACKNAME))
+       $(call DELFILE, $(MBEDTLS_ZIP))
+
+# Configuration Applications
+
+ifneq ($(CONFIG_MBEDTLS_APPS),)
+CONFIGURED_APPS += $(APPDIR)/crypto/mbedtls/
+
+PROGNAME =
+PRIORITY =
+STACKSIZE =
+MAINSRC =

Review comment:
       don't empty variable since it's default value. 

##########
File path: crypto/mbedtls/Makefile
##########
@@ -0,0 +1,91 @@
+############################################################################
+# apps/crypto/mbedtls/Makefile
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+include $(APPDIR)/Make.defs
+
+# Mbed TLS crypto library
+
+# Set up build configuration and environment
+
+MBEDTLS_URL ?= "https://github.com/ARMmbed/mbedtls/archive";
+
+MBEDTLS_VERSION = $(patsubst "%",%,$(strip $(CONFIG_MBEDTLS_VERSION)))
+MBEDTLS_ZIP = v$(MBEDTLS_VERSION).zip
+
+MBEDTLS_UNPACKNAME = mbedtls
+UNPACK ?= unzip -q -o
+
+MBEDTLS_UNPACKLIBDIR = $(MBEDTLS_UNPACKNAME)$(DELIM)library
+MBEDTLS_UNPACKPROGDIR = $(MBEDTLS_UNPACKNAME)$(DELIM)programs
+
+# This lets Mbed TLS better use some of the POSIX features we have
+CFLAGS += ${shell $(DEFINE) "$(CC)" __unix__}
+
+CSRCS = $(wildcard $(MBEDTLS_UNPACKLIBDIR)$(DELIM)*.c)
+
+
+$(MBEDTLS_ZIP):
+       @echo "Downloading: $(MBEDTLS_URL)/$(MBEDTLS_ZIP)"
+       $(Q) curl -O -L $(MBEDTLS_URL)/$(MBEDTLS_ZIP)
+
+$(MBEDTLS_UNPACKNAME): $(MBEDTLS_ZIP)
+       @echo "Unpacking: $(MBEDTLS_ZIP) -> $(MBEDTLS_UNPACKNAME)"
+       $(Q) $(UNPACK) $(MBEDTLS_ZIP)
+       $(Q) mv mbedtls-$(MBEDTLS_VERSION) $(MBEDTLS_UNPACKNAME)
+       $(Q) touch $(MBEDTLS_UNPACKNAME)
+
+context:: $(MBEDTLS_UNPACKNAME)
+
+distclean::
+       $(call DELDIR, $(MBEDTLS_UNPACKNAME))
+       $(call DELFILE, $(MBEDTLS_ZIP))
+
+# Configuration Applications
+
+ifneq ($(CONFIG_MBEDTLS_APPS),)
+CONFIGURED_APPS += $(APPDIR)/crypto/mbedtls/

Review comment:
       CONFIGURED_APPS need define in Make.def, Makefile can't reference it if 
we define it here.

##########
File path: crypto/mbedtls/Kconfig
##########
@@ -0,0 +1,80 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+menuconfig CRYPTO_MBEDTLS
+       bool "Mbed TLS Cryptography Library"
+       default n
+       ---help---
+               Enable support for Mbed TLS.
+
+if CRYPTO_MBEDTLS
+
+config MBEDTLS_VERSION
+       string "MBEDTLS Version"
+       default "2.25.0"
+
+menuconfig MBEDTLS_APPS

Review comment:
       normally, we reuse CRYPTO_MBEDTLS for module by changing it to tristate 
and update the if condition in Make.defs:
   ```
   ifneq ($(CONFIG_CRYPTO_MBEDTLS),)
   CONFIGURED_APPS += $(APPDIR)/crypto/mbedtls
   endif
   ```

##########
File path: crypto/mbedtls/Makefile
##########
@@ -0,0 +1,91 @@
+############################################################################
+# apps/crypto/mbedtls/Makefile
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+include $(APPDIR)/Make.defs
+
+# Mbed TLS crypto library
+
+# Set up build configuration and environment
+
+MBEDTLS_URL ?= "https://github.com/ARMmbed/mbedtls/archive";
+
+MBEDTLS_VERSION = $(patsubst "%",%,$(strip $(CONFIG_MBEDTLS_VERSION)))
+MBEDTLS_ZIP = v$(MBEDTLS_VERSION).zip
+
+MBEDTLS_UNPACKNAME = mbedtls
+UNPACK ?= unzip -q -o
+
+MBEDTLS_UNPACKLIBDIR = $(MBEDTLS_UNPACKNAME)$(DELIM)library
+MBEDTLS_UNPACKPROGDIR = $(MBEDTLS_UNPACKNAME)$(DELIM)programs
+
+# This lets Mbed TLS better use some of the POSIX features we have
+CFLAGS += ${shell $(DEFINE) "$(CC)" __unix__}
+
+CSRCS = $(wildcard $(MBEDTLS_UNPACKLIBDIR)$(DELIM)*.c)
+
+
+$(MBEDTLS_ZIP):
+       @echo "Downloading: $(MBEDTLS_URL)/$(MBEDTLS_ZIP)"
+       $(Q) curl -O -L $(MBEDTLS_URL)/$(MBEDTLS_ZIP)
+
+$(MBEDTLS_UNPACKNAME): $(MBEDTLS_ZIP)
+       @echo "Unpacking: $(MBEDTLS_ZIP) -> $(MBEDTLS_UNPACKNAME)"
+       $(Q) $(UNPACK) $(MBEDTLS_ZIP)
+       $(Q) mv mbedtls-$(MBEDTLS_VERSION) $(MBEDTLS_UNPACKNAME)
+       $(Q) touch $(MBEDTLS_UNPACKNAME)
+
+context:: $(MBEDTLS_UNPACKNAME)
+
+distclean::
+       $(call DELDIR, $(MBEDTLS_UNPACKNAME))
+       $(call DELFILE, $(MBEDTLS_ZIP))
+
+# Configuration Applications
+
+ifneq ($(CONFIG_MBEDTLS_APPS),)
+CONFIGURED_APPS += $(APPDIR)/crypto/mbedtls/

Review comment:
       CONFIGURED_APPS need define in Make.def, apps/Makefile can't reference 
it if we define it here.

##########
File path: crypto/mbedtls/apps/selftest/Makefile
##########
@@ -0,0 +1,33 @@
+############################################################################
+# apps/crypto/mbedtls/apps/selftest/Makefile
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+include $(APPDIR)/Make.defs
+include ../Makefile
+
+# mbedtls built-in benchmark application info
+
+PROGNAME  = "mbedselftest"
+PRIORITY  = $(CONFIG_MBEDTLS_APP_SELFTEST_PRIORITY)
+STACKSIZE = $(CONFIG_MBEDTLS_APP_SELFTEST_STACKSIZE)
+MODULE    = $(CONFIG_MBEDTLS_APP_SELFTEST)
+
+MAINSRC = $(MBEDPROGDIR)/test/selftest.c

Review comment:
       Yes, another normal approach is reuse CRYPTO_MBEDTLS option.

##########
File path: crypto/mbedtls/Makefile
##########
@@ -0,0 +1,91 @@
+############################################################################
+# apps/crypto/mbedtls/Makefile
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+include $(APPDIR)/Make.defs
+
+# Mbed TLS crypto library
+
+# Set up build configuration and environment
+
+MBEDTLS_URL ?= "https://github.com/ARMmbed/mbedtls/archive";
+
+MBEDTLS_VERSION = $(patsubst "%",%,$(strip $(CONFIG_MBEDTLS_VERSION)))
+MBEDTLS_ZIP = v$(MBEDTLS_VERSION).zip
+
+MBEDTLS_UNPACKNAME = mbedtls
+UNPACK ?= unzip -q -o
+
+MBEDTLS_UNPACKLIBDIR = $(MBEDTLS_UNPACKNAME)$(DELIM)library
+MBEDTLS_UNPACKPROGDIR = $(MBEDTLS_UNPACKNAME)$(DELIM)programs
+
+# This lets Mbed TLS better use some of the POSIX features we have
+CFLAGS += ${shell $(DEFINE) "$(CC)" __unix__}
+
+CSRCS = $(wildcard $(MBEDTLS_UNPACKLIBDIR)$(DELIM)*.c)
+
+
+$(MBEDTLS_ZIP):
+       @echo "Downloading: $(MBEDTLS_URL)/$(MBEDTLS_ZIP)"
+       $(Q) curl -O -L $(MBEDTLS_URL)/$(MBEDTLS_ZIP)
+
+$(MBEDTLS_UNPACKNAME): $(MBEDTLS_ZIP)
+       @echo "Unpacking: $(MBEDTLS_ZIP) -> $(MBEDTLS_UNPACKNAME)"
+       $(Q) $(UNPACK) $(MBEDTLS_ZIP)
+       $(Q) mv mbedtls-$(MBEDTLS_VERSION) $(MBEDTLS_UNPACKNAME)
+       $(Q) touch $(MBEDTLS_UNPACKNAME)
+
+context:: $(MBEDTLS_UNPACKNAME)
+
+distclean::
+       $(call DELDIR, $(MBEDTLS_UNPACKNAME))
+       $(call DELFILE, $(MBEDTLS_ZIP))
+
+# Configuration Applications
+
+ifneq ($(CONFIG_MBEDTLS_APPS),)
+CONFIGURED_APPS += $(APPDIR)/crypto/mbedtls/

Review comment:
       We don't need define CONFIGURED_APPS in Makefile, it's enough to define 
CONFIGURED_APPS in Make.defs

##########
File path: crypto/mbedtls/Kconfig
##########
@@ -0,0 +1,25 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+menuconfig CRYPTO_MBEDTLS
+       bool "Mbed TLS Cryptography Library"
+       default n
+       ---help---
+               Enable support for Mbed TLS.
+
+if CRYPTO_MBEDTLS
+
+config MBEDTLS_VERSION
+       string "MBEDTLS Version"
+       default "2.25.0"
+
+config MBEDTLS_DEFAULT_TASK_STACKSIZE
+       int "Mbed TLS app default stack size"
+       default 8192

Review comment:
       Yes, sim may need more stack size, DEFAULT_TASK_STACKSIZE has special 
value(64KB?) for sim.

##########
File path: crypto/mbedtls/Kconfig
##########
@@ -0,0 +1,80 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+menuconfig CRYPTO_MBEDTLS
+       bool "Mbed TLS Cryptography Library"
+       default n
+       ---help---
+               Enable support for Mbed TLS.
+
+if CRYPTO_MBEDTLS
+
+config MBEDTLS_VERSION
+       string "MBEDTLS Version"
+       default "2.25.0"
+
+menuconfig MBEDTLS_APPS

Review comment:
       Yes, in this case(not zmodem), it may make sense to add a new variable 
for module.

##########
File path: crypto/mbedtls/Kconfig
##########
@@ -0,0 +1,25 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+menuconfig CRYPTO_MBEDTLS
+       bool "Mbed TLS Cryptography Library"
+       default n
+       ---help---
+               Enable support for Mbed TLS.
+
+if CRYPTO_MBEDTLS
+
+config MBEDTLS_VERSION
+       string "MBEDTLS Version"
+       default "2.25.0"
+
+config MBEDTLS_DEFAULT_TASK_STACKSIZE
+       int "Mbed TLS app default stack size"
+       default 8192

Review comment:
       Why not create PRfor mbedtls to allocate 100KB from heap:)

##########
File path: crypto/mbedtls/Make.defs
##########
@@ -0,0 +1,32 @@
+############################################################################
+# apps/crypto/mbedtls/Make.defs
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+ifeq ($(CONFIG_CRYPTO_MBEDTLS),y)
+CONFIGURED_APPS += $(APPDIR)/crypto/mbedtls
+
+# Allows `<mbedtls/<>.h>` import.
+
+CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" 
$(APPDIR)/crypto/mbedtls/mbedtls/include}
+CXXFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" 
$(APPDIR)/crypto/mbedtls/mbedtls/include}
+
+CFLAGS += ${shell $(DEFINE) "$(CC)" 
MBEDTLS_CONFIG_FILE='"<crypto/mbedtls_config.h>"'}

Review comment:
       It's the known build system issue, @anchao has the patch to fix it, 
please wait a moment.

##########
File path: crypto/mbedtls/Kconfig
##########
@@ -0,0 +1,25 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+menuconfig CRYPTO_MBEDTLS
+       bool "Mbed TLS Cryptography Library"
+       default n
+       ---help---
+               Enable support for Mbed TLS.
+
+if CRYPTO_MBEDTLS
+
+config MBEDTLS_VERSION
+       string "MBEDTLS Version"
+       default "2.25.0"
+
+config MBEDTLS_DEFAULT_TASK_STACKSIZE
+       int "Mbed TLS app default stack size"
+       default 8192

Review comment:
       Why not create PR for mbedtls to allocate 100KB from heap:)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to