Skip to content

Commit a390293

Browse files
committed
[build] Added IP.BIN updater script.
1 parent 1b3f7f8 commit a390293

File tree

4 files changed

+114
-9
lines changed

4 files changed

+114
-9
lines changed

Makefile

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,24 @@
1111
#
1212

1313
TARGET = DS
14-
TARGET_NAME = DreamShell_v4.0.2_RC1
14+
VER_MAJOR = 4
15+
VER_MINOR = 0
16+
VER_MICRO = 2
17+
# Build types: 0x0N - Alpha, 0x1N - Beta, 0x2N - RC, 0x3N - Release
18+
VER_BUILD = 0x22
19+
20+
BUILD_TYPE_NAME = $(if $(filter 0x3%,$(VER_BUILD)),Release, \
21+
$(if $(filter 0x2%,$(VER_BUILD)),RC, \
22+
$(if $(filter 0x1%,$(VER_BUILD)),Beta, \
23+
$(if $(filter 0x0%,$(VER_BUILD)),Alpha,Release))))
24+
TARGET_NAME = DreamShell_v$(VER_MAJOR).$(VER_MINOR).$(VER_MICRO)_$(BUILD_TYPE_NAME)
1525
TARGET_BIN = $(TARGET)_CORE.BIN
1626
TARGET_BIN_CD = 1$(TARGET_BIN)
17-
# Build types: 0x0N - Alpha, 0x1N - Beta, 0x2N - RC, 0x3N - Release
18-
TRAGET_VERSION = -DVER_MAJOR=4 \
19-
-DVER_MINOR=0 \
20-
-DVER_MICRO=2 \
21-
-DVER_BUILD=0x21
27+
28+
TRAGET_VERSION = -DVER_MAJOR=$(VER_MAJOR) \
29+
-DVER_MINOR=$(VER_MINOR) \
30+
-DVER_MICRO=$(VER_MICRO) \
31+
-DVER_BUILD=$(VER_BUILD)
2232
# TARGET_DEBUG = 1 # or 2 for GDB
2333
# TARGET_EMU = 1
2434
# TARGET_PROF = 1
@@ -263,17 +273,20 @@ $(TARGET_BIN_CD): $(TARGET_BIN)
263273
cdi: $(TARGET).cdi
264274

265275
$(TARGET).cdi: $(TARGET_BIN_CD) make-build
276+
@echo Updating IP.BIN with current version and date...
277+
@utils/update_ip_bin.sh $(DS_RES)/IP.BIN /tmp/IP_$(TARGET).BIN $(VER_MAJOR) $(VER_MINOR) $(VER_MICRO) $(VER_BUILD) >/dev/null
266278
@echo Creating ISO...
267279
@-rm -f $(DS_BUILD)/$(TARGET_BIN)
268280
@-rm -f $(DS_BUILD)/$(TARGET_BIN_CD)
269281
@cp $(TARGET_BIN_CD) $(DS_BUILD)/$(TARGET_BIN_CD)
270282
@-rm -rf $(DS_BUILD)/.* 2> /dev/null
271-
@$(DS_SDK)/bin/mkisofs -V DreamShell -C 0,11702 -G $(DS_RES)/IP.BIN -joliet -rock -l -x .DS_Store -o $(TARGET).iso $(DS_BUILD)
283+
@$(DS_SDK)/bin/mkisofs -V DreamShell -C 0,11702 -G /tmp/IP_$(TARGET).BIN -joliet -rock -l -x .DS_Store -o $(TARGET).iso $(DS_BUILD)
272284
@echo Convert ISO to CDI...
273285
@-rm -f $(TARGET).cdi
274286
@$(DS_SDK)/bin/cdi4dc $(TARGET).iso $(TARGET).cdi >/dev/null
275287
@-rm -f $(TARGET).iso
276288
@-rm -f $(DS_BUILD)/$(TARGET_BIN_CD)
289+
@-rm -f /tmp/IP_$(TARGET).BIN
277290

