<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Problems running an application, build and flashing without warnings. NRF9160-DK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/49849/problems-running-an-application-build-and-flashing-without-warnings-nrf9160-dk</link><description>Hi, 
 
 I have NCS v1.0.0 on an NRF9160-DK v.0.8.3 and I am trying to run a program written before the SDK update. I can build and flash the program but when I try running it this is what I get out: 
 
 
 
 I have tried with clean solution and reflashed</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 18 Jul 2019 09:46:22 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/49849/problems-running-an-application-build-and-flashing-without-warnings-nrf9160-dk" /><item><title>RE: Problems running an application, build and flashing without warnings. NRF9160-DK</title><link>https://devzone.nordicsemi.com/thread/199202?ContentTypeID=1</link><pubDate>Thu, 18 Jul 2019 09:46:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7deea9a9-bede-43e8-bd07-e00815e67cc0</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;You could lock the band(s) using this AT command:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ref_at_commands/REF/at_commands/mob_termination_ctrl_status/xbandlock_set.html"&gt;https://infocenter.nordicsemi.com/topic/ref_at_commands/REF/at_commands/mob_termination_ctrl_status/xbandlock_set.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Note that it should be done prior to setting AT+CFUN=1.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems running an application, build and flashing without warnings. NRF9160-DK</title><link>https://devzone.nordicsemi.com/thread/199190?ContentTypeID=1</link><pubDate>Thu, 18 Jul 2019 09:24:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a96723f2-acef-41a7-b1f9-70764352d47a</guid><dc:creator>Samuel</dc:creator><description>&lt;p&gt;Okay, that makes sense. We don&amp;#39;t use the ibasis SIMs but I have noticed some long registration times in other applications so that is probably the problem.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for your help&lt;/p&gt;
&lt;p&gt;Samuel&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems running an application, build and flashing without warnings. NRF9160-DK</title><link>https://devzone.nordicsemi.com/thread/198942?ContentTypeID=1</link><pubDate>Wed, 17 Jul 2019 11:27:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a7e9570a-5619-4363-a1cb-1bf422a8fba5</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Sounds like the registration time to the network. Are you using a ibasis SIM? They can take a bit of time before registering properly.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems running an application, build and flashing without warnings. NRF9160-DK</title><link>https://devzone.nordicsemi.com/thread/198883?ContentTypeID=1</link><pubDate>Wed, 17 Jul 2019 08:44:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d47e6c0d-7cf8-47ad-b797-b4ef7eb2c91b</guid><dc:creator>Samuel</dc:creator><description>&lt;p&gt;It does work now after I enabled serial and I can see the expected output, however the boot process is extremely slow I measured the time from:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;***** Booting Zephyr OS v1.14.99-ncs2 *****&lt;/p&gt;
&lt;p&gt;to the application running at ~45 seconds.&lt;/p&gt;
&lt;p&gt;So I can run my applications but the delay seems very strange.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems running an application, build and flashing without warnings. NRF9160-DK</title><link>https://devzone.nordicsemi.com/thread/198860?ContentTypeID=1</link><pubDate>Wed, 17 Jul 2019 07:04:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4479964d-30fb-4db8-941e-f61d499de9d3</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Could you try enabling serial, and see if it prints anything useful?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems running an application, build and flashing without warnings. NRF9160-DK</title><link>https://devzone.nordicsemi.com/thread/198855?ContentTypeID=1</link><pubDate>Wed, 17 Jul 2019 06:27:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b871650b-c0b1-400e-a4ba-9d076cec4392</guid><dc:creator>Samuel</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;No it is for a specific application. Other applications work fine including at_client. We have the latest nRF5x command line tools.&lt;/p&gt;
&lt;p&gt;This is the prj.conf file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_NEWLIB_LIBC=n
CONFIG_BSD_LIBRARY=y
#CONFIG_GPIO=n
CONFIG_SERIAL=n
CONFIG_STDOUT_CONSOLE=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NETWORKING=y
CONFIG_NET_BUF_USER_DATA_SIZE=1
CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_RAW_MODE=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_LTE_LEGACY_PCO_MODE=y
CONFIG_LTE_NETWORK_MODE_NBIOT=y
#CONFIG_LTE_NETWORK_MODE_LTE_M=y

# Main thread
CONFIG_MAIN_THREAD_PRIORITY=7
CONFIG_MAIN_STACK_SIZE=4096
#CONFIG_LTE_PSM_REQ_RPTAU=&amp;quot;10101010&amp;quot;
#CONFIG_LTE_PSM_REQ_RAT=&amp;quot;00000000&amp;quot;
CONFIG_AT_HOST_LIBRARY=n&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And this is the main.c file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2018 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
 */

