How to build IPQ4018 firmware

@zyxmon Sorry, I try following steps, but get compile error even I make twice. Do you know what problem I encounter ?

steps

 git clone https://github.com/chunkeey/LEDE-IPQ40XX
 cd LEDE-IPQ40XX/
  ./scripts/feeds update -a
  ./scripts/feeds install -a
 make menuconfig
// choose Target Sytem=Qualcomm Atheros IPQ40XX and Target Profile=Asus RT-AC58U
 make V=s -j1

results

Configuring in arm-openwrt-linux-muslgnueabi/libstdc++-v3
configure: loading cache ./config.cache
checking build system type... x86_64-pc-linux-gnu
checking host system type... arm-openwrt-linux-muslgnueabi
checking target system type... arm-openwrt-linux-muslgnueabi
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-openwrt-linux-muslgnueabi-strip... /home/stephen/LEDE-IPQ40XX/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.3.0_musl_eabi/arm-openwrt-linux-muslgnueabi/bin/strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for arm-openwrt-linux-muslgnueabi-gcc... /home/stephen/LEDE-IPQ40XX/build_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.3.0_musl_eabi/gcc-7.3.0-final/./gcc/xgcc -B/home/stephen/LEDE-IPQ40XX/build_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.3.0_musl_eabi/gcc-7.3.0-final/./gcc/ -B/home/stephen/LEDE-IPQ40XX/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.3.0_musl_eabi/arm-openwrt-linux-muslgnueabi/bin/ -B/home/stephen/LEDE-IPQ40XX/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.3.0_musl_eabi/arm-openwrt-linux-muslgnueabi/lib/ -isystem /home/stephen/LEDE-IPQ40XX/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.3.0_musl_eabi/arm-openwrt-linux-muslgnueabi/include -isystem /home/stephen/LEDE-IPQ40XX/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.3.0_musl_eabi/arm-openwrt-linux-muslgnueabi/sys-include   
checking for C compiler default output file name... 
configure: error: in `/home/stephen/LEDE-IPQ40XX/build_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.3.0_musl_eabi/gcc-7.3.0-final/arm-openwrt-linux-muslgnueabi/libstdc++-v3':
configure: error: C compiler cannot create executables
See `config.log' for more details.
Makefile:10617: recipe for target 'configure-target-libstdc++-v3' failed
make[5]: *** [configure-target-libstdc++-v3] Error 1
make[5]: Leaving directory '/home/stephen/LEDE-IPQ40XX/build_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.3.0_musl_eabi/gcc-7.3.0-final'
Makefile:896: recipe for target 'all' failed
make[4]: *** [all] Error 2
make[4]: Leaving directory '/home/stephen/LEDE-IPQ40XX/build_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.3.0_musl_eabi/gcc-7.3.0-final'
Makefile:86: recipe for target '/home/stephen/LEDE-IPQ40XX/build_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.3.0_musl_eabi/gcc-7.3.0-final/.built' failed
make[3]: *** [/home/stephen/LEDE-IPQ40XX/build_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.3.0_musl_eabi/gcc-7.3.0-final/.built] Error 2
make[3]: Leaving directory '/home/stephen/LEDE-IPQ40XX/toolchain/gcc/final'
Command exited with non-zero status 2
time: toolchain/gcc/final/compile#0.79#0.07#2.52
toolchain/Makefile:96: recipe for target 'toolchain/gcc/final/compile' failed
make[2]: *** [toolchain/gcc/final/compile] Error 2
make[2]: Leaving directory '/home/stephen/LEDE-IPQ40XX'
toolchain/Makefile:94: recipe for target '/home/stephen/LEDE-IPQ40XX/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.3.0_musl_eabi/stamp/.toolchain_compile' failed
make[1]: *** [/home/stephen/LEDE-IPQ40XX/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.3.0_musl_eabi/stamp/.toolchain_compile] Error 2
make[1]: Leaving directory '/home/stephen/LEDE-IPQ40XX'
/home/stephen/LEDE-IPQ40XX/include/toplevel.mk:216: recipe for target 'world' failed
make: *** [world] Error 2

I cannot say about compiling from chunkeey repo. Building from my fork passed at the time of last fork update.
Since RT-AC58U is now in the trunk - I see no reason to use chunkeey or my repos.

1 Like

Yes, pretty much that. I keep the LEDE-IPQ40XX around as staging repo for testing random stuff...
(In your case, the musl 1.1.20 pre-patch broke the build)

But make no mistake, if you want to compile your own images, just get the source from the main openwrt repo.

@chunkeey @zyxmon
Oh! Thanks. Then, I know the meaning of previous posts. The project is merged to OpenWRT and we can use OpenWRT directly. We also found the OpenWRT support Target System=Qualcomm Atheros IPQ40XX and Target Profile=QCA AP-DK04. Could I ask you one more question after the firmware is made, how to upgrade to IPQ40XX board ? Because the IPQ40xx EVK has its own uboot and rootfs format, how can we replace it with OpenWRT images? Thanks!

Below are images built by OpenWRT:
config.seed
openwrt-ipq40xx-qcom_ap-dk04.1-c1-initramfs-fit-uImage.itb
openwrt-ipq40xx-device-qcom-ap-dk04.1-c1.manifest
openwrt-ipq40xx-qcom_ap-dk04.1-c1-squashfs-nand-factory.ubi
openwrt-ipq40xx-qcom_ap-dk04.1-c1-fit-uImage.itb
openwrt-ipq40xx-qcom_ap-dk04.1-c1-squashfs-nand-sysupgrade.bin

If we upgrade via EVK runtime shell, it is fail.
root:/tmp/run# sysupgrade -v ./openwrt-ipq40xx-qcom_ap-dk04.1-c1-squas
hfs-nand-sysupgrade.bin
rm: can't remove './openwrt-ipq40xx-qcom_ap-dk04.1-c1-squashfs-nand-sysupgrade.bin_1530850850': No such file or directory
./openwrt-ipq40xx-qcom_ap-dk04.1-c1-squashfs-nand-sysupgrade.bin is not a valid FIT image
Image check 'platform_check_image' failed.

I also have a RT58U and see that openwrt does support it, now the question is literally how does one flash it... ive used the all in one image and was succesful in getting openwrt on it, but it would not sysupgrade from shell a newer image, so i reflashed it back to ASUS firmware... i need an upgradeable custom image on this device. thanks, custom image built today needs to be flashed... any ideas ?
drwxr-xr-x 3 dingo dingo 4096 jul 17 08:09 .
drwxr-xr-x 3 dingo dingo 4096 jul 17 07:45 ..
-rw-r--r-- 1 dingo dingo 1406 jul 17 07:45 config.seed
-rw-r--r-- 1 dingo dingo 5660220 jul 17 08:09 openwrt-ipq40xx-asus_rt-ac58u-initramfs-fit-uImage.itb
-rw-r--r-- 1 dingo dingo 5857453 jul 17 08:09 openwrt-ipq40xx-asus_rt-ac58u-squashfs-sysupgrade.bin
-rw-r--r-- 1 dingo dingo 3424 jul 17 08:09 openwrt-ipq40xx-device-asus-rt-ac58u.manifest
drwxr-xr-x 2 dingo dingo 4096 jul 17 08:09 packages
-rw-r--r-- 1 dingo dingo 431 jul 17 08:09 sha256sums

@chunkeey Sorry, I have seen https://github.com/chunkeey/FritzBox-4040-UBOOT/releases and know there are no big different between Qualcomm IPQ40xx boards. So I try to select uboot in make menuconfig, and uboot-fritz4040.bin is generated. Then, I try to update it by following steps, but the device cannot boot anymore, haha! Any mistake in my update procedure ?
Thanks for your advice.

root:/# cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 00100000 00020000 "0:SBL1"
mtd1: 00100000 00020000 "0:MIBIB"
mtd2: 00100000 00020000 "0:BOOTCONFIG"
mtd3: 00100000 00020000 "0:QSEE"
mtd4: 00100000 00020000 "0:QSEE_ALT"
mtd5: 00080000 00020000 "0:CDT"
mtd6: 00080000 00020000 "0:CDT_ALT"
mtd7: 00080000 00020000 "0:DDRPARAMS"
mtd8: 00080000 00020000 "0:APPSBLENV"
mtd9: 00200000 00020000 "0:APPSBL"
mtd10: 00200000 00020000 "0:APPSBL_ALT"
mtd11: 00080000 00020000 "0:ART"
mtd12: 04100000 00020000 "rootfs"
mtd13: 003a2000 0001f000 "kernel"
mtd14: 01113000 0001f000 "ubi_rootfs"
mtd15: 0292c000 0001f000 "rootfs_data"

root:/tmp/run# tftp -r uboot-fritz4040.bin -g 192.168.1.100
root:/tmp/run# mtd write ./uboot-fritz4040.bin /dev/mtd9
Unlocking /dev/mtd9 ...

