Add builder firmware repack script

This commit is contained in:
Viktor
2024-03-25 18:55:22 +01:00
parent 420a878384
commit 11b309932d
3 changed files with 61 additions and 5 deletions

8
.gitignore vendored
View File

@@ -4,6 +4,8 @@
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
# Assembly folders
/archive/
/cache/
/openipc/
archive
cache
openipc
output
*.bin

View File

@@ -107,7 +107,6 @@ The file names contain variables with option names - **flavor, model, processor,
- vendor - the name of the official equipment manufacturer; if there are several of them, a [description](https://github.com/OpenIPC/builder/tree/master#compatibility-and-clones) is created
- version - usually this is an addition to the model, version or revision of hardware differences
### Preparing and using the project
```
@@ -119,6 +118,12 @@ cd builder
./builder.sh
```
### Create firmware with built-in credentials
- Usage: `repack.sh [uboot] [firmware] [ssid] [pass]`
```
sh repack.sh ssc337de ssc337de_ultimate_foscam-x5-nor router password
```
### Existing problems
- On some devices NOR flash 8M is small, and the WiFi driver is very large and the QR scanner currently does not fit into the firmware
@@ -128,5 +133,4 @@ cd builder
Please **_[support our project](https://openipc.org/support-open-source)_** with donations or orders for development or maintenance. Thank you!
[logo]: https://openipc.org/assets/openipc-logo-black.svg

50
repack.sh Executable file
View File

@@ -0,0 +1,50 @@
#!/bin/sh
openipc=https://github.com/openipc/firmware/releases/download/latest
builder=https://github.com/openipc/builder/releases/download/latest
if [ -z "$(dpkg -l | grep squashfs-tools)" ]; then
echo Install the following package:
echo sudo apt-get install squashfs-tools
exit 0
fi
if [ -z "$1" ]; then
echo "Usage: $0 [uboot] [firmware] [ssid] [pass]"
exit 0
fi
uboot=u-boot-$1-nor.bin
chipset=$(echo $2 | cut -d_ -f1)
release=openipc-$1-nor.bin
mkdir -p output
if ! wget -q --show-progress $openipc/$uboot -O output/uboot.bin; then
echo "Download failed: $openipc/$uboot"
exit 1
fi
if ! wget -q --show-progress $builder/$2.tgz -O output/builder.tgz; then
echo "Download failed: $builder/$2.tgz"
exit 1
fi
tar -xf output/builder.tgz -C output
if [ -n "$3" ] && [ -n "$4" ]; then
file=output/squashfs/usr/share/openipc/wireless.sh
unsquashfs -d output/squashfs output/rootfs.squashfs.$chipset > /dev/null
echo "#!/bin/sh" >> $file
echo "fw_setenv wlanssid $3" >> $file
echo "fw_setenv wlanpass $4" >> $file
chmod 755 $file
mksquashfs output/squashfs output/rootfs.$chipset -comp xz > /dev/null
else
mv output/rootfs.squashfs.$chipset output/rootfs.$chipset
fi
dd if=/dev/zero bs=1K count=5000 status=none | tr '\000' '\377' > $release
dd if=output/uboot.bin of=$release bs=1K seek=0 conv=notrunc status=none
dd if=output/uImage.$chipset of=$release bs=1K seek=320 conv=notrunc status=none
dd if=output/rootfs.$chipset of=$release bs=1K seek=2368 conv=notrunc status=none
rm -rf output
echo "Created: $release"