首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

请教一个C语言应用工程编译错误问题?

请教一个C语言应用工程编译错误问题?

我自定义了一个外设后,将该外设添加到NiosII系统中,之后编写了一个测试外设的应用程序,build project 后提示如下错误信息,请高人指教:

1. 该信息是否是说ROM和RAM空间不足,无法完全存储程序和数据代码?

2. 如果是存储空间不足,为什么很简单的一个测试程序会占用那么多空间?

编译器提示错误信息如下:

**** Build of configuration Debug for project hello_pwm ****

make -s all
Compiling hello_altera_avalon_pwm.c...
Linking hello_pwm.elf...
/cygdrive/d/Altera/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/../../../../nios2-elf/bin/ld: region onchip_rom is full (hello_pwm.elf section .text). Region needs to be 44832 bytes larger.
/cygdrive/d/Altera/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/../../../../nios2-elf/bin/ld: region onchip_ram is full (hello_pwm.elf section .rodata). Region needs to be 1216 bytes larger.
/cygdrive/d/Altera/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/../../../../nios2-elf/bin/ld: region onchip_ram is full (hello_pwm.elf section .rwdata). Region needs to be 5708 bytes larger.
/cygdrive/d/Altera/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/../../../../nios2-elf/bin/ld: address 0xe1ec of hello_pwm.elf section .onchip_rom is not within region onchip_rom
/cygdrive/d/Altera/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/../../../../nios2-elf/bin/ld: section .bss [00001020 -> 00001233] overlaps section .text [00000820 -> 0000bf1f]
/cygdrive/d/Altera/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/../../../../nios2-elf/lib/mno-hw-mul/libc.a(sbrkr.o)(.text+0x14): In function `_sbrk_r':
/build/nios2/bin/nios2-gnutools/src/newlib/newlib/libc/reent/sbrkr.c:59: Unable to reach errno (at 0x00001020) from the global pointer (at 0x0000a9e0) because the offset (-39360) is out of the allowed range, -32678 to 32767.

collect2: ld returned 1 exit status
make: *** [hello_pwm.elf] Error 1
Build completed in 6.359 seconds

测试程序v代码如下:

//Includes
#include "altera_avalon_pwm_regs.h"
#include "altera_avalon_pwm_routines.h"
#include "system.h"
#include <stdio.h>
//Function Protypes
void print_error(unsigned int address, int return_code);
void check_return_code(unsigned int address, int return_code);

int main(void)

{

unsigned int duty_cycle;
int return_code = ALTERA_AVALON_PWM_OK;

printf("Hello from the PWM test program.\n");
printf("The starting values in the PWM registers are:\n");
printf("Period = %u\n", IORD_ALTERA_AVALON_PWM_CLOCK_DIVIDER(Z_PWM_0_BASE) );
printf("Duty cycle = %u\n", IORD_ALTERA_AVALON_PWM_DUTY_CYCLE(Z_PWM_0_BASE) );

printf("\nNotice the pulsing LED on the development board.\n");

//Initialize PWM and Check Return Code
return_code = altera_avalon_pwm_init(Z_PWM_0_BASE, 500000, 1);
check_return_code(Z_PWM_0_BASE, return_code);

//Enable PWM and Check Return Code
return_code = altera_avalon_pwm_enable(Z_PWM_0_BASE);
check_return_code(Z_PWM_0_BASE, return_code);

//init duty_cycle with the value written to duty_cycle register during initialization
duty_cycle = IORD_ALTERA_AVALON_PWM_DUTY_CYCLE(Z_PWM_0_BASE);


while(1)
{
while(duty_cycle++ < IORD_ALTERA_AVALON_PWM_CLOCK_DIVIDER(Z_PWM_0_BASE))
{
return_code = altera_avalon_pwm_change_duty_cycle(Z_PWM_0_BASE, duty_cycle);
check_return_code(Z_PWM_0_BASE, return_code);
}
while(--duty_cycle > 1)
altera_avalon_pwm_change_duty_cycle(Z_PWM_0_BASE, duty_cycle);
check_return_code(Z_PWM_0_BASE, return_code);
}
return 0;
}

void check_return_code(unsigned int address, int return_code)
{
if(return_code != ALTERA_AVALON_PWM_OK)
print_error(address, return_code);
}

void print_error(unsigned int address, int return_code)
{
printf("Program Terminated Due to an error with Avalon PWM located at 0x%x:\n", address);
switch(return_code)
{
case ALTERA_AVALON_PWM_DUTY_CYCLE_GREATER_THAN_CLOCK_CYCLE_ERROR:
printf("The value in the clock cycle register must be greater than the value in the duty cycle register\n");
printf("Value in the Clock Divide Register: 0x%x\n", IORD_ALTERA_AVALON_PWM_CLOCK_DIVIDER(address));
printf("Value in the Duty Cycle Register: 0x%x\n", IORD_ALTERA_AVALON_PWM_DUTY_CYCLE(address));
break;
case ALTERA_AVALON_PWM_ENABLED_CONFIRMATION_ERROR:
printf("Unable to confirm that the PWM is enabled\n");
printf("Value in the Enable Register: 0x%x\n", IORD_ALTERA_AVALON_PWM_ENABLE(address));
break;
case ALTERA_AVALON_PWM_DISABLED_CONFIRMATION_ERROR:
printf("Unable to confirm that the PWM is disabled\n");
printf("Value in the Enable Register: 0x%x\n", IORD_ALTERA_AVALON_PWM_ENABLE(address));
break;
default:
break;
}

while(1);
}
// end of file

Region needs to be 44832 bytes larger,

是的,就是楼主指定的存储器不够,楼主可以选择很小的模板试试就知道了,比如使用hello_world_small这样的小模板。

楼主在设定reset地址的时候应该选flash的地址,exception地址的时候选择ram的地址就可以了。

这个版主不太冷 =========================== 我的中电网博客:http://blog.chinaecnet.com/u/20/index.htm
返回列表