Binary files /tmp/tmpaww9v68f/4xNu3LXw45/sunxi-tools-1.4.2+git20211216.02a865/bin/fel-sdboot.sunxi and /tmp/tmpaww9v68f/tq5lx6tJgu/sunxi-tools-1.4.2+git20220212.08e209/bin/fel-sdboot.sunxi differ Binary files /tmp/tmpaww9v68f/4xNu3LXw45/sunxi-tools-1.4.2+git20211216.02a865/bin/jtag-loop.sunxi and /tmp/tmpaww9v68f/tq5lx6tJgu/sunxi-tools-1.4.2+git20220212.08e209/bin/jtag-loop.sunxi differ Binary files /tmp/tmpaww9v68f/4xNu3LXw45/sunxi-tools-1.4.2+git20211216.02a865/bin/ramboot.scr and /tmp/tmpaww9v68f/tq5lx6tJgu/sunxi-tools-1.4.2+git20220212.08e209/bin/ramboot.scr differ Binary files /tmp/tmpaww9v68f/4xNu3LXw45/sunxi-tools-1.4.2+git20211216.02a865/bin/uart0-helloworld-sdboot.sunxi and /tmp/tmpaww9v68f/tq5lx6tJgu/sunxi-tools-1.4.2+git20220212.08e209/bin/uart0-helloworld-sdboot.sunxi differ diff -Nru sunxi-tools-1.4.2+git20211216.02a865/debian/changelog sunxi-tools-1.4.2+git20220212.08e209/debian/changelog --- sunxi-tools-1.4.2+git20211216.02a865/debian/changelog 2022-02-12 23:15:28.000000000 +0000 +++ sunxi-tools-1.4.2+git20220212.08e209/debian/changelog 2022-02-12 23:15:28.000000000 +0000 @@ -1,3 +1,11 @@ +sunxi-tools (1.4.2+git20220212.08e209-1) unstable; urgency=medium + + * New upstream release. + + Includes new sunxi-fel.1 manpage + * Include the upstream target stubs in the package. + + -- Ian Campbell Sat, 12 Feb 2022 13:48:51 +0000 + sunxi-tools (1.4.2+git20211216.02a865-2) unstable; urgency=medium * Fix FTCBFS: (Closes: #1000564) diff -Nru sunxi-tools-1.4.2+git20211216.02a865/debian/control sunxi-tools-1.4.2+git20220212.08e209/debian/control --- sunxi-tools-1.4.2+git20211216.02a865/debian/control 2022-02-12 23:15:28.000000000 +0000 +++ sunxi-tools-1.4.2+git20220212.08e209/debian/control 2022-02-12 23:15:28.000000000 +0000 @@ -9,6 +9,7 @@ u-boot-tools, ruby, binutils-arm-none-eabi, + gcc-arm-none-eabi, zlib1g-dev Standards-Version: 4.6.0 Vcs-Browser: https://salsa.debian.org/debian/sunxi-tools diff -Nru sunxi-tools-1.4.2+git20211216.02a865/debian/copyright sunxi-tools-1.4.2+git20220212.08e209/debian/copyright --- sunxi-tools-1.4.2+git20211216.02a865/debian/copyright 2022-02-12 23:15:28.000000000 +0000 +++ sunxi-tools-1.4.2+git20220212.08e209/debian/copyright 2022-02-12 23:15:28.000000000 +0000 @@ -46,6 +46,7 @@ thunks/sid_read_root.S thunks/sid_read_root.h include/types.h include/list.h bin/ramboot.uboot-sh bin/ramboot.scr + sunxi-fel.1 Copyright: 2011,2012,2013 Henrik Nordstrom 2012 Alejandro Mery 2012 Jens Andersen @@ -56,6 +57,7 @@ Copyright (C) 2015,2016 Bernhard Nortmann Copyright (C) 2015,2016 Siarhei Siamashka (C) Copyright 2013 Stefan Kristiansson + Copyright (C) 2018 by Andre Przywara License: GPL-2+ Files: fel-remotefunc-spi-data-transfer.c diff -Nru sunxi-tools-1.4.2+git20211216.02a865/debian/rules sunxi-tools-1.4.2+git20220212.08e209/debian/rules --- sunxi-tools-1.4.2+git20211216.02a865/debian/rules 2022-02-12 23:15:28.000000000 +0000 +++ sunxi-tools-1.4.2+git20220212.08e209/debian/rules 2022-02-12 23:15:28.000000000 +0000 @@ -12,10 +12,16 @@ override_dh_auto_build: $(MAKE) -C thunks CROSS_COMPILE=arm-none-eabi- dh_auto_build -- CFLAGS="$(CFLAGS) $(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" tools - mkimage -A arm -T script -d bin/ramboot.uboot-sh bin/ramboot.scr + + mkimage -A arm -T script -d bin/ramboot.uboot-sh ramboot.scr + $(MAKE) CROSS_COMPILE=arm-none-eabi- binfiles override_dh_auto_install: PKG := debian/sunxi-tools override_dh_auto_install: $(MAKE) install-tools DESTDIR=$(CURDIR)/$(PKG) PREFIX=/usr - install -m0644 bin/ramboot.scr $(PKG)/usr/share/sunxi-tools/ramboot.scr + find -name \*.sunxi + install -m0644 ramboot.scr $(PKG)/usr/share/sunxi-tools/ramboot.scr + install -m0644 fel-sdboot.sunxi $(PKG)/usr/share/sunxi-tools/fel-sdboot.sunxi + install -m0644 jtag-loop.sunxi $(PKG)/usr/share/sunxi-tools/jtag-loop.sunxi + install -m0644 uart0-helloworld-sdboot.sunxi $(PKG)/usr/share/sunxi-tools/uart0-helloworld-sdboot.sunxi diff -Nru sunxi-tools-1.4.2+git20211216.02a865/fit_image.c sunxi-tools-1.4.2+git20220212.08e209/fit_image.c --- sunxi-tools-1.4.2+git20211216.02a865/fit_image.c 2022-01-16 08:58:47.000000000 +0000 +++ sunxi-tools-1.4.2+git20220212.08e209/fit_image.c 2022-02-12 02:10:39.000000000 +0000 @@ -77,13 +77,13 @@ static uint32_t fdt_getprop_u32(const void *fdt, int node, const char *name) { - const struct fdt_property *prop; + const fdt32_t *val; - prop = fdt_get_property(fdt, node, name, NULL); - if (!prop) + val = fdt_getprop(fdt, node, name, NULL); + if (!val) return ~0U; - return be32toh(*(uint32_t *)prop->data); + return fdt32_to_cpu(*val); } static const char *fdt_getprop_str(const void *fdt, int node, const char *name) diff -Nru sunxi-tools-1.4.2+git20211216.02a865/.gitignore sunxi-tools-1.4.2+git20220212.08e209/.gitignore --- sunxi-tools-1.4.2+git20211216.02a865/.gitignore 2022-02-12 23:15:28.000000000 +0000 +++ sunxi-tools-1.4.2+git20220212.08e209/.gitignore 2022-02-12 02:10:39.000000000 +0000 @@ -6,6 +6,5 @@ sunxi-nand-part sunxi-pio version.h -fel-to-spl-thunk.h.pristine *.o *.swp diff -Nru sunxi-tools-1.4.2+git20211216.02a865/Makefile sunxi-tools-1.4.2+git20220212.08e209/Makefile --- sunxi-tools-1.4.2+git20211216.02a865/Makefile 2022-02-12 23:15:28.000000000 +0000 +++ sunxi-tools-1.4.2+git20220212.08e209/Makefile 2022-02-12 02:10:39.000000000 +0000 @@ -64,6 +64,7 @@ DESTDIR ?= PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin +MANDIR ?= $(PREFIX)/share/man/man1 .PHONY: all clean tools target-tools install install-tools install-target-tools .PHONY: check @@ -88,6 +89,7 @@ @set -ex ; for l in $(FEXC_LINKS) ; do \ ln -nfs sunxi-fexc $(DESTDIR)$(BINDIR)/$$l ; \ done + install -D -m0644 -t $(DESTDIR)$(MANDIR) sunxi-fel.1 install-target-tools: $(TARGET_TOOLS) install -d $(DESTDIR)$(BINDIR) diff -Nru sunxi-tools-1.4.2+git20211216.02a865/nand-part.c sunxi-tools-1.4.2+git20220212.08e209/nand-part.c --- sunxi-tools-1.4.2+git20211216.02a865/nand-part.c 2022-01-16 08:58:47.000000000 +0000 +++ sunxi-tools-1.4.2+git20220212.08e209/nand-part.c 2022-02-12 02:10:39.000000000 +0000 @@ -90,7 +90,7 @@ printf("check partition table copy %d: ", mbr_num); printmbrheader(mbr); if (force) { - strncpy((char *)mbr->magic, MBR_MAGIC, 8); + memcpy(mbr->magic, MBR_MAGIC, 8); mbr->version = MBR_VERSION; return mbr; } diff -Nru sunxi-tools-1.4.2+git20211216.02a865/sunxi-fel.1 sunxi-tools-1.4.2+git20220212.08e209/sunxi-fel.1 --- sunxi-tools-1.4.2+git20211216.02a865/sunxi-fel.1 1970-01-01 00:00:00.000000000 +0000 +++ sunxi-tools-1.4.2+git20220212.08e209/sunxi-fel.1 2022-02-12 02:10:39.000000000 +0000 @@ -0,0 +1,255 @@ +.\" Manpage for sunxi-fel +.\" Copyright (C) 2018 by Andre Przywara +.TH sunxi-fel 1 "14 Jan 2022" "1.5" "sunxi-fel man page" +.SH NAME +sunxi-fel \- controlling USB BootROM protocol for Allwinner CPUs +.SH SYNOPSIS +sunxi-fel [OPTIONS] COMMAND [ARGS] +.SH DESCRIPTION +sunxi-fel is a script interface for USB communication with the BootROM of +Allwinner CPUs. + +On explicit request (typically by pressing a button often labeled "uboot" +or "recovery"), or when all other booting methods fail, the CPU's early ROM +code enters the so called FEL mode, where it will wait for USB commands sent +by some host to the Allwinner CPU's USB OTG interface. sunxi-fel implements +this FEL protocol and communicates with the ROM code, to download or upload +data and to start code execution. + +Besides simply allowing to write to or to read from device memory, sunxi-fel +also helps with more complex things, which involve uploading code, executing +it and then returning to FEL mode, to allow further data transfer or inspection. +In particular it supports loading and executing U-Boot, including the primary +SPL stage. +.SH "OPTIONS" +Those options affect general execution and should be put first, before any +actual commands. +.sp +.B \-h, \-\-help +.RS 4 +Print a help message and exit. +.RE +.sp +.B \-v, \-\-verbose +.RS 4 +Enable verbose logging. +.RE +.sp +.B \-p, \-\-progress +.RS 4 +"write" transfers show a progress bar. +.RE +.sp +.B \-l, \-\-list +.RS 4 +Enumerate all (USB) FEL devices and exit. +.RE +.sp +.B \-d, \-\-dev bus:devnum +.RS 4 +Use specific USB bus and device number +.RE +.sp +.B \-\-sid SID +.RS 4 +Select a device by its SID key (exact match). The SID key of a particular +device can be queried using the "sid" command. +.RE +.SH "SUNXI-FEL COMMANDS" +sunxi-fel can take several commands, each followed by their parameters, and +will execute them in order. The only exception is the "uboot" command, +which will delay launching U-Boot until all other commands have been executed. +.sp +Please note that accessing any part of the DRAM will not work until the +DRAM controller has been initialized. This can be achieved by uploading and +executing a suitable U-Boot SPL image, using the "spl" command. Trying to +access DRAM before that will most likely hang. +.sp +Any numbers given as parameters to those commands can be prefixed with "0x" +to denote hexadecimal notation or "0" to start an octal number. +They are interpretated as decimal numbers otherwise. +.PP +.B spl +.RS 4 +Load and execute U-Boot SPL. +.sp +Upload the given binary file to the appropriate SRAM location, carefully +moving the FEL stack out of the way in the process. The binary is then +executed. When it returns, the FEL stack is restored and execution is +transferred back to the BootROM's FEL routine. +.sp +If the file additionally contains a main U-Boot binary +(u-boot-sunxi-with-spl.bin), this command also transfers that +to memory, using the load address stored in the image file, but won't execute +it. +.RE +.PP +.B uboot +.RS 4 +like "spl", but actually starts U-Boot. U-Boot execution will take place +when the fel utility exits. This allows combining "uboot" with further "write" +commands, to transfer other files possibly needed for the boot. +.RE +.PP +.B hex[dump]
+.RS 4 +Hexadecimal memory dump. Dumps bytes of the memory region starting at +
. The context will be displayed as a hexdump, suitable for human +inspection. +.RE +.PP +.B dump
+.RS 4 +Binary memory dump. Dumps bytes of the memory region starting at +
. The context will be dumped "as is" to the standard output, so it +can be redirected to a file and processed as binary data. +.RE +.PP +.B exe[cute]
+.RS 4 +Start executing code at
in memory on the device. +.RE +.PP +.B reset64
+.RS 4 +Request a warm reset of the core, starting execution in the 64-bit AArch64 +execution state, at
. +.RE +.PP +.B memmove +.RS 4 +Copy bytes within device memory, from to . +.RE +.PP +.B readl
+.RS 4 +Read a 32-bit value from device memory at
. The value will be output +as a hexadecimal number, prefixed with "0x". The address needs to be 4-byte +aligned. +.RE +.PP +.B writel
+.RS 4 +Write the given 32-bit to device memory at
. +.RE +.PP +.B read
+.RS 4 +Write memory contents into file. Reads bytes from memory at
+and writes the content into . +.RE +.PP +.B write
+.RS 4 +Store file contents into memory. Writes the entire content of into +memory at
. +.RE +.PP +.B write-with-progress +.RS 4 +Display a textual progress bar while writing to the device. Same as "write" +with the "-p" parameter. +.RE +.PP +.B write-with-gauge +.RS 4 +Same as write, but write the progress in percentages to the standard output. +This can be piped to any "dialog" compatible program, when using the --gauge +widget. +.RE +.PP +.B write-with-xgauge +.RS 4 +Same as write-with-gauge, but with extended gauge output. This can be piped to +any "dialog" compatible program, using the --gauge widget. Aside from updating +the current progress in percents, it also updates the number of bytes written +and gives an estimated time to completion. +.RE +.PP +.B multi[write] # ... +.RS 4 +Like "write-with-progress", but with multiple load adddresses and files, +all sharing the same progress bar. +.RE +.PP +.B multi[write]-with-gauge ... +.RS 4 +Like "write-with-gauge", but with multiple load adddresses and files, +all sharing the same progress bar. +.RE +.PP +.B multi[write]-with-xgauge ... +.RS 4 +Like "write-with-xgauge", but with multiple load adddresses and files, +all sharing the same progress bar. +.RE +.PP +.B echo-gauge "some text" +.RS 4 +Update prompt/caption for gauge output. This outputs a command to be +interpreted by "dialog" to change the caption text. +.RE +.PP +.B ver[sion] +.RS 4 +Show the BROM version. This prints some static data, among other things +containing the detected SoC. Can be used to verify a FEL connection is working. +.RE +.PP +.B sid +.RS 4 +Retrieve and output the 128-bit SID key. This key contains some form of serial +number, which should be unique to each chip (although there have been reports +of same SIDs for particular batches of chips). +.RE +.PP +.B sid-register +.RS 4 +As the "sid" command above, but use the alternative MMIO register access method +on the device. Some SoCs require this method for reliable results. +.RE +.PP +.B clear
+.RS 4 +Clear bytes of memory starting at
(filling with zeroes). +.RE +.PP +.B fill
+.RS 4 +Fills bytes of memory starting at
with the byte . +.RE +.PP +.B spiflash-info +.RS 4 +Retrieves basic information about a SPI flash chip attached to the SPI0 pins. +This is using the same method as the BootROM does, to accesses the same storage +that the device could boot from. + +Prints the manufacturer of the flash chip and +its capacity. Should also be used to detect the presence of a SPI flash chip. +.RE +.PP +.B spiflash-read +.RS 4 +Reads bytes starting from offset of a SPI flash chip, storing +the result into . +.RE +.PP +.B spiflash-write +.RS 4 +Reads and stores its content in the SPI flash, starting at offset . +.RE +.SH EXAMPLES +.RS 4 +\fB$\fR sunxi-fel -v -p ver +.RE +.sp +.RS 4 +\fB$\fR sunxi-fel uboot u-boot-sunxi-with-spl.bin +.RE +.sp +.RS 4 +\fB$\fR sunxi-fel -v -p spl sunxi-spl.bin write 0x44000 bl31.bin write 0x4a000000 u-boot.bin reset64 0x44000 +.RE +.SH AUTHOR +Andre Przywara diff -Nru sunxi-tools-1.4.2+git20211216.02a865/tests/test_bin2fex_corner_cases.sh sunxi-tools-1.4.2+git20220212.08e209/tests/test_bin2fex_corner_cases.sh --- sunxi-tools-1.4.2+git20211216.02a865/tests/test_bin2fex_corner_cases.sh 2022-01-16 08:58:47.000000000 +0000 +++ sunxi-tools-1.4.2+git20220212.08e209/tests/test_bin2fex_corner_cases.sh 2022-02-12 23:15:28.000000000 +0000 @@ -7,6 +7,11 @@ # use sunxi-fexc in "fex2bin" mode, testing explicit parameters at the same time FEX2BIN="../sunxi-fexc -v -q -I fex -O bin" +if [ ! -e "${TESTFILE}" } ; then + echo >&2 "Skipping $(basename $0), no board files found" + exit 0 +fi + ${FEX2BIN} ${TESTFILE}.fex ${TESTFILE}.bin # have bin2fex explicitly read /dev/stdin, to force use of fexc.c's "read_all()" cat ${TESTFILE}.bin | ${BIN2FEX} /dev/stdin > /dev/null