OpenWrt Forum Archive

Topic: Serial not working

The content of this topic has been archived on 1 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I am trying to run Kamikaze 8.09.1 on WNR3500L. Kernel is booting properly but I am not getting any message from user space application. I have found that it is unable to open "/dev/console" and I am getting following error message --
"Please be patient, while OpenWrt loads"

Below is the minicom dump that I am getting. Any help regarding this is highly appreciated.

Linux version 2.6.25.20 (root@icm2.alumnus.co.in) (gcc version 4.1.2) #197 Thu Jan 21 17:32:11 IST 2010
CPU revision is: 00019740 (MIPS 74K)
Core 1 found: ChipCommon (cc 0x800, rev 0x1F, vendor 0x04BF)
Core 2 found: IEEE 802.11 (cc 0x812, rev 0x11, vendor 0x04BF)
Core 3 found: Gigabit MAC Core (cc 0x82D, rev 0x00, vendor 0x04BF)
Core 4 found: MIPS 74K Core (cc 0x82C, rev 0x01, vendor 0x04A7)
Core 5 found: USB 2.0 Host (cc 0x819, rev 0x04, vendor 0x04BF)
Core 6 found: PCI-E (cc 0x820, rev 0x0E, vendor 0x04BF)
Core 7 found: DDR1/2 memory controller Core (cc 0x82E, rev 0x01, vendor 0x04BF)
Core 8 found: Internal Memory (cc 0x80E, rev 0x07, vendor 0x04BF)
Core 9 found: I2S Core (cc 0x834, rev 0x00, vendor 0x04BF)
Found END of erom after 9 cores
ssb: Initializing MIPS core...
rate: 113000000
ssb: Sonics Silicon Backplane found at address 0x18000000
Serial init done.
Determined physical RAM map:
memory: 04000000 @ 00000000 (usable)
Initrd not found or empty - disabling initrd
Zone PFN ranges:
  Normal          0 ->    16384
Movable zone start PFN for each node
early_node_map[1] active PFN ranges
    0:        0 ->    16384
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: root=/dev/mtdblock2 rootfstype=squashfs,jffs2 init=/etc/preinit noinitrd console=ttyS0,115200
Primary instruction cache 32kB, VIPT, 4-way, linesize 32 bytes.
Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
Synthesized clear page handler (25 instructions).
Synthesized copy page handler (44 instructions).
PID hash table entries: 256 (order: 8, 1024 bytes)
CPU: BCM4716 rev 1 at 453 MHz
console [ttyS0] enabled
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 62304k/65536k available (1999k kernel code, 3160k reserved, 305k data, 132k init, 0k highmem)
Mount-cache hash table entries: 512
net_namespace: 444 bytes
NET: Registered protocol family 16
@@@@@@@ WNR3500L_PCIBIOS_INIT CALLED @@@@@@
PCI: Using membase 8000000
PCI: Disabled
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
detected lzma initramfs
initramfs: LZMA lc=1,lp=2,pb=2,origSize=512
squashfs: version 3.0 (2006/03/15) Phillip Lougher
Registering mini_fo version $Id$
JFFS2 version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.
io scheduler noop registered
io scheduler deadline registered (default)
Serial: 8250/16550 driver $Revision: 1.90 $ 2 ports, IRQ sharing enabled
serial8250: ttyS0 at MMIO 0xb8000300 (irq = 8) is a 16550A
serial8250.0: ttyS0 at MMIO 0xb8000300 (irq = 8) is a 16550A
pflash: found no supported devices
bootloader size: 262144
sflash: Filesystem type: squashfs
Creating 5 MTD partitions on "sflash":
0x00000000-0x00040000 : "cfe"
0x00040000-0x007f0000 : "linux"
0x000f8400-0x001e0000 : "rootfs"
mtd: partition "rootfs" set to be root filesystem
0x001e0000-0x00740000 : "rootfs_data"
0x007f0000-0x00800000 : "nvram"
TCP vegas registered
NET: Registered protocol family 1
NET: Registered protocol family 17
802.1Q VLAN Support v1.8 Ben Greear <greearb@candelatech.com>
All bugs added by David S. Miller <davem@redhat.com>
VFS: Mounted root (squashfs filesystem) readonly.
Freeing unused kernel memory: 132k freed
Please be patient, while OpenWrt loads
Algorithmics/MIPS FPU Emulator v1.5
mini_fo: using base directory: /
mini_fo: using storage directory: /tmp/root
PPP generic driver version 2.4.2
ip_tables: (C) 2000-2006 Netfilter Core Team
nf_conntrack version 0.5.0 (1024 buckets, 4096 max)

I am not getting any message from any user space application. 'echo', 'printf' command are not working.
Any idea ?

Tathagata

Hi!
Are you building trunk? What else is needed to get a wnr3500l flashable image in forms of patches?
I want to help out but have some bits to learn in openwrt to get up to speed...

/Per

I am building kakikaze-8.09.1. Current source code does not support wnr3500l. I have modified the ssb driver code along with some codes in flash and in arch/mips.
I dont think my problem is a wnr3500l specific. I am probably doing some common mistake.

Tathagata

Hi, I have an Asus RT-N16 router. I've been trying all sort of stuff to get the kernel to boot on this device, but it all failed. I'm not very skilled in kernel development, but I like to get my hands dirty smile

Ok! If you have any patches to share, I'm happy to get going on helping out.
Got my wnr3500l last week and installed UART port for flashing, so I'm ready to go!

Have built trunk and starting to look at the patches on myopenrouter.com (for 2.4 kernel) and also the tomato kernel patches for Asus rt-n16.

/Per

It will take time to prepare the patch. You can look into the existing code and tell me what could be the reason of not getting any print in the console through printf and echo.
I am using kamikaze-8.09.1 with kernel version 2.6.25 and platform is brcm47xx.
I have found one interesting thing -- In kernel it is unable to open "/dev/console" file. It may be the reason behind it.

Sorry for not getting back sooner! Work is crazy and sick kids is a bad combo...

I looked in the code and tried to see what it is that fails. It's kind of hard without knowing exactly what your patches are. Your config at least

But as far as I can see the /dev/console device should be created in from init which sources /etc/preinit which in turn sources /lib/preinit/30_device_fs_daemon which adds init_device_fs to the boot_hook. But if /sbin/udevd nor /sbin/hotplug2 is present the device isn't.

Do you have either udev enabled in your build? You should be able to mknod the device directly in init for debugging purposes at least.

/Per

Hmm... Looking at it a bit further I think the above post was rubbish...
Think the root file system is under target-mipsel_uClibc-0.9.30.1/root-brcm47xx which uses busybox init, but I think you still need either  udevd or hotplug2 enabled. Not sure what the default case is...

Have a stereo-mic uart plug installed on my router and flashed some stuff just to make sure it works.

/Per

hotplug and udev are enabled in my configuration.
CONFIG_PACKAGE_udev=y
CONFIG_PACKAGE_hotplug2=y

Kernel calls /etc/preinit file first where I have written one small program which actually mount /dev by tmpfs and create "/dev/console" using mknod. After that I write some bytes into that file but nothing is coming up on the console.
This same program is working fine with 2.4 kernel.

Hm... So you mean /dev/console isn't created on boot. That probably means that /dev/ttyS0 isn't created either which is needed to open the console. Have you tried to create that device as well?

Yes. Instead of creating /dev/console I have created /dev/ttyS0. But in that case also I am not getting any message.
Do you mean to say that both this device files are required ? To which file should I write ... ttyS0 or console ?
On boot /dev is not mounted and so it fails to create /dev/console file. That is why I am getting message "Please be patient, while OpenWrt loads" on boot.

(Last edited by tathagata on 18 Feb 2010, 08:54)

Yes! You need both /dev/console with major 5 minor 1 and also the /dev/ttyS0 device with major 4 and minor 64 from what I can tell.

I'm really looking forward to trying your patches... :-)

I will create both files and let you know the result.

I will also create patches for kernel. Could you please tell me how to upload patches here ?

I created two files as you told. Then I tried to write to both these files one by one. But nothing is displayed on the console.
Below is the program that I am using

