Write to eMMC boot0 partition from u-boot - u-boot

I am using eMMC based on 5.1 Version, which has boot0, boot1, rpmb and userarea.
Inorder to write to eMMC from u-boot, mmc commands can be used.
mmc read commands is of below form.
$mmc read addr blk# cnt
if i give blk to 0x0, where it will write boot0 partition or user area ?
Thanks in advance

Related

Uboot NAND flash or mtd partition auto-changes to ubi(?)

I am not sure whether the following situation is normal.
I have the following command to boot to kernel from uboot:
set mtdids nand0=pxa3xx_nand-0
set mtdparts mtdparts=pxa3xx_nand-0:0x600000(boot)ro,0x400000(kernel),-(rootfs)
usb start
fatload usb 0:1 0x201000000 ubifs.img
nand erase.part rootfs; ubi part rootfs; ubi create nand_rootfs
ubi write 0x201000000 nand_rootfs $filesize
fatload usb 0:1 0x206000000 Image;
fatload usb 0:1 0x201000000 dtb.dtb;
set bootargs mem=2G console=ttyS0,115200 earlycon=uart8250,mmio32,0x7f012000 ubi.mtd=2 root=ubi0 rootfstype=ubifs rw cpuidle.off=1;
booti 0x206000000 - 0x201000000;
As you can see, since the Image and dtb are not stored internally, I have to plug in a USB to boot my device with this method. To get rid of using USB every time, I modified the cmds as follows:
set mtdparts mtdparts=pxa3xx_nand-0:0x600000(boot)ro,0x3200000(kernel),0x100000(dtb),0x100000(dtb_spare),0x5C80000(rootfs),-(rootfsubi); //I will explain why I made that many partitions
set kernelsize 0x2916808;
set dtbsize 0x1f15;
set ubifsimgsize 0x2cc0ff0;
nand erase.chip;usb start;
fatload usb 0:1 0x210000000 ubifs.img;
ubi part rootfs; ubi create nand_rootfs;
ubi write 0x210000000 nand_rootfs $ubifsimgsize;
nand write 0x210000000 rootfsubi $ubifsimgsize; // will be explained below
fatload usb 0:1 0x206000000 Image;
fatload usb 0:1 0x201000000 dtb.dtb;
nand write 0x206000000 kernel $kernelsize;
nand write 0x201000000 dtb $dtbsize;nand write 0x201000000 dtb_spare $dtbsize;
setenv boot_device 'nand read 0x206000000 kernel $kernelsize;nand read 0x201000000 dtb $dtbsize;set bootargs mem=2G console=ttyS0,115200 earlycon=uart8250,mmio32,0x7f012000 ubi.mtd=3 root=ubi0 rootfstype=ubifs rw cpuidle.off=1;booti 0x206000000 - 0x201000000;'
set boot_cmd run boot_device;
set bootargs mem=2G console=ttyS0,115200 earlycon=uart8250,mmio32,0x7f012000 ubi.mtd=2 root=ubi0 rootfstype=ubifs rw cpuidle.off=1;
saveenv
booti 0x206000000 - 0x201000000;
The first time boot using the above command was always successful. My problem happened when I reboot to uboot from kernel.
The "nand write" ubifs img appears because the ubi volume was gone but every time I boot to uboot from kernel. This command was meant to do the ubi device and volume process again without using USB.
Moreover, when the first time booted to the kernel, and reboot to enter uboot again, I discovered with the commands md address, ubi read and nand read that, the memory in the partition changed into UBI something. Please take a look at the picture below
Picture: Auto-changes to ubi something(?)
Basically all partition except the first 0x400000 bytes of kernel and boot behave as above when booted to uboot from kernel.
I did not find anything relevant online. I wonder if this is something normal when using ubi or ubifs to boot to kernel. Please let me know if you have any hints or clues about how to achieve booting to kernel without external USB.
Post the mtd part here if it matters:
uboot>> mtd
device nand0 <pxa3xx_nand-0>, # parts = 6
#: name size offset mask_flags
0: boot 0x00600000 0x00000000 1
1: kernel 0x03200000 0x00600000 0
2: dtb 0x00100000 0x03800000 0
3: dtb_spare 0x00100000 0x03900000 0
4: rootfs 0x05c80000 0x03a00000 0
5: rootfsubi 0x06980000 0x09680000 0
active partition: nand0,0 - (boot) 0x00600000 # 0x00000000
defaults:
mtdids :
mtdparts:

