This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

FTP client callback overflow?

Hi Nordic!

I'm using the nrf ftp client library found here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/networking/ftp_client.html

I'm having problem with one specific line of code, which is this

ctrl_buf[ret] = 0x00;
	if (post_result) {
		client.ctrl_callback(ctrl_buf, ret);
	}



I get a cpu fault and the device reboots. The ctrl_buf has a predefined size of 708 and it is on the line client.ctrl_callback(ctrl_buf, ret); that the reboot happens.
If I comment this part out, I can open a connection to my ftp server, I can log in and I can change file names so the connection is true. I can not use put as I get -116 connection timed out after trying for some seconds.

I'm thinking that this line can't be commented out for the ftp client to work as it should and something might be lacking from my prj.conf or similar but I do not know what.
The ftp connection is a passive one without TLS so it should work with the library.

I'll post my prj.conf and hopefully, this is just a case of needing to allocate stack to the ftp client in some manner.

CONFIG_NEWLIB_LIBC=y
CONFIG_GPIO=n
CONFIG_SERIAL=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_NETWORKING=y
CONFIG_NET_BUF_USER_DATA_SIZE=1000
CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_TRUSTED_EXECUTION_NONSECURE=y
CONFIG_LOG=n
CONFIG_LOG_DEFAULT_LEVEL=4
CONFIG_HEAP_MEM_POOL_SIZE=1024

# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_FTP_CLIENT=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=y

# General config
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_NCS_SAMPLES_DEFAULTS=y

# Network
CONFIG_NETWORKING=y
CONFIG_NET_NATIVE=n
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_OFFLOAD=y

# LTE link control
CONFIG_LTE_LINK_CONTROL=y

# Modem library
CONFIG_NRF_MODEM_LIB=y


Thank you for reading

  • Hello Niclas,

    I’ll try to reproduce this error and see if I can find the reason / root cause for the fatal error you are facing. I’ll keep you posted.

    Regards,

    Markus

  • Hello again Niclas,

    I'm having problem with one specific line of code, which is this

    As this code snippet is called from several functions in the library, during which step are you facing the fatal error?

    I have tested the API myself now in NCS v1.9.0 using mfw 1.3.1 and everything appears to work fine so far. See log below:

    *** Booting Zephyr OS build v2.7.99-ncs1  ***
    Set up button at GPIO_0 pin 6
    AT+CEREG=5
    Modem response:
    OK
    AT%CESQ=1
    Modem response:
    OK
    AT+CFUN=1
    Modem response:
    OK
    AT notification received: %CESQ: 47,2,9,1
    
    AT notification received: +CEREG: 2,"76C1","03106F00",7
    
    AT notification received: +CEREG: 1,"76C1","03106F00",7,,,"00001010","11000001"
    
    220 Welcome to the DLP Test FTP Server
    200 Always in UTF8 mode.
    331 Please specify the password.
    230 Login successful.
    215 UNIX Type: L8
    211-FTP server status:
         Connected to 77.16.77.252
         Logged in as dlpuser
         TYPE: ASCII
         No session bandwidth limit
         Session timeout in seconds is 600
         Control connection is plain text
         Data connections will be plain text
         At session startup, client count was 65
         vsFTPd 3.0.2 - secure, fast, stable
    211 End of status
    221 Goodbye.
    AT notification received: %CESQ: 49,2,15,2
    
    AT notification received: %CESQ: 255,0,255,0

    The FTP part of my code looks like this:

    	ret = ftp_init(ftp_ctrl_callback, ftp_data_callback);
    	if(ret) {
    		printk("FTP Client initialisation failed: %d\n", ret);
    	}
    	
    	/* Modem initialisation and connecting to network */
    	
    	ret = ftp_open("ftp.dlptest.com", 21, -1);
    	/* Positive values are FTP response codes */
    	if(ret < 0){
    		printk("Failed to open a FTP connection: %d\n", ret);
    	}	
    
    	/* Wait for answer from server */
    	k_sem_take(&my_sem, K_FOREVER);
    
    	ret = ftp_login("dlpuser","rNrKYTX9g7z3RgJRmxWuGHbeu");
    	if(ret < 0){
    		printk("Login to FTP server failed: %d\n", ret);
    	}	
    
    	/* Wait for answer from server */
    	k_sem_take(&my_sem, K_FOREVER);
    
    	ret = ftp_status();
    	if(ret < 0){
    		printk("Requesting server status failed: %d\n", ret);
    	}	
    
    	/* Wait for answer from server */
    	k_sem_take(&my_sem, K_FOREVER);	
    
    	ret = ftp_close();
    	if(ret < 0){
    		printk("Disconnecting from server failed: %d\n", ret);
    	}	
    
    	/* Wait for answer from server */
    	k_sem_take(&my_sem, K_FOREVER);		

    With ctrl and data callback defined as following:

    void ftp_ctrl_callback(const uint8_t *msg, uint16_t len)
    {
    	printk("%s",msg);
    	/* Release semaphore when receiving answer from server */
    	k_sem_give(&my_sem);
    }
    
    void ftp_data_callback(const uint8_t *msg, uint16_t len)
    {
    	printk("%s",msg);
    }

    prj.conf:

    # General configurations
    CONFIG_PRINTK=y
    CONFIG_HEAP_MEM_POOL_SIZE=256
    CONFIG_ASSERT=y
    CONFIG_GPIO=y
    CONFIG_NEWLIB_LIBC=y
    
    # Modem library
    CONFIG_NRF_MODEM_LIB=y
    CONFIG_NRF_MODEM_LIB_SYS_INIT=y
    
    # FTP Client
    CONFIG_FTP_CLIENT=y
    
    # Network
    CONFIG_NETWORKING=y
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_NATIVE=n

    Regards,

    Markus

  • Dear Markus, it worked well, I had declared the callbacks wrong. Thank you very much for your time. Your code could be used as a nice example for the FTP-client if there are any more noobs in here.

    Have a great day!

Related