Firefly Open Source Community

   Login   |   Register   |
New_Topic
Print Previous Topic Next Topic

Build everything from scratch

16

Credits

0

Prestige

0

Contribution

new registration

Rank: 1

Credits
16

Build everything from scratch

Posted at 3/14/2018 22:13:10      View:12814 | Replies:8        Print      Only Author   [Copy Link] 1#
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

Reply

Use props Report

112

Credits

10

Prestige

12

Contribution

registered members

Rank: 2

Credits
112
Posted at 3/15/2018 18:38:26        Only Author  2#
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)
已有 1评分Prestige +10 Money +11 Contribution +12 Pack up reason
markwylde + 10 + 11 + 12

View all ratings

Reply

Use props Report

16

Credits

0

Prestige

0

Contribution

new registration

Rank: 1

Credits
16
Posted at 3/20/2018 07:02:15        Only Author  3#
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.
Reply

Use props Report

112

Credits

10

Prestige

12

Contribution

registered members

Rank: 2

Credits
112
Posted at 3/20/2018 09:32:52        Only Author  4#
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.
Reply

Use props Report

62

Credits

0

Prestige

0

Contribution

registered members

Rank: 2

Credits
62
Posted at 3/26/2018 10:50:17        Only Author  5#
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?
Reply

Use props Report

112

Credits

10

Prestige

12

Contribution

registered members

Rank: 2

Credits
112
Posted at 3/26/2018 13:07:12        Only Author  6#
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.
Reply

Use props Report

62

Credits

0

Prestige

0

Contribution

registered members

Rank: 2

Credits
62
Posted at 3/31/2018 23:30:59        Only Author  7#
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?



Reply

Use props Report

18

Credits

0

Prestige

0

Contribution

new registration

Rank: 1

Credits
18
Posted at 4/2/2018 11:06:26        Only Author  8#
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.
Reply

Use props Report

17

Credits

0

Prestige

0

Contribution

new registration

Rank: 1

Credits
17
Posted at 7/10/2019 19:38:13        Only Author  9#
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.
Reply

Use props Report

You need to log in before you can reply Login | Register

This forum Credits Rules

Quick Reply Back to top Back to list