diff --git a/mqx/ctaocrypt_test/.cproject b/mqx/ctaocrypt_test/.cproject new file mode 100644 index 000000000..6a742b34d --- /dev/null +++ b/mqx/ctaocrypt_test/.cproject @@ -0,0 +1,2542 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mqx/ctaocrypt_test/.project b/mqx/ctaocrypt_test/.project new file mode 100644 index 000000000..82a85749d --- /dev/null +++ b/mqx/ctaocrypt_test/.project @@ -0,0 +1,98 @@ + + + ctaocrypt_test + + + +cyassl + +util_lib + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.buildArguments + -j6 + + + org.eclipse.cdt.make.core.buildCommand + ${system:ECLIPSE_HOME}/../gnu/bin/mingw32-make + + + org.eclipse.cdt.make.core.buildLocation + ${ProjDirPath}/twrk70f120m_Int_Flash_SramData_Debug + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + Sources/ctaocrypt-test + 2 + PARENT-2-PROJECT_LOC/ctaocrypt/test + + + + + 1351803045734 + Sources/ctaocrypt-test + 5 + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-true-(.*?)\.(c)$ + + + + + + MQX_ROOT_DIR + file:/C:/Freescale/Freescale%20MQX%203.8 + + + diff --git a/mqx/ctaocrypt_test/ReferencedRSESystems.xml b/mqx/ctaocrypt_test/ReferencedRSESystems.xml new file mode 100644 index 000000000..3df5e1711 --- /dev/null +++ b/mqx/ctaocrypt_test/ReferencedRSESystems.xml @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mqx/ctaocrypt_test/Sources/main.c b/mqx/ctaocrypt_test/Sources/main.c new file mode 100644 index 000000000..bb3304320 --- /dev/null +++ b/mqx/ctaocrypt_test/Sources/main.c @@ -0,0 +1,103 @@ +/* main.c */ + +#include "main.h" + +/* SD card open/close utility functions */ +#include "util.h" + +#if !BSPCFG_ENABLE_IO_SUBSYSTEM +#error This application requires BSPCFG_ENABLE_IO_SUBSYSTEM defined \ + non-zero in user_config.h. Please recompile BSP with this option. +#endif + +#ifndef BSP_DEFAULT_IO_CHANNEL_DEFINED +#error This application requires BSP_DEFAULT_IO_CHANNEL to be not NULL. \ + Please set corresponding BSPCFG_ENABLE_TTYx to non-zero in \ + user_config.h and recompile BSP with this option. +#endif + + +TASK_TEMPLATE_STRUCT MQX_template_list[] = +{ +/* Task number, Entry point, Stack, Pri, String, Auto? */ + {MAIN_TASK, Main_task, 20000, 9, "main", MQX_AUTO_START_TASK}, + {0, 0, 0, 0, 0, 0, } +}; + +/*TASK*----------------------------------------------------- +* +* Task Name : Main_task +* Comments : +* This task opens the SD card device and runs the +* CTaoCrypt test functions located in test.c. +* +*END*-----------------------------------------------------*/ + +#if defined BSP_SDCARD_ESDHC_CHANNEL + #if ! BSPCFG_ENABLE_ESDHC + #error This application requires BSPCFG_ENABLE_ESDHC defined \ + non-zero in user_config.h. Please recompile libraries with \ + this option. + #endif + +#elif defined BSP_SDCARD_SDHC_CHANNEL + #if ! BSPCFG_ENABLE_SDHC + #error This application requires BSPCFG_ENABLE_SDHC defined \ + non-zero in user_config.h. Please recompile libraries with \ + this option. + #endif +#endif + +#if defined (BSP_SDCARD_SPI_CHANNEL) + #define SDCARD_COM_CHANNEL BSP_SDCARD_SPI_CHANNEL +#elif defined (BSP_SDCARD_ESDHC_CHANNEL) + #define SDCARD_COM_CHANNEL BSP_SDCARD_ESDHC_CHANNEL +#elif defined (BSP_SDCARD_SDHC_CHANNEL) + #define SDCARD_COM_CHANNEL BSP_SDCARD_SDHC_CHANNEL +#else + #error "SDCARD low level communication device not defined!" +#endif + +/* func_args from test.h */ +typedef struct func_args { + int argc; + char** argv; + int return_code; +} func_args; + +void Main_task(uint_32 initial_data) +{ + int ret = 0; + func_args args; + _mqx_int error_code, bytes; + _mqx_uint sz; + char filesystem_name[] = "a:"; + char partman_name[] = "pm:"; + MQX_FILE_PTR com_handle, sdcard_handle, filesystem_handle, partman_handle; + MQX_FILE_PTR cert_file = NULL; + const char* fileName = "a:\certs\\client-key.der"; + + ret = sdcard_open(&com_handle, &sdcard_handle, &partman_handle, + &filesystem_handle, partman_name, filesystem_name); + + if (ret != 0) { + printf("error: sdcard_open(), ret = %d\n", ret); + _mqx_exit(1); + } + printf("SD card installed to %s\n", filesystem_name); + + ctaocrypt_test(&args); + + ret = sdcard_close(&sdcard_handle, &partman_handle, + &filesystem_handle, partman_name, filesystem_name); + + if (ret != 0) { + printf("error: sdcard_close(), ret = %d\n", ret); + _mqx_exit(1); + } + printf("SD card uninstalled.\n"); + + _mqx_exit(0); +} + +/* EOF */ diff --git a/mqx/ctaocrypt_test/Sources/main.h b/mqx/ctaocrypt_test/Sources/main.h new file mode 100644 index 000000000..2ea7c9133 --- /dev/null +++ b/mqx/ctaocrypt_test/Sources/main.h @@ -0,0 +1,21 @@ +/* main.h */ + +#ifndef __main_h_ +#define __main_h_ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#define MAIN_TASK 1 + +extern void Main_task(uint_32); + +#endif /* __main_h_ */ + diff --git a/mqx/ctaocrypt_test/ctaocrypt_test_twrk70f120m_Int_Flash_SramData_Debug_PnE U-MultiLink.launch b/mqx/ctaocrypt_test/ctaocrypt_test_twrk70f120m_Int_Flash_SramData_Debug_PnE U-MultiLink.launch new file mode 100644 index 000000000..6c74d9ae1 --- /dev/null +++ b/mqx/ctaocrypt_test/ctaocrypt_test_twrk70f120m_Int_Flash_SramData_Debug_PnE U-MultiLink.launch @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mqx/ctaocrypt_test/ctaocrypt_test_twrk70f120m_Int_Flash_SramData_Release_PnE U-MultiLink.launch b/mqx/ctaocrypt_test/ctaocrypt_test_twrk70f120m_Int_Flash_SramData_Release_PnE U-MultiLink.launch new file mode 100644 index 000000000..8a56e79c0 --- /dev/null +++ b/mqx/ctaocrypt_test/ctaocrypt_test_twrk70f120m_Int_Flash_SramData_Release_PnE U-MultiLink.launch @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mqx/cyassl/.cproject b/mqx/cyassl/.cproject new file mode 100644 index 000000000..14a6d3b85 --- /dev/null +++ b/mqx/cyassl/.cproject @@ -0,0 +1,2579 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mqx/cyassl/.project b/mqx/cyassl/.project new file mode 100644 index 000000000..1ab3cb41d --- /dev/null +++ b/mqx/cyassl/.project @@ -0,0 +1,103 @@ + + + cyassl + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.buildArguments + -j6 + + + org.eclipse.cdt.make.core.buildCommand + ${system:ECLIPSE_HOME}/../gnu/bin/mingw32-make + + + org.eclipse.cdt.make.core.buildLocation + ${ProjDirPath}/twrk70f120m_Int_Flash_SramData_Debug + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + Sources/ctaocrypt_src + 2 + PARENT-2-PROJECT_LOC/ctaocrypt/src + + + Sources/cyassl_src + 2 + PARENT-2-PROJECT_LOC/src + + + + + 1351802255000 + Sources/ctaocrypt_src + 6 + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-aes_asm.s + + + + + + CYASSL_SOURCES + PARENT-2-PROJECT_LOC + + + MQX_ROOT_DIR + file:/C:/Freescale/Freescale%20MQX%203.8 + + + diff --git a/mqx/cyassl_client/.cproject b/mqx/cyassl_client/.cproject new file mode 100644 index 000000000..f75ed3280 --- /dev/null +++ b/mqx/cyassl_client/.cproject @@ -0,0 +1,2585 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mqx/cyassl_client/.project b/mqx/cyassl_client/.project new file mode 100644 index 000000000..a2241849c --- /dev/null +++ b/mqx/cyassl_client/.project @@ -0,0 +1,80 @@ + + + cyassl_client + + + +cyassl + +util_lib + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.buildArguments + -j6 + + + org.eclipse.cdt.make.core.buildCommand + ${system:ECLIPSE_HOME}/../gnu/bin/mingw32-make + + + org.eclipse.cdt.make.core.buildLocation + ${ProjDirPath}/twrk70f120m_Int_Flash_SramData_Debug + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + MQX_ROOT_DIR + file:/C:/Freescale/Freescale%20MQX%203.8 + + + diff --git a/mqx/cyassl_client/ReferencedRSESystems.xml b/mqx/cyassl_client/ReferencedRSESystems.xml new file mode 100644 index 000000000..0f4419bd0 --- /dev/null +++ b/mqx/cyassl_client/ReferencedRSESystems.xml @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mqx/cyassl_client/Sources/main.c b/mqx/cyassl_client/Sources/main.c new file mode 100644 index 000000000..7d04f9f3f --- /dev/null +++ b/mqx/cyassl_client/Sources/main.c @@ -0,0 +1,239 @@ +/* + * main.c + */ + +#include "main.h" +#include "util.h" + +#if !BSPCFG_ENABLE_IO_SUBSYSTEM +#error This application requires BSPCFG_ENABLE_IO_SUBSYSTEM defined \ + non-zero in user_config.h. Please recompile BSP with this option. +#endif + +#ifndef BSP_DEFAULT_IO_CHANNEL_DEFINED +#error This application requires BSP_DEFAULT_IO_CHANNEL to be not NULL. \ + Please set corresponding BSPCFG_ENABLE_TTYx to non-zero in \ + user_config.h and recompile BSP with this option. +#endif + +#if defined BSP_SDCARD_ESDHC_CHANNEL +#if ! BSPCFG_ENABLE_ESDHC +#error This application requires BSPCFG_ENABLE_ESDHC defined non-zero in \ + user_config.h. Please recompile libraries with this option. +#endif + +#elif defined BSP_SDCARD_SDHC_CHANNEL + +#if ! BSPCFG_ENABLE_SDHC +#error This application requires BSPCFG_ENABLE_SDHC defined non-zero in \ + user_config.h. Please recompile libraries with this option. +#endif + +#endif + +#if defined (BSP_SDCARD_SPI_CHANNEL) + #define SDCARD_COM_CHANNEL BSP_SDCARD_SPI_CHANNEL +#elif defined (BSP_SDCARD_ESDHC_CHANNEL) + #define SDCARD_COM_CHANNEL BSP_SDCARD_ESDHC_CHANNEL +#elif defined (BSP_SDCARD_SDHC_CHANNEL) + #define SDCARD_COM_CHANNEL BSP_SDCARD_SDHC_CHANNEL +#else + #error "SDCARD low level communication device not defined!" +#endif + +TASK_TEMPLATE_STRUCT MQX_template_list[] = +{ +/* Task number, Entry point, Stack, Pri, String, Auto? */ + {MAIN_TASK, Main_task, 20000, 9, "main", MQX_AUTO_START_TASK}, + {0, 0, 0, 0, 0, 0, } +}; + +/*TASK*----------------------------------------------------- +* +* Task Name : Main_task +* Comments : +* This task sets up the SD card and Ethernet devices, +* then starts the example CyaSSL client. The example +* CyaSSL client connects to a server over SSL and sends +* a simple HTTP GET message, then prints out the reply +* from the server. +* +* To change the IP address and port of the server, +* change the yasslIP and yasslPort variables in +* client_test(). Note that yasslIP needs to be given +* in hexadecimal. +* +*END*-----------------------------------------------------*/ + +void Main_task(uint_32 initial_data) +{ + int ret = 0; + _mqx_int error_code, bytes; + _mqx_uint param; + _mqx_uint sz; + MQX_FILE_PTR com_handle, sdcard_handle, filesystem_handle, partman_handle; + MQX_FILE_PTR cert_file = NULL; + char filesystem_name[] = "a:"; + char partman_name[] = "pm:"; + const char* fileName = "a:\certs\\client-key.der"; + + printf("Starting client example... \n"); + + ret = sdcard_open(&com_handle, &sdcard_handle, &partman_handle, + &filesystem_handle, partman_name, filesystem_name); + + if (ret != 0) { + printf("error: sdcard_open(), ret = %d\n", ret); + _mqx_exit(1); + } + printf("SD card installed to %s\n", filesystem_name); + + setup_ethernet(); + client_test(); + + ret = sdcard_close(&sdcard_handle, &partman_handle, &filesystem_handle, + partman_name, filesystem_name); + + if (ret != 0) { + printf("error: sdcard_close(), ret = %d\n", ret); + _mqx_exit(1); + } + printf("SD card uninstalled.\n"); + + _mqx_exit(0); +} + +void setup_ethernet(void) { + + int error; + _enet_handle ehandle; /* for Ethernet driver */ + _rtcs_if_handle ihandle; + _enet_address address; + + error = RTCS_create(); + if (error) { + err_sys("failed to create RTCS"); + } + + ENET_get_mac_address(BSP_DEFAULT_ENET_DEVICE, ENET_IPADDR, address); + + /* Set up the Ethernet driver */ + error = ENET_initialize(BSP_DEFAULT_ENET_DEVICE, address, 0, &ehandle); + if (error) + err_sys("failed to initialize Ethernet driver"); + + error = RTCS_if_add(ehandle, RTCS_IF_ENET, &ihandle); + if (error) + err_sys("failed to add interface for Ethernet"); + + error = RTCS_if_bind(ihandle, ENET_IPADDR, ENET_IPMASK); + if (error) + err_sys("failed to bind interface for Ethernet"); + +#ifdef GATE_IPADDR + RTCS_gate_add(GATE_IPADDR, INADDR_ANY, INADDR_ANY); +#endif + + printf("Ethernet device %d bound to %X\n", BSP_DEFAULT_ENET_DEVICE, + ENET_IPADDR); +} + +void client_test(void) { + + char msg[64]; + char reply[1024]; + int sockfd, input; + int ret = 0, msgSz = 0; + struct sockaddr_in servaddr; + CYASSL_CTX* ctx; + CYASSL* ssl; + + long yasslIP = 0xa9fea662; /* 169.254.166.98 */ + long yasslPort = 11111; + + CyaSSL_Debugging_ON(); + CyaSSL_Init(); + + ctx = CyaSSL_CTX_new(CyaSSLv3_client_method()); + + if (ctx == 0) + err_sys("setting up ctx"); + + ret = CyaSSL_CTX_use_certificate_file(ctx, clientCert, SSL_FILETYPE_PEM); + if (ret != SSL_SUCCESS) { + err_sys("can't load client cert file, check file"); + } + + ret = CyaSSL_CTX_use_PrivateKey_file(ctx, clientKey, SSL_FILETYPE_PEM); + if (ret != SSL_SUCCESS) { + err_sys("can't load client key file, check file"); + } + + ret = CyaSSL_CTX_load_verify_locations(ctx, caCert, 0); + if (ret != SSL_SUCCESS) { + err_sys("can't load CA cert file, check file"); + } + + /* create socket descriptor */ + sockfd = socket(AF_INET, SOCK_STREAM, 0); + if (sockfd == RTCS_SOCKET_ERROR) { + err_sys("socket creation failed"); + } else { + printf("socket created successfully\n"); + } + + /* Unlike most TCP/IP stacks, RTCS requires that sin_port and + * sin_addr needs to be in Host Byte Order, not Network Byte Order. + * This means we shouldn't use htons() when setting these values. */ + memset((char*)&servaddr, 0, sizeof(servaddr)); + servaddr.sin_family = AF_INET; + servaddr.sin_port = yasslPort; + servaddr.sin_addr.s_addr = yasslIP; + + ret = connect(sockfd, &servaddr, sizeof(servaddr)); + if (ret != RTCS_OK) { + err_sys("connect() failed"); + } else { + printf("Connected to %lx, port %d.\n", servaddr.sin_addr.s_addr, + servaddr.sin_port); + } + + if( (ssl = CyaSSL_new(ctx)) == NULL) { + err_sys("CyaSSL_new failed"); + } + + CyaSSL_set_fd(ssl, sockfd); + + ret = CyaSSL_connect(ssl); + if (ret != SSL_SUCCESS) + err_sys("CyaSSL_connect failed"); + + printf("CyaSSL_connect() ok, sending GET...\n"); + msgSz = 28; + strncpy(msg, "GET /index.html HTTP/1.0\r\n\r\n", msgSz); + if (CyaSSL_write(ssl, msg, msgSz) != msgSz) + err_sys("CyaSSL_write() failed"); + + input = CyaSSL_read(ssl, reply, sizeof(reply)); + if (input > 0) { + reply[input] = 0; + printf("Server response: %s\n", reply); + + while(1) { + input = CyaSSL_read(ssl, reply, sizeof(reply)); + if (input > 0) { + reply[input] = 0; + printf("%s\n", reply); + } else { + break; + } + } + } + + CyaSSL_shutdown(ssl); + CyaSSL_free(ssl); + CyaSSL_CTX_free(ctx); + CyaSSL_Cleanup(); +} + +/* EOF */ diff --git a/mqx/cyassl_client/Sources/main.h b/mqx/cyassl_client/Sources/main.h new file mode 100644 index 000000000..91c11b339 --- /dev/null +++ b/mqx/cyassl_client/Sources/main.h @@ -0,0 +1,61 @@ +/* main.h */ + +#ifndef __main_h_ +#define __main_h_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define MAIN_TASK 1 + +extern void Main_task(uint_32); +extern void setup_ethernet(void); +extern void client_test(void); + +/* cert file locations */ +static const char* fileName = "a:\certs\\ca-cert.pem"; +static const char* caCert = "a:\certs\\ca-cert.pem"; +static const char* clientCert = "a:\certs\\client-cert.pem"; +static const char* clientKey = "a:\certs\\client-key.pem"; + +static inline void err_sys(const char* msg) +{ + printf("yassl error: %s\n", msg); + if (msg) + _mqx_exit(1); +} + +/* PPP device must be set manually and +** must be different from the default IO channel (BSP_DEFAULT_IO_CHANNEL) +*/ +#define PPP_DEVICE "ittyb:" + +/* +** Define PPP_DEVICE_DUN only when using PPP to communicate +** to Win9x Dial-Up Networking over a null-modem +** This is ignored if PPP_DEVICE is not #define'd +*/ +#define PPP_DEVICE_DUN 1 + +#ifndef ENET_IPADDR + #define ENET_IPADDR IPADDR(169,254,3,3) +#endif + +#ifndef ENET_IPMASK + #define ENET_IPMASK IPADDR(255,255,0,0) +#endif + +#define GATE_IPADDR IPADDR(192,168,0,1) + +#endif /* __main_h_ */ + diff --git a/mqx/cyassl_client/cyassl_client_twrk70f120m_Int_Flash_SramData_Debug_PnE U-MultiLink.launch b/mqx/cyassl_client/cyassl_client_twrk70f120m_Int_Flash_SramData_Debug_PnE U-MultiLink.launch new file mode 100644 index 000000000..9aa53216f --- /dev/null +++ b/mqx/cyassl_client/cyassl_client_twrk70f120m_Int_Flash_SramData_Debug_PnE U-MultiLink.launch @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mqx/cyassl_client/cyassl_client_twrk70f120m_Int_Flash_SramData_Release_PnE U-MultiLink.launch b/mqx/cyassl_client/cyassl_client_twrk70f120m_Int_Flash_SramData_Release_PnE U-MultiLink.launch new file mode 100644 index 000000000..cff2bff7c --- /dev/null +++ b/mqx/cyassl_client/cyassl_client_twrk70f120m_Int_Flash_SramData_Release_PnE U-MultiLink.launch @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mqx/util_lib/.cproject b/mqx/util_lib/.cproject new file mode 100644 index 000000000..139b9a354 --- /dev/null +++ b/mqx/util_lib/.cproject @@ -0,0 +1,2538 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mqx/util_lib/.project b/mqx/util_lib/.project new file mode 100644 index 000000000..4e538b6e1 --- /dev/null +++ b/mqx/util_lib/.project @@ -0,0 +1,76 @@ + + + util_lib + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.buildArguments + -j6 + + + org.eclipse.cdt.make.core.buildCommand + ${system:ECLIPSE_HOME}/../gnu/bin/mingw32-make + + + org.eclipse.cdt.make.core.buildLocation + ${ProjDirPath}/twrk70f120m_Int_Flash_SramData_Debug + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + MQX_ROOT_DIR + file:/C:/Freescale/Freescale%20MQX%203.8 + + + diff --git a/mqx/util_lib/Sources/util.c b/mqx/util_lib/Sources/util.c new file mode 100644 index 000000000..0a3f396b5 --- /dev/null +++ b/mqx/util_lib/Sources/util.c @@ -0,0 +1,178 @@ +/* util.c */ + +#include +#include +#include +#include + +#include "util.h" + +#if !BSPCFG_ENABLE_IO_SUBSYSTEM + #error This application requires BSPCFG_ENABLE_IO_SUBSYSTEM defined \ + non-zero in user_config.h. Please recompile BSP with this option. +#endif + +#ifndef BSP_DEFAULT_IO_CHANNEL_DEFINED + #error This application requires BSP_DEFAULT_IO_CHANNEL to be not \ + NULL. Please set corresponding BSPCFG_ENABLE_TTYx to non-zero \ + in user_config.h and recompile BSP with this option. +#endif + +#if defined BSP_SDCARD_ESDHC_CHANNEL + #if ! BSPCFG_ENABLE_ESDHC + #error This application requires BSPCFG_ENABLE_ESDHC defined \ + non-zero in user_config.h. Please recompile libraries with \ + this option. + #endif +#elif defined BSP_SDCARD_SDHC_CHANNEL + #if ! BSPCFG_ENABLE_SDHC + #error This application requires BSPCFG_ENABLE_SDHC defined \ + non-zero in user_config.h. Please recompile libraries with \ + this option. + #endif +#endif + +#if defined (BSP_SDCARD_SPI_CHANNEL) + #define SDCARD_COM_CHANNEL BSP_SDCARD_SPI_CHANNEL +#elif defined (BSP_SDCARD_ESDHC_CHANNEL) + #define SDCARD_COM_CHANNEL BSP_SDCARD_ESDHC_CHANNEL +#elif defined (BSP_SDCARD_SDHC_CHANNEL) + #define SDCARD_COM_CHANNEL BSP_SDCARD_SDHC_CHANNEL +#else + #error "SDCARD low level communication device not defined!" +#endif + +int sdcard_open(MQX_FILE_PTR *com_handle, MQX_FILE_PTR *sdcard_handle, + MQX_FILE_PTR *partman_handle, MQX_FILE_PTR *filesystem_handle, + char *partman_name, char *filesystem_name) +{ + + _mqx_int error_code; + _mqx_uint param; + + /* Open low level communication device */ + *com_handle = fopen(SDCARD_COM_CHANNEL, NULL); + + if (NULL == *com_handle) { + printf("Error installing communication handle.\n"); + return -60; + } + + /* Install SD card device */ + error_code = _io_sdcard_install("sdcard:", (pointer) &_bsp_sdcard0_init, + *com_handle); + if (error_code != MQX_OK) { + printf("Error installing SD card device (0x%x)\n", error_code); + return -61; + } + + _time_delay(200); + + /* Open the device which MFS will be installed on */ + *sdcard_handle = fopen("sdcard:", 0); + if (*sdcard_handle == NULL) { + printf("Unable to open SD card device.\n"); + return -62; + } + + /* Install partition manager over SD card driver */ + error_code = _io_part_mgr_install(*sdcard_handle, partman_name, 0); + if (error_code != MFS_NO_ERROR) { + printf("Error installing partition manager: %s\n", MFS_Error_text( + (uint_32) error_code)); + return -63; + } + + /* Open partition manager */ + *partman_handle = fopen(partman_name, NULL); + if (*partman_handle == NULL) { + error_code = ferror(*partman_handle); + printf("Error opening partition manager: %s\n", MFS_Error_text( + (uint_32) error_code)); + return -64; + } + + /* Validate partition 1 */ + param = 1; + error_code = _io_ioctl(*partman_handle, IO_IOCTL_VAL_PART, ¶m); + if (error_code == MQX_OK) { + /* Install MFS over partition 1 */ + error_code = _io_mfs_install(*partman_handle, filesystem_name, param); + if (error_code != MFS_NO_ERROR) { + printf("Error initializing MFS over partition: %s\n", + MFS_Error_text((uint_32) error_code)); + return -65; + } + + } else { + /* Install MFS over SD card driver */ + error_code = _io_mfs_install(*sdcard_handle, filesystem_name, + (_file_size) 0); + if (error_code != MFS_NO_ERROR) { + printf("Error initializing MFS: %s\n", MFS_Error_text( + (uint_32) error_code)); + return -66; + } + } /* end Validate partition 1 */ + + /* Open file system */ + *filesystem_handle = fopen(filesystem_name, NULL); + error_code = ferror(*filesystem_handle); + if ((error_code != MFS_NO_ERROR) && (error_code != MFS_NOT_A_DOS_DISK)) { + printf("Error opening filesystem: %s\n", MFS_Error_text( + (uint_32) error_code)); + return -67; + } + if (error_code == MFS_NOT_A_DOS_DISK) { + printf("NOT A DOS DISK! You must format to continue.\n"); + return -68; + } + + return 0; +} + +int sdcard_close(MQX_FILE_PTR *sdcard_handle, MQX_FILE_PTR *partman_handle, + MQX_FILE_PTR *filesystem_handle, + char *partman_name, char *filesystem_name) +{ + _mqx_int error_code; + + /* Close the filesystem */ + if (MQX_OK != fclose(*filesystem_handle)) { + printf("Error closing filesystem.\n"); + return -69; + } + *filesystem_handle = NULL; + + /* Uninstall MFS */ + error_code = _io_dev_uninstall(filesystem_name); + if (error_code != MFS_NO_ERROR) { + printf("Error uninstalling filesystem.\n"); + return -70; + } + + /* Close partition manager */ + if (MQX_OK != fclose(*partman_handle)) { + printf("Unable to close partition manager.\n"); + return -71; + } + *partman_handle = NULL; + + /* Uninstall partition manager */ + error_code = _io_dev_uninstall(partman_name); + if (error_code != MFS_NO_ERROR) { + printf("Error uninstalling partition manager.\n"); + return -72; + } + + /* Close the SD card device */ + if (MQX_OK != fclose(*sdcard_handle)) { + printf("Unable to close SD card device.\n"); + return -73; + } + *sdcard_handle = NULL; + + return 0; +} + +/* EOF */ diff --git a/mqx/util_lib/Sources/util.h b/mqx/util_lib/Sources/util.h new file mode 100644 index 000000000..67bdca2fe --- /dev/null +++ b/mqx/util_lib/Sources/util.h @@ -0,0 +1,14 @@ +/* util.h */ + +#ifndef UTIL_H_ +#define UTIL_H_ + +int sdcard_open(MQX_FILE_PTR *com_handle, MQX_FILE_PTR *sdcard_handle, + MQX_FILE_PTR *partman_handle, MQX_FILE_PTR *filesystem_handle, + char *partman_name, char *filesystem_name); + +int sdcard_close(MQX_FILE_PTR *sdcard_handle, MQX_FILE_PTR *partman_handle, + MQX_FILE_PTR *filesystem_handle, + char *partman_name, char *filesystem_name); + +#endif /* UTIL_H_ */