Re: [U-Boot] am335x based board nand boot crashes to ubi0 error

2017-01-09 Thread matti kaasinen
I made two trials with NANDARGS/nandroot variable in
include/configs/am335x_evm.h that made booting work:
nandroot 'ubi0:rootfs rw ubi.mtd=NAND.file-system,512'
and
nandroot 'ubi0:rootfs rw ubi.mtd=NAND.file-system'
However, nandroot 'ubi0:rootfs rw ubi.mtd=NAND.file-system,2048' did not
work as VID header in ubifs partition created by linux had VID header
position 512.

I tried also:
ubiformat /dev/mtd9  -s 2048
Then ubiattach crashed without -O 2048 option. So, possibly it's better not
providing VID header position in nandroot parameter at all. MTD commands
seem working fine with defaults. If nothing else than default is fed as VID
headr in ubiformat, that should also be fed in nandroot variable.

I found the reason why bootcmd_nand0 variable was missing even though
boot_targets variable had nand0 parameter.
There is a mistake in BOOTENV_DEV_NAND macro definition in:
ti-u-boot/
include/configs/am335x_evm.h:
= original macro
#define BOOTENV_DEV_NAND(devtypeu, devtypel, instance) \
"bootcmd_" #devtypel "=" \
"run nandboot\0"

= fixed macro
#define BOOTENV_DEV_NAND(devtypeu, devtypel, instance) \
"bootcmd_" #devtypel  #instance "=" \
"run nandboot\0"

naturally it could be just as simple as below
#define BOOTENV_DEV_NAND(devtypeu, devtypel, instance) \
"bootcmd_nand0=" \
"run nandboot\0"

Now nand boot works.
Only booting worry is that I don't seem to get fdt properly fed to u-boot.
In my opinion simply replacing am335x-evm.dts with myfdt.dts should work,
but still cd_gpio does not get properly detected. So either fdt does not
get loaded or, cd_gpio logic does not work properly. I use quite same dts
file as in Linux side that works fine with mmc card.
This is now very minor problem as car boots fine with main booting device.
Cheers,
Matti

2017-01-06 11:23 GMT+02:00 matti kaasinen :

> It seems that
> http://www.denx.de/wiki/publish/DULG/DULG-enbw_cmc.html#Section_9.1.5.2.
> Chapter 9.1.5.3.4. Installing UBI images (if no UBI Volumes exist): is
> mentioning a problem like this. Figures in error message are swapped,
> though. Anyhow, the root problem could be the fact that my ubiformat
> statement misses '-s' switch. I'll try that on Monday.
>
> 2017-01-05 16:16 GMT+02:00 matti kaasinen :
>
>> Hi!
>> I would need help related to nand boot with am335x based board. Board
>> boots from mmc (sd card), but not from nand flash.
>> I have been using yocto/poky build system with meta-ti layer that brings
>> up u-boot-ti-staging. Current u-boot version is 2016.05 and
>> linux-ti-staging-rt-4.4.
>>
>> I have used am335x_evm config (include/configs/am335x_evm.h) that I have
>> made minor modifications to suit it to my board. Most of the modifications
>> are made to board/ti/am335x/board.c and mux.c to adapt to different
>> memories and pin mappings and lack of card id eeprom.
>>
>> This story is "follow up" to http://lists.denx.de/pipermail
>> /u-boot/2017-January/277168.html. So, I2C was initialized somehow when
>> booting from mmc, but not when booting from nand.
>>
>> "Follow up" part:
>> Board did still not start booting kernel even though I2C init problem was
>> fixed.
>>
>> The reason was that boot_targets variable has been assigned with
>> mmc0 legacy_mmc0 mmc1 legacy_mmc1 nand0 pxe dhcp
>> when main u-boot is brought up. These values are iterated when
>> distro_bootcmd is executed.
>> distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target};
>> done
>> I made minor modification to distro_bootcmd:
>> distro_bootcmd=for target in ${boot_targets}; do echo "=== ${target}
>> ===" ; run bootcmd_${target}; done
>> Please find the distro_bootcmd running results below:
>> => run distro_bootcmd
>> === mmc0 ===
>> Card did not respond to voltage select!
>> === legacy_mmc0 ===
>> Card did not respond to voltage select!
>> Card did not respond to voltage select!
>> === mmc1 ===
>> data abort
>> pc : [<8ff70fa0>]  lr : [<8ff701e9>]
>> reloc pc : [<8081dfa0>]lr : [<8081d1e9>]
>> sp : 8ef286f0  ip : 8ff5891d fp : 0003
>> r10: 8ffb3b18  r9 : 8ef32ed8 r8 : 8ef41b10
>> r7 : 8ff584bd  r6 : 8ef39478 r5 : 8ef39500  r4 : 4781
>> r3 : 8ff70f91  r2 : 00014892 r1 :   r0 : 8ef39500
>> Flags: nZCv  IRQs off  FIQs on  Mode SVC_32
>> Resetting CPU ...
>>
>> So, MMC1 was troublemaker this time.
>> I removed mmc1 from that command - I do not have mmc1 on my board.
>> => setenv boot_targets ' mmc0 legacy_mmc0  nand0 '
>>
>> Please find modified command results below:
>> => run distro_bootcmd
>> === mmc0 ===
>> Card did not respond to voltage select!
>> === legacy_mmc0 ===
>> Card did not respond to voltage select!
>> Card did not respond to voltage select!
>> === nand0 ===
>> ## Error: "bootcmd_nand0" not defined
>>
>> NOTE!! Is this a bug in u-boot-ti? There is no bootcmd_nand0 in u-boot
>> memory at this time. However, there is bootcmd_nand. So, I changed nand0 to
>> nand
>> => setenv boot_

