Advertisement
MrRockchip

Old tp-link's u-boot, new toolchain: 4.3.3 -> libreCMC 5.5.0

Oct 3rd, 2019
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.40 KB | None | 0 0
  1. 1) Download a GPL package from TP-Link for TP-Link TL-WR841ND v9:
  2.  
  3. https://www.tp-link.com/us/support/gpl-code/
  4.  
  5. TL-WR841ND V9 361.54 MB
  6.  
  7. https://static.tp-link.com/resources/gpl/wr841nv9_en_gpl.tar.gz
  8.  
  9. and unpack it somewhere, i.e. to
  10.  
  11. /home/anon/tp-link-gpl/wr841nv9_en_gpl/
  12.  
  13. cd /home/anon/
  14. mkdir /home/anon/tp-link-gpl/
  15. cp /home/anon/Downloads/wr841nv9_en_gpl.tar.gz /home/anon/tp-link-gpl/wr841nv9_en_gpl.tar.gz
  16. cd /home/anon/tp-link-gpl/
  17. tar -zxvf /home/anon/tp-link-gpl/wr841nv9_en_gpl.tar.gz
  18.  
  19. 2) TP-Link TL-WR841ND v9: change from 4MB to 16MB
  20.  
  21. cd /home/anon/tp-link-gpl/wr841nv9_en_gpl/
  22.  
  23. and apply this patch:
  24.  
  25. diff --git a/ap143/boot/u-boot/include/configs/board953x.h b/ap143/boot/u-boot/include/configs/board953x.h
  26. --- a/ap143/boot/u-boot/include/configs/board953x.h
  27. +++ b/ap143/boot/u-boot/include/configs/board953x.h
  28. @@ -10,7 +10,7 @@
  29. #include <atheros.h>
  30.  
  31. #ifndef FLASH_SIZE
  32. -#define FLASH_SIZE 4
  33. +#define FLASH_SIZE 16
  34. #endif
  35. /*-----------------------------------------------------------------------
  36. * FLASH and environment organization
  37. === last line above ^
  38.  
  39. patch -p1 < ./16mb.patch
  40.  
  41. 3-4.2, PATH A) Prepare an old toolchain, to see the "desired" directory tree:
  42.  
  43. cd /home/anon/tp-link-gpl/wr841nv9_en_gpl/build/
  44. make DEV_NAME=wr841nv9_en toolchain_prep
  45.  
  46. This toolchain is ancient, built by unknown person at TP-Link, and is x86 - did not work on Arch/Artix without these changes:
  47.  
  48. {
  49.  
  50. According to
  51.  
  52. https://wiki.archlinux.org/index.php/Official_repositories#multilib
  53.  
  54. uncomment "multilib" :
  55.  
  56. sudo nano /etc/pacman.conf
  57.  
  58. then install these packages :
  59.  
  60. pacman -Suy lib32-glibc lib32-zlib gcc-libs lib32-gcc-libs
  61.  
  62. }
  63.  
  64. I want a good GCC toolchain, i.e. a fresh musl 5.5.0 from libreCMC
  65. ( musl seems to be better than uclibc - http://www.etalabs.net/compare_libcs.html )
  66.  
  67. 4) Using another toolchain's files, replace an old toolchain with a new one:
  68.  
  69. 4.1) /home/anon/libreCMC/staging_dir/toolchain-mips_24kc_gcc-5.5.0_musl-1.1.16/ = /home/anon/tp-link-gpl/wr841nv9_en_gpl/build/gcc-4.3.3/build_mips/staging_dir/usr/ :
  70.  
  71. rm -rf /home/anon/tp-link-gpl/wr841nv9_en_gpl/build/gcc-4.3.3/build_mips/staging_dir/usr/
  72. cp -R /home/anon/libreCMC/staging_dir/toolchain-mips_24kc_gcc-5.5.0_musl-1.1.16/ /home/anon/tp-link-gpl/wr841nv9_en_gpl/build/gcc-4.3.3/build_mips/staging_dir/usr/
  73.  
  74. 4.2) /home/anon/libreCMC/staging_dir/host/ = /home/anon/tp-link-gpl/wr841nv9_en_gpl/build/gcc-4.3.3/build_mips/staging_dir/host/
  75.  
  76. rm -rf /home/anon/tp-link-gpl/wr841nv9_en_gpl/build/gcc-4.3.3/build_mips/staging_dir/host/
  77. cp -R /home/anon/libreCMC/staging_dir/host/ /home/anon/tp-link-gpl/wr841nv9_en_gpl/build/gcc-4.3.3/build_mips/staging_dir/host/
  78.  
  79. ===> 3-4.2, PATH B) Or, even better,
  80.  
  81. cd /home/anon/tp-link-gpl/wr841nv9_en_gpl/build/
  82. rm -rf ./gcc-4.3.3/
  83. mkdir ./gcc-4.3.3/
  84. mkdir ./gcc-4.3.3/build_mips/
  85. mkdir ./gcc-4.3.3/build_mips/staging_dir/
  86. cp -R /home/anon/libreCMC/staging_dir/toolchain-mips_24kc_gcc-5.5.0_musl-1.1.16/ ./gcc-4.3.3/build_mips/staging_dir/usr/
  87. cp -R /home/anon/libreCMC/staging_dir/host/ ./gcc-4.3.3/build_mips/staging_dir/host/
  88.  
  89. 4.3)
  90.  
  91. export STAGING_DIR="/home/anon/tp-link-gpl/wr841nv9_en_gpl/build/gcc-4.3.3/build_mips/staging_dir/"
  92.  
  93. 4.4 - PATH A)
  94.  
  95. cd /home/anon/tp-link-gpl/wr841nv9_en_gpl/build/gcc-4.3.3/build_mips/staging_dir/usr/bin/
  96.  
  97. ln -s mips-openwrt-linux-musl-addr2line mips-linux-uclibc-addr2line
  98. ln -s mips-openwrt-linux-musl-ar mips-linux-uclibc-ar
  99. ln -s mips-openwrt-linux-musl-as mips-linux-uclibc-as
  100. ln -s mips-openwrt-linux-musl-c++ mips-linux-uclibc-c++
  101. ln -s mips-openwrt-linux-musl-c++filt mips-linux-uclibc-c++filt
  102. ln -s mips-openwrt-linux-musl-gcc mips-linux-uclibc-cc
  103. ln -s mips-openwrt-linux-musl-cpp mips-linux-uclibc-cpp
  104. ln -s mips-openwrt-linux-musl-elfedit mips-linux-uclibc-elfedit
  105. ln -s mips-openwrt-linux-musl-g++ mips-linux-uclibc-g++
  106. ln -s mips-openwrt-linux-musl-gcc mips-linux-uclibc-gcc
  107. ln -s mips-openwrt-linux-musl-gcov mips-linux-uclibc-gcov
  108. ln -s mips-openwrt-linux-musl-gdb mips-linux-uclibc-gdb
  109. ln -s mips-openwrt-linux-musl-gprof mips-linux-uclibc-gprof
  110. ln -s mips-openwrt-linux-musl-ld mips-linux-uclibc-ld
  111. ln -s mips-openwrt-linux-musl-nm mips-linux-uclibc-nm
  112. ln -s mips-openwrt-linux-musl-objcopy mips-linux-uclibc-objcopy
  113. ln -s mips-openwrt-linux-musl-objdump mips-linux-uclibc-objdump
  114. ln -s mips-openwrt-linux-musl-ranlib mips-linux-uclibc-ranlib
  115. ln -s mips-openwrt-linux-musl-readelf mips-linux-uclibc-readelf
  116. ln -s mips-openwrt-linux-musl-size mips-linux-uclibc-size
  117. ln -s mips-openwrt-linux-musl-strings mips-linux-uclibc-strings
  118. ln -s mips-openwrt-linux-musl-strip mips-linux-uclibc-strip
  119.  
  120. 4.4 - PATH B)
  121.  
  122. cd /home/anon/tp-link-gpl/wr841nv9_en_gpl/
  123.  
  124. and apply this patch:
  125.  
  126. diff --git a/build/products_config/wr841nv9_en/basic.config b/build/products_config/wr841nv9_en/basic.config
  127. --- a/build/products_config/wr841nv9_en/basic.config
  128. +++ b/build/products_config/wr841nv9_en/basic.config
  129. @@ -2,7 +2,7 @@
  130. export BOARD_TYPE=ap143
  131. export CFG_BOARD_TYPE=$(BOARD_TYPE)
  132. export TOOLCHAIN=gcc-4.3.3
  133. -export TOOLPREFIX=mips-linux-uclibc-
  134. +export TOOLPREFIX=mips-openwrt-linux-musl-
  135. export TOOLARCH=build_mips/staging_dir/usr
  136. export UBOOT_GCC_4_3_3_EXTRA_CFLAGS=-fPIC
  137.  
  138. === last line above ^
  139.  
  140. patch -p1 < ./toolchain.patch
  141.  
  142. 5) According to
  143.  
  144. https://github.com/pepe2k/u-boot_mod/issues/95
  145. https://github.com/pepe2k/u-boot_mod/commit/6d509b9219dc0e87f06ac2f24df60505fc1af707
  146.  
  147. do
  148.  
  149. cd /home/anon/tp-link-gpl/wr841nv9_en_gpl/ap143/boot/u-boot/include/asm-mips/
  150.  
  151. find . -type f -name "bitops.h" -print0 | xargs -0 sed -i 's/extern __inline__/static __inline__/g'
  152. find . -type f -name "io.h" -print0 | xargs -0 sed -i 's/extern __inline__/static __inline__/g'
  153. find . -type f -name "mipsregs.h" -print0 | xargs -0 sed -i 's/extern __inline__/static __inline__/g'
  154. find . -type f -name "processor.h" -print0 | xargs -0 sed -i 's/extern __inline__/static __inline__/g'
  155. find . -type f -name "string.h" -print0 | xargs -0 sed -i 's/extern __inline__/static __inline__/g'
  156. find . -type f -name "system.h" -print0 | xargs -0 sed -i 's/extern __inline__/static __inline__/g'
  157.  
  158. find . -type f -name "bitops.h" -print0 | xargs -0 sed -i 's/extern inline/static inline/g'
  159. find . -type f -name "io.h" -print0 | xargs -0 sed -i 's/extern inline/static inline/g'
  160. find . -type f -name "mipsregs.h" -print0 | xargs -0 sed -i 's/extern inline/static inline/g'
  161. find . -type f -name "processor.h" -print0 | xargs -0 sed -i 's/extern inline/static inline/g'
  162. find . -type f -name "string.h" -print0 | xargs -0 sed -i 's/extern inline/static inline/g'
  163. find . -type f -name "system.h" -print0 | xargs -0 sed -i 's/extern inline/static inline/g'
  164.  
  165. 6) According to
  166.  
  167. https://stackoverflow.com/questions/58206403/multiple-definitions-of-error-while-linking-two-archives-using-the-same-source
  168.  
  169. do
  170.  
  171. cd /home/anon/tp-link-gpl/wr841nv9_en_gpl/ap143/boot/u-boot/include/
  172.  
  173. find . -type f -name "pci.h" -print0 | xargs -0 sed -i 's/extern __inline__/static __inline__/g'
  174. find . -type f -name "pci.h" -print0 | xargs -0 sed -i 's/extern inline/static inline/g'
  175.  
  176. 7) Now you can
  177.  
  178. cd /home/anon/tp-link-gpl/wr841nv9_en_gpl/build/
  179. make DEV_NAME=wr841nv9_en uboot
  180.  
  181. and your file will be called
  182.  
  183. /home/anon/tp-link-gpl/wr841nv9_en_gpl/ap143/boot/u-boot/tuboot.bin
  184.  
  185. === ;-)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement