www.zeroshell.org Forum Index www.zeroshell.org
Linux Distribution for server and embedded devices
 
 SearchSearch  RegisterRegister  UsergroupsUsergroups 
 ProfileProfile  Log inLog in  Log in to check your private messagesPrivate Message 

Create a Development Environment

 
Post new topic   Reply to topic    www.zeroshell.org Forum Index -> ZeroShell
View previous topic :: View next topic  
Author Message
iulyb



Joined: 02 Jun 2016
Posts: 100

PostPosted: Tue Jun 28, 2016 4:52 pm    Post subject: Create a Development Environment Reply with quote

Hi,
I decided to share my adventure with you. There is some great documents about this especially this http://www.renatomorano.net/?p=1154 Many thanks to Renato Morano

My setup is a bit simpler and assume you already have a Virtual Box image like here:
http://www.zeroshell.org/forum/viewtopic.php?t=5275

With your guest off
Virtual Box -> Add New Storage Attachment. -> Hard Disk
Pick VDI and size should be about 5-8 G. Select SSD if is the case.

# We need to format and mount this.
Start ZS guest, login to console,

Code:
root@zeroshell ~> lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0     1G  0 disk
|-sda1   8:1    0   210M  0 part
|-sda2   8:2    0   320M  0 part /cdrom
|-sda3   8:3    0   320M  0 part
`-sda4   8:4    0   173M  0 part /DB
sdb      8:16   0     8G  0 disk
sr0     11:0    1  1024M  0 rom


Our new space is sdb, we need to create a partition, format and mount it.

Partition:
Code:
fdisk /dev/sdb

Pick n (new) select p (primary) use 1 as partition number and allocate all space (hit enter enter for defaults)
After partition was created use w to write changes to disk
Check to make sure (note sdb1):
Code:
root@zeroshell ~> lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0     1G  0 disk
|-sda1   8:1    0   210M  0 part
|-sda2   8:2    0   320M  0 part /cdrom
|-sda3   8:3    0   320M  0 part
`-sda4   8:4    0   173M  0 part /DB
sdb      8:16   0     8G  0 disk
`-sdb1   8:17   0     8G  0 part
sr0     11:0    1  1024M  0 rom 

# Format:
mkfs.ext4 /dev/sdb1

# Mount:
# First create a mount point that will survive reboots. (needs to be under \DB)
mkdir -p /DB/devel/headers
mkdir -p /DBdevel/cdrom
mount /dev/sdb1 /DB/devel
ln -s /DB/devel /devel
df -h

####### NOt used anymore #########
#Mount /usr as RW
#cd /cdrom
#tar -czvf /DB/devel/cdrom/usr.tar.gz usr
#cd /DB/devel/cdrom
#tar -xzvf usr.tar.gz
#rm /usr
#ln -s /DB/devel/cdrom/usr /usr

cd /DB/devel/headers

At this point we need to download some stuff. ZS has all we need
wget http://mirror.switch.ch/ftp/mirror/zeroshell/gcc-4.5.2-i386.tar.bz2
wget http://mirror.switch.ch/ftp/mirror/zeroshell/gcc-include.tar.bz2
wget http://mirror.switch.ch/ftp/mirror/zeroshell/glibc-2.8-includes-zs.tar.bz2
wget http://mirror.switch.ch/ftp/mirror/zeroshell/binutils-2.17-i386.tar.bz2
wget http://mirror.switch.ch/ftp/mirror/zeroshell/static-lib-i386.tar.bz2

# Unpack..:
cat *.bz2 |tar -xjvf - -i



Here is the twist... the order is important !, there are 2 versions of gcc on these packages, we need 4.5 Wink .. so again:
Code:
tar -xjvf gcc-4.5.2-i386.tar.bz2


# Testing gcc
Code:
root@zeroshell devel> gcc -v
bash: /usr/bin/gcc: Permission denied


# Add magic glue
Code:
PATH=/DB/devel/headers/usr/bin:$PATH


Testing our work:
Code:
root@zeroshell devel> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/DB/devel/headers/usr/bin/../libexec/gcc/i586-pc-linux-gnu/4.5.2/lto-wrapper
Target: i586-pc-linux-gnu
Configured with: ./configure --prefix=/usr --enable-languages=c,c++
Thread model: posix
gcc version 4.5.2 (GCC)

Now we are talking
Make sure gcc is 4.5 and not 3.3 !!!!!!!!!!!!

Downloading kernels
Code:
wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.1.15.tar.gz
wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.4.9.tar.gz

tar -xzvf linux-4.1.15.tar.gz
mkdir usr/src
mv linux-4.1.15 usr/src/

cd /DB/devel/headers/usr/lib
ln -s /cdrom/lib/libdl-2.23.so libdl.so
ldconfig

# you get :
ldconfig: File /usr/local/lib/libstdc++.so is empty, not checked.
ldconfig: File /usr/local/lib/libstdc++.so.6.0.10 is empty, not checked.


Move kernel source in place and compile it
Code:
cd /DB/devel/headers/usr/src
ln -s linux-4.1.15 linux-4.1.15-ZS
ln -s linux-4.1.15 linux
cd linux-4.1.15
make mrproper

zcat /proc/config.gz >.config


If you not upgrade kernel skip :
Code:
make oldconfig
make menuconfig


Compile
Code:
make


Repeat same steps for the other kernel. However you will config file for 4.4.9 supplied on ZS upgrade.

Test on a module:
#### i2c
Code:
cd /DB/devel/work
wget http://pcengines.ch/file/i2cpiix4.tar.gz
tar -xzvf i2cpiix4.tar.gz
cd i2cpiix4
modinfo i2c-piix4.ko
rmmod i2c-piix4
make -C /lib/modules/$(uname -r)/build M=$(pwd) modules
#make -C /DB/devel/headers/usr/src/linux-4.4.9/modules/lib/modules/4.4.9-ZS/build M=$(pwd) modules
insmod i2c-piix4.ko

mkdir modules
make INSTALL_MOD_PATH=modules/ modules_install


#command for running kernel
Code:
make -C /lib/modules/$(uname -r)/build M=$(pwd) modules

#command for different kernel
Code:
make -C /DB/devel/headers/usr/src/linux-4.4.9/modules/lib/modules/4.4.9-ZS/build M=$(pwd)


Test our work:
Quote:
modinfo xxxx.ko


Make a switch to dev script
This environment is not permanent so after each reboot we need to recreate it:
First create a location
mkdir /DB/opt
vi /DB/opt/setDevEnv.sh

Then add:
Code:
#/bin/bash
mount /dev/sdb1 /DB/devel
ln -s /DB/devel /devel
#rm /usr
#ln -s /DB/devel/cdrom/usr /usr
PATH=/devel/headers/usr/bin:$PATH


Call this script with
Code:
source /DB/opt/setDevEnv.sh
Back to top
View user's profile Send private message
DrmCa



Joined: 12 Apr 2011
Posts: 232

PostPosted: Wed Jun 29, 2016 4:38 pm    Post subject: Reply with quote

Wow, great, I've been struggling with getting compilation environment up for so long and never had time to figure it out. Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    www.zeroshell.org Forum Index -> ZeroShell All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group