Rebuilding Freedom-U-SDK


(Boris Shingarov) #1

What is the currently-accepted way to build the Freedom-U-SDK?
I have been developing a JIT compiler and so far using an old drop of Debian I got during the Barcelona workshop and haven’t updated since then (I develop on an actual Unleashed board). For the coming meeting in Santa Clara, I wanted to try out my JIT with the current toolchain, so I thought I’d rebuild the SDK from a clean slate. So I just did the most trivial checkout of SiFive’s umbrella repo:

$ git clone https://github.com/sifive/freedom-u-sdk.git
$ cd freedom-u-sdk
$ git submodule update --init --recursive
$ make
...
/usr/bin/gcc  -I.   -I/home/boris/work/freedom-u-sdk/work/buildroot_initramfs/host/usr/include  -O2 -I/home/boris/work/freedom-u-sdk/work/buildroot_initramfs/host/usr/include -c -o fseek.o fseek.c
freadahead.c: In function 'freadahead':
freadahead.c:91:3: error: #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."
  #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."
   ^~~~~
make[5]: *** [Makefile:1842: freadahead.o] Error 1
make[5]: *** Waiting for unfinished jobs....
make[5]: Leaving directory '/home/boris/work/freedom-u-sdk/work/buildroot_initramfs/build/host-m4-1.4.17/lib'

If I replace the indicated buildroot (dfc153) with the current master (ea5280), then it complains:

$ make
...
Makefile.legacy:9: *** "You have legacy configuration in your .config! Please check your configuration.".  Stop.

So… how do people build the world these days?


(Jim Wilson) #2

The currently accepted way to build freedom-u-sdk is to type make. freedom-u-sdk has an old copy of everything. It is easy to build if you have an OS distro from 2 years ago such as Ubuntu 16.04, but it is certainly not up-to-date. We will eventually upgrade freedom-u-sdk, but there is no schedule for that.

It should be buildable on a newer OS with a few patches. See for instance


which discusses the patches necessary to build on Ubuntu 18.04. A patch for this is checked into the buildroot sifive branch. If you just cd into buildroot and checkout that branch you will get it. Then try to avoid running a git submodule update in the top level tree and that will check out the old buildroot again.

If you think you have the right versions of stuff and are still getting a config error complaining about legacy stuff, then you may have a build inconsistency. Just use rm -rf to delete the buildroot/linux/whatever build tree to force it to reconfigure and rebuild. That will sometimes solve the problem. This is probably necessary every time you update your buildroot source tree.

If you want up-to-date, and you want a real distro, then take a look at Debian, Fedora, OpenSuse, FreeBSD, etc. You don’t build the world from scratch for one of these unless you have no option, because there is far too much work involved resolving all of the circular dependencies.

If you want an embedded linux system, there is OpenEmbedded support.

If you want a smaller simpler buildroot system, with up-to-date buildroot, then yes that works too, but the config files in freedom-u-sdk aren’t going to work unless updated to match current buildroot. It might be simpler to throw away the ones in freedom-u-sdk and get them from somewhere else. Or you can try to update them. I tried this once as an experiment and ended up with these patches. Ignore the gcc-9 stuff, as I was experimenting with gcc-9, which is why I needed a buildroot update.

rohan:2005$ cat buildroot.diff.txt 
diff --git a/conf/buildroot_initramfs_config b/conf/buildroot_initramfs_config
index 335ad76..068167f 100644
--- a/conf/buildroot_initramfs_config
+++ b/conf/buildroot_initramfs_config
@@ -1,8 +1,11 @@
-BR2_riscv64=y
+BR2_riscv=y
+BR2_RISCV_64=y
+BR2_RISCV_g=y
+BR2_RISCV_ABI_LP64D=y
 BR2_TOOLCHAIN_EXTERNAL=y
 BR2_TOOLCHAIN_EXTERNAL_PATH="$(RISCV)"
 BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="$(ARCH)-unknown-linux-gnu"
-BR2_TOOLCHAIN_EXTERNAL_GCC_7=y
+BR2_TOOLCHAIN_EXTERNAL_GCC_9=y
 BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_6=y
 BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
 # BR2_TOOLCHAIN_EXTERNAL_INET_RPC is not set
@@ -36,4 +39,4 @@ BR2_PACKAGE_PCIUTILS=y
 BR2_PACKAGE_DROPBEAR=y
 BR2_PACKAGE_SCREEN=y
 BR2_PACKAGE_HTOP=y
-BR2_PACKAGE_HOST_MKE2IMG=y
+# BR2_PACKAGE_HOST_MKE2IMG is not set
diff --git a/conf/buildroot_rootfs_config b/conf/buildroot_rootfs_config
index c0ba5a7..877b777 100644
--- a/conf/buildroot_rootfs_config
+++ b/conf/buildroot_rootfs_config
@@ -1,8 +1,11 @@
-BR2_riscv64=y
+BR2_riscv=y
+BR2_RISCV_64=y
+BR2_RISCV_g=y
+BR2_RISCV_ABI_LP64D=y
 BR2_TOOLCHAIN_EXTERNAL=y
 BR2_TOOLCHAIN_EXTERNAL_PATH="$(RISCV)"
 BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="$(ARCH)-unknown-linux-gnu"
-BR2_TOOLCHAIN_EXTERNAL_GCC_7=y
+BR2_TOOLCHAIN_EXTERNAL_GCC_9=y
 BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_6=y
 BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
 # BR2_TOOLCHAIN_EXTERNAL_INET_RPC is not set
@@ -42,7 +45,6 @@ BR2_PACKAGE_UTIL_LINUX_HWCLOCK=y
 BR2_PACKAGE_UTIL_LINUX_KILL=y
 BR2_PACKAGE_UTIL_LINUX_LAST=y
 BR2_PACKAGE_UTIL_LINUX_LINE=y
-BR2_PACKAGE_UTIL_LINUX_LOGIN_UTILS=y
 BR2_PACKAGE_UTIL_LINUX_LOSETUP=y
 BR2_PACKAGE_UTIL_LINUX_LSBLK=y
 BR2_PACKAGE_UTIL_LINUX_MESG=y
@@ -57,7 +59,6 @@ BR2_PACKAGE_UTIL_LINUX_PARTX=y
 BR2_PACKAGE_UTIL_LINUX_PIVOT_ROOT=y
 BR2_PACKAGE_UTIL_LINUX_RAW=y
 BR2_PACKAGE_UTIL_LINUX_RENAME=y
-BR2_PACKAGE_UTIL_LINUX_RESET=y
 BR2_PACKAGE_UTIL_LINUX_SCHEDUTILS=y
 BR2_PACKAGE_UTIL_LINUX_SETPRIV=y
 BR2_PACKAGE_UTIL_LINUX_SETTERM=y
@@ -74,5 +75,5 @@ BR2_PACKAGE_UTIL_LINUX_WRITE=y
 BR2_PACKAGE_UTIL_LINUX_ZRAMCTL=y
 BR2_TARGET_ROOTFS_EXT2=y
 BR2_TARGET_ROOTFS_EXT2_4=y
-BR2_TARGET_ROOTFS_EXT2_EXTRA_BLOCKS=10240
+# BR2_TARGET_ROOTFS_EXT2_EXTRA_BLOCKS is not set
 # BR2_TARGET_ROOTFS_TAR is not set
rohan:2006$