README_custom_port 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. Steps taken to evaluate wolfSSL with the following:
  2. Required Software for this guide:
  3. IAR Embedded Workbench IDE - ARM v7.60.1 (or similar version)
  4. embOS (version that supports your CPU)
  5. wolfssl (latest version)
  6. #----------------------------------------------------------------------------#
  7. # SECTION 1:
  8. # Setting up the file system
  9. #----------------------------------------------------------------------------#
  10. 1. Browse to wolfssl/IDE/IAR-EWARM/embOS/
  11. a. copy/paste the directory custom_port and re-name it to the CPU
  12. you intend to target. For now we will just use the term CUSTOM_DIR
  13. to signify a copy of the custom_port directory
  14. #----------------------------------------------------------------------------#
  15. # SECTION 2:
  16. # Create wolfcrypt_lib.a
  17. #----------------------------------------------------------------------------#
  18. 1. Open IAR Workbench -> Project -> Create New Project -> Empty Project
  19. c. Browse to CUSTOM_DIR/wolfcrypt_lib_custom_port/ (from section 1)
  20. d. Called it "wolfcrypt_lib" and hit "Save"
  21. 2. Go to Project -> Add Group...
  22. a. call group wolfcrypt_sources
  23. 3. Right click on wolfcrypt_sources group -> Add -> Add Files...
  24. 4. Browse to wolfssl/wolfcrypt/src directory and select the following files:
  25. #---------------------------------------------#
  26. # aes.c memory.c #
  27. # asn.c misc.c #
  28. # chacha.c poly1305.c #
  29. # chacha20_poly1305.c pwdbased.c #
  30. # coding.c random.c #
  31. # des3.c rsa.c #
  32. # dh.c sha.c #
  33. # dsa.c sha256.c #
  34. # ecc.c sha512.c #
  35. # hash.c tfm.c #
  36. # hmac.c wc_encrypt.c #
  37. # md4.c wc_port.c #
  38. # md5.c #
  39. # kdf.c #
  40. #---------------------------------------------#
  41. 5. Once those are all added go to
  42. Project -> Properties C/C++ Compiler -> Preprocessor (Tab)
  43. a. In the field "Defined symbols:" add WOLFSSL_USER_SETTINGS
  44. b. In the field "Additional include directories:"
  45. put in this line: $PROJ_DIR$\..\..\..\..\..\
  46. and this line: $PROJ_DIR$\..\custom_port_user_settings
  47. #---------------------------------------------
  48. #(Or alternately you can use the browse option to navigate to
  49. #C:\<path-to>\wolfssl and
  50. #C:\<path-to>\wolfssl\IDE\IAR-EWARM\CUSTOM_DIR\
  51. # custom_port_user_settings\)
  52. #(If you ever need to change or customize your build settings this
  53. #is the file that should be modified:
  54. #CUSTOM_DIR\custom_port_user_settings\user_settings.h)
  55. #---------------------------------------------
  56. 7. In Project -> Options -> General Options -> Output (Tab)
  57. Check the option for "Library" instead of "Executable"
  58. Click "OK"
  59. 8. Go to Project -> Rebuild all (The library should build)
  60. 9. Confirm the library is now located here:
  61. C:\<path to>\wolfssl\IDE\IAR-EWARM\CUSTOM_DIR\wolfcrypt_lib_custom_port\
  62. Debug\Exe\wolfcrypt_lib.a
  63. We are now set to link to this library in the evaluation project
  64. #----------------------------------------------------------------------------#
  65. # SECTION 3:
  66. # Evaluate wolfcrypt tests in embOS project:
  67. #----------------------------------------------------------------------------#
  68. 1. go to embOS website and download a trial for your platform
  69. https://www.segger.com/downloads/embos ->
  70. embOS trial for Cortex-M and IAR compiler
  71. 2. After downloading, extract the zip to:
  72. C:\<path-to>\wolfssl\IDE\IAR-EWARM\embOS\extract_trial_here\
  73. 3. Open IAR Workbench -> Project -> Create New Project -> Empty Project
  74. c. Browse to CUSTOM_DIR\wolfcrypt_test_custom_port\ (from section 1)
  75. d. Called it "wolfcrypt_test" and hit "Save"
  76. 4. Go to Project -> Options -> C/C++ Compiler -> Preprocessor (Tab)
  77. a. Add these to the field "Defined symbols:"
  78. DEBUG=1
  79. __CPU-YOU-ARE-TARGETING__ (For example: __SAMV71Q21__)
  80. WOLFSSL_USER_SETTINGS
  81. b. Now in the field "Additional include directories:"
  82. $PROJ_DIR$\..\..\..\..\..\
  83. $PROJ_DIR$\..\custom_port_user_settings
  84. #---------------------------------------------
  85. #(Or alternately you can use the browse option to navigate to
  86. #C:\<path-to>\wolfssl and
  87. #C:\<path-to>\wolfssl\IDE\IAR-EWARM\CUSTOM_DIR\
  88. # custom_port_user_settings\)
  89. #---------------------------------------------
  90. 5. Go to Project -> Options -> Linker -> Library (Tab)
  91. Add to the field "Additional libraries:"
  92. $PROJ_DIR$\..\embOS_wolfcrypt_lib_SAMV71_XULT\Debug\Exe\wolfcrypt_lib.a
  93. $PROJ_DIR$\..\..\extract_trial_here\Start\Lib\os7m_tlv_dp.a
  94. 6. The main project file is located here:
  95. CUSTOM_DIR\wolfcrypt_test_custom_port\Application\runWolfcryptTests.c
  96. 7. Right Click the project name: Add -> Add Group
  97. add a group called "Application"
  98. 8. Right Click that group and Add -> Add files
  99. browse to the main project file in step 5 above
  100. 9. Create Groups and add files for your CPU's support. These will be .c
  101. files found in the extracted directory in two places:
  102. extract_trial_here\Start\BoardSupport\<vendor>\<CPU>\DeviceSupport
  103. extract_trial_here\Start\BoardSupport\<vendor>\<CPU>\Setup
  104. #---------------------------------------------
  105. # For example:
  106. # extract_trial_here\Start\BoardSupport\Atmel\SAMV71_XPlainedUltra\
  107. # DeviceSupport
  108. # extract_trial_here\Start\BoardSupport\Atmel\SAMV71_XPlainedUltra\Setup
  109. #---------------------------------------------
  110. 10. To get Logging working for seeing test results:
  111. a. Go to Project -> Options -> General Options -> Library Configuration
  112. b. In the field "Library low-level interface implementation"
  113. Check the radio button for Semihosted
  114. Then in the inner field marked "stdout/stderr"
  115. Check the radio button for "Via semihosting" and click "OK"
  116. 11. Now we're ready to build and debug the project.
  117. a. Project -> Options -> Debugger
  118. In the field marked "Driver" Select drop-down and choose J-Link/J-Trace
  119. Click "OK"
  120. b. Project -> Rebuild All
  121. c. Connect your Cortex-M evaluation board to j-Trace and j-Trace to PC
  122. d. Connect the micro-USB to the debug port of the Cortex-M and PC for power
  123. e. Project -> Download and Debug
  124. 12. Once the Debug environment spawns go to View -> Terminal I/O
  125. This is where the "printf" to stdout will be directed
  126. 13. In the Debug Menu bar look for the little square with three arrows pointing
  127. to the right. When you mouse over it should say "GO"
  128. Click this option and in the Terminal I/O Window you should see something
  129. like this (depends on which functionality you set in user_settings.h)
  130. SEE NOTE 1 BELOW IF YOU OBSERVE AN ERROR (-40) IN RSA TEST
  131. Begin wolfcrypt tests
  132. MD5 test passed!
  133. MD4 test passed!
  134. SHA test passed!
  135. SHA-256 test passed!
  136. SHA-384 test passed!
  137. SHA-512 test passed!
  138. HMAC-MD5 test passed!
  139. HMAC-SHA test passed!
  140. HMAC-SHA256 test passed!
  141. HMAC-SHA384 test passed!
  142. HMAC-SHA512 test passed!
  143. GMAC test passed!
  144. Chacha test passed!
  145. POLY1305 test passed!
  146. ChaCha20-Poly1305 AEAD test passed!
  147. DES test passed!
  148. DES3 test passed!
  149. AES test passed!
  150. AES-GCM test passed!
  151. RANDOM test passed!
  152. RSA test passed!
  153. DH test passed!
  154. DSA test passed!
  155. PWDBASED test passed!
  156. ECC test passed!
  157. wolfcrypt tests complete.
  158. #----------------------------------------------------------------------------#
  159. # SECTION 4:
  160. # Evaluate benchmark tests in embOS project:
  161. #----------------------------------------------------------------------------#
  162. Follow the steps from section 3 only using
  163. CUSTOM_DIR\wolfcrypt_benchmark_custom_port\
  164. #----------------------------------------------------------------------------#
  165. #----------------------------------------------------------------------------#
  166. Thank you for using this guide and we hope this was helpful to you. If you have
  167. any suggestions / feedback for us please contact us:
  168. support@wolfssl.com
  169. info@wolfssl.com
  170. /* --------------------------------------------------------------------------*/
  171. #### NOTE 1: ####
  172. If you are working off of a base example project and you observe memory errors
  173. when malloc is called, make sure that the linker script has set the HEAP high
  174. enough.
  175. Project -> Options -> Linker -> (Config Tab) -> Linker configuration file
  176. Check this file for __size_heap__ it is typically set to 0x200 by default.
  177. There are places in wolfSSL that malloc as much as 4k at a time and peak usage
  178. can be as high as 29K if using full functionality.
  179. /* --------------------------------------------------------------------------*/
  180. Copyright © 2016 wolfSSL Inc. All rights reserved.