How to make a SD card with bootloader

introduction

there are two ways to boot w2, controlled by SW4 image

  1. boot from emmc.
  2. boot from SPI + SD card.

After power on, there are 3 steps must be done before loading kernel,(Normally they all are called bootloader):

  • step 1: CPU init - the code is inside CPU;
  • step 2: init the flash device on which we boot from; (normally it’s called preloader)
  • step 3: u-boot;

RTD1296 supports booting from eMMC and SPI flash, so if we want to boot W2 from SD card, (that means we put u-boot on the SD card.) the second step code must be written to SPI flash, normally it’s done in factory before the board sending out, and the code is fixed and provided by RTK without source. We need not care about it, it does a simple job.

In fact, if the board will boot from eMMC, the second code must be written to eMMC first too, remember that we introduced how to do it with u-boot together on other pages. Normally it’s also been done in factory.

The u-boot for eMMC and SD card are different, normally eMMC u-boot 's name is dvrboot.exe.bin, and u-boot for SD card name is u-boot.bin.

Write u-boot to SD card

The u-boot file for booting from SD card is here: https://drive.google.com/drive/folders/17ShSHLOvxeYA6tI9HQXOAb3O7RjqfD_6?usp=sharing

step 1: build a SD card system according:

step 2: boot up the board with eMMC and press ‘Esc’ key to let board stays on u-boot prompt; step 3: using tftp to get u-boot.bin file from network;

       tftp 0x1500000 u-boot.bin

step4: using sd command to write it to SD card:

        sd write 0x1500000 0x50 0x3f0
1 Like

As alternative, under Linux u-boot.bin can be written to SD by

sudo dd if=u-boot.bin of=/dev/sdcard bs=$((0x200)) seek=$((0x50))

Replace ‘/dev/sdcard’ by actual device here!

But, this u-boot image wants DTB to be ‘sd.dtb’ and kernel ‘sd.uImage’.

And it doesn’t like those from https://drive.google.com/file/d/1LX4FwXcSzkuI4BUPEVxbUyeG_UYwIkwY/view

Boot log is https://pastebin.com/QAMt8JR9

Thanks. I success to make a bootable sd card, but there is a problem that @apxii also mentioned.

The system tries to load sd.dtb and sd.uImage. I try to rename bpi-w2.dtb to sd.dtb and uImage to sd.uImage. It boots and gets kernel panic.

Boot without rename https://pastebin.com/sfgrhX7X

Boot with rename https://pastebin.com/t3QjMrRM

Sorry, maybe I shared a wrong file, I have updated the link up, please download it again. And please remember to set env var of u-boot to default in u-boot by: env default …

Thanks! This works!

Can I ask you to supply also kernel modules with uImage?

And can you please recompile kernel with:

CONFIG_AUTOFS4_FS=m
CONFIG_NFS_FS=m
CONFIG_NFS_V2=m
CONFIG_NFS_V3=m
CONFIG_NFS_V3_ACL=y
CONFIG_NFS_V4=m
CONFIG_NFS_V4_SECURITY_LABEL=y
CONFIG_NFS_USE_KERNEL_DNS=y
CONFIG_NFSD=m
CONFIG_NFSD_V2_ACL=y
CONFIG_NFSD_V3=y
CONFIG_NFSD_V3_ACL=y
CONFIG_NFSD_V4=y
CONFIG_NFSD_PNFS=y
CONFIG_NFSD_BLOCKLAYOUT=y
CONFIG_NFSD_SCSILAYOUT=y
CONFIG_NFSD_FLEXFILELAYOUT=y
CONFIG_NFSD_V4_SECURITY_LABEL=y
CONFIG_NFSD_FAULT_INJECTION=y
CONFIG_NFS_ACL_SUPPORT=m
CONFIG_NFS_COMMON=y

(I’ve copied settings from 4.16, possible some diffs)

In short – enable NFS (client and server) and AUTOFS, and board can be used as NFS server.

It is important to have Autofs as module since Debian scripts wanted it to be a module.

It works, but I have some problem. It doesn’t work every time. My w2 got about 50% boots fail. It shows kernel panic or just hangs.

I had changed different sd card. Do I get a broken board?

It doesn’t hang at the same position.

This is one of fail boot log. https://pastebin.com/3MPFDLpS

kernel panic log. https://pastebin.com/0pF6RWra

I rebuilt the kernel with the configs, please re-download it and try.

You were using the kernel which is debugging version, please re-download which I have updated.

Thanks! Autofs and NFS are working.

I have no problems with latest (2018.05.23) kernel and u-boot, board reboots fine.

But I’m using a freshly bootstrapped Debian Unstable and not Ubuntu.

Sadly. I use the newest uImage which is in this topic, but it still boot fail almost every times. (I need to keep reboot and hope there are one time to boot into system. I need to reboot about 20 to 30 times and it may successes boot. rarely)

