Welcome! Log In Create A New Profile

Advanced

when writting to mtd0, Permission denied, unwritable?

Posted by Ben 
My device is Pogo mobile. When I tried to upgrade its uboot, I got this error message.

Can't open /dev/mtd0: Permission denied

I read this post but it didn't help. https://forum.doozan.com/read.php?2,31358

Here are the related settings. Can anybody help me?

root@PogoMob:~# uname -a
Linux PogoMob 3.14.0-kirkwood-tld-1 #1 PREEMPT Tue Apr 1 22:54:58 PDT 2014 armv5tel GNU/Linux
 
cat /proc/cmdline
console=ttyS0,115200 root=/dev/mmcblk0p1 rootdelay=10 mtdparts=mtdparts=orion_nand:2M(u-boot),3M(uImage),3M(uImage2),8M(failsafe),112(root)

 cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00100000 00020000 "u-boot"
mtd1: 00400000 00020000 "uImage"
mtd2: 07b00000 00020000 "root"

root@PogoMob:~# dmesg | grep -i mtd
[    0.000000] Kernel command line: console=ttyS0,115200 root=/dev/mmcblk0p1 rootdelay=10 mtdparts=mtdparts=orion_nand:2M(u-boot),3M(uImage),3M(uImage2),8M(failsafe),112(root)
[    9.792464] mtd: partition size too small (70)
[    9.805155] Creating 3 MTD partitions on "orion_nand":

 dmesg | grep -i mtd
[    0.000000] Kernel command line: console=ttyS0,115200 root=/dev/mmcblk0p1 rootdelay=10 mtdparts=mtdparts=orion_nand:2M(u-boot),3M(uImage),3M(uImage2),8M(failsafe),112(root)
[    9.792464] mtd: partition size too small (70)
[    9.805155] Creating 3 MTD partitions on "orion_nand":
root@PogoMob:~# dmesg | grep -i 0x000
[    8.073712] pci 0000:00:00.0: reg 0x18: [mem 0x00000000-0x07ffffff]
[    9.693105] Bad eraseblock 13 at 0x0000001a0000
[    9.711792] Bad eraseblock 190 at 0x0000017c0000
[    9.738856] Bad eraseblock 470 at 0x000003ac0000
[    9.767051] Bad eraseblock 764 at 0x000005f80000
[    9.810293] 0x000000000000-0x000000100000 : "u-boot"
[    9.815784] 0x000000100000-0x000000500000 : "uImage"
[    9.821117] 0x000000500000-0x000008000000 : "root"

 cat /etc/fw_env.config
/dev/mtd0 0xc0000 0x20000 0x20000

 ls -l /dev/mtd*
crw------- 1 root root 90, 0 Dec 31 16:00 /dev/mtd0
crw------- 1 root root 90, 1 Dec 31 16:00 /dev/mtd0ro
crw------- 1 root root 90, 2 Dec 31 16:00 /dev/mtd1
crw------- 1 root root 90, 3 Dec 31 16:00 /dev/mtd1ro
crw------- 1 root root 90, 4 Dec 31 16:00 /dev/mtd2
crw------- 1 root root 90, 5 Dec 31 16:00 /dev/mtd2ro

 cat /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/root      /               ext3    noatime,errors=remount-ro 0 1
tmpfs          /tmp            tmpfs   defaults          0       0