278291
# If you have problems with mkisofs try data/data image:
279292
# $(DS_SDK)/bin/mkisofs -V DreamShell -G $(DS_RES)/IP.BIN -joliet -rock -l -x .DS_Store -o $(TARGET).iso $(DS_BUILD)

firmware/bootloader/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
#
55

66
TARGET = bootloader
7-
VERSION = 2.8
7+
VER_MAJOR = 2
8+
VER_MINOR = 8
9+
VER_MICRO = 0
10+
VERSION = $(VER_MAJOR).$(VER_MINOR)
811
TARGET_NAME = DreamShell_$(TARGET)_v$(VERSION)
912
TARGET_CD = cd/1DS_BOOT.BIN
1013
KOS_ROMDISK_DIR = romdisk
@@ -43,13 +46,16 @@ $(TARGET).elf: $(OBJS)
4346
$(TARGET_CD): $(TARGET).bin
4447

4548
cdi: $(TARGET_CD)
49+
@echo Updating IP.BIN with current bootloader version and date...
50+
@../../utils/update_ip_bin.sh $(DS_RES)/IP.BIN /tmp/IP_$(TARGET).BIN $(VER_MAJOR) $(VER_MINOR) $(VER_MICRO) 0x30 bootloader >/dev/null
4651
@mkdir -p ./cd
4752
@$(DS_SDK)/bin/scramble $(TARGET).bin $(TARGET_CD)
48-
@$(DS_SDK)/bin/mkisofs -V DreamShell -C 0,11702 -G $(DS_RES)/IP_BOOT.BIN -joliet -rock -l -x .DS_Store -o $(TARGET).iso ./cd
53+
@$(DS_SDK)/bin/mkisofs -V DreamShell -C 0,11702 -G /tmp/IP_$(TARGET).BIN -joliet -rock -l -x .DS_Store -o $(TARGET).iso ./cd
4954
@echo Convert ISO to CDI...
5055
@-rm -f $(TARGET).cdi
5156
@$(DS_SDK)/bin/cdi4dc $(TARGET).iso $(TARGET).cdi >/dev/null
5257
@-rm -f $(TARGET).iso
58+
@-rm -f /tmp/IP_$(TARGET).BIN
5359

5460
# If you have problems with mkisofs try data/data image:
5561
# $(DS_SDK)/bin/mkisofs -V DreamShell -G $(DS_RES)/IP.BIN -joliet -rock -l -x .DS_Store -o $(TARGET).iso ./cd

resources/IP_BOOT.BIN

-32 KB
Binary file not shown.