#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;net/socket.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;uart.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;lte_lc.h&amp;gt;

#define HOST &amp;quot;52.20.16.20&amp;quot;
//#define HOST &amp;quot;52.59.252.50&amp;quot;
#define PORT 10000
#define RECV_BUF_SIZE 1024
#define SEND_BUF_SIZE 1024
#define AT_CMD_SIZE1(x) (sizeof(x) - 1)
#define LC_MAX_READ_LENGTH1 128

extern int errno;
u8_t recv_buf[RECV_BUF_SIZE];

static int at_cmd1(int fd, const char *cmd, size_t size)
{
	int len;
	u8_t buffer[LC_MAX_READ_LENGTH1];

	printk(&amp;quot;AT send (%d bytes): %s\n&amp;quot;, strlen(cmd), cmd);
	len = send(fd, cmd, size, 0);
	if (len != size) {
		printk(&amp;quot;***ERROR: AT send: failed, ret=%d.\n&amp;quot;, len);
		return -1;
	}

	for (int i=0; i&amp;lt;50; i++)		// wait for 5s
	{
		len = recv(fd, buffer, LC_MAX_READ_LENGTH1, MSG_DONTWAIT);
		if (len &amp;gt; 0)
		{
			printk(&amp;quot;AT receive (%d bytes): %s&amp;quot;, strlen(buffer), buffer);
			return 0;
		} 
		k_sleep(K_MSEC(100));
	}
	printk(&amp;quot;**********AT receive ERROR.\n&amp;quot;);
	return -1;
}


int blocking_recv(int fd, u8_t *buf, u32_t size, u32_t flags)
{
	int err;

	do {
		err = recv(fd, buf, size, flags);
	} while (err &amp;lt; 0 &amp;amp;&amp;amp; errno == EAGAIN);

	return err;
}

int blocking_recvfrom(int fd, void *buf, u32_t size, u32_t flags,
		      struct sockaddr *src_addr, socklen_t *addrlen)
{
	int err;

	do {
		err = recvfrom(fd, buf, size, flags, src_addr, addrlen);
	} while (err &amp;lt; 0 &amp;amp;&amp;amp; errno == EAGAIN);

	return err;
}

int blocking_send(int fd, u8_t *buf, u32_t size, u32_t flags)
{
	int err;

	do {
		err = send(fd, buf, size, flags);
	} while (err &amp;lt; 0 &amp;amp;&amp;amp; errno == EAGAIN);

	return err;
}

int blocking_connect(int fd, struct sockaddr *local_addr, socklen_t len)
{
	int err;

	do {
		err = connect(fd, local_addr, len);
	} while (err &amp;lt; 0 &amp;amp;&amp;amp; errno == EAGAIN);

	return err;
}

void at_read(int at_socket_fd)
{
    while(true)
    {
    u8_t buffer[LC_MAX_READ_LENGTH1];
    int bytes;
    bytes = recv(at_socket_fd, buffer, LC_MAX_READ_LENGTH1, MSG_DONTWAIT );
	if (bytes &amp;lt;= 0)
           return;
	buffer[bytes] = 0;
	printk(&amp;quot;AT receive (%d bytes): %s&amp;quot;, bytes, buffer);
        }
}


