Git Product home page Git Product logo

marmolak / gray386linux Goto Github PK

View Code? Open in Web Editor NEW
69.0 7.0 5.0 191.98 MB

Linux distribution for i386 machines only.

License: BSD 2-Clause "Simplified" License

Makefile 0.32% C 97.15% Assembly 2.08% Shell 0.14% C++ 0.07% Awk 0.01% sed 0.01% Python 0.03% GDB 0.01% Perl 0.12% Yacc 0.02% Lex 0.01% M4 0.01% Roff 0.02% UnrealScript 0.01% SmPL 0.01% Scilab 0.01% Classic ASP 0.01% XS 0.01% Raku 0.01%

gray386linux's Introduction

  _______ .______          ___   ____    ____  ____     ___      __   
 /  _____||   _  \        /   \  \   \  /   / |___ \   / _ \    / /   
|  |  __  |  |_)  |      /  ^  \  \   \/   /    __) | | (_) |  / /_   
|  | |_ | |      /      /  /_\  \  \_    _/    |__ <   > _ <  | '_ \  
|  |__| | |  |\  \----./  _____  \   |  |      ___) | | (_) | | (_) | 
 \______| | _| `._____/__/     \__\  |__|     |____/   \___/   \___/  
Linux for i386 machines

Gray386linux is a single-user, source-based (but binary build is provided) Linux distribution with tiny but current user space (busybox + musl). Main target is a real i386 net-booted machines with at least 8 MB RAM (should work even with 4 MB RAM - and it should work when net-boot is out of a game).

Used Linux kernel is 3.7.10 which should be last kernel directly support i386, however in reality some patching is needed to compile it. So I think that no one ever built/tested this kernel version for/on real i386.

Additional patches & features:

  • make kernel compilable - avoid some hard coded cmpxchg in kernel source code.
  • cmpxchg, xadd, bswap instruction emulator/simulator - currently I'm not able to force gcc to not emit them. Seems like lack of cmpxchg instruction is one of reasons why Linux dropped support for real i386.
  • Skip endbr32 instruction for user space - distributions started to use CET for gcc and even for libraries. endbr32 is handled as a multinop on i686 generations of CPUs (Pentium II for example) but they are not supported on real i386 (result is CPU exception which is handled by patch - not reproducible in QEMU). You can recompile gcc without support of CET which is one of reasons why Nix is involved.
  • Fix floppy issues - patches from Linux kernel 5.17 git.
  • Experimental support for ontrack disk manager partitions - ontrack moves real FAT to a different offset.
  • Provide Nix based build environment which allows build of Linux kernel with old gcc and perl.

Main goal of this tiny distribution is to be able to boot via network and be used to:

  • Deployment of preconfigured DOS disk images - you can prepare basic setup on virtual machine then move it on real hardware.
  • Play around with old hardware.
  • As a proof that, with some effort, it works & to learn some old/new stuff :).

Currently, it's not possible to run gray386linux on i486 machines (but it's possible to run gray386linux on Cyrix 486DLC and similar CPUs). Are you interested in Linux for i486 machines? Take a look at gray486linux. i486 machines are still able to run actual Linux kernel (2024).

NOTE FOR Pocket386 USERS!

Gray386linux runs on M6117 (386SX SOC), which is the heart of Pocket386. However, you need to add i8042.dumbkbd=1 to the kernel command-line interface to disable the handling of keyboard LEDs in order to make the internal keyboard work.

How to get a binary build?

It's easy. Just take a look at bin directory.

Two versions of build has been cancelled because fpu version doesn't add load of bytes (~24 KB) and works on both (non fpu & fpu) machines.

NOTE: gray386linux is mainly source based distribution so binaries can be older than current configuration.

How to build a gray386linux

Tested build environments:

  • Fedora 40 with Nix installed.
  • NixOS 23.11.
  • Docker/podman container.

11. Decide how to build

If you want just default build, and you have installed make and bash then you can just type make in src directory. You are done and GOTO 100. But if you don't like make, you can just type ./graybuild.sh in src directory. In both cases, results will be placed in results directory.

In case you want to make some changes then follow next steps.

20. Get num of cpus

Nix-shell scripts take handle of it.

If you don't want to use nix-shell, just type:

export GR_CPUS=$(nproc --all)

28. Get kernel headers with nix-shell

cd src/build-kernel-env-with-nix/

nix-shell --pure

28. Install kernel headers

make headers_install ARCH=i386 INSTALL_HDR_PATH=../gray386/

29. Leave nix-shell

exit

30. Build user env with nix-shell

cd src/build-env-with-nix/

nix-shell --pure

40. Build musl libc

CFLAGS="$CFLAGS -I$(realpath "${PWD}/../gray386/include")" ./configure --target=i386 --prefix=$(realpath "${PWD}/../gray386/")

make -j"$GR_CPUS"

make install

50. Build busybox

(optional) make menuconfig

make -j"$GR_CPUS"

make install

51. (optional) Build dropbear SSH client (+~266 K)

autoconf; autoheader

CC="$(realpath $PWD/../gray386/bin/musl-gcc)" ./configure --enable-static --enable-bundled-libtom --disable-syslog --disable-harden --disable-zlib --disable-shadow --disable-utmp --disable-utmpx --disable-wtmpx --disable-loginfunc --prefix="$(realpath $PWD/../gray386/_install/)"

make -j"$GR_CPUS"

strip dbclient

cp dbclient ../gray386/_install/bin

59. Leave nix-shell

exit

60. Build kernel with nix-shell

cd src/build-kernel-env-with-nix/

nix-shell --pure

61. Update .config in kernel directory

There is mapping hidden in .config and you need to change it to UID of user under you compile a kernel.

CONFIG_INITRAMFS_ROOT_UID=1001

CONFIG_INITRAMFS_ROOT_GID=1001

Then you can do some other changes with:

make -j"$GR_CPUS" ARCH=i386 nconfig

70. In Linux kernel directory

(optional) make -j"$GR_CPUS" ARCH=i386 nconfig

make -j"$GR_CPUS" ARCH=i386 bzImage

Results are in:

arch/x86/boot/bzImage usr/initramfs_data.cpio.gz

80. Exit nix-shell

exit

81. (optional) Test build

You need to have qemu installed.

In kernel directory just run

./test-build.sh

90. Cleanup build

git clean -f -d -X

100. END

gray386linux's People

Contributors

marmolak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gray386linux's Issues

Pocket386 - It seems like the keyboard doesn't work.

Based on:
#3 (comment)

It seems like the keyboard doesn't work.

According datasheets of M6117, there is keyboard controller in SoC which should be compatible with 8042 controller (hope I have right datasheet - i don't have access to device).

Original linux for M6117 is still around, but it's build on 2.4 kernel so kernel config file looks very different.
Original linux for M6117: https://www.dmp.com.tw/tech/os-xlinux/r54.htm

Note:
i8042 have some nice kernel options:

       i8042.debug    [HW] Toggle i8042 debug mode
        i8042.direct    [HW] Put keyboard port into non-translated mode
        i8042.dumbkbd   [HW] Pretend that controller can only read data from
                             keyboard and cannot control its state
                             (Don't attempt to blink the leds)
        i8042.noaux     [HW] Don't check for auxiliary (== mouse) port
        i8042.nokbd     [HW] Don't check/create keyboard port
        i8042.noloop    [HW] Disable the AUX Loopback command while probing
                             for the AUX port
        i8042.nomux     [HW] Don't check presence of an active multiplexing
                             controller
        i8042.nopnp     [HW] Don't use ACPIPnP / PnPBIOS to discover KBD/AUX
                             controllers
        i8042.notimeout [HW] Ignore timeout condition signalled by controller
        i8042.reset     [HW] Reset the controller during init and cleanup
        i8042.unlock    [HW] Unlock (ignore) the keylock

nix-shell can't find "which" command.

I have an Ubuntu VM that I am running this build on, and after this command:

cd src/build-env-with-nix/
nix-shell --pure

I get:

........
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/x1as1wikbr6k7vcl9z9p632c2md8hizl-gcc-wrapper-11.2.0
patching script interpreter paths in /nix/store/x1as1wikbr6k7vcl9z9p632c2md8hizl-gcc-wrapper-11.2.0
checking for references to /build/ in /nix/store/x1as1wikbr6k7vcl9z9p632c2md8hizl-gcc-wrapper-11.2.0...
find: '/nix/store/9qi6bzjg8164nqh8l0ccvmfxjs85msvp-gcc-wrapper-11.2.0-man': No such file or directory
find: '/nix/store/ai8bkjs9w2f1p8n7hd84zs0dgbw04w8a-gcc-wrapper-11.2.0-info': No such file or directory
substituteStream(): WARNING: pattern '
' doesn't match anything in file '/nix/store/x1as1wikbr6k7vcl9z9p632c2md8hizl-gcc-wrapper-11.2.0/nix-support/libc-ldflags'
substituteStream(): WARNING: pattern '
' doesn't match anything in file '/nix/store/x1as1wikbr6k7vcl9z9p632c2md8hizl-gcc-wrapper-11.2.0/nix-support/libcxx-cxxflags'
substituteStream(): WARNING: pattern '
' doesn't match anything in file '/nix/store/x1as1wikbr6k7vcl9z9p632c2md8hizl-gcc-wrapper-11.2.0/nix-support/libcxx-ldflags'
building '/nix/store/l93rwgjj0kr9gawnmx7cabq4vy1y0sz9-stdenv-linux.drv'...
bash: which: command not found
ln: failed to create symbolic link 'musl-strip' -> '': No such file or directory
bash: which: command not found
ln: failed to create symbolic link 'musl-ar' -> '': No such file or directory

The which command is installed and located at /usr/bin/which

I assume that it not being able to find the command is causing the next two lines to bug. Any ideas? I am new to the nix-shell.

Build seems to require FPU

Reading the README, it seems as if the build in bin/ should work without an FPU, however on my 386SX without FPU I get this error:
IMG_1387

Did I misread the README and FPU emulation is in fact off in the default kernel?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.