Error when build a 32bit linux kernel with riscv32-linux-gnu on 32bit OS

380 views
Skip to first unread message

Haoran Shi

unread,
Nov 25, 2016, 9:58:56 AM11/25/16
to RISC-V SW Dev
Help!!! Has anyone build the linux kernel successfully with riscv32-unknown-linux-gnu tools? 
I downloaded the linux kernel according to the instructions in https://github.com/riscv/riscv-linux and checkout to the branch priv-1.9.
And the riscv32-unknown-linux-gnu tools is from https://github.com/riscv/riscv-tools with xlen=32.
But Whatever I configure the linux kernel compiler environment, I always met errors.
After "$ make defconfig" "$ make menuconfig", I also
changed Platform type -> CPU selection from Rocket to Generic RISC-V
changed Kernel type -> Kernel code model from 64-bit kernel to 32-bit kernel
changed General setup -> Cross-compiler tool prefix from riscv64-unknown-linux-gnu- to riscv32-unknown-linux-gnu- (which I built in riscv-tools)

but I got an error that 
```
include/asm-generic/div64.h:224:22: error: passing argument 1 of '__div64_32' from incompatible pointer type [-Werror=incompatible-pointer-types]
   __rem = __div64_32(&(n), __base); \
                      ^
```
The OS on my computer is
```
Linux ubuntu32 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:06:37 UTC 2016 i686 i686 i686 GNU/Linux
```
I have no idea how to fix it...Could anyone help me? Thanks a lot!

Sijmen Woutersen

unread,
Nov 28, 2016, 1:12:45 PM11/28/16
to Haoran Shi, RISC-V SW Dev
Hi,

We made some fixes and got 32-bit linux booting on our own core, see: https://github.com/Technolution/riscv-linux/tree/priv-1.9.

Notably;

We do intend to make a pull request at some point, but we have to isolate some changes & cleanup. The above patches disable / break floating point so you might not want everything.

Regards,

Sijmen


--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+unsubscribe@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/4ccb87b3-89eb-4e2d-a432-3c28fbf6c27f%40groups.riscv.org.



--
Sijmen Woutersen  Architect

T +31(0)182594000 | M +31(0)615426154 | E sijmen.w...@technolution.nl 
A Burgemeester Jamessingel 1, P.O. Box 2013, 2800 BD Gouda, The Netherlands | W www.technolution.nl

Haoran Shi

unread,
Nov 29, 2016, 7:00:53 AM11/29/16
to RISC-V SW Dev, shr9...@gmail.com
Thanks for your effort! I got a 32-bit vmlinux according to your solution, however, when I boot the kernel with bbl in qemu, it just reminds that ”cannot allocate memory" 
shore@ubuntu32:~/riscv-qemu$ ./riscv32-softmmu/qemu-system-riscv32 -nographic -kernel /home/shore/riscv/riscv32-unknown-elf/bin/bbl -drive file=/home/shore/linux-4.6.2/root.bin,format=raw -m 512M
qemu-system-riscv32: cannot set up guest memory 'riscv_spike_board.ram': Cannot allocate memory

Actually, the memory of my machine is 4GB. I cannot believe that it is because the memory is not adequate. I mean that the 32bit OS can access 4GB memory at most, the OS of my computer is

Linux ubuntu32 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:06:37 UTC 2016 i686 i686 i686 GNU/Linux

Actually, the bbl is built according to https://github.com/riscv/riscv-pk/tree/master, except that I modify the configuration because I am running a 32bit Machine

../configure --prefix=$RISCV --host=riscv32-unknown-linux-gnu --enable-32bit --with-payload=/home/shore/linux-4.6.2/vmlinux

the drive file system is build according to the https://github.com/riscv/riscv-tools#creating-root-disk


Have you met such probloms or do you have any solution?

Maybe I should open a new thread to ask this problem?



 在 2016年11月29日星期二 UTC+8上午2:12:45,Sijmen Woutersen写道:
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.



--
Sijmen Woutersen  Architect

T +31(0)182594000 | M +31(0)615426154 | E sijmen.wout...@technolution.nl 

Haoran Shi

unread,
Dec 8, 2016, 10:46:21 PM12/8/16
to RISC-V SW Dev
The solution is described here, https://github.com/riscv/riscv-qemu/issues/39.
Thanks for all the kindness!

在 2016年11月25日星期五 UTC+8下午10:58:56,Haoran Shi写道:
Reply all
Reply to author
Forward
0 new messages