{"id":2638,"date":"2021-07-15T14:09:28","date_gmt":"2021-07-15T22:09:28","guid":{"rendered":"http:\/\/wonghoi.humgar.com\/blog\/?p=2638"},"modified":"2021-07-15T14:35:51","modified_gmt":"2021-07-15T22:35:51","slug":"flashing-router-firmware-through-serial-port-cfe-bootloader-usually-broadcom-based-routers","status":"publish","type":"post","link":"https:\/\/wonghoi.humgar.com\/blog\/2021\/07\/15\/flashing-router-firmware-through-serial-port-cfe-bootloader-usually-broadcom-based-routers\/","title":{"rendered":"Flashing router firmware through Serial Port: CFE bootloader (usually Broadcom) based routers"},"content":{"rendered":"\n<p>Here&#8217;s a summary of learnings from <a href=\"https:\/\/wiki.dd-wrt.com\/wiki\/index.php\/Serial_Recovery\">dd-wrt&#8217;s serial recovery instructions<\/a>:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Use a <strong>UART controller that signals at 3.3V<\/strong> (e.g.  FTDI <a rel=\"noreferrer noopener\" href=\"https:\/\/ftdichip.com\/wp-content\/uploads\/2021\/02\/DS_TTL-232R_CABLES.pdf\" target=\"_blank\">TTL-232R-3V3<\/a>) to talk to the board. Regular serial RS-232 ports requires a voltage level shifter converting the signal to swing between 0V to 3.3V. <\/li><li><strong>You only need 3 pins: Tx, Rx and Ground<\/strong>. There&#8217;s voltage contention if you plug in the Vcc from TTL-232R-3V3 (It&#8217;s the USB&#8217;s 5V despite the signaling is 3.3V) to the 3.3V supply of the router. You don&#8217;t need the Vcc pin. It didn&#8217;t harm anything or do anything when I connected the Vcc pin.<\/li><li>Stick with all serial port defaults and only set the baud to 115200 (default is 9600) and turn off flow control (default is xon\/xoff). I use Putty for terminal.<\/li><li>The terminal serves as the monitor for the computer on the router that shows a text console. Broadcom uses CFE bootloader (others use U-Boot with busybox).<\/li><li>CFE bootloader defaults to 192.168.1.1 with subnet mask 255.255.255.0 (aka \/24). Set up the network interface to have a <strong>static<\/strong> IP on the same subnet to talk to the board.<\/li><li>Good habit: <code>nvram erase<\/code><\/li><li>The flash program relies on TFTP protocol to receive the firmware file. So get your TFTP client ready. Microsoft included a TFTP client\/server since Windows 7 but usually disabled (turn it on in Windows OptionalFeatures.exe).<\/li><li>TFTP is a simple push(put)\/pull(get) design. You can either &#8220;push a file on your computer&#8221; or &#8220;get a file as filename&#8221;. You&#8217;d want to specify <code>-i<\/code> switch (binary image transfer) with Windows tftp.exe.<\/li><li>So type this command at the command prompt but don not press enter until your router is ready to grab the file: <code>tftp -i 192.168.1.1 put {path to whatever TRX firmware file}<\/code><\/li><li>Go back to the serial terminal and tell the router to accept a TFTP push (in a window of a few seconds before it time out) and flash the memory region flash1.trx with this command: <code>flash -ctheader : flash1.trx<\/code><\/li><li>Immediately initiate the TFTP push from your computer (Windows command line example in Step #9 above)<\/li><li>Wait for a couple of hours! The terminal might tell you that it has received the file completely, but it won&#8217;t show anything when it&#8217;s writing to the flash! It&#8217;s a painfully slow process with no feedback. Just be patient!<\/li><\/ol>\n\n\n\n<p>Some observations<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>FreshTomato firmware absolutely won&#8217;t tell you on the screen after it has done flashing (Merlin-WRT does). Just turn the router back on after a couple of hours.<\/li><li>Merlin firmware repeats (exposes) the raw passwords to the serial port!<\/li><li>FreshTomato firmware boots to a linux prompt on the serial port<\/li><\/ul>\n<div class=\"pvc_clear\"><\/div><p id=\"pvc_stats_2638\" class=\"pvc_stats all  \" data-element-id=\"2638\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p><div class=\"pvc_clear\"><\/div>","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a summary of learnings from dd-wrt&#8217;s serial recovery instructions: Use a UART controller that signals at 3.3V (e.g. FTDI TTL-232R-3V3) to talk to the board. Regular serial RS-232 ports requires a voltage level shifter converting the signal to swing &hellip; <a href=\"https:\/\/wonghoi.humgar.com\/blog\/2021\/07\/15\/flashing-router-firmware-through-serial-port-cfe-bootloader-usually-broadcom-based-routers\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_2638\" class=\"pvc_stats all  \" data-element-id=\"2638\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[44,39],"tags":[],"class_list":["post-2638","post","type-post","status-publish","format-standard","hentry","category-hardware","category-linux"],"_links":{"self":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts\/2638","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/comments?post=2638"}],"version-history":[{"count":2,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts\/2638\/revisions"}],"predecessor-version":[{"id":2641,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts\/2638\/revisions\/2641"}],"wp:attachment":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/media?parent=2638"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/categories?post=2638"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/tags?post=2638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}