SAMA5D3_XPL booting problem (u-boot not loaded..)

Moderator: nferre

Jaewoo
Posts: 1
Joined: Thu Apr 04, 2019 2:19 am

SAMA5D3_XPL booting problem (u-boot not loaded..)

Thu Apr 04, 2019 3:13 am

Hi guys~
I have a problem, need guys help. :roll:

The software and instructions followed the guidance of at91 ( linux4sam/bin/view/Linux4SAM ).
I am using the sama5d3_xplained board and using the NAND flash memory only by changing it to the skynix.
And I modified and used the demo script provided to write binary images in NAND memory.

Code: Select all

#flashing.sh
#!/bin/bash
./sam-ba /dev/ttyACM0 at91sama5d3x-xplained sama5d3_linux_nandflash.tcl

Code: Select all

#sama5d3_linux_nandflash.tcl
## Files to load
set bootstrapFile	"/data/Atmel/BlueNight/at91bootstrap/binaries/at91bootstrap.bin"
set ubootFile		"/data/Atmel/BlueNight/u-boot-at91/u-boot.bin"

set dtbFile			"/data/Atmel/BlueNight/linux-at91/arch/arm/boot/dts/at91-sama5d3_xplained.dtb"
set kernelFile		"/data/Atmel/BlueNight/linux-at91/arch/arm/boot/zImage"
set rootfsFile		"/data/Atmel/BlueNight/buildroot-at91/output/images/rootfs.ubi"


## board variant
set boardFamily "at91-sama5d3"
set board_suffix "_xplained"

puts "-I- Binaries param set complete."

## now call common script
source sama5d3_script_linux_nandflash.tcl

Code: Select all

#sama5d3_script_linux_nandflash.tcl
# ----------------------------------------------------------------------------
#         ATMEL Microcontroller
# ----------------------------------------------------------------------------
# Copyright (c) 2013, Atmel Corporation
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# - Redistributions of source code must retain the above copyright notice,
# this list of conditions and the disclaimer below.
#
# Atmel's name may not be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
# DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ----------------------------------------------------------------------------

################################################################################
#  proc uboot_env: Convert u-boot variables in a string ready to be flashed
#                  in the region reserved for environment variables
################################################################################
proc set_uboot_env {nameOfLstOfVar} {
    upvar $nameOfLstOfVar lstOfVar
    
    # sector size is the size defined in u-boot CFG_ENV_SIZE
    set sectorSize [expr 0x20000 - 5]

    set strEnv [join $lstOfVar "\0"]
    while {[string length $strEnv] < $sectorSize} {
        append strEnv "\0"
    }
    # \0 between crc and strEnv is the flag value for redundant environment
    set strCrc [binary format i [::vfs::crc $strEnv]]
    return "$strCrc\0$strEnv"
}

################################################################################
#  Main script: Load the linux demo in NandFlash,
#               Update the environment variables
################################################################################

################################################################################

# check for proper variable initialization
if {! [info exists boardFamily]} {
   puts "-E- === Board family not defined ==="
   exit
}

## Additional files to load
#append dtbFile $boardFamily $board_suffix ".dtb"
set ubootEnvFile  "ubootEnvtFileNandFlash.bin"

## Now check for the needed files
if {! [file exists $bootstrapFile]} {
   puts "-E- === AT91Bootstrap file not found ==="
   exit
}

if {! [file exists $ubootFile]} {
   puts "-E- === U-Boot file not found ==="
   exit
}

if {! [file exists $kernelFile]} {
   puts "-E- === Linux kernel file not found ==="
   exit
}
puts "-D- === dtb : $dtbFile"
if {! [file exists $dtbFile]} {
   puts "-E- === Unknown $boardFamily + board $board_suffix combination ==="
   exit
}

if {! [file exists $rootfsFile]} {
   puts "-E- === Rootfs file not found ==="
   exit
}