utils/update_ip_bin.sh

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/bin/bash
2+
#
3+
# DreamShell IP.BIN updater
4+
# Copyright (C) 2025 SWAT
5+
# http://www.dc-swat.ru
6+
#
7+
# This script is used to update the IP.BIN file with the current version and date.
8+
#
9+
10+
if [ $# -lt 6 ] || [ $# -gt 7 ]; then
11+
echo "Usage: $0 <source_ip_bin> <target_ip_bin> <major> <minor> <micro> <build_type> [type]"
12+
echo "Example: $0 resources/IP.BIN build/IP.BIN 4 0 2 30"
13+
echo " $0 resources/IP.BIN build/IP.BIN 2 8 0 30 bootloader"
14+
exit 1
15+
fi
16+
17+
SOURCE_IP="$1"
18+
TARGET_IP="$2"
19+
VER_MAJOR="$3"
20+
VER_MINOR="$4"
21+
VER_MICRO="$5"
22+
BUILD_TYPE="$6"
23+
IP_TYPE="${7:-main}"
24+
25+
if [ ! -f "$SOURCE_IP" ]; then
26+
echo "Error: Source file $SOURCE_IP not found"
27+
exit 1
28+
fi
29+
30+
# Create target directory if needed
31+
TARGET_DIR="$(dirname "$TARGET_IP")"
32+
if [ "$TARGET_DIR" != "." ] && [ ! -d "$TARGET_DIR" ]; then
33+
mkdir -p "$TARGET_DIR"
34+
fi
35+
cp "$SOURCE_IP" "$TARGET_IP"
36+
37+
BUILD_TYPE_STR=""
38+
case "$BUILD_TYPE" in
39+
0x0*) BUILD_TYPE_STR="ALP" ;;
40+
0x1*) BUILD_TYPE_STR="BET" ;;
41+
0x2*) BUILD_TYPE_STR="RC " ;;
42+
0x3*) BUILD_TYPE_STR="REL" ;;
43+
*) BUILD_TYPE_STR="REL" ;;
44+
esac
45+
46+
CURRENT_DATE=$(date +%Y%m%d)
47+
48+
# Create version string with null byte separator
49+
if [ "$IP_TYPE" = "bootloader" ]; then
50+
VERSION_FIELD="DS-BOOTLD"
51+
BIN_NAME_FIELD="1DS_BOOT.BIN "
52+
DESC_FIELD="Bootloader ${VER_MAJOR}.${VER_MINOR}"
53+
else
54+
VERSION_FIELD="DS-${VER_MAJOR}${VER_MINOR}${VER_MICRO}${BUILD_TYPE_STR}"
55+
BIN_NAME_FIELD="1DS_CORE.BIN "
56+
DESC_FIELD="DreamShell ${VER_MAJOR}.${VER_MINOR}"
57+
fi
58+
59+
# Create version string with null byte separator using printf directly
60+
VERSION_PART2="V${VER_MAJOR}.${VER_MINOR}${VER_MICRO}0"
61+
62+
# Write version field (0x40-0x4F) with null byte separator
63+
printf "${VERSION_FIELD}\x00${VERSION_PART2}%*s" $((16 - ${#VERSION_FIELD} - 1 - ${#VERSION_PART2})) "" | \
64+
dd of="$TARGET_IP" bs=1 seek=64 count=16 conv=notrunc 2>/dev/null
65+
# Write other fields
66+
printf "%-16.16s" "$CURRENT_DATE" | dd of="$TARGET_IP" bs=1 seek=80 count=16 conv=notrunc 2>/dev/null
67+
printf "%-16.16s" "$BIN_NAME_FIELD" | dd of="$TARGET_IP" bs=1 seek=96 count=16 conv=notrunc 2>/dev/null
68+
printf "%-16.16s" "$DESC_FIELD" | dd of="$TARGET_IP" bs=1 seek=128 count=16 conv=notrunc 2>/dev/null
69+
70+
if [ "$IP_TYPE" = "bootloader" ]; then
71+
VERSION_STRING="DS-BOOTLD.V${VER_MAJOR}.${VER_MINOR}${VER_MICRO}0"
72+
BIN_NAME="1DS_BOOT.BIN"
73+
DESCRIPTION_STRING="Bootloader ${VER_MAJOR}.${VER_MINOR}"
74+
else
75+
VERSION_STRING="DS-${VER_MAJOR}${VER_MINOR}${VER_MICRO}${BUILD_TYPE_STR}.V${VER_MAJOR}.${VER_MINOR}${VER_MICRO}0"
76+
BIN_NAME="1DS_CORE.BIN"
77+
DESCRIPTION_STRING="DreamShell ${VER_MAJOR}.${VER_MINOR}"
78+
fi
79+
80+
echo "Updated IP.BIN:"
81+
echo " Type: $IP_TYPE"
82+
echo " Version: $VERSION_STRING"
83+
echo " Date: $CURRENT_DATE"
84+
echo " Binary: $BIN_NAME"
85+
echo " Description: $DESCRIPTION_STRING"
86+
echo " Target: $TARGET_IP"

0 commit comments

Comments
 (0)