WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: IBM ThinkPad 560Z Core Project Pentium II  (Read 4168 times)

Offline linic

  • Newbie
  • *
  • Posts: 18
IBM ThinkPad 560Z Core Project Pentium II
« on: August 13, 2023, 05:16:54 PM »
I read somewhere on the internet that old hardware does not die, it only gets more difficult to support over time.

I plan to post the workarounds I found to support the 560Z with Core Linux. There are links to the original documentation throughout my post. This is a digest of all the bits and pieces I found here and there.

I found this IBM ThinkPad 560Z PII Mobile 233 @ 300 MHz with 64 MB RAM years ago. The lid is cracked as if a brick fell on it, but all the rest is in a great condition. RAM can be expanded as there is a free slot, but the RAM itself is hard to find at a price that makes sense for this project.

According to the sticker under it, this 560Z was made in Mexico on 10/98, so October 1998. It is close to 25 years old now.

With this low quantity of RAM, I went with the Core version that has only a terminal.

The 560Z doesn't have a CD-ROM drive and I don't have an external floppy to connect to it. To workaround this, I'm using an IDE to USB adapter. That way I can more easily flash the drive with the image I want.

To make a working image to flash on the drive, there are steps in this other post about the ThinkPad 600X: http://forum.tinycorelinux.net/index.php/topic,22583.msg170008.html#msg170008

I made my image by connecting the IDE drive to my 2012 laptop running Debian 12  and using the command
Code: [Select]
sudo dd if=/dev/sd<replace> of=core14.dd conv=sync,noerror bs=512M count=3 status=progressYou'll need to find your drive with
Code: [Select]
sudo fdisk -l and you'll need to adapt the count=3 if you chose different partition sizes than me.

Once you have your image, you can either write it to another IDE drive or go on and use the current IDE drive in the 560Z. Check that it boots and check
Code: [Select]
sudo ifconfig eth0 to see if the network card gets its IP address.