int main(void)
{
	printk(&amp;quot;UDP echo running&amp;quot;);

        // create AT socket
        int at_socket_fd;
	at_socket_fd = socket(AF_LTE, 0, NPROTO_AT);

        // Check rsrp level and subscrive to rsrp level changes, subscribe to unsolicited network information
        at_cmd1(at_socket_fd, &amp;quot;AT+CESQ&amp;quot;, AT_CMD_SIZE1(&amp;quot;AT+CESQ&amp;quot;));
        at_cmd1(at_socket_fd, &amp;quot;AT%CESQ=1&amp;quot;, AT_CMD_SIZE1(&amp;quot;AT%CESQ=1&amp;quot;));
        at_cmd1(at_socket_fd, &amp;quot;AT+CEREG?&amp;quot;, AT_CMD_SIZE1(&amp;quot;AT+CEREG?&amp;quot;));
        at_cmd1(at_socket_fd, &amp;quot;AT+CEREG=2&amp;quot;, AT_CMD_SIZE1(&amp;quot;AT+CEREG=2&amp;quot;));
        // LTE-M or NB-IoT?
        at_cmd1(at_socket_fd, &amp;quot;AT%XSYSTEMMODE=1,0,0,0&amp;quot;, AT_CMD_SIZE1(&amp;quot;AT%XSYSTEMMODE=0,1,0,0&amp;quot;));  // LTE-M
//      at_cmd2(at_socket_fd, &amp;quot;AT%XSYSTEMMODE=0,1,0,0&amp;quot;, AT_CMD_SIZE1(&amp;quot;AT%XSYSTEMMODE=0,1,0,0&amp;quot;));  // NB-IoT
        at_cmd1(at_socket_fd, &amp;quot;AT%XSYSTEMMODE?&amp;quot;, AT_CMD_SIZE1(&amp;quot;AT%XSYSTEMMODE?&amp;quot;));
        
        // Make sure PSM is off
        at_cmd1(at_socket_fd, &amp;quot;AT+CPSMS=0&amp;quot;, AT_CMD_SIZE1(&amp;quot;AT+CPSMS=0&amp;quot;));
        at_cmd1(at_socket_fd, &amp;quot;AT+CPSMS?&amp;quot;, AT_CMD_SIZE1(&amp;quot;AT+CPSMS?&amp;quot;));
	
struct addrinfo *res;
	socklen_t addrlen = sizeof(struct sockaddr_storage);

	int err = getaddrinfo(HOST, NULL, NULL, &amp;amp;res);
	if (err &amp;lt; 0) {
		printk(&amp;quot;getaddrinfo err: %d\n\r&amp;quot;, err);
          
		return;
	}
	((struct sockaddr_in *)res-&amp;gt;ai_addr)-&amp;gt;sin_port = htons(PORT);
	struct sockaddr_in local_addr;

	local_addr.sin_family = AF_INET;
	local_addr.sin_port = htons(0);
	local_addr.sin_addr.s_addr = 0;

	int client_fd = socket(AF_INET, SOCK_DGRAM, 0);
	if (client_fd &amp;lt; 0) {
		printk(&amp;quot;client_fd: %d\n\r&amp;quot;, client_fd);
		
	}

	err = bind(client_fd, (struct sockaddr *)&amp;amp;local_addr,
		   sizeof(local_addr));
	if (err &amp;lt; 0) {
		printk(&amp;quot;bind err: %d errno: %d\n\r&amp;quot;, err, errno);
		
	}

	err = connect(client_fd, (struct sockaddr *)res-&amp;gt;ai_addr,
		      sizeof(struct sockaddr_in));
	if (err &amp;lt; 0) {
		printk(&amp;quot;connect err: %d errno: %d\n\r&amp;quot;, err, errno);
		
	}
    
        int counter = 0;
        u8_t message[5];
        int len = sizeof(message);

	while (1) {
        at_read(at_socket_fd);
        itoa(counter,message,10);
            err = send(client_fd, message, sizeof(message), 0); // returns error or number of bytes sent.
	if (err != len) {
		printk(&amp;quot;sendto err: %d errno: %d\n\r&amp;quot;, err, errno);
        }else{
                printk(&amp;quot;UDP send : (%d bytes): %s\n&amp;quot;, len, message);
        }
        counter++;              
        
        err = blocking_recvfrom(client_fd, recv_buf, sizeof(recv_buf), 0,
				(struct sockaddr *)res-&amp;gt;ai_addr, &amp;amp;addrlen);
	if (err &amp;lt; 0) {
		printk(&amp;quot;recvfrom err: %d errno: %d\n\r&amp;quot;, err, errno);
		
	} else {
                printk(&amp;quot;UDP receive (%d bytes): %s\n&amp;quot;, err, recv_buf);
        }
        k_sleep(K_MSEC(1000));	// delay 1s to reduce speed of transmissions
   }    
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know if the files i included helps with figuring out the problem but I might as well include them.&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Samuel&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems running an application, build and flashing without warnings. NRF9160-DK</title><link>https://devzone.nordicsemi.com/thread/198675?ContentTypeID=1</link><pubDate>Tue, 16 Jul 2019 11:15:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0367c562-8452-4710-92ff-0f09c1287d7f</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Does this happen on all applications that you try to flash? Have you tried at_client, and see if it behaves the same?&lt;/p&gt;
&lt;p&gt;Have you updated to the latest nRF5x command line tools? It can be downloaded here:&amp;nbsp;&lt;a href="https://www.nordicsemi.com/?sc_itemid=%7B56868165-9553-444D-AA57-15BDE1BF6B49%7D"&gt;https://www.nordicsemi.com/?sc_itemid=%7B56868165-9553-444D-AA57-15BDE1BF6B49%7D&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>