Subversion Repositories zpu
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 66 to Rev 67
- ↔ Reverse comparison
Rev 66 → Rev 67
Compiling hello world program with the ZPU GCC toolchain
-The ZPU comes with a standard GCC toolchain and an instruction set simulator. This allows compiling, running & debugging simple test programs. The Simulator has -some very basic peripherals defined: counter, timer interrupt and a debug output port. -Installation
--
-
- Install Cygwin. http://www.cygwin.com -
- Start Cygwin bash -
- unzip zputoolchain.zip -
- Add install/bin from zputoolchain.zip to PATH.
-export PATH=$PATH:/install/bin -
Hello world example
-The ZPU toolchain comes with newlib & libstdc++ support which means that many C/C++ programs can be compiled without modification. -
-
-zpu-elf-gcc -Os -zeta hello.c -o hello.elf -Wl,--relax -Wl,--gc-sections
-
-zpu-elf-size hello.elf
-
Optimizing for size
-The ZPU toolchain produces highly compact code. --
-
- Since the ZPU GCC toolchain supports standard ANSI C, it is easy to stumble across -functionality that takes up a lot of space. E.g. the standard printf() function is a beast. Some compilers drop e.g. floating point support -from the printf() function and thus boast a "smaller" printf() when in fact they have a non-standard printf(). newlib has a standard printf() function -and an alternative iprintf() function that works only on integers. -
- The ZPU ships with default startup code that works across various configurations of the ZPU, so be warned that there is some overhead that will -not occurr in the final application(anywhere between 1-4kBytes). -
- Compilation and linker options matter. The ZPU benefits greatly from the "-Wl,--relax -Wl,--gc-sections" options which is not used by -all architectures(e.g. GCC ARM does not implement/need -Wl,--relax). -
Small code example
-
-zpu-elf-gcc -Os -abel smallstd.c -o smallstd.elf -Wl,--relax -Wl,--gc-sections
-zpu-elf-size small.elf
-
-$ zpu-elf-size small.elf
- text data bss dec hex filename
- 2845 952 36 3833 ef9 small.elf
-
-
-
-Even smaller code example
-If the ZPU implements the optional instructions, the RAM overhead can be reduced significantly. -
-
-zpu-elf-gcc -Os -abel crt0_phi.S small.c -o small.elf -Wl,--relax -Wl,--gc-sections -nostdlib
-
-
-
Index: trunk/zpu/roadshow/roadshow/ecos/index.html
===================================================================
--- trunk/zpu/roadshow/roadshow/ecos/index.html (revision 66)
+++ trunk/zpu/roadshow/roadshow/ecos/index.html (nonexistent)
@@ -1,145 +0,0 @@
-
-
-zpu-elf-size small.elf
-
-$ zpu-elf-size small.elf
- text data bss dec hex filename
- 56 8 0 64 40 small.elf
-
-
Installing eCos build tools
-
-tar -xjvf ecossnapshot.tar.bz2
-tar -xjvf repository.tar.bz2
-tar -xjvf ecostools.tar.bz2
-# run this every time you open the shell
-export PATH=$PATH:`pwd`/ecos-install
-export ECOS_REPOSITORY=`pwd`/ecos/packages:`pwd`/repository
-
-Compiling eCos tests
-
-ecosconfig new zeta default
-ecosconfig tree
-make
-cd kernel/current
-make tests
-
-
-Code size ZPU
-
-$ zpu-elf-size *
- text data bss dec hex filename
- 15761 1504 12060 29325 728d bin_sem0
- 16907 1512 14436 32855 8057 bin_sem1
- 17105 1524 30032 48661 be15 bin_sem2
- 17186 1512 14436 33134 816e bin_sem3
- 18986 1500 12036 32522 7f0a clock0
- 15812 1504 13236 30552 7758 clock1
- 25095 1972 13224 40291 9d63 clockcnv
- 16437 1500 13224 31161 79b9 clocktruth
- 15762 1504 12060 29326 728e cnt_sem0
- 17124 1512 14436 33072 8130 cnt_sem1
- 35947 1564 22512 60023 ea77 dhrystone
- 16428 1500 13228 31156 79b4 except1
- 15751 1504 12052 29307 727b flag0
- 19145 1512 15624 36281 8db9 flag1
- 20053 1516 102908 124477 1e63d fptest
- 15998 1496 12092 29586 7392 intr0
- 16080 1496 12200 29776 7450 kalarm0
- 15327 1496 12036 28859 70bb kcache1
- 15549 1496 13224 30269 763d kcache2
- 18291 1500 12260 32051 7d33 kclock0
- 16231 1500 13232 30963 78f3 kclock1
- 16572 1496 13228 31296 7a40 kexcept1
- 15618 1496 12060 29174 71f6 kflag0
- 19287 1500 15624 36411 8e3b kflag1
- 16887 1516 15628 34031 84ef kill
- 16186 1496 12128 29810 7472 kintr0
- 19724 1504 14516 35744 8ba0 klock
- 18283 1500 14592 34375 8647 kmbox1
- 15539 1496 12064 29099 71ab kmutex0
- 16524 1504 15664 33692 839c kmutex1
- 18272 1712 20348 40332 9d8c kmutex3
- 18682 1608 20352 40642 9ec2 kmutex4
- 15619 1496 14412 31527 7b27 ksched1
- 15567 1496 12060 29123 71c3 ksem0
- 17063 1500 14436 32999 80e7 ksem1
- 15504 1496 13228 30228 7614 kthread0
- 16167 1496 14412 32075 7d4b kthread1
- 18281 1512 14580 34373 8645 mbox1
- 20611 1508 14940 37059 90c3 mqueue1
- 15672 1504 12064 29240 7238 mutex0
- 16678 1516 15664 33858 8442 mutex1
- 17694 1508 16868 36070 8ce6 mutex2
- 18203 1720 20344 40267 9d4b mutex3
- 16352 1508 14428 32288 7e20 release
- 15890 1500 14412 31802 7c3a sched1
- 44196 1612 286332 332140 5116c stress_threads
- 17891 1524 16864 36279 8db7 sync2
- 16943 1512 15644 34099 8533 sync3
- 15467 1496 13064 30027 754b thread0
- 16134 1496 14420 32050 7d32 thread1
- 17560 1512 15636 34708 8794 thread2
- 16279 1500 24028 41807 a34f thread_gdb
- 17051 1504 20376 38931 9813 timeslice
- 17146 1504 21564 40214 9d16 timeslice2
- 37313 1512 422380 461205 70995 tm_basic
-
-Code size ARM (non-thumb)
-Thumb does not compile out of the box w/AT91 EB40a for which this test was made.
-
-$ arm-elf-size *
-
-
-
-
-
Index: trunk/zpu/docs/images/GCC_logo.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/zpu/docs/images/GCC_logo.png
===================================================================
--- trunk/zpu/docs/images/GCC_logo.png (nonexistent)
+++ trunk/zpu/docs/images/GCC_logo.png (revision 67)
- text data bss dec hex filename
- 25204 692 16976 42872 a778 bin_sem0
- 26644 700 22096 49440 c120 bin_sem1
- 26996 712 55584 83292 1455c bin_sem2
- 27008 700 22100 49808 c290 bin_sem3
- 28992 688 16944 46624 b620 clock0
- 25456 692 19532 45680 b270 clock1
- 34572 1160 19520 55252 d7d4 clockcnv
- 26224 688 19508 46420 b554 clocktruth
- 25204 692 16976 42872 a778 cnt_sem0
- 26888 700 22108 49696 c220 cnt_sem1
- 44180 752 27416 72348 11a9c dhrystone
- 26088 688 19520 46296 b4d8 except1
- 25236 692 16968 42896 a790 flag0
- 29532 700 24668 54900 d674 flag1
- 29508 704 109652 139864 22258 fptest
- 25932 684 17016 43632 aa70 intr0
- 25824 684 17112 43620 aa64 kalarm0
- 24728 684 16956 42368 a580 kcache1
- 25168 684 19512 45364 b134 kcache2
- 28112 688 17168 45968 b390 kclock0
- 25976 688 19524 46188 b46c kclock1
- 26372 684 19512 46568 b5e8 kexcept1
- 25140 684 16968 42792 a728 kflag0
- 29824 688 24660 55172 d784 kflag1
- 26896 704 24656 52256 cc20 kill
- 26088 684 17028 43800 ab18 kintr0
- 30812 692 22176 53680 d1b0 klock
- 28504 688 22260 51452 c8fc kmbox1
- 24984 684 16984 42652 a69c kmutex0
- 26504 692 24704 51900 cabc kmutex1
- 28792 900 34892 64584 fc48 kmutex3
- 29264 796 34896 64956 fdbc kmutex4
- 25240 684 22084 48008 bb88 ksched1
- 25044 684 16968 42696 a6c8 ksem0
- 26988 688 22100 49776 c270 ksem1
- 25028 684 19512 45224 b0a8 kthread0
- 25996 684 22080 48760 be78 kthread1
- 28552 700 22252 51504 c930 mbox1
- 31324 696 22612 54632 d568 mqueue1
- 25108 692 16980 42780 a71c mutex0
- 26464 704 24700 51868 ca9c mutex1
- 27624 696 27280 55600 d930 mutex2
- 28596 908 34884 64388 fb84 mutex3
- 26156 696 22100 48952 bf38 release
- 25460 688 22084 48232 bc68 sched1
- 56356 828 45892 103076 192a4 stress_threads
- 27900 712 27288 55900 da5c sync2
- 26760 700 24692 52152 cbb8 sync3
- 24924 684 19356 44964 afa4 thread0
- 25868 684 22084 48636 bdfc thread1
- 27452 700 24680 52832 ce60 thread2
- 26136 688 42704 69528 10f98 thread_gdb
- 27212 692 34916 62820 f564 timeslice
- 52728 700 123332 176760 2b278 tm_basic
-
It performs better(despite having less memory bandwidth than zpu_core_small.vhd) since it implements many more instructions. +
Compiling hello world program with the ZPU GCC toolchain
+The ZPU comes with a standard GCC toolchain and an instruction set simulator. This allows compiling, running & debugging simple test programs. The Simulator has +some very basic peripherals defined: counter, timer interrupt and a debug output port. +Installation
+-
+
- Install Cygwin. http://www.cygwin.com +
- Start Cygwin bash +
- unzip zputoolchain.zip +
- Add install/bin from zputoolchain.zip to PATH.
+export PATH=$PATH:/install/bin +
Hello world example
+The ZPU toolchain comes with newlib & libstdc++ support which means that many C/C++ programs can be compiled without modification. +
+
+zpu-elf-gcc -Os -zeta hello.c -o hello.elf -Wl,--relax -Wl,--gc-sections
+
+
+zpu-elf-size hello.elf
+
Optimizing for code size
+The ZPU toolchain produces highly compact code. +-
+
- Since the ZPU GCC toolchain supports standard ANSI C, it is easy to stumble across +functionality that takes up a lot of space. E.g. the standard printf() function is a beast. Some compilers drop e.g. floating point support +from the printf() function and thus boast a "smaller" printf() when in fact they have a non-standard printf(). newlib has a standard printf() function +and an alternative iprintf() function that works only on integers. +
- The ZPU ships with default startup code that works across various configurations of the ZPU, so be warned that there is some overhead that will +not occurr in the final application(anywhere between 1-4kBytes). +
- Compilation and linker options matter. The ZPU benefits greatly from the "-Wl,--relax -Wl,--gc-sections" options which is not used by +all architectures(e.g. GCC ARM does not implement/need -Wl,--relax). +
Small code example
+
+zpu-elf-gcc -Os -abel smallstd.c -o smallstd.elf -Wl,--relax -Wl,--gc-sections
+zpu-elf-size small.elf
+
+$ zpu-elf-size small.elf
+ text data bss dec hex filename
+ 2845 952 36 3833 ef9 small.elf
+
+
+Even smaller code example
+If the ZPU implements the optional instructions, the RAM overhead can be reduced significantly. +
+
+zpu-elf-gcc -Os -abel crt0_phi.S small.c -o small.elf -Wl,--relax -Wl,--gc-sections -nostdlib
+
+
+
+
+
+zpu-elf-size small.elf
+
+$ zpu-elf-size small.elf
+ text data bss dec hex filename
+ 56 8 0 64 40 small.elf
+
+
Installing eCos build tools
+
+tar -xjvf ecossnapshot.tar.bz2
+tar -xjvf repository.tar.bz2
+tar -xjvf ecostools.tar.bz2
+# run this every time you open the shell
+export PATH=$PATH:`pwd`/ecos-install
+export ECOS_REPOSITORY=`pwd`/ecos/packages:`pwd`/repository
+
+Compiling eCos tests
+
+ecosconfig new zeta default
+ecosconfig tree
+make
+cd kernel/current
+make tests
+
+
+Code size ZPU
+
+$ zpu-elf-size *
+ text data bss dec hex filename
+ 15761 1504 12060 29325 728d bin_sem0
+ 16907 1512 14436 32855 8057 bin_sem1
+ 17105 1524 30032 48661 be15 bin_sem2
+ 17186 1512 14436 33134 816e bin_sem3
+ 18986 1500 12036 32522 7f0a clock0
+ 15812 1504 13236 30552 7758 clock1
+ 25095 1972 13224 40291 9d63 clockcnv
+ 16437 1500 13224 31161 79b9 clocktruth
+ 15762 1504 12060 29326 728e cnt_sem0
+ 17124 1512 14436 33072 8130 cnt_sem1
+ 35947 1564 22512 60023 ea77 dhrystone
+ 16428 1500 13228 31156 79b4 except1
+ 15751 1504 12052 29307 727b flag0
+ 19145 1512 15624 36281 8db9 flag1
+ 20053 1516 102908 124477 1e63d fptest
+ 15998 1496 12092 29586 7392 intr0
+ 16080 1496 12200 29776 7450 kalarm0
+ 15327 1496 12036 28859 70bb kcache1
+ 15549 1496 13224 30269 763d kcache2
+ 18291 1500 12260 32051 7d33 kclock0
+ 16231 1500 13232 30963 78f3 kclock1
+ 16572 1496 13228 31296 7a40 kexcept1
+ 15618 1496 12060 29174 71f6 kflag0
+ 19287 1500 15624 36411 8e3b kflag1
+ 16887 1516 15628 34031 84ef kill
+ 16186 1496 12128 29810 7472 kintr0
+ 19724 1504 14516 35744 8ba0 klock
+ 18283 1500 14592 34375 8647 kmbox1
+ 15539 1496 12064 29099 71ab kmutex0
+ 16524 1504 15664 33692 839c kmutex1
+ 18272 1712 20348 40332 9d8c kmutex3
+ 18682 1608 20352 40642 9ec2 kmutex4
+ 15619 1496 14412 31527 7b27 ksched1
+ 15567 1496 12060 29123 71c3 ksem0
+ 17063 1500 14436 32999 80e7 ksem1
+ 15504 1496 13228 30228 7614 kthread0
+ 16167 1496 14412 32075 7d4b kthread1
+ 18281 1512 14580 34373 8645 mbox1
+ 20611 1508 14940 37059 90c3 mqueue1
+ 15672 1504 12064 29240 7238 mutex0
+ 16678 1516 15664 33858 8442 mutex1
+ 17694 1508 16868 36070 8ce6 mutex2
+ 18203 1720 20344 40267 9d4b mutex3
+ 16352 1508 14428 32288 7e20 release
+ 15890 1500 14412 31802 7c3a sched1
+ 44196 1612 286332 332140 5116c stress_threads
+ 17891 1524 16864 36279 8db7 sync2
+ 16943 1512 15644 34099 8533 sync3
+ 15467 1496 13064 30027 754b thread0
+ 16134 1496 14420 32050 7d32 thread1
+ 17560 1512 15636 34708 8794 thread2
+ 16279 1500 24028 41807 a34f thread_gdb
+ 17051 1504 20376 38931 9813 timeslice
+ 17146 1504 21564 40214 9d16 timeslice2
+ 37313 1512 422380 461205 70995 tm_basic
+
+Code size ARM (non-thumb)
+Thumb does not compile out of the box w/AT91 EB40a for which this test was made.
+
+$ arm-elf-size *
+
+
+
+ text data bss dec hex filename
+ 25204 692 16976 42872 a778 bin_sem0
+ 26644 700 22096 49440 c120 bin_sem1
+ 26996 712 55584 83292 1455c bin_sem2
+ 27008 700 22100 49808 c290 bin_sem3
+ 28992 688 16944 46624 b620 clock0
+ 25456 692 19532 45680 b270 clock1
+ 34572 1160 19520 55252 d7d4 clockcnv
+ 26224 688 19508 46420 b554 clocktruth
+ 25204 692 16976 42872 a778 cnt_sem0
+ 26888 700 22108 49696 c220 cnt_sem1
+ 44180 752 27416 72348 11a9c dhrystone
+ 26088 688 19520 46296 b4d8 except1
+ 25236 692 16968 42896 a790 flag0
+ 29532 700 24668 54900 d674 flag1
+ 29508 704 109652 139864 22258 fptest
+ 25932 684 17016 43632 aa70 intr0
+ 25824 684 17112 43620 aa64 kalarm0
+ 24728 684 16956 42368 a580 kcache1
+ 25168 684 19512 45364 b134 kcache2
+ 28112 688 17168 45968 b390 kclock0
+ 25976 688 19524 46188 b46c kclock1
+ 26372 684 19512 46568 b5e8 kexcept1
+ 25140 684 16968 42792 a728 kflag0
+ 29824 688 24660 55172 d784 kflag1
+ 26896 704 24656 52256 cc20 kill
+ 26088 684 17028 43800 ab18 kintr0
+ 30812 692 22176 53680 d1b0 klock
+ 28504 688 22260 51452 c8fc kmbox1
+ 24984 684 16984 42652 a69c kmutex0
+ 26504 692 24704 51900 cabc kmutex1
+ 28792 900 34892 64584 fc48 kmutex3
+ 29264 796 34896 64956 fdbc kmutex4
+ 25240 684 22084 48008 bb88 ksched1
+ 25044 684 16968 42696 a6c8 ksem0
+ 26988 688 22100 49776 c270 ksem1
+ 25028 684 19512 45224 b0a8 kthread0
+ 25996 684 22080 48760 be78 kthread1
+ 28552 700 22252 51504 c930 mbox1
+ 31324 696 22612 54632 d568 mqueue1
+ 25108 692 16980 42780 a71c mutex0
+ 26464 704 24700 51868 ca9c mutex1
+ 27624 696 27280 55600 d930 mutex2
+ 28596 908 34884 64388 fb84 mutex3
+ 26156 696 22100 48952 bf38 release
+ 25460 688 22084 48232 bc68 sched1
+ 56356 828 45892 103076 192a4 stress_threads
+ 27900 712 27288 55900 da5c sync2
+ 26760 700 24692 52152 cbb8 sync3
+ 24924 684 19356 44964 afa4 thread0
+ 25868 684 22084 48636 bdfc thread1
+ 27452 700 24680 52832 ce60 thread2
+ 26136 688 42704 69528 10f98 thread_gdb
+ 27212 692 34916 62820 f564 timeslice
+ 52728 700 123332 176760 2b278 tm_basic
+