For an unknown reason, the 560Z doesn't always gets its IP address on its own after rebooting. When it doesn't find its IP and you know your network you can use the following commands:
Code: [Select]
sudo ifconfig eth0 192.168.0.180
sudo route add default gw 192.168.0.1
sudo cat /etc/resolv.conf
sudo echo "nameserver 1.1.1.1" > /etc/resolv.conf
Adjust the IP addresses here to your network configuration! ifconfig sets a static IP, route adds the default gw which is used to get to addresses on the internet. cat /etc/resolv.conf shows you if you have a name server/DNS server to resolve hostnames. In my case, it was empty, so I added 1.1.1.1 which is the cloudflare name server. Feel free to replace with another one you wish to use. I read here (https://www.cyberciti.biz/faq/howto-linux-bsd-unix-set-dns-nameserver/) that you can add up to 3 name servers.

Next thing I adjusted is the resolution. vga=788 is good with the 560Z. I didn't find a way to edit the extlinux.conf while the 560Z is running so I did sudo poweroff disconnected the power cable and pulled the IDE drive out to connect it again to my Debian machine. Debian mounted the drive automatically and I went to /mnt/<replace with your mount point>/tce/boot/extlinux/ and then did a
Code: [Select]
sudo vim extlinux.confand changed the file to this (for context, I'm giving the whole file. Read on to see the exact lines I changed...):
Code: [Select]
UI vesamenu.c32
MENU TITLE Tiny Core Bootloader
TIMEOUT 1

DEFAULT core
LABEL core
KERNEL /tce/boot/vmlinuz
INITRD /tce/boot/core.gz
APPEND vga=788 syslog showapps tce=UUID="3541ff21-9683-4df0-9ecd-a5a3fce0014c" swapfile=UUID="a53d3aa0-1607-44a2-8c43-bf71d35edf59"

LABEL unknown
MENU LABEL Unknown OS
COM32 chain.c32
APPEND boot 1
I changed this line:
Code: [Select]
TIMEOUT 1 which had value 100 to wait 10 seconds on the OS selection screen at bootup which I don't need as I always want to boot in Core Linux on the 560Z since it is the only OS.
I also changed this line:
Code: [Select]
APPEND vga=788 syslog showapps tce=UUID="3541ff21-9683-4df0-9ecd-a5a3fce0014c" swapfile=UUID="a53d3aa0-1607-44a2-8c43-bf71d35edf59"Originally, right after the tc-install.sh I had this:
Code: [Select]
APPEND quiet vga=normal syslog showapps waitusb=5 tce=sda1 waitusb=5:UUID="d39a00cb-d63f-470e-8c46-0bdbd1db2d6f" tce=UUID="d39a00cb-d63f-470e-8c46-0bdbd1db2d6f"I was confused why waitusb and tce= appeared twice so I went to the core book: http://tinycorelinux.net/book.html
It is pretty clear so search the flags and read the paragraphs they appear in you'll understand what's happening.
I tested and found out I didn't need waitusb=10 so I removed it. I initially thought that increasing waitusb would help my network adapter get its IP automatically, but after testing various values, it didn't improve that so I removed it and everything else was fine. I also removed waitusb=10:UUID="d39a00cb-d63f-470e-8c46-0bdbd1db2d6f" because my partition is on the IDE drive, not a USB drive.

I noticed tce=sda1 and tce=UUID="d39a00cb-d63f-470e-8c46-0bdbd1db2d6f" and the tce=sda1 is redundant see the Core book to understand why. I kept only tce=UUID=, but I changed the UUID to "3541ff21-9683-4df0-9ecd-a5a3fce0014c". Read on to know why.

You'll see I added swapfile=UUID="a53d3aa0-1607-44a2-8c43-bf71d35edf59", read the Core book to know more. Note that you may not need this. I partitionned my IDE drive this way:
1. First primary partition about 1 GB which has everything to boot Core Linux. UUID="d39a00cb-d63f-470e-8c46-0bdbd1db2d6f"
2. Second primary partition which contains most of the space of the IDE drive. UUID="3541ff21-9683-4df0-9ecd-a5a3fce0014c"
3. Third and last primary partition which is formatted as a swap partition. UUID="a53d3aa0-1607-44a2-8c43-bf71d35edf59"
I partitioned the drive using gparted in on Debian machine.

Once this was all done, I inserted the IDE drive again in the 560Z, plugged the power and turned it on. All was working great so went on.

If you are curious to look at the swaps usages:
Code: [Select]
cat /proc/meminfo
cat /proc/swaps
I found those commands here: https://unix.stackexchange.com/questions/23072/how-can-i-check-if-swap-is-active-from-the-command-line

I wanted to test the internet connection more so I tried curl. Get it using:
Code: [Select]
tce-load -wi curl.tczYou'll see it installs also curl.tcz, ca-certificates.tcz and openssl-1.1.1.tcz. That's nice as it looks like https will work well! Once the install completes, you can try to curl some websites you care about:
Code: [Select]
curl google.com/will print some html formatted text to the terminal. That command sends an HTTP GET to the website you give it. It can do more than that. You'll see in its manual.

Next, I wanted tmux as 1 terminal is good, but n terminals is great!
Code: [Select]
tce-load -wi tmux.tczOnce the install completed, I tried to run tmux and it told me it couldn't start because the locale wasn't set correctly because the locale was set to ANSI-something-1968. So by reading this post http://forum.tinycorelinux.net/index.php/topic,23825.0.html, the Core Book and http://tinycorelinux.net/14.x/x86/tcz/getlocale.tcz.info I decided to run
Code: [Select]
tce-load -wi getlocale.tczand once it was installed I ran
Code: [Select]
sudo getlocale.shand then I was confused by this
Code: [Select]
cp: can't stat '/tmp/mylocale.tcz': No such file or directory
md5sum: can't open 'mylocale.tcz': No such file or directory
Done. The extension is at /mnt/sda2/tce/optional/mylocale.tcz and in onboot.lst
du: /mnt/sha2/tce/optional/mylocale.tcz: No such file or directory
sh: bad number
Reboot with lang=xyz (for example lang=fr_CA.UTF-8) to start using this.
Press enter to quit.
I found that /mnt/sha2/tce/optional/mylocale.tcz didn't exist. So I thought, meh, 64 MB of RAM even with the swap partition, maybe something goes wrong and the file doesn't get written. I turned off the laptop removed the IDE drive and put it in the 600X to run the getlocale.sh again. There it worked. So once that was done, I turned off the 600X and connected again the drive to my Debian to add the flag
Code: [Select]
lang=fr_CA.UTF-8. Replace it with the locale you chose when running getlocale.sh if your following my steps. I put the drive back in the 560Z. When the 560Z finished booting, the locale got set correctly and tmux works now.

That's it for now.

Special thanks to Curaga for getlocale.tcz and to juanito, cheslavic and Nicholas Marriott for tmux.tcz

If anyone appears to know a place in Montréal, Canada where I could shop for a used and working 64MB RAM module (60 ns, non-parity, 3.3 volt, 144Pin EDO) under 20$ CAD I am interested.

Offline polikuo

  • Hero Member
  • *****
  • Posts: 714
Re: IBM ThinkPad 560Z Core Project Pentium II
« Reply #1 on: August 13, 2023, 06:14:00 PM »
I didn't find a way to edit the extlinux.conf while the 560Z is running so I did sudo poweroff disconnected the power cable and pulled the IDE drive out to connect it again to my Debian machine.
Hi, linic.
Welcome to the forum.
You can edit the file directly with vi instead of vim.
Code: [Select]
vi /mnt/sda1/tce/boot/extlinux/extlinux.conf
Quote
Code: [Select]
UI vesamenu.c32
MENU TITLE Tiny Core Bootloader
TIMEOUT 1

DEFAULT core
LABEL core
KERNEL /tce/boot/vmlinuz
INITRD /tce/boot/core.gz
APPEND vga=788 syslog showapps tce=UUID="3541ff21-9683-4df0-9ecd-a5a3fce0014c" swapfile=UUID="a53d3aa0-1607-44a2-8c43-bf71d35edf59"

LABEL unknown
MENU LABEL Unknown OS
COM32 chain.c32
APPEND boot 1
If you're sure that TC is the only system on your drive, remove the "Unknown OS" entry.
Syslinux automatically boot to default OS if there's only one option available.
This section alone will do. You won't need UI, MENU TITLE, TIMEOUT
Code: [Select]
DEFAULT core
LABEL core
KERNEL /tce/boot/vmlinuz
INITRD /tce/boot/core.gz
APPEND ...

Quote
I was confused why waitusb and tce= appeared twice
You probably filled in those value during the installation.
The later value will replace the previous, so it doesn't really matter.
The boot code waitusb tells TC to wait until the drive is visible to load extensions and the backup
Anything beyond that is irrelevant.

Quote
You'll see I added swapfile=UUID=...
That's not exactly the way swapfile work.
The swapfile is the alternative when you forgot to make a swap partition or the size is too small.
It slower by nature and you have to manually make a swapfile, a file, for it to work properly.
Since you already have your third partition as swap partition, you can drop that line completely and let the kernel do its job.
BTW, you should reset the UUID value of your tce variable so TC won't have to figure it out itself.
To find out the proper value (assuming you have your tce in sda1)
Code: [Select]
blkid /dev/sda1
Quote
I decided to run
Code: [Select]
tce-load -wi getlocale.tcz
You can remove getlocale.tcz from your onboot.lst
It's one time only operation.

Offline linic

  • Newbie
  • *
  • Posts: 18
Re: IBM ThinkPad 560Z Core Project Pentium II
« Reply #2 on: August 15, 2023, 04:39:35 PM »
Thanks polikuo! I really appreciate your tips!  :D

I'll test those in the next couple of days and I'll update my original post to correct my mistakes.

You're right, I added tce=sda1 at install time. What I found surprising is the tce=UUID="3541ff21-9683-4df0-9ecd-a5a3fce0014c" that was automatically added. I guess that's because the installer found the UUID and filled it automatically.

Thanks about the reminder that swap partition and swap file are two different things. I didn't know that the swap partition is faster than a swap file, that's nice!

I want to install my extensions in the larger partition which is the second one. That's why I changed the tce=UUID=. So far, it looks good. I see everytime I tce-load -wi something.tcz, it is written to sda2 which is what I want.

sda1 (1 GB) contains the required files to boot, sda2 (~490 GB) the extensions I add with tce-load and sda3 (3 GB) is the swap partition. I also consider sda2 as "the place where I'll put any other raw data I might want to work with" later (kind of like a home folder in Debian).

Offline polikuo

  • Hero Member
  • *****
  • Posts: 714
Re: IBM ThinkPad 560Z Core Project Pentium II
« Reply #3 on: August 15, 2023, 06:25:31 PM »
sda1 (1 GB) contains the required files to boot, sda2 (~490 GB) the extensions I add with tce-load and sda3 (3 GB) is the swap partition. I also consider sda2 as "the place where I'll put any other raw data I might want to work with" later (kind of like a home folder in Debian).

That's great, I see you have plenty of room for storage.
Just saying, you can hack around the boot code to make your "/home" directory stays on a hard drive.
It's slower, but it saves RAM.
I sometimes do that for machines with RAM under 1G.
Read the book for more information if you are interested.
You'll need to edit /opt/.filetool.lst

Offline linic

  • Newbie
  • *
  • Posts: 18
Re: IBM ThinkPad 560Z Core Project Pentium II
« Reply #4 on: August 19, 2023, 12:02:38 PM »
I can't edit my original post. Since we can quote posts, it makes sense that they are immutable. I have all that I changed from my original post and what I tested in this new post.

Locating extlinux.conf when sda1 is not mounted automatically
I wasn't able to see the extlinux.conf file last time I tried because /mnt/sda1 was empty. I realized that I needed to
Code: [Select]
sudo mount /dev/sda1
I am able to see the files now and to edit them using vi.

Editing extlinux.conf
I was able to try your suggestion to keep only 1 entry in extlinux.conf as I only have Core Linux. It works well!
I removed the swapfile=UUID= from my extlinux.conf since I have a swap partition which is different than a swap file. The swap partition on sda3 mounts automatically as you said. I'm happy that Core could boot even if that boot code was wrong.

My extlinux.conf looked like this at this point:
Code: [Select]
DEFAULT core 
LABEL core 
KERNEL /tce/boot/vmlinuz 
INITRD /tce/boot/core.gz 
APPEND vga=788 syslog showapps tce=UUID="3541ff21-9683-4df0-9ecd-a5a3fce0014c" lang=fr_CA.UTF-8

Locating onboot.lst when tce= refers to sda2
I looked at /mnt/sda1/onboot.lst and it was there, but empty.
Then, I looked at /mnt/sda2/tce/oboot.lst and getlocale.tcz was there so I removed it.

USB to ethernet adapter behavior
Another thing I found is that there's a way to make eth0 automatically detect the network. I boot from the 600X and turn it off. Then, I put the drive back in the 560Z and it consistently detects the network automatically. I'm not sure why, but as long as I don't open the BIOS on the 560Z, eth0 (which is a 10/100 USB to ethernet adapter) continues to obtain its IP, gateway and name servers automatically. If I open the BIOS of the 560Z and boot, it seems to lose that capability and I need to configure the network manually.

Configuring a persistent home and opt
I found chapter 7.2 "Persistent home/opt" which gives the following warning "every write to these locations will then go directly to the device, so unless the device is a hard drive, you’ll need to weigh on how often it is written" which is alright for my current setup. I was looking to put home on my sda2 and since the section describes also opt, I went on and made that one go to sda2 also.

My 1st try at using what's described in chapter 7.2 was a MISTAKE for the 560Z
Read this section if you want to avoid my mistakes. Skip to My 2nd try which worked and appears later in this post.
I thought that I could make 2 new partitions and add a boot code for home and opt similar to the following:
Code: [Select]
home=UUID="3e89f24e-78a3-431e-b1f3-5776363a919b" opt=UUID="b803c5f8-7b87-4bc7-9a21-0a9ccb47f0dc"I made sda2 smaller, created an sda4 extended partition and within it created sda5 for home and sda6 for opt.
The end result is:
1. sda1 (primary) for boot at 1 GB
2. sda2 (primary) for tce at ~160 GB
3. sda4 (extended)
3.a. sda5 for home at ~160 GB
3.b. sda6 for opt at ~160 GB
4. sda3 for swap at 3 GB
I list the partitions in this order because that is how gparted displayed them. I did create the extended partition within the space between sda2 and sda3.

My APPEND line in my extlinux.conf looked like this
Code: [Select]
APPEND vga=788 syslog showapps tce=UUID="3541ff21-9683-4df0-9ecd-a5a3fce0014c" home=UUID="3e89f24e-78a3-431e-b1f3-5776363a919b" opt=UUID="b803c5f8-7b87-4bc7-9a21-0a9ccb47f0dc" lang=fr_CA.UTF-8
When I booted the 560Z, I waited something like 30 to 60 seconds and a message got displayed saying there was no operating system.

My 2nd try worked
I edited my partitions to go back to this:
1. sda1 (primary) for boot at 1 GB
2. sda2 (primary) for tce at ~490 GB
3. sda3 (primary) for swap at 3 GB
and I changed my APPEND line to this:
Code: [Select]
APPEND vga=788 syslog showapps tce=UUID="3541ff21-9683-4df0-9ecd-a5a3fce0014c" home=UUID="3541ff21-9683-4df0-9ecd-a5a3fce0014c" opt=UUID="3541ff21-9683-4df0-9ecd-a5a3fce0014c" lang=fr_CA.UTF-8
Now, home, opt and tce are all on the sda2 partition which has UUID 3541ff21-9683-4df0-9ecd-a5a3fce0014c in my case.

When I booted the 560Z I could confirm by cd /mnt/sda2 that home, opt and tce folders are there now.

Adjusting the .filetool.lst
Then, I checked .filetool.lst which is at /mnt/sda2/opt/.filetool.lst for me. Using
Code: [Select]
sudo vi .filetool.lstI found these two lines
Code: [Select]
opt
home
At the end of chapter 7.2, "you need to remove the corresponding directory from /opt/.filetool.lst. Otherwise it is both backed up and stored directly, removing any benefits of either". So, I removed opt and home from .filetool.lst.

This is it for now.

Thank you polikuo! You gave me very good tips! I appreciate very much :)

Offline CardealRusso

  • Full Member
  • ***
  • Posts: 160
Re: IBM ThinkPad 560Z Core Project Pentium II
« Reply #5 on: August 19, 2023, 01:46:40 PM »
On a related note...UUID and LABEL don't work with pretce or am I doing something wrong?

Offline linic

  • Newbie
  • *
  • Posts: 18
Re: IBM ThinkPad 560Z Core Project Pentium II
« Reply #6 on: August 20, 2023, 03:24:39 AM »
I haven't tried this boot code. Interestingly, I can't find any reference in the core book or in the forum, but it is documented in the wiki: http://wiki.tinycorelinux.net/doku.php?id=wiki:pretce
At one point it states "The format of this [boot code] entry will depend on the bootloader you are currently using."
I haven't seen examples of pretce with a UUID anywhere. I found the thread where gerald_clark posted that he created the wiki page (reply#3): http://forum.tinycorelinux.net/index.php/topic,16927.msg101433.html#msg101433
maybe you will have better chance of finding an answer or hints to it there.

Offline CardealRusso

  • Full Member
  • ***
  • Posts: 160
Re: IBM ThinkPad 560Z Core Project Pentium II
« Reply #7 on: August 20, 2023, 05:52:01 AM »
I can't find any reference in the core book
yes pretce doesn't have good documentation.
it seems like a maze to make it work, since the function find_mountpoint(), which is responsible for finding the disk through the UUID or LABEL sets the MOUNTPOINT variable instead of simply returning the mountpoint... And I assume that MOUNTPOINT is already, somehow, being used during pretce, which would be inconvenient to define it again.

https://github.com/tinycorelinux/Core-scripts/blob/783944e165d4a12ae4815b362261e95a3e39f44d/etc/init.d/tc-functions#L97

Offline linic

  • Newbie
  • *
  • Posts: 18
Re: IBM ThinkPad 560Z Core Project Pentium II
« Reply #8 on: September 04, 2023, 04:17:03 AM »
Rust on PII
There is a rust.tcz extension available tce-load -wi rust.tcz, but it it throws an illegal operation when trying rustc --version on my 560Z or on my 600X. The illegal operation comes from opcodes that do not exist on PII. The solution is to build the rust toolchain programs without the invalid opcodes.

Great thanks to Adam that wrote this article https://ww1.thecodecache.net/projects/p2-rust/. Without his help, I may not have reached this point.

You may have to adjust some settings or to install more packages than me. I may have missed some details that made this work on my machine. Hopefully, the steps here will be enough for you to find your way.

DISCLAIMER: I got close to building programs in rust on the 560Z, but I'm hitting the 64 MB of RAM memory limit when running "cargo run" or when having my custom "rust-1.71.1-pii.tcz" loaded automatically via "onboot.lst". I tried to load it manually with "tce-load -i rust-1.71.1-pii.tcz" after booting since I have a 3 GB swap partition and I got an out of memory error displayed in the terminal. Since the "tce-load" seemed to have done something, I tried "rustc --version" and "cargo --version" worked. Then, I tried "cargo new hello-world-3" which worked. then, "cd hello-world-3" and "cargo run". I saw the drive LED flash intensely. The build of a simple program like the default "Hello world!" that cargo gives you won't build with only 64 MB of RAM. I am not sure if it would work with 128 MB of RAM. The 560Z can be upgraded to that. I even saw 128 MB RAM dimms available and maybe that could bring the RAM to 196 MB, but I can't try it as I don't have those parts. Still, if you compile a rust program with the compiler built from the instructions here, the compiled programs will run on the 560Z. I built an "Hello World!" program on my 600X and it ran fine on the 560Z. Happy reading!

Setting Up a Build Environment
My build environment is an FX9590/a 2TB Samsung SATA SSD (iirc it's a QVO model)/32GB RAM(I don't think the RAM amount matters much as long as you have 8 GB, I think it should be fine)/Debian 11 x64. The time to compile is about 1 hour 45 minutes when I use the 8 cores.

I needed to install several packages:
Code: [Select]
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install build-essential cmake gcc gcc-multilib g++ g++-multilib git lib32z1 zlib1g-dev zlib1g-dev:i386 libssl-dev libssl-dev:i386 openssl curl ninja-build python3
Note that I installed some dependencies twice. For example, zlib1g-dev zlib1g-dev:i386. The first is the x64 version and the last is the x86 version. When I only had the x64 version, the rust build would fail as it would search for the x86 which was not installed.

Code: [Select]
git clone https://github.com/rust-lang/rust
cd rust
git checkout stable
git submodule update --init --recursive
stable is at rust version 1.71.1 at time of writing.

Environment Variables
Code: [Select]
export CFLAGS="-march=pentium"
export CXXFLAGS="-march=pentium"
export RUST_BACKTRACE=full

config.toml and starting the build
Code: [Select]
./configure --set build.extended=true --set build.build=i686-unknown-linux-gnu --set build.host=i586-unknown-linux-gnu --set build.target=i586-unknown-linux-gnu --set llvm.cflags="-lz -fcf-protection=none" --set llvm.cxxflags="-lz -fcf-protection=none" --set llvm.ldflags="-lz -fcf-protection=none" --set llvm.targets=X86 --set llvm.download-ci-llvm=false
./x.py check
PKG_CONFIG_ALLOW_CROSS=1 ./x.py dist -j 8 2>&1 | tee date-time-rust-i586-build-log.txt
The x.py check is optional, but it may give you hints about missing dependencies before starting the full build. I use "-j 8" to use all my 8 CPU cores. You may use a smaller number than your max number of cores if you're doing something else while the build runs and you need some CPU time.
For some reason, I got an error that build.host=i586-unknown-linux-gnu and build.target=i586-unknown-linux-gnu were not of type sequence in the config.toml file. I opened it using vim config.toml and added brackets [ ] around the values to get to
Code: [Select]
host = ['i586-unknown-linux-gnu']
target = ['i586-unknown-linux-gnu']
there's probaly a way to change the ./configure arguments so that a sequence gets set in the config.toml correctly.

Once the build is complete, you should have several .tar.gz files at rust/build/dist. You want rust-1.71.1-dev-i586-unknown-linux-gnu.tar.gz. You can extract it using tar -xf and you should be able to see that cargo and rustc are there along several other files.

Reaching the Hello World on the 600X
I didn't have enough memory to run mksquasfs on the 560Z. I put my drive in my 600X to work around this. You'll need to have the compiled rust-1.71.1-dev-i586-unknown-linux-gnu.tar.gz available on an ftp on your local network or you'll need some other means of transferring it to the computer. In my case
Code: [Select]
ftpget -v -u replace_with_your_ftp_user -p replace_with_your_ftp_user_password replace_with_your_IP-192.168.0.155 rust-1.71.1-dev-i586-unknown-linux-gnu.tar.gz
md5sum rust-1.71.1-dev-i586-unknown-linux-gnu.tar.gz
tar -xf rust-1.71.1-dev-i586-unknown-linux-gnu.tar.gz
mkdir rust-1.71.1-i586
mkdir rust-1.71.1-i586/etc
cd rust-1.71.1-dev-i586-unknown-linux-gnu
sudo sh ./install.sh --verbose --destdir=/home/tc/rust-1.71.1-i586 --sysconfdir=/home/tc/rust-1.71.1-i586/etc
tce-load -wi squashfs-tools.tcz
mksquashfs rust-tcz rust-1.71.1-pii.tcz
sudo cp -v rust-1.71.1-pii.tcz /mnt/sda2/tce/optional/
sudo vi /mnt/sda2/tce/onboot.lst # and add rust-1.71.0-pii.tcz
sudo reboot
After the reboot, you should be able to run
Code: [Select]
rustc --version
cargo --version
cargo new hello-world
cd hello-world
cargo run
If you get an error that cc is missing install these
Code: [Select]
tce-load -wi gcc.tcz
tce-load -wi glibc_base-dev.tcz
because you need a C linker. Sites that helped me understand that: http://forum.tinycorelinux.net/index.php/topic,22216.msg139089.html#msg139089 and https://stackoverflow.com/questions/52445961/how-do-i-fix-the-rust-error-linker-cc-not-found-for-debian-on-windows-10

Rustlings on 600X
My plan was to make rustlings work on the 600X first and then move over to the 560Z. It didn't work, but read on to see where I got to. It might help you get further than me.
Code: [Select]
tce-load -wi git.tcz
git clone -b 5.5.1 --depth 1 https://github.com/rust-lang/rustlings
cd rustlings
cargo install --force --path .
At this point, I get
Code: [Select]
failed to download from https://index.crates.io/config.json
Caused by:
[60] SSL peer certificate or SSH remote key was not OK (SSL certificate problem: unable to get local issuer certificate)
So I went looking for the certificate chain with this command
Code: [Select]
openssl s_client -debug -showcerts -connect index.crates.io:443
My plan is to make a bas64 encoded .crt file of the certificates I see from that command and I should be able to put it somewhere in TC so that it gets trusted correctly. Interestingly, curl doesn't seem to mind the error when I try
Code: [Select]
curl https://index.crates.io/config.json
so it might just be cargo that is not looking at the right place... From the messages appearing at boot, I see that /usr/local/etc/ssl/certs seems to be the place where the trusted certificates get loaded. I'll try to find out more about how certificates get loaded. Another option is that cargo has its own trusted certificates...

I also tried
Code: [Select]
curl -L https://raw.githubusercontent.com/rust-lang/rustlings/main/install.sh -o install.sh
sh install.sh
but got an error that "rustup does not seem to be installed. Please download rustup using https://rustup.rs". That won't work because of the illegal operation issue.

Bonus
Fixing the clock
Code: [Select]
sudo date -s "2023-09-03 11:32:15"
sudo hwclock -w
This will work if you are in UTC. For other timezones, you may have to search to adjust those commands.

Avoid these Pitfalls
During my search, I tried things that didn't work. Read-on if you are interested.
1. DO NOT install gcc:i386 using apt. Or at least, carefully read what it is going to uninstall. I ended up uninstalling my desktop environment. Fortunately, I was able to reinstall everything on the stop using apt-get and didn't suffer any noticeable consequences.
2. DO NOT forget --set build.extended=true otherwise parts of the rust distribution will be missing. For me cargo and some standard packages were missing.
3. DO NOT use the other tar.gz files. They have install scripts, but they are missing enough files that you won't be able to create a new project or build. The best I got was a rustc that I couldn't do anything with except ask its version with rustc --version. At least it confirmed that the illegal operation was fixed.
4. DO NOT use export CFLAGS="-march=pentium2" or export CXXFLAGS="-march=pentium" and build.host=i686-unknown-linux-gnu and build.target=i686-unknown-linux-gnu. I understand (maybe wrongly so) that the Pentium II is a 686, but I got illegal operation errors building with a compiler built like this.

Thanks!
Again, great thanks to Adam that wrote this article https://ww1.thecodecache.net/projects/p2-rust/

Thanks for chapter 14 and 15 of the Core Book which helped me create my custom rust-1.71.1-pii.tcz extension.

Thanks to juanito for gcc.tcz (http://tinycorelinux.net/14.x/x86/tcz/gcc.tcz.info) and for glibc_base-dev.tcz (http://tinycorelinux.net/14.x/x86/tcz/glibc_base-dev.tcz.info)

This is it for now!

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: IBM ThinkPad 560Z Core Project Pentium II
« Reply #9 on: September 04, 2023, 06:38:12 AM »
Hi linic
... since I have a 3 GB swap partition and I got an out of memory error displayed in the terminal. ...
Just a few of points on swap:
1. If you need to rely on swap to run, your machine will likely slow down
   due to data constantly being shuffled between RAM and swap.

2. This will only work as long as there is something in RAM that the system
   can temporarily do without. If you reach a point where everything
   that's in RAM is still needed, no amount of swap will save you.

3. Some things can't be swapped, such as the kernel, drivers, and the initrd
   which is the RAM based section of the file system to name a few. That's
   why a persistent /home and /opt are good choices in these cases.

You can try freeing up more RAM with this boot code:
Code: [Select]
nozswapIf you look in  /etc/init.d/tc-config  you'll find the following:
Code: [Select]
        grep MemFree /proc/meminfo | awk '{print $2/4 "K"}' > /sys/block/zram0/disksize

        mkswap /dev/zram0 >/dev/null 2>&1
That's the system taking 1/4 of your free RAM and using it for swap space.

Offline linic

  • Newbie
  • *
  • Posts: 18
Re: IBM ThinkPad 560Z Core Project Pentium II
« Reply #10 on: September 10, 2023, 04:12:21 AM »
Thanks Rich! Those are good points! My current boot options are
Code: [Select]
APPEND vga=788 syslog showapps tce=UUID="3541ff21-9683-4df0-9ecd-a5a3fce0014c" home=UUID="3541ff21-9683-4df0-9ecd-a5a3fce0014c" opt=UUID="3541ff21-9683-4df0-9ecd-a5a3fce0014c" nozswap lang=fr_CA.UTF-8
Even with those, I didn't have enough RAM to tce-load my custom tgz. I found another way to make rust and rustlings work on 560Z though.

Working with 64 MB of RAM
I got the idea of not loading my custom rust-1.71.1-i586.tgz. Before creating the tgz, I had to install rust to a folder. I decided to add the executables nested in that folder to my PATH.
Code: [Select]
export PATH=/home/tc/rust-1.71.1-i586/usr/local/bin:$PATH
That went well and I can now run rustc --version and cargo --version.

Getting and Trusting more Certificates
I tackled the SSL error 60 from the cargo install --force --path . preventing me to install rustlings by downloading the certificates and making my own .crt file.
Code: [Select]
mkdir /home/tc/certificates
cd /home/tc/certiticates
openssl s_client -showcerts index.crates.io:443 2>&1 | sed --quiet '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > index.crates.io.all.crt
sudo cp -v index.crates.io.all.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
cd /home/tc/rustlings
cargo install --force --path .
It was still failing, but then I found https://users.rust-lang.org/t/unable-to-update-my-cargo-package-ssl-error/5157/5
Code: [Select]
export SSL_CERT_FILE=/usr/local/share/ca-certificates/index.crates.io.all.crt
cargo install --force --path .
I got past the failed to download from https://index.crates.io/config.json error. Next, I got stuck on another SSL 60 error, but with this new URL: https://crates.io/api/v1/crates/aho-corasick/1.0.5/download
I got the certificates for crates.io
Code: [Select]
cd /home/tc/certificates
openssl s_client -showcerts crates.io:443 2>&1 | sed --quiet '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > crates.io.all.crt
cp index.crates.io.all.crt cargo.all.crt
cat crates.io.all.crt >> cargo.all.crt
export SSL_CERT_FILE=/home/tc/certificates/cargo.all.crt
cd /home/tc/rustlings
cargo install --force --path .
Then, I got the SSL 60 error again. So I thought, maybe I need to add it to /usr/local/share/ca-certificates/ and update-ca-certificates again...
Code: [Select]
sudo cp -v /home/tc/certificates/cargo.all.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
cargo install --force --path .
To my surprise I got again the same SSL 60 error... I inspected the cargo.all.crt file with less and all looked great. I did cargo install --force --path . again and then it started to work... I don't know maybe something needed some time to refresh itself...?

Installing rustlings on the 560Z with 64 MB of RAM
The install downloaded 43 creates (3.5 MB) in 48.69 seconds. There were 57 dependencies to build. It took 5 hours. After that, I had to
Code: [Select]
export PATH=/home/tc/.cargo/bin:$PATH
rustlings
and rustlings would display its "welcome to..." screen which fits on my 560Z screen.

I wrote a source file
Code: [Select]
vi add-rust-paths.source
export PATH=/home/tc/rust-1.71.1-i586/usr/local/bin:/home/tc/.cargo/bin:$PATH
source ./add-rust-paths.source
So that I can easily edit my PATH when I want to use rust and rustlings.

Going through the exercises
Code: [Select]
cd /home/tc/rustlings
rustlings watch
I tried an horizontal split screen in tmux (CTRL+B+"). To my surprise, this works well! My two consoles are in /home/tc/rustlings/exercises. The top one has rustlings watch running and I use the bottom one to edit the code.

Note that:
exercises/intro/intro1.rs took about 30 seconds to build.
exercises/intro/intro2.rs took about 40 seconds to build.

Thanks!
Thanks to misterpki.com for how to make a crt file from the outputs of openssl https://www.misterpki.com/openssl-s-client/
Thanks to ansible on this forum who gave me the SSL_CERT_FILE idea https://users.rust-lang.org/t/unable-to-update-my-cargo-package-ssl-error/5157/5
Thanks Jon and Thanh Nhan who refreshed my memory on how to load certificates with update-ca-certificates https://askubuntu.com/questions/935990/update-ca-certificates-0-added-0-removed-how-come

This is it for now!