Quantcast
Channel: Astr0baby's not so random thoughts _____ rand() % 100;
Viewing all articles
Browse latest Browse all 183

Pkgsrc on Ci20 Creator (v2) board

$
0
0

Ci20 is a great little board that I got recently since I wanted to experiment with a new architecture (mips)  Quick specifications are here :

SoC Ingenic JZ4780
CPU Dual 1.2GHz XBurst MIPS32 little endian
Caches 32kI + 32kD per core, 512K shared L2
RAM 1Gbyte DDR3
NAND 8 Gbyte

More detailed information is here https://elinux.org/CI20_Hardware  and here https://elinux.org/MIPS_Creator_CI20

The  board comes with Debian Linux mips  7.5  preinstalled and a custom kernel

Linux mipsbox 3.0.8-00847-g2e5af7d #1 SMP PREEMPT Wed Jun 24 10:10:52 BST 2015 mips GNU/Linux

There are possibilities to flash the NAND storage with newer images available from here https://elinux.org/CI20_Distros but I wanted to keep the stock kernel because of the custom drivers for the GPU that support mplayer hw-playback.

Before getting to work with the PKGSRC on Linux I wanted to build natively a newer GCC compiler (stock comes with GCC 4.6.3) So I have decided to give the 7.2.0 a try and build it natively.

Please note that I have used the –program-suffix=-4.6  and /usr/include/c++/4.6 in the configure – this is not correct but a dirty hack to overwrite the current GCC 4.6 files in Debian (it is a nightmare to remove the GCC related stuff as it has many dependencies)  It works quite well :)

 

Download GCC to the Ci20 
# wget https://ftp.gnu.org/gnu/gcc/gcc-7.2.0/gcc-7.2.0.tar.gz
# tar -zxvf gcc-7.2.0.tar.gz
# ./configure -v --enable-languages=c,c++,objc,obj-c++ --prefix=/usr
 --program-suffix=-4.6 --enable-shared --enable-linker-build-id 
 --with-system-zlib --libexecdir=/usr/lib --without-included-gettext
 --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6
 --libdir=/usr/lib --enable-nls --with-sysroot=/ 
 --enable-clocale=gnu --enable-libstdcxx-debug
 --enable-libstdcxx-time=yes --enable-gnu-unique-object 
 --enable-plugin --with-mips-plt --with-arch-32=mips2 
 --with-tune-32=mips32 --enable-targets=all --with-arch-64=mips3
 --with-tune-64=mips64 --enable-checking=release 
 --build=mipsel-linux-gnu --host=mipsel-linux-gnu
 --target=mipsel-linux-gnu

It took approx 30 hours to build on my Ci20, be patient (also maybe
a good idea is to create some swap just in case you would run out of
memory, I did mine on a USB drive) 

# mount /dev/sda1 /mnt/usb
# dd if=/dev/zero of=/mnt/usb/swapfile bs=1M count=102
# chmod 600 /mnt/usb/swapfile 
# mkswap /mnt/usb/swapfile
# swapon /mnt/usb/swapfile 

Finally build GCC 

# make
# make install

Once we have the GCC 7.2 installed it will be in the old GCC 4.6 directory structure, but it does not matter

root@mipsbox:/usr/include/c++/4.6# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/mipsel-linux-gnu/7.2.0/lto-wrapper
Target: mipsel-linux-gnu
Configured with: ./configure -v --enable-languages=c,c++,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-mips-plt --with-arch-32=mips2 --with-tune-32=mips32 --enable-targets=all --with-arch-64=mips3 --with-tune-64=mips64 --enable-checking=release --build=mipsel-linux-gnu --host=mipsel-linux-gnu --target=mipsel-linux-gnu
Thread model: posix
gcc version 7.2.0 (GCC)

Now lets go and bootstrap pkgsrc on the Ci20 ! I have decided to keep the pkgsrc sources on a separate USB flash drive and the /usr/pkg on the NAND flash.

root@mipsbox:/disk# ftp ftp.netbsd.org
Connected to ftp.netbsd.org.
220 ftp.NetBSD.org FTP server (NetBSD-ftpd 20110904) ready.
Name (ftp.netbsd.org:root): ftp
331 Guest login ok, type your name as password.
Password:
230 Guest login ok, access restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pas
Passive mode on.
ftp> cd pub
250 CWD command successful.
ftp> cd pkgsrc
250-
 Please read the file README
 it was last modified on Tue Nov 18 09:53:20 2008 - 3299 days ago
