Skip to content
This repository has been archived by the owner on Oct 13, 2022. It is now read-only.

Serial console outputs junks #21

Closed
zwhfly opened this issue Mar 19, 2014 · 10 comments
Closed

Serial console outputs junks #21

zwhfly opened this issue Mar 19, 2014 · 10 comments

Comments

@zwhfly
Copy link
Contributor

zwhfly commented Mar 19, 2014

I have a TPLINK TL-WDR4310 and a Mercury MW4530R. They have basically the same hardware, both with an Atheros AR9344.
When connected to a CH341A based USB-UART adapter (we call it "TTL cable" in Chinese), the routers output junks to my terminal, as seen by the guys here (http://www.right.com.cn/forum/thread-89181-1-1.html), here (http://www.right.com.cn/forum/thread-89038-1-1.html) and here (http://www.right.com.cn/forum/thread-131982-1-1.html).
Here's the output of the TL-WDR4310, and the MW4530R has a similar situation:

root@OpenWrt:/# reboot
root@OpenWrt:/# [   26.760000] br-lan: port 1(eth0.1) entered disabled state
[   26.790000] device eth0.1 left promiscuous mode
[   26.790000] device eth0 left promiscuous mode
[   26.790000] br-lan: port 1(eth0.1) entered disabled state
[   29.360000] Removing MTD device #3 (rootfs_data) with use count 1
[   29.370000] Restarting system.

.%?I?RR***%%?IIRRR?*%%%IIIRRR?*.?H  ���.U.?..1.�B
                                                                  ?.9 2?    �. .HHII?RR**.%?I?RR***%%?IIRRR***%%%I?
.2�(A?&�S   .码?for �.�I360.3.
!.5i  ?�j   
?M!?WiK焦.W25T��B?MBJC!H.ED 
                                 "丈ing.?ini?X+K.ソ?..C?.it..key 
                                                                          .? a]?浇tin.�..j.!?.?�imaV�
                                                                                                              ? 0xN�..0.?.m?�r.e:� O?k%?r3堵?
                                                                                                                                                           R[XV�㈠?:  .R5bス蔗 K?+?Ima?Bb?a 惬辽.seV
                                               .".a s榀���.9M.?BytY.??4..BC!��b?.add?. 0x8.0?j
                                                                                                            .E??poin.�.?0�..

Uk降?e螽?.er?
                 J?ge.�.?
                             ?裳?g .??..C?. ...00. ?+?ver?
                                                                        .3.�(b祀?�Deb?..sq?Y.散jjスサ.) ?.ver??4.6.?..20?..elYX.    Bbス.���.0.0?�AU re?.r ?.?9:&�..20L?h���.00.0?浇?on?.[ear+?.+.ed
                       J烷 00?N�?(M傻.?
[ ...00瓣.k?P�.? A.?�rev
?��.00.0?苯.s:.Uオ?..M?   "�R:4?..!楸 AH?&&  .j?, .?0.0?!?
                                                                                   [ ...00. ?W傻ine?″?ca?5.ap?[.�..0?? memK彘...00.00.0.(醍..
[   .0?.?InZ..ot ??�or Y[彦 - ?.?ng.+.d
+���.00.0菀焦.PF
                   .?es:C?�� 0..0瓣.r缴?l .铝0000?�j?0x.0?.
                                                                       [  .r..0?M?..zo?..t e9.K.X,
?���0.?...?+.emo?.9 ra??                                                                           r?e
                                   [  ..?...� 0?铝0000?�j?0x.0?.
                                                                           [   ...00W�榨? 1医??st.J?Zon??., ?ケ?y 绠.?g 怂��⒔??pa?.�.51?[.�..0??KernY
                  �降man�bス.  .?uTL...0 闼徒?=tWM连LLM&.r?.?peO..hfsI?? noZ.?
[  ..?...R�B.h tX,.entrZY..2.K.r: . .? ..%
[. r00?..en舢.X,.has琚.? e??? 1勇?BordY.'? 65M&��?e?C?   .0.0?J菇de-?,.has
                                                                                               ?.e e.?? 8LN&Bz?.: 3 .翰8 b^W庭
[  .r..0?P?[X.in???on�.? 64-(   播PT,?wX^  b?esZ.. byW止
[ ...00瓣...?d?.X,.32kB    ??y,.
.   .0?.?Wr?穗.rr(�                      E?ca惬.++?? lZ+庭ze ?�逖es
?���0.0.0?..ba.*缮Ctl..?erO..00??.�..0.].Y[K彘 ?.②???Z.vXZ+.e (&?Z�ke颢?code.?纶.瀹�?d, S?.ata   ...nZ�  ..?.?
[  ..0.0?.UB: ?k?bs=N   B].ig..�OrdY.j. ???ct?b��AU王1, ?.?
?��.00.0?I}%RQS?LC? ...00. ?+K?ti?".ay 腚凉.. 27r93.k?IPS.俩?39.?j
                                                                                      [ .0...] ?终.: V.毡t: &?��minZ[]K�30??.�..0??MounWi.? hX.
    ?ble.焉ies邯.j
                     [ .0...] .?.ネter?.?oc
. ...00瓣.ソ.?_?...脱ere�:A%? 阿?22 o?.?e:.�胧j
                                                                ?��.09?..IP*'j.hinYJ?TP-LR?TL-W莫&�.43??.
%�con.北. wZ�.k?rin�
? .0i..0] .?,.? s+.棘氲0> a?j
                                       [. ?..0].%.ost.?. t
                                                                   �胀�00耙00C?�� 0.&&.. p.%? 0??. r?.]..?u颥�诘em 芭00.0j0x?..f].+��..?....%胀 00.0?.? b]..?ur.讠? 0?0?
                                              ?��.33?..ci.0?...0?官.id�.?ratZ??W5
                                                                                                [. 0i..0] ...?.0r0:.I.: a螽牍. [[Y[.?0.0?屡001f.�并bitWC?  0i?.0].?0000??.0:�I.: a.牍. [[Y[.??..0x?..f 甬.5
                                                                                   [ � 0.�.. 瓞
                                                                                                  ..:.0 ?.ス.irq? ?.Z
                                                                                                                                   .
                                                                                                                                     [  .r..0?.?chZ?
?苯cks?..IP.[  ..?.. NQ..gisW..pr镒k奖 fa?+.
?��.36.0?A.out?.? hX.
                             ?ble.焉?s:.2�Bz?er:. 词?�逖.%
A.sta,+汀. hX.
                ?bl濯寡?es孩.?(o?�?3, &??bytY.H. � 0.�.. ?�?d +汀.ablY*寡?es'?什 (?V砷 2,.勇?by?.H?� 0.?.. T(?B.h... c锼??ed.脱.li...096.?�40?
A.en                      ?���.38.0茛
     ..ste.5.���.3.0?.A ha
                                  螈.le Y.?s: ?�Bz?.: 0    ?什.yW芝.+��..?...�Ubパe hX.
                                                                                                    ?ble.焉ies?.�?r?.�. 4? ?W庭
[ � 0...] ?��..脱er?.?oc
                                 ?.ily
[ .0...] ..?s:?赏?n    �B.0    ..) ?北? L.?
[. ?..0]..?ve.胨
                        ..?A?   B.55RY).i5) (?.?(CS.}?IO
                                                                       ..(c).0LK&. Re�B.1 In,
                                                                                                  ?. ?..0]j?倒i hX.�.n sY�⒔ 24??.�.?0??Bloc-b.. Sí
        :.erZ,B�??.?r v瀹.
                                ?r?lo?�.maj?.⑹
+���.44.0??scheV�..oo.e?.W...���.4�...o.?.l?".dli?..st瀹.(defX].
[ ..?00. ?.? 8?z..0"丧?r, L�.?s,JIE.ha?k.nab?VH..�.?0.]...82?.�⒀?A a?5%= 0x?..0 )K?= 11JJ?a 16MM
                                                                                                                                   5
                                                                                                                                    [    0.490000] console [ttyS0] enabled, bootconsole disabled
[    0.490000] console [ttyS0] enabled, bootconsole disabled
[    0.500000] m25p80 spi0.0: found s25fl064k, expected m25p80
[    0.510000] m25p80 spi0.0: s25fl064k (8192 Kbytes)
[    0.510000] 5 tp-link partitions found on MTD device spi0.0
[    0.520000] Creating 5 MTD partitions on "spi0.0":
[    0.520000] 0x000000000000-0x000000020000 : "u-boot"
[    0.530000] 0x000000020000-0x000000109d54 : "kernel"
[    0.530000] mtd: partition "kernel" must either start or end on erase block boundary or be smaller than an erase block -- forcing read-only
[    0.550000] 0x000000109d54-0x0000007f0000 : "rootfs"
[    0.550000] mtd: partition "rootfs" must either start or end on erase block boundary or be smaller than an erase block -- forcing read-only
[    0.570000] mtd: partition "rootfs" set to be root filesystem
[    0.570000] mtd: partition "rootfs_data" created automatically, ofs=2E0000, len=510000 
[    0.580000] 0x0000002e0000-0x0000007f0000 : "rootfs_data"
[    0.590000] 0x0000007f0000-0x000000800000 : "art"
[    0.590000] 0x000000020000-0x0000007f0000 : "firmware"
[    0.730000] ag71xx_mdio: probed
[    0.730000] eth0: Atheros AG71xx at 0xb9000000, irq 4
......

Some particular USB-UART adapters may work, but lots not. As tested by jnny188 @ http://www.right.com.cn/forum/thread-131982-1-1.html, a pl-2303hx adapter works.

As seen above, when booting into linux kernel, the output goes perfectly. So this has to be a software problem.

@pepe2k
Copy link
Owner

pepe2k commented Mar 19, 2014

Hi @zwhfly,

Do you have the same problem with original U-Boot from TP-Link/Mercury?

Regards

@zwhfly
Copy link
Contributor Author

zwhfly commented Mar 19, 2014

Hi @pepe2k ,
Thanks for replying so fast.
Yes. Both the original and this u-boot_mod, both the TP-Link/Mercury, have this problem.
And I think I found the cause of this problem and I can fix it.
I will submit a pull request shortly. I'm learning how to use this thing - GitHub.

Regards

@pepe2k
Copy link
Owner

pepe2k commented Mar 19, 2014

Hi @zwhfly,

OK :)

Piotr

zwhfly added a commit to zwhfly/u-boot_mod that referenced this issue Mar 19, 2014
This commit fixes this issue: pepe2k#21.
@zwhfly
Copy link
Contributor Author

zwhfly commented Mar 19, 2014

I managed to read the "Divisor Latch Low" register (address 0x18020000).
In the Linux kernel of OpenWrt, where the serial works well, the value of this register is 0x00000016.
While in this u-boot, I read this register with the UDP console, the value is 0x00000015.
After I changed the value to 0x00000016, the serial starts to work, like a miracle!! (OK, I'm a newbie here.)

OK, this is the line:
div = (40 * 1000000) / (16 * CONFIG_BAUDRATE);
It should be 21.701388888888888888888888888889. Apparently, 22(0x16) works better.
In OpenWrt, the serial driver uses DIV_ROUND_CLOSEST, so let's use it here.
And it works:

root@OpenWrt:/# reboot
root@OpenWrt:/# [   43.140000] br-lan: port 1(eth0.1) entered disabled state
[   43.160000] device eth0.1 left promiscuous mode
[   43.160000] device eth0 left promiscuous mode
[   43.160000] br-lan: port 1(eth0.1) entered disabled state
[   45.620000] Removing MTD device #3 (rootfs_data) with use count 1
[   45.640000] Restarting system.


*********************************************
*        U-Boot 1.1.4  (Mar 19 2014)        *
*********************************************

DB120 (AR9344) U-Boot for TL-WDR3600/43x0

DRAM:   128 MB DDR2 32-bit
FLASH:  Winbond W25Q64 (8 MB)
CLOCKS: 560/450/225/28 MHz (CPU/RAM/AHB/SPI)

LED on during eth initialization...

Hit any key to stop autobooting:  0 

Booting image at: 0x9F020000

   Image name:   OpenWrt r36088
   Image type:   MIPS Linux Kernel Image (lzma compressed)
   Data size:    957268 Bytes = 934.8 kB
   Load address: 0x80060000
   Entry point:  0x80060000

Uncompressing kernel image... OK!
Starting kernel...

[    0.000000] Linux version 3.3.8 (blogic@Debian-60-squeeze-64-minimal) (gcc version 4.6.3 20120201 (prerelease) (Linaro GCC 4.6-2012.02) ) #1 Sat Mar 23 16:49:30 UTC 2013
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU revision is: 0001974c (MIPS 74Kc)
[    0.000000] SoC: Atheros AR9344 rev 2
[    0.000000] Clocks: CPU:560.000MHz, DDR:450.000MHz, AHB:225.000MHz, Ref:40.000MHz
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 08000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Zone PFN ranges:
[    0.000000]   Normal   0x00000000 -> 0x00008000
[    0.000000] Movable zone start PFN for each node
[    0.000000] Early memory PFN ranges
[    0.000000]     0: 0x00000000 -> 0x00008000
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 32512
[    0.000000] Kernel command line:  board=TL-WDR4300 console=ttyS0,115200 rootfstype=squashfs,jffs2 noinitrd
[    0.000000] PID hash table entries: 512 (order: -1, 2048 bytes)
[    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
[    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
[    0.000000] Writing ErrCtl register=00000000
[    0.000000] Readback ErrCtl register=00000000
[    0.000000] Memory: 126464k/131072k available (2211k kernel code, 4608k reserved, 418k data, 212k init, 0k highmem)
[    0.000000] SLUB: Genslabs=9, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS:51
[    0.000000] Calibrating delay loop... 278.93 BogoMIPS (lpj=1394688)
[    0.070000] pid_max: default: 32768 minimum: 301
[    0.070000] Mount-cache hash table entries: 512
[    0.080000] NET: Registered protocol family 16
[    0.080000] gpiochip_add: registered GPIOs 0 to 22 on device: ath79
[    0.090000] MIPS: machine is TP-LINK TL-WDR3600/4300/4310
[    0.090000] registering PCI controller with io_map_base unset
[    0.310000] bio: create slab <bio-0> at 0
[    0.310000] PCI host bridge to bus 0000:00
[    0.320000] pci_bus 0000:00: root bus resource [mem 0x10000000-0x13ffffff]
[    0.320000] pci_bus 0000:00: root bus resource [io  0x0000]
[    0.330000] pci 0000:00:00.0: invalid calibration data
[    0.330000] pci 0000:00:00.0: BAR 0: assigned [mem 0x10000000-0x1001ffff 64bit]
[    0.340000] pci 0000:00:00.0: BAR 6: assigned [mem 0x10020000-0x1002ffff pref]
[    0.340000] pci 0000:00:00.0: using irq 40 for pin 1
[    0.350000] Switching to clocksource MIPS
[    0.350000] NET: Registered protocol family 2
[    0.360000] IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.360000] TCP established hash table entries: 4096 (order: 3, 32768 bytes)
[    0.370000] TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
[    0.370000] TCP: Hash tables configured (established 4096 bind 4096)
[    0.380000] TCP reno registered
[    0.380000] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.390000] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.400000] NET: Registered protocol family 1
[    0.410000] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.420000] JFFS2 version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.430000] msgmni has been set to 247
[    0.440000] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
[    0.440000] io scheduler noop registered
[    0.450000] io scheduler deadline registered (default)
[    0.450000] Serial: 8250/16550 driver, 16 ports, IRQ sharing enabled
[    0.480000] serial8250.0: ttyS0 at MMIO 0x18020000 (irq = 11) is a 16550A
[    0.490000] console [ttyS0] enabled, bootconsole disabled
[    0.490000] console [ttyS0] enabled, bootconsole disabled
[    0.500000] m25p80 spi0.0: found s25fl064k, expected m25p80
[    0.510000] m25p80 spi0.0: s25fl064k (8192 Kbytes)
[    0.520000] 5 tp-link partitions found on MTD device spi0.0
[    0.520000] Creating 5 MTD partitions on "spi0.0":
......

I have submitted a pull request.

Woo Hoo, this is my first commit to a open source project. I'm so happy!

Cheers

@pepe2k
Copy link
Owner

pepe2k commented Mar 19, 2014

Hi @zwhfly,

Yep, you are right with that divider.
I have just tested your change on all supported SoCs and merged your pull request.

Woo Hoo, this is my first commit to a open source project. I'm so happy!

Congratulations! I hope it won't be your first and last commit :)

Regards!

@pepe2k pepe2k closed this as completed Mar 19, 2014
@zwhfly
Copy link
Contributor Author

zwhfly commented Mar 19, 2014

Hi @pepe2k, thank you!
And thank you for this splendid project!

@pepe2k
Copy link
Owner

pepe2k commented Mar 19, 2014

You're welcome!

@hackruu
Copy link
Contributor

hackruu commented Mar 19, 2014

👍

@landingware
Copy link

I have this problem too, but resolved now !
Connect your device using putty and set com port to 117000,n,8,1,none

@ergdfrte
Copy link

I have this problem too, but resolved now !
Connect your device using putty and set com port to 117000,n,8,1,none

good , very helpful for me

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants