Uboot & Firmware Update for GL-AR300M

Hello, could you please backup the information of your ART partition and send it to me?

dd if=/dev/mtd6 of=/tmp/art.bin bs=64k

Sorry, took me some time to find a way how to transfer it.

Here you go:
https://www.abgesteppt.de/art.bin.gz

Don't worry, it is my personal server.

Hello, your file seems to be different from the information you sent previously? Did you use this command "dd if=/dev/mtd6 of=/tmp/art.bin bs=64k" to make the backup?

yes, I did
Copy & paste

but see, now:

root@GL-AR300M:/mnt/sda1# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00400000 00020000 "nand_kernel"
mtd1: 07c00000 00020000 "nand_ubi"
mtd2: 00040000 00010000 "u-boot"
mtd3: 00010000 00010000 "u-boot-env"
mtd4: 00fa0000 00010000 "firmware"
mtd5: 0027a176 00010000 "kernel"
mtd6: 00d25e8a 00010000 "rootfs"
mtd7: 000e0000 00010000 "rootfs_data"
mtd8: 00010000 00010000 "art"

I rebooted in the mean time?!? How can this change?

https://www.abgesteppt.de/art_mdt8.bin.gz

Hello, use the following command to write the file to the art partition and wait for the reboot.

mtd -r write /tmp/art_mdt8 art

art_mdt8.zip (680 Bytes)

Then enter the command so that you can switch between NAND(position next to reset button) or NOR(away from reset button) using the switch.

fw_setenv boot_dev on

Thank you. Am I missing something?

root@GL-AR300M:/mnt/sdb1# mtd -r write /mnt/sdb1/art_mdt8.bin art
Could not open mtd device: art
Can't open device for writing!
root@GL-AR300M:/mnt/sdb1#

I would guess the command should be
mtd -r write /mnt/sdb1/art_mdt8.bin mdt8

Thanks, not yet:

root@GL-AR300M:/mnt/sdb1# mtd -r write /mnt/sdb1/art_mdt8.bin mdt8
Could not open mtd device: mdt8
Can't open device for writing!

Hello, you need to install the package kmod-mtd-rw first, and then use this command:

insmod mtd-rw.ko i_want_a_brick=1
2 Likes

Thank you very much. Booting took quite some time, but in the end, see above.

For Future reference the commands:

opkg update
opkg install /tmp/kmod-mtd-rw_5.10.176+git-20160214-2_mips_24kc.ipk
insmod mtd-rw.ko i_want_a_brick=1
mtd -r write /mnt/sdb1/art_mdt8.bin art

Again, thanks to the GL.inet team for not giving up!

One final question: How Do I update the NOR part in the future? Via uboot? with the M16 Firmware?

1 Like

Yes that is correct. Uboot should update both Nor and Nand as its instructions. The problem was resolved so that uboot will work as normal.

We should thank you sincerely not giving up on us!

@alzhao @renbo.xu
I would like to update uboot on a couple older ar300m routers, so I can have the switch option between NOR and NAND. They both have older versions of the uboot file, without this option. Do I have to also update the art file if I update the uboot file? Both these routers are still being used, and I would prefer not to brick them.

Should not be that difficult. Let me ask developer to give a simpler method.

You might need to trim/cut the plastic box so the button make contact with the micro switch inside

Thanks. Simple would be nice!

Hello, upgrading uboot generally won't change the ART area. You can back up the content of the ART area before updating. If there are any issues, you can rewrite the backup file to the ART area.

Hello, Only for AR300M:

  1. Install the package kmod-mtd-rw first, and then use this command:
insmod mtd-rw.ko i_want_a_brick=1
  1. Find the art area
cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00400000 00020000 "kernel"
mtd1: 07c00000 00020000 "ubi"
mtd2: 00040000 00010000 "u-boot"
mtd3: 00010000 00010000 "u-boot-env"
mtd4: 00fa0000 00010000 "nor_firmware"
mtd5: 00010000 00010000 "art"
  1. Check the information in the art area (confirm whether there is a test)