<cut>
int main()
{
FILE *port, *port1;
   unsigned int data = 'X';
   unsigned char *string = "Waiting for input...\r";
   int rc1, rc2;

   rc1 = mount("devfs", "/dev", "tmpfs", MS_MGC_VAL, NULL);
   rc2 = mknod("/dev/console", S_IRWXU|S_IFCHR, makedev(5, 1));
   rc2 = mknod("/dev/ttyS0", S_IRWXU|S_IFCHR, makedev(4, 64));

   port = fopen("/dev/console","w+");
   if (port == NULL) {
      perror("fopen");
      return 0;
   }

   fputs(string, port);
   fflush(port);

   port1 = fopen("/dev/ttyS0","w+");
   if (port1 == NULL) {
      perror("fopen");
      return 0;
   }

   fputs(string, port1);
   fflush(port1);

   while (data != 'Q') {
      data = fgetc(port);
      fprintf(port, "--->%c<---\r", data);
      fflush(port);
   }

/* close the serial port */
   fclose(port);
   fclose(port1);
   return 0;
}

I'm not sure why you can't attach files to the forum, but you can always email the patch to me.

Can you send your config as well so we are on the same page with regards to packages etc.

I'm not sure that it is as easy as that just to write directly to a serial port. Doesn't it need to be configured and setup properly?

I have copied my config files.

<cut>
CONFIG_TARGET_brcm47xx=y
CONFIG_TARGET_BOARD="brcm47xx"
CONFIG_LINUX_2_6_25=y
CONFIG_DEFAULT_base-files=y
CONFIG_DEFAULT_bridge=y
CONFIG_DEFAULT_busybox=y
CONFIG_DEFAULT_dnsmasq=y
CONFIG_DEFAULT_dropbear=y
CONFIG_DEFAULT_firewall=y
CONFIG_DEFAULT_hostapd-mini=y
CONFIG_DEFAULT_hotplug2=y
CONFIG_DEFAULT_iptables=y
CONFIG_DEFAULT_kmod-b43=y
CONFIG_DEFAULT_kmod-diag=y
CONFIG_DEFAULT_kmod-ipt-nathelper=y
CONFIG_DEFAULT_kmod-switch=y
CONFIG_DEFAULT_libgcc=y
CONFIG_DEFAULT_mtd=y
CONFIG_DEFAULT_nvram-brcm47xx=y
CONFIG_DEFAULT_opkg=y
CONFIG_DEFAULT_ppp=y
CONFIG_DEFAULT_ppp-mod-pppoe=y
CONFIG_DEFAULT_uci=y
CONFIG_DEFAULT_uclibc=y
CONFIG_DEFAULT_udevtrigger=y
CONFIG_LINUX_2_6=y
CONFIG_GPIO_SUPPORT=y
CONFIG_PCI_SUPPORT=y
CONFIG_USB_SUPPORT=y
CONFIG_USES_SQUASHFS=y
CONFIG_mipsel=y
CONFIG_ARCH="mipsel"
CONFIG_TARGET_ROOTFS_SQUASHFS=y

#
# Base system
#
CONFIG_PACKAGE_base-files=y
# CONFIG_PACKAGE_br2684ctl is not set
CONFIG_PACKAGE_bridge=y
CONFIG_PACKAGE_busybox=y

#
# Configuration
#
# CONFIG_BUSYBOX_CONFIG_FEATURE_DEVFS is not set
# CONFIG_BUSYBOX_CONFIG_FEATURE_2_4_MODULES is not set
CONFIG_BUSYBOX_CONFIG_FEATURE_2_6_MODULES=y
CONFIG_BUSYBOX_CONFIG_HAVE_DOT_CONFIG=y

CONFIG_PACKAGE_dnsmasq=y
CONFIG_PACKAGE_dropbear=y
CONFIG_PACKAGE_firewall=y
CONFIG_PACKAGE_hotplug2=y
CONFIG_PACKAGE_iptables=y
CONFIG_PACKAGE_iptables-mod-conntrack=y
# CONFIG_PACKAGE_iptables-mod-conntrack-extra is not set
# CONFIG_PACKAGE_iptables-mod-extra is not set
# CONFIG_PACKAGE_iptables-mod-filter is not set
# CONFIG_PACKAGE_iptables-mod-imq is not set
# CONFIG_PACKAGE_iptables-mod-ipopt is not set
# CONFIG_PACKAGE_iptables-mod-iprange is not set
# CONFIG_PACKAGE_iptables-mod-ipsec is not set
# CONFIG_PACKAGE_iptables-mod-ipset is not set
CONFIG_PACKAGE_iptables-mod-nat=y
# CONFIG_PACKAGE_iptables-mod-nat-extra is not set
# CONFIG_PACKAGE_iptables-mod-ulog is not set
# CONFIG_PACKAGE_iptables-utils is not set
# CONFIG_PACKAGE_ldconfig is not set
# CONFIG_PACKAGE_ldd is not set
CONFIG_PACKAGE_libgcc=y
# CONFIG_PACKAGE_libpthread is not set
# CONFIG_PACKAGE_libstdcpp is not set
CONFIG_PACKAGE_mtd=y
CONFIG_PACKAGE_nvram-brcm47xx=y
CONFIG_PACKAGE_ngr_test=y
CONFIG_PACKAGE_opkg=y
# CONFIG_PACKAGE_qos-scripts is not set
CONFIG_PACKAGE_uci=y
CONFIG_PACKAGE_uclibc=y
CONFIG_PACKAGE_udevtrigger=y
# CONFIG_PACKAGE_wireless-tools is not set

# Network
#
# CONFIG_PACKAGE_arptables is not set
# CONFIG_PACKAGE_ebtables is not set
# CONFIG_PACKAGE_ebtables-utils is not set
# CONFIG_PACKAGE_genl is not set
# CONFIG_PACKAGE_hostapd is not set
# CONFIG_PACKAGE_hostapd-mini is not set
# CONFIG_PACKAGE_ifenslave is not set
# CONFIG_PACKAGE_ip is not set
# CONFIG_PACKAGE_ipset is not set
CONFIG_PACKAGE_ppp=y
# CONFIG_PACKAGE_chat is not set
# CONFIG_PACKAGE_ppp-mod-pppoa is not set
CONFIG_PACKAGE_ppp-mod-pppoe=y
# CONFIG_PACKAGE_ppp-mod-radius is not set
# CONFIG_PACKAGE_pppdump is not set
# CONFIG_PACKAGE_pppstats is not set
# CONFIG_PACKAGE_pptp is not set
# CONFIG_PACKAGE_tc is not set
# CONFIG_PACKAGE_wpa-supplicant is not set
# CONFIG_PACKAGE_wprobe-export is not set
# CONFIG_PACKAGE_wprobe-info is not set

CONFIG_PACKAGE_libuci=y

CONFIG_PACKAGE_udev=y

</cut>

Any idea about what is going wrong ?

Sorry for not answering sooner. I've been busy at work. I have no more idea at the moment why it's not working.
For debugging I would maybe suggest trying out Early serial console (drivers/serial/8250_early.c) for getting more info out on what's going on.

/Per

Thanks for your help.

I'm still interested in helping out more when you have your kernel patches ready (in whatever shape).

Hi,

There are apparently quite a few people working on the new SSB drivers to make the new routers to work (i.e. ASUS RT16, WNR3500L, etc..). Currently, there is a diff created to make the kernel boot:
https://lists.openwrt.org/pipermail/ope … 06547.html

However, the drivers seem to be missing (USB, ETHERNET, WIRELESS).

If you could help out fixing the drivers, based on dd-wrt, tomator or stock firmware, it would help a lot!

I'm currently trying to port ethernet driver... but it goes very slowly as I do not have much experience in this stuff.

Thanks,
Greg

Good to know that other people like you are also working on this stuff. I am still stuck into the same problem, i.e serial is not working. Is serial working in your case ?
Can you please help in this matter ?

tathagata wrote:

Good to know that other people like you are also working on this stuff. I am still stuck into the same problem, i.e serial is not working. Is serial working in your case ?
Can you please help in this matter ?

Yes, everything seems to be fine in my case. I've got serial and everything else is working, except of the three drivers (usb, ethernet and wifi). Have you tried to compile the trunk version with the diffs provided?

can you please send me your patch along with application so that I can compare with mine ?
Do you have any idea why I am not getting any print from application ? I am getting kernel messages like printk properly but not getting any message from application like printf or echo.

The discussion might have continued from here.