Skip to content

Commit

Permalink
A script to build a gcw0 sdcard image
Browse files Browse the repository at this point in the history
* od_gcw0_defconfig adjusted to build the linux kernel.
* Kernel modules squashfs built as a post-image step.
* Adds ubiboot boot package.
* Adds od-imager host package.
  • Loading branch information
glebm committed Mar 29, 2020
1 parent 43cda75 commit b272cd2
Show file tree
Hide file tree
Showing 11 changed files with 157 additions and 0 deletions.
6 changes: 6 additions & 0 deletions board/opendingux/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ menu "OpenDingux packages"
source "$BR2_EXTERNAL_OPENDINGUX_PATH/package/unlockvt/Config.in"

endmenu

menu "Bootloaders"

source "$BR2_EXTERNAL_OPENDINGUX_PATH/boot/ubiboot/Config.in"

endmenu
15 changes: 15 additions & 0 deletions board/opendingux/boot/ubiboot/Config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
config BR2_TARGET_UBIBOOT
bool "UBIBoot"
help
UBIBoot is a very small and simple bootloader for
Ingenic JZ47xx based boards, which is able to start
a Linux kernel located on a UBI partition.

if BR2_TARGET_UBIBOOT
config BR2_TARGET_UBIBOOT_BOARDNAME
string "UBIBoot board name"
help
One of UBIBoot supported boards to be built.
This will be suffixed with _config to meet UbiBoot
standard naming.
endif
1 change: 1 addition & 0 deletions board/opendingux/boot/ubiboot/ubiboot.hash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sha256 d095208e4587f2446aea94b05acf9fa1bfc6e7d750c46fccdd8f5b2eae2de84f ubiboot-121d5ae7af.tar.gz
35 changes: 35 additions & 0 deletions board/opendingux/boot/ubiboot/ubiboot.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
################################################################################
#
# UbiBoot
#
################################################################################

UBIBOOT_VERSION = 121d5ae7af
UBIBOOT_SITE = $(call github,pcercuei,UBIBoot,$(UBIBOOT_VERSION))
UBIBOOT_BOARD_NAME = $(call qstrip,$(BR2_TARGET_UBIBOOT_BOARDNAME))

UBIBOOT_LICENSE = GPLv2+
UBIBOOT_LICENSE_FILES = README

UBIBOOT_INSTALL_IMAGES = YES

define UBIBOOT_BUILD_CMDS
$(MAKE) CROSS_COMPILE="$(TARGET_CROSS)" -C $(@D) CONFIG=$(UBIBOOT_BOARD_NAME)
endef

