Build everything from scratch

Hello

I have a RK3399 Firefly and have wiped the eMMC (from offset 0 to the end) using the rkflashtool. Therefore I believe the eMMC is completly empty.

My end goal is to build everything from source, but until then I’m simply trying to get the RK3399 binaries to work.

STEP 1: Wipe everything on the eMMC

sudo rkflashtool e 0 1000000

STEP 2: Download the following files:

wget https://rawgit.com/rockchip-linux/rkbin/master/rk33/rk3399_ddr_666MHz_v1.08.bin
wget https://rawgit.com/rockchip-linux/rkbin/master/rk33/rk3399_miniloader_v1.06.bin
wget https://rawgit.com/rockchip-linux/rkbin/blob/master/img/rk3399/uboot.img
wget https://rawgit.com/rockchip-linux/rkbin/blob/master/img/rk3399/trust.img

STEP 3: Use mkimage tool and merge miniloader to generate idbloader.img

tools/mkimage -n rk3399 -T rksd -d rk3399_ddr_666MHz_v1.08.bin idbloader.img
cat rk3399_miniloader_v1.06.bin >> idbloader.img

STEP 4: Use flashtool to upload idbloader.img

sudo rkflashtool w 0x40 2000 < idbloader.img

STEP 5: Use flashtool to upload uboot.img

sudo rkflashtool w 0x4000 2000 < uboot.img

STEP 6: Use flashtool to upload trust.img

sudo rkflashtool w 0x6000 2000 < trust.img

Unfortunatly when I start restart the board my serial outputs:

DDR Version 1.07 20161103
In
Channel 0: DDR3, 666MHz
Bus Width=32 Col=10 Bank=8 Row=15/15 CS=2 Die Bus-Width=16 Size=2048MB
Channel 1: DDR3, 666MHz
Bus Width=32 Col=10 Bank=8 Row=15/15 CS=2 Die Bus-Width=16 Size=2048MB
256B stride
ch 0 ddrconfig = 0x101, ddrsize = 0x2020
ch 1 ddrconfig = 0x101, ddrsize = 0x2020
pmugrf_os_reg[2] = 0x3AA17AA1, stride = 0xD
OUT
Boot1: 2016-07-29, version: 1.05
CPUId = 0x0
ChipType = 10 1836
SdmmcInit=2 0
BootCapSize=100000
UserCapSize=119276MB
FwPartOffset=2000 , 100000
SdmmcInit=0 20
StorageInit ok = 63256
LoadTrustBL
LoadTrustBL error:-1
powerOn 476773

I don’t understand what the LoadTrustBL error means. Could it not find the trust img or was it corrupt?

Thanks for any help you can provide.

Mark Wylde

I personally recommend using rockchip u-boot instead of firefly u-boot.

First sync rockchip repos:

repo init --repo-url=https://github.com/rockchip-linux/repo -u https://github.com/rockchip-linux/manifests -b master
repo sync

build u-boot and flash the images to emmc:

build/mk-uboot.sh rk3399-firefly
rkdeveloptool wl 0x40 idbloader.img
rkdeveloptool wl 0x4000 uboot.img
rkdeveloptool wl 0x6000 trust.img

Now you can power on the device, use serial console to stop auto booting (hit any key before it proceeds), and write partitions tables with u-boot shell:
gpt write mmc 0 $partitions

After writing the partition table, connect the usb-c to your PC and use u-boot command “ums 0 mmc 0” to mount the emmc as mass storage, and there will be /dev/sdX1-sdX7, which is the default partition layout for RK3399.

You only need to care about sdX6 and sdX7, sdX6 is boot partition and sdX7 is rootfs.
Format sdX6 as fat32 or ext2 and place extlinux/extlinux.conf, kernel and dtb files there. (reference: http://opensource.rock-chips.com/wiki_Rockchip_Kernel)
sdX7 can be used as rootfs then. (ext4 or whatever your kernel supports. This should be specified in boot parameters, in extlinux.conf)

cb182d Posted at 3/15/2018 18:38
I personally recommend using rockchip u-boot instead of firefly u-boot.

First sync rockchip repos …

@cb182d thank you so much for your help. It’s now getting further and to uboot. Still not at the stage of getting linux to boot, but at least it’s getting past the bootloader error to things I can manage.

I’ll post my full steps from a blank eMMC to working linux when I have it recreatable.

markwylde Posted at 3/20/2018 07:02
@cb182d thank you so much for your help. It’s now getting further and to uboot. Still not at the s …

Getting Linux working is relatively easy, you can even try to install mainline Debian buster on top of that (mount ext2 mmcblk1p6 on /boot, mmcblk1p7 on /, then just apt install flash-kernel linux-image-4.15-arm64), though it is only useful when you are planning a headless deploy and I haven’t tried myself yet.

The most functional kernel is the Firefly kernel (https://gitlab.com/TeeFirefly/linux-kernel)
Just build this repo and copy arch/arm64/boot/Image and arch/arm64/boot/dts/rockchip/rk3399-firefly-linux.dtb to mmcblk1p6 (ext2) and create extlinux.conf

In case you have the following file layout

/boot
|-- Image
|-- extlinux
| -- extlinux.conf – rk3399-firefly-linux.dtb

Then the extlinux.conf should be

label kernel
kernel /Image
fdt /rk3399-firefly-linux.dtb
append earlyprintk console=ttyFIQ0,115200 rw root=PARTUUID=b921b045-1d rootfstype=ext4 init=/sbin/init rootwait

the arg “PARTUUID=b921b045-1d” is the default partition UUID of “/dev/mmcblk1p7” when you create the gpt partition table on emmc with “gpt write mmc 0 $partitions” in u-boot.
This seems to be the only way to specify the root partition. I tried root=/dev/mmcblk1p7 but the kernel failed to locate the partition.

Thanks a lot for these hints @cb182d! I have two questions:

  1. when you say it’s only useful for a headless setup is that because the display drivers are not expected to work? Or are there other things that won’t work?

  2. With this setup will I be able to flash kernel updates with a regular apt-get update from the repos?

maarten Posted at 3/26/2018 10:50
Thanks a lot for these hints @cb182d! I have two questions:

  1. when you say it’s only useful for …

Display, GPU and VPU will not work with mainline kernel. (check http://opensource.rock-chips.com/wiki_Status_Matrix)
The big.LITTLE scheduling will not work either, CPU-bound tasks will not be pinned to Cortex-A72 cores, resulting unstable performance.
I haven’t tested others by myself, because I only succeeded to boot into mainline Debian once and ssh into it.

For updating the kernel, if you use Debian packages (install both linux-image-*-arm64 and flash-kernel package), you will be able to update the kernel using apt, and “flash-kernel” package will generate everything needed in /boot partition. You don’t need, and shouldn’t, create extlinux.conf if you plan to use flash-kernel.

I’ve flashed the files created by “build/mk-uboot.sh rk3399-firefly” as described above, but I’m getting exactly the same error as @markwylde first reported: “LoadTrustBL error:-1”.

@markwylde, did the above steps resolve the problem for you immediately, or were there other issues to be fixed?

if you are still having an issue, I found the following:
In MASKROM mode, you flash uboot to 0x4000 and trust to 0x6000 (you will only be in this mode if you erased all flash or if you pressed jumpered the onboard emmc
In RKUSB mode, you flash uboot to 0x2000 and trust to 0x4000

Either way, the version of uboot being currently built from the rockchip repos creates 6 paritions (0-5), not the 7 mentioned above. Tou need to format/upload the kernel/dtb/extlinux config to partition 5 (sdX4) and the root filesystem to partition 6 (sdX5). After that, things should work more or less as mentioned above.

Just a note to anyone googling for this:
The mk-uboot.sh script will fail because the rkbin repository has been updated and the structure and files don’t match what’s needed by the script. You could replace the repository with https://github.com/respeaker/rkbin but I haven’t tested this.

Files needed:
rkbin/rk33/rk3399_ddr_800MHz_v1.08.bin - deleted upstream and replaced with new versions as of November 2017
rkbin/rk33/rk3399_miniloader_v1.06.bin - deleted upstream and replaced with new versions as of May 2017.

The restructure from rkbin/rk33 to rkbin/bin/rk33 happened, too.

Elevate your scent game with ECS’s best perfume for men. Discover top-notch fragrances tailored to enhance your style. Shop now and find your signature scent!

Discover Cloud Nexus Lab, your premier solution provider for NetSuite Support. Our expert team offers tailored assistance to optimize your NetSuite experience, ensuring seamless integration and performance. Maximize your business potential with our comprehensive support services designed for efficiency and growth. Contact us today for expert NetSuite solutions!

Discover the allure of Mushq Official’s velvet dress. From classic silhouettes to contemporary cuts, indulge in luxurious comfort and effortless style.

Discover the perfect ready to wear wedding dresses and Pakistani fashion in the UK with Qamaash. Find the latest trends and styles in ready-to-wear fashion today.

Check out the newest chiffon collection on our online store. Find chic and fashionable chiffon clothes to wear for every event. Shop now today.

See what’s in Roheenaz’s new winter collection! Find the latest warm and trendy outfits that will refresh your winter wardrobe. Stay stylish and comfortable with our newest arrivals!

Buy Pakistani ladies casual wear, Pakistani salwar kameezhttps://rangjah.com/collections/casual-pret casual suits for women, and salwar kameez online in the UK, USA, Canada, Australia, Italy & Europe.

Explore the ethereal beauty of chiffon with Mushq Official. Discover lightweight fabrics that embody elegance and grace, perfect for every occasion.

Find your perfect silk dress design at Mushq. We offer a wide range of silk dresses in Pakistan to suit any occasion. Shop now and elevate your style with our luxurious silk dresses.

Explore the new dress design for women in Pakistan from Mushq Official. Check out our handpicked selection of stylish and trendy outfits, including both traditional and modern styles. Find the perfect outfit to upgrade your wardrobe.

Are you looking for best ladies Pump Shoes Online? essence Offer their costumer best pump shoes for women that are best in quality and Comfort. Shop Now!