Skip to content

Commit

Permalink
Remove concept of make configure; we know have simple FS
Browse files Browse the repository at this point in the history
  • Loading branch information
scopeInfinity committed Aug 14, 2021
1 parent edc4228 commit 825e43f
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 49 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ jobs:
- name: Prerequisite
run: sudo bash before_install.sh

- name: make configure
run: make configure

- name: make
run: make

Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ jobs:
- name: Prerequisite
run: sudo bash before_install.sh

- name: make configure
run: make configure

- name: make
run: make

Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*.vmdk
*.o
configure
local_notes/
build/
src_test/
Expand Down
22 changes: 10 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,29 +101,27 @@ binaries: $(bt_stage1) $(bt_stage2) $(kernel_core) $(rm_static)

# Build dependecies for configure and $(image_vmdk) are ordered based on their position on disk.
# Note: Relying on default value doesn't guarantee bin size.
SECTOR_COUNT_BT_STAGE1 = 1
SECTOR_COUNT_SHARED_LIBRARY = 1
SECTOR_COUNT_BT_STAGE2 = 11
SECTOR_COUNT_KERNEL = 44

SECTOR_START_BT_STAGE1 = 0
SECTOR_COUNT_BT_STAGE1 = $(shell cut -d' ' -f1 configure 2> /dev/null || echo 1 )
SECTOR_START_SHARED_LIBRARY = $(shell expr $(SECTOR_START_BT_STAGE1) + $(SECTOR_COUNT_BT_STAGE1) )
SECTOR_COUNT_SHARED_LIBRARY = $(shell cut -d' ' -f2 configure 2> /dev/null || echo 1 )
SECTOR_START_BT_STAGE2 = $(shell expr $(SECTOR_START_SHARED_LIBRARY) + $(SECTOR_COUNT_SHARED_LIBRARY) )
SECTOR_COUNT_BT_STAGE2 = $(shell cut -d' ' -f3 configure 2> /dev/null || echo 30 )
SECTOR_START_KERNEL = $(shell expr $(SECTOR_START_BT_STAGE2) + $(SECTOR_COUNT_BT_STAGE2) )
SECTOR_COUNT_KERNEL = $(shell cut -d' ' -f4 configure 2> /dev/null || echo 30 )

# configure file stores the sector size of each sub images.
configure: $(bt_stage1) $(rm_static) $(bt_stage2) $(kernel_core)
bash scripts/build_image.sh /dev/null $^ > $@
rm -r $(BUILD_DIR)/ && "Cleared build directory" || echo "Build directory is clean."

$(image_vmdk): $(bt_stage1) $(rm_static) $(bt_stage2) $(kernel_core) $(BUILD_DIR)/external/bin/mbr_builder $(MINIMAL_DISK)
test -s configure || { echo -e "\033[0;31mFailed! Please execute 'make configure' first.\033[0m" >&2; exit 1; }
bash scripts/build_image.sh $(BUILD_DIR)/temp_vmdk $(bt_stage1) $(rm_static) $(bt_stage2) $(kernel_core)
bash scripts/build_image.sh $(BUILD_DIR)/temp_vmdk \
$(bt_stage1) $(SECTOR_COUNT_BT_STAGE1) \
$(rm_static) $(SECTOR_COUNT_SHARED_LIBRARY) \
$(bt_stage2) $(SECTOR_COUNT_BT_STAGE2) \
$(kernel_core) $(SECTOR_COUNT_KERNEL)
./$(BUILD_DIR)/external/bin/mbr_builder $@ $(BUILD_DIR)/temp_vmdk $(MINIMAL_DISK)
@echo "Image Size : $$(stat -c %s $@) byte(s)"

clean:
rm -r $(BUILD_DIR)/ || echo "Build directory is clean."
rm -f configure

include emulator/Makefile.mk

Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ The VMDK image can be found under `Assets` for the corresponding release.

