-
Notifications
You must be signed in to change notification settings - Fork 200
How to develop for jor1k
Please note, that compiling for such an embedded machine is never easy. You need a lot of experience and you must know the architecture very well. You can send me wishes of software you would like to see in jor1k.
Yes, I mean this seriously. By far, this is the easiest way. Upload your code in the /home/user folder and compile directly in jor1k. You can download your compiled code and put it into a .tar.bz2 file. jor1k has the option to load such files directly at the beginning. Take a look in the index.html file. If some header files are missing for you compilation in the rootfs, don't hesitate to ask. I will upload them.
Another way to develop for jor1k is to use the provided sysroot-environment and using the qemu-user tools. The kernel must support the binfmt-feature and the Linux distribution should run on the x86-64 architecture.
- Download sysroot environment
Download the packages you want to use from www.jor1k.com/packages/
The minimum requirement is base.tar.bz2 and busybox.tar.bz2
mkdir -p jor1k-sysroot
cd jor1k-sysroot
wget www.jor1k.com/packages/base.tar.bz2
wget www.jor1k.com/packages/busybox.tar.bz2
in order to develop in C the minimum requirements are the following additionals packages:
wget www.jor1k.com/packages/musl.tar.bz2
wget www.jor1k.com/packages/musl-dev.tar.bz2
wget www.jor1k.com/packages/zlib.tar.bz2
wget www.jor1k.com/packages/binutils.tar.bz2
wget www.jor1k.com/packages/gcc-libs.tar.bz2
wget www.jor1k.com/packages/gcc.tar.bz2
To compile the linux kernel you should add the following packages
wget www.jor1k.com/packages/make.tar.bz2
wget www.jor1k.com/packages/ncurses.tar.bz2
wget www.jor1k.com/packages/ncurses-dev.tar.bz2
wget www.jor1k.com/packages/bc.tar.bz2
- Extract the compressed sysroot
mkdir -p sysroot
cd sysroot
for a in `ls -1 ../*.tar.bz2`; do tar -xvjf $a; done
cd ..
-
download qemu-or1k-static to sysroot/usr/bin
wget https://github.com/multiarch/qemu-user-static/releases/download/v2.12.0/qemu-or1k-static -O sysroot/usr/bin/qemu-or1k-static chmod u+x sysroot/usr/bin/qemu-or1k-static
-
install the binfmt packages on your system and provide the kernel the or1k binary header details.
sudo mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
sudo echo ":qemu-or1k:M:0:\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x5c:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-or1k-static:OC" > /proc/sys/fs/binfmt_misc/register
- Enter the chroot environment
sudo chroot sysroot /usr/bin/qemu-or1k-static -E PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin bin/sh
- To improve the compatibility execute the following commands before step 5
cp /etc/resolv.conf sysroot/etc/ sudo mount -t proc none sysroot/proc sudo mount -t sysfs none sysroot/sys sudo mount -o bind /dev sysroot/dev sudo mount -o bind /dev/pts sysroot/dev/pts
Follow the building description of the musl toolchain at http://opencores.org/or1k/OpenRISC_GNU_tool_chain
Take a look at https://github.com/s-macke/jor1k-toolchain-builder