cancel
Showing results for 
Search instead for 
Did you mean: 

undefined reference to

Agde.1
Associate III

Hello!

Can somebody say what im doing wrong

I have project in STM32CubeIDE with lwip and freertos

Im trying to add new thread(as new task) with exist principles and cant do it

/* Definitions for TCPip */

osThreadId_t mtcpConHandle;

const osThreadAttr_t mtcpCon_attributes = {

.name = “mtcpCon�?,

.stack_size = 384 * 4,

.priority = (osPriority_t) osPriorityNormal,

};

void mstartTcpCon(void *argument);

int main(void)

{

/* creation of TCPip connection*/

mtcpConHandle = osThreadNew(mstartTcpCon, NULL, &mtcpCon_attributes);

while (1)

{

}

}

void mstarTcpCon(void *argument)

{

....

}

And at build I have got the following make errors:

main.o: in function ‘main’

undefined reference to ‘mstartTcpCon’

1 ACCEPTED SOLUTION

Accepted Solutions
Agde.1
Associate III

Sorry, fixed, mstarTcpCon is already in main, partly declared here

View solution in original post

9 REPLIES 9

hello

void mstartTcpCon(void *argument); is a declaration.

need to define this entry function for thread.

Agde.1
Associate III

Sorry, fixed, mstarTcpCon is already in main, partly declared here

Agde.1
Associate III

and in that the point

Agde.1
Associate III

yet another question to that

The target of mstartTcpCon is to connect to the sever(PC) within TCPIP

In that function I use netconn API within FreeRTOS and I create connection(socket), connect to server and send data

But in proctice I have en Error after netconn_connect

Please help

Here the source code of that function:

void mstartTcpCon(void *argument)

{

ip_addr_t server_ip;

struct netconn *conn, *newconn;

err_t err, accept_err;

struct netbuf *buf;

uint8_t *data;

uint8_t mas[8] = {1,2,3,4,5,6,7,8};

u16_t len = 8;

data = &mas[0];

IP4_ADDR(&server_ip, 169, 254, 44, 141);

conn = netconn_new(NETCONN_TCP);

if (conn != NULL)

{

err = netconn_bind(conn, NULL, 80);

if (err == ERR_OK)

{

err = netconn_connect(conn, &server_ip, 80);

if(err == ERR_OK)

{

err = netconn_write(conn, data, len, NETCONN_DONTBLOCK);

if (err == ERR_OK)

{

netconn_listen(conn);

while (1)

{

accept_err = netconn_accept(conn, &newconn);

if (accept_err == ERR_OK)

{

while (netconn_recv(newconn, &buf) == ERR_OK)

{

do

{

netbuf_data(buf, (void *)&data, &len);

if(data[0] == 0xAA && len >= 2) data[1] = ~data[0];

netconn_write(newconn, data, len, NETCONN_COPY);

}

while (netbuf_next(buf) >= 0);

netbuf_delete(buf);

}

netconn_close(newconn);

netconn_delete(newconn);

}

}

}

}}

else

{

netconn_delete(newconn);

}

}

vTaskDelete(NULL);

}

Hello

Searching for a solution to this issue, implies that board is initialized well, configured and successfully pinged from another network device in the same network.

There are known issues about lwip+RTOS+cubeMX conf, depending also from MCU type .

By giving much more details about board, MCU, and which function is affected, what is the returned error code, helps people here to find a solution easier than guessing.

Search on community articles here, to find similar issues. Take a look also here https://community.st.com/s/article/How-to-create-project-for-STM32H7-with-Ethernet-and-LwIP-stack-working.

Agde.1
Associate III

Sorry, the previous en error was cause of absence of server

Now connection established but when I send data I cant see it in Wireshark

and in debug mode I have Err_Ok after data transmission. At PC side server in listen 

void mstartTcpCon(void *argument)

{

ip_addr_t server_ip;

ip_addr_t client_ip;

  struct netconn *conn, *newconn;

  err_t err, accept_err;

  struct netbuf *buf;

  struct netbuf *buf2;

  uint8_t *data;

  uint8_t mas[8] = {1,2,3,4,5,6,7,8};

  u16_t len = 8;

  //data = &mas[0];

  IP4_ADDR(&server_ip, 169, 254, 44, 141);

  IP4_ADDR(&client_ip, 169, 254, 44, 138);

  conn = netconn_new(NETCONN_TCP);

  if (conn != NULL)

  {

   //err = netconn_bind(conn, IP4_ADDR_ANY, 56547);

   err = netconn_bind(conn, &client_ip, 56547);

   if (err == ERR_OK)

   {

   err = netconn_connect(conn, &server_ip, 56547);

   

    }

   }

   else

   {

    netconn_delete(newconn);

   }

  }

  vTaskDelete(NULL);

}