Re: [U-Boot] am335x based board nand boot crashes to ubi0 error

2017-01-06 Thread matti kaasinen
It seems that
http://www.denx.de/wiki/publish/DULG/DULG-enbw_cmc.html#Section_9.1.5.2.
Chapter 9.1.5.3.4. Installing UBI images (if no UBI Volumes exist): is
mentioning a problem like this. Figures in error message are swapped,
though. Anyhow, the root problem could be the fact that my ubiformat
statement misses '-s' switch. I'll try that on Monday.

2017-01-05 16:16 GMT+02:00 matti kaasinen :

> Hi!
> I would need help related to nand boot with am335x based board. Board
> boots from mmc (sd card), but not from nand flash.
> I have been using yocto/poky build system with meta-ti layer that brings
> up u-boot-ti-staging. Current u-boot version is 2016.05 and
> linux-ti-staging-rt-4.4.
>
> I have used am335x_evm config (include/configs/am335x_evm.h) that I have
> made minor modifications to suit it to my board. Most of the modifications
> are made to board/ti/am335x/board.c and mux.c to adapt to different
> memories and pin mappings and lack of card id eeprom.
>
> This story is "follow up" to http://lists.denx.de/
> pipermail/u-boot/2017-January/277168.html. So, I2C was initialized
> somehow when booting from mmc, but not when booting from nand.
>
> "Follow up" part:
> Board did still not start booting kernel even though I2C init problem was
> fixed.
>
> The reason was that boot_targets variable has been assigned with
> mmc0 legacy_mmc0 mmc1 legacy_mmc1 nand0 pxe dhcp
> when main u-boot is brought up. These values are iterated when
> distro_bootcmd is executed.
> distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target};
> done
> I made minor modification to distro_bootcmd:
> distro_bootcmd=for target in ${boot_targets}; do echo "=== ${target}
> ===" ; run bootcmd_${target}; done
> Please find the distro_bootcmd running results below:
> => run distro_bootcmd
> === mmc0 ===
> Card did not respond to voltage select!
> === legacy_mmc0 ===
> Card did not respond to voltage select!
> Card did not respond to voltage select!
> === mmc1 ===
> data abort
> pc : [<8ff70fa0>]  lr : [<8ff701e9>]
> reloc pc : [<8081dfa0>]lr : [<8081d1e9>]
> sp : 8ef286f0  ip : 8ff5891d fp : 0003
> r10: 8ffb3b18  r9 : 8ef32ed8 r8 : 8ef41b10
> r7 : 8ff584bd  r6 : 8ef39478 r5 : 8ef39500  r4 : 4781
> r3 : 8ff70f91  r2 : 00014892 r1 :   r0 : 8ef39500
> Flags: nZCv  IRQs off  FIQs on  Mode SVC_32
> Resetting CPU ...
>
> So, MMC1 was troublemaker this time.
> I removed mmc1 from that command - I do not have mmc1 on my board.
> => setenv boot_targets ' mmc0 legacy_mmc0  nand0 '
>
> Please find modified command results below:
> => run distro_bootcmd
> === mmc0 ===
> Card did not respond to voltage select!
> === legacy_mmc0 ===
> Card did not respond to voltage select!
> Card did not respond to voltage select!
> === nand0 ===
> ## Error: "bootcmd_nand0" not defined
>
> NOTE!! Is this a bug in u-boot-ti? There is no bootcmd_nand0 in u-boot
> memory at this time. However, there is bootcmd_nand. So, I changed nand0 to
> nand
> => setenv boot_targets ' mmc0 legacy_mmc0  nand'
> => run distro_bootcmd
> === mmc0 ===
> Card did not respond to voltage select!
> === legacy_mmc0 ===
> Card did not respond to voltage select!
> Card did not respond to voltage select!
> === nand ===
> Booting from nand ...
>
> NAND read: device 0 offset 0x8, size 0x4
>  262144 bytes read: OK
>
> NAND read: device 0 offset 0x20, size 0x80
>  8388608 bytes read: OK
> Kernel image @ 0x8200 [ 0x00 - 0x2c4fd8 ]
> ## Flattened Device Tree blob at 8800
>Booting using the fdt blob at 0x8800
>Loading Device Tree to 8ef1b000, end 8ef27614 ... OK
>
> Starting kernel ...
>
> [0.00] Booting Linux on physical CPU 0x0
> [0.00] Initializing cgroup subsys cpu
>
> ... lots of listing and then ..
> [1.172458] nand: device found, Manufacturer ID: 0x2c, Chip ID: 0xda
> [1.179257] nand: Micron MT29F2G08ABAEAWP
> [1.183469] nand: 256 MiB, SLC, erase size: 128 KiB, page size: 2048,
> OOB size: 64
> [1.191491] nand: using OMAP_ECC_BCH8_CODE_HW ECC scheme
> [1.197164] 10 ofpart partitions found on MTD device 800.nand
> [1.203607] Creating 10 MTD partitions on "800.nand":
> [1.209285] 0x-0x0002 : "NAND.SPL"
> [1.216261] 0x0002-0x0004 : "NAND.SPL.backup1"
> [1.223834] 0x0004-0x0006 : "NAND.SPL.backup2"
> [1.231275] 0x0006-0x0008 : "NAND.SPL.backup3"
> [1.238794] 0x0008-0x000c : "NAND.u-boot-spl-os"
> [1.246571] 0x000c-0x001c : "NAND.u-boot"
> [1.254316] 0x001c-0x001e : "NAND.u-boot-env"
> [1.261612] 0x001e-0x0020 : "NAND.u-boot-env.backup1"
> [1.269653] 0x0020-0x00a0 : "NAND.kernel"
> [1.283112] 0x00a0-0x1000 : "NAND.file-system"
> [1.520856] tps65217 0-0024: TPS65217 ID 

[U-Boot] am335x based board nand boot crashes to ubi0 error

2017-01-05 Thread matti kaasinen
Hi!
I would need help related to nand boot with am335x based board. Board boots
from mmc (sd card), but not from nand flash.
I have been using yocto/poky build system with meta-ti layer that brings up
u-boot-ti-staging. Current u-boot version is 2016.05 and
linux-ti-staging-rt-4.4.

I have used am335x_evm config (include/configs/am335x_evm.h) that I have
made minor modifications to suit it to my board. Most of the modifications
are made to board/ti/am335x/board.c and mux.c to adapt to different
memories and pin mappings and lack of card id eeprom.

This story is "follow up" to
http://lists.denx.de/pipermail/u-boot/2017-January/277168.html. So, I2C was
initialized somehow when booting from mmc, but not when booting from nand.

"Follow up" part:
Board did still not start booting kernel even though I2C init problem was
fixed.

The reason was that boot_targets variable has been assigned with
mmc0 legacy_mmc0 mmc1 legacy_mmc1 nand0 pxe dhcp
when main u-boot is brought up. These values are iterated when
distro_bootcmd is executed.
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
I made minor modification to distro_bootcmd:
distro_bootcmd=for target in ${boot_targets}; do echo "=== ${target}
===" ; run bootcmd_${target}; done
Please find the distro_bootcmd running results below:
=> run distro_bootcmd
=== mmc0 ===
Card did not respond to voltage select!
=== legacy_mmc0 ===
Card did not respond to voltage select!
Card did not respond to voltage select!
=== mmc1 ===
data abort
pc : [<8ff70fa0>]  lr : [<8ff701e9>]
reloc pc : [<8081dfa0>]lr : [<8081d1e9>]
sp : 8ef286f0  ip : 8ff5891d fp : 0003
r10: 8ffb3b18  r9 : 8ef32ed8 r8 : 8ef41b10
r7 : 8ff584bd  r6 : 8ef39478 r5 : 8ef39500  r4 : 4781
r3 : 8ff70f91  r2 : 00014892 r1 :   r0 : 8ef39500
Flags: nZCv  IRQs off  FIQs on  Mode SVC_32
Resetting CPU ...

So, MMC1 was troublemaker this time.
I removed mmc1 from that command - I do not have mmc1 on my board.
=> setenv boot_targets ' mmc0 legacy_mmc0  nand0 '

Please find modified command results below:
=> run distro_bootcmd
=== mmc0 ===
Card did not respond to voltage select!
=== legacy_mmc0 ===
Card did not respond to voltage select!
Card did not respond to voltage select!
=== nand0 ===
## Error: "bootcmd_nand0" not defined

NOTE!! Is this a bug in u-boot-ti? There is no bootcmd_nand0 in u-boot
memory at this time. However, there is bootcmd_nand. So, I changed nand0 to
nand
=> setenv boot_targets ' mmc0 legacy_mmc0  nand'
=> run distro_bootcmd
=== mmc0 ===
Card did not respond to voltage select!
=== legacy_mmc0 ===
Card did not respond to voltage select!
Card did not respond to voltage select!
=== nand ===
Booting from nand ...

NAND read: device 0 offset 0x8, size 0x4
 262144 bytes read: OK

NAND read: device 0 offset 0x20, size 0x80
 8388608 bytes read: OK
Kernel image @ 0x8200 [ 0x00 - 0x2c4fd8 ]
## Flattened Device Tree blob at 8800
   Booting using the fdt blob at 0x8800
   Loading Device Tree to 8ef1b000, end 8ef27614 ... OK

Starting kernel ...

[0.00] Booting Linux on physical CPU 0x0
[0.00] Initializing cgroup subsys cpu

... lots of listing and then ..
[1.172458] nand: device found, Manufacturer ID: 0x2c, Chip ID: 0xda
[1.179257] nand: Micron MT29F2G08ABAEAWP
[1.183469] nand: 256 MiB, SLC, erase size: 128 KiB, page size: 2048,
OOB size: 64
[1.191491] nand: using OMAP_ECC_BCH8_CODE_HW ECC scheme
[1.197164] 10 ofpart partitions found on MTD device 800.nand
[1.203607] Creating 10 MTD partitions on "800.nand":
[1.209285] 0x-0x0002 : "NAND.SPL"
[1.216261] 0x0002-0x0004 : "NAND.SPL.backup1"
[1.223834] 0x0004-0x0006 : "NAND.SPL.backup2"
[1.231275] 0x0006-0x0008 : "NAND.SPL.backup3"
[1.238794] 0x0008-0x000c : "NAND.u-boot-spl-os"
[1.246571] 0x000c-0x001c : "NAND.u-boot"
[1.254316] 0x001c-0x001e : "NAND.u-boot-env"
[1.261612] 0x001e-0x0020 : "NAND.u-boot-env.backup1"
[1.269653] 0x0020-0x00a0 : "NAND.kernel"
[1.283112] 0x00a0-0x1000 : "NAND.file-system"
[1.520856] tps65217 0-0024: TPS65217 ID 0xe version 1.2
[1.526486] omap_i2c 44e0b000.i2c: bus 0 rev0.11 at 400 kHz
[1.533461] omap_i2c 4802a000.i2c: bus 1 rev0.11 at 400 kHz
[1.539830] ubi0: attaching mtd9
[1.543810] ubi0 error: validate_ec_hdr: bad VID header offset 512,
expected 2048
[1.551672] ubi0 error: validate_ec_hdr: bad EC header
[1.557063] Erase counter header dump:
[1.560998]  magic  0x55424923
[1.564930]  version1
[1.568041]  ec 1
[1.571151]  vid_hdr_offset 512
[1.57]  data_offset2048
[1.577831]  image_seq  1630296601
[1.581762]  hdr