2

我为 Tricore 控制器编写了一个 C 程序,编译后我收到以下错误消息,我实际上无法弄清楚。你能提供一些意见吗?

我可以猜测它与内存层次结构有关,但仍然无法找出实际问题。

Error Messages:
ltc I455:   requirement: 193K (0x304c8) bytes of RAM area in space spe:tc:linear
amk E451: make stopped
ltc I456:   section type: group restriction - clustered
ltc I457:   .bss.Pro2.group (60) (0x30140 bytes)
ltc I457:   .bss._dbg_request.libcs_fpu (418) (0x14 bytes)
ltc I457:   .bss.Pro2.rocount (61) (0x2d4 bytes)
ltc I457:   .bss.stdin_buf.libcs_fpu (273) (0x50 bytes)
ltc I457:   .bss.stdout_buf.libcs_fpu (274) (0x50 bytes)

代码 :

/*
 ============================================================================
 Name        : hough.c
 Author      :
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define M 4
#define N 4
#define PI 3.14159265
typedef struct point {
    int x;
    int y;
} point;
typedef struct points {
    point points[M * N];
    double ro;
    int pointCount;
} points;
int image[M][N] = { { 1, 1, 0, 1 }, { 1, 1, 0, 1 }, { 1, 1, 1, 1 },
        { 1, 0, 0, 0 } };
int i, j, k;

points group[181][M * N / 2];
int rocount[181];

int compare_float(double f1, double f2) {
    float precision = 0.000001;
    if (((f1 - precision) < f2) && ((f1 + precision) > f2)) {
        return 1;
    } else {
        return 0;
    }
}

void insert(double ro, int x, int y, int angle) {
    int loopcount;
    int roflag = 0;
    if (rocount[angle] == 0) {
        group[angle][rocount[angle]].ro = ro;
        group[angle][rocount[angle]].pointCount = 0;
        group[angle][rocount[angle]].points[group[angle][rocount[angle]].pointCount].x =
                x;
        group[angle][rocount[angle]].points[group[angle][rocount[angle]].pointCount].y =
                y;
        group[angle][rocount[angle]].pointCount++;
        rocount[angle]++;
    } else {
        for (loopcount = 0; loopcount < rocount[angle]; loopcount++) {
            if (compare_float(group[angle][loopcount].ro, ro)) {
                roflag = 1;

                group[angle][loopcount].points[group[angle][loopcount].pointCount].x =
                        x;
                group[angle][loopcount].points[group[angle][loopcount].pointCount].y =
                        y;
                group[angle][loopcount].pointCount++;
                break;
            }

        }
        if (roflag == 0) {
            group[angle][rocount[angle]].ro = ro;
            group[angle][rocount[angle]].pointCount = 0;
            group[angle][rocount[angle]].points[group[angle][rocount[angle]].pointCount].x =
                    x;
            group[angle][rocount[angle]].points[group[angle][rocount[angle]].pointCount].y =
                    y;

            group[angle][rocount[angle]].pointCount++;
            rocount[angle]++;
        }
    }
}

int main(void) {
    double ro;
    point x1;
    for (k = -90; k <= 90; k++) {
        rocount[k + 90];
        for (i = 0; i < M; i++) {
            for (j = 0; j < N; j++) {
                if (image[i][j] == 1) {
                    ro = (i + 1) * cos(k * (PI / 180))
                            + (j + 1) * sin(k * (PI / 180));
                    insert(ro, i + 1, j + 1, k + 90);

                }
            }
        }

    }
    for (k = -90; k <= 90; k++) {

        for (i = 0; i < rocount[k + 90]; i++) {
            printf("\n Angle :%d RO:%f \n", k, group[k + 90][i].ro);

            for (j = 0; j < group[k + 90][i].pointCount; j++) {
                printf("(x:%d,y:%d)", group[k + 90][i].points[j].x,
                        group[k + 90][i].points[j].y);
            }
        }
    }
    return EXIT_SUCCESS;
}

PS:代码是为TC1797微控制器编写的。

4

1 回答 1

1

I don't know the Tricore controller, but this looks like you've exceeded some limit. I assume this controller has very limited resources, and the build process checks that you didn't exceed them.

requirement: 193K (0x304c8) bytes of RAM area in space spe:tc:linear must mean you used 193K of something, which is too much.
.bss.Pro2.group (60) (0x30140 bytes) means most of this comes from a BSS section (i.e. static uninitialized variables).

I didn't do the math, but the size of points group[181][M * N / 2]; is probably the main issue.

于 2013-01-04T06:56:30.013 回答