Firefly Open Source Community

Title: Build everything from scratch [Print This Page]

Author: markwylde    Time: 3/14/2018 22:13
Title: Build everything from scratch
Last edited by markwylde In 3/14/2018 22:15 Editor

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
  1. sudo rkflashtool e 0 1000000
Copy the code

STEP 2: Download the following files:
  1. wget https://rawgit.com/rockchip-linux/rkbin/master/rk33/rk3399_ddr_666MHz_v1.08.bin
  2. wget https://rawgit.com/rockchip-linux/rkbin/master/rk33/rk3399_miniloader_v1.06.bin
  3. wget https://rawgit.com/rockchip-linux/rkbin/blob/master/img/rk3399/uboot.img
  4. wget https://rawgit.com/rockchip-linux/rkbin/blob/master/img/rk3399/trust.img
Copy the code



STEP 3: Use mkimage tool and merge miniloader to generate idbloader.img
  1. tools/mkimage -n rk3399 -T rksd -d rk3399_ddr_666MHz_v1.08.bin idbloader.img
  2. cat rk3399_miniloader_v1.06.bin >> idbloader.img
Copy the code



STEP 4: Use flashtool to upload idbloader.img
  1. sudo rkflashtool w 0x40 2000 < idbloader.img
Copy the code



STEP 5: Use flashtool to upload uboot.img
  1. sudo rkflashtool w 0x4000 2000 < uboot.img
Copy the code



STEP 6: Use flashtool to upload trust.img
  1. sudo rkflashtool w 0x6000 2000 < trust.img
Copy the code



Unfortunatly when I start restart the board my serial outputs:

  1. DDR Version 1.07 20161103
  2. In
  3. Channel 0: DDR3, 666MHz
  4. Bus Width=32 Col=10 Bank=8 Row=15/15 CS=2 Die Bus-Width=16 Size=2048MB
  5. Channel 1: DDR3, 666MHz
  6. Bus Width=32 Col=10 Bank=8 Row=15/15 CS=2 Die Bus-Width=16 Size=2048MB
  7. 256B stride
  8. ch 0 ddrconfig = 0x101, ddrsize = 0x2020
  9. ch 1 ddrconfig = 0x101, ddrsize = 0x2020
  10. pmugrf_os_reg[2] = 0x3AA17AA1, stride = 0xD
  11. OUT
  12. Boot1: 2016-07-29, version: 1.05
  13. CPUId = 0x0
  14. ChipType = 10 1836
  15. SdmmcInit=2 0
  16. BootCapSize=100000
  17. UserCapSize=119276MB
  18. FwPartOffset=2000 , 100000
  19. SdmmcInit=0 20
  20. StorageInit ok = 63256
  21. LoadTrustBL
  22. LoadTrustBL error:-1
  23. powerOn 476773
Copy the code



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


Author: cb182d    Time: 3/15/2018 18:38
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)
Author: markwylde    Time: 3/20/2018 07:02
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.
Author: cb182d    Time: 3/20/2018 09:32
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.

Author: maarten    Time: 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 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?
Author: cb182d    Time: 3/26/2018 13:07
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.
Author: maarten    Time: 3/31/2018 23:30
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?




Author: prozac    Time: 4/2/2018 11:06
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.
Author: voltagex    Time: 7/10/2019 19:38
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.

Author: adoroshoes    Time: 11/13/2024 18:25
With our exquisite collection of women formal shoes, you can up your style match. These stylish flats and heels, both beautifully made, will elevate your ensemble to new heights. Find the ideal pair that will improve the look of your satisfaction and leave a memorable impression.
Author: shopecs    Time: 11/13/2024 18:30
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!
Author: Gulaal    Time: 11/13/2024 19:42
Discover GulaalĄ¯s exquisite Pakistani bridal dresses, designed to make your special day unforgettable. Explore luxurious fabrics and intricate details for a perfect bridal look.
Author: cloudnexuslab    Time: 11/13/2024 20:39
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!
Author: Mushq    Time: 11/14/2024 14:28
Discover the allure of Mushq Official's velvet dress. From classic silhouettes to contemporary cuts, indulge in luxurious comfort and effortless style.
Author: qamaash    Time: 11/14/2024 15:13
Last edited by qamaash In 11/14/2024 15:14 Editor

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.
Author: afrozeh    Time: 11/14/2024 19:24
Check out the newest chiffon collection on our online store. Find chic and fashionable chiffon clothes to wear for every event. Shop now today.
Author: roheenazfsd    Time: 11/22/2024 19:09
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!
Author: tomcruis    Time: 11/26/2024 21:56
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.
Author: CrossStitch    Time: 6 day before
Discover the perfect new trouser design to elevate your style. Our new collection features the latest ladies trouser designs, blending fashion-forward looks with timeless sophistication. Explore the versatility of contemporary trouser silhouettes and find your ideal fit today.




Welcome Firefly Open Source Community (https://bbs.t-firefly.com/) Powered by Discuz! X3.1