Hi,
Openwrt by default have single partition and while doing firmware upgrade from openwrt GUI then it would upgrade default partition and boot from the same partition.
But In my case, i have 2 partition(primary and secondary). what my use case is when we do firmware upgrade from openwrt GUI then it should upgrade the secondary partition and boot from the updated partition i.e., secondary partition or vice versa.
So we have one u-boot arguments i.e., primary whose value would be 0 or 1 i.e., 0 for primary partition and 1 for secondary partition. i want to read this u-boot argument from the script paltform.sh which is running on doing firmware upgrade from GUI using command fw_printenv primary but i am not able to run this command from platform.sh script and it shows the following error:
fw_printenv
ash: fw_printenv: not found
Please help me in this i am stuck over here.
or is there any other way to do firmware upgrade while having 2 partitions in board?
fw_printenv is only included in targets that require it.
If you are experimenting with a new target or modifying another, you will need to install it (not sure if that is possible) or recompile to include it.
I believe the relevant config line is
CONFIG_DEFAULT_uboot-envtools=y
Thank you for your reply.
I have already enabled this env tool(CONFIG_DEFAULT_uboot-envtools=y) and working fine when board is properly boot-up but when i add these commands in platform.sh and common.sh which is running when doing firmware upgrade then only these commands are not getting executed and showing error (error: not found).
If u want then i can share platform.sh and common.sh file with you.
If u can check platform.sh and common.sh file please check because i am stuck over here and not able to do upgrade in alternate partition.
Please help.
Thank a lot in advance.
i have added the thing which u mentioned in comments in platform.sh file RAMFS_COPY_BIN='fw_printenv fw_setenv' RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
and also try to do firmware upgarde using the following command: sysupgrade -v /tmp/firmware.img
But still i am getting same error which is shown below:
**+ fw_printenv primary**
**ash: fw_printenv: not found**
**+ cut -b 9**
**+ check=**
**+ echo !!!!*********** check is *************!!!!!!!!!!**
**!!!!*********** check is *************!!!!!!!!!!**
Also uploading file:
#
# Copyright (C) 2011 OpenWrt.org
#
USE_REFRESH=1
set -x
. /lib/ipq806x.sh
. /lib/upgrade/common.sh
RAMFS_COPY_BIN='fw_printenv fw_setenv'
RAMFS_COPY_DATA=/lib/ipq806x.sh
RAMFS_COPY_BIN="/usr/bin/dumpimage /bin/mktemp /usr/sbin/mkfs.ubifs
/usr/sbin/ubiattach /usr/sbin/ubidetach /usr/sbin/ubiformat /usr/sbin/ubimkvol
/usr/sbin/ubiupdatevol /usr/bin/basename /bin/rm /usr/bin/find
/usr/sbin/mkfs.ext4 /etc/fw_env.config /var/lock/fw_printenv.lock"
do_flash_mtd() {
local bin=$1
local mtdname=$2
local append=""
echo "the bin is $1" > /dev/console
echo "The mtdname is $2" > /dev/console
local mtdpart=$(grep "\"${mtdname}\"" /proc/mtd | awk -F: '{print $1}')
echo "mtdpart is $mtdpart" > /dev/console
local pgsz=$(cat /sys/class/mtd/${mtdpart}/writesize)
echo "pgsz is $pgsz" > /dev/console
check=$(fw_printenv primary | cut -b 9)
echo "!!!!*********** check is $check *************!!!!!!!!!!" > /dev/console
echo "Praty primary is $check" > /dev/console
if [ $check == '1' ]
then
echo "in if ****successfull*** primary is $check" > /dev/console
[ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 -a "$2" == "rootfs" ] && append="-j $CONF_TAR"
else
echo "in else ****successfull*** primary is $check" > /dev/console
[ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 -a "$2" == "rootfs_1" ] && append="-j $CONF_TAR"
fi
dd if=/tmp/${bin}.bin bs=${pgsz} conv=sync | mtd $append write - -e "/dev/${mtdpart}" "/dev/${mtdpart}"
}
And my fw_printenv prints the following u-boot arguments:
i have checked the things u mentioned in comments using example mvedu.
and all the things are present in our file.
Also we are giving valid uboot_env config but still facing same problem.
Can u have another method to resolve this?
Thanks in advance
I have fw_printenv under RAMFS_COPY_DATA in the platform.sh file. Below is the file attached:-
#
# Copyright (C) 2011 OpenWrt.org
#
set -x
USE_REFRESH=1
. /lib/ipq806x.sh
. /lib/upgrade/common.sh
RAMFS_COPY_BIN="fw_printenv fw_setenv"
**RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'**
RAMFS_COPY_DATA=/lib/ipq806x.sh
RAMFS_COPY_BIN="/usr/bin/dumpimage /bin/mktemp /usr/sbin/mkfs.ubifs
/usr/sbin/ubiattach /usr/sbin/ubidetach /usr/sbin/ubiformat /usr/sbin/ubimkvol
/usr/sbin/ubiupdatevol /usr/bin/basename /bin/rm /usr/bin/find
/usr/sbin/mkfs.ext4"
REQUIRE_IMAGE_METADATA=1
get_full_section_name() {
local img=$1
local sec=$2
dumpimage -l ${img} | grep "^ Image.*(${sec})" | \
sed 's,^ Image.*(\(.*\)),\1,'
}
image_contains() {
local img=$1
local sec=$2
dumpimage -l ${img} | grep -q "^ Image.*(${sec}.*)" || return 1
}
But when i didnt write
install_bin /usr/sbin/fw_printenv
install_bin /usr/sbin/fw_setenv
i was not getting logs which i added to get to know that in which partition i have, below are the logs:
" * echo !!!!*********** check is ** <em><strong><strong><strong><strong><strong>!!!!!!!!!!
!!!!</strong></strong></strong></strong></strong></em> check is *************!!!!!!!!!! </>"
and
" * echo in else * ***successfull*** primary is
in else * ***successfull*** primary is</>" </>"
I’m not sure I understand what the question is in this last post sorry
You really need to start using code tags in your post to make these readable. It would be great if you edited all your previous posts to use them too.
Code goes here like this
In your above snippet, it looks like you set the variables, and then immediately overwrite them, which might be why it is not working the way you expect it?
Yep. At the first glance sakshi first sets the fwgetenv etc. values to variables, but then on the next line the variable gets reset with the original values.
You need to add the files to the existing file list, instead if trying to set variables twice.
Thanks for your help.
But this didn't work for me. So I have to take a new path. I was using "sysugrade -v" command to do the firmware upgrade which is a script. So I take a variable in that script and export that variable and then use that variable in the platform.sh script. It works for me and I am able to do the firmware upgrade in alternate partition. Following is the sysupgrade file changes:
I'm glad this works for you.
If you wanted this change pushed upstream however, i think it would need to be fixed properly. So i'd encourage you to keep working at it!
But if you were just after a solution to your individual problem, you're all done
I don't have time to do more search on this but yes whenever I get free I will do.
But I am facing one problem in this.
When I am doing firmware upgrade via connecting locally, it is working fine but when I put the board on the network and got the DHCP IP and then do firmware upgrade from GUI. It is showing "BAD GATEWAY...The process did not produce any response".
I think GUI is taking so much time to upload the image as I have the single image which is of 45.6 MB or may be GUI timeout time is less.
I don't know how to solve this problem.