Comments (18)
I'll write about results
Please let us know, hopefully we can make it work as well.
Btw, after a bit of searching, there is a simpler approach! The trick is to let gcc do the link because it knows where the libs are (found the hint at the bottom of the answer: https://stackoverflow.com/questions/64603070/risc-v-linker-cannot-find-lgcc ).
We can then use -lm
(for math) and -nostartfiles
(to use our custom crt0).
$ARCH-as -march=rv32i -mabi=ilp32 -o crt0.o $BASE/crt0.s
$ARCH-gcc -DICESTICK -nostartfiles -fno-builtin -fno-unroll-loops -O1 -fno-stack-protector -fno-pic -march=rv32i -mabi=ilp32 -T $BASE/config_c.ld -o $DST/code.elf $1 crt0.o -lm
That is way cleaner, I'll update my scripts accordingly.
from silice.
I compiled my code and tested it.
About your latest compilation script tested, I don't check it yet.
Newlib is fantastic, thank you @sylefeb.
from silice.
Thanks for the feedback and tests! I'll close the issue for now but feel free to reopen if needed.
from silice.
from silice.
Thanks for your help, but where is "--specs=nano.specs" inside "https://github.com/sylefeb/Silice/blob/master/projects/ice-v/compile/icestick/compile_c.sh" script?
I used ice-v scripts but caused: undefined reference to __subsf3'
from silice.
from silice.
Hi @ShervinShokouhi, Hi @rob-ng15,
This missing entry is due to floating point emulation not being found by the linker. I never had to use it (I do fixed point / integer only) but we definitely need that to work. I'll try to look into the issue as soon as possible but @rob-ng15 has definitely more experience on this. Rob, I believe you did compile with floating point emulation in the past, right?
from silice.
Yes, I believe that the floating point emulation is in the libgcc.a file.
from silice.
Just realised that I've given the paths to the versions that have hardware floating point support, I think you need to remove the f from the end of ip32
from silice.
from silice.
Hi @sylefeb, @rob-ng15
Thanks for your detailed descriptions, now I'm able to compile C file to O. But in linker stage again asks for MATH functions:
C:\msys64\mingw64\bin\riscv64-unknown-elf-ld.exe: main.c:(.text+0x1e0): undefined reference to `__mulsf3'
How to link newlib library in linker stage?
from silice.
Have a look in your gcc directories for libgcc and put that path in,ale sue is it for rve2i and ilp32
from silice.
Its my gcc command (Toolchain is made for RV32I with NewLib):
riscv32-unknown-elf-gcc -fno-unroll-loops -O1 -fno-stack-protector -fno-pic -march=rv32i -mabi=ilp32 --specs=nano.specs -LF:\Silice\Toolchains\riscv32-unknown-elf\riscv32-unknown-elf\lib\rv32i\ilp32/libc.a -L-LF:\Silice\Toolchains\riscv32-unknown-elf\riscv32-unknown-elf\lib\rv32i\ilp32/libm.a -LF:\Silice\Toolchains\riscv32-unknown-elf\riscv32-unknown-elf\lib\rv32i\ilp32/libg.a -LF:\Silice\Toolchains\riscv32-unknown-elf\newlib-nano\lib\gcc\riscv32-unknown-elf\11.3.0\rv32i\ilp32/libgcc.a -lm -S test.c -o test.s
Generated ASM (or ELF) file again contains "call" to MATH functions.
I create GCC toolchain with crosstool-ng in Ubuntu for use in Windows x64.
Any idea?
from silice.
I could not test beyond compilation yet but this seems to work (*) on my side:
https://gist.github.com/sylefeb/64a0a55681f0680908989724c05e1778
(*) (edit: added this note) by 'seems to work' I mean I could compile code using float on an rv32i setup.
Might need a change in paths, for libgcc in particular as it contains a version number (note: the order of object file / libraries does matter in the ld command line).
from silice.
It works! I was able to run the following on the ice-v (with the scripts I linked above and a small change to the .ld
, see comment in the gist:
#include "config.h"
#include <math.h>
void main()
{
float f = 1.111111f;
for (int i = 0 ; i < 20 ; ++i) {
f = f * f;
*LEDS = (int)round(f);
}
}
from silice.
I also compiled it :)
Thank you @sylefeb
But I have some problem with test it in my custom SOC.
I'll write about results
from silice.
Another question: Now generated HEX file contains several sections split by something like "@000001E0", how do you fill them into BRAM for CPU?
from silice.
Hex file: I have updated the preprocessor script to do that: https://github.com/sylefeb/Silice/blob/draft/projects/ice-v/SOCs/pre_include_compiled.lua (could use a rewrite but does the job ;) ).
from silice.
Related Issues (20)
- interleaving pipelined algorithms in host pipelines HOT 1
- Extracting bits from a bitfield results in a segmentation fault HOT 2
- Combining declaration and always assignment
- Many boards share a common set of features, yet each board has its own define HOT 2
- Empty FSM states could be optimized HOT 7
- Unused states that remain and cycles that could be avoided HOT 35
- Unexpected code execution. HOT 4
- Name shadowing
- Error initialising bram not brom
- A subroutine which is never called in a design can crash Silice. HOT 6
- Not setting a subroutines output parameter leads to a yosys error. HOT 2
- uart_tx and uart_rx seem to have wrong direction in the Verilog framework file for the ECPIX5-Board HOT 1
- Can't compile Silice on Arch Linux HOT 14
- ULX3S sdram_memtest sample build fails. HOT 4
- **ASSERT FAILED** (if_deadend && !if_statless) || !if_deadend, file ..Algorithm.cpp, line 4078 HOT 3
- inouts cannot be bound using a bit-select syntax
- Documentation: possible typo in Silice/learn-silice/Documentation.md?
- Enhancement of declaration of bram/brom/simple_dualport_bram/dualport_bram
- $$ directives in board file Verilog are not ignored in code disabled by preprocessor test or /* */
- Enhancement of declaration of and usage of always assignments
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from silice.