Skip to content

Commit d28ea08

Browse files
committed
Build u-boot flash/erase image
1 parent 148ac4e commit d28ea08

File tree

6 files changed

+51
-1
lines changed

6 files changed

+51
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
/tmp/
55
/sunxi-tools/
66
/bootloaders/
7+
/*.img
8+
/*.img.xz

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ include Makefile.atf.mk
88
include Makefile.uboot.mk
99
include Makefile.tools.mk
1010
include Makefile.sopine.mk
11+
include Makefile.blobs.mk
1112

1213
bootloaders:
1314
mkdir -p $@
@@ -21,4 +22,6 @@ bootloaders/sopine_baseboard-uboot.bin: tmp/u-boot-sopine_baseboard/u-boot-with-
2122
.PHONY: image-bootloaders
2223
image-bootloaders: \
2324
bootloaders/pine64_plus-uboot.bin \
24-
bootloaders/sopine_baseboard-uboot.bin
25+
bootloaders/sopine_baseboard-uboot.bin \
26+
u-boot-sopine-flash-spi.img.xz \
27+
u-boot-sopine-erase-spi.img.xz \

Makefile.blobs.mk

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
tmp/u-boot/%/boot.scr: blobs/%.cmd
2+
mkdir -p $$(dirname $@)
3+
mkimage -C none -A arm -T script -d $< $@
4+
5+
tmp/u-boot/%/boot.img: tmp/u-boot/%/boot.scr
6+
dd if=/dev/zero of=$@ bs=1M count=2
7+
mkfs.vfat -n "u-boot-script" $@
8+
mcopy -sm -i $@ $< ::
9+
10+
u-boot-sopine-%.img: tmp/u-boot-sopine_baseboard/u-boot-with-spl.bin tmp/u-boot/%/boot.img
11+
rm -f $@.tmp
12+
dd if=$(word 2,$^) of=$@.tmp seek=8192 conv=notrunc status=none
13+
parted -s $@.tmp mklabel msdos
14+
parted -s $@.tmp unit s mkpart primary fat16 8192 100%
15+
parted -s $@.tmp set 1 boot on
16+
dd if=$(word 1,$^) of=$@.tmp seek=16 conv=notrunc status=none
17+
mv "$@.tmp" $@

Makefile.tools.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@ sunxi-tools:
33

44
sunxi-tools/sunxi-fel: sunxi-tools
55
make -C sunxi-tools
6+
7+
%.img.xz: %.img
8+
pxz -f -3 $<
9+
10+
clean:
11+
rm -rf tmp/ bootloaders/

blobs/erase-spi.cmd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# erase flash
2+
sf probe
3+
4+
echo erasing flash...
5+
sf erase 0 3e8000
6+
7+
echo done

blobs/flash-spi.cmd

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# first read existing loader
2+
sf probe
3+
4+
echo reading flash...
5+
${devtype} read ${kernel_addr_r} 10 1f40;
6+
7+
# erase flash
8+
echo erasing flash...
9+
sf erase 0 3e8000
10+
11+
# write flash
12+
echo writing flash...
13+
sf write ${kernel_addr_r} 0 3e8000
14+
15+
echo done

0 commit comments

Comments
 (0)