250 CWD command successful.
ftp> cd pkgsrc-2017Q3
250 CWD command successful.
ftp> get pkgsrc.tar.gz

Once it is downloaded, extract it on the USB drive and set symlinks

# pwd 
/mnt/usb
# tar -zxvf pkgsrc.tar.gz
# ln -s /mnt/usb/pkgsrc /usr/pkgsrc

and move onto the bootstrapping, also read the following https://wiki.netbsd.org/pkgsrc/how_to_use_pkgsrc_on_linux/

# echo "export SH=/bin/bash" >> /root/.bashrc

Relogin to root again and continue the bootstrap. The current bootstrap script does not understand the endianess of MIPS platforms, thus fails to produce correct arch type as mipseb or mipsel (Ci20 is mipsel)

I have produced a patch bootstrap that works for the Ci20

*** patched-bootstrap 2017-12-03 22:06:12.960991623 +0100
--- bootstrap 2017-10-23 03:00:23.000000000 +0200
***************
*** 1,6 ****
 #! /bin/sh
 
! # $NetBSD: bootstrap,v 1.243.4.1 2017/10/31 15:53:48 spz Exp $
 #
 # Copyright (c) 2001-2011 Alistair Crooks <agc@NetBSD.org>
 # All rights reserved.
--- 1,6 ----
 #! /bin/sh
 
! # $NetBSD: bootstrap,v 1.244 2017/10/22 19:29:20 bsiegert Exp $
 #
 # Copyright (c) 2001-2011 Alistair Crooks <agc@NetBSD.org>
 # All rights reserved.
***************
*** 691,697 ****
 need_awk=yes
 need_sed=yes
 set_opsys=yes
! machine_arch=mipsel
 check_compiler=yes
 if [ `uname -r` -lt 6 ]; then
 # IRIX 5's mkdir bails out with an error when trying to create with the -p
--- 691,697 ----
 need_awk=yes
 need_sed=yes
 set_opsys=yes
! machine_arch=mipseb
 check_compiler=yes
 if [ `uname -r` -lt 6 ]; then
 # IRIX 5's mkdir bails out with an error when trying to create with the -p
***************
*** 720,727 ****
 case "$machine_arch" in
 i?86) machine_arch=i386 ;;
 ppc64le) machine_arch=powerpc64le ;;
! mips) machine_arch=mipsel 
! esac
 ;;
 Minix)
 root_group=operator
--- 720,726 ----
 case "$machine_arch" in
 i?86) machine_arch=i386 ;;
 ppc64le) machine_arch=powerpc64le ;;
! esac
 ;;
 Minix)
 root_group=operator
