Askey RAC2V1K / RT4230W REV6 Support

That's correct, however, for that to happen the uImage header magic and rootfs partition checksum would need to be bad. In which case, you have a bigger problem to worry about. Of course, you can always modify the bootcmd variable to perform all the necessary nand/ubi steps to get everything mounted and booted. I decided to stick with bootipq for sake of convenience. With the failsafe system, you can have a secondary OpenWRT image in rootfs_1

This is my memory mapping in dts:

memory@0 {
	reg = <0x42000000 0x3e000000>;
	device_type = "memory";
};

Thanks. I've just been using this as my bootcmd and it works fine setenv mtdids nand0=nand0 && set mtdparts mtdparts=nand0:0x1A000000@0x2400000(firmware) && ubi part firmware && ubi read 0x44000000 kernel 0x6e0000 && bootm

I'm about to upload an image, just waiting for it to compile. The flashing process is the same as yours

Edit: I was thinking, we might be able to flash images without opening it using the fw_setenv command in the stock fw. Like just make a small script that sets bootcmd to all the flashing commands then have bootcmd set itself to whatever command is used in the end.

https://github.com/lmore377/openwrt-rac2v1k/raw/master/openwrt-ipq806x-generic-askey_rt4230w.zip

@lmore377 -
i've got your images and have been able to write to nand - however, the factory firmware keeps booting. are there two images in nand? i could not find anything in environment vars that would indicate this.
i have tried writing both the initramfs-uimage and the nand-factory files - but still the factory (spectrum) firmware boots.
i cant figure this out -
do i need to setenv your alternate bootcmd ?
edit - this did not work either.

thank you for your continued help

That's the problem I was talking about when using bootipq. The image is too small to override both of the stock firmware partitions, so uboot just overrides openwrt with the still good fw partition. Try reflashing and setting the bootcmd without restarting the router

@ghoffman can you send what the model number by the buttons say?

The size of the image has nothing to do with it. You're not padding your uImage correctly which is why the header check done by the bootloader fails. If you flash my image, you won't have that problem. I'll be uploading my build files for the device later today.

@lmore377 -
RT4230W-D187(RoHS)A Rev:9

@omdr3j -
your image boots from ram, but writing to nand fails in the same way - reboots to stock. there is a log of the process below
https://pastebin.com/jEMkcJn0

what does the bootloader use for a header check? at the end of the log is the interrupted console and the printenv results.

With my image you need to run
setenv mtdids nand0=nand0 && set mtdparts mtdparts=nand0:0x1A000000@0x2400000(firmware) && ubi part firmware && ubi read 0x44000000 kernel 0x6e0000 && bootm
saveenv
after flashing then reboot

That image doesn't have luci or anything extra installed. I'm rebuilding a new one with some extras

I had to edit some stuff so it took a a bit longer but I finally got it. It has luci and packages for usb storage https://github.com/lmore377/openwrt-rac2v1k/raw/master/openwrt-ipq806x-generic-askey_rt4230w.zip

@lmore377 -
i get an error with your setenv command:

(IPQ) # setenv mtdids nand0=nand0 && set mtdparts mtdparts=nand0:0x1A000000@0x2400000(firmware) && ubi part firmware && ubi read 0x44000000 kernel 0x6e0000 && bootm
Creating 1 MTD partitions on "nand0":
0x000002400000-0x00001c400000 : "mtd=0"
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:    126976 bytes
UBI: smallest flash I/O unit:    2048
UBI: VID header offset:          2048 (aligned 2048)
UBI: data offset:                4096
UBI error: compare_lebs: PEB 2 and PEB 1026 have the same version 0
UBI error: ubi_init: cannot attach mtd1
UBI error: ubi_init: UBI error: cannot initialize UBI, error -22
UBI init error 22
(IPQ) #

From the logs you posted, I don't see it reverting back to stock. However, it looks like your bootloader always boots from rootfs_1 instead of the default rootfs. I'm now wondering if this is the case on certain revisions? Although, your revision numbers match with mine. If you don't mind completely wiping out the stock firmware, would you mind running a test by writing my image to both partitions? You can do this by running these two commands after TFTPing the image over.

nand write 0x44000000 0x2400000 0x6c0000
nand write 0x44000000 0xa400000 0x6c0000

not so good now.

(IPQ) # nand erase 0x2400000 0x8000000

NAND erase: device 0 offset 0x2400000, size 0x8000000
Erasing at 0xa3e0000 -- 100% complete.
OK
(IPQ) # nand erase 0xa400000 0x8000000

NAND erase: device 0 offset 0xa400000, size 0x8000000
Erasing at 0x123e0000 -- 100% complete.
OK
(IPQ) # tftpboot openwrt-factory.bin
Mac0 unit failed
Using eth1 device
TFTP from server 192.168.1.9; our IP address is 192.168.1.1
Filename 'openwrt-factory.bin'.
Load address: 0x44000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #
done
Bytes transferred = 6684672 (660000 hex)
(IPQ) # and write 0x44000000 0x2400000 0x6c0000
Unknown command 'and' - try 'help'
(IPQ) # nand write 0x44000000 0x2400000 0x6c0000

