OpenCores
no use no use 1/1 no use no use
How to run a program on minsoc
by zhongyang on Feb 8, 2012
zhongyang
Posts: 21
Joined: Dec 24, 2010
Last seen: May 9, 2012
Hi there,
I have loaded the minsoc down to a FPGA board and run the test successfully. Besides, I have completed the step that connect the or1200 and the or32-elf-gdb.
The problem I am facing now is that I have no proper programs to download. I want to compile my own programs, but I don't know the commands that used to compile my source code. I used the command below but I wasn't successed.

or32-elf-gcc -o test test.c

It just reports errors and I can't get my code compiled. My toolchain is newlib-1.0rc1 downloaded from the old web.
How can I get my code compiled to run on the FPGA board?

Thanks for helping.
RE: How to run a program on minsoc
by vlogaras on Feb 8, 2012
vlogaras
Posts: 46
Joined: Aug 28, 2005
Last seen: Dec 15, 2014
Can you show us the errors that have been reported?
RE: How to run a program on minsoc
by zhongyang on Feb 9, 2012
zhongyang
Posts: 21
Joined: Dec 24, 2010
Last seen: May 9, 2012
Can you show us the errors that have been reported?
My code is here. #include void main() { int a; int b; int c; a = 1; b = 2; c = a + b; } And I use or32-elf-gcc -o test test.c to compile, but I got these errors. zhongyang@zhongyang-desktop:~/test$ or32-elf-gcc -o test test.c /opt/or32-elf-1.0rc1/bin/../lib/gcc/or32-elf/4.5.1-or32-1.0rc4/../../../../or32-elf/lib/crt0.o: In function `_start': (.text+0x0): undefined reference to `_board_mem_base' /opt/or32-elf-1.0rc1/bin/../lib/gcc/or32-elf/4.5.1-or32-1.0rc4/../../../../or32-elf/lib/crt0.o: In function `_start': (.text+0x4): undefined reference to `_board_mem_base' /opt/or32-elf-1.0rc1/bin/../lib/gcc/or32-elf/4.5.1-or32-1.0rc4/../../../../or32-elf/lib/crt0.o: In function `_start': (.text+0xc): undefined reference to `_board_mem_size' /opt/or32-elf-1.0rc1/bin/../lib/gcc/or32-elf/4.5.1-or32-1.0rc4/../../../../or32-elf/lib/crt0.o: In function `_start': (.text+0x10): undefined reference to `_board_mem_size' /opt/or32-elf-1.0rc1/bin/../lib/gcc/or32-elf/4.5.1-or32-1.0rc4/../../../../or32-elf/lib/crt0.o: In function `_start': (.text+0x68): undefined reference to `_board_uart_base' /opt/or32-elf-1.0rc1/bin/../lib/gcc/or32-elf/4.5.1-or32-1.0rc4/../../../../or32-elf/lib/crt0.o: In function `_start': (.text+0x6c): undefined reference to `_board_uart_base' /opt/or32-elf-1.0rc1/bin/../lib/gcc/or32-elf/4.5.1-or32-1.0rc4/../../../../or32-elf/lib/crt0.o: In function `_start': (.text+0x80): undefined reference to `__uart_init' /opt/or32-elf-1.0rc1/bin/../lib/gcc/or32-elf/4.5.1-or32-1.0rc4/../../../../or32-elf/lib/libc.a(lib_a-exit.o): In function `exit': /home/jules/Documents/openrisc/svn/trunk/gnu-src/bd-elf/or32-elf/newlib/libc/stdlib/../../../../../unisrc/newlib/libc/stdlib/exit.c:65: undefined reference to `_exit' collect2: ld return 1 What is the problem and how can I solve it?
RE: How to run a program on minsoc
by zhongyang on Feb 9, 2012
zhongyang
Posts: 21
Joined: Dec 24, 2010
Last seen: May 9, 2012
Can you show us the errors that have been reported?


My code is here.

void main()
{
int a;
int b;
int c;

a = 1;
b = 2;
c = a + b;
}

And I use or32-elf-gcc -o test test.c to compile, but I got these errors.

zhongyang@zhongyang-desktop:~/test$ or32-elf-gcc -o test test.c
/opt/or32-elf-1.0rc1/bin/../lib/gcc/or32-elf/4.5.1-or32-1.0rc4/../../../../or32-elf/lib/crt0.o: In function `_start':
(.text+0x0): undefined reference to `_board_mem_base'
/opt/or32-elf-1.0rc1/bin/../lib/gcc/or32-elf/4.5.1-or32-1.0rc4/../../../../or32-elf/lib/crt0.o: In function `_start':
(.text+0x4): undefined reference to `_board_mem_base'
/opt/or32-elf-1.0rc1/bin/../lib/gcc/or32-elf/4.5.1-or32-1.0rc4/../../../../or32-elf/lib/crt0.o: In function `_start':
(.text+0xc): undefined reference to `_board_mem_size'
/opt/or32-elf-1.0rc1/bin/../lib/gcc/or32-elf/4.5.1-or32-1.0rc4/../../../../or32-elf/lib/crt0.o: In function `_start':
(.text+0x10): undefined reference to `_board_mem_size'
/opt/or32-elf-1.0rc1/bin/../lib/gcc/or32-elf/4.5.1-or32-1.0rc4/../../../../or32-elf/lib/crt0.o: In function `_start':
(.text+0x68): undefined reference to `_board_uart_base'
/opt/or32-elf-1.0rc1/bin/../lib/gcc/or32-elf/4.5.1-or32-1.0rc4/../../../../or32-elf/lib/crt0.o: In function `_start':
(.text+0x6c): undefined reference to `_board_uart_base'
/opt/or32-elf-1.0rc1/bin/../lib/gcc/or32-elf/4.5.1-or32-1.0rc4/../../../../or32-elf/lib/crt0.o: In function `_start':
(.text+0x80): undefined reference to `__uart_init'
/opt/or32-elf-1.0rc1/bin/../lib/gcc/or32-elf/4.5.1-or32-1.0rc4/../../../../or32-elf/lib/libc.a(lib_a-exit.o): In function `exit':
/home/jules/Documents/openrisc/svn/trunk/gnu-src/bd-elf/or32-elf/newlib/libc/stdlib/../../../../../unisrc/newlib/libc/stdlib/exit.c:65: undefined reference to `_exit'
collect2: ld return 1

