Hi,
I am running on kernel 4.19.46 Ubuntu distro.
I have a LS1021a - twr eva board and it's booted from SD card but in the future will be an external eMMC. I am thinking to have two copies of image in the system if one is broken the u-boot or bootloader can detect next time upon boot and it will switch to the working version automatically. Any one knows how to achieve this purpose?
Hello Elias Bitbaker,
You could define a u-boot environment variable boot_status, if boot_status is 1, boot system 1 and reset boot_status as 0, after boot into system 1 Linux, then modify u-boot environment variable boot_status as 1. If the system enter into watchdog exception, the variable boot_status is still 0, then boot system 2 after reset.
Thanks,
Yiping
Hi Yipin,
Changing the variable as you mentioned needs to be done in the linux userspace right? I am able to switch partition to boot different distro now but I installed u-boot-tool in the linux and it shows error :
After I run "apt-get install u-boot-tools"
then I perform fw_printenv in the linux it tells me that
Cannot parse config file '/etc/fw_env.config': No such file or directory
On the target, please create a configuration file /etc/fw_env.config, the content like this
/dev/mtd5 0x60000 0x2000 0x100000
MTD device name
Device Offset
Environment Size
Flash sector size
Then execute "fw_printenv" and "fw_setenv" to read and write u-boot environment
Please refer to the following definition in include/configs/ls1021atwr.h in u-boot source code.
#if defined(CONFIG_SD_BOOT)
#define CONFIG_ENV_OFFSET 0x300000
#define CONFIG_SYS_MMC_ENV_DEV 0
#define CONFIG_ENV_SIZE 0x20000
Please refer to the content in /etc/fw_env.config
# Device name Offset Size
/dev/mmcblk0 0x300000 0x20000
Hi Yiping,
I do not think I used this u-boot source code while compiling my kernel. How am I able to add this into my device after?
I mean after I copy this new offset and size into the fw_env.config it still show me CRC warning. Do I need to install the u-boot source code into the target device and run first ?
Hello Elias Bitbaker,
After editing /etc/fw_env.config, you could write u-boot environment variable with fw_setenv command.
Thanks,
Yiping
Hi Yiping,
Everything is set up correctly now, but I want to purposely damage the first filesystem and trigger the watchdog timer to throw exception so that the system can automatically reboot after the watchdog timer expires.
I was doing something in the uboot:
=> mm.b 0x2ad0000
02ad0000: 00 ?
02ad0001: 30 ?
according to the date sheet 1021ARM let's assume I want to set the time to 8 seconds so
02ad0000: 00 ? ---------------------------------> 0000 1111 --------->0x0f
since 0x00 is 0.5 seconds
.
.
so 0x 0f is 8 seconds
then enable the watch dog timer by setting up bit 13 to 1 which is
02ad0001: 30 ? -----------------------------------> 0000 0100 ------->0x04
not sure if the value I gave is correct. But after I set up the values and reboot the device the values go back to default:
02ad0000: 00 ?
02ad0001: 30 ?
do you know how to save the changes ?
Please create a new thread to track your latest problem.
I put something like this:
/dev/mmcblk0 0x7000 0x1000 0x1000
then it works but I am not sure if it's correct when I use command fw_printenv
it shows:
===================
Warning: Bad CRC, using default environment
bootcmd=run distro_bootcmd
bootdelay=2
baudrate=115200
stdin=serial,cros-ec-keyb,usbkbd
stdout=serial,vidconsole
stderr=serial,vidconsole
ethaddr=00:00:11:22:33:44
eth1addr=00:00:11:22:33:45
eth3addr=00:00:11:22:33:46
eth5addr=00:00:11:22:33:47
ipaddr=1.2.3.4
host_boot=if host dev ${devnum}; then setenv devtype host; run scan_dev_for_boot_part; fi
sata_boot=if sata dev ${devnum}; then setenv devtype sata; run scan_dev_for_boot_part; fi
scsi_init=if ${scsi_need_init}; then setenv scsi_need_init false; scsi scan; fi
scsi_boot=run scsi_init; if scsi dev ${devnum}; then setenv devtype scsi; run scan_dev_for_boot_part; fi
boot_prefixes=/ /boot/
boot_scripts=boot.scr.uimg boot.scr
boot_script_dhcp=boot.scr.uimg
boot_targets=host1 host0
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}extlinux/extlinux.conf
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}extlinux/extlinux.conf; then echo Found ${prefix}extlinux/extlinux.conf; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
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
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;
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
bootcmd_host1=setenv devnum 1; run host_boot
bootcmd_host0=setenv devnum 0; run host_boot
distro_bootcmd=setenv scsi_need_init; for target in ${boot_targets}; do run bootcmd_${target}; done
bootm_size=0x10000000
kernel_addr_r=0x1000000
fdt_addr_r=0xc00000
ramdisk_addr_r=0x2000000
scriptaddr=0x1000
pxefile_addr_r=0x2000
========================
Seems like the mac address of the eth0 eth1 eht2 is not correct compares to the one I saw in the u-boot prompt "printenv"
Also when i perform
"setenv devpart_root 3" in the uboot prompt I am able to boot the roof file system that is saved from my partition 3
but when I was trying to set a variable called:
fw_setenv devpart_root 3
from the userspace it will crash the device
Hi Yiping,
I get the point. I really want to know
(1) how to wording the bootargs so that the system will know it will boot into system 2 (what arguments or format I can use)
take this in the boot environment as an example:
==========================================================================================
bootcmd=run distro_bootcmd; run sd_bootcmd; env exists secureboot && esbc_halt;
bootcmd_mmc0=devnum=0; run mmc_boot
bootcmd_usb0=devnum=0; run usb_boot
==========================================================================================
How to write a system 2 in these arguments in my case must be in bootcmd_mmc0.
(2) Where or what partition should I save the second system. Is it under a different partition? if so do I need to mount that partition into the system first ?
or I am using lsdk1906 There are 4 partitions in the sd card:
/dev/mmcblk0p1 880K 72K 240K 24% /media/misc
/dev/mmcblk0p2 37M 14M 19M 42% /media/boot
/dev/mmcblk0p3 104M 3.1M 89M 4% /media/backup
/dev/mmcblk0p4 6.0G 481M 5.3G 9% /media/system
How can I take use of the backup partition? In other words how to make this partition bootable?
(3) When "modify u-boot environment variable boot_status as 1" is this done via the userspace? if so do I need to write a script like bash to change the values automatically or it is done by u-boot-tools? This should not be done manually.
Thanks !