OpenWrt Forum Archive

Topic: How to change "bootcmd" var in u-boot image?

The content of this topic has been archived on 21 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello!
I remove unnecessary “language” partition from my tew-712 device.
Nowadays I have to type “bootm 0x9f040000” to serial console every time when device boot.
I have to change default value “bootcmd=bootm 0x9f070000”. to “bootcmd=bootm 0x9f040000” to avoid that.

Default “bootcmd=bootm 0x9f070000” located in my uimage in compressed form. I skip headers  and decompress it by xzcat and patch it.

I dont know how to construct uimage back with corrected check sum and headers.

Any experience with that ?

Can I ask a stupid question? Why not move the firmware to the new address and leave uboot untouched?

I move firmware from 0x9f070000 to 0x9f040000. I got 30000h for my openwrt firmware. Its works and I can compile larger kernel and add more packages.

But uboot still try to boot from 0x9f070000 because of default "bootcmd" variable in uboot image.
When it boot from 0x9f070000 then i see error message from uboot and boot failed.

I connect attiny2313 to UART and send "bootm 0x9f040000" when uboot prompt. But it's nasty way:((

ok sorry, now i got it.. you already moved your firmware, that's the problem XD

cannot help with editing uimage.. best wishes..

How did you "move it"? What have you already done for trunk/target/linux/ar71xx/image/Makefile?
https://dev.openwrt.org/browser/trunk/t … e/Makefile

That is the file defining the image creation steps and I suppose that you have already modified something there.

TEW712 definition: https://dev.openwrt.org/browser/trunk/t … efile#L842
cameo933x bootline: https://dev.openwrt.org/browser/trunk/t … efile#L171

  cameo933x_mtdlayout=mtdparts=spi0.0:64k(u-boot)ro,64k(art)ro,64k(mac)ro,64k(nvram)ro,192k(language)ro,896k(kernel),2752k(rootfs),3648k@0x70000(firmware)

I suppose that you have already modified that line and removed language and increased the size of the kernel and/or rootfs. I guess that the last parameter 0x70000 is the kernel boot location. You might try changing that to 0x40000. I am not sure about that, but I think so...

(You might try compiling that way and then you could probably analyze the uimage before flashing.)

hi hnyman.
All works but I still cant change bootcmd in uboot.

diff Makefile.orig Makefile.exp1
253c253
< cameo933x_mtdlayout=mtdparts=spi0.0:64k(u-boot)ro,64k(art)ro,64k(mac)ro,64k(nvram)ro,192k(language)ro,896k(kernel),2752k(rootfs),3648k@0x70000(firmware)
---
> cameo933x_mtdlayout=mtdparts=spi0.0:64k(u-boot)ro,64k(art)ro,64k(mac)ro,64k(nvram)ro,960k(kernel),2880k(rootfs),3840k@0x70000(firmware)
255c255
<       $(call Image/Build/CameoHornet,$(1),$(2),$(3),$(cameo933x_mtdlayout),917504,2818048,$(4))
---
>       $(call Image/Build/CameoHornet,$(1),$(2),$(3),$(cameo933x_mtdlayout),983040,2949120,$(4))

I correct 3840k@0x70000 to 3840k@0x40000 but nothing changed.

It's works!
uboot patched.
steps:
0. It's very dangerous! you must be ready to replace flash chip if something wrong.
1. Download uboot partition to file. Get uimage from this file (it begin with 27 05 19 56)
2. find lzma image and unpack it. use binwalk and lzma.
3. change “bootcmd=bootm 0x9f070000”. to “bootcmd=bootm 0x9f030000”
4. pack it by lzma 4.65.
5. create uimage by mkimage. "mkimage -A mips -T firmware -C lzma -n 'u-boot image' -a 0x80010000 -e 0x80010000 -d file.lzma uboot.uimg"
6. write this image to the same place in original uboot file.
7. connect to router by UART console.
7. write uboot it to flash.
8. write openwrt image to flash.

I remove "language" and "nvram" partitions.

cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00010000 00010000 "u-boot"
mtd1: 00010000 00010000 "art"
mtd2: 00010000 00010000 "mac"
mtd3: 000f0000 00010000 "kernel"
mtd4: 002e0000 00010000 "rootfs"
mtd5: 00070000 00010000 "rootfs_data"
mtd6: 003d0000 00010000 "firmware"

also you need to patch /trunk/target/linux/ar71xx/image/Makefile

diff Makefile Makefile.orig 
253c253
< cameo933x_mtdlayout=mtdparts=spi0.0:64k(u-boot)ro,64k(art)ro,64k(mac)ro,960k(kernel),2944k(rootfs),3904k@0x30000(firmware)
---
> cameo933x_mtdlayout=mtdparts=spi0.0:64k(u-boot)ro,64k(art)ro,64k(mac)ro,64k(nvram)ro,192k(language)ro,896k(kernel),2752k(rootfs),3648k@0x70000(firmware)
255c255
<    $(call Image/Build/CameoHornet,$(1),$(2),$(3),$(cameo933x_mtdlayout),983040,3014656,$(4))
---
>    $(call Image/Build/CameoHornet,$(1),$(2),$(3),$(cameo933x_mtdlayout),917504,2818048,$(4))

(Last edited by supaplexin on 29 Dec 2012, 17:45)

art and mac also can be removed.
I move necessary data from art and mac to uboot.
uboot have enough free space for 1088 bytes of art and 96 bytes of mac.

address of atheros data and address of MAC must be changed in
/trunk/target/linux/ar71xx/files/arch/mips/ath79/mach-tew-712br.c

result:

cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00010000 00010000 "u-boot"
mtd1: 000f0000 00010000 "kernel"
mtd2: 00300000 00010000 "rootfs"
mtd3: 00060000 00010000 "rootfs_data"
mtd4: 003f0000 00010000 "firmware"

The discussion might have continued from here.