-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some preliminary support for spiboot for rockpro64
- Loading branch information
Showing
5 changed files
with
110 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
UBOOT_OUTPUT_DIR ?= $(CURDIR)/tmp/u-boot-$(BOARD_TARGET) | ||
UBOOT_LOADER ?= out/u-boot-$(BOARD_TARGET)/idbloader.img | ||
ifeq (rkspl,$(SPI_BOOT)) | ||
UBOOT_LOADER_SPL ?= out/u-boot-$(BOARD_TARGET)/idbloader_spl.img | ||
endif | ||
UBOOT_MAKE ?= make -C $(UBOOT_DIR) KBUILD_OUTPUT=$(UBOOT_OUTPUT_DIR) BL31=$(realpath $(BL31)) \ | ||
CROSS_COMPILE="ccache aarch64-linux-gnu-" | ||
UBOOT_PACKAGE ?= u-boot-$(BOARD_TARGET)-$(RELEASE_NAME)_all.deb | ||
|
||
tmp/u-boot-$(BOARD_TARGET)/.config: $(UBOOT_DIR)/configs/$(UBOOT_DEFCONFIG) | ||
$(UBOOT_MAKE) $(UBOOT_DEFCONFIG) | ||
$(UBOOT_MAKE) $(UBOOT_DEFCONFIG) | ||
|
||
$(UBOOT_LOADER): tmp/u-boot-$(BOARD_TARGET)/.config $(BL31) | ||
$(UBOOT_OUTPUT_DIR)/u-boot.itb: tmp/u-boot-$(BOARD_TARGET)/.config $(BL31) | ||
$(UBOOT_MAKE) -j $$(nproc) | ||
$(UBOOT_MAKE) -j $$(nproc) u-boot.itb | ||
|
||
$(UBOOT_LOADER): $(UBOOT_OUTPUT_DIR)/u-boot.itb | ||
mkdir -p out/u-boot-$(BOARD_TARGET) | ||
ifneq (,$(USE_UBOOT_SPL)) | ||
$(UBOOT_OUTPUT_DIR)/tools/mkimage -n $(BOARD_CHIP) -T rksd -d $(UBOOT_OUTPUT_DIR)/spl/u-boot-spl.bin [email protected] | ||
else ifneq (,$(USE_UBOOT_TPL)) | ||
$(UBOOT_OUTPUT_DIR)/tools/mkimage -n $(BOARD_CHIP) -T rksd -d $(UBOOT_OUTPUT_DIR)/tpl/u-boot-tpl.bin [email protected] | ||
cat $(UBOOT_OUTPUT_DIR)/spl/u-boot-spl.bin >> [email protected] | ||
else ifeq (rock64,$(BOARD_TARGET)) | ||
$(UBOOT_OUTPUT_DIR)/tools/mkimage -n $(BOARD_CHIP) -T rksd -d $(DDR) [email protected] | ||
cat $(UBOOT_OUTPUT_DIR)/spl/u-boot-spl.bin >> [email protected] | ||
else ifeq (rockpro64,$(BOARD_TARGET)) | ||
else ifneq (,$(DDR)) | ||
$(UBOOT_OUTPUT_DIR)/tools/mkimage -n $(BOARD_CHIP) -T rksd -d $(DDR) [email protected] | ||
cat $(UBOOT_OUTPUT_DIR)/spl/u-boot-spl.bin >> [email protected] | ||
else | ||
|
@@ -29,6 +31,28 @@ endif | |
dd if=$(UBOOT_OUTPUT_DIR)/u-boot.itb [email protected] seek=$$((0x200-64)) conv=notrunc | ||
mv [email protected] $@ | ||
|
||
ifeq (,$(UBOOT_LOADER_SPL)) | ||
$(UBOOT_LOADER_SPL): $(UBOOT_OUTPUT_DIR)/u-boot.itb | ||
mkdir -p out/u-boot-$(BOARD_TARGET) | ||
ifneq (,$(USE_UBOOT_SPL)) | ||
$(UBOOT_OUTPUT_DIR)/tools/mkimage -n $(BOARD_CHIP) -T rkspi -d $(UBOOT_OUTPUT_DIR)/spl/u-boot-spl.bin [email protected] | ||
else ifneq (,$(USE_UBOOT_TPL)) | ||
$(UBOOT_OUTPUT_DIR)/tools/mkimage -n $(BOARD_CHIP) -T rkspi -d $(UBOOT_OUTPUT_DIR)/tpl/u-boot-tpl.bin [email protected] | ||
cat $(UBOOT_OUTPUT_DIR)/spl/u-boot-spl.bin >> [email protected] | ||
else ifneq (,$(DDR)) | ||
$(UBOOT_OUTPUT_DIR)/tools/mkimage -n $(BOARD_CHIP) -T rkspi -d $(DDR) [email protected] | ||
for i in $$(seq 1 128); do \ | ||
dd count=4 && dd of=/dev/zero count=4; \ | ||
done < $(UBOOT_OUTPUT_DIR)/spl/u-boot-spl.bin >> [email protected] | ||
else | ||
@echo "Invalid $(BOARD_TARGET)" | ||
@exit 1 | ||
endif | ||
ls -al [email protected] | ||
dd if=$(UBOOT_OUTPUT_DIR)/u-boot.itb [email protected] seek=$$((0x200)) conv=notrunc | ||
mv [email protected] $@ | ||
endif | ||
|
||
.PHONY: u-boot-menuconfig # edit u-boot config and save as defconfig | ||
u-boot-menuconfig: | ||
$(UBOOT_MAKE) ARCH=arm64 $(UBOOT_DEFCONFIG) | ||
|
@@ -45,20 +69,7 @@ u-boot-build: | |
u-boot-clear: | ||
rm -rf $(UBOOT_LOADER)/.. | ||
|
||
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-%-$(BOARD_TARGET).img: out/u-boot/%/boot.img $(UBOOT_LOADER) | ||
build/mk-image.sh -c $(BOARD_CHIP) -d out/u-boot-$(BOARD_TARGET) -t system -s 128 -b $< -o "$@.tmp" | ||
mv "$@.tmp" $@ | ||
|
||
$(UBOOT_PACKAGE): u-boot-package $(UBOOT_LOADER) | ||
$(UBOOT_PACKAGE): u-boot-package $(UBOOT_LOADER) $(UBOOT_LOADER_SPL) | ||
fpm -s dir -t deb -n u-boot-$(BOARD_TARGET) -v $(RELEASE_NAME) \ | ||
-p $@ \ | ||
--deb-priority optional --category admin \ | ||
|
@@ -76,13 +87,44 @@ $(UBOOT_PACKAGE): u-boot-package $(UBOOT_LOADER) | |
--vendor "Kamil Trzciński" \ | ||
-a all \ | ||
u-boot-package/root/=/ \ | ||
$(UBOOT_LOADER)=/usr/lib/u-boot-$(BOARD_TARGET)/idbloader.img | ||
$(addsuffix =/usr/lib/u-boot-$(BOARD_TARGET)/,$(UBOOT_LOADER) $(UBOOT_LOADER_SPL)) | ||
|
||
.PHONY: u-boot-package | ||
u-boot-package: $(UBOOT_PACKAGE) | ||
|
||
.PHONY: u-boot-flash-spi-$(BOARD_TARGET) | ||
u-boot-flash-spi-$(BOARD_TARGET): u-boot-flash-spi-$(BOARD_TARGET).img.xz | ||
ifneq (,$(SPI_BOOT)) | ||
out/u-boot/%/boot.scr: blobs/%.cmd | ||
mkdir -p $$(dirname $@) | ||
mkimage -C none -A arm -T script -d $< $@ | ||
|
||
out/u-boot-$(BOARD_TARGET)/%-boot.img: out/u-boot/%/boot.scr $(UBOOT_LOADER) $(UBOOT_LOADER_SPL) | ||
dd if=/dev/zero of=$@.tmp bs=1M count=32 | ||
mkfs.vfat -n "u-boot-script" $@.tmp | ||
mcopy -sm -i $@.tmp $< :: | ||
ifneq (,$(UBOOT_LOADER_SPL)) | ||
mcopy -sm -i [email protected] $(UBOOT_LOADER_SPL) :: | ||
else | ||
mcopy -sm -i [email protected] $(UBOOT_LOADER) :: | ||
endif | ||
mv [email protected] $@ | ||
|
||
.PHONY: u-boot-erase-spi-$(BOARD_TARGET) | ||
u-boot-erase-spi-$(BOARD_TARGET): u-boot-erase-spi-$(BOARD_TARGET).img.xz | ||
u-boot-%-$(BOARD_TARGET).img: out/u-boot-$(BOARD_TARGET)/%-boot.img $(UBOOT_LOADER) | ||
build/mk-image.sh -c $(BOARD_CHIP) -d out/u-boot-$(BOARD_TARGET) -t system -s 128 -b $< -o "$@.tmp" | ||
mv "$@.tmp" $@ | ||
|
||
.PHONY: u-boot-flash-spi | ||
u-boot-flash-spi: u-boot-flash-spi-$(BOARD_TARGET).img.xz | ||
|
||
.PHONY: u-boot-erase-spi | ||
u-boot-erase-spi: u-boot-erase-spi-$(BOARD_TARGET).img.xz | ||
|
||
else | ||
|
||
.PHONY: u-boot-flash-spi | ||
u-boot-flash-spi: | ||
# not-supported | ||
|
||
.PHONY: u-boot-erase-spi | ||
u-boot-erase-spi: | ||
# not-supported | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,42 @@ | ||
setenv blink_power 'led power off; sleep 0.1; led power on' | ||
setenv blink_standby 'led standby off; sleep 0.1; led standby on' | ||
|
||
# first read existing loader | ||
run blink_power | ||
sf probe | ||
${devtype} read ${kernel_addr_r} 40 1f40; | ||
|
||
# erase flash | ||
run blink_power blink_power | ||
sf erase 8000 3e8000 | ||
# or load idbloader_spl.img and write it to 0 offset of spi | ||
# or load idbloader.img and write it to 0 offset of spi | ||
# or fail badly | ||
|
||
# write flash | ||
run blink_power blink_power blink_power | ||
sf write ${kernel_addr_r} 8000 3e8000 | ||
if size ${devtype} ${devnum}:${distro_bootpart} idbloader_spl.img; then | ||
load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} idbloader_spl.img | ||
|
||
# blink forever | ||
while true; do run blink_power; sleep 1; done | ||
# erase flash | ||
run blink_power blink_power | ||
sf erase 0 3f0000 | ||
|
||
# write flash | ||
run blink_power blink_power blink_power | ||
sf write ${kernel_addr_r} 0 ${filesize} | ||
|
||
# blink forever | ||
while true; do run blink_power; sleep 1; done | ||
elif size ${devtype} ${devnum}:${distro_bootpart} idbloader.img; then | ||
load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} idbloader.img | ||
|
||
# erase flash | ||
run blink_power blink_power | ||
sf erase 8000 3e8000 | ||
|
||
# write flash | ||
run blink_power blink_power blink_power | ||
sf write ${kernel_addr_r} 8000 ${filesize} | ||
|
||
# blink forever | ||
while true; do run blink_power; sleep 1; done | ||
else | ||
# blink forever | ||
echo "missing idbloader.img or idbloader_spl.img" | ||
while true; do run blink_standby; sleep 1; done | ||
fi |