***************
*** 869,875 ****
 # "i386" can support 64-bit, e.g. SunOS, defaults to 32-bit.
 i386/64) abi=64 machine_arch=x86_64 ;;
 i386/*) abi=32 machine_arch=i386 ;;
- mips/*) abi=32 machine_arch=mipsel ;;
 # XXX: powerpc untested
 powerpc/64) abi=64 machine_arch=powerpc64 ;;
 powerpc/*) abi=32 machine_arch=powerpc ;;
--- 868,873 ----

After you patch the /usr/pkgsrc/bootstrap/bootstrap, you can run it and after 1 hour the pkgsrc will get bootstrapped successfully on the Ci20 Debian mipsel

# cd /usr/pkgsrc/bootstrap
# ./bootstrap

To bmake packages afterwards make sure you have the following directories in path/usr/pkg/bin and /usr/pkg/sbin

What I found however were these minor issues during bmake build afterwards

/usr/pkgsrc/deve/readline

root@mipsbox:/usr/pkgsrc/devel/readline# /usr/pkg/bin/bmake 
=> Bootstrap dependency digest>=20010302: found digest-20160304
===> Skipping vulnerability checks.
WARNING: No /usr/pkg/pkgdb/pkg-vulnerabilities file found.
WARNING: To fix run: `/usr/pkg/sbin/pkg_admin -K /usr/pkg/pkgdb fetch-pkg-vulnerabilities'.
=> Checksum SHA1 OK for readline-7.0.tar.gz
=> Checksum RMD160 OK for readline-7.0.tar.gz
=> Checksum SHA512 OK for readline-7.0.tar.gz
===> Installing dependencies for readline-7.0
=> Tool dependency libtool-base>=2.4.2nb9: found libtool-base-2.4.6
=> Tool dependency nbpatch-[0-9]*: found nbpatch-20151107
=> Build dependency cwrappers>=20150314: found cwrappers-20170611
===> Overriding tools for readline-7.0
===> Extracting for readline-7.0
===> Patching for readline-7.0
=> Applying pkgsrc patches for readline-7.0
===> Creating toolchain wrappers for readline-7.0
===> Configuring for readline-7.0
=> Modifying GNU configure scripts to avoid --recheck
=> Replacing config-guess with pkgsrc versions
=> Replacing config-sub with pkgsrc versions
=> Replacing install-sh with pkgsrc version
checking build system type... mipsel-debian-linux-gnu
checking host system type... mipsel-debian-linux-gnu

Beginning configuration for readline-7.0 for mipsel-debian-linux-gnu

checking whether make sets $(MAKE)... yes
checking for mipsel-debian-linux-gcc... /usr/bin/gcc
checking whether the C compiler works... no
configure: error: in `/disk/pkgsrc/devel/readline/work/readline-7.0':
configure: error: C compiler cannot create executables
See `config.log' for more details
*** Error code 77

Stop.
bmake[1]: stopped in /usr/pkgsrc/devel/readline
*** Error code 1

Stop.
bmake: stopped in /usr/pkgsrc/devel/readline

The problem is during the following configure test (lets check the cofig.log)

root@mipsbox:/usr/pkgsrc/devel/readline# less /disk/pkgsrc/devel/readline/work/readline-7.0/config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by readline configure 7.0, which was
generated by GNU Autoconf 2.69. Invocation command line was

$ ./configure --prefix=/usr/pkg --build=mipsel-debian-linux --host=mipsel-debian-linux --infodir=/usr/pkg/info --mandir=/usr/pkg/man
<--snip-->
gcc version 7.2.0 (GCC) 
configure:2792: $? = 0
configure:2781: /usr/bin/gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:2792: $? = 1
configure:2781: /usr/bin/gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.
configure:2792: $? = 1
configure:2812: checking whether the C compiler works
configure:2834: /usr/bin/gcc -O2 -D_FORTIFY_SOURCE=2 -Wl,-R/usr/pkg/lib conftest.c >&5
as: Invalid transform rule: l:termcap:
configure:2838: $? = 1
configure:2876: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "readline"
| #define PACKAGE_TARNAME "readline"
| #define PACKAGE_VERSION "7.0"
| #define PACKAGE_STRING "readline 7.0"
| #define PACKAGE_BUGREPORT "bug-readline@gnu.org"
| #define PACKAGE_URL ""
| /* end confdefs.h. */
| 
| int
| main ()
| {
| 
| ;
| return 0;
| }
configure:2881: error: in `/disk/pkgsrc/devel/readline/work/readline-7.0':
configure:2883: error: C compiler cannot create executables
See `config.log' for more details

What worked however was going to the work dir of readline and doing the following

root@mipsbox:# cd /usr/pkgsrc/devel/readline/work/readline-7.0
root@mipsbox:# ./configure --prefix=/usr/pkg 
root@mipsbox:# echo "readline-7.0" > /usr/pkgsrc/devel/readline/work/.configure_done
root@mipsbox:# cd /usr/pkgsrc/devel/readline/work/readline-7.0/
root@mipsbox:# /usr/pkg/bin/bmake 
root@mipsbox:# echo "readline-7.0" > /usr/pkgsrc/devel/readline/work/.build_done
root@mipsbox:# mkdir -p work/.destdir/usr/pkg/info
root@mipsbox:# touch work/.destdir/usr/pkg/info/history.info
root@mipsbox:# touch work/.destdir/usr/pkg/info/readline.info
root@mipsbox:# touch work/.destdir/usr/pkg/info/rluserman.info
root@mipsbox:# touch work/.destdir/usr/pkg/lib/libhistory.la
root@mipsbox:# touch work/.destdir/usr/pkg/lib/libreadline.la
root@mipsbox:# mkdir -p work/.destdir/usr/pkg/man/man3
root@mipsbox:# touch work/.destdir/usr/pkg/man/man3/readline.3
root@mipsbox:# cd /usr/pkgsrc/devel/readline
root@mipsbox:# /usr/pkg/bin/bmake install 

Same approach as above worked for /usr/pkgsrc/lang/python27

root@mipsbox:/usr/pkg/bin# ./python2.7
Python 2.7.14 (default, Dec 3 2017, 18:36:28) 
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

Here is the list of packages that I have made so far

