WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [Solved] Instructions on updating TinyCore 11 to Real Time?  (Read 21252 times)

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: Instructions on updating TinyCore 11 to Real Time?
« Reply #15 on: April 21, 2020, 03:26:46 AM »
Somehow your extension loading is broken. That's not too easy to help remotely.
The only barriers that can stop you are the ones you create yourself.

Offline pditty

  • Newbie
  • *
  • Posts: 19
Re: Instructions on updating TinyCore 11 to Real Time?
« Reply #16 on: April 21, 2020, 07:11:40 AM »
Yes, I used this patch

patch-5.4.3-rt1.patch.xz

And this command after extracting the TinyCore pre-patched kernel (http://distro.ibiblio.org/tinycorelinux/11.x/x86/release/src/kernel/linux-5.4.3-patched.txz).

$ xzcat ../patch-5.4.3-rt1.patch.xz | patch -p1

Offline pditty

  • Newbie
  • *
  • Posts: 19
Re: Instructions on updating TinyCore 11 to Real Time?
« Reply #17 on: April 21, 2020, 07:12:31 AM »
Is there an IRC channel we can use to chat on?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11630
Re: Instructions on updating TinyCore 11 to Real Time?
« Reply #18 on: April 21, 2020, 09:25:54 AM »
Hi pditty
I'm guessing maybe some permissions got messed up in  rootfs.gz.  Maybe I missed it, but I didn't see why  rootfs.gz  needed
to be changed.

Try this procedure:
... A couple of months ago I had to recompile a kernel to get some hardware on an ASUS T100 Transformer recognized and ran into
the same problem ("is already owned by kernel" error).

The error ("is already owned by kernel") is basically saying a symbol that a module is defining is already defined by the kernel. When
configuring a kernel, selecting certain options will force some drivers to be built into the kernel instead of as a module. So, assuming
you already have existing kernel modules, DRIVER_A is a module depending on DRIVER_B. You select a kernel option that requires
DRIVER_B to be built into the kernel. If you try loading DRIVER_A with the new kernel, it will attempt to load DRIVER_B (a dependency)
and you get that symbol "is already owned by kernel" error. This means DRIVER_A also needs to be recompiled so it no longer tries
to load DRIVER_B.

What I wound up doing is recompiling all modules when I changed the kernel. Here's a step by step for the whole procedure:
Code: [Select]
Compile a kernel:
tce-load -i compiletc perl5 bash ncursesw-dev bc glibc_apps elfutils-dev
wget http://tinycorelinux.net/10.x/x86_64/release/src/kernel/config-4.19.10-tinycore64
wget http://tinycorelinux.net/10.x/x86_64/release/src/kernel/linux-4.19.10-patched.txz
tar xf linux-4.19.10-patched.txz
cd  linux-4.19.10
make mrproper
# Start with the most recent config file.
cp ../config-4.19.10-tinycore64 .config
make oldconfig
make menuconfig [make your changes]
# I like to save a copy of the config file to use as a starting point for the next time.
cp .config ../config-4.19.10-tinycore64-asusT100CHIrev1
# Compile kernel
make -j 2 bzImage
# Copy the kernel where the bootloader can find it.
cp arch/x86/boot/bzImage /mnt/sdg1/Linux/vmlinuzASUS64rev1
# Compile modules
make -j 2 modules
# Place the modules somewhere for packaging.
mkdir -p /home/tc/tmp/ASUS/modules/usr/local
make INSTALL_MOD_PATH=/home/tc/tmp/ASUS/modules/usr/local modules_install
cd /home/tc/tmp/ASUS/
# I like to keep the mod.alias, mod.builtin, mod.dep, mod.order, and mod.symbols files.
mv modules/usr/local/lib/modules/4.19.10-tinycore64/modules.* .
# Remove the 2 links in modules/usr/local/lib/modules/4.19.10-tinycore64/
rm modules/usr/local/lib/modules/4.19.10-tinycore64/build
rm modules/usr/local/lib/modules/4.19.10-tinycore64/source

# Set up sorter.sh to package all the modules.
cd ..
mkdir sorter
cd sorter
tce-load -i squashfs-tools zsync
wget https://github.com/tinycorelinux/sorter/archive/master.zip
unzip master.zip
cd sorter-master/
# This creates all of the Tinycore module packages and leaves them in the current directory.
./sorter.sh 4.19.10-tinycore64 /home/tc/tmp/ASUS/modules
# Back to the tmp directory.
cd ../../
# Fetch a 32 bit root file system.
wget http://tinycorelinux.net/10.x/x86/release/distribution_files/rootfs.gz
# Copy the module archive that's part of the base system
cp sorter/sorter-master/modules64.gz modulesASUS64rev1.gz
# Make a new initrd, 64 bit modules with 32 bit root file system (32 bit apps) in this example.
cat rootfs.gz modulesASUS64rev1.gz > coreASUS64rev1.gz
# Copy the initrd where the bootloader can find it.
cp coreASUS64rev1.gz /mnt/sdg1/Linux/

The downloads only need to be done once. If you need to compile again, use the config file you saved previously as a starting point.

Created directories to archive the results of each build. This allows you to revert to a previous build and keeps matching config,
kernels, modules, and initrd files together. Append  rev1  to the config, kernel, and initrd filenames and place them in a  rev1
directory along with their matching modules.

Compile times on a Dell Dimension E310 were 52 minutes for the kernel and 3 hours 45 minutes for the modules.
Apply your patch, probably after  make mrproper.  There's a sorter script that separates and packages all of the modules. I mixed
a 64 bit kernel with a 32 bit  rootfs.gz  for my needs. Download the  rootfs.gz  that matches your requirements. The procedure is
fairly well commented as to what's going on. Ask questions if something I did seems unclear.

If you really feel the need to unpack/pack  rootfs.gz:
To unpack:
Code: [Select]
mkdir tempdir
cd tempdir
zcat /path/to/existing/rootfs.gz | sudo cpio -i

To repack:
Code: [Select]
sudo find . | sudo cpio -o -H newc | gzip > /path/to/new/rootfs.gz
Found here:
http://forum.tinycorelinux.net/index.php/topic,22398.msg140327.html#msg140327
« Last Edit: December 26, 2020, 07:47:00 PM by Rich »

Offline pditty

  • Newbie
  • *
  • Posts: 19
Re: Instructions on updating TinyCore 11 to Real Time?
« Reply #19 on: April 21, 2020, 09:46:01 AM »
Thanks Rich, let me give this a try and get back to you.

Offline pditty

  • Newbie
  • *
  • Posts: 19
Re: Instructions on updating TinyCore 11 to Real Time?
« Reply #20 on: April 21, 2020, 10:13:04 AM »
Do I need to gzip the new .ko files before running the sorter script?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11630
Re: Instructions on updating TinyCore 11 to Real Time?
« Reply #21 on: April 21, 2020, 10:23:09 AM »
Hi pditty
You can, I didn't. The sorter script gzips the base modules file:
Code: [Select]
# Copy the module archive that's part of the base system
cp sorter/sorter-master/modules64.gz modulesASUS64rev1.gz
So the package is smaller, but the modules get unpacked when you boot and take more space in the RAM filesystem.

The  .tcz  files are compressed file systems. They get loop mounted so compressing those modules won't buy you anything.

Offline pditty

  • Newbie
  • *
  • Posts: 19
Re: Instructions on updating TinyCore 11 to Real Time?
« Reply #22 on: April 21, 2020, 11:23:21 AM »
You're the man Rich!

That worked and I am now booting to the GUI. 

Your instructions were perfect!!

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11630
Re: [Solved] Instructions on updating TinyCore 11 to Real Time?
« Reply #23 on: April 21, 2020, 11:27:05 AM »
Hi pditty
Glad I could help. Thank you for confirming it worked for you. I will mark your original post as  [Solved].

Offline pditty

  • Newbie
  • *
  • Posts: 19
Re: [Solved] Instructions on updating TinyCore 11 to Real Time?
« Reply #24 on: April 21, 2020, 12:38:43 PM »
Rich, This is essentially everything you did but tweaked for 5.4.3, ubuntu, and building an ISO (that can run in a vm if you want).

I wanted to post it in case it helps anyone else.

NOTE: I have the following folder structure as well as tinycore-extract.sh and sorter.sh already in the folders.  If you don't have them you can download them from github and extract them (if necessary).

-wget https://github.com/tinycorelinux/sorter/archive/master.zip
-https://github.com/elazarl/customize_tinycorelinux

tmp/
tmp/backup
tmp/image
tmp/image/tinycore-extract.sh
tmp/modules/usr/local
tmp/sorter/sorter-master/sorter.sh

############################ Create the Image directory #########################
->cd image
->sudo ./tinycore-extract.sh <image iso name OR Tinycore-current.iso by default>
->cd iso/boot
->sudo rm core.gz vmlinuz
->cd ../../../

############################  Compile The Kernel#####################################
### Only install these if you don't have them already
->sudo apt-get install zsync -y
->sudo apt-get install squashfs-tools
->sudo apt-get install -y xorriso

### Get the patched Tinycore kernel and Real time patch
->wget http://tinycorelinux.net/11.x/x86/release/src/kernel/config-5.4.3-tinycore
->wget http://tinycorelinux.net/11.x/x86/release/src/kernel/linux-5.4.3-patched.txz
->wget https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
->tar xf linux-5.4.3-patched.txz
->cd  linux-5.4.3

###Clean the Kernel, just in case
->make mrproper

###Patch the Kerenl with the Real time extension
->xzcat ../patch-5.4.3-rt1.patch.xz | patch -p1

### Start with the most recent config file.
->cp ../config-5.4.3-tinycore .config

### Merge the old .config with the real time patch features
->make oldconfig

#### Enter #4 for FULLY PREEMPT, everything else is default

### OPTIONAL: Make your changes to the kernel
->make menuconfig

### OPTIONAL: Save Kernel Config as a starting point for next time.
->cp .config ../config-5.4.3-tinycoreRT-rev1

### Compile the kernel
->make -j 2 bzImage

### Copy the kernel where the bootloader can find it in the image directory
->cp arch/x86/boot/bzImage ../image/iso/boot/vmlinuz

### Compile modules
->make -j 2 modules

### Place the modules in a temporary directory
->make INSTALL_MOD_PATH=../modules/usr/local modules_install
->cd ../

### OPTIONAL: Backup modules.alias, modules.builtin, modules.dep, modules.order, and modules.symbols files just in case
->mv modules/usr/local/lib/modules/5.4.3-rt1-tinycore/modules.* backup/

### Remove the 2 uneccessary symlinks in modules/usr/local/lib/modules/5.4.3-rt1-tinycore
->rm modules/usr/local/lib/modules/5.4.3-rt1-tinycore/build
->rm modules/usr/local/lib/modules/5.4.3-rt1-tinycore/source


######################### Set up sorter.sh to package all the modules.  ###############################
->cd sorter/sorter-master

### Create the Tinycore module packages and leave them in the current directory.
->sudo ./sorter.sh 5.4.3-rt1-tinycore ../../modules

### Back to the working directory.
->cd ../../

### Fetch a 32 bit root file system.
->wget http://tinycorelinux.net/11.x/x86/release/distribution_files/rootfs.gz

### Copy the module archive to the working directory
->cp sorter/sorter-master/modules.gz modulesRT.gz

### Make a new initrd
->cat rootfs.gz modulesRT.gz > coreRT.gz

### Copy the initrd where the bootloader can find it.
->cp coreRT.gz image/iso/boot

######################## Build the ISO ##############################################################
->cd image
->sudo chmod 755 iso

### isolinux.cfg hasn't changed we are still using core.gz and vmlinuz as rootfs and kernel
->xorriso -as mkisofs -iso-level 3 -full-iso9660-filenames -volid tinycoreRT \
        -eltorito-boot boot/isolinux/isolinux.bin -boot-load-size 4 \
        -eltorito-catalog boot/isolinux/boot.cat -boot-info-table \
        -no-emul-boot -output <tinycore iso name> iso
       
### DONE! Boot .iso file
« Last Edit: April 21, 2020, 12:54:52 PM by pditty »

Offline pditty

  • Newbie
  • *
  • Posts: 19
Re: [Solved] Instructions on updating TinyCore 11 to Real Time?
« Reply #25 on: April 21, 2020, 03:55:46 PM »
Another question....

I have an x86_64 app that I built in Ubuntu 18.04 and copied to the rootfs before compressing.  I can see the executable in TC but when I try to run it I get...

sh: ./test: not found

On ubuntu this is what the file looks like....

$file test
test: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 3.2.0, BuildID[sha1]=d42cc427dd007288259a8ece5ae803633471a8a2, with debug_info, not stripped



Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11630
Re: [Solved] Instructions on updating TinyCore 11 to Real Time?
« Reply #26 on: April 21, 2020, 04:19:06 PM »
Hi pditty
Based on your reply #24 you are running 32 bit. You can't run a 64 bit app on a 32 bit system.

If you are actually running a 64 bit system, maybe the app isn't marked as being executable:
Code: [Select]
chmod 775 app

Offline xor

  • Hero Member
  • *****
  • Posts: 1268
Re: [Solved] Instructions on updating TinyCore 11 to Real Time?
« Reply #27 on: April 22, 2020, 05:48:24 AM »
As a TCL-RT project, are you considering adding it to official distributions!?

In terms of performance, it should not be forgotten that there are many low system users.

Offline pditty

  • Newbie
  • *
  • Posts: 19
Re: [Solved] Instructions on updating TinyCore 11 to Real Time?
« Reply #28 on: April 22, 2020, 07:36:02 AM »
Rich,  I converted my instructions to use 64-bit and my app still doesn't run.  It's almost like it doesn't exist.

I get this if I try to run it even though it's there (NOTE: App was built in Ubuntu as well).
tc@box:/home$ ./test
sh: ./test: not found




Here are the 64-bit instructions (directory structure mentioned in post #24 is still the same).

############################ Create the Image directory #########################
->cd image
->sudo ./tinycore-extract.sh <image iso name OR TinyCorePure64-current.iso by default>
->cd iso/boot
->sudo rm corepure64.gz vmlinuz64
->cd ../../../

############################  Compile The Kernel#####################################
### Only install these if you don't have them already
->sudo apt-get install zsync -y
->sudo apt-get install squashfs-tools
->sudo apt-get install -y xorriso

### Get the patched Tinycore kernel and Real time patch
->wget http://tinycorelinux.net/11.x/x86_64/release/src/kernel/config-5.4.3-tinycore64
->wget http://tinycorelinux.net/11.x/x86_64/release/src/kernel/linux-5.4.3-patched.txz
->wget https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patch-5.4.3-rt1.patch.xz
->tar xf linux-5.4.3-patched.txz
->cd  linux-5.4.3

###Clean the Kernel, just in case
->make mrproper

###Patch the Kerenl with the Real time extension
->xzcat ../patch-5.4.3-rt1.patch.xz | patch -p1

### Start with the most recent config file.
->cp ../config-5.4.3-tinycore64 .config

### Merge the old .config with the real time patch features
->make oldconfig

#### Enter #4 for FULLY PREEMPT, everything else is default

### OPTIONAL: Make your changes to the kernel
->make menuconfig

### OPTIONAL: Save Kernel Config as a starting point for next time.
->cp .config ../config-5.4.3-tinycore64RT-rev1

### Compile the kernel
->make -j 2 bzImage

### Copy the kernel where the bootloader can find it in the image directory
->sudo cp arch/x86_64/boot/bzImage ../image/iso/boot/vmlinuz64

### Compile modules
->make -j 2 modules

### Place the modules in a temporary directory
->make INSTALL_MOD_PATH=../modules/usr/local modules_install
->cd ../

### OPTIONAL: Backup modules.alias, modules.builtin, modules.dep, modules.order, and modules.symbols files just in case
->mv modules/usr/local/lib/modules/5.4.3-rt1-tinycore64/modules.* backup/

### Remove the 2 uneccessary symlinks in modules/usr/local/lib/modules/5.4.3-rt1-tinycore
->rm modules/usr/local/lib/modules/5.4.3-rt1-tinycore64/build
->rm modules/usr/local/lib/modules/5.4.3-rt1-tinycore64/source


######################### Set up sorter.sh to package all the modules.  ###############################
->cd sorter/sorter-master

### Create the Tinycore module packages and leave them in the current directory.
->sudo ./sorter.sh 5.4.3-rt1-tinycore64 ../../modules

### Back to the working directory.
->cd ../../

### Fetch a 64 bit root file system.
->wget http://tinycorelinux.net/11.x/x86_64/release/distribution_files/rootfs64.gz

####################### OPTIONAL: If you need to add something to the rootfs #########################
->mkdir initrd
->cp rootfs64.gz initrd
->zcat rootfs64.gz | sudo cpio -i
->sudo rm rootfs64.gz

### CP files to the directory and change permissions if needed
->sudo cp ../../mw_test/mw_test ../../mw_test/tmw_daemon home
->sudo chmod 777 home/mw_test home/tmw_daemon

### Zip up the rootfs again.
->sudo rm ../rootfs64.gz
->sudo find . | sudo cpio -o -H newc | gzip > ../rootfs64.gz
######################################################################################################

### Copy the module archive to the working directory
->cp sorter/sorter-master/modules64.gz modules64_RT.gz

### Make a new initrd
->cat rootfs64.gz modules64_RT.gz > core64RT.gz

### Copy the initrd where the bootloader can find it.
->cp core64RT.gz image/iso/boot/corepure64.gz

######################## Build the ISO ##############################################################
->cd image
->sudo chmod 755 iso

### isolinux.cfg hasn't changed we are still using core.gz and vmlinuz as rootfs and kernel
->xorriso -as mkisofs -iso-level 3 -full-iso9660-filenames -volid tinycoreRT \
        -eltorito-boot boot/isolinux/isolinux.bin -boot-load-size 4 \
        -eltorito-catalog boot/isolinux/boot.cat -boot-info-table \
        -no-emul-boot -output <tinycore iso name> iso
       
### DONE! Boot .iso file




Offline pditty

  • Newbie
  • *
  • Posts: 19
Re: [Solved] Instructions on updating TinyCore 11 to Real Time?
« Reply #29 on: April 22, 2020, 07:38:26 AM »
XOR, I hadn't considered it, what would be involved?

As a TCL-RT project, are you considering adding it to official distributions!?

In terms of performance, it should not be forgotten that there are many low system users.