📌 置頂: 請把任何比你弱勢的用路人當作你的至親對待。跟前車保持安全車距 (2秒以上)。

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

In

Tags:



by

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.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.