drwxr-xr-x 2 root root 728 Dec 3 20:00 bigreqsproto-1.1.2
drwxr-xr-x 2 root root 728 Dec 2 15:07 bmake-20150505
drwxr-xr-x 2 root root 800 Dec 2 15:07 bootstrap-mk-files-20170802
drwxr-xr-x 2 root root 800 Dec 3 22:07 bzip2-1.0.6nb1
drwxr-xr-x 2 root root 656 Dec 2 15:01 cwrappers-20170611
drwxr-xr-x 2 root root 728 Dec 3 19:56 damageproto-1.2.1
drwxr-xr-x 2 root root 800 Dec 3 22:07 db4-4.8.30
drwxr-xr-x 2 root root 728 Dec 2 15:31 digest-20160304
drwxr-xr-x 2 root root 944 Dec 3 21:32 docbook-xml-4.5
drwxr-xr-x 2 root root 872 Dec 3 21:32 docbook-xsl-1.79.1nb2
drwxr-xr-x 2 root root 728 Dec 3 19:48 dri2proto-2.8
drwxr-xr-x 2 root root 728 Dec 3 19:50 dri3proto-1.0
drwxr-xr-x 2 root root 728 Dec 3 19:55 fixesproto-5.0
drwxr-xr-x 2 root root 728 Dec 3 19:52 glproto-1.4.17
drwxr-xr-x 2 root root 728 Dec 3 19:54 inputproto-2.3.2
drwxr-xr-x 2 root root 728 Dec 2 15:35 kbproto-1.0.7
drwxr-xr-x 2 root root 1016 Dec 3 22:07 libffi-3.2.1nb4
drwxr-xr-x 2 root root 944 Dec 3 21:35 libgpg-error-1.27
drwxr-xr-x 2 root root 728 Dec 2 15:32 libtool-base-2.4.6
drwxr-xr-x 2 root root 728 Dec 3 20:05 libXau-1.0.8
drwxr-xr-x 2 root root 728 Dec 3 20:07 libXdmcp-1.1.2
drwxr-xr-x 2 root root 728 Dec 3 19:47 libxml2-2.9.6
drwxr-xr-x 2 root root 872 Dec 3 22:07 mozilla-rootcerts-1.0.20170121nb6
drwxr-xr-x 2 root root 728 Dec 2 15:08 nawk-20121220nb1
drwxr-xr-x 2 root root 728 Dec 2 15:32 nbpatch-20151107
drwxr-xr-x 2 root root 728 Dec 3 11:02 pax-20080110nb2
drwxr-xr-x 2 root root 944 Dec 3 21:32 perl-5.26.0nb3
drwxr-xr-x 2 root root 728 Dec 2 15:35 pkgconf-1.3.5
-rw-r--r-- 1 root root 2170880 Dec 3 22:07 pkgdb.byfile.db
drwxr-xr-x 2 root root 944 Dec 2 15:30 pkg_install-20170419
drwxr-xr-x 2 root root 728 Dec 3 19:51 presentproto-1.1
drwxr-xr-x 2 root root 656 Dec 3 09:25 pth-2.0.7nb5
drwxr-xr-x 2 root root 656 Dec 3 22:07 python27-2.7.14
drwxr-xr-x 2 root root 728 Dec 3 19:58 randrproto-1.5.0
drwxr-xr-x 2 root root 800 Dec 3 10:45 readline-7.0
drwxr-xr-x 2 root root 728 Dec 2 15:35 renderproto-0.11.1
drwxr-xr-x 2 root root 728 Dec 3 19:59 tradcpp-0.5.2nb2
drwxr-xr-x 2 root root 728 Dec 3 21:29 unzip-6.0nb8
drwxr-xr-x 2 root root 728 Dec 3 19:47 xcb-proto-1.12
drwxr-xr-x 2 root root 728 Dec 3 20:01 xcmiscproto-1.2.2
drwxr-xr-x 2 root root 728 Dec 3 19:53 xextproto-7.3.0
drwxr-xr-x 2 root root 728 Dec 3 20:02 xf86bigfontproto-1.2.0
drwxr-xr-x 2 root root 728 Dec 3 19:57 xf86driproto-2.1.1nb1
drwxr-xr-x 2 root root 728 Dec 3 19:56 xf86vidmodeproto-2.3.1
drwxr-xr-x 2 root root 1144 Dec 3 19:47 xmlcatmgr-2.2nb1
drwxr-xr-x 2 root root 728 Dec 2 15:35 xproto-7.0.31
drwxr-xr-x 2 root root 728 Dec 3 20:03 xtrans-1.3.5
drwxr-xr-x 2 root root 800 Dec 3 19:47 xz-5.2.3nb1

 

 

 

 


Viewing all articles
Browse latest Browse all 183

Trending Articles