Monday, October 10, 2016

Compiling DIR-818LW (RTL8881AB) stock firmware

After getting all the required packages, and following the readme file of the provided GPL source files, I still met some compilation errors. It is predictable as vendors really don't give a f*** on open source.

However, with some bug fixing, I can get the firmware image compiled:
  1. Remember to use bash as main sh (unlink /bin/sh && ln -sf /bin/bash /bin/sh)
  2. Setup the env vars, and run "make" two times (see the readme)
  3. Modify the main Makefile, find "read answer;" replace the NEXT LINE to:
    if [ $answer == "yes" ]; then \ 
  4. Modify templates/aries/progs/Makefile, comment out line 54
  5. Modify progs.gpl/busybox-1.14.1/Makefile, comment out line 833 (the touch command), line 500 (as there is no slientoldconfig exists in the make file)
  6. Perform the following make command on progs.gpl/busybox-1.14.1
    make oldconfig
    And copy progs.template/busybox-1.14.1.config to progs.gpl/busybox-1.14.1, rename the file to .config
  7. Apply the following patch on kernel/kernel/timeconst.pl:
    diff --git a/kernel/timeconst.pl b/kernel/timeconst.pl
    index eb51d76..0461239 100644
    --- a/kernel/timeconst.pl
    +++ b/kernel/timeconst.pl
    @@ -365,14 +365,14 @@ if ($hz eq '--can') {
      print "\n);\n";
     } else {
      $hz += 0;   # Force to number
      if ($hz < 1) {
       die "Usage: $0 HZ\n";
      }
     
      @val = @{$canned_values{$hz}};
    - if (!defined(@val)) {
    + if (!@val) {
       @val = compute_values($hz);
      }
      output($hz, @val);
     }
     exit 0;
    
  8. Run the make command third time (see readme)

After 2 to 3 hours (it varies), the firmware image should be available at images/.

To burn the firmware into the router:

  1. Connect the computer to the LAN port of the router
  2. Set computer's IP to static, with the following configuration:
    • IP: 192.168.0.2
    • Sub-Netmask: 255.255.255.0
    • GW: 192.168.0.1
  3. Connect the router via serial, and turn it on
  4. Hold ESC to enter Realtek bootloader
  5. Enable stop flag by issuing: (IMPORTANT, or else the firmware will not burn)
    sig f 1
  6. Enable autoburn (the bootloader will burn your FW when it receives it from TFTP):
    autoburn 1
  7. Reboot router, at this time, it should not boot into the system as stop flag is enabled
  8. Issue:
    ipconfig
  9. Make sure "Target Address" is "192.168.0.1", this should match to your GW config above
  10. Start a TFTP client and upload the firmware (.bin file) I use this on Windows and it works well.
  11. After the process is complete, it will reboot into the bootloader, disable stop flag by:
    sig f 0
  12. Reboot the router, and you will be using your new firmware.


No comments:

Post a Comment