This is a cache of https://discuss.96boards.org/t/error-on-stock-u-boot-fastboot-unknown-command-source/1876. It is a snapshot of the page at 2024-11-01T07:14:27.118+0000.
Error on stock u-boot/fastboot - Unknown command 'source' - Poplar Board - 96Boards Forum

Error on stock u-boot/fastboot - Unknown command 'source'

I am having an issue on the last step of the build and flash instructions:
https://github.com/Linaro/poplar-tools/blob/latest/build_instructions.md

Seems the stock fastboot/u-boot does not recognize the “source” command:

 usb reset
 fatload usb 0:1 ${scriptaddr} install.scr
 source ${scriptaddr}

Did not work so I ran the older commands and got to the last step:

usb reset
fatsize usb 0:1 install.scr
fatload usb 0:1 0x07000000 install.scr
source 0x07000000

fastboot# source 0x07000000                                                
Unknown command 'source' - try 'help'                                           
fastboot# 

Stock fastboot version: Fastboot 3.3.0 (stb@collin-ubuntu) (Aug 25 2016 - 19:07:47)

Maybe use setenv?

setenv source ${scriptaddr}

usb reset
setenv scriptaddr 0x07000000
setenv source ${scriptaddr}
saveenv
fatload usb 0:1 ${scriptaddr} install.scr

I’ll try this in a few…

Did not work.

Here is full output of how the instruction are written now:

fastboot# usb reset                                                             
(Re)start USB...                                                                
USB0:   Register 1111 NbrPorts 1                                                
USB EHCI 1.00                                                                   
scanning bus 0 for devices... 3 USB Device(s) found                             
       scanning usb for storage devices... 1 Storage Device(s) found            
fastboot# fatload usb 0:1 ${scriptaddr} install.scr                             
usage: fatload <interface> <dev[:part]> <addr> <filename> [bytes]               
fastboot# source ${scriptaddr}                                                  
Unknown command 'source' - try 'help'                                           
fastboot#

Getting closer… Just need to execute the install.scr script but how without ‘source’ command…

   fastboot# usb reset
    (Re)start USB...
    USB0:   Register 1111 NbrPorts 1
    USB EHCI 1.00
    scanning bus 0 for devices... 3 USB Device(s) found
           scanning usb for storage devices... 1 Storage Device(s) found
    fastboot# setenv scriptaddr 0x07000000
    fastboot# setenv source ${scriptaddr}
    fastboot# saveenv
    Saving Environment to eMMC...
    done
    fastboot# fatload usb 0:1 ${scriptaddr} install.scr
    reading install.scr

    1841 bytes read
    fastboot# source ${scriptaddr}
    Unknown command 'source' - try 'help'
    fastboot#

So just a bit of research shows that the current fastboot/u-boot that comes preinstalled on poplar has no support for the source command built into u-boot.

define CONFIG_CMD_SOURCE=y

I’m going to try to tftp the new u-boot/l-boot next chance I get. In the meantime any pointers would be appreciated :wink:

You can download the images over TFTP after setting the network parameters:

setenv serverip xxx.xxx.xxx.xxx
setenv ipaddr xxx.xxx.xxx.xxx
setenv gatewayip xxx.xxx.xxx.xxx
setenv ethaddr 00:xx:xx:xx:xx:xx
setenv netmask 255.255.xxx.0

To download the boot image:

    mw.b 1000000 ff 80000                       //Write 0xff to 0x1000000. 0x80000 space is used.
    tftp 1000000 fastboot-burn.bin              //Download fastboot-burn.bin to 0x1000000.
    nand erase 0 100000                         //Erase the 0x100000 flash space after the 0x0 address.
    nand write 1000000 0 80000

I’m afraid I only really have experience with the (new) 64-bit u-boot.

However, what I can assure you is that can experiment with that non-destructively. If fastboot.bin is copied to a FAT32 partition on a USB stick then the poplar boot ROM can be made to load that by holding down the USB_BOOT button. This allows you to experiment with what is (and isn’t) supported by the 64-bit version without altering eMMC (just make sure you say “No” when asked if you want to do the install… or just git revert 1de155d0a).

The 64-bit u-boot does not currently support the built-in network interface (although I think networking can be achieved via USB). More importantly using USB means it supports the regular distro mechanisms of a modern u-boot (i.e. it fetches extlinux/extlinux.conf automatically from USB and uses that to launch a kernel).

I’ve used this feature to construct a proof-of-concept installer that loads Linux and a buildroot userspace (this could also be used to backup the original contents of eMMC if you wanted to… although I didn’t actually bother with that myself).

The same distro mechanisms remain in place once u-boot is burned to eMMC. It will try USB first and if it does not find a suitable extlinux.conf it will go looking on the eMMC instead.

So you are saying I can put the newest uboot/lboot on a USB drive rename it to fastboot.bin and press USB button to load and flash new u-boot??

Almost… if you just drop fastboot.bin onto a USB stick that you will make that stick bootable by poplar, subject to some restrictions on partitioning and filesystem. If you drop only fastboot.bin on the stick then the rest of the installer will be missing (so I wouldn’t advise saying “YES” if it asks you if you want to install u-boot).

However, if you say anything except YES then u-boot will run its distro boot protocols (including a boot auto-delay if you just want to poke about at the prompt.

If you augment fastboot.bin with extlinux/extlinux.conf (appropriately configured), Image and ramdisk.cpio.gz in the same filesystem then you can boot the kernel from USB.

Okay so I created the USB with the poplar tools and this has the new l-boot so I can press USB and yes to update mmc with the full usb_recovery.img correct?

Yes. This will install (a slightly tailored) debian stretch together with ARM trusted firmware, bootloader and kernel. There is pretty limited hardware enablement right now.

I guess I should also note (if not for you then for other interested readers) that after saying YES the action will be very difficult to reverse. I don’t think there are any tools available to help restore the original partitioning and images.

That is good to know. So lets say if one wanted to test the u-boot/l-boot (without committing to writing to flash) you would press USB_BOOT button then type anything BUT “YES” at the prompt and the poplar will just boot and run from USB. Correct?

Very good to know when testing other OS’s…

Tocoding has images available to restore the original image. They are available at: http://www.tocoding.com/index.php/96board-hitv/

I also see that they are now linking to the Linux Release on GitHub.org/Linao.

Lets just say that I chose the word “difficult” with some care!

For sure it is not impossible… but there are no flashing tools to help. The user would need to author their own USB image and hand craft all the fatload/mmc write commands for themselves!

My own scripts for non-destructive fiddling look something like this:

#!/bin/sh

# Currently guestfish offers no way to force FAT32 when creating a vfat
# filesystem. The poplar boot ROM only supports FAT32 so we have to
# pre-format the boot filesystem.
guestfish sparse poplar-install.img 63M
mkfs.vfat -F 32 -n INSTALL poplar-install.img

cat <<EOF >>extlinux.conf
default Buildroot
timeout 3

label Buildroot
        kernel ../Image
        append quiet
        fdtdir ../
        initrd ../rootfs.cpio.gz
EOF

guestfish <<EOF
sparse poplar-debian-installer.img 64M
scratch 512M
run

part-init /dev/sda mbr
part-add /dev/sda p 2048 131071
part-set-mbr-id /dev/sda 1 0xc
part-set-bootable /dev/sda 1 true

mkfs ext4 /dev/sdb
mount /dev/sdb /

# "Format" /dev/sda1
copy-in poplar-install.img /
copy-file-to-device /poplar-install.img /dev/sda1

mkdir-p /boot
mount /dev/sda1 /boot
mkdir-p /boot/extlinux
copy-in overlay/root/fastboot.bin /boot
copy-in extlinux.conf /boot/extlinux
copy-in overlay/root/boot/Image /boot
copy-in overlay/root/boot/hi3798cv200-poplar.dtb /boot
copy-in output/images/rootfs.cpio.gz /boot
copy-in overlay/root/README.md /boot
EOF

rm poplar-install.img
rm extlinux.conf

I’ve been using buildroot build and this script is the final step in the build process (using BR2_ROOTFS_POST_IMAGE_SCRIPT="./generate-media.sh"). The only other thing about my buildroot that is at all interesting is the overlay directory (BR2_ROOTFS_OVERLAY="./overlay") where I’ve copied fastboot.bin, a kernel and a dtb.

The overlay directory is not just used to construct the media, it is also copied into the initial ramdisk (so I can install stuff to eMMC if I want).

BTW I’m not trying to drip feed information here. This stuff was all put together as a proof-of-concept and I’ve not tied it up nicely for anyone to play with (?yet?).

I managed to flash the newer u-boot/l-boot using USB_BOOT button and now I can see the u-boot prompt but the script failed to flash the linaro stretch to internal mmc.

This error repeats over and over. No worries tho as long as u-boot is there I can use extlinux.conf to load an OS :wink:

poplar# usb reset                                                               
resetting USB...                                                                
USB0:   USB EHCI 1.00                                                           
scanning bus 0 for devices... 3 USB Device(s) found                             
       scanning usb for storage devices... 1 Storage Device(s) found            
       scanning usb for ethernet devices... 0 Ethernet Device(s) found          
poplar# fatload usb 0:1 ${scriptaddr} install.scr                               
reading install.scr                                                             
1841 bytes read in 21 ms (85 KiB/s)                                             
poplar# source ${scriptaddr}                                                    
## Executing script at 32000000                                                 
reading mbr.gz                                                                  
159 bytes read in 16 ms (8.8 KiB/s)                                             
Uncompressed size: 512 = 0x200                                                  
                                                                                
MMC write: dev # 0, block # 0, count 1 ... 1 blocks written: OK                 
                                                                                
reading partition1.1-of-1.gz                                                    
223849 bytes read in 33 ms (6.5 MiB/s)                                          
Uncompressed size: 4193792 = 0x3FFE00                                           
                                                                                
MMC write: dev # 0, block # 1, count 8191 ... 8191 blocks written: OK           
                                                                                
reading partition2.1-of-1.gz                                                    
7229954 bytes read in 229 ms (30.1 MiB/s)                                       
Uncompressed size: 134217728 = 0x8000000                                        
                                                                                
MMC write: dev # 0, block # 8192, count 262144 ... 262144 blocks written: OK    
                                                                                
reading partition3.1-of-8.gz                                                    
52855584 bytes read in 1530 ms (32.9 MiB/s)                                     
Uncompressed size: 268435456 = 0x10000000                                       
                                                                                
MMC write: dev # 0, block # 270336, count 524288 ... 524288 blocks written: OK  
                                                                                
reading partition3.2-of-8.gz                                                    
EHCI timed out on TD - token=0x2c008d80                                         
EHCI timed out on TD - token=0x80008d80                                         
EHCI timed out on TD - token=0x80008d80                                         
EHCI timed out on TD - token=0x80008d80                                         
EHCI timed out on TD - token=0x80128d80                                         
EHCI timed out on TD - token=0x80008d80                                         
EHCI timed out on TD - token=0x80008d80                                         
EHCI timed out on TD - token=0x80008d80                                         
EHCI timed out on TD - token=0x801f8c80                                         
EHCI timed out on TD - token=0x80008d80                                         
EHCI timed out on TD - token=0x80008d80                                         
EHCI timed out on TD - token=0x80008d80                                         
EHCI timed out on TD - token=0x801f8c80                                         
EHCI timed out on TD - token=0x80008d80                                         
EHCI timed out on TD - token=0x80008d80                                         
EHCI timed out on TD - token=0x80008d80                                         
EHCI timed out on TD - token=0x801f8c80                                         
EHCI timed out on TD - token=0x80008d80                                         
EHCI timed out on TD - token=0x80008d80                                         
EHCI timed out on TD - token=0x80008d80                                         
EHCI timed out on TD - token=0x801f8c80                                         
EHCI timed out on TD - token=0x80008d80                                         
EHCI timed out on TD - token=0x80008d80                                         
EHCI timed out on TD - token=0x80008d80                                         
Error reading cluster                                                           
** Unable to read file partition3.2-of-8.gz **                                  
Error: inflate() returned -3


poplar# reset
resetting ...
INFO:    PSCI Power Domain Map:
INFO:      Domain Node : Level 1, parent_node -1, State ON (0x0)
INFO:      Domain Node : Level 0, parent_node 0, State ON (0x0)
INFO:      Domain Node : Level 0, parent_node 0, State ON (0x0)
INFO:      Domain Node : Level 0, parent_node 0, State ON (0x0)
INFO:      CPU Node : MPID 0x0, parent_node 0, State ON (0x0)
INFO:      CPU Node : MPID 0xffffffffffffffff, parent_node 0, State OFF (0x2)
INFO:      CPU Node : MPID 0xffffffffffffffff, parent_node 0, State OFF (0x2)
INFO:      CPU Node : MPID 0xffffffffffffffff, parent_node 0, ▒
Bootrom start
Boot Media: eMMC
Decrypt auxiliary code ...OK

lsadc voltage min: 000000FF, max: 000000FF, aver: 000000FF, index: 00000000

Entry boot auxiliary code

Auxiliary code - v1.00
DDR code - V1.1.2 20160205
Build: Mar 24 2016 - 17:09:44

Reg Version:  v134
Reg Time:     2016/03/18 09:44:55
Reg Name:     hi3798cv2dmb_hi3798cv200_ddr3_2gbyte_8bitx4_4layers.reg

Boot auxiliary code success
Bootrom success

LOADER:  Switched to aarch64 mode
LOADER:  Entering ARM TRUSTED FIRMWARE
LOADER:  CPU0 executes at 0x000ce000

INFO:    BL1: 0xe1000 - 0xe7000 [size = 24576]
NOTICE:  Booting Trusted Firmware
NOTICE:  BL1: v1.3(debug):e5a3825
NOTICE:  BL1: Built : 13:47:53, May 16 2017
INFO:    BL1: RAM 0xe1000 - 0xe7000
INFO:    BL1: Loading BL2
INFO:    Loading image id=1 at address 0xe9000
INFO:    Image id=1 loaded at address 0xe9000, size = 0x5008
NOTICE:  BL1: Booting BL2
INFO:    Entry point address = 0xe9000
INFO:    SPSR = 0x3c5
NOTICE:  BL2: v1.3(debug):e5a3825
NOTICE:  BL2: Built : 13:47:56, May 16 2017
INFO:    BL2: Loading BL31
INFO:    Loading image id=3 at address 0x129000
INFO:    Image id=3 loaded at address 0x129000, size = 0x7020
INFO:    BL2: Loading BL33
INFO:    Loading image id=5 at address 0x37000000
INFO:    Image id=5 loaded at address 0x37000000, size = 0x566b7
NOTICE:  BL1: Booting BL31
INFO:    Entry point address = 0x129000
INFO:    SPSR = 0x3cd
INFO:    Boot bl33 from 0x37000000 for 353975 Bytes
NOTICE:  BL31: v1.3(debug):e5a3825
NOTICE:  BL31: Built : 13:48:00, May 16 2017
INFO:    ARM GICv2 driver initialized
INFO:    BL31: Initializing runtime services
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x37000000
INFO:    SPSR = 0x3c9


U-Boot 2017.05-g1de155d (May 16 2017 - 13:46:54 -0400)poplar

Model: HiSilicon Poplar Development Board
BOARD: Hisilicon HI3798cv200 Poplar
DRAM:  1 GiB
MMC:   Hisilicon DWMMC: 0
*** Warning - bad CRC, using default environment

In:    serial@8b00000
Out:   serial@8b00000
Err:   serial@8b00000
Net:   Net Initialization Skipped
No ethernet found.
Hit any key to stop autoboot:  0
poplar# mmc info
Device: Hisilicon DWMMC
Manufacturer ID: 15
OEM: 100
Name: 8WPD3
Tran Speed: 52000000
Rd Block Len: 512
MMC version 5.0
High Capacity: Yes
Capacity: 7.3 GiB
Bus Width: 8-bit
Erase Group Size: 512 KiB
HC WP Group Size: 8 MiB
User Capacity: 7.3 GiB WRREL
Boot Capacity: 4 MiB ENH
RPMB Capacity: 512 KiB ENH
poplar# printenv
arch=arm
baudrate=115200
board=poplar
board_name=poplar
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${pref}
boot_efi_binary=load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} ei
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr}f
boot_net_usb_start=usb start
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_targets=usb0 mmc0 dhcp
bootcmd=run distro_bootcmd
bootcmd_dhcp=run boot_net_usb_start; if dhcp ${scriptaddr} ${boot_script_dhcp};;
bootcmd_mmc0=setenv devnum 0; run mmc_boot
bootcmd_usb0=setenv devnum 0; run usb_boot
bootdelay=2
cpu=armv8
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
efi_dtb_prefixes=/ /dtb/ /dtb/current/
env_mmc_blknum=0xF0000
env_mmc_nblks=0x80
fdt_addr_r=0x32200000
fdtcontroladdr=3df4faf0
kernel_addr_r=0x30000000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefi}
loader_mmc_blknum=0x0
loader_mmc_nblks=0x780
mmc_boot=if mmc dev ${devnum}; then setenv devtype mmc; run scan_dev_for_boot_pi
pxefile_addr_r=0x32000000
ramdisk_addr_r=0x32400000
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env ee
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; for prefix in ${efi_dtb_prefixee
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${e
scriptaddr=0x32000000
soc=hi3798cv200
stderr=serial@8b00000
stdin=serial@8b00000
stdout=serial@8b00000
usb_boot=usb start; if usb dev ${devnum}; then setenv devtype usb; run scan_devi
vendor=hisilicon

I have a problem with this last step too. When I run:
fatload usb 0:1 ${scriptaddr} install.src
it shows:
reading install.src
** Unable to read file install.src **

Tried the updated instructions, not even working unknown command “source” yet again…

@mattgorski I’ve been using the updated instructions (https://github.com/Linaro/poplar-tools/blob/latest/build_instructions.md) for ~2 months now without issues. Have you tried flashing the latest build first using USB_BOOT?

@mattgorski: Can you provide the full boot logs in a pastebin somewhere?