Wireshark absence of data transfer from slave here:

https://dropmefiles.com/9en66

P.S. I use custom board based on STM32F429 and project in CubeIDE

Agde.1
Associate III

Thanks fro your support. In debug mode I see that I have only ERR_OK from netconn API.

I simpify the code and have got the following:

void mstartTcpCon(void *argument)

{

ip_addr_t server_ip;

ip_addr_t client_ip;

struct netconn *conn;//, *newconn;

err_t err;//, accept_err;

struct netbuf *buf2;

uint8_t *data;

uint8_t mas[8];

u16_t len = 8;

IP4_ADDR(&server_ip, 169, 254, 44, 141);

IP4_ADDR(&client_ip, 169, 254, 44, 138);

conn = netconn_new(NETCONN_TCP);

if (conn != NULL)

{

err = netconn_bind(conn, &client_ip, 56547);

if (err == ERR_OK)

{

err = netconn_connect(conn, &server_ip, 56547);

if(err == ERR_OK)

{

mas[0] = 0x31;

mas[1] = 0x32;

mas[2] = 0x33;

mas[3] = 0x34;

mas[4] = 0x35;

mas[5] = 0x36;

mas[6] = 0x37;

mas[7] = 0x38;

buf2 = netbuf_new();

netbuf_alloc(buf2,len);

netbuf_ref(buf2, mas, len);

err = netconn_write(conn, mas, len, NETCONN_NOCOPY);

if (err == ERR_OK)

{

netbuf_free(buf2);

netbuf_delete(buf2);

netconn_close(conn);

netconn_delete(conn);

}}

else

{

netconn_close(conn);

netconn_delete(conn);

}

}

vTaskDelete(NULL);

}

///

}

And wireshark log which I cant recognize

https://dropmefiles.com/mBeRq

At the PC(server) side I see the connetion, receiving, but the data is mpty string and size of data decreased in 2 bytes, - I send 8 bytes and receive 6.

Why I cant see it in wireshark maybe cause of W10?

Also I cant see any ARP

> Why I cant see it in wireshark maybe cause of W10?

Wireshark capture driver for win10 has known issues, so yes, may be. Better use Linux.

--pa

Agde.1
Associate III

Finally Ive got working TCP, but while integration it in exist project I have some problem

Project based on queues and then I create new queue I stopped on xQueueReceive

And when I trying to paste new code into existing queue I also have problem

Here the existing queue:

  ~~~

void startUartTx(void *argument)

{

  

 UART_HandleTypeDef* uart = uartM3g;

 osMessageQueueId_t qu = quMsgM3gHandle;

 struct netbuf *buffer;

  err_t err;

 /* Infinite loop */

 for(;;)

 {

  MessageNode msgNode;

  xQueueReceive(qu, &msgNode, portMAX_DELAY);

  vPortEnterCritical();

  HAL_UART_Transmit(uart, (uint8_t*)msgNode.message, msgNode.size, 1000);

  //xQueueSend(qu, &msgNode, portMAX_DELAY);

  buffer = netbuf_new();

   //netbuf_alloc(buffer,sizeof(msgNode));

   netbuf_alloc(buffer,5);

   //netbuf_ref(buf2, data, len);

   buffer->p->payload = msgNode.message;

   buffer->p->len = 5;//msgNode.size;

   err = netconn_write(conn, buffer->p->payload, buffer->p->len, NETCONN_COPY);// NETCONN_DONTBLOCK);

   netbuf_delete(buffer);

  msg_free(&msgNode);

    vPortExitCritical();

    osDelay(1);

  // vTaskResume(TCPTxHandle);

 }

}~~~

 There I stoping in на buffer->p->len = 5;//msgNode.size; with any value of buffer size.

In debug mode I see that I stopped in while of the following functions:

~~~

void HardFault_Handler(void)

{

 /* USER CODE BEGIN HardFault_IRQn 0 */

 struct

 {

  uint32_t r0;

  uint32_t r1;

  uint32_t r2;

  uint32_t r3;

  uint32_t r12;

  uint32_t lr;

  uint32_t pc;

  uint32_t psr;

 } *stack_ptr;        

 asm(

  "TST lr, #4 \n"      

  "ITE EQ \n"        

  "MRSEQ %[ptr], MSP \n" 

  "MRSNE %[ptr], PSP \n" 

  : [ptr] "=r" (stack_ptr)

 );

 /* USER CODE END HardFault_IRQn 0 */

 while (1)

 {

  /* USER CODE BEGIN W1_HardFault_IRQn 0 */

  /* USER CODE END W1_HardFault_IRQn 0 */

 }

}

~~~

Please help, I dont understand how work in FreeRTOS with queues instead of tasks