Download: sys1a.zip.
This project consists of the following NIOS II System:
A small-library C++ application (hello_world_small) was created.
/* * "Small Hello World" example. * * This example prints 'Hello from Nios II' to the STDOUT stream. It runs on * the Nios II 'standard', 'full_featured', 'fast', and 'low_cost' example * designs. It requires a STDOUT device in your system's hardware. * * The purpose of this example is to demonstrate the smallest possible Hello * World application, using the Nios II HAL library. The memory footprint * of this hosted application is ~3124 bytes by default using the standard * reference design. For a more fully featured Hello World application * example, see the example titled "Hello World". * * The memory footprint of this example has been reduced by making the * following changes to the normal "Hello World" example. * Check in the Nios II Software Developers Manual for a more complete * description. * * In the SW Application project (small_hello_world): * * - In the C/C++ Build page * * - Set the Optimization Level to -Os * * In System Library project (small_hello_world_syslib): * - In the C/C++ Build page * * - Set the Optimization Level to -Os * * - Define the preprocessor option ALT_NO_INSTRUCTION_EMULATION * This removes software exception handling, which means that you cannot * run code compiled for Nios II cpu with a hardware multiplier on a core * without a the multiply unit. Check the Nios II Software Developers * Manual for more details. * * - In the System Library page: * - Set Periodic system timer and Timestamp timer to none * This prevents the automatic inclusion of the timer driver. * * - Set Max file descriptors to 4 * This reduces the size of the file handle pool. * * - Uncheck Clean exit (flush buffers) * This removes the call to exit, and when main is exitted instead of * calling exit the software will just spin in a loop. * * - Check Small C library * This uses a reduced functionality C library, which lacks * support for buffering, file IO, floating point and getch(), etc. * Check the Nios II Software Developers Manual for a complete list. * * - Check Reduced device drivers * This uses reduced functionality drivers if they're available. For the * standard design this means you get polled UART and JTAG UART drivers, * no support for the LCD driver and you lose the ability to program * CFI compliant flash devices. * * * */ #include <stdio.h> int main() { printf("Hello from Nios II!\n"); printf("University of Dayton\n"); return 0; }
The offset in the od command was taken from the headers file (.rodata).
#!/bin/sh nios2-elf-size hello_world_small_1.elf > hello.size.txt nios2-elf-objdump -dS hello_world_small_1.elf > hello.disassemble.txt nios2-elf-objdump -h hello_world_small_1.elf > hello.headers.txt nios2-elf-nm hello_world_small_1.elf > hello.symbols.txt nios2-elf-objcopy -S -O binary hello_world_small_1.elf hello.bin # dump from .rodata od -Ax -j0xab8 -txz hello.bin > hello.od.txt
text data bss dec hex filename 2824 256 4 3084 c0c hello_world_small_1.elf
hello_world_small_1.elf: file format elf32-littlenios2 Sections: Idx Name Size VMA LMA File off Algn 0 .entry 00000020 00000000 00000000 00000074 2**5 CONTENTS, ALLOC, LOAD, READONLY, CODE 1 .exceptions 00000000 00000020 00000020 00000c7c 2**0 CONTENTS 2 .text 00000a98 00000020 00000020 00000094 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE 3 .rodata 00000050 00000ab8 00000ab8 00000b2c 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA 4 .rwdata 00000100 00000b08 00000b08 00000b7c 2**2 CONTENTS, ALLOC, LOAD, DATA, SMALL_DATA 5 .bss 00000004 00000c08 00000c08 00000c7c 2**2 ALLOC, SMALL_DATA 6 .onchip_memory_0 00000000 00000c0c 00000c0c 00000c7c 2**0 CONTENTS 7 .comment 00000408 00000000 00000000 00000c7c 2**0 CONTENTS, READONLY 8 .debug_aranges 000002c8 00000000 00000000 00001088 2**3 CONTENTS, READONLY, DEBUGGING 9 .debug_pubnames 000003ab 00000000 00000000 00001350 2**0 CONTENTS, READONLY, DEBUGGING 10 .debug_info 00004ee9 00000000 00000000 000016fb 2**0 CONTENTS, READONLY, DEBUGGING 11 .debug_abbrev 00001662 00000000 00000000 000065e4 2**0 CONTENTS, READONLY, DEBUGGING 12 .debug_line 0000412f 00000000 00000000 00007c46 2**0 CONTENTS, READONLY, DEBUGGING 13 .debug_frame 00000394 00000000 00000000 0000bd78 2**2 CONTENTS, READONLY, DEBUGGING 14 .debug_str 00000ebe 00000000 00000000 0000c10c 2**0 CONTENTS, READONLY, DEBUGGING 15 .debug_alt_sim_info 00000030 00000000 00000000 0000cfcc 2**2 CONTENTS, READONLY, DEBUGGING 16 .debug_ranges 00000048 00000030 00000030 0000cffc 2**0 CONTENTS, READONLY, DEBUGGING
00000ab8 A __CTOR_END__ 00000ab8 A __CTOR_LIST__ 00008000 A __alt_data_end 00000000 A __alt_mem_onchip_memory_0 00008000 A __alt_stack_pointer 00000c0c A __bss_end 00000c08 A __bss_start w __errno 00000000 T __reset 0000016c T __sfvwrite_small_dev 00000504 T _do_ctors 00000c08 A _edata 00000c0c A _end 00000aa8 T _exit 00008be0 A _gp 00000be0 G _impure_ptr 00000094 T _puts_r 00000020 T _start 00000240 T _write_r 00000bec G alt_argc 00000be8 G alt_argv 000003d4 T alt_avalon_jtag_uart_read 00000450 T alt_avalon_jtag_uart_write 00000bf4 G alt_dev_list 00000490 T alt_dev_llist_insert 00000bb8 G alt_dev_null 00000488 t alt_dev_null_write 00000be4 G alt_envp 00000c04 G alt_errno 00000b88 G alt_fd_list 000007f8 T alt_find_dev 00000884 T alt_find_file 00000bfc G alt_fs_list 0000094c T alt_get_fd 000005c4 T alt_io_redirect 000002a4 T alt_main 00000bf0 G alt_max_fd 0000054c t alt_open_fd 000007d4 T alt_release_fd 000002ec T alt_sys_init 00000c0c A end 00000c08 B errno 00000aa8 T exit 00000b08 g impure_data 00000b5c g jtag_uart_0 00000064 T main 00000a6c T memcmp 00000658 T open 00000138 T puts 0000014c T strlen 00000304 T write
000ab8 6c6c6548 7266206f 4e206d6f 20736f69 >Hello from Nios < 000ac8 00214949 76696e55 69737265 6f207974 >II!.University o< 000ad8 61442066 6e6f7479 00000000 0000000a >f Dayton........< 000ae8 7665642f 61746a2f 61755f67 305f7472 >/dev/jtag_uart_0< 000af8 00000000 7665642f 6c756e2f 0000006c >..../dev/null...< 000b08 00000b3c 00000b44 00000b4c 00000000 ><...D...L.......< 000b18 00000000 00000000 00000000 00000000 >................< * 000b38 00000000 00000004 00000000 0001000a >................< 000b48 00000000 0002000a 00000000 00000000 >................< 000b58 00000000 00000000 00000000 00000ae8 >................< 000b68 00000000 00000000 000003d4 00000450 >............P...< 000b78 00000000 00000000 00000000 00008830 >............0...< 000b88 00000bb8 00000000 00000000 00000bb8 >................< 000b98 00000000 00000000 00000bb8 00000000 >................< 000ba8 00000000 00000000 00000000 00000000 >................< 000bb8 00000bf4 00000bf4 00000afc 00000000 >................< 000bc8 00000000 00000000 00000488 00000000 >................< 000bd8 00000000 00000000 00000b08 00000000 >................< 000be8 00000000 00000000 ffffffff 00000bb8 >................< 000bf8 00000bb8 00000bfc 00000bfc 00000000 >................< 000c08
Maintained by John Loomis, last updated 29 May 2007