Building LEDE / OpenWrt for TP-Link C2600 with ftrace enable

Summary: Using Linux kernel ftrace to trace down kernel problems is essential in different ways, this post is to summarize how to build a LEDE / OpenWrt image for C2600 with ftrace enable (CONFIG_FUNCTION_TRACER, CONFIG_DYNAMIC_FTRACECONFIG_FUNCTION_GRAPH_TRACER, CONFIG_FUNCTION_PROFILER).

0x1 Prepare LEDE source code

Make sure you get LEDE source code from GitHub mirror or their git.

You can take a look at this post for detail: Build LEDE for TP-Link Archer C2600 from source (Chinese)

0x2 You will get failed if you just enable ftrace

You can use make menuconfig and go through Global build settings -> Kernel build options and check all option in Function tracer to enable.

And when you build with make -j8, you will get something like this:

There have nothing like openwrt-ipq806x-squashfs-sysupgrade.bin as usual. (Remember don’t use openwrt-ipq806x-squashfs-root.img with sysupgrade -f, this will brick your device and you will need to use tftp to debrick it)

0x3 Setting up config properly for C2600 with ftrace enable

Using make V=s to debug, we will find this output at the near end from tplink-safeloader:

Bingo, ftrace options make the firmware too large so that it can not let tplink-safeloader generate the file.

Adjust some config and rebuild again, then we can get the sysupgrade.bin file.

Following options are what I used:

  • CONFIG_KERNEL_KALLSYMS (so that you can trace with driver, mac80211 …etc)
  • KERNEL_FTRACE
  • KERNEL_FUNCTION_TRACER
  • KERNEL_FUNCTION_GRAPH_TRACER
  • KERNEL_DYNAMIC_FTRACE
  • KERNEL_FUNCTION_PROFILER

Following config file is what I used:

LEDE_C2600_ftrace.config

0x4 Using ftrace on C2600 with LEDE

To record mac80211 and ath10k events

To record specific function and draw out the function graph

More references:

0x5 Special Thanks

Many thanks to #lede-dev @hanetzer,hanetzer kindly help me in the first timing when I post the problem on the channel, and give me many useful advice on LEDE and images. Without hanetzer I will not able to enable this. Thanks.




如果你覺得這篇文章不錯,歡迎打賞

BTH: 35QooNA82isrmQLmpEnqXpJoxeZmaPubPf

ETH:0x4cf61fea5EA842D202B85158d8b5e239C872De46

或是點選下方圖片贊助我一杯咖啡:

Leave a reply:

Your email address will not be published.

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料