So I'm having issues with building the TWR-K60F120M_QSD demo project for MQX 4.0.1 using IAR workbench v6.6. Although I was able to successfully build the project using MQX 3.8.1 with my IAR compiler.
It all started with IAR not being able to open certain header files, I figured this out after some googling. It turns out that the demo project was built with a previous version of IAR and the new IAR versioon (6.6) loses some of the include paths when opening on old IAR workspace project. After I fixed that problem I then ran into some issues where it was missing some MACRO definitions. Below is a screenshot of the errors from the IAR development environment.
I added the MACROS shown below into the ipcfg.h file then recompiled the MQX libraries.
extern uint_32 IPCFG_default_enet_device;
extern _enet_address IPCFG_default_enet_address;
extern _ip_address IPCFG_default_ip_address;
extern _ip_address IPCFG_default_ip_mask;
extern _ip_address IPCFG_default_ip_gateway;
I then switch over to my demo project workspace, in IAR, attempted to build the project. I then saw the following errors.
I also see an issue where it can’t find the definition for _cortex_in_init. If anyone can help that would be awesome.
Solved! Go to Solution.
I figured out why I could not link to the function _cortex_int_init, this was because it is no longer used in MQX versions greater than 3.8. You simply have to replace _cortex_int_init with _bsp_int_init in the <demo project dir>/tsi/tsi,c file.
For the IPCFG_default macro reference problems I simply had to not used them. Instead you have to refer to the ENET_ macros in the <demo project dir>/source/web/RTSC.c file. I also had to properly pass in the third parameter to the ENET_get_mac_address() function in RTCS.c Here is my new RTCS.c file:
/**HEADER********************************************************************
*
* Copyright (c) 2008 Freescale Semiconductor;
* All Rights Reserved
*
* Copyright (c) 2004-2008 Embedded Access Inc.;
* All Rights Reserved
*
***************************************************************************
*
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************
*
* $FileName: RTCS.c$
* $Version : 3.5.34.0$
* $Date : Jan-6-2010$
*
* Comments:
*
* Example of HVAC using RTCS.
*
*END************************************************************************/
#include "demo.h"
#include "web.h"
#include "httpd_types.h"
#include "tfs.h"
#include <ipcfg.h>
/* Define file structures to store HTML pages */
const HTTPD_ROOT_DIR_STRUCT root_dir[] = {
{ "", "tfs:" }, //Internal flash with Trivial File System (TFS)
{ "sdcard", "a:" }, //SDCard
{ 0, 0 }
};
void initialize_networking(void)
{
int_32 error;
IPCFG_IP_ADDRESS_DATA ip_data;
/* runtime RTCS configuration */
_RTCSPCB_init = 4;
_RTCSPCB_grow = 2;
_RTCSPCB_max = 20;
_RTCS_msgpool_init = 4;
_RTCS_msgpool_grow = 2;
_RTCS_msgpool_max = 20;
_RTCS_socket_part_init = 4;
_RTCS_socket_part_grow = 2;
_RTCS_socket_part_max = 20;
_enet_address serverAddress = { 0x00, 0xcf, 0x52, 0x53, 0x54, 0xcc };
_RTCSTASK_stacksize = 2200;
error = RTCS_create();
LWDNS_server_ipaddr = ENET_IPGATEWAY;
ip_data.ip = ENET_IPADDR;
ip_data.mask = ENET_IPMASK;
ip_data.gateway = ENET_IPGATEWAY;
ENET_get_mac_address (DEMOCFG_DEFAULT_DEVICE, ENET_IPADDR, serverAddress);
error = ipcfg_init_device (DEMOCFG_DEFAULT_DEVICE, serverAddress);
#if DEMOCFG_ENABLE_DHCP
error = ipcfg_bind_dhcp_wait(DEMOCFG_DEFAULT_DEVICE, 1, &ip_data);
if (error != IPCFG_ERROR_OK)
{
printf("DHCP Error %08x!\n", error);
}
#else
error = ipcfg_bind_staticip (DEMOCFG_DEFAULT_DEVICE, &ip_data);
if (error != IPCFG_ERROR_OK)
{
printf("Static IP Error %08x!\n", error);
}
#endif
ipcfg_get_ip(DEMOCFG_DEFAULT_DEVICE, &ip_data);
printf("IP Address : %d.%d.%d.%d\n\n",IPBYTES(ip_data.ip));
#if DEMOCFG_ENABLE_WEBSERVER
{
HTTPD_STRUCT *server;
extern const HTTPD_CGI_LINK_STRUCT cgi_lnk_tbl[];
extern const HTTPD_FN_LINK_STRUCT fn_lnk_tbl[];
extern const TFS_DIR_ENTRY tfs_data[];
if ((error = _io_tfs_install("tfs:", tfs_data))) {
printf("\ninstall returned: %08x\n", error);
}
server = httpd_server_init((HTTPD_ROOT_DIR_STRUCT*)root_dir, "\\mqx.html");
HTTPD_SET_PARAM_CGI_TBL(server, (HTTPD_CGI_LINK_STRUCT*)cgi_lnk_tbl);
HTTPD_SET_PARAM_FN_TBL(server, (HTTPD_FN_LINK_STRUCT*)fn_lnk_tbl);
httpd_server_run(server);
}
#endif
}
/* EOF */
I figured out why I could not link to the function _cortex_int_init, this was because it is no longer used in MQX versions greater than 3.8. You simply have to replace _cortex_int_init with _bsp_int_init in the <demo project dir>/tsi/tsi,c file.
For the IPCFG_default macro reference problems I simply had to not used them. Instead you have to refer to the ENET_ macros in the <demo project dir>/source/web/RTSC.c file. I also had to properly pass in the third parameter to the ENET_get_mac_address() function in RTCS.c Here is my new RTCS.c file:
/**HEADER********************************************************************
*
* Copyright (c) 2008 Freescale Semiconductor;
* All Rights Reserved
*
* Copyright (c) 2004-2008 Embedded Access Inc.;
* All Rights Reserved
*
***************************************************************************
*
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************
*
* $FileName: RTCS.c$
* $Version : 3.5.34.0$
* $Date : Jan-6-2010$
*
* Comments:
*
* Example of HVAC using RTCS.
*
*END************************************************************************/
#include "demo.h"
#include "web.h"
#include "httpd_types.h"
#include "tfs.h"
#include <ipcfg.h>
/* Define file structures to store HTML pages */
const HTTPD_ROOT_DIR_STRUCT root_dir[] = {
{ "", "tfs:" }, //Internal flash with Trivial File System (TFS)
{ "sdcard", "a:" }, //SDCard
{ 0, 0 }
};
void initialize_networking(void)
{
int_32 error;
IPCFG_IP_ADDRESS_DATA ip_data;
/* runtime RTCS configuration */
_RTCSPCB_init = 4;
_RTCSPCB_grow = 2;
_RTCSPCB_max = 20;
_RTCS_msgpool_init = 4;
_RTCS_msgpool_grow = 2;
_RTCS_msgpool_max = 20;
_RTCS_socket_part_init = 4;
_RTCS_socket_part_grow = 2;
_RTCS_socket_part_max = 20;
_enet_address serverAddress = { 0x00, 0xcf, 0x52, 0x53, 0x54, 0xcc };
_RTCSTASK_stacksize = 2200;
error = RTCS_create();
LWDNS_server_ipaddr = ENET_IPGATEWAY;
ip_data.ip = ENET_IPADDR;
ip_data.mask = ENET_IPMASK;
ip_data.gateway = ENET_IPGATEWAY;
ENET_get_mac_address (DEMOCFG_DEFAULT_DEVICE, ENET_IPADDR, serverAddress);
error = ipcfg_init_device (DEMOCFG_DEFAULT_DEVICE, serverAddress);
#if DEMOCFG_ENABLE_DHCP
error = ipcfg_bind_dhcp_wait(DEMOCFG_DEFAULT_DEVICE, 1, &ip_data);
if (error != IPCFG_ERROR_OK)
{
printf("DHCP Error %08x!\n", error);
}
#else
error = ipcfg_bind_staticip (DEMOCFG_DEFAULT_DEVICE, &ip_data);
if (error != IPCFG_ERROR_OK)
{
printf("Static IP Error %08x!\n", error);
}
#endif
ipcfg_get_ip(DEMOCFG_DEFAULT_DEVICE, &ip_data);
printf("IP Address : %d.%d.%d.%d\n\n",IPBYTES(ip_data.ip));
#if DEMOCFG_ENABLE_WEBSERVER
{
HTTPD_STRUCT *server;
extern const HTTPD_CGI_LINK_STRUCT cgi_lnk_tbl[];
extern const HTTPD_FN_LINK_STRUCT fn_lnk_tbl[];
extern const TFS_DIR_ENTRY tfs_data[];
if ((error = _io_tfs_install("tfs:", tfs_data))) {
printf("\ninstall returned: %08x\n", error);
}
server = httpd_server_init((HTTPD_ROOT_DIR_STRUCT*)root_dir, "\\mqx.html");
HTTPD_SET_PARAM_CGI_TBL(server, (HTTPD_CGI_LINK_STRUCT*)cgi_lnk_tbl);
HTTPD_SET_PARAM_FN_TBL(server, (HTTPD_FN_LINK_STRUCT*)fn_lnk_tbl);
httpd_server_run(server);
}
#endif
}
/* EOF */