I get different kernel panic message when boot failed. I had tested different SD card.

But this board can boot to openWrt which in emmc.

I’m really thinking that is this a broken board or what I did wrong.

different fail message https://pastebin.com/vhN72UXy https://pastebin.com/S5Uqen8R https://pastebin.com/6h94a201 (stuck here and not continue https://pastebin.com/hBfi0Stf

Could you please flash the newest u-boot to emmc and boot from it, which will load system from SD card firstly, to test if it works? The u-boot for emmc name is dvrboot.exe.bin.

I don’t fully understand step 3. I’ve downloaded u-boot.bin using my Windows PC, but I’m not sure where to put it for this step. Can you please clarify for me. Thanks.

This is my result of executing tftp:

BPI-W2> tftp 0x1500000 u-boot.bin
Using r8168#0 device
TFTP from server 192.168.100.2; our IP address is 192.168.100.1
Filename 'u-boot.bin'.
Load address: 0x1500000
Loading: T T T T T T T T T T
Retry count exceeded; starting again
BPI-W2>

Here is full output of reboot with ESC key:

  C1:80000000
C2
?
C3hswitch frequency to 0x00000046
frequency divider is 0x00000080
switch frequency to 0x00000046
frequency divider is 0x00000004
switch to SDR 8 bit
switch bus width to 0x00000008 bits success

hwsetting size: 00000BE4
C4
f
5-5
s_f
5-5-2
Goto FSBL: 0x10100000
switch frequency to 0x00000046
frequency divider is 0x00000080
switch frequency to 0x00000046
frequency divider is 0x00000004
emmc_cid[3] = 0xE9547849 emmc_cid[2] = 0xDD650152 emmc_cid[1] = 0x34454D47 emmc_
cid[0] = 0x38000115
switch bus width to 0x00000008 bits success
DEVICE_TYPE = 00000057
emmc_sec_count = 00E90000
switch speed to 0x00000002 success
switch frequency to 0x000000A6
frequency divider is 0x00000000
1st TX_window = 0xFFFFFFDE
1st phase TX VP0= 0x00000012
RX_window = 0xFFFFFC03
phase RX VP1= 0x00000015
Welcome to FSBL ...
[FSBL] Warm Boot: 0x00000000
[FSBL] Secure: 0x0000BEEE
[FSBL] Flash Type: 0x00000002
[FSBL] DCache Enable: 0x00000000
[FSBL] SVP = N
********** FW_TYPE_GOLD_TEE **********
    FW Image to 0x10200000, size=0x0007BDA0 (0x1027BDA0)
    FW Image fr 0x000B0600
********** FW_TYPE_GOLD_BL31 **********
    FW Image to 0x10120000, size=0x000062A0 (0x101262A0)
    FW Image fr 0x0012C400
********** FW_TYPE_BOOTCODE **********
    FW Image to 0x00020000, size=0x0007DC20 (0x0009DC20)
    FW Image fr 0x00020E00
md copy audio bin
VERBOSE: bl31_setup
NOTICE:  BL31: v1.2(debug):a6c9ab6
NOTICE:  BL31: Built : 15:16:22, Apr 27 2017
INFO:    BL31: Initializing runtime services
INFO:    Start to init service std_svc
INFO:    Finish to init service std_svc
INFO:    Start to init service opteed_fast
INFO:    Finish to init service opteed_fast
INFO:    BL31: Initializing BL32
INFO:    TEE-CORE: TEE OS v2.1
INFO:    TEE-CORE: TA RAM slim vesion.
INFO:    TEE-CORE: Skipping to check tee os version.
INFO:    TEE-CORE: Initializing (9a5884c #1 四 12月  7 17:26:20 CST 2017 aarch
64)
MESSAGE: [0x0] TEE-CORE:tee_otp_get_hw_unique_key:70: ************************
   tee_otp_get_hw_unique_key chip id: 30000
MESSAGE: [0x0] TEE-CORE:tee_otp_get_hw_unique_key:75: ************************
   tee_otp_get_hw_unique_key used Kf
INFO:    TEE-CORE: teecore inits done
INFO:    Core_0 TEESMC_OPTEED_RETURN_ENTRY_DONE
INFO:    Core_0 got optee_vectors (0x1020093c)
INFO:    BL31: Initialized BL32
INFO:    EXIT BL31
INFO:    bl31_to_kernel: kernel_resume_entry = 0x1e000
INFO:    bl31 jumps to EL2: LK entry


U-Boot 2015.07 (May 15 2018 - 22:44:59 +0800)

CPU  : Cortex-A53 Quad Core - AARCH64
Board: Realtek QA Board
DRAM:  2 GiB
Watchdog: Disabled
mapping memory 0x20000000-0x40000000 non-cached
flushing dcache successfully.
nor flash id [0x00ef4018]
sector 256k en: 0
sector  64k en: 1
sector  32k en: 1
sector   4k en: 1
page_program  : 1
max capacity  : 0x01000000
spi type name : WINBOND_W325Q128BV_128Mbit
MMC:   Initialize eMMC in traditional mmc flow.
RTD1295 eMMC: 0
rsp[0]=0x15010038,
                       rsp[1]=0x474d4534,
                       rsp[2]=0x520165dd,
                       rsp[3]=0x497854e9
The cid_val is 15.
rsp[0]=0xd0270132,
                       rsp[1]=0x0f5903ff,
                       rsp[2]=0xf6dbffef,
                       rsp[3]=0x8e40400d
mmc->version=0x40000000
version=0x00000004
[LY] cardtype=57, mmc->card_caps=0f
[LY] freq = 00464388, clk diver = 00000080
[LY] speed up emmc at HS-200
[LY] HS-200 bus width=2
[LY] mmc->boot_caps = 20b
TEMP TX_WINDOW=0xffffffde, TX_best=0x12
RX_WINDOW=0xfffffc03, RX_best=0x15
TX1_WINDOW=0x7fffff80, TX_best=0x12
[LY] hs200 : 0
[HC] ERASE Unit Size = 524288 bytes
[HC] WPG_SIZE = 8388608 bytes
Device: RTD1295 eMMC
Manufacturer ID: 15
OEM: 100
Name: 8GME4
Tran Speed: 200000000
Rd Block Len: 512
MMC version 4.0
High Capacity: No
Capacity: 7.3 GiB
User Capacity: 7.3 GiB
Boot Capacity: 4 MiB
RPMB Capacity: 512 KiB
Bus Width: 8-bit
Speed: HS200
SD:
SD device index# 0
Factory: MMC
Factory: pp:1, seq#:0x1a, size:0x22000
------------can't find tmp/factory/000BootParam.h
In:    serial
Out:   serial
Err:   serial
HDMITx_HPD=False
------------tmp/factory/video_rpc.bin found
EDID checksum: read 00 00, last 8e 00
Sink changed, skip ONE_STEP_RPC
tv_system=25 mode=1
Net:   Realtek PCIe GBE Family Controller mcfg = 0024
dev->name=r8168#0
Checking default environment
Hit Esc or Tab key to enter console mode or rescue linux:  0
------------can't find tmp/factory/recovery

Press Esc Key

Enter console mode, disable watchdog ...

BPI-W2> mmcinfo
Device: RTD1295 eMMC
Manufacturer ID: 15
OEM: 100
Name: 8GME4
Tran Speed: 200000000
Rd Block Len: 512
MMC version 4.0
High Capacity: No
Capacity: 7.3 GiB
Bus Width: 8-bit
Erase Group Size: 256 MiB
BPI-W2> tftp 0x1500000 u-boot.bin
Using r8168#0 device
TFTP from server 192.168.100.2; our IP address is 192.168.100.1
Filename 'u-boot.bin'.
Load address: 0x1500000
Loading: T T T T T T T T T T
Retry count exceeded; starting again
BPI-W2>

I had re flashed dvrboot.exe.bin which is include in this topic google drive, but the problem still happened.

Different kernel panic message randomly shows, or hangs at cpu freq message.

You need to set a tftp server and let your board can access through network.

  1. Set a tftp server. If you use windows, you can try Tftpd32.
  2. Connect a network wire from your board to your computer or switch which your computer is connected too.
  3. Press esc and boot
  4. “env print” can show your settings. Check ipaddr and serverip is correct. (Board and your computer need at same subnet)
  5. If not (EX: your computer is 192.168.1.5), you can use “setenv " to change” (Ex: setenv serverip 192.168.1.5. setenv ipaddr 192.168.1.10)

Then you can try to download file from your computer through tftp protocol.

The issue you met is caused by CPU got wrong instruction, normally it should be one of three reasons:

  1. CPU or cache within it is not stable;
  2. DDR is not stable;
  3. Got wrong data from SD card;

Since you said openwrt works fine, so could you please check SD partition 1 type and formatting, is it Fat32? And mount it on openwrt to do some reading tests?

The boot partition is fat32, and I had put my sd card and run badblocks. It’s fine.

I also try to use different sd card but I get the same result.

https://pastebin.com/MqV6b7qf

I am on business trip in Australia now, will do some test when back to office next week.

hello,

I seem to have the same problem as Jalen. However, only cold system occurs with me. Once the processor has warmed up, it is fully initialized by the kernel. I hope this does not indicate a hardware error on the board.

Furthermore, I noticed that the LEDs of eth0 (interface next to usb3.0) are without any function.

Is this behavior with you too?

Is there a schematic of the board to download?

Is it possible to download the kernel source? I would like to work under Debian.

Best regards