Problem porting TCP Client example

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
srini_a
Level 3
Level 3
50 sign-ins 10 questions asked 10 replies posted

Hi,

I successfully tested the TCP Client and TCP Server example using 2 CY8CKIT-062-WIFI-BT. The only configuration setting I changed was the SSID and Password. Everything worked as expected.

I then ported the TCP Client example to my custom board based on CY8C6247FDI-D32 and CY4343W and it is failing in netifapi_netif_add() when calling tcpip_api_call(). Any suggestion?

Just wanted to add that the WiFi Scan example from modus toolbox works fine on my board - this proves that the board itself is OK from HW point of view.

Screenshot 2023-03-03 at 4.04.13 PM.pngScreenshot 2023-03-03 at 2.08.01 PM.png

0 Likes
1 Solution
GrCa_1363456
Level 6
Level 6
50 likes received Beta tester First comment on KBA

Some of the TCP code examples are configured to utilize a hardware Crypto accelerator.

 

The code example provided uses cy-mbedtls-acceleration library ( https://github.com/Infineon/cy-mbedtls-acceleration ).  This library is dependent on a hardware crypto accelerator which does not exist on every PSoC 6 device. Check the Ordering Information table in the data sheet to determine which specific devices have “Crypto”.

 

The crypto hardware acceleration can be disabled by modifying the makefile and a header file as follows:

 

Modify the Makefile 

# Custom configuration of mbedtls library.

MBEDTLSFLAGS = MBEDTLS_USER_CONFIG_FILE='"mbedtls_user_config.h"'

 

# Add additional defines to the build process (without a leading -D).

DEFINES=$(MBEDTLSFLAGS) CYBSP_WIFI_CAPABLE CY_RETARGET_IO_CONVERT_LF_TO_CRLF CY_RTOS_AWARE DISABLE_MBEDTLS_ACCELERATION

 

Modify mbedtls_user_config.h in mtb_shared folder to disable the hardware entropy by commenting out the #define MBEDTLS_ENTROPY_HARDWARE_ALT

  

/**

* \def MBEDTLS_ENTROPY_HARDWARE_ALT

*

* Uncomment this macro to let mbed TLS use your own implementation of a

* hardware entropy collector.

*

* Your function must be called \c mbedtls_hardware_poll(), have the same

* prototype as declared in entropy_poll.h, and accept NULL as first argument.

*

* Uncomment to use your own hardware entropy collector.

*/

#define MBEDTLS_ENTROPY_HARDWARE_ALT

 

P.S. Thank you to Mark and Srini for confirming this fix and staying with the Infineon team while they resolved this issue.

Greg

 

View solution in original post

6 Replies
Phanindra_I
Moderator
Moderator
Moderator
250 sign-ins 10 likes given 25 likes received

Hi,

Is the tcp server example also not working on your custom board? If possible, can you use the "Tester - WiFi Mfg Tool" application and connect to an AP with "wl join" command?

Thanks

0 Likes
srini_a
Level 3
Level 3
50 sign-ins 10 questions asked 10 replies posted

Thanks so much for the reply. Are the TCP examples expected to work on our board (CY8C6247FDI-D32) that doesn't support CRYPTO feature??

 

GPIOs

Crypto

Secure Boot

Package

 

CY8C6247FDI-D32

62

No

No

80-WLCSP

Custom board

CY8C6247BZI-D54

100

Yes

Yes

124-BGA

CY8CKIT-062-WIFI-BT

 

Following up on your suggestion @Phanindra_I , when I ported the TCP Server example on our board, I get the same exact error as the TCP Client example. I then tried to use the "Tester - WiFi Mfg Tool" on the CY8CKIT-062-WiFi-BT, but its not clear how the join command supposed to work. I want to first get this example working correctly on the DEVKIT so I can compare the results. 

On the DEVKIT:

  • wl4343x.exe --serial 8 ver returns the version info - no problem.
  • wl4343x.exe --serial 8 isscan_s <my ap name> and then wl4343x.exe --serial 8 isscanresults returns the information about the SSID successfully.
  • wl4343x.exe --serial 8 join <my AP name> <password> and then the status returns Not associated. Last associated with SSID:""
0 Likes
Phanindra_I
Moderator
Moderator
Moderator
250 sign-ins 10 likes given 25 likes received

Hi,

Please execute the below set of commands appropriately to join a network as per its security.

For open security -

  1. wl4343X.exe --serial <com_port> down
  2. wl4343X.exe --serial <com_port> up
  3. wl4343X.exe --serial <com_port> join <ssid> imode bss amode open

For WPA2 AES PSK security -

  1. wl4343X.exe --serial <com_port> down
  2. wl4343X.exe --serial <com_port> up
  3. wl4343X.exe --serial <com_port> wsec 4
  4. wl4343X.exe --serial <com_port> set_pmk <wifi_password>
  5. wl4343X.exe --serial <com_port> join <ssid> imode bss amode wpa2psk

Thanks

 

0 Likes

@Phanindra_I Thank you for your response. I first verified using the commands you listed above that the application works fine on the CY8CKIT-062-WIFI-BT.   I then ported the mfg tool application to our hardware. We are using the following WiFi chipset.

  • LBEE5KL1DX-883 (Uses CY4343W)

I verified that the application starts up OK, but when using the 'wl' commands, I see errors. Please advise.

=============================================

FreeRTOS MfgTest Application

FreeRTOS Version: V10.4.3 LTS Patch 2

WiFi Mfg Tester : WIFI_MFG_VER

=============================================

Mfg test Application.

Wi-Fi Connection Manager initialized.

//////////////////////////////////////////////////////////

 
0 Likes
mark_ennamorato
Level 3
Level 3
5 questions asked 25 sign-ins First like given

All,

Ok can we get back to the original problem ?  Which is ... in the Infineon lwip stack, there are packet buffers used for tx and rx that get allocated and freed in pbuf.c.  For some *unknown reason*  the original error shows up where the function pbuf_free is failing to release a buffer.   The path to get here is thru the process of trying to connect to a Access Point (AP) and a long trail thru wifiinit(), whd_buffer_release(), cy_buffer_release() and finally pbuf_free() where the first check is :

731 if (p == NULL) {
732          LWIP_ASSERT("p != NULL", p != NULL);   <---- asserts here!  AND I cannot make sense of this assert but..

So... instead of going thru other rabbit holes of different projects to try,  can someone explain this?

ESPECIALLY why does this only happen with the CY8C6247FDI-D32 and CY4343W combo  AND the Makefile directive DEFINES+=COMPONENT_43907 ???  [ this last items is needed to make it even compile since this MCU does not have a hardware TRNG and without this directive linking everything at the end fails because mbed_tls is looking for certain TRNG related hardware functions that are not available - this is a whole separate topic worth discussing but...]

*** THIS ONLY HAPPENS WITH THE MAKEFILE DIRECTIVE ABOVE ***.. which makes no sense how its related to packet buffers .  IT DOES NOT HAPPEN on the CY8CKIT-062-WIFI-BT board because that MCU has the hardware TRNG.

MAYBE...

1) using '43907 software TRNG' we need to allocate more heap space or other memory in FreeRTOS config? 

Is there any 'lwip' *expert* who can explain this?

thanks

Mark

 

 

0 Likes
GrCa_1363456
Level 6
Level 6
50 likes received Beta tester First comment on KBA

Some of the TCP code examples are configured to utilize a hardware Crypto accelerator.

 

The code example provided uses cy-mbedtls-acceleration library ( https://github.com/Infineon/cy-mbedtls-acceleration ).  This library is dependent on a hardware crypto accelerator which does not exist on every PSoC 6 device. Check the Ordering Information table in the data sheet to determine which specific devices have “Crypto”.

 

The crypto hardware acceleration can be disabled by modifying the makefile and a header file as follows:

 

Modify the Makefile 

# Custom configuration of mbedtls library.

MBEDTLSFLAGS = MBEDTLS_USER_CONFIG_FILE='"mbedtls_user_config.h"'

 

# Add additional defines to the build process (without a leading -D).

DEFINES=$(MBEDTLSFLAGS) CYBSP_WIFI_CAPABLE CY_RETARGET_IO_CONVERT_LF_TO_CRLF CY_RTOS_AWARE DISABLE_MBEDTLS_ACCELERATION

 

Modify mbedtls_user_config.h in mtb_shared folder to disable the hardware entropy by commenting out the #define MBEDTLS_ENTROPY_HARDWARE_ALT

  

/**

* \def MBEDTLS_ENTROPY_HARDWARE_ALT

*

* Uncomment this macro to let mbed TLS use your own implementation of a

* hardware entropy collector.

*

* Your function must be called \c mbedtls_hardware_poll(), have the same

* prototype as declared in entropy_poll.h, and accept NULL as first argument.

*

* Uncomment to use your own hardware entropy collector.

*/

#define MBEDTLS_ENTROPY_HARDWARE_ALT

 

P.S. Thank you to Mark and Srini for confirming this fix and staying with the Infineon team while they resolved this issue.

Greg