Skip to content

Commit

Permalink
Build u-boot flash/erase image
Browse files Browse the repository at this point in the history
  • Loading branch information
ayufan committed Jan 16, 2018
1 parent 148ac4e commit d28ea08
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
/tmp/
/sunxi-tools/
/bootloaders/
/*.img
/*.img.xz
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ include Makefile.atf.mk
include Makefile.uboot.mk
include Makefile.tools.mk
include Makefile.sopine.mk
include Makefile.blobs.mk

bootloaders:
mkdir -p $@
Expand All @@ -21,4 +22,6 @@ bootloaders/sopine_baseboard-uboot.bin: tmp/u-boot-sopine_baseboard/u-boot-with-
.PHONY: image-bootloaders
image-bootloaders: \
bootloaders/pine64_plus-uboot.bin \
bootloaders/sopine_baseboard-uboot.bin
bootloaders/sopine_baseboard-uboot.bin \
u-boot-sopine-flash-spi.img.xz \
u-boot-sopine-erase-spi.img.xz \
17 changes: 17 additions & 0 deletions Makefile.blobs.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
tmp/u-boot/%/boot.scr: blobs/%.cmd
mkdir -p $$(dirname $@)
mkimage -C none -A arm -T script -d $< $@

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

u-boot-sopine-%.img: tmp/u-boot-sopine_baseboard/u-boot-with-spl.bin tmp/u-boot/%/boot.img
rm -f $@.tmp
dd if=$(word 2,$^) of=$@.tmp seek=8192 conv=notrunc status=none
parted -s $@.tmp mklabel msdos
parted -s $@.tmp unit s mkpart primary fat16 8192 100%
parted -s $@.tmp set 1 boot on
dd if=$(word 1,$^) of=$@.tmp seek=16 conv=notrunc status=none
mv "$@.tmp" $@
6 changes: 6 additions & 0 deletions Makefile.tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ sunxi-tools:

sunxi-tools/sunxi-fel: sunxi-tools
make -C sunxi-tools

%.img.xz: %.img
pxz -f -3 $<

clean:
rm -rf tmp/ bootloaders/
7 changes: 7 additions & 0 deletions blobs/erase-spi.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# erase flash
sf probe

echo erasing flash...
sf erase 0 3e8000

echo done
15 changes: 15 additions & 0 deletions blobs/flash-spi.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# first read existing loader
sf probe

echo reading flash...
${devtype} read ${kernel_addr_r} 10 1f40;

# erase flash
echo erasing flash...
sf erase 0 3e8000

# write flash
echo writing flash...
sf write ${kernel_addr_r} 0 3e8000

echo done

0 comments on commit d28ea08

Please sign in to comment.