您的位置:首页 > 移动开发 > IOS开发

nios II程序兼容性问题

2012-08-08 16:53 309 查看
这两天新装了Quartus II 11.1和Nios II 11.1,安装成功后尝试着跑了一下Altera的一个例程,硬件部分没有问题,只是在SOPC中提示版本不同,原本代码是9.1版本的,现在用11.1版本的软件来跑,所以要将所有的硬件、软件重新跑一遍。到了Nios II部分后,问题出现了。编译到一半的时候老是会出现*.exe: *** fatal error - couldn't allocate heap, Win32 error之类的错误,后来在网上搜了一下,得知是兼容性问题。下面是网上搜到的相关资料,提供的方法有几个,但我只尝试了一个,就是更改Cygwin 程序分配的内存,操作如下:在开始菜单中打开cmd命令,输入“d: 回车”,转到软件的安装目录所在的硬盘下,再输入“cd D:\altera\11.1\quartus\bin\cygwin\bin 回车”,来到regtool.exe所在的目录。然后“regtool -i set /HKLM/Software/Cygnus\ Solutions/Cygwin/heap_chunk_in_mb 1024 回车”,“regtool -v list /HKLM/Software/Cygnus\ Solutions/Cygwin 回车”。关闭cmd。回到Nios II重新编译,这次没有error了!!!

下文转自:http://blog.sina.com.cn/s/blog_86a00bb90100ykaf.html

我的quartus nios版本均为9.1SP1,这几日NIOS II 编译时会出现以下类似错误让我疼痛了好久,比如:

4 [main] ? (6340) d:\altera\91\nios2eds\bin\nios2-gnutools\H-i686-pc-cygwin\bin\nios2-elf-gcc.exe: *** fatal error - couldn't allocate heap, Win32 error 487, base 0x660000, top 0x680000, reserve_size 126976, allocsize 131072, page_const 4096 4 [main] nios2-elf-gcc 4328 fork: child -1 - died waiting for longjmp before initialization, retry 0, exit code 0x100, errno 11

make -s all includes 3 [main] ? (3732) c:\altera\91\quartus\bin\cygwin\bin\make.exe: ***fatalerror- couldn'tallocateheap, Win32error487, base 0x9E0000, top 0xB30000, reserve_size 1372160, allocsize 1376256, page_const 4096 2 [main] make 7588 fork: child -1 - died waiting for longjmp before initialization, retry 0, exit code 0x100, errno 11 make: vfork: Resource temporarily unavailable

make -s all includes 3 [main] ? (4980) c:\altera\91\quartus\bin\cygwin\bin\make.exe: ***fatalerror- couldn'tallocateheap, Win32error487, base 0x970000, top 0xA40000, reserve_size 847872, allocsize 851968, page_const 4096 2 [main] make 1972 fork: child -1 - died waiting for longjmp before initialization, retry 0, exit code 0x100, errno 11 make[1]: /cygdrive/c/altera/91/nios2eds/components/altera_hal/build/common.mk:54: fork: Resource temporarily unavailable Build completed in 40.947 seconds
网上大致有两种方案,这里给出连接,大家可以根据自己的实际情况使用。

1、 http://blog.sina.com.cn/s/blog_49ad960501000aqk.html(见下面附录1)

核心:
Cygwin 程序缺省可以分配的内存不超过384 MB(program+data)。多数情况下不需要修改这个限制。然而,如果需要更多实际或虚拟内存,应该修改注册表的 HKEY_LOCAL_MACHINE或HKEY_CURRENT_USER区段。田家一个DWORD键heap_chunk_in_mb并把它的值设为 需要的内存限制,单位是十进制MB。也可以用cygwin中的regtool完成该设置。例子如下: regtool -i set /HKLM/Software/Cygnus\ Solutions/Cygwin/heap_chunk_in_mb 1024 regtool -v list /HKLM/Software/Cygnus\ Solutions/Cygwin
2、http://www.cnblogs.com/xitian/archive/2011/08/06/2129291.html(见下面附录2)
核心:修改Quartus II->bin->cygwin->bin->perl.exe的兼容性
这两种方案我都实验过了,
第1种方案直接用regtool根本无法操作,因为程序打开以后就自动关闭了,而在注册表里面添加heap_chunk_in_mb,倒是可以操作,但是效果不佳,问题依然存在。
第2种方案,是可以的,但经过我的试验觉得比较片面。在Quartus II的bin有很多应用程序,因为在编译时任何一个都有可能出现那一种情况。
我的解决办法是这样的:
如果有错,先看路径,比如 c:\altera\91\quartus\bin\cygwin\bin\make.exe ***fatalerror- couldn'tallocateheap。
那么就将相应的修改目录下的make.exe的兼容性,改为windowsSP2或者windowsSP3

再比如 d:\altera\91\nios2eds\bin\nios2-gnutools\H-i686-pc-cygwin\bin\nios2-elf-gcc.exe: *** fatal error - couldn't allocate heap

则将目录下的nios2-elf-gcc.exe的兼容性,改为windowsSP2或者windowsSP3。

这样我最终解决了自己的问题,并且屡试不爽。

附录1:

最近在编译一些较大的软件包时经常会出现一些couldn't allocate heap的错误,一会是gcc.exe,一会是make.exe,一会是bash...不过我发现这些错误通常只有重复执行make多几次,最终都会通过.

