This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/CC2650: ROV ERRORs - Need interpreting

Part Number: CC2650


Tool/software: TI-RTOS

Hello.

Can someone interpret and explain these errors for me? Thanks [I have included my main() and custom linked list library, along with a photo of the errors)

Caught exception in view init code: "C:/ti/xdctools_3_32_01_22_core/packages/xdc/rov/StructureDecoder.xs", line 518: java.lang.Exception: Target memory read failed at address: 0x20004628, length: 8This read is at an INVALID address according to the application's section map. The application is likely either uninitialized or corrupt.

Error fetching Queue Elem struct: JavaException: java.lang.Exception: Target memory read failed at address: 0x20004628, length: 8This read is at an INVALID address according to the application's section map. The application is likely either uninitialized or corrupt.

Error: Problem scanning pend Queue: JavaException: java.lang.Exception: Target memory read failed at address: 0xbebebebe, length: 8This read is at an INVALID address according to the application's section map. The application is likely either uninitialized or corrupt. [error occurs 3 times]

int main(void)
{
    Task_Params serial_params;
    Task_Params algo_params;
    Task_Params lidar_params;

	Semaphore_Params semParams;

    /* Call board init functions */
    Board_initGeneral();
    Board_initUART();

    /* Construct read/write Task thread */
    Task_Params_init(&serial_params);
    serial_params.stackSize = SERIALSTACK;
    serial_params.stack = &serial_task_0;
    serial_params.priority = 1;
    Task_construct(&serial_task_Struct, (Task_FuncPtr)read_write, &serial_params, NULL);

    /* Construct test Task thread */
    Task_Params_init(&algo_params);
    algo_params.stackSize = CYCSTACK;
    algo_params.stack = &algo_task_1;
    algo_params.priority = 2;
    Task_construct(&algo_task_Struct, (Task_FuncPtr)cyc_algo, &algo_params, NULL);

    /* Construct lidar Task thread */
    Task_Params_init(&lidar_params);
    lidar_params.stackSize = LIDARSTACK;
    lidar_params.stack = &lidar_task_2;
    lidar_params.priority = 3;
    Task_construct(&lidar_task_Struct, (Task_FuncPtr)lidar_task, &lidar_params, NULL);

	/* Construct a Semaphore object to be use as a resource lock, inital count 1 */
	Semaphore_Params_init(&semParams);
	semParams.mode = Semaphore_Mode_BINARY;
	Semaphore_construct(&semStruct, 0, &semParams);

	/* Obtain instance handle */
	semHandle = Semaphore_handle(&semStruct);

	/* Declare and define the heap */
	char buf[2560]; // IN MAU, in CC2650 this is in BYTES

	Error_init(&eb);
	HeapBuf_Params_init(&params);
	params.blockSize = 16; // 16 MAUs = 16 bytes per block
	params.numBlocks = 160; // 160 blocks (16 bytes/block * 160 blocks= 2560 bytes)
	params.buf = (Ptr)buf; // Stores buffer as a character array of bytes
	params.bufSize = 2560; // Number of bytes contained within buffer
	heap_buff = HeapBuf_create(&params, &eb); // Sets all properties for the heap handle
	heap = HeapBuf_Handle_upCast(heap_buff);

    System_printf("Starting BIOS\n");
    /* SysMin will only print to the console when you call flush or exit */
    System_flush();

    init_sens_structs();

    /* Start BIOS */
    BIOS_start();

    return (0);
}

/*
 * l_list.c
 *
 *  Created on: May 8, 2017
 *      Author: aandre24
 */
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>

#include <xdc/runtime/IHeap.h>
#include <ti/sysbios/heaps/HeapBuf.h>
#include <xdc/runtime/Memory.h>
#include <xdc/runtime/Error.h>

#define MAX_SIZE 75 // maximum size of list

IHeap_Handle heap;
Memory_Stats heapStats;
Error_Block eb;

/*
 * Creates the Heap_Buf
 */

/*
 * These structs should be private (user should not be able to create them)
 *	Since they are not defined in header file, they cannot be created by user
 */

int blocksize = 16;

// holds a single data stamp
struct data {
	long time;
	long dist;
	struct data *next;
};


// holds the linked list of a single sensor
struct sensor {
	struct data *head;
	struct data *tail;
	int size;
};

#define DATA_STRUCT_SIZE sizeof(struct sensor)

int get_struct_size() {
	return DATA_STRUCT_SIZE;
}

// Defines the two linked lists, one per sensor
static struct sensor *s1 = NULL;
static struct sensor *s2 = NULL;

// Initializes memory for both sensors
_Bool init_sens_structs() {
	/*
	 * Creates a memory location for both sensor pointers
	 * Can also incorporate an exit(0) to force quit
	 */

	// Can be removed when in working order
	System_printf("PRE_INIT:\n\tPointing addr s1: %x s2: %x\n", s1, s2);
	System_flush();

	s1 = Memory_alloc(heap, blocksize, 0, &eb);

	if (!s1) // malloc failed
	{
		System_printf("Could not initialize sensor 1"); // can be removed later
		System_flush();
		return 0;
	}

	s1->head = NULL;
	s1->tail = NULL;
	s1->size = 0;

	s2 = Memory_alloc(heap, blocksize, 0, &eb);

	if (!s2)
	{
		System_printf("Could not initialize sensor 2"); // can be removed later
		System_flush();
		return 0;
	}

	s2->head = NULL;
	s2->tail = NULL;
	s2->size = 0;

	System_printf("POST_INIT:\n\tPointing addr s1: %x s2: %x\n", s1, s2);
	System_flush();

	return 1;
}

// Returns the size of the linked list (how many elements left to be read)
int get_size_1() {
	return s1->size;
}

int get_size_2() {
	return s2->size;
}

// Adds a piece of data to the desired linked list via parameters
// Returns 0 if the memory allocation was unsuccessful, or exceeded maximum size
_Bool add_1(long time, long dist) {

	if (s1->size == MAX_SIZE) // List has reached pre-defined maximum size
	{
		System_printf("Maximum size %d reached, no more adding\n", s1->size);
		System_flush();
		return 0;
	}

	if (!s1->head && !s1->tail) // head and tail point to null
	{
		// Allocates memory for linked list
		s1->head = Memory_alloc(heap, blocksize, 0, &eb);

		if (!s1->head) { // Malloc failed
			return 0;
		}

		// Assigns values to current data object
		s1->head->time = time;
		s1->head->dist = dist;
		s1->head->next = NULL;

		s1->tail = s1->head; // Tail points to head

		s1->size++; // increment size

		return 1; // Malloc was successful

	} else { // there is at least 1 data in list

		// Allocates memory for next data
		s1->tail->next = Memory_alloc(heap, blocksize, 0, &eb);

		if (!s1->tail->next) { // Malloc failed
			return 0;
		}

		// Moves tail to end of list
		s1->tail = s1->tail->next;

		// Assigns values to current data object
		s1->tail->time = time;
		s1->tail->dist = dist;
		s1->tail->next = NULL;

		s1->size++; // increment size

		return 1;
	}
}

_Bool add_2(long time, long dist) {

	if (s2->size == MAX_SIZE) // List has reached pre-defined maximum size
	{
		System_printf("Maximum size %d reached, no more adding\n", s2->size);
		System_flush();
		return 0;
	}

	if (!s2->head && !s2->tail) // head and tail point to null
		{
			// Allocates memory for linked list
			s2->head = Memory_alloc(heap, blocksize, 0, &eb);

			if (!s2->head) { // Malloc failed
				return 0;
			}

			// Assigns values to current data object
			s2->head->time = time;
			s2->head->dist = dist;
			s2->head->next = NULL;

			s2->tail = s2->head; // Tail points to head

			s2->size++; // increment size

			return 1; // Malloc was successful

		} else { // there is at least 1 data in list

			// Allocates memory for next data
			s2->tail->next = Memory_alloc(heap, blocksize, 0, &eb);

			if (!s2->tail->next) { // Malloc failed
				return 0;
			}

			// Moves tail to end of list
			s2->tail = s2->tail->next;

			// Assigns values to current data object
			s2->tail->time = time;
			s2->tail->dist = dist;
			s2->tail->next = NULL;

			s2->size++; // increment size

			return 1;
		}
}

void print_list(int s) {
	/*
	 * Prints all elements in either sensor 1 or 2
	 */

	// Holds a temporary pointer to the start of list
	struct data *temp = NULL;

	// Assigns temp to point to start of list 1 or 2
	if (s == 1)
		temp = s1->head;
	else if (s == 2)
		temp = s2->head;
	else
		return;
	// Iterates and prints list until it is null
	while (temp) {
		System_printf("Sensor: %i Time: %i Dist: %i\n", s, temp->time, temp->dist);
		temp = temp->next;
	}
	System_flush();

	return;
}

_Bool rm_1(long *time, long *dist) {
	/*
	 * Function stores the next values of time and dist
	 * inside the pass-by-pointer values.
	 *
	 * It also removes and frees the memory allocated for the
	 * data being pointed to by head
	 *
	 * These values should only be considered with a return value
	 * of 1.
	 */

	if (!s1->head && !s1->tail) // sensor has no values ready
	{
		return 0; // Should always check this value before using values
	}
	else { // There is available data for reading
		struct data *temp = s1->head; // temp points to current head
		s1->head = s1->head->next; // head is moved to next data (or null)

		// Data is filled
		*time = temp->time;
		*dist = temp->dist;

		// Erase possible memory leak
		temp->next = NULL;

		// Free the memory pointed to by temp
		Memory_free(heap, (Ptr)temp, blocksize);

		// If list is empty, set tail to point to head (NULL)
		if (!s1->head) s1->tail = s1->head; // For list with only 1 item reduced to zero

		s1->size--; // Decrement size

		return 1;
	}
}

_Bool rm_2(long *time, long *dist) {
	/* Function stores the next values of time and dist
	 * inside the pass-by-pointer values.
	 *
	 * It also removes and frees the memory allocated for the
	 * data being pointed to by head
	 *
	 * These values should only be considered with a return value
	 * of 1.
	 */

	if (!s2->head && !s2->tail) // sensor has no values ready
	{
		return 0; // Should always check this value before using values
	}
	else { // There is available data for reading
		struct data *temp = s2->head; // temp points to current head
		s2->head = s2->head->next; // head is moved to next data (or null)

		// Data is filled
		*time = temp->time;
		*dist = temp->dist;

		// Erase possible memory leak
		temp->next = NULL;

		// Free the memory pointed to by temp
		Memory_free(heap, (Ptr)temp, blocksize);

		// If list is empty, set tail to point to head (NULL)
		if (!s2->head) s2->tail = s2->head; // For list with only 1 item reduced to zero

		s2->size--; // Decrement size

		return 1;
	}
}

void show_heap_stats()
{
	Memory_getStats(heap, &heapStats);
	System_printf("Total Size: %d Total Free: %d Largest Free: %d\n", heapStats.totalSize, heapStats.totalFreeSize, heapStats.largestFreeSize);
	System_flush();
}

void show_size_stats()
{
	System_printf("Size of data: %d\n Size of lList: %d\n", sizeof(struct sensor), sizeof(struct data));
	System_flush();
}