How to pass data from u-boot bootloader to QNX application via ram?

Using QNX 6.5.x with u-boot as a bootloader, on an ATSAMA5d3x module.
We'd like to pass some amount of data, ~1.5kb, from the bootloader into QNX via RAM, rather than trying to pass it via flash storage.
Is there a mechanism to tell QNX to reserve an area of RAM and not touch it? This would let us mmap it from the QNX application to read the data out of it, without QNX using it for heap or otherwise zeroing it out.
Is there another approach you've used to pass data like this into QNX?
QNX startup-* programs permit the use of the -r argument to reserve a block of phyiscal address space. You can supply arguments to startup in the .build file for the bootstrap image (the source to mkifs).
Example:
[image=0x22000000]
[virtual=armle-v7,raw +compress] .bootstrap = {
# reserve 4k at paddr 0x20000000 and don't clear it
startup-atsama5d3x-ek -vvv -r 0x20000000,4096,1
# reset of boot code goes here
}
[+script] .script = {
# and so on
}
# and so forth
Ref: http://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.utilities/topic/s/startup_options.html
I try using qnx 6.5.0 on ATSAMA5d3x
I use default nand driver from bsp, but periodically(when try open some bin file) i get this error:
fs-etfs-sama5d3x: readcluster DATAERR on cluster xxxxxx
after reset all ok, i can run binary, but after a while this error will appear again
Why is this happening? You use default driver?
Maybe you know something
*Forgive me for asking in your question, too little information on qnx 6.5.0 on ATSAMA5d3x
enter image description here

Load u-boot.ldr in bf548 ezkit using sd card

i am working on BF548 EZKIT LITE, i had done tftp booting in it. Kernel and jffs2 file system loaded successfully and got the root prompt.
But now i need to use SD card for booting, I had made ext2 partition into sd card and copy u-boot.ldr(boot loader) in it, but when try to load this file after inserting SD card into board i had got an error like
tranfering data failed
** ext4fs_devread read error - block
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
search on net but could not find anything , add log for detail which shows SD card is detected.
bfin> mmcinfo
Device: Blackfin SDH
Manufacturer ID: 3
OEM: 5344
Name: SD02G
Tran Speed: 25000000
Rd Block Len: 512
SD version 2.0
High Capacity: No
Capacity: 1.8 GiB
Bus Width: 4-bit
bfin>
bfin> ext2load mmc 0 0x1000000 u-boot.ldr
tranfering data failed
** ext4fs_devread read error - block
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
bfin>
I had tried different sd card also but still got the same problem, Any one have clue about this? Please share.
U-boot version= 2014.07.
Linux kernel = 4.5.4
I am using Buildroot for making board support package.
Thank in advance....
Ah, so your problem is:
bfin> ext2load mmc 0 0x1000000 u-boot.ldr
and this should be:
bfin> ext4load mmc 0:1 0x1000000 u-boot.ldr
as you need to specify both the MMC device (0) and the partition on the device (1 as you made 1 partition on the SD card and formatted that). Just saying 0 causes it to try and read the whole device as where the filesystem is which fails when it runs into the partition table. And you need to use 'ext4load' (or just load, if you have the generic commands enabled) as well since you've got ext3/ext4 most likely and not just ext2.

Can I easily compile u-boot with more commands for arm versatile bp

I have compiled u-boot from u-boot-2013.01.y branch for versatilebp board (arm), and I need fatload command that is not present in this configuation.
I'm running u-boot under qemu
DRAM: 128 MiB
WARNING: Caches not enabled
Using default environment
In: serial
Out: serial
Err: serial
Net: SMC91111-0
Warning: SMC91111-0 using MAC address from net device
VersatilePB # fat
Unknown command 'fat' - try 'help'
VersatilePB # help
? - alias for 'help'
base - print or set address offset
bdinfo - print Board Info structure
bootm - boot application image from memory
bootp - boot image via network using BOOTP/TFTP protocol
cmp - memory compare
cp - memory copy
crc32 - checksum calculation
dhcp - boot image via network using DHCP/TFTP protocol
env - environment handling commands
erase - erase FLASH memory
flinfo - print FLASH memory information
go - start application at address 'addr'
help - print command description/usage
iminfo - print header information for application image
loop - infinite loop on address range
md - memory display
mm - memory modify (auto-incrementing address)
mtest - simple RAM read/write test
mw - memory write (fill)
nm - memory modify (constant address)
ping - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
protect - enable or disable FLASH write protection
reset - Perform RESET of the CPU
setenv - set environment variables
tftpboot- boot image via network using TFTP protocol
version - print monitor, compiler and linker version
VersatilePB #
I need fatload to load file containing image of fat filesystem containing kernel of freebsd. Can I somehow change compile config for that board to compile u-boot with fatload command? Or it's just not possible/not supported for that board?
Having done more or less exactly this for a Versatile AB, it's most certainly possible. The simplest way is to find where that board's command set is defined, and hack in the commands you want by defining the relevant CONFIG_CMD_* symbols. In this case, that place is include/configs/versatile.h.
Looking at my checkout of 2015.07, I seem to have added, among others (I think I was trying to convince the MMC to work at the time), these lines:
#define CONFIG_CMD_FAT
#define CONFIG_DOS_PARTITION 1

Can't boot basic OpenEmbedded-Core on Freescale i.MX28

I've been trying to build and boot OpenEmbedded-Core on the evaluation kit for Freescale's ARM i.MX28, using the Freescale ARM layer for OpenEmbedded-Core. Unfortunately, I can't find a basic "Getting Started" guide (though there is a Yocto getting-started guide). Unfortunately, I haven't been able to "get started", to the point of successfully booting to a basic command prompt on the board's debug serial port.
Here is what I've been able to piece together, and as far as I've managed to get so far.
Fetch sources
mkdir -p oe-core/freescale-arm
cd oe-core/freescale-arm
git clone git://git.openembedded.org/openembedded-core oe-core
git clone git://github.com/Freescale/meta-fsl-arm.git
cd oe-core
git clone git://git.openembedded.org/meta-openembedded
git clone git://git.openembedded.org/bitbake bitbake
Set up environment
. ./oe-init-build-env
That puts us in a new sub-directory build and sets certain environment variables.
Edit configuration
Edit the conf/bblayers.conf and local.conf files:
conf/bblayers.conf should have the meta-fls-arm and meta-oe layers added for BBLAYERS. E.g.:
BBLAYERS ?= " \
/home/craigm/oe-core/freescale-arm/oe-core/meta \
/home/craigm/oe-core/freescale-arm/oe-core/meta-openembedded/meta-oe \
${TOPDIR}/../../meta-fsl-arm \
"
In conf/local.conf, I set:
BB_NUMBER_THREADS = "4"
PARALLEL_MAKE = "-j 4"
MACHINE = "imx28evk"
Build
bitbake core-image-minimal
I ran this build overnight, and it has completed successfully for me. Output files were in ~/oe-core/freescale-arm/oe-core/build/tmp-eglibc/deploy/images.
There are two boot options that I'd like to try, as described below. Boot from SD card is simpler, but takes quite a long time (~30 min) to write the image to the SD card. Booting from TFTP + NFS is faster, but requires more set-up.
Boot from SD Card
Write image to SD card:
sudo dd if=tmp-eglibc/deploy/images/core-image-minimal-imx28evk.sdcard of=/dev/sdc
It took something like 30 minutes (3.5 GB file). Then I put it in the board's SD card slot 0, and powered-up. It got as far as loading the kernel, then stopped:
U-Boot 2012.04.01-00059-g4e6e824 (Aug 23 2012 - 18:08:54)
Freescale i.MX28 family at 454 MHz
BOOT: SSP SD/MMC #0, 3V3
DRAM: 128 MiB
MMC: MXS MMC: 0
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: FEC0, FEC1
Hit any key to stop autoboot: 0
reading boot.scr
** Unable to read "boot.scr" from mmc 0:2 **
reading uImage
2598200 bytes read
Booting from mmc ...
## Booting kernel from Legacy Image at 42000000 ...
Image Name: Linux-2.6.35.3-11.09.01+yocto-20
Created: 2012-08-23 7:53:40 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2598136 Bytes = 2.5 MiB
Load Address: 40008000
Entry Point: 40008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Boot from TFTP + NFS
First, I tried to write U-Boot onto an SD card:
sudo dd if=tmp-eglibc/deploy/images/u-boot-imx28evk.mxsboot-sdcard of=/dev/sdc
Then I put it in the board's SD card slot 0, and powered-up. But all I got in the debug serial port was:
0x8020a01d
So, I decided to use Freescale's distribution of U-Boot for i.MX28 (from their LTIB distribution) onto an SD card. I set suitable U-Boot parameters for NFS booting with parameters from DHCP.
setenv bootargs console=ttyAMA0,115200n8
setenv bootargs_nfs setenv bootargs ${bootargs} root=/dev/nfs ip=dhcp nfsroot=,v3,tcp fec_mac=${ethaddr}
saveenv
I connected to a DD-WRT router with the following DNSmasq settings:
dhcp-boot=,,192.168.250.106
dhcp-option=17,"192.168.250.106:/home/craigm/rootfs"
On my host PC, I set up a TFTP server to serve the uImage file from ~/oe-core/freescale-arm/oe-core/build/tmp-eglibc/deploy/images/.
I also set up a root NFS server to serve the root file system. I edited /etc/exports to serve /home/craigm/rootfs. I extracted the root file system:
bitbake meta-ide-support
rm -Rf ~/rootfs
runqemu-extract-sdk tmp-eglibc/deploy/images/core-image-minimal-imx28evk.tar.bz2 ~/rootfs
Then I put the U-Boot SD card in the board's SD card slot 0, and powered-up. It got as far as this, then stopped:
...
TCP cubic registered
NET: Registered protocol family 17
can: controller area network core (rev 20090105 abi 8)
NET: Registered protocol family 29
can: raw protocol (rev 20090105)
mxs-rtc mxs-rtc.0: setting system clock to 1970-01-01 00:03:33 UTC (213)
eth0: Freescale FEC PHY driver [Generic PHY] (mii_bus:phy_addr=0:00, irq=-1)
eth1: Freescale FEC PHY driver [Generic PHY] (mii_bus:phy_addr=0:01, irq=-1)
Sending DHCP requests .
PHY: 0:00 - Link is Up - 100/Full
., OK
IP-Config: Got DHCP answer from 192.168.250.106, my address is 192.168.250.142
IP-Config: Complete:
device=eth0, addr=192.168.250.142, mask=255.255.255.0, gw=192.168.250.1,
host=192.168.250.142, domain=, nis-domain=(none),
bootserver=192.168.250.106, rootserver=192.168.250.106, rootpath=/home/craigm/rootfs
Looking up port of RPC 100003/3 on 192.168.250.106
Looking up port of RPC 100005/3 on 192.168.250.106
VFS: Mounted root (nfs filesystem) on device 0:15.
Freeing init memory: 160K
I'm not sure if it's running without a serial console, or some other problem. I can ping it on 192.168.250.142, but I can't Telnet or SSH to it.
Questions
Is there any sort of "getting started" guide for OpenEmbedded-Core on Freescale's i.MX28?
Is the Freescale ARM layer really intended for use with OpenEmbedded-Core, Yocto, or what? I don't really understand how those projects relate.
Has anyone else had success booting a minimal image of OpenEmbedded-Core on Freescale's i.MX28? If so, how did your procedure differ from mine?
I'm not sure at this stage whether the problem is just a non-functional serial console, or some other sort of issue. It's hard to diagnose these problems that prevent even getting a basic system running. Any pointers on how to diagnose at this point?
Why would the U-Boot be broken so it can't even boot?
From the boot message it looks like U-boot is working fine. U-boot is not broken.
The following boot message
2598200 bytes read
Booting from mmc ...
## Booting kernel from Legacy Image at 42000000 ...
Image Name: Linux-2.6.35.3-11.09.01+yocto-20
Created: 2012-08-23 7:53:40 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2598136 Bytes = 2.5 MiB
Load Address: 40008000
Entry Point: 40008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
By the above log u-boot has done its job.
"Booting the kernel" is the point where bootloader given the control to the kernel.
I guess the problem might be in kernel image or in memory.
To eliminate the problem of memory, try to check the manual and try to read and write in the RAM using the board's reference manual.
From the boot log RAM looks like has no problem. It has been initialized.
DRAM: 128 MiB
Check if the following message is not causing any problem.
* Warning - bad CRC, using default environment
Check if all the devices have been initialized and nothing is skipped after the bad crc warning.

Resources