#set pmeccConfig 0xc0902405
#set pmeccConfig 0xc0c02805
[color=#FF0000]set pmeccConfig 0xC1902805[/color]


## NandFlash Mapping
set bootStrapAddr 0x00000000
[color=#FF0000]set ubootAddr   0x00040000[/color]
set ubootEnvAddr  0x000c0000
set dtbAddr   0x00180000
set kernelAddr    0x00200000
set rootfsAddr    0x00800000

## u-boot variable
set kernelLoadAddr 0x22000000
set dtbLoadAddr 0x21000000

## NandFlash Mapping
set kernelSize  [format "0x%08X" [file size $kernelFile]]
set dtbSize [format "0x%08X" [file size $dtbFile]]

set bootCmd "bootcmd=nand read $dtbLoadAddr $dtbAddr $dtbSize; nand read $kernelLoadAddr $kernelAddr $kernelSize; bootz $kernelLoadAddr - $dtbLoadAddr"

lappend u_boot_variables \
    "bootdelay=1" \
    "baudrate=115200" \
    "stdin=serial" \
    "stdout=serial" \
    "stderr=serial" \
    "bootargs=console=ttyS0,115200 mtdparts=atmel_nand:256k(bootstrap)ro,512k(uboot)ro,256k(env),256k(env_redundant),256k(spare),512k(dtb),6M(kernel)ro,-(rootfs) rootfstype=ubifs ubi.mtd=7 root=ubi0:rootfs rw" \
    "$bootCmd"


puts "-I- === Initialize the NAND access ==="
NANDFLASH::Init

if {$pmeccConfig != "none"} {
   puts "-I- === Enable PMECC OS Parameters ==="
   NANDFLASH::NandHeaderValue HEADER $pmeccConfig
}

puts "-I- === Erase all the NAND flash blocs and test the erasing ==="
NANDFLASH::EraseAllNandFlash

puts "-I- === Load the bootstrap in the first sector ==="
if {$pmeccConfig != "none"} {
   NANDFLASH::SendBootFilePmeccCmd $bootstrapFile
} else {
   NANDFLASH::sendBootFile $bootstrapFile
}

puts "-I- === Load the u-boot in the next sectors ==="
send_file {NandFlash} "$ubootFile" $ubootAddr 0 

puts "-I- === Load the u-boot environment variables ==="
set fh [open "$ubootEnvFile" w]
fconfigure $fh -translation binary
puts -nonewline $fh [set_uboot_env u_boot_variables]
close $fh
send_file {NandFlash} "$ubootEnvFile" $ubootEnvAddr 0 

puts "-I- === Load the Kernel image and device tree database ==="
send_file {NandFlash} "$dtbFile" $dtbAddr 0
send_file {NandFlash} "$kernelFile" $kernelAddr 0

if {$pmeccConfig != "none"} {
   puts "-I- === Enable trimffs ==="
   NANDFLASH::NandSetTrimffs 1
}

puts "-I- === Load the linux file system ==="
send_file {NandFlash} "$rootfsFile" $rootfsAddr 0

puts "-I- === DONE. ==="
I compiled each bootstrap, boot, and kernel, and confirmed that it was written in NAND memory without errors.
After reset, bootstrap seems to have worked normally, but there has been a problem with the u-boot being held without being loaded.

What I don't understand is that when I write the same u-boot binary to NAND memory using sam-ba(v2.18) and then reboot, the u-boot will load normally. :shock:

I confirmed that the memory address of the NAND where u-boot is written and the pmecc of the NAND is the same as sam-ba and script.

Does anyone know what's wrong? :idea:
blue_z
Location: USA
Posts: 1911
Joined: Thu Apr 19, 2007 10:15 pm

Re: SAMA5D3_XPL booting problem (u-boot not loaded..)

Fri Apr 05, 2019 6:56 pm

Jaewoo wrote: ... and using the NAND flash memory only by changing it to the skynix.
What is "skynix"?

Jaewoo wrote: And I modified and used the demo script provided to write binary images in NAND memory.
Modified what and why?

Jaewoo wrote: I compiled each bootstrap, boot, and kernel, and confirmed that it was written in NAND memory without errors.
How did you "confirm" the write operation?
Did you perform a read verify?

Jaewoo wrote: After reset, bootstrap seems to have worked normally, but there has been a problem with the u-boot being held without being loaded.
So there's a boot issue.
Where's the boot log?

Jaewoo wrote: What I don't understand is that when I write the same u-boot binary to NAND memory using sam-ba(v2.18) and then reboot, the u-boot will load normally.
FYI the "script" clearly indicates that it invokes SAM-BA.
Which version of SAM-BA is in your PATH?
If using the SAM-BA GUI produces different results, then where's that boot log?

Jaewoo wrote: I confirmed that the memory address of the NAND where u-boot is written and the pmecc of the NAND is the same as sam-ba and script.
Another summary without any details.

Jaewoo wrote: Does anyone know what's wrong?
You've only provided your summations and neglect to provide any details.

Regards

Return to “SAMA5-based”

Who is online

Users browsing this forum: No registered users and 2 guests