hexdump -C /dev/mtd5
  1. Copy information in the art area (and backup a copy at the same time)
dd if=/dev/mtd5 of=/tmp/art (backup: dd if=/dev/mtd5 of=/tmp/art_bak)
  1. Write information in /tmp/art
    <1> Test information required (entering NAND)
    At address 00000050 (needs to be converted to decimal), write "firsttest"
printf "firsttest" | dd of=/tmp/art bs=1 count=9 seek=80 conv=notrunc

At address 00000060 (needs to be converted to decimal), write "secondtest"

printf "secondtest" | dd of=/tmp/art bs=1 count=10 seek=96 conv=notrunc

<2> Test information not required, erase test information (entering NOR)
At address 00000050 (needs to be converted to decimal)

printf "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" | dd of=/tmp/art bs=1 count=16 seek=80 conv=notrunc

At address 00000060 (needs to be converted to decimal)

printf "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" | dd of=/tmp/art bs=1 count=16 seek=96 conv=notrunc
  1. Check if the test information is written (or erased)
hexdump -C /tmp/art
  1. Write the modified file to the art partition
mtd -r write /tmp/art art
2 Likes

@renbo.xu Thank you very much for the procedure. It has been many years since I last binary edited parts of an OS.

On one of my routers that is in production, but accessible via ssh, I tried out all the steps except writing the file back to the art partition, as I want to test this when I am onsite. I have diff loaded on my router and it shows the following differences between the hex output of the original and modified version of the /tmp/art file. Does this look correct?

diff art_org.hex art_modified.hex
6,8d5
< 00000050  66 69 72 73 74 74 65 73  74 ff ff ff ff ff ff ff  |firsttest.......|
< 00000060  73 65 63 6f 6e 64 74 65  73 74 ff ff ff ff ff ff  |secondtest......|
< 00000070  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

The new version of the art file does not have the text: firsttest or secondtest as the last two printf commands are overwriting these entries with xff.

To prove to myself that the text "firsttest" and "secondtest" are being overwritten I wrote a script that makes the same modifications to a zeroed out file:

cat /tmp/test-art-change.sh
dd if=/dev/zero bs=1 count=1000 > /tmp/test.art
hexdump -C /tmp/test.art
printf "firsttest" |  dd of=/tmp/test.art bs=1 count=9 seek=80 conv=notrunc
printf "secondtest" | dd of=/tmp/test.art bs=1 count=10 seek=96 conv=notrunc
printf "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" | dd of=/tmp/test.art bs=1 count=16 seek=80 conv=notrunc
printf "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" | dd of=/tmp/test.art bs=1 count=16 seek=96 conv=notrunc
hexdump -C /tmp/test.art

Running the script shows:

sh /tmp/test-art-change.sh
1000+0 records in
1000+0 records out
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000003e0  00 00 00 00 00 00 00 00                           |........|
000003e8
9+0 records in
9+0 records out
10+0 records in
10+0 records out
16+0 records in
16+0 records out
16+0 records in
16+0 records out
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000050  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
*
00000070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000003e0  00 00 00 00 00 00 00 00                           |........|
000003e8

This does not look correct to me. Please let me know if this really is correct.

Thanks, Eric

I apologize for the late reply. The two commands below are for writing "firsttest" and "secondtest" (accessing NAND memory):

printf "firsttest" | dd of=/tmp/test.art bs=1 count=9 seek=80 conv=notrunc  
printf "secondtest" | dd of=/tmp/test.art bs=1 count=10 seek=96 conv=notrunc

The hexdump -C /tmp/test.art command is merely for viewing the file's content in a hexadecimal format, which you can exclude from your script.

The following two commands are for erasing "firsttest" and "secondtest" (accessing NOR memory):

printf "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" | dd of=/tmp/test.art bs=1 count=16 seek=80 conv=notrunc  
printf "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" | dd of=/tmp/test.art bs=1 count=16 seek=96 conv=notrunc

You can try executing these commands step by step to see how they work.
You can first try writing "firsttest" and "secondtest", and then attempt to erase them afterwards.

Thank you for clarifying the commands.