root@PogoMob:~# fw_printenv
arcNumber=2097
baudrate=115200
bootcmd=usb start; run force_rescue_bootcmd; run ubifs_bootcmd; run usb_bootcmd; usb stop; run mmc_bootcmd
bootdelay=3
console=ttyS0,115200
ethact=egiga0
ethaddr=02:50:43:3e:e9:18
force_rescue=0
force_rescue_bootcmd=if test $force_rescue -eq 1 || ext2load usb 0:1 0x1700000 /rescueme 1 || fatload usb 0:1 0x1700000 /rescueme.txt 1; then run rescue_bootcmd; fi
if_netconsole=ping $serverip
ipaddr=192.168.2.35
ippaddr=192.168.2.22
led_error=orange blinking
led_exit=green off
led_init=green blinking
mainlineLinux=yes
mmc_boot=mw 0x800000 0 1; ext2load mmc 0:1 0x00800000 /boot/uImage; if ext2load mmc 0:1 0x01100000 /boot/uInitrd; then bootm 0x800000 0x1100000; else bootm 0x800000; fi
mmc_bootcmd=mmc init; mmc init; run mmc_set_bootargs; run mmc_boot
mmc_root=/dev/mmcblk0p1
mmc_set_bootargs=setenv bootargs console=$console root=$mmc_root rootdelay=$usb_rootdelay
mtdids=nand0=orion_nand
mtdparts=mtdparts=orion_nand:2M(u-boot),3M(uImage),3M(uImage2),8M(failsafe),112(root)
partition=nand0,2
pogo_bootcmd=if fsload uboot-original-mtd0.kwb; then go 0x800200; fi
preboot=run if_netconsole start_netconsole
rescue_bootcmd=if test $rescue_installed -eq 1; then run rescue_set_bootargs; nand read.e 0x800000 0x100000 0x400000; bootm 0x800000; else run pogo_bootcmd; fi
rescue_installed=0
rescue_set_bootargs=setenv bootargs console=$console ubi.mtd=2 root=ubi0:rootfs ro rootfstype=ubifs $mtdparts $rescue_custom_params
serverip=192.168.2.140
start_netconsole=setenv ncip $serverip; setenv bootdelay 10; setenv stdin nc; setenv stdout nc; setenv stderr nc; version;
stderr=serial
stdin=serial
stdout=serial
ubifs_bootcmd=run ubifs_set_bootargs; if ubi part data && ubifsmount rootfs && ubifsload 0x800000 /boot/uImage && ubifsload 0x1100000 /boot/uInitrd; then bootm 0x800000 0x1100000; fi
ubifs_mtd=3
ubifs_set_bootargs=setenv bootargs console=$console ubi.mtd=$ubifs_mtd root=ubi0:rootfs rootfstype=ubifs $mtdparts $ubifs_custom_params
usb_boot=mw 0x800000 0 1; ext2load usb $usb_device 0x800000 /boot/uImage; if ext2load usb $usb_device 0x1100000 /boot/uInitrd; then bootm 0x800000 0x1100000; else bootm 0x800000; fi
usb_bootcmd=run usb_init; run usb_set_bootargs; run usb_boot
usb_device=0:1
usb_init=run usb_scan
usb_root=/dev/sda1
usb_rootdelay=10
usb_rootfstype=ext2
usb_scan=usb_scan_done=0;for scan in $usb_scan_list; do run usb_scan_$scan; if test $usb_scan_done -eq 0 && ext2load usb $usb 0x800000 /boot/uImage 1; then usb_scan_done=1; echo "Found bootable drive on usb $usb"; setenv usb_device $usb; setenv usb_root /dev/$dev; fi; done
usb_scan_1=usb=0:1 dev=sda1
usb_scan_2=usb=1:1 dev=sdb1
usb_scan_3=usb=2:1 dev=sdc1
usb_scan_4=usb=3:1 dev=sdd1
usb_scan_list=1 2 3 4
usb_set_bootargs=setenv bootargs console=$console root=$usb_root rootdelay=$usb_rootdelay rootfstype=$usb_rootfstype $mtdparts $usb_custom_params

Re: when writting to mtd0, Permission denied, unwritable?
March 11, 2018 12:22AM
Ben,

You did not say which version of u-boot that you have installed on this box. But by the look of the envs, it looks like an older version of my released u-boot here.

This env is wrong:

mtdparts=mtdparts=orion_nand:2M(u-boot),3M(uImage),3M(uImage2),8M(failsafe),112(root)

There is a typo
mtdparts=mtdparts=orion_nand:2M(u-boot),3M(uImage),3M(uImage2),8M(failsafe),112M(root)

Please post output of

cat /etc/fw_env.config
fw_printenv

Do you have serial console connected? Even if not, it is still possible to to fix the error so you can install new u-boot and its env image if u-boot version is new enough.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Hi bodhi,

I can't believe I missed that typo! After fixing that, I could get uboot updated using your release. HOWEVER, my device couldn't boot after I followed your instructions to upgrade the kernel (this post, https://forum.doozan.com/read.php?2,12096).

I can connect the console using serial so here's the booting error messages and my printenv

U-Boot 2017.07-tld-1 (Sep 05 2017 - 00:34:01 -0700)
Pogoplug V4

SoC:   Kirkwood 88F6192_A1
DRAM:  128 MiB
WARNING: Caches not enabled
NAND:  128 MiB
MMC:   MVEBU_MMC: 0
In:    serial
Out:   serial
Err:   serial
Net:   egiga0
Hit any key to stop autoboot:  0
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found

Reset IDE: ide_preinit failed

MMC rescan: current device # 0 initialized OK
## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0
loading envs from usb 0 ...
** Bad device usb 0 **

no IDE devices available

Partition Map for MMC device 0  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     63              7213122         0dd70bad-01     83
  2     7213185         530145          0dd70bad-02     82
loading envs from mmc 0 ...
87 bytes read in 21 ms (3.9 KiB/s)
importing envs ...
running scan_disk ...
Scan device usb
device usb 0:1
** Bad device usb 0 **
device usb 1:1
** Bad device usb 1 **
device usb 2:1
** Bad device usb 2 **
device usb 3:1
** Bad device usb 3 **
Scan device ide

Reset IDE: ide_preinit failed
device ide 0:1
** Bad device ide 0 **
device ide 1:1
** Bad device ide 1 **
device ide 2:1
** Bad device ide 2 **
device ide 3:1
** Bad device ide 3 **
Scan device mmc

MMC rescan: current device # 0 initialized OK
device mmc 0:1
1 bytes read in 17 ms (0 Bytes/s)
Found bootable drive on mmc 0
** Bad device usb 0 **
** Bad device usb 0 **
** Bad device usb 0 **
Wrong Image Format for bootm command
ERROR: can't get kernel image!
Pogov4>


This is the my printenv

Pogov4> printenv
arcNumber=3960
bootargs=console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 mtdparts=orion_nand:2M(u-boot),3M(uImage),3M(uImage2),8M(failsafe),112M(root)
bootcmd=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec
bootcmd_exec=run load_uimage; if run load_initrd; then if run load_dtb; then bootm $load_uimage_addr $load_initrd_addr $load_dtb_addr; else bootm $load_uimage_addr $load_initrd_addr; fi; else if run load_dtb; then bootm $load_uimage_addr - $load_dtb_addr; else bootm $load_uimage_addr; fi; fi
bootcmd_uenv=run uenv_load; if test $uenv_loaded -eq 1; then run uenv_import; fi
bootdelay=10
bootdev=mmc
device=0:1
devices=usb ide mmc
disks=0 1 2 3
dtb_file=/boot/dts/kirkwood-pogo_e02.dtb
ethact=egiga0
ethaddr=02:50:43:3f:e9:18
fileaddr=800000
filesize=1
if_netconsole=ping $serverip
init_ide=ide reset
init_mmc=mmc rescan
init_usb=usb start
ipaddr=192.168.0.231
led_error=orange blinking
led_exit=green off
led_init=green blinking
load_dtb=ext2load usb 0:1 0x1c00000 /boot/dts/kirkwood-pogoplug_v4.dtb
load_dtb_addr=0x1c00000
load_initrd=ext2load usb 0:1 0x1100000 /boot/uInitrd
load_initrd_addr=0x1100000
load_uimage=ext2load usb 0:1 0x800000 /boot/uImage
load_uimage_addr=0x800000
machid=f78
mainlineLinux=yes
mtdids=nand0=orion_nand
mtdparts=mtdparts=orion_nand:2M(u-boot),3M(uImage),3M(uImage2),8M(failsafe),112M(root)
partition=nand0,2
preboot_nc=run if_netconsole start_netconsole
scan_disk=echo running scan_disk ...; scan_done=0; setenv scan_usb "usb start";  setenv scan_ide "ide reset";  setenv scan_mmc "mmc rescan"; for dev in $devices; do if test $scan_done -eq 0; then echo Scan device $dev; run scan_$dev; for disknum in $disks; do if test $scan_done -eq 0; then echo device $dev $disknum:1; if load $dev $disknum:1 $load_uimage_addr /boot/uImage 1; then scan_done=1; echo Found bootable drive on $dev $disknum; setenv device $disknum:1; setenv bootdev $dev; fi; fi; done; fi; done
scan_ide=ide reset
scan_mmc=mmc rescan
scan_usb=usb start
serverip=192.168.0.220
set_bootargs=setenv bootargs console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 $mtdparts $custom_params
start_netconsole=setenv ncip $serverip; setenv bootdelay 10; setenv stdin nc; setenv stdout nc; setenv stderr nc; version;
stderr=serial
stdin=serial
stdout=serial
uenv_addr=0x810000
uenv_import=echo importing envs ...; env import -t $uenv_addr $filesize
uenv_init_devices=setenv init_usb "usb start";  setenv init_ide "ide reset";  setenv init_mmc "mmc rescan"; for devtype in $devices; do run init_$devtype; done;
uenv_load=run uenv_init_devices; setenv uenv_loaded 0; for devtype in $devices;  do for disknum in 0; do run uenv_read_disk; done; done;
uenv_loaded=1
uenv_read=echo loading envs from $devtype $disknum ...; if load $devtype $disknum:1 $uenv_addr /boot/uEnv.txt; then setenv uenv_loaded 1; fi
uenv_read_disk=if test $devtype -eq mmc; then if $devtype part; then run uenv_read;  fi; else if $devtype part $disknum; then run uenv_read; fi;  fi
usb_boot=run load_dtb; run load_uimage; if run load_initrd; then bootm 0x800000 0x1100000 0x1c00000; else bootm 0x800000 - 0x1c00000; fi
usb_ready_retry=15

Environment size: 3234/131068 bytes
Pogov4>

Re: when writting to mtd0, Permission denied, unwritable?
March 12, 2018 02:46PM
Ben,


-------------------------------------------------------
> Hi bodhi,
>
> I can't believe I missed that typo! After fixing
> that, I could get uboot updated using your
> release. HOWEVER, my device couldn't boot after I
> followed your instructions to upgrade the kernel
> (this post,
> https://forum.doozan.com/read.php?2,12096).
>
> I can connect the console using serial so here's
> the booting error messages and my printenv
>
>

> U-Boot 2017.07-tld-1 (Sep 05 2017 - 00:34:01
> -0700)
> Pogoplug V4
>
> SoC: Kirkwood 88F6192_A1
> DRAM: 128 MiB
> WARNING: Caches not enabled
> NAND: 128 MiB
> MMC: MVEBU_MMC: 0
> In: serial
> Out: serial
> Err: serial
> Net: egiga0
> Hit any key to stop autoboot: 0
> starting USB...
> USB0: USB EHCI 1.00
> scanning bus 0 for devices... 1 USB Device(s)
> found
> scanning usb for storage devices... 0
> Storage Device(s) found
>
> Reset IDE: ide_preinit failed
>
> MMC rescan: current device # 0 initialized OK
> ## Unknown partition table type 0
>
> ## Unknown partition table type 0
>
> ## Unknown partition table type 0
>
> ## Unknown partition table type 0
>
> ## Unknown partition table type 0
>
> ## Unknown partition table type 0
>
> ## Unknown partition table type 0
> loading envs from usb 0 ...
> ** Bad device usb 0 **
>
> no IDE devices available
>
> Partition Map for MMC device 0 -- Partition
> Type: DOS
>
> Part Start Sector Num Sectors UUID
> Type
> 1 63 7213122
> 0dd70bad-01 83
> 2 7213185 530145
> 0dd70bad-02 82

To avoid booting problem, you should have 1 partition for the rootfs. That was mentioned in the instruction. Once it booted, set up a swap file instead of swap partition.

> loading envs from mmc 0 ...
> 87 bytes read in 21 ms (3.9 KiB/s)
> importing envs ...

What envs were defined in the /boot/uEnv.txt?

> running scan_disk ...
> Scan device usb
> device usb 0:1
> ** Bad device usb 0 **
> device usb 1:1
> ** Bad device usb 1 **
> device usb 2:1
> ** Bad device usb 2 **
> device usb 3:1
> ** Bad device usb 3 **
> Scan device ide
>
> Reset IDE: ide_preinit failed
> device ide 0:1
> ** Bad device ide 0 **
> device ide 1:1
> ** Bad device ide 1 **
> device ide 2:1
> ** Bad device ide 2 **
> device ide 3:1
> ** Bad device ide 3 **
> Scan device mmc
>
> MMC rescan: current device # 0 initialized OK
> device mmc 0:1
> 1 bytes read in 17 ms (0 Bytes/s)
> Found bootable drive on mmc 0
> ** Bad device usb 0 **
> ** Bad device usb 0 **
> ** Bad device usb 0 **
> Wrong Image Format for bootm command
> ERROR: can't get kernel image!
> Pogov4>
>

>
> This is the my printenv
>
>
> Pogov4> printenv
> arcNumber=3960
> bootargs=console=ttyS0,115200 root=LABEL=rootfs
> rootdelay=10
> mtdparts=orion_nand:2M(u-boot),3M(uImage),3M(uImage2),8M(failsafe),112M(root)
> bootcmd=run bootcmd_uenv; run scan_disk; run
> set_bootargs; run bootcmd_exec
> bootcmd_exec=run load_uimage; if run load_initrd;
> then if run load_dtb; then bootm $load_uimage_addr
> $load_initrd_addr $load_dtb_addr; else bootm
> $load_uimage_addr $load_initrd_addr; fi; else if
> run load_dtb; then bootm $load_uimage_addr -
> $load_dtb_addr; else bootm $load_uimage_addr; fi;
> fi
> bootcmd_uenv=run uenv_load; if test $uenv_loaded
> -eq 1; then run uenv_import; fi
> bootdelay=10
> bootdev=mmc
> device=0:1
> devices=usb ide mmc

Try changing the devices to mmc first:

setenv devices ‘mmc usb ide’

> disks=0 1 2 3
> dtb_file=/boot/dts/kirkwood-pogo_e02.dtb

The DTB is wrong, should be Pogo V4.

> ethact=egiga0
> ethaddr=02:50:43:3f:e9:18
> fileaddr=800000
> filesize=1
> if_netconsole=ping $serverip
> init_ide=ide reset
> init_mmc=mmc rescan
> init_usb=usb start
> ipaddr=192.168.0.231
> led_error=orange blinking
> led_exit=green off
> led_init=green blinking
> load_dtb=ext2load usb 0:1 0x1c00000
> /boot/dts/kirkwood-pogoplug_v4.dtb
> load_dtb_addr=0x1c00000
> load_initrd=ext2load usb 0:1 0x1100000
> /boot/uInitrd
> load_initrd_addr=0x1100000
> load_uimage=ext2load usb 0:1 0x800000
> /boot/uImage
> load_uimage_addr=0x800000
> machid=f78
> mainlineLinux=yes
> mtdids=nand0=orion_nand
> mtdparts=mtdparts=orion_nand:2M(u-boot),3M(uImage),3M(uImage2),8M(failsafe),112M(root)
> partition=nand0,2
> preboot_nc=run if_netconsole start_netconsole
> scan_disk=echo running scan_disk ...; scan_done=0;
> setenv scan_usb "usb start"; setenv scan_ide "ide
> reset"; setenv scan_mmc "mmc rescan"; for dev in
> $devices; do if test $scan_done -eq 0; then echo
> Scan device $dev; run scan_$dev; for disknum in
> $disks; do if test $scan_done -eq 0; then echo
> device $dev $disknum:1; if load $dev $disknum:1
> $load_uimage_addr /boot/uImage 1; then
> scan_done=1; echo Found bootable drive on $dev
> $disknum; setenv device $disknum:1; setenv bootdev
> $dev; fi; fi; done; fi; done
> scan_ide=ide reset
> scan_mmc=mmc rescan
> scan_usb=usb start
> serverip=192.168.0.220
> set_bootargs=setenv bootargs console=ttyS0,115200
> root=LABEL=rootfs rootdelay=10 $mtdparts
> $custom_params
> start_netconsole=setenv ncip $serverip; setenv
> bootdelay 10; setenv stdin nc; setenv stdout nc;
> setenv stderr nc; version;
> stderr=serial
> stdin=serial
> stdout=serial
> uenv_addr=0x810000
> uenv_import=echo importing envs ...; env import -t
> $uenv_addr $filesize
> uenv_init_devices=setenv init_usb "usb start";
> setenv init_ide "ide reset"; setenv init_mmc "mmc
> rescan"; for devtype in $devices; do run
> init_$devtype; done;
> uenv_load=run uenv_init_devices; setenv
> uenv_loaded 0; for devtype in $devices; do for
> disknum in 0; do run uenv_read_disk; done; done;
> uenv_loaded=1
> uenv_read=echo loading envs from $devtype $disknum
> ...; if load $devtype $disknum:1 $uenv_addr
> /boot/uEnv.txt; then setenv uenv_loaded 1; fi
> uenv_read_disk=if test $devtype -eq mmc; then if
> $devtype part; then run uenv_read; fi; else if
> $devtype part $disknum; then run uenv_read; fi;
> fi
> usb_boot=run load_dtb; run load_uimage; if run
> load_initrd; then bootm 0x800000 0x1100000
> 0x1c00000; else bootm 0x800000 - 0x1c00000; fi
> usb_ready_retry=15
>
> Environment size: 3234/131068 bytes
> Pogov4>
>

Lastly, make sure your mmc rootfs partition is labeled rootfs.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
bodhi,

The problem is now that I can't get it to boot. If we can figure out how to boot it, I think I can easily fix those errors. I tried
setenv devices ‘mmc usb ide’
but it didn't work. In my understanding of the booting message, there's an error preventing the device from locating the SD card. Can you find where to change the setting to let it see the SD card?

My root is labeled as rootfs but I neglected the swap partition. BTW, the device could boot up after loading your new uBoot but failed when upgrading to the new kernel. I must have done something wrong when following that instructions....

Thanks a lot!
Bin
I guess I should fix the SD card by changing it to be a single partition, and then it will probably work, right?
I changed the SD partition to a single one. but still saw the similar error message as follows.

U-Boot 2017.07-tld-1 (Sep 05 2017 - 00:34:01 -0700)
Pogoplug V4

SoC:   Kirkwood 88F6192_A1
DRAM:  128 MiB
WARNING: Caches not enabled
NAND:  128 MiB
MMC:   MVEBU_MMC: 0
In:    serial
Out:   serial
Err:   serial
Net:   egiga0
Hit any key to stop autoboot:  0
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found

Reset IDE: ide_preinit failed

MMC rescan: current device # 0 initialized OK
## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0
loading envs from usb 0 ...
** Bad device usb 0 **

no IDE devices available

Partition Map for MMC device 0  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     63              7743425         3ba23039-01     83
loading envs from mmc 0 ...
87 bytes read in 26 ms (2.9 KiB/s)
importing envs ...
running scan_disk ...
Scan device usb
device usb 0:1
** Bad device usb 0 **
device usb 1:1
** Bad device usb 1 **
device usb 2:1
** Bad device usb 2 **
device usb 3:1
** Bad device usb 3 **
Scan device ide

Reset IDE: ide_preinit failed
device ide 0:1
** Bad device ide 0 **
device ide 1:1
** Bad device ide 1 **
device ide 2:1
** Bad device ide 2 **
device ide 3:1
** Bad device ide 3 **
Scan device mmc

MMC rescan: current device # 0 initialized OK
device mmc 0:1
1 bytes read in 16 ms (0 Bytes/s)
Found bootable drive on mmc 0
** Bad device usb 0 **
** Bad device usb 0 **
** Bad device usb 0 **
Wrong Image Format for bootm command
ERROR: can't get kernel image!

my /boot/uEnv.txt is just one line...

mtdparts=mtdparts=orion_nand:2M(u-boot),3M(uImage),3M(uImage2),8M(failsafe),112M(root)
Re: when writting to mtd0, Permission denied, unwritable?
March 12, 2018 06:38PM
Ben,

Yes, the rootfs is most like the reason. But the DTB file name is wrong, too. Here is what you need to do.


1. Recreate the rootfs, and make sure you follow the instruction closely.
2. Attach the rootfs to the box, power up.
3. Interrupt serial console at count down, and execute

setenv devices mmc
setenv dtb_file ‘/boot/dts/kirkwood-pogoplug_v4.dtb’
printenv
boot

And then post the entire serial console log here.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 1 time(s). Last edit at 03/12/2018 06:42PM by bodhi.
bodhi,

If I can't boot, how can I recreate the rootfs? Recreating it needs to be done on the device, right? Can we do that on other device/linux like across compiling? I'm not good at the embedded linux OS, please advise. Thanks!
bodhi,

Please ignore my last question. I'm working on the rootfs and will get back to here soon.
Hi bodhi,

I used a new SD card, formatted it to a single ext3 partition with "rootfs", and then closely follow the instructions about creating roofts (the section of "Updated 24 Jul 2017:" ) at the post https://forum.doozan.com/read.php?2,12096, where I used the Debian-4.12.1-kirkwood-tld-1-rootfs-bodhi.tar.bz2 to recreate the rootfs.

And then I attached the SD card to my pogoplug mobile, ran the commands as you instructed. That is "setenv devices mmc", "setenv dtb_file ‘/boot/dts/kirkwood-pogoplug_v4.dtb’ ", and "printenv" and then "boot"

I got this error message
Pogov4> boot

MMC rescan: current device # 0 initialized OK

Partition Map for MMC device 0  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     2048            7923712         00000000-01     83
loading envs from mmc 0 ...
87 bytes read in 18 ms (3.9 KiB/s)
importing envs ...
running scan_disk ...
Scan device mmc

MMC rescan: current device # 0 initialized OK
device mmc 0:1
1 bytes read in 16 ms (0 Bytes/s)
Found bootable drive on mmc 0
** Bad device usb 0 **
** Bad device usb 0 **
** Bad device usb 0 **
Wrong Image Format for bootm command
ERROR: can't get kernel image!

BTW, I created the rootfs using a pogoplug E02. I skipped step 4 (Create uImage with embedded DTB) when creating the rootfs because I had installed your latest UBoot on the pogoplug mobile.
Re: when writting to mtd0, Permission denied, unwritable?
March 13, 2018 12:43AM
Ben,

Quote
bodhi
And then post the entire serial console log here

That will tell the story.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Ok, this is everything from when I powered it on

Pogov4>

U-Boot 2017.07-tld-1 (Sep 05 2017 - 00:34:01 -0700)
Pogoplug V4

SoC:   Kirkwood 88F6192_A1
DRAM:  128 MiB
WARNING: Caches not enabled
NAND:  128 MiB
MMC:   MVEBU_MMC: 0
In:    serial
Out:   serial
Err:   serial
Net:   egiga0
Hit any key to stop autoboot:  0
Pogov4> setenv devices mmc
Pogov4> setenv dtb_file '/boot/dts/kirkwood-pogoplug_v4.dtb'
Pogov4> printenv
arcNumber=3960
bootcmd=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec
bootcmd_exec=run load_uimage; if run load_initrd; then if run load_dtb; then bootm $load_uimage_addr $load_initrd_addr $load_dtb_addr; else bootm $load_uimage_addr $load_initrd_addr; fi; else if run load_dtb; then bootm $load_uimage_addr - $load_dtb_addr; else bootm $load_uimage_addr; fi; fi
bootcmd_uenv=run uenv_load; if test $uenv_loaded -eq 1; then run uenv_import; fi
bootdelay=10
bootdev=usb
device=0:1
devices=mmc
disks=0 1 2 3
dtb_file=/boot/dts/kirkwood-pogoplug_v4.dtb
ethact=egiga0
ethaddr=02:50:43:3f:e9:18
if_netconsole=ping $serverip
ipaddr=192.168.0.231
led_error=orange blinking
led_exit=green off
led_init=green blinking
load_dtb=ext2load usb 0:1 0x1c00000 /boot/dts/kirkwood-pogoplug_v4.dtb
load_dtb_addr=0x1c00000
load_initrd=ext2load usb 0:1 0x1100000 /boot/uInitrd
load_initrd_addr=0x1100000
load_uimage=ext2load usb 0:1 0x800000 /boot/uImage
load_uimage_addr=0x800000
machid=f78
mainlineLinux=yes
mtdids=nand0=orion_nand
mtdparts=mtdparts=orion_nand:2M(u-boot),3M(uImage),3M(uImage2),8M(failsafe),112M(root)
partition=nand0,2
preboot_nc=run if_netconsole start_netconsole
scan_disk=echo running scan_disk ...; scan_done=0; setenv scan_usb "usb start";  setenv scan_ide "ide reset";  setenv scan_mmc "mmc rescan"; for dev in $devices; do if test $scan_done -eq 0; then echo Scan device $dev; run scan_$dev; for disknum in $disks; do if test $scan_done -eq 0; then echo device $dev $disknum:1; if load $dev $disknum:1 $load_uimage_addr /boot/uImage 1; then scan_done=1; echo Found bootable drive on $dev $disknum; setenv device $disknum:1; setenv bootdev $dev; fi; fi; done; fi; done
serverip=192.168.0.220
set_bootargs=setenv bootargs console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 $mtdparts $custom_params
start_netconsole=setenv ncip $serverip; setenv bootdelay 10; setenv stdin nc; setenv stdout nc; setenv stderr nc; version;
stderr=serial
stdin=serial
stdout=serial
uenv_addr=0x810000
uenv_import=echo importing envs ...; env import -t $uenv_addr $filesize
uenv_init_devices=setenv init_usb "usb start";  setenv init_ide "ide reset";  setenv init_mmc "mmc rescan"; for devtype in $devices; do run init_$devtype; done;
uenv_load=run uenv_init_devices; setenv uenv_loaded 0; for devtype in $devices;  do for disknum in 0; do run uenv_read_disk; done; done;
uenv_read=echo loading envs from $devtype $disknum ...; if load $devtype $disknum:1 $uenv_addr /boot/uEnv.txt; then setenv uenv_loaded 1; fi
uenv_read_disk=if test $devtype -eq mmc; then if $devtype part; then run uenv_read;  fi; else if $devtype part $disknum; then run uenv_read; fi;  fi
usb_boot=run load_dtb; run load_uimage; if run load_initrd; then bootm 0x800000 0x1100000 0x1c00000; else bootm 0x800000 - 0x1c00000; fi
usb_ready_retry=15

Environment size: 2913/131068 bytes
Pogov4> boot

MMC rescan: current device # 0 initialized OK

Partition Map for MMC device 0  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     2048            7923712         00000000-01     83
loading envs from mmc 0 ...
87 bytes read in 18 ms (3.9 KiB/s)
importing envs ...
running scan_disk ...
Scan device mmc

MMC rescan: current device # 0 initialized OK
device mmc 0:1
1 bytes read in 16 ms (0 Bytes/s)
Found bootable drive on mmc 0
** Bad device usb 0 **
** Bad device usb 0 **
** Bad device usb 0 **
Wrong Image Format for bootm command
ERROR: can't get kernel image!
Pogov4>

Re: when writting to mtd0, Permission denied, unwritable?
March 13, 2018 03:31AM
I see. Your envs are not good to boot from mmc automatially.

You did not flash the default envs image when you went through the u-boot installation.

Quote

8. Flashing default u-boot envs image (if you are upgrading from 2016.05-tld-1 u-boot, you can skip this step 8).

As described in step 1, u-boot envs must be defined in /etc/fw_env.config as

# MTD device name Device offset Env. size Flash sector size Number of sectors
/dev/mtd0 0xc0000 0x20000 0x20000

This default envs image supports booting with multiple disk drives (and hubs) attached. The disk drives could be any type (usb, sata, sd card). The scanning logic and default envs were set to automatically boot the box with the following required configuration:

For whatever reason, if you can't set up your configuration to satisfy the following 4 requirements, then don't flash this defaut envs image. It might not boot properly. In this case, section C below can be used to tailor the envs to your specific configuration.

r1. There must be only one partition among all partitions from all drives that contains the kernel files. The 2 kernel files are /boot/uImage and /boot/uInitrd.
r2. The partition that contains the 2 kernel files must be partition 1 in a disk drive
r3. The partition that contains the rootfs must be labeled rootfs
r4. The rootfs partition is recommended to be type Ext3 (this is not a hard requirement, ext4 should boot OK, but Ext3 will ensure no problem).

So the bottom line is if you have only one rootfs in a single Ext3 partition, which is labeled as rootfs, then you're all set.

a. Download the default u-boot envs at Dropbox:

uboot.2016.05-tld-1.environment.bodhi.tar
md5:
3823eef10011b864859d31a76470e0e3
sha256:
c8db95a4225e8d78bdaaaa372bd5a87e4b98f3448dd9c62fc96c72b2df1a997c

This tarball includes 3 files:

uboot.2016.05-tld-1.environment.img (the default envs image to be flashed)
uboot.2016.05-tld-1.environment (the content of the default envs in text format)
uboot.2016.05-tld-1.environment.64K.img (small envs image to be flashed on HP T5325 only).

b. Extract the archive to /tmp
cd /tmp
tar -xf uboot.2016.05-tld-1.environment.bodhi.tar

c. Save current envs with fw_printenv, or just copy/paste the listing into a text file.
fw_printenv > current_envs.txt

d. Flash u-boot envs to NAND location 0xC0000.

Be extra careful with the next 2 commands, you should see output that look like below. If there is error, then do not reboot, post your problem here so we can help.

/usr/sbin/flash_erase /dev/mtd0 0xc0000 1
Expected output:
Erase Total 1 Units
Performing Flash Erase of length 131072 at offset 0xc0000 done

/usr/sbin/nandwrite -s 786432 /dev/mtd0 uboot.2016.05-tld-1.environment.img
Expected output:
Writing data to block 6 at offset 0xc0000

e. Modify the following u-boot variables using fw_setenv:

Note that arcNumber and machid are not necessary if you are booting with FDT kernel 3.17+ in the latest kernel and rootfs thread. But it does not hurt to set them anyway.

archNumber and machid are required for non-FDT kernel (3.16.x or earlier)

Also note that only some boxes need machid, some don't (so the command fw_setenv machid below clears them).

for Pogo V4/Mobile:
fw_setenv arcNumber 3960
fw_setenv machid f78

for iConnect:
fw_setenv arcNumber 2870
fw_setenv machid

for Stora:
fw_setenv arcNumber 2743
fw_setenv machid

for Dockstar:
fw_setenv arcNumber 2998
fw_setenv machid

for Pogo E02:
fw_setenv arcNumber 3542
fw_setenv machid dd6

for GoFlex Home:
fw_setenv arcNumber 3338
fw_setenv machid


for GoFlex Net:
fw_setenv arcNumber 3089
fw_setenv machid

for Sheevaplug:
fw_setenv arcNumber 2097
fw_setenv machid

for NSA325:
fw_setenv arcNumber 4495
fw_setenv machid

for NSA320:
fw_setenv arcNumber 3956
fw_setenv machid

for NSA310S/320S:
fw_setenv arcNumber 4931
fw_setenv machid

for NSA310:
fw_setenv arcNumber 4022
fw_setenv machid


Then for all boxes, restore these 2 envs using the saved envs text in step c (replace xxx with the real saved values)
fw_setenv mtdparts 'xxxxxxxxx'
fw_setenv ethaddr 'xx:xx:xx:xx:xx:xx'

Note: for boxes that boot with SATA as rootfs. Please make this adjustment if your boot drive is SATA:
fw_setenv bootcmd_uenv 'run uenv_load; if test $uenv_loaded -eq 1; then run uenv_import; fi; sleep 3'
(This will help the "ide reset" to work properly. There seems to be a bug in u-boot that if you do "ide reset" too quickly in succession, the SATA drive might have problem spinning up).

f. Adjust the DTB name to boot with a rootfs that has FDT kernel 3.17+ (this is the normal case):

Find your box DTB file in the rootfs /boot/dts directory and adjust the env to it. For example, if the box is the Dockstar
fw_setenv dtb_file '/boot/dts/kirkwood-dockstar.dtb'

In the special case when you are booting with a non-FDT kernel 3.16 or earlier, or if you have appended the DTB to uImage. Remove the DTB file env. If not sure please post question before continuing.
fw_setenv dtb_file

h. For sanity check, list you envs again
fw_printenv

If there is error in listing u-boot envs, stop here and post your problem so we can help.

Remember to save away your old envs text file created in step c for future reference in case more need to be restored.

i. Done step 8.

Your current envs is set up to boot with USB drive only (yours were the old default envs before u-boot-2016.05-tld-1)


See here how to load the latest default envs script at u-boot prompt:

https://forum.doozan.com/read.php?3,29362,29390#msg-29390

And since you have the Pogo V4 and want to boo twith MMC these setenvs in that post should be adjusted (replace xx:xx:xx:xx:xx:xx with your real MAC address)

from
setenv devices 'usb ide'
setenv ethaddr xx:xx:xx:xx:xx:xx
setenv dtb_file '/boot/dts/kirkwood-goflexnet.dtb'
boot

to
setenv devices 'mmc usb ide'
setenv ethaddr xx:xx:xx:xx:xx:xx
setenv dtb_file '/boot/dts/kirkwood-pogoplug_v4.dtb'
boot

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 1 time(s). Last edit at 03/13/2018 03:33AM by bodhi.
Hi bodhi,

Super! It's working now :D although it's not exactly the same as you described for loading Envs at Uboot prompt. That post still described how to load Envs using USB but mine is MMC (SD card) so I had to plug it into a SD card reader and plugged the card reader to the USB port. After that, "ext2load usb 0:1 0x800000 ...." could run but "source 0x800000" complaint about "wrong image....". After that, I realized it may be able to boot up directly using the USB SD card since you said the wrong Uboot Envs supported USB booting only. My guess worked it booted up via the USB card reader. After that, the thing turned a lot easier.....

After I installed everything, including the latest kernel, I just noticed a message when it's booting as below

[....] Waiting for /dev to be fully populated...[   28.736136] marvell-cesa f1030000.crypto: CESA device successfully registered
[   28.778489] orion_wdt: Initial timeout 25 sec
done (timeout).

Is that something I should be concerned? But the device can boot up and I can log in as usual.

You take paypal donation? I'd like to buy you a cup of beer or something. I guess many people thank you the same way. If you like drinking, you might get drunk everyday xD.

I haven't touched the little things (I have 4) for years. This time it really refreshed my memory about its setup/installation.....

Thanks a lot!
Re: when writting to mtd0, Permission denied, unwritable?
March 13, 2018 05:01PM
Ben,

> Super! It's working now :D

Cool :)

> After that, I realized it may be able
> to boot up directly using the USB SD card since
> you said the wrong Uboot Envs supported USB
> booting only. My guess worked it booted up via the
> USB card reader. After that, the thing turned a
> lot easier.....

That's even better than loading uenv script solution!

> [....] Waiting for /dev to be fully populated...[
> 28.736136] marvell-cesa f1030000.crypto: CESA
> device successfully registered
> [ 28.778489] orion_wdt: Initial timeout 25 sec
> done (timeout).

Sometime the SD card is very slow responding. You can ignore this message.

> You take paypal donation? I'd like to buy you a
> cup of beer or something. I guess many people
> thank you the same way. If you like drinking, you
> might get drunk everyday xD.

I drink, but only get drunk a few times a year :D. Donation is not necessary. But if you'd like, see bodhi's corner in my signature.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 1 time(s). Last edit at 03/13/2018 05:02PM by bodhi.
Hi bodhi,

One more thing, I got this error message when I ran apt-get update/upgrade. Do you know anything about that? That error seems to cause systemd not to run.

Setting up ntp (1:4.2.8p10+dfsg-3+deb9u2) ...
insserv: script checkroot.sh: service mtab already provided!
[....] Starting NTP server: ntpdAutomated Options Processing Error!
        /usr/sbin/ntpd called AutoOpts function with structure version 41:0:1.
        This exceeds the compiled library version:  AO_CURRENT:AO_REVISION:AO_AGE
 failed!
invoke-rc.d: initscript ntp, action "start" failed.
dpkg: error processing package ntp (--configure):
 subprocess installed post-installation script returned error exit status 70
Errors were encountered while processing:
 ntp

E: Sub-process /usr/bin/dpkg returned an error code (1)

Re: when writting to mtd0, Permission denied, unwritable?
March 13, 2018 07:51PM
Ben,

> One more thing, I got this error message when I
> ran apt-get update/upgrade. Do you know anything
> about that? That error seems to cause systemd not
> to run.

Boot back to sysvinit, do apt-get update/upgrade. And then switch back to systemd.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: