Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

U-Boot Command Prompt #1

Closed
jzlynn opened this issue May 15, 2024 · 5 comments
Closed

U-Boot Command Prompt #1

jzlynn opened this issue May 15, 2024 · 5 comments

Comments

@jzlynn
Copy link

jzlynn commented May 15, 2024

Hi Lup, thanks for your build and it's really a nice work!
I followed your detailed README, but met problems whenever I tried to run commands in u-boot:

$setenv tftp_server 192.168.31.10 ; dhcp ${kernel_addr_r} ${tftp_server}:Image-sg2000 ;
tftpboot ${fdt_addr_r} ${tftp_server}:jh7110-star64-pine64.dtb ; fdt addr ${fdt_addr_r} ;
booti ${kernel_addr_r} - ${fdt_addr_r}

I am stucked at the second step:
dhcp ${kernel_addr_r} ${tftp_server}
Speed: 100, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4
BOOTP broadcast 5
BOOTP broadcast 6
BOOTP broadcast 7
BOOTP broadcast 8
BOOTP broadcast 9
BOOTP broadcast 10
BOOTP broadcast 11
BOOTP broadcast 12
BOOTP broadcast 13
BOOTP broadcast 14
BOOTP broadcast 15
BOOTP broadcast 16
BOOTP broadcast 17

Retry time exceeded; starting again

And when I tried to ping the host, I got:
cv181x_c906# ping 192.168.1.2
Speed: 100, full duplex
***** ERROR: `ipaddr' not set**
ping failed; host 192.168.1.2 is not alive

It said that 'ipaddr' not set but I did set it, and this is my environment:
cv181x_c906# printenv
arch=riscv
baudrate=115200
board=mars
board_name=mars
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_efi_binary=load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootriscv64.efi; if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r};else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi
boot_efi_bootmgr=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr;fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=mmc0 dhcp pxe
bootcmd=run distro_bootcmd || run sdboot || run sdbootauto
bootcmd_dhcp=devtype=dhcp; if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi;setenv efi_fdtfile ${fdtfile}; setenv efi_old_vci ${bootp_vci};setenv efi_old_arch ${bootp_arch};setenv bootp_vci PXEClient:Arch:00027:UNDI:003000;setenv bootp_arch 0x1b;if dhcp ${kernel_addr_r}; then tftpboot ${fdt_addr_r} dtb/${efi_fdtfile};if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r}; else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi;fi;setenv bootp_vci ${efi_old_vci};setenv bootp_arch ${efi_old_arch};setenv efi_fdtfile;setenv efi_old_arch;setenv efi_old_vci;
bootcmd_mmc0=devnum=0; run mmc_boot
bootcmd_pxe=dhcp; if pxe get; then pxe boot; fi
bootdelay=1
consoledev=ttyS0
cpu=generic
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
efi_dtb_prefixes=/ /dtb/ /dtb/current/
ethact=ethernet@4070000
fdt_addr_r=0x81200000
fdtcontroladdr=9f27f810
fdtfile=cv181x_milkv_duos_sd.dtb
fdtoverlay_addr_r=0x81300000
gatewayip=192.168.1.11
ipaddr=192.168.1.1
kernel_addr_r=0x80200000
kernel_comp_addr_r=0x81800000
kernel_comp_size=0x1000000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
netdev=eth0
netmask=255.255.255.0
othbootargs=earlycon=sbi riscv.fwsz=0x80000 loglevel=9
pxefile_addr_r=0x81400000
ramdisk_addr_r=0x84000000
root=root=/dev/mmcblk0p2 rootwait rw
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;run scan_dev_for_efi;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done; setenv devplist
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile}; then run load_efi_dtb; fi;done;run boot_efi_bootmgr;if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/bootriscv64.efi; then echo Found EFI removable media binary efi/boot/bootriscv64.efi; run boot_efi_binary; echo EFI LOAD FAILED: continuing...; fi; setenv efi_fdtfile
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scriptaddr=0x81500000
sdboot=setenv bootargs ${reserved_mem} ${root} ${mtdparts} console=$consoledev,$baudrate $othbootargs;echo Boot from SD dev ${sddev} ...;mmc dev ${sddev} && fatload mmc ${sddev} ${uImage_addr} boot.sd;if test $? -eq 0; then bootm ${uImage_addr}#config-cv181x_milkv_duos_sd;fi;
sdbootauto=cvi_sd_boot;setenv bootargs ${reserved_mem} ${root} ${mtdparts} console=$consoledev,$baudrate $othbootargs;echo Boot from SD dev ${sddev} auto ...;mmc dev ${sddev} && fatload mmc ${sddev} ${uImage_addr} boot.sd;if test $? -eq 0; then bootm ${uImage_addr}#config-cv181x_milkv_duos_sd;fi;
sddev=0
serverip=192.168.1.2
stderr=serial
stdin=serial
stdout=serial
tftp_server=192.168.1.2
uImage_addr=0x81800000
update_addr=0x9fe00000
vendor=cvitek

Environment size: 4378/131068 bytes.

where 192.168.1.2 is the Ipv4 addr of my pc and 192.168.1.1 is the ipaddr I set manually in u-boot.

I can successfully ping the board from my host when i am on the board terminal. I am really confused and wonder if you could offer some suggestions?

Thanks!

@lupyuen
Copy link
Owner

lupyuen commented May 15, 2024

Hi: Thank you so much for testing this :-) Sorry I'm cleaning up the instructions, please bear with me, the latest steps are here: https://github.com/lupyuen/lupyuen.github.io/blob/master/src/sg2000.md#boot-nuttx-over-tftp

I see that you're having problems with this:

## Set the U-Boot TFTP Server
## TODO: Change to your TFTP Server
setenv tftp_server 192.168.31.10

## Fetch the IP Address over DHCP
## Load the NuttX Image from TFTP Server
## kernel_addr_r=0x80200000
dhcp ${kernel_addr_r} ${tftp_server}:Image-sg2000

I understand that you're using Static IP Addresses, not DHCP Dynamic IP Addresses? Maybe that's why the dhcp command is failing, it couldn't get an IP Address from the DHCP Server.

Wonder if you could try this? It might work with the Static IP Address:

## Load the NuttX Image from TFTP Server
## kernel_addr_r=0x80200000
tftpboot ${kernel_addr_r} ${tftp_server}:Image-sg2000

Please lemme know what happens. Thanks! :-)

@jzlynn
Copy link
Author

jzlynn commented May 16, 2024

Thanks so much for your reply!!!!
I followed your new instruction and this command worked for me!
bootcmd_tftp=tftpboot ${kernel_addr_r} ${tftp_server}:Image-sg2000 ; tftpboot ${fdt_addr_r} ${tftp_server}:jh7110-star64-pine64.dtb ; fdt addr ${fdt_addr_r} ; booti ${kernel_addr_r} - ${fdt_addr_r}

I saw the '123' printed and entered the NuttX terminal. Great. But I have come up some new questions (sorry I'm new to this field..):

  1. I think I only boot a bit now and I'm not sure how to fix the NuttX drive on PLIC: link. My understand is to rebuild the NuttX image using the right config, is that correct?
  2. For the incomplete version of NuttX, every time I run 'exit', it gets stuck:
    `
    nsh> exit
    posix_spawn: pid=0xc0202968 path=exit file_actions=0xc0202970 attr=0xc0202978 argv=0xc0202a18
    exec_internal: ERROR: Failed to load program 'exit': -2
    nxposix_spawn_exec: ERROR: exec failed: 2
    nxtask_exit: /system/bin/init pid=3,TCB=0x8040b730

`
3. If we set auto-boot the NuttX, how do we switch to this system after we're on the board terminal?

Hope my silly questions will not bother you and thanks in advance!

@lupyuen
Copy link
Owner

lupyuen commented May 16, 2024

That's super awesome, thank you so much! :-)

  1. I think I only boot a bit now and I'm not sure how to fix the NuttX drive on PLIC: link. My understand is to rebuild the NuttX image using the right config, is that correct?

No worries, the PLIC fixes have already been added to the sg2000 branch. Here's everything that we have fixed in the branch: https://github.com/lupyuen2/wip-nuttx/commits/sg2000/?author=lupyuen

2. For the incomplete version of NuttX, every time I run 'exit', it gets stuck:

Yep I think exit won't work on NuttX SG2000, since it doesn't know how to Shutdown or Reboot :-)

  1. If we set auto-boot the NuttX, how do we switch to this system after we're on the board terminal?

If we follow the instructions here: https://github.com/lupyuen/lupyuen.github.io/blob/master/src/sg2000.md#boot-nuttx-over-tftp

## Add the Boot Command for TFTP
setenv bootcmd_tftp 'dhcp ${kernel_addr_r} ${tftp_server}:Image-sg2000 ; tftpboot ${fdt_addr_r} ${tftp_server}:jh7110-star64-pine64.dtb ; fdt addr ${fdt_addr_r} ; booti ${kernel_addr_r} - ${fdt_addr_r}'

## Save it for future reboots
saveenv

## Test the Boot Command for TFTP, then reboot
run bootcmd_tftp

## Remember the Original Boot Targets: `mmc0 dhcp pxe`
setenv orig_boot_targets "$boot_targets"

## Prepend TFTP to the Boot Targets: `tftp mmc0 dhcp pxe`
setenv boot_targets "tftp $boot_targets"

## Save it for future reboots
saveenv

Note that we save the Original Boot Targets: mmc0 dhcp pxe. So to undo the auto-boot:

  1. Power up SG2000 and press Enter until the U-Boot Prompt appears

  2. Restore the Original Boot Targets:

    setenv boot_targets "$orig_boot_targets"
    
    ## Or This:
    ## setenv boot_targets "mmc0 dhcp pxe"
  3. Save the U-Boot Settings:

    saveenv

Hope this makes sense :-)

@jzlynn
Copy link
Author

jzlynn commented May 16, 2024

Kudos! I'm new to the embedded systems and these stuff, but I found it super interesting. Thanks again for your contribution and patience as well.. I'm expecting to see more explorations of NuttX on different OS or boards!

ps: Would you mind writing a study note about your contributions to share online? I believe there will be many people interested : )

@lupyuen
Copy link
Owner

lupyuen commented May 16, 2024

Thanks again for being my very first tester for NuttX on SG2000, I really appreciate your feedback! :-)

This weekend I'll publish my article on NuttX for SG2000. Also I'll have a quick Q&A on SG2000 at the Apache NuttX International Workshop (free to join online). Stay tuned! :-)

@jzlynn jzlynn closed this as completed May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants