This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Problems running an application, build and flashing without warnings. NRF9160-DK

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:

SPM: NS image at 0xc000
SPM: NS MSP at 0x200248f0
SPM: NS reset vector at 0xe159
SPM: prepare to jump to Non-Secure image.
***** Booting Zephyr OS v1.14.99-ncs2 *****
Flash region		Domain		Permissions
00 0x00000 0x08000 	Secure		rwxl
01 0x08000 0x10000 	Non-Secure	rwxl
02 0x10000 0x18000 	Non-Secure	rwxl
03 0x18000 0x20000 	Non-Secure	rwxl
04 0x20000 0x28000 	Non-Secure	rwxl
05 0x28000 0x30000 	Non-Secure	rwxl
06 0x30000 0x38000 	Non-Secure	rwxl
07 0x38000 0x40000 	Non-Secure	rwxl
08 0x40000 0x48000 	Non-Secure	rwxl
09 0x48000 0x50000 	Non-Secure	rwxl
10 0x50000 0x58000 	Non-Secure	rwxl
11 0x58000 0x60000 	Non-Secure	rwxl
12 0x60000 0x68000 	Non-Secure	rwxl
13 0x68000 0x70000 	Non-Secure	rwxl
14 0x70000 0x78000 	Non-Secure	rwxl
15 0x78000 0x80000 	Non-Secure	rwxl
16 0x80000 0x88000 	Non-Secure	rwxl
17 0x88000 0x90000 	Non-Secure	rwxl
18 0x90000 0x98000 	Non-Secure	rwxl
19 0x98000 0xa0000 	Non-Secure	rwxl
20 0xa0000 0xa8000 	Non-Secure	rwxl
21 0xa8000 0xb0000 	Non-Secure	rwxl
22 0xb0000 0xb8000 	Non-Secure	rwxl
23 0xb8000 0xc0000 	Non-Secure	rwxl
24 0xc0000 0xc8000 	Non-Secure	rwxl
25 0xc8000 0xd0000 	Non-Secure	rwxl
26 0xd0000 0xd8000 	Non-Secure	rwxl
27 0xd8000 0xe0000 	Non-Secure	rwxl
28 0xe0000 0xe8000 	Non-Secure	rwxl
29 0xe8000 0xf0000 	Non-Secure	rwxl
30 0xf0000 0xf8000 	Non-Secure	rwxl
31 0xf8000 0x100000 	Non-Secure	rwxl
Non-secure callable region 0 placed in flash region 0 with size 32.


SRAM region		Domain		Permissions
00 0x00000 0x02000	Secure		rwxl
01 0x02000 0x04000	Secure		rwxl
02 0x04000 0x06000	Secure		rwxl
03 0x06000 0x08000	Secure		rwxl
04 0x08000 0x0a000	Secure		rwxl
05 0x0a000 0x0c000	Secure		rwxl
06 0x0c000 0x0e000	Secure		rwxl
07 0x0e000 0x10000	Secure		rwxl
08 0x10000 0x12000	Non-Secure	rwxl
09 0x12000 0x14000	Non-Secure	rwxl
10 0x14000 0x16000	Non-Secure	rwxl
11 0x16000 0x18000	Non-Secure	rwxl
12 0x18000 0x1a000	Non-Secure	rwxl
13 0x1a000 0x1c000	Non-Secure	rwxl
14 0x1c000 0x1e000	Non-Secure	rwxl
15 0x1e000 0x20000	Non-Secure	rwxl
16 0x20000 0x22000	Non-Secure	rwxl
17 0x22000 0x24000	Non-Secure	rwxl
18 0x24000 0x26000	Non-Secure	rwxl
19 0x26000 0x28000	Non-Secure	rwxl
20 0x28000 0x2a000	Non-Secure	rwxl
21 0x2a000 0x2c000	Non-Secure	rwxl
22 0x2c000 0x2e000	Non-Secure	rwxl
23 0x2e000 0x30000	Non-Secure	rwxl
24 0x30000 0x32000	Non-Secure	rwxl
25 0x32000 0x34000	Non-Secure	rwxl
26 0x34000 0x36000	Non-Secure	rwxl
27 0x36000 0x38000	Non-Secure	rwxl
28 0x38000 0x3a000	Non-Secure	rwxl
29 0x3a000 0x3c000	Non-Secure	rwxl
30 0x3c000 0x3e000	Non-Secure	rwxl
31 0x3e000 0x40000	Non-Secure	rwxl