The screenshots can be located as `Artifacts` under completed run on [Actions/CI](https://github.com/scopeInfinity/FuzzyOS/actions/workflows/ci.yaml?query=branch%3Amaster+event%3Apush+is%3Asuccess).

Bootloader | Kernel Turnup | Simple Application
Bootloader | Kernel Turnup | Simple Application
-------------|----------------|-------------------
![image](https://user-images.githubusercontent.com/9819066/119272271-12b67700-bbfd-11eb-8036-1466d39ebe8e.png) | ![image](https://user-images.githubusercontent.com/9819066/119273658-ca4e8780-bc03-11eb-8353-2dcf41354c82.png) | ![image](https://user-images.githubusercontent.com/9819066/119272299-2bbf2800-bbfd-11eb-9e8a-350946e1218b.png)

### Boot OS

#### How to get boot image?
- Download image from one of the [Release](#Release).
- Or directly build image using `make configure && make images` after cloning the repository.
- Or directly build image using `make images` after cloning the repository.

#### Boot on VMware
- Create *Virtual Machine Disk* with fixed size of *4MB*.
Expand All @@ -33,7 +33,7 @@ The screenshots can be located as `Artifacts` under completed run on [Actions/CI
##### Boot on a real machine
- Use `dd` or `scripts/burn.sh` to burn image into the disk (potentially destructive).
- `bash scripts/burn.sh build/image.vmdk /path/to/devicefile`

###### If boot from Flash Drive doesn't work
- Try formatting device MBR with a FAT partition.
- And then burn the image again.
Expand All @@ -46,7 +46,6 @@ The screenshots can be located as `Artifacts` under completed run on [Actions/CI
```
bash before_install.sh
make clean
make configure
```

#### QEMU Quick Launch
Expand Down
62 changes: 37 additions & 25 deletions scripts/build_image.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,50 @@
#!/bin/bash
# The scripts take multiple subimages as argument and prepare final image
# by merging them. Once successful echo's sub images size.
# The scripts take essential subimages as argument merging them while verifying their size.

set -e
if [ $# -lt 2 ] ; then
echo "Usage: build_image.sh <target_image> <subimage1> [ <subimage2> ... ]" >&2
if [ $# -ne 9 ] ; then
echo "Usage: build_image.sh <target_image> <bt_stage1> <sc> <realmode_lib> <sc> <bt_stage2> <sc> <kernel> <sc>"
echo "<sc> is sector count of preceding subimage."
exit 1
fi

# Currently image is build in two phases.
# Phase 1:
# Build image with undefined SECTOR index which can be used to calculate
# SECTOR index and cache them.
# Phase 2:
# Populate the Makefile SECTOR indexes from the cache and retrigger build
# to generate final image.

IMAGE_FILE="$1"
TMP_SUBIMAGE="/tmp/fuzzy_subimage"
shift

echo "Using $IMAGE_FILE as image file" >&2
rm "${IMAGE_FILE:?}" || echo "Can't remove existing image file, continuing..." >&2
touch "${IMAGE_FILE}"
function verify_subimage_and_push() {
subimage_name="${1:?}"
subimage="${2:?}"
min_sectors="${3:?}"
max_sectors="${4:?}"

subImagesSectorCount=( )
for target in "$@"
do
echo "Appending '$target' to image" >&2
fsize=$(stat -c "%s" ${target:?})
cat ${target:?} >> ${IMAGE_FILE:?}
echo "Verifying ${subimage_name:?}: ${subimage:?} min_sectors: ${min_sectors:?} max_sectors: ${max_sectors:?}"
fsize=$(stat -c "%s" ${subimage:?})

if [ "$(( $fsize % 512 ))" -ne 0 ]; then
echo "The intermediate image $target size isn't divisible by 512" >&2
echo "The ${subimage} size isn't divisible by 512" >&2
exit 2
fi
if [ "$(( $fsize / 512 ))" -lt ${min_sectors:?} ]; then
echo "The ${subimage} uses less sectors than ${min_sectors:?}" >&2
exit 2
fi
subImagesSectorCount+=($(($fsize / 512)) )
done
echo "${subImagesSectorCount[@]}"
if [ "$(( $fsize / 512 ))" -gt ${max_sectors:?} ]; then
echo "The ${subimage} uses more sectors than ${max_sectors:?}" >&2
exit 2
fi

cp -f ${subimage:?} ${TMP_SUBIMAGE:?}
truncate --size=%"$(( $max_sectors * 512 ))" ${TMP_SUBIMAGE:?}
cat ${TMP_SUBIMAGE:?} >> ${IMAGE_FILE:?}
}

echo "Using $IMAGE_FILE as image file" >&2
rm "${IMAGE_FILE:?}" || echo "Can't remove existing image file, continuing..." >&2
touch "${IMAGE_FILE}"

# sum of all should not exceed 256 sectors
verify_subimage_and_push "bt_stage1" $1 $2 $2
verify_subimage_and_push "realmode_lib" $3 $4 $4
verify_subimage_and_push "bt_stage2" $5 $6 $6
verify_subimage_and_push "kernel" $7 $8 $8
1 change: 0 additions & 1 deletion tests/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ function os_test_up() {

# Turn up QEMU in background
make clean BUILD_DIR="${BUILD_TEST_DIR:?}" \
&& make configure \
&& make qemu \
INIT_APPNAME="${INIT_APPNAME:?}" \
SRC_DIR="${SRC_TEST_DIR:?}" \
Expand Down

0 comments on commit 825e43f

Please sign in to comment.