OpenWrt Forum Archive

Topic: reboot hangs with 32M flash board

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

I met an issue reboot will hangs. That’s my environment.
       CPU: Atheros AR9344(Mips)
       Kernel: linux-3.10.2
Useing the follow patch, the system could run with 32M flash.
https://forum.openwrt.org/viewtopic.php?id=45219
But it could not reboot. I used openwrt to build the firmware. Using the same firmware and uboot, 16M flash board could reboot ,but 32M could not.

       I found the kernel hangs calling _machine_restart. That’s my debug log:
       Requesting system reboot
[ 5686.080000] Restarting system.
[ 5686.080000] Entering kmsg_dump
[ 5686.080000] Leaving kmsg_dump and entering machine_restart
[ 5686.090000] Entering ath79_restart and to ath79_device_reset_set
[ 5686.100000] Entering ath79_reset_wr(0x0000001c, 0x25044008) t:0x24044008 mask:0x01000000
[ 5686.100000] __raw_writel(0x25044008, 0xb806001c) ath79_reset_base:0xb8060000 reg:0x0000001c  hangs here
The RST_RESET register original value is 0x24044008, writing the RESET register to 0x25044008, just set FULL_CHIP_RESET bit to 1. In fact, that should reboot, but it hangs.
I also used a user space tool to set the register value to 0x25044008, that also hangs. But in uboot, I used md command to change the value to 0x25044008 it could restart.

I had this symptom on every soft reset. The flash chip is not reset while the SoC is. It still operates in 4 byte address mode while the SoC h/w uses 3 byte mode. It cannot load code from flash and thus appears to hang. I believe I submitted that patch too. Are you sure your 25p80.c file is correctly patched?

(Last edited by gerritb on 2 Sep 2013, 15:30)

gerritb wrote:

I had this symptom on every soft reset. The flash chip is not reset while the SoC is. It still operates in 4 byte address mode while the SoC h/w uses 3 byte mode. It cannot load code from flash and thus appears to hang. I believe I submitted that patch too. Are you sure your 25p80.c file is correctly patched?

Gerribt,

Thank you for your reply! 
That's the patch I applied to let 32M flash work:

.../ar71xx/patches-3.10/903-support-32Mflash.patch |   31 ++++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 target/linux/ar71xx/patches-3.10/903-support-32Mflash.patch

diff --git a/target/linux/ar71xx/patches-3.10/903-support-32Mflash.patch b/target/linux/ar71xx/patches-3.10/903-support-32Mflash.patch
new file mode 100644
index 0000000..042a833
--- /dev/null
+++ b/target/linux/ar71xx/patches-3.10/903-support-32Mflash.patch
@@ -0,0 +1,31 @@
+diff -Nur linux-3.10.2-backup/drivers/mtd/devices/m25p80.c linux-3.10.2/drivers/mtd/devices/m25p80.c
+--- linux-3.10.2-backup/drivers/mtd/devices/m25p80.c    2013-08-05 14:28:55.856974234 +0800
++++ linux-3.10.2/drivers/mtd/devices/m25p80.c    2013-08-05 14:46:06.029000612 +0800
+@@ -1137,6 +1137,11 @@
+     struct m25p    *flash = dev_get_drvdata(&spi->dev);
+     int        status;
+
++    const struct spi_device_id *id = spi_get_device_id(spi);
++    struct flash_info *info = (void *)id->driver_data;
++    // return 3-btye address mode so hardware FTLs don't get confused.
++    set_4byte(flash, info->jedec_id, 0);
++
+     /* Clean up MTD stuff. */
+     status = mtd_device_unregister(&flash->mtd);
+     if (status == 0) {
+diff -Nur linux-3.10.2-backup/drivers/spi/spi-ath79.c linux-3.10.2/drivers/spi/spi-ath79.c
+--- linux-3.10.2-backup/drivers/spi/spi-ath79.c    2013-08-05 14:28:58.492974302 +0800
++++ linux-3.10.2/drivers/spi/spi-ath79.c    2013-08-05 14:46:51.161001768 +0800
+@@ -335,9 +335,9 @@
+         return ret;
+
+     cdata = spi->controller_data;
+-    if (cdata->is_flash)
+-        sp->bitbang.txrx_bufs = ath79_spi_txrx_bufs;
+-    else
++    //if (cdata->is_flash)
++    //    sp->bitbang.txrx_bufs = ath79_spi_txrx_bufs;
++    //else
+         sp->bitbang.txrx_bufs = spi_bitbang_bufs;
+
+     return ret;
--
1.7.9.5
Is that patch has something wrong? I also found the mtd_device_unregister result is not 0. Is that normal? That's the debug info after mtd_device_unregister:
mtd_device_unregister failed with status:-16.

Hi Gerrit,

    Thank you for your great help. After modifying your patch, now I could reboot.
    Main cause: m25p80 remove doesn't return to 3byte address mode
    That's because when return to 3btye address to set_4byte(flash, info->jedec_id, 0) the second parameter info->jedec_id is not correct.
    And then it goes to Spansion style.
static inline int set_4byte(struct m25p *flash, u32 jedec_id, int enable) {
    switch (JEDEC_MFR(jedec_id)) {
    case CFI_MFR_MACRONIX:
    case 0xEF /* winbond */:
        flash->command[0] = enable ? OPCODE_EN4B : OPCODE_EX4B;
        return spi_write(flash->spi, flash->command, 1);
    default:
        /* Spansion style */
        flash->command[0] = OPCODE_BRWR;
        flash->command[1] = enable << 7;
        return spi_write(flash->spi, flash->command, 2);
    }
}
   After I get spi_device_id using jedec_probe(spi), the jedec_id is correct and successful return to 3byte address mode. Jedec_probe read the register value from Flash MX25L25635, so the value is right.
    --- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -1137,7 +1137,7 @@ static int m25p_remove(struct spi_device *spi)
    struct m25p    *flash = dev_get_drvdata(&spi->dev);
    int        status;

-    const struct spi_device_id *id = spi_get_device_id(spi);
+    const struct spi_device_id *id = jedec_probe(spi);
    struct flash_info *info = (void *)id->driver_data;
    // return 3-btye address mode so hardware FTLs don't get confused.
    set_4byte(flash, info->jedec_id, 0);
--
1.7.9.5

i have same issue here
however in my case issue can't solve with patch above
anybody has idea what's wrong here
below debug mode 4 log dump

root@OpenWrt:/# reboot
procd: signal_shutdown(51): Triggering reboot
procd: procd_shutdown(187): Shutting down system with event 1234567
procd: - shutdown -
procd: _rc(135): running /etc/rc.d/K* shutdown
procd: q_initd_run(71): start /etc/rc.d/K50dropbear shutdown
root@OpenWrt:/# procd: service_instance_update(62): Free instance dropbear::instance1
procd: q_initd_complete(101): stop /etc/rc.d/K50dropbear shutdown
procd: q_initd_run(71): start /etc/rc.d/K85odhcpd shutdown
procd: service_instance_update(62): Free instance odhcpd::instance1
procd: q_initd_complete(101): stop /etc/rc.d/K85odhcpd shutdown
procd: q_initd_run(71): start /etc/rc.d/K89log shutdown
procd: service_instance_update(62): Free instance log::instance1
procd: q_initd_complete(101): stop /etc/rc.d/K89log shutdown
procd: q_initd_run(71): start /etc/rc.d/K90network shutdown
procd: watch_notify_cb(107): Received ubus notify 'interface.down':

{"interface":"lan","up":false,"pending":false,"available":tr[   31.980000] br-lan: port 3(wlan1) entered disabled state
ue,"autostart":f[   31.980000] br-lan: port 2(wlan0) entered disabled state
alse,"proto":"st[   31.990000] br-lan: port 1(eth0.1) entered disabled state
atic","device":"br-lan","data":{}}
[   32.000000] device eth0.1 left promiscuous mode
[   32.000000] br-lan: port 1(eth0.1) entered disabled state
[   32.010000] IPv6: ADDRCONF(NETDEV_UP): eth0.1: link is not ready
procd: hotplug_handler_debug(404): {{"ACTION":"remove","DEVPATH"[   32.030000] device wlan0 left promiscuous mode
:"\/devices\/vir[   32.040000] br-lan: port 2(wlan0) entered disabled state
tual\/net\/eth0.1\/queues\/tx-0","SUBSYSTEM":"queues","SEQNUM":"[   32.050000] device wlan1 left promiscuous mode
433"}}
procd: h[   32.050000] br-lan: port 3(wlan1) entered disabled state
otplug_handler_debug(404): {{"ACTION":"remove","DEVPATH":"\/devices\/virtual\/net

\/eth0.1","SUBSYSTEM":"net","DEVTYPE":"vlan","INTERFACE":"eth0.1","IFINDEX":"6","SEQNUM":"434"}}
procd: rule_handle_command(355): Command: execprocd: rule_handle_command(357):  /sbin/hotplug-callprocd:

rule_handle_command(357):  netprocd: rule_handle_command(358):
procd: rule_handle_command(360): Message:procd: rule_handle_command(362):  ACTION=removeprocd: rule_handle_command(362): 

DEVPATH=/devices/virtual/net/eth0.1procd: rule_handle_command(362):  SUBSYSTEM=netprocd: rule_handle_command(362): 

DEVTYPE=vlanprocd: rule_handle_command(362):  INTERFACE=eth0.1procd: rule_handle_command(362):  IFINDEX=6procd:

rule_handle_command(362):  SEQNUM=434procd: rule_handle_command(363):
procd: queue_next(281): Launched hotplug exec instance, pid=1314
procd: hotplug_handler_debug(404): {{"ACTION":"remove","DEVPATH":"\/devices\/virtual\/net\/br-lan\/queues\/tx-

0","SUBSYSTEM":"queues","SEQNUM":"435"}}
procd: hotplug_handler_debug(404): {{"ACTION":"remove","DEVPATH":"\/devices\/virtual\/net\/br-

lan","SUBSYSTEM":"net","DEVTYPE":"bridge","INTERFACE":"br-lan","IFINDEX":"5","SEQNUM":"436"}}
procd: rule_handle_command(355): Command: execprocd: rule_handle_command(357):  /sbin/hotplug-callprocd:

rule_handle_command(357):  netprocd: rule_handle_command(358):
procd: rule_handle_command(360): Message:procd: rule_handle_command(362):  ACTION=removeprocd: rule_handle_command(362): 

DEVPATH=/devices/virtual/net/br-lanprocd: rule_handle_command(362):  SUBSYSTEM=netprocd: rule_handle_command(362): 

DEVTYPE=bridgeprocd: rule_handle_command(362):  INTERFACE=br-lanprocd: rule_handle_command(362):  IFINDEX=5procd:

rule_handle_command(362):  SEQNUM=436procd: rule_handle_command(363):
procd: watch_notify_cb(107): Received ubus notify 'interface.down':

{"interface":"loopback","up":false,"pending":false,"available":true,"autostart":false,"proto":"static","device":"lo","data

":{}}
procd: watch_notify_cb(107): Received ubus notify 'interface.down':

{"interface":"wan","up":false,"pending":false,"available":true,"autostart":false,"proto":"dhcp","device":"eth0.2","data":

{"leasetime":691200,"ntpserver":"207.46.232.182 192.43.244.18"}}
cat: can't open '/sys/devices/virtual/ieee80211/phy*/name': No such file or directory
sh: remove: unknown operand
sh: remove: unknown operand
procd: queue_proc_cb(286): Finished hotplug exec instance, pid=1314
procd: queue_next(281): Launched hotplug exec instance, pid=1336
[   32.400000] device eth0 left promiscuous mode
procd: hotplug_handler_debug(404): {{"ACTION":"r[   32.410000] eth0: link down
emove","DEVPATH":"\/devices\/virtual\/net\/eth0.2\/queues\/tx-0","SUBSYSTEM":"queues","SEQNUM":"437"}}
procd: hotplug_handler_debug(404): {{"ACTION":"remove","DEVPATH":"\/devices\/virtual\/net

\/eth0.2","SUBSYSTEM":"net","DEVTYPE":"vlan","INTERFACE":"eth0.2","IFINDEX":"7","SEQNUM":"438"}}
procd: rule_handle_command(355): Command: execprocd: rule_handle_command(357):  /sbin/hotplug-callprocd:

rule_handle_command(357):  netprocd: rule_handle_command(358):
procd: rule_handle_command(360): Message:procd: rule_handle_command(362):  ACTION=removeprocd: rule_handle_command(362): 

DEVPATH=/devices/virtual/net/eth0.2procd: rule_handle_command(362):  SUBSYSTEM=netprocd: rule_handle_command(362): 

DEVTYPE=vlanprocd: rule_handle_command(362):  INTERFACE=eth0.2procd: rule_handle_command(362):  IFINDEX=7procd:

rule_handle_command(362):  SEQNUM=438procd: rule_handle_command(363):
cat: can't open '/sys/devices/virtual/ieee80211/phy*/name': No such file or directory
sh: remove: unknown operand
sh: remove: unknown operand
procd: queue_proc_cb(286): Finished hotplug exec instance, pid=1336
procd: queue_next(281): Launched hotplug exec instance, pid=1362
cat: can't open '/sys/devices/virtual/ieee80211/phy*/name': No such file or directory
sh: remove: unknown operand
sh: remove: unknown operand
procd: queue_proc_cb(286): Finished hotplug exec instance, pid=1362
procd: q_initd_complete(101): stop /etc/rc.d/K90network shutdown
procd: q_initd_run(71): start /etc/rc.d/K98boot shutdown
procd: q_initd_complete(101): stop /etc/rc.d/K98boot shutdown
procd: q_initd_run(71): start /etc/rc.d/K99umount shutdown
procd: q_initd_complete(101): stop /etc/rc.d/K99umount shutdown
procd: procd_state_next(172): Change state 5 -> 6
procd: - SIGTERM processes -
procd:[   36.210000] Unhandled kernel unaligned access[#1]:
[   36.210000] CPU: 0 PID: 1384 Comm: procd Not tainted 3.14.30 #32
[   36.210000] task: 87bf44c8 ti: 87bea000 task.ti: 87bea000
[   36.210000] $ 0   : 00000000 00000001 ffffff71 00000001
[   36.210000] $ 4   : 8034bb40 87bebb88 00000087 70000000
[   36.210000] $ 8   : 00000001 0e000000 87854481 00000200
[   36.210000] $12   : 10000000 20000000 40000000 02000000
[   36.210000] $16   : 87913210 878c4900 803502ec 803b0000
[   36.210000] $20   : 803108bc 80340e1c 803b0000 00000000
[   36.210000] $24   : 04000000 08000000
[   36.210000] $28   : 87bea000 87bebc00 7fe577d8 801b1510
[   36.210000] Hi    : 0000028f
[   36.210000] Lo    : 00000001
[   36.210000] epc   : 801b1510 m25p_remove+0x2c/0x1a4
[   36.210000]     Not tainted
[   36.210000] ra    : 801b1510 m25p_remove+0x2c/0x1a4
[   36.210000] Status: 1100dc03 KERNEL EXL IE
[   36.210000] Cause : 00800010
[   36.210000] BadVA : ffffff91
[   36.210000] PrId  : 0001974c (MIPS 74Kc)
[   36.210000] Modules linked in: ath9k ath9k_common pppoe ppp_async iptable_nat ath9k_hw ath pppox ppp_generic

nf_nat_ipv4 nf_conntrack_ipv6 nf_conntrack_ipv4 mac80211 ipt_MASQUERADE cfg80211 xt_time xt_tcpudp xt_state xt_nat

xt_multiport xt_mark xt_mac xt_limit xt_id xt_conntrack xt_comment xt_TCPMSS xt_REDIRECT xt_LOG xt_CT slhc nf_nat_irc

nf_nat_ftp nf_nat nf_defrag_ipv6 nf_defrag_ipv4 nf_conntrack_rtcache nf_conntrack_irc nf_conntrack_ftp nf_conntrack

iptable_raw iptable_mangle iptable_filter ipt_REJECT ip_tables crc_ccitt compat ip6t_REJECT ip6table_raw ip6table_mangle

ip6table_filter ip6_tables x_tables ipv6 arc4 crypto_blkcipher ehci_platform ehci_hcd gpio_button_hotplug usbcore nls_base

usb_common
[   36.210000] Process procd (pid: 1384, threadinfo=87bea000, task=87bf44c8, tls=77693440)
[   36.210000] Stack : 803108bc 80340e1c 87915630 80000000 87bebc78 87bebc40 803108bc 80340e1c
          803b0000 00000000 7fe577d8 8019c530 00000000 8019cbc0 879155a0 879155e8
          00000000 87bebc44 87bebc44 87915630 87911ee8 87915630 87911ee8 878c4900
          8034bb9c 803502ec 803b0000 800dee5c 803502ec 8012c670 00000000 878c4900
          8034bb9c 803502ec 803b0000 8008d8fc 80340e1c 8019fd0c 803108bc 80340e1c
          ...
[   36.210000] Call Trace:
[   36.210000] [<801b1510>] m25p_remove+0x2c/0x1a4
[   36.210000] [<8008d8fc>] __device_release_driver+0x6c/0xd0
[   36.210000] [<80113354>] device_release_driver+0x28/0x40
[   36.210000] [<800edebc>] bus_remove_device+0xec/0x120
[   36.210000] [<80112aec>] device_del+0x110/0x170
[   36.210000] [<801139e4>] device_unregister+0x14/0x28
[   36.210000] [<800afaac>] __unregister+0x18/0x30
[   36.210000] [<80112cb4>] device_for_each_child+0x84/0x94
[   36.210000] [<80255dd0>] spi_unregister_master+0x8c/0xa4
[   36.210000] [<80254948>] spi_bitbang_stop+0x10/0x20
[   36.210000] [<800ca0cc>] ath79_spi_remove+0x20/0x58
[   36.210000] [<8011386c>] device_shutdown+0x100/0x158
[   36.210000] [<8019c104>] kernel_restart+0x14/0x6c
[   36.210000] [<80079504>] SyS_reboot+0xf8/0x1d4
[   36.210000] [<8006283c>] handle_sys+0x11c/0x140
[   36.210000]
[   36.210000]
Code: 02202021  0c0626c5  00408021 <8c420020> 240300c2  94420000  10430022  240300ef  10430020
[   36.500000] ---[ end trace 3007a3e89cf3aab2 ]---

if i did "reboot -f" then segmentation fault
i'm using trunk (chaos calmer)
something really bad happening

root@OpenWrt:/# reboot -f
[  207.760000] Unhandled kernel unaligned access[#1]:
[  207.760000] CPU: 0 PID: 1270 Comm: reboot Not tainted 3.14.30 #32
[  207.760000] task: 86ef2b08 ti: 86ed2000 task.ti: 86ed2000
[  207.760000] $ 0   : 00000000 00000001 ffffff71 00000001
[  207.760000] $ 4   : 8034bb40 86ed3b88 00000087 70000000
[  207.760000] $ 8   : 00000001 0e000000 87854481 00000200
[  207.760000] $12   : 10000000 20000000 40000000 02000000
[  207.760000] $16   : 87913210 878c4900 803502ec 803b0000
[  207.760000] $20   : 803108bc 80340e1c 803b0000 00000000
[  207.760000] $24   : 04000000 08000000
[  207.760000] $28   : 86ed2000 86ed3c00 7fde4c58 801b1510
[  207.760000] Hi    : 0000028f
[  207.760000] Lo    : 00000001
[  207.760000] epc   : 801b1510 m25p_remove+0x2c/0x1a4
[  207.760000]     Not tainted
[  207.760000] ra    : 801b1510 m25p_remove+0x2c/0x1a4
[  207.760000] Status: 1100dc03 KERNEL EXL IE
[  207.760000] Cause : 00800010
[  207.760000] BadVA : ffffff91
[  207.760000] PrId  : 0001974c (MIPS 74Kc)
[  207.760000] Modules linked in: ath9k ath9k_common pppoe ppp_async iptable_nat ath9k_hw ath pppox ppp_generic nf_nat_ipv4 nf_conntrack_ipv6 nf_conntrack_ipv4 mac80211 ipt_MASQUERADE cfg80211 xt_time xt_tcpudp xt_state xt_nat xt_multiport xt_mark xt_mac xt_limit xt_id xt_conntrack xt_comment xt_TCPMSS xt_REDIRECT xt_LOG xt_CT slhc nf_nat_irc nf_nat_ftp nf_nat nf_defrag_ipv6 nf_defrag_ipv4 nf_conntrack_rtcache nf_conntrack_irc nf_conntrack_ftp nf_conntrack iptable_raw iptable_mangle iptable_filter ipt_REJECT ip_tables crc_ccitt compat ip6t_REJECT ip6table_raw ip6table_mangle ip6table_filter ip6_tables x_tables ipv6 arc4 crypto_blkcipher ehci_platform ehci_hcd gpio_button_hotplug usbcore nls_base usb_common
[  207.760000] Process reboot (pid: 1270, threadinfo=86ed2000, task=86ef2b08, tls=77fc5440)
[  207.760000] Stack : 803108bc 80340e1c 87915630 80000000 86ed3c78 86ed3c40 803108bc 80340e1c
          803b0000 00000000 7fde4c58 8019c530 00000000 8019cbc0 879155a0 879155e8
          00000000 86ed3c44 86ed3c44 87915630 87911ee8 87915630 87911ee8 878c4900
          8034bb9c 803502ec 803b0000 800dee5c 803502ec 8012c670 00000000 878c4900
          8034bb9c 803502ec 803b0000 8008d8fc 80340e1c 8019fd0c 803108bc 80340e1c
          ...
[  207.760000] Call Trace:
[  207.760000] [<801b1510>] m25p_remove+0x2c/0x1a4
[  207.760000] [<8008d8fc>] __device_release_driver+0x6c/0xd0
[  207.760000] [<80113354>] device_release_driver+0x28/0x40
[  207.760000] [<800edebc>] bus_remove_device+0xec/0x120
[  207.760000] [<80112aec>] device_del+0x110/0x170
[  207.760000] [<801139e4>] device_unregister+0x14/0x28
[  207.760000] [<800afaac>] __unregister+0x18/0x30
[  207.760000] [<80112cb4>] device_for_each_child+0x84/0x94
[  207.760000] [<80255dd0>] spi_unregister_master+0x8c/0xa4
[  207.760000] [<80254948>] spi_bitbang_stop+0x10/0x20
[  207.760000] [<800ca0cc>] ath79_spi_remove+0x20/0x58
[  207.760000] [<8011386c>] device_shutdown+0x100/0x158
[  207.760000] [<8019c104>] kernel_restart+0x14/0x6c
[  207.760000] [<80079504>] SyS_reboot+0xf8/0x1d4
[  207.760000] [<8006283c>] handle_sys+0x11c/0x140
[  207.760000]
[  207.760000]
Code: 02202021  0c0626c5  00408021 <8c420020> 240300c2  94420000  10430022  240300ef  10430020
[  208.050000] ---[ end trace 676e97930dd32d2d ]---
Segmentation fault

(Last edited by dony71 on 13 Feb 2015, 00:18)

no problem to apply this patch on barrier breaker
however on current trunk chaos calmer, this patch doesn't work
reboot will hang the device

Hi,  would you please tell me how to use kmsg_dump() function to show the message in kernel ????
I eally need this.  ( contact me with banglang.huang@foxmail.com)

(Last edited by banglang.huang on 26 Sep 2016, 09:39)

The discussion might have continued from here.