Skip to content

Developing for ELKS on Windows

toncho11 edited this page Apr 10, 2024 · 35 revisions

You can clone and compile ELKS inside WSL2 (Windows Subsystem for Linux). It works perfectly.

Compile your program in ELKS

Example: ../cross/bin/ia16-elf-gcc ./vgatest.c -o vgatest -melks-libc -mcmodel=small

Edit source code

Mode 1

You can do the compilation inside WSL2 and access your C files with your favorite Windows editor by using: \\wsl.localhost\ or \\wsl$.

Mode 2

Using VS Code with WSL2 plugin to run GCC as explained here: https://code.visualstudio.com/docs/cpp/config-wsl If you can not run the step code . then you can try /mnt/c/users/YOUR_USER/AppData/Local/Programs/Microsoft\ VS\ Code/bin/code .. You can either use a WSL2 terminal inside the VS Code or you should be able to configure Compile and Run by configuring the 16 bit gcc compiler that we use (not tried yet). After the initial installation and code . in WSL2 you should be able to do everything without leaving VS Code.

Mode 3

Using MS Visual Studio with remote execution plugin through SSH.

Execute

You can copy an image to Windows using: cp ./image/fd1440-fat.img /mnt/c/Temp inside WSL. The alternative is in Windows:

net use y: \\wsl$\Ubuntu-20.04
copy y:\home\YOUR_USER\elks\image\fd1440-fat.img c:\temp

After compilation you can use the following script that will take a newly created 1440-fat ELKS image, mount it, add your executable (vgatest), unmount the image and store it to c:\Temp.

rm /mnt/c/Temp/fd1440-fat.img
sudo mount -t vfat ../image/fd1440-fat.img /mnt/elksimage
sudo cp vgatest /mnt/elksimage/
sudo umount /mnt/elksimage
cp ../image/fd1440-fat.img /mnt/c/Temp

Note that you will need to adapt this script. Next you can either use qemu to boot the image or write it to a floppy drive. You can also directly mount the image that is already in c:\test and add your executable to it:

sudo mount -t vfat /mnt/c/Temp/fd1440-fat.img /mnt/elksimage
sudo cp vgatest /mnt/elksimage/
sudo umount /mnt/elksimage