Skip to content

Commit

Permalink
Add u-boot-(flash|erase)-spi
Browse files Browse the repository at this point in the history
  • Loading branch information
ayufan committed Jan 5, 2018
1 parent fe920fc commit b1ea24a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 12 deletions.
22 changes: 22 additions & 0 deletions Makefile.uboot.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,28 @@ u-boot-menuconfig:
$(UBOOT_MAKE) ARCH=arm64 savedefconfig
cp $(UBOOT_DIR)/defconfig $(UBOOT_DIR)/configs/$(UBOOT_DEFCONFIG)

.PHONY: u-boot-build # compile u-boot
u-boot-build: out/u-boot/idbloader.img

.PHONY: u-boot-clear
u-boot-clear:
rm -rf out/u-boot/

out/u-boot/%/boot.scr: blobs/%.cmd
mkdir -p $$(dirname $@)
mkimage -C none -A arm -T script -d $< $@

out/u-boot/%/boot.img: out/u-boot/%/boot.scr
dd if=/dev/zero of=$@ bs=1M count=2
mkfs.vfat -n "u-boot-script" $@
mcopy -sm -i $@ $< ::

u-boot-%.img: out/u-boot/%/boot.img out/u-boot/idbloader.img
build/mk-image.sh -c rk3328 -t system -s 128 -b $< -o "$@.tmp"
mv "$@.tmp" $@

.PHONY: u-boot-flash-spi
u-boot-flash-spi: u-boot-flash-spi.img.xz

.PHONY: u-boot-erase-spi
u-boot-erase-spi: u-boot-erase-spi.img.xz
8 changes: 6 additions & 2 deletions Makefile.variants.mk
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ linux-rock64: \
xenial-rock64 \
stretch-rock64 \
jessie-rock64 \
linux-virtual
linux-virtual \
u-boot-flash-spi \
u-boot-erase-spi

.PHONY: linux-minimal-rock64 # build all linux variants
linux-minimal-rock64: \
Expand All @@ -56,4 +58,6 @@ linux-minimal-rock64: \
stretch-minimal-rock64 \
jessie-minimal-rock64 \
jessie-openmediavault-rock64 \
linux-virtual
linux-virtual \
u-boot-flash-spi \
u-boot-erase-spi
9 changes: 9 additions & 0 deletions blobs/erase-spi.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
setenv blink_power 'led power off; sleep 0.1; led power on'

# erase flash
run blink_power blink_power
sf probe
sf erase 8000 3e8000

# blink forever
while true; do run blink_power; sleep 1; done
19 changes: 9 additions & 10 deletions build/mk-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,13 @@ generate_system_image() {
exit 1
fi

if [ ! -f "${ROOTFS_PATH}" ]; then
echo -e "\e[31m CAN'T FIND ROOTFS IMAGE \e[0m"
usage
exit 1
fi

SYSTEM="${OUT_IMAGE}"
rm -rf ${SYSTEM}

echo "Generate System image : ${SYSTEM} !"

if [[ -z "$SIZE" ]]; then
SIZE=256
SIZE=120
fi

dd if=/dev/zero of=${SYSTEM} bs=1M count=0 seek=$SIZE status=none
Expand Down Expand Up @@ -127,8 +121,11 @@ generate_system_image() {
echo "Burn boot..."
dd if=${BOOT_PATH} of=${SYSTEM} seek=${BOOT_START} conv=notrunc status=none

echo "Burn rootfs..."
dd if=${ROOTFS_PATH} of=${SYSTEM} seek=${ROOTFS_START} conv=notrunc status=none
if [ -n "${ROOTFS_PATH}" ]; then
echo "Burn rootfs..."
dd if=${ROOTFS_PATH} of=${SYSTEM} seek=${ROOTFS_START} conv=notrunc status=none
fi

dd if=/dev/zero of=${SYSTEM} count=2048 oflag=append conv=notrunc

echo Updating GPT...
Expand All @@ -139,7 +136,9 @@ generate_system_image() {
parted -s ${SYSTEM} unit s mkpart loader2 ${LOADER2_START} $(expr ${ATF_START} - 1)
parted -s ${SYSTEM} unit s mkpart atf ${ATF_START} $(expr ${BOOT_START} - 1)
parted -s ${SYSTEM} unit s mkpart boot fat16 ${BOOT_START} $(expr ${ROOTFS_START} - 1)
parted -s ${SYSTEM} unit s mkpart root ext4 ${ROOTFS_START} 100%
if [ -n "${ROOTFS_PATH}" ]; then
parted -s ${SYSTEM} unit s mkpart root ext4 ${ROOTFS_START} 100%
fi
parted -s ${SYSTEM} set 6 legacy_boot on
}

Expand Down

0 comments on commit b1ea24a

Please sign in to comment.