What is the problem and how can I solve it?
RE: How to run a program on minsoc
by rfajardo on Feb 9, 2012
rfajardo
Posts: 306
Joined: Jun 12, 2008
Last seen: Jan 6, 2020
Hi zhongyang,

there are times when you don't know how to go further. Generally, this is the point where a better understanding of the related concepts will help you out.

In the case of MinSoC, you can get more information about its concepts and build in the documentation.

I highly recommend that you read Chapter 3, Firmware, from page 14 of the minsoc.pdf under minsoc/doc. Or get it here: http://opencores.org/websvn,filedetails?repname=minsoc&path=%2Fminsoc%2Ftrunk%2Fdoc%2Fminsoc.pdf

I would also recommend that you make use of the existing Makefiles in order to compile your firmware. In the case of the uart one, link below, you can see the issued commands by typing make clean and make all under that directory.

http://opencores.org/websvn,filedetails?repname=minsoc&path=%2Fminsoc%2Ftrunk%2Fsw%2Fuart%2FMakefile

Lastly, in order to create your own firmware, just adapt lines 5 and 6 to your needs:
SRCS = uart.c
OR32_TARGET = uart.hex

Under SRCS, you can simply list more files with spaces in between. For target, give a name to your firmware and put .hex after that. That should do it.

I hope that helps.
Raul
RE: How to run a program on minsoc
by zhongyang on Feb 13, 2012
zhongyang
Posts: 21
Joined: Dec 24, 2010
Last seen: May 9, 2012
Hi zhongyang,

there are times when you don't know how to go further. Generally, this is the point where a better understanding of the related concepts will help you out.

In the case of MinSoC, you can get more information about its concepts and build in the documentation.

I highly recommend that you read Chapter 3, Firmware, from page 14 of the minsoc.pdf under minsoc/doc. Or get it here: http://opencores.org/websvn,filedetails?repname=minsoc&path=%2Fminsoc%2Ftrunk%2Fdoc%2Fminsoc.pdf

I would also recommend that you make use of the existing Makefiles in order to compile your firmware. In the case of the uart one, link below, you can see the issued commands by typing make clean and make all under that directory.

http://opencores.org/websvn,filedetails?repname=minsoc&path=%2Fminsoc%2Ftrunk%2Fsw%2Fuart%2FMakefile

Lastly, in order to create your own firmware, just adapt lines 5 and 6 to your needs:
SRCS = uart.c
OR32_TARGET = uart.hex

Under SRCS, you can simply list more files with spaces in between. For target, give a name to your firmware and put .hex after that. That should do it.

I hope that helps.
Raul


Thanks for your help.
But now I encouted with a new problem. I want to compile my program with float variables and uing math functions like sin(), But when using the default makefile, I got errors.

/home/zhongyang/minsoc/minsoc/trunk/sw/uart/test.c:16: undefined reference to `__floatsisf'
/home/zhongyang/minsoc/minsoc/trunk/sw/uart/test.c:16: undefined reference to `__addsf3'
/home/zhongyang/minsoc/minsoc/trunk/sw/uart/test.c:17: undefined reference to `__extendsfdf2'
/home/zhongyang/minsoc/minsoc/trunk/sw/uart/test.c:17: undefined reference to `sin'
/home/zhongyang/minsoc/minsoc/trunk/sw/uart/test.c:17: undefined reference to `__truncdfsf2'
collect2: ld return 1
make: *** [test.or32] error 1

I think I should add the libs when compiling the codes, but what can I do about this? How can modify the makefile?
RE: How to run a program on minsoc
by rfajardo on Mar 16, 2012
rfajardo
Posts: 306
Joined: Jun 12, 2008
Last seen: Jan 6, 2020
Floating point operations require a floating point arithmetics unit which MinSoC does not include. Besides, I doubt that the math library is supported by the community. Thus, you couldn't use it either.

It seems you are addressing your problem with the wrong apprach.
RE: How to run a program on minsoc
by skrzyp on Mar 16, 2012
skrzyp
Posts: 28
Joined: Jun 9, 2011
Last seen: Jan 25, 2013
Hi zhongyang

If you don't mind using RTOS, you can use eCos for that. Just turn off any optimizations and turn on soft floats. eCos has it's own math library. I have tested eCos math library on or1ksim and ordb2 hardware - it works perfectly well. I believe it will work on MinSoC too.

Here you will find instructions how to build a binary:
http://opencores.org/or1k/ECos

You can then upload the binary using GDB and adv_jtag_bridge

Best regards
Piotr Skrzypek
no use no use 1/1 no use no use
© copyright 1999-2026 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.