NAND write: device 0 offset 0x2400000, size 0x6c0000
 7077888 bytes written: OK
(IPQ) # nand write 0x44000000 0xa400000 0x6c0000

NAND write: device 0 offset 0xa400000, size 0x6c0000
 7077888 bytes written: OK
(IPQ) #

U-Boot 1.0.6 [spf.5.0.2_csu1.1] (Nov 15 2018 - 03:26:55)

smem ram ptable found: ver: 0 len: 5
DRAM:  1003 MiB
setting 0x177d as machine type from smem
NAND:  SF: Unsupported manufacturer 00
ipq_spi: SPI Flash not found (bus/cs/speed/mode) = (0/0/48000000/0)
512 MiB
MMC:
PCI0 Link Intialized
PCI1 Link Intialized
In:    serial
Out:   serial
Err:   serial
MMC Device 0 not found
cdp: get part failed for 0:HLOS
Net:   MAC0 addr:94:91:7f:c4:fa:a3
athrs17_reg_init: complete
athrs17_vlan_config ...done
S17c init  done
MAC1 addr:94:91:7f:c4:fa:a4
eth0, eth1
Hit space key to stop autoboot:  0
MMC Device 0 not found
WiFi detect OK
******* check firmware img *****
Creating 1 MTD partitions on "nand0":
0x00000a400000-0x000012400000 : "mtd=1"
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:    126976 bytes
UBI: smallest flash I/O unit:    2048
UBI: VID header offset:          2048 (aligned 2048)
UBI: data offset:                4096
UBI: volume 2 ("rootfs_data") re-sized from 9 to 961 LEBs
UBI: attached mtd1 to ubi0
UBI: MTD device name:            "mtd=1"
UBI: MTD device size:            128 MiB
UBI: number of good PEBs:        1024
UBI: number of bad PEBs:         0
UBI: max. allowed volumes:       128
UBI: wear-leveling threshold:    4096
UBI: number of internal volumes: 1
UBI: number of user volumes:     3
UBI: available PEBs:             0
UBI: total number of reserved PEBs: 1024
UBI: number of PEBs reserved for bad PEB handling: 10
UBI: max/mean erase counter: 1/0
Read 2048 bytes from volume kernel to 44000000
Read 2484224 bytes from volume kernel to 44000000
Volume ubi_rootfs not found!
UBI: mtd1 is detached from ubi0
read rootfs error ......

******* FAILED *****
******* check firmware_1 img *****
Creating 1 MTD partitions on "nand0":
0x000002400000-0x00000a400000 : "mtd=0"
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:    126976 bytes
UBI: smallest flash I/O unit:    2048
UBI: VID header offset:          2048 (aligned 2048)
UBI: data offset:                4096
UBI: volume 2 ("rootfs_data") re-sized from 9 to 961 LEBs
UBI: attached mtd1 to ubi0
UBI: MTD device name:            "mtd=0"
UBI: MTD device size:            128 MiB
UBI: number of good PEBs:        1024
UBI: number of bad PEBs:         0
UBI: max. allowed volumes:       128
UBI: wear-leveling threshold:    4096
UBI: number of internal volumes: 1
UBI: number of user volumes:     3
UBI: available PEBs:             0
UBI: total number of reserved PEBs: 1024
UBI: number of PEBs reserved for bad PEB handling: 10
UBI: max/mean erase counter: 1/0
Read 2048 bytes from volume kernel to 44000000
Read 2484224 bytes from volume kernel to 44000000
Volume ubi_rootfs not found!
UBI: mtd1 is detached from ubi0
read rootfs_1 error
******* FAILED *****
(IPQ) #

You're not using my image. The size of my image is 0x6c0000. In your log, the size you sent over TFTP is 0x660000.

If you're going to use @ondr3j image, only use the instructions here. This image leaves one of the stock partitions, but there's only about 150Mb of free space. I recommend this if you're renting the router.

If you're going to use my image, only use the instructions here. This image overrides both stock partitions so it'll be impossible to go back. Because it overrides both partitions, theres about 300Mb of free space. I recommend this if you own the router (bought it off of eBay or something)

I don't mean to sound rude, but what would that accomplish? We have sufficient access in U-Boot right now. You can modify the bootcmd variable which gives you the ability to use a larger portion of the flash for your firmware.The PBL in the SoC ROM (which is out of our control) authenticates SBL* based on its signature, which in turn validates APPSBL. Messing around with any of the SBL* or APPSBL partitions puts you at risk of bricking your device. We haven't found JTAG pins on the board yet, so there would be no going back.

@lmore377, @ondr3j -
i have now been able to flash each of your images to nand and boot.
. no going back, but this is good.

thanks to both and @efsg - this project is moving ahead - thank you

please let me know how i can contribute to this project. i cant build images currently, but i can test
thank you

There's not much else to do. At this point I'm just putting some finishing touches and making sure things like Mac addresses are correct. Can you connect the router to the internet and run speedtests over ethernet, 2.4ghz wifi, and 5 GHz wifi and tell me if speeds are what you're expecting?