我猜想这可能是因为heap size设置太小的原因造成的. 而多重复几次可以成功的原因是因为这个makefile牵涉到许多次的编译以及链接工作,而其中的heap没有得到很好的释放,结果积累下来就超过了所设置的heap大小.而重复执行时,之前在heap size没超过之前编译成功的文件已不需要继续编译或链接,这样不再占用heap size,从而可以继续编译以下的内容,所以等效来看只是将一个需要大heap的工作分解成几个占用小heap的工作.但是当单个不再可分解的工作所需的heap size就超过了限制估计是无法通过这种方法来解决的.

那如何能够增加cygwin的heap尺寸呢?
尝试1:
Cygwin 程序缺省可以分配的内存不超过384 MB(program+data)。多数情况下不需要修改这个限制。然而,如果需要更多实际或虚拟内存,应该修改注册表的 HKEY_LOCAL_MACHINE或HKEY_CURRENT_USER区段。田家一个DWORD键heap_chunk_in_mb并把它的值设为 需要的内存限制,单位是十进制MB。也可以用cygwin中的regtool完成该设置。例子如下: regtool -i set /HKLM/Software/Cygnus\ Solutions/Cygwin/heap_chunk_in_mb 1024 regtool -v list /HKLM/Software/Cygnus\ Solutions/Cygwin

附录2:

(转)Nios ii 中奇怪的报错(系统兼容性相关)

关键之处是把相应的编译软件改为与XP SP3或SP2的兼容模式,以管理员的模式运行即可

I am sharing my personal experience here. I have been using Quartus II 9.1 and NIOS II IDE 9.1 on Windows 7 since they were released. Now, I am using Quartus II 9.1 SP2 and NIOS II IDE 9.1 SP2.

A lot of users were asking questions the compatibility of these softwares on Windows 7. Quartus II 9.1 and its SOPC builder seem to work fine on Windows 7 since the first day they are installed.
It is the NIOS II IDE 9.1 that really bothered me. Most of the time when you build a project, it will report error messages like two examples below. The success rate is only 20%.
Example 1: make -s all includes 3 [main] ? (3732) c:\altera\91\quartus\bin\cygwin\bin\make.exe: ***fatal error - couldn't allocate heap, Win32 error487, base 0x9E0000, top 0xB30000, reserve_size 1372160, allocsize 1376256, page_const 4096 2 [main] make 7588 fork: child -1 - died waiting for longjmp before initialization, retry 0, exit code 0x100, errno 11 make: vfork: Resource temporarily unavailable Example 2: make -s all includes 3 [main] ? (4980) c:\altera\91\quartus\bin\cygwin\bin\make.exe: ***fatal error - couldn't allocate heap, Win32 error 487, base 0x970000, top 0xA40000, reserve_size 847872, allocsize 851968, page_const 4096 2 [main] make 1972 fork: child -1 - died waiting for longjmp before initialization, retry 0, exit code 0x100, errno 11 make[1]: /cygdrive/c/altera/91/nios2eds/components/altera_hal/build/common.mk:54: fork: Resource temporarily unavailable 3 [main] ? (6092) c:\altera\91\quartus\bin\cygwin\bin\make.exe: ***fatal error - couldn't allocate heap, Win32 error 487, base 0x970000, top 0xA60000, reserve_size 978944, allocsize 983040, page_const 4096 8408744 [main] make 1972 fork: child -1 - died waiting for longjmp before initialization, retry 0, exit code 0x100, errno 11 make[1]: /cygdrive/c/altera/91/nios2eds/components/altera_hal/build/chac_rules.mk:147: fork: Resource temporarily unavailable make[1]: *** No rule to make target `/bin/gtf/generated_all.mk.gtf', needed by `system_description/../obj/generated_all.mk-t'. Stop. make: *** [system_project] Error 2 Build completed in 40.947 seconds
Some says it is related to the Norton Antivirus software. Yes, my PC is installed with Norton Antivirus software. But I observed that it happened to Windows 7 PC which is not installed with Norton Antivirus software, as well. Turning off the Norton Antivirus software does slightly help to increase the probability that the project is successfully built, from 20% to about 40%.
Anyway, I found some tricks which can make your life easier if you are using Nios II IDE 9.1 on Windows7.
Under your Quartus II folder, go to bin->cygwin->bin folder, select the following files in the list below and then right-click and choose Properties. Under the Compatibility tab, check“Run this program in compatibility mode for:” and choose “Windows XP (Service Pack 2)”. Check “Run this program as an administrator”, as well. Here is the list of files that you can select to change their compatibility mode under the Quartus II->bin->cygwin->bin folder: 1. Make.exe 2. Sh.exe 3. Echo.exe 4. Cygstart.exe 5. MakeInfo.exe 6. Perl.exe 7. Collect2.exe (under nios2eds\bin\nios2-gnutools\ H-i686-pc-cygwin\libexec\gcc\nios2-elf\3.4.6) 8. Nios2-elf-g++.exe (under nios2eds\bin\nios2-gnutools\ H-i686-pc-cygwin\bin)

By doing the steps mentioned above, the success rate of building a project in NIOS II IDE 9.1
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: