[讨论]Nios II工程模板 Hello World 和 Hello LED的区别
- UID
- 154181
- 性别
- 男
|
[讨论]Nios II工程模板 Hello World 和 Hello LED的区别
各位前辈,请教Nios II工程模板 Hello World 和 Hello LED到底区别在哪儿? 为什么从Hello World 建的工程最小得6K多(只是实现一个IO口输出),而Hello LED工程则可以少到200多字节? 是不是EP1C3在on chip memory里面也就只能运行个Hello World? 它的片上RAM只有7K多点,EP1C6也只有11K多
[此贴子已经被作者于2007-8-31 14:01:50编辑过] |
********求知欲和创造欲是原动力******** |
|
|
|
|
|
- UID
- 169538
- 性别
- 男
|
区别在于hello world调用了printf函数 |
博客:
http://NiosII.cublog.cn |
|
|
|
|
|
- UID
- 154181
- 性别
- 男
|
我倒是想到了这一点 如果不优化代码的话,直接生成的Hello World代码有30几K,起码现在提示我还需37K的空间,我的on chip memory是4K 但是把printf函数屏蔽掉的话,只是一个空的main()函数,优化后的代码都有6K 而Hello LED生成的代码只有几百个字节,当然是没有用到printf函数 这个Hello World工程代码到底多在了哪儿?
|
********求知欲和创造欲是原动力******** |
|
|
|
|
|
- UID
- 136199
- 性别
- 男
|
"而Hello LED生成的代码只有几百个字节,当然是没有用到printf函数 这个Hello World工程代码到底多在了哪儿?" 你可以看看nios_led的说明: * This example is a freestanding program because it's entry point is the * function: * * void alt_main (void) * * As opposed to "main()" as a "hosted" application would (see the * "hello_world" example). * * Upon entry to alt_main(): * - The CPU's caches (if any) have been initialized. * - The stack-pointer has been set. * - That's all. The rest is up to you. * * If you modify this example and try to call C library functions such as * printf, they will NOT work unless you explicitly initialize the system. * If you wish to use C library calls, it is strongly suggested you start * with the hosted hello_world template which uses main() as it's entry * point. * * On the other hand, if you want to write a program that gets-in even * earlier, you will need to provide your own assembly-language machine-setup * code by defining the symbol "_start". Any definition of _start in your * directory will override the library definition. You can find source code * for the Nios II library _start here: |
这个版主不太冷
===========================
我的中电网博客:http://blog.chinaecnet.com/u/20/index.htm |
|
|
|
|
|
- UID
- 169538
- 性别
- 男
|
主要是alt_main.c和alt_sys_init.c引入的代码 而这俩文件又间接引入了很多设备驱动代码,比如系统包含定时器,则定时器的驱动会被自动加载到最终的可执行文件... 更详细的资料自己研究吧或者等我的书出版^_^ |
博客:
http://NiosII.cublog.cn |
|
|
|
|
|
- UID
- 154181
- 性别
- 男
|
楼上前辈说的很明白,谢谢,而且你要出的书我看过介绍了,很好,期待中 对于Hello LED工程我是这么做的: 向导产生的.c文件中的代码我都删除了,我没有用alt_main()作为入口,而是用了main()函数 而且我还在上面成功驱动了1602字符液晶!完全IO口驱动,其实就是用了个IOWR()函数 继续学习研究中~~
|
********求知欲和创造欲是原动力******** |
|
|
|
|
|