Peripheral		Domain		Status
00 NRF_P0		Non-Secure	OK
01 NRF_CLOCK		Non-Secure	OK
02 NRF_RTC1		Non-Secure	OK
03 NRF_NVMC		Non-Secure	OK
04 NRF_UARTE1		Non-Secure	OK
05 NRF_UARTE2		Secure		SKIP
06 NRF_TWIM2		Non-Secure	OK
07 NRF_SPIM3		Non-Secure	OK
08 NRF_TIMER0		Non-Secure	OK
09 NRF_TIMER1		Non-Secure	OK
10 NRF_TIMER2		Non-Secure	OK
11 NRF_SAADC		Non-Secure	OK
12 NRF_PWM0		Non-Secure	OK
13 NRF_PWM1		Non-Secure	OK
14 NRF_PWM2		Non-Secure	OK
15 NRF_PWM3		Non-Secure	OK
16 NRF_IPC		Non-Secure	OK
17 NRF_VMC		Non-Secure	OK
18 NRF_FPU		Non-Secure	OK
19 NRF_EGU1		Non-Secure	OK
20 NRF_EGU2		Non-Secure	OK
21 NRF_GPIOTE1		Non-Secure	OK

SPM: NS image at 0xc000
SPM: NS MSP at 0x200248f0
SPM: NS reset vector at 0xe159
SPM: prepare to jump to Non-Secure image.

I have tried with clean solution and reflashed it but it stays the same.

Is there any solution for this?

Kind regards 

Samuel

Parents
  • Hi,

     

    Does this happen on all applications that you try to flash? Have you tried at_client, and see if it behaves the same?

    Have you updated to the latest nRF5x command line tools? It can be downloaded here: https://www.nordicsemi.com/?sc_itemid=%7B56868165-9553-444D-AA57-15BDE1BF6B49%7D

     

    Kind regards,

    Håkon

  • Hi,

    No it is for a specific application. Other applications work fine including at_client. We have the latest nRF5x command line tools.

    This is the prj.conf file:

    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="10101010"
    #CONFIG_LTE_PSM_REQ_RAT="00000000"
    CONFIG_AT_HOST_LIBRARY=n

    And this is the main.c file:

    /*
     * Copyright (c) 2018 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
     */
    
    #include <zephyr.h>
    #include <net/socket.h>
    #include <stdio.h>
    #include <uart.h>
    #include <string.h>
    #include <lte_lc.h>
    
    #define HOST "52.20.16.20"
    //#define HOST "52.59.252.50"
    #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("AT send (%d bytes): %s\n", strlen(cmd), cmd);
    	len = send(fd, cmd, size, 0);
    	if (len != size) {
    		printk("***ERROR: AT send: failed, ret=%d.\n", len);
    		return -1;
    	}
    
    	for (int i=0; i<50; i++)		// wait for 5s
    	{
    		len = recv(fd, buffer, LC_MAX_READ_LENGTH1, MSG_DONTWAIT);
    		if (len > 0)
    		{
    			printk("AT receive (%d bytes): %s", strlen(buffer), buffer);
    			return 0;
    		} 
    		k_sleep(K_MSEC(100));
    	}
    	printk("**********AT receive ERROR.\n");
    	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 < 0 && 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 < 0 && 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 < 0 && 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 < 0 && 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 <= 0)
               return;
    	buffer[bytes] = 0;
    	printk("AT receive (%d bytes): %s", bytes, buffer);
            }
    }
    
    
    int main(void)
    {
    	printk("UDP echo running");
    
            // 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, "AT+CESQ", AT_CMD_SIZE1("AT+CESQ"));
            at_cmd1(at_socket_fd, "AT%CESQ=1", AT_CMD_SIZE1("AT%CESQ=1"));
            at_cmd1(at_socket_fd, "AT+CEREG?", AT_CMD_SIZE1("AT+CEREG?"));
            at_cmd1(at_socket_fd, "AT+CEREG=2", AT_CMD_SIZE1("AT+CEREG=2"));
            // LTE-M or NB-IoT?
            at_cmd1(at_socket_fd, "AT%XSYSTEMMODE=1,0,0,0", AT_CMD_SIZE1("AT%XSYSTEMMODE=0,1,0,0"));  // LTE-M
    //      at_cmd2(at_socket_fd, "AT%XSYSTEMMODE=0,1,0,0", AT_CMD_SIZE1("AT%XSYSTEMMODE=0,1,0,0"));  // NB-IoT
            at_cmd1(at_socket_fd, "AT%XSYSTEMMODE?", AT_CMD_SIZE1("AT%XSYSTEMMODE?"));
            
            // Make sure PSM is off
            at_cmd1(at_socket_fd, "AT+CPSMS=0", AT_CMD_SIZE1("AT+CPSMS=0"));
            at_cmd1(at_socket_fd, "AT+CPSMS?", AT_CMD_SIZE1("AT+CPSMS?"));
    	
    struct addrinfo *res;
    	socklen_t addrlen = sizeof(struct sockaddr_storage);
    
    	int err = getaddrinfo(HOST, NULL, NULL, &res);
    	if (err < 0) {
    		printk("getaddrinfo err: %d\n\r", err);
              
    		return;
    	}
    	((struct sockaddr_in *)res->ai_addr)->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 < 0) {
    		printk("client_fd: %d\n\r", client_fd);
    		
    	}
    
    	err = bind(client_fd, (struct sockaddr *)&local_addr,
    		   sizeof(local_addr));
    	if (err < 0) {
    		printk("bind err: %d errno: %d\n\r", err, errno);
    		
    	}
    
    	err = connect(client_fd, (struct sockaddr *)res->ai_addr,
    		      sizeof(struct sockaddr_in));
    	if (err < 0) {
    		printk("connect err: %d errno: %d\n\r", 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("sendto err: %d errno: %d\n\r", err, errno);
            }else{
                    printk("UDP send : (%d bytes): %s\n", len, message);
            }
            counter++;              
            
            err = blocking_recvfrom(client_fd, recv_buf, sizeof(recv_buf), 0,
    				(struct sockaddr *)res->ai_addr, &addrlen);
    	if (err < 0) {
    		printk("recvfrom err: %d errno: %d\n\r", err, errno);
    		
    	} else {
                    printk("UDP receive (%d bytes): %s\n", err, recv_buf);
            }
            k_sleep(K_MSEC(1000));	// delay 1s to reduce speed of transmissions
       }    
    }

    I don't know if the files i included helps with figuring out the problem but I might as well include them.

    Kind regards,

    Samuel

  • Could you try enabling serial, and see if it prints anything useful?

  • 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: 

    ***** Booting Zephyr OS v1.14.99-ncs2 *****

    to the application running at ~45 seconds.

    So I can run my applications but the delay seems very strange.

  • Sounds like the registration time to the network. Are you using a ibasis SIM? They can take a bit of time before registering properly.

     

    Kind regards,

    Håkon

  • Okay, that makes sense. We don't use the ibasis SIMs but I have noticed some long registration times in other applications so that is probably the problem.

    Thanks for your help

    Samuel

  • You could lock the band(s) using this AT command:

    https://infocenter.nordicsemi.com/topic/ref_at_commands/REF/at_commands/mob_termination_ctrl_status/xbandlock_set.html

     

    Note that it should be done prior to setting AT+CFUN=1.

     

    Cheers,

    Håkon

Reply Children
No Data
Related