Writing from ./uboot-fritz4040.bin to /dev/mtd9 ...     
root:/tmp/run# reboot
procd: - reboot -
[  780.995206] reboot: Restarti
Format: Log Type - Time(microsec) - Message - Optional Info
Log Type: B - Since Boot(Power On Reset),  D - Delta,  S - Statistic
S - QC_IMAGE_VERSION_STRING=BOOT.BF.3.1.1-00096
S - IMAGE_VARIANT_STRING=DAACANAZA
S - OEM_IMAGE_VERSION_STRING=CRM
S - Boot Config, 0x00000025
S - Core 0 Frequency, 0 MHz
B -       261 - PBL, Start
B -      1339 - bootable_media_detect_entry, Start
B -      2612 - bootable_media_detect_success, Start
B -      2626 - elf_loader_entry, Start
B -      4036 - auth_hash_seg_entry, Start
B -      6192 - auth_hash_seg_exit, Start
B -     73461 - elf_segs_hash_verify_entry, Start
B -    194340 - PBL, End
B -    194364 - SBL1, Start
B -    283029 - pm_device_init, Start
D -         6 - pm_device_init, Delta
B -    284555 - boot_flash_init, Start
D -     84696 - boot_flash_init, Delta
B -    373301 - boot_config_data_table_init, Start
D -     13985 - boot_config_data_table_init, Delta - (419 Bytes)
B -    389984 - clock_init, Start
D -      7570 - clock_init, Delta
B -    400957 - CDT version:2,Platform ID:8,Major ID:1,Minor ID:0,Subtype:1
B -    404444 - sbl1_ddr_set_params, Start
B -    409428 - cpr_init, Start
D -         2 - cpr_init, Delta
B -    413919 - Pre_DDR_clock_init, Start
D -         5 - Pre_DDR_clock_init, Delta
D -     13142 - sbl1_ddr_set_params, Delta
B -    427200 - pm_driver_init, Start
D -         2 - pm_driver_init, Delta
B -    497787 - sbl1_wait_for_ddr_training, Start
D -        27 - sbl1_wait_for_ddr_training, Delta
B -    513311 - Image Load, Start
D -    140605 - QSEE Image Loaded, Delta - (262104 Bytes)
B -    654413 - Image Load, Start
D -      2115 - SEC Image Loaded, Delta - (2048 Bytes)
B -    664570 - Image Load, Start
B -    667157 - Boot error ocuured!. Error code: 3039

Instructions are in the commit message for the RT-AC58U.

There used to be an "easy-install" image that would have allowed you to flash the initramfs image over the web-interface and go directly to step 3... But alas this method was rejected multiple times, the latest attempt by @ptpt52 can still be found on github https://github.com/openwrt/openwrt/pull/802 . So if you are looking for pointers, look there.

@dingo did you figure this out? i have the firmware running from http://lede-ac58u.zyxmon.org/firmware/ and its working in a nice but somewhat clunky way. is there any way to upgrade to the latest build without the soldering? through SSH or Luci? anyone know?

Just upgrade it with luci or ssh - it workes.

1 Like

Ive flashed back to stock as i see no way to flash openwrt to the latest rev in trunk and have it be functional, ive completely bricked one router since i doont have usb cable to fix, i bought another...

now if someone says install this, then build the latest from trunk annd it will sysupgrade properly then fine.. ill take another go at it

There should be openwrt release in few days that will have RT58U firmware.
All flashing instaructions were correct at the time of posting. I do not think they should be changed.

1 Like

i put the latest Snapshot on my ACRH13 today and it works fine. because its a snapshot it didnt come with Luci and webUI so i stupidly wasted a few hours trying to get into the web. duh. anyway i couldnt reset the router settings with any combination of buttons of 30-30-30 or WPS or reset or anything so i ended up going in with SSH and doing a FIRSTBOOT. then it came up fine and fresh and i installed luciUI and im in.

link to snapshot for AC58U (ACRH13) is what i used.

good luck!

Yes but which image did you use to flash to the be on openwrt first, this itself is a sysupgrade image

On my ASUS RT-N56U I can use the Asus Firmware Restoration utility to install the sysupgrade image. Anyone know if it's the same with RT-AC58U?

For installation instructions see the git commit which added support for the RT-AC58U

It is different - http://lede-ac58u.zyxmon.org/HowToFlashENG.html

@dingo i used instructions here HowToFlashUS and then SCP the newest Sysupgrade from OpenWRT and Sysupgrade from the CLI as @zyxmon says above. from OEM to zyxmon version to sysupgrade straight from snapshot OpenWRT

dare i try it again, last time i bricked a router...

whew, i dont know. its pretty cool to have the latest snapshot on this little $40 router but it did take a bit of work. good luck.

just to clarify, you did step one then flashed the latest image? or you did step 1 and two then flashed the latest?