define UBIBOOT_INSTALL_IMAGES_CMDS
mkdir -p $(BINARIES_DIR)/ubiboot
$(INSTALL) -D -m 0755 $(@D)/output/$(UBIBOOT_BOARD_NAME)/* $(BINARIES_DIR)/ubiboot
endef

$(eval $(generic-package))

ifeq ($(BR2_TARGET_UBIBOOT),y)
# we NEED a board name unless we're at make source
ifeq ($(filter source,$(MAKECMDGOALS)),)
ifeq ($(UBIBOOT_BOARD_NAME),)
$(error NO UBIBoot board name set. Check your BR2_BOOT_UBIBOOT_BOARDNAME setting)
endif
endif

endif
1 change: 1 addition & 0 deletions board/opendingux/external.mk
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include $(sort $(wildcard $(BR2_EXTERNAL_OPENDINGUX_PATH)/boot/*/*.mk))
include $(sort $(wildcard $(BR2_EXTERNAL_OPENDINGUX_PATH)/package/*/*.mk))
11 changes: 11 additions & 0 deletions board/opendingux/gcw0/build-linux-modules-squashfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

set -e

# Build modules.squashfs
if [ -f output/build/linux-custom/create_modules_fs.sh ]; then
output/build/linux-custom/create_modules_fs.sh
cp output/build/linux-custom/modules.squashfs "$1"
else
echo 'modules.squashfs not built because create_modules_fs.sh is missing'
fi
14 changes: 14 additions & 0 deletions board/opendingux/gcw0/download_local_pack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -euo pipefail

mkdir -p dl/od_local_pack_gcw0/
cd dl/od_local_pack_gcw0/

echo Downloading rs97.bitgala.xyz/RG-350/localpack/emulators/...
wget -N -r -nd --no-parent --reject='index.html*' --reject='scumm*' --reject='robots.txt*' \
https://rs97.bitgala.xyz/RG-350/localpack/default_emulators/ |& tee /tmp/emulators.log

echo Downloading rs97.bitgala.xyz/RG-350/localpack/apps/...
wget -N -r -nd --no-parent --reject='index.html*' --reject='robots.txt*' \
https://rs97.bitgala.xyz/RG-350/localpack/default_apps/ |& tee /tmp/apps.log
48 changes: 48 additions & 0 deletions board/opendingux/gcw0/make_initial_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh

# Builds a full SD card image
#
# If you want the localpack apps included in the image, run this first:
# board/opendingux/gcw0/download_local_pack.sh

set -e

make world mininit ubiboot host-od-imager

# Data image (OPKs):
cd output/images
mkdir -p od-imager/apps/
rm -f od-imager/apps/*
if [ -d ../../dl/od_local_pack_gcw0/ ]; then
cp ../../dl/od_local_pack_gcw0/*.opk od-imager/apps/
fi
if [ -d opks ]; then
cp opks/*.opk od-imager/apps/
fi

# System image
cp mininit-syspart od-imager/
cat vmlinuz.bin gcw0.dtb > od-imager/vmlinuz.bin
cp modules.squashfs od-imager/
cp rootfs.squashfs od-imager/
# Fallbacks are empty as this is the initial image.
echo -n > od-imager/vmlinuz.bak
echo -n > od-imager/modules.squashfs.bak

# Bootloader
cp ubiboot/ubiboot-v20_mddr_512mb.bin od-imager/ubiboot.bin
cd -

# Assemble partitions and the final image
cd output/images/od-imager/
./create_mbr.sh
./create_system_image.sh
./create_data_image.sh
./assemble_images.sh
cd -

echo
echo 'SD card image created in:'
echo output/images/od-imager/images/sd_image.bin
echo Size:
du -sh output/images/od-imager/images/sd_image.bin
1 change: 1 addition & 0 deletions board/opendingux/package/od-imager/od-imager.hash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sha256 1602ad56137506a8a8613da9c24d535ef5c9f1cdb3ba214c6306e435899489f2 od-imager-ff98a7e13f.tar.gz
15 changes: 15 additions & 0 deletions board/opendingux/package/od-imager/od-imager.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#############################################################
#
# od-imager
#
#############################################################

OD_IMAGER_VERSION = ff98a7e13f
OD_IMAGER_SITE = $(call github,glebm,imager,$(OD_IMAGER_VERSION))

define HOST_OD_IMAGER_INSTALL_CMDS
mkdir -p $(BINARIES_DIR)/od-imager
cp $(@D)/*.* $(BINARIES_DIR)/od-imager
endef

$(eval $(host-generic-package))
10 changes: 10 additions & 0 deletions configs/od_gcw0_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,19 @@ BR2_ROOTFS_DEVICE_TABLE="board/opendingux/device_table.txt"
BR2_ROOTFS_MERGED_USR=y
BR2_SYSTEM_ENABLE_NLS=y
BR2_TARGET_TZ_INFO=y
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="https://github.com/OpenDingux/linux/archive/jz-5.3-gcw0.tar.gz"
BR2_LINUX_KERNEL_DEFCONFIG="gcw0"
BR2_LINUX_KERNEL_VMLINUZ_BIN=y
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="ingenic/gcw0"
BR2_TARGET_UBIBOOT=y
BR2_TARGET_UBIBOOT_BOARDNAME="gcw0"
BR2_ROOTFS_USERS_TABLES="board/opendingux/users.txt"
BR2_ROOTFS_OVERLAY="board/opendingux/gcw0/overlay"
BR2_ROOTFS_POST_BUILD_SCRIPT="board/opendingux/gcw0/cleanup-rootfs.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/opendingux/gcw0/build-linux-modules-squashfs.sh"
BR2_PACKAGE_BUSYBOX_CONFIG="board/opendingux/busybox.config"
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
BR2_PACKAGE_ALSA_UTILS=y
Expand Down

0 comments on commit b272cd2

Please sign in to comment.