# Rockchip RK3399 USB

**URL:** <https://genode.discourse.group/t/rockchip-rk3399-usb/51>\
**Category:** Hardware\
**Tags:** arm, arm64\
**Created:** [August 31, 2024, 10:17am UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51 "2024-08-31T10:17:32Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![micken](https://dub1.discourse-cdn.com/flex006/user_avatar/genode.discourse.group/micken/32/22_2.png) [@micken](https://genode.discourse.group/u/micken)\
**Post date:** [August 31, 2024, 10:17am UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/1 "2024-08-31T10:17:32Z")

</div>

I have started doing Rockchip ( rk3399 to start with). I have built the driver. I don’t know how it would work, but I am facing a dtb issue. I only get a empty dts file. I have been trying to follow the allwinner port, but no luck. So the question of today is: What do I need to do in order to get a dts. I have dts extracting in usb\_host/rk3399/target.mk and also the paths to the rk3399 and pinebooks dts files. I wonder … can it be that I ask for wrong selection? I am going to try that now. Since I tend to write a lot I thought a forum thread is better than spamming the maillist 🙂

---

<div class="post-metadata">

**Author:** ![micken](https://dub1.discourse-cdn.com/flex006/user_avatar/genode.discourse.group/micken/32/22_2.png) [@micken](https://genode.discourse.group/u/micken)\
**Post date:** [August 31, 2024, 11:02am UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/2 "2024-08-31T11:02:57Z")

</div>

I get this from the dtb creation part:

> LINK rk3399\_usb\_host  
> genode-aarch64-cpp: internal compiler error: in do\_spec\_1, at gcc.cc:6087

Not so good , if you ask me… I have the 23.05 toolchain. If I hit make again , I don’t get that error , but from what I understand the preprocessor is needed.

---

<div class="post-metadata">

**Author:** ![nfeske](https://dub1.discourse-cdn.com/flex006/user_avatar/genode.discourse.group/nfeske/32/6_2.png) [@nfeske](https://genode.discourse.group/u/nfeske)\
**Post date:** [August 31, 2024, 11:03am UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/3 "2024-08-31T11:03:47Z")

</div>

To follow the lines of the Allwinner work, I recommend reading my article [Taking Linux out for a Walk](http://genodians.org/nfeske/2021-05-12-pine-fun-linux) (in particular the Section [Device-tree treasure trove](http://genodians.org/nfeske/2021-05-12-pine-fun-linux#Device-tree_treasure_trove)) as well as the article [Pruning device trees](http://genodians.org/nfeske/2021-05-19-pine-dts-pruning). Once you get useful results by using the tool/dts/extract tool manually, the make rules will hopefully become more clear.

---

<div class="post-metadata">

**Author:** ![micken](https://dub1.discourse-cdn.com/flex006/user_avatar/genode.discourse.group/micken/32/22_2.png) [@micken](https://genode.discourse.group/u/micken)\
**Post date:** [August 31, 2024, 12:19pm UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/4 "2024-08-31T12:19:38Z")

</div>

> Once you get useful results by using the tool/dts/extract tool manually, the make rules will hopefully become more clear.

Thanks! I could do it manually. The reason for ICE error is unknown since it worked manually. Same command line. Then the extract failed because of several labels had sub labels that the tool recognized as labels. I hand edited the flat file and the result look good. I now have a dtb file.

To summarize the ICE is still a mystery: IF it hasen’t got a file path to start with… and even if that worked the extract part will fail because of the aliases.

---

<div class="post-metadata">

**Author:** ![micken](https://dub1.discourse-cdn.com/flex006/user_avatar/genode.discourse.group/micken/32/22_2.png) [@micken](https://genode.discourse.group/u/micken)\
**Post date:** [August 31, 2024, 12:39pm UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/5 "2024-08-31T12:39:41Z")

</div>

Next up:

> icken@minimonster:~/src/Genode/git4/genode/build/arm\_v8a$ make drivers/platform/rk3399 BOARD=rk3399 KERNEL=hw  
> Program drivers/platform/rk3399/rk3399\_platform  
> micken@minimonster:~/src/Genode/git4/genode/build/arm\_v8a$ ls drivers/platform/rk3399/  
> micken@minimonster:~/src/Genode/git4/genode/build/arm\_v8a$

I have platform in my archives file and as you can see it says "Proogram … " but the directory is empty. In fact none of the drivers in archives are built from drivers-interactive… test-case run/demo

Found it!

---

<div class="post-metadata">

**Author:** ![micken](https://dub1.discourse-cdn.com/flex006/user_avatar/genode.discourse.group/micken/32/22_2.png) [@micken](https://genode.discourse.group/u/micken)\
**Post date:** [August 31, 2024, 2:01pm UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/6 "2024-08-31T14:01:34Z")

</div>

> [init → drivers] child “report\_rom” announces service “Report”  
> [init → drivers] child “report\_rom” announces service “ROM”  
> [init → drivers] child “platform\_drv” announces service “Platform”  
> [init → drivers → gui\_fb] — rk3399 fb driver —  
> [init → drivers → gui\_fb] fb init: 0  
> [init → drivers → gui\_fb] fb cfg: 0  
> [init → drivers → gui\_fb] win0en: 0x3a000081  
> [init → drivers → gui\_fb] act info: 0xef013f  
> [init → drivers → gui\_fb] fb init2: 0x0  
> [init → drivers → gui\_fb] fbset: 0x46400000  
> [init → drivers → gui\_fb] vop sys: 0x20805800  
> [init → drivers] child “usb\_drv” announces service “Usb”  
> [init → drivers] child “event\_filter” announces service “Event”  
> [init → drivers → usb\_drv] Error: Initcall \_\_initcall\_timer\_sysctl\_init6 unknown in initcall database!  
> [init → drivers → usb\_drv] Error: Initcall \_\_initcall\_vsprintf\_init\_hashval4 unknown in initcall database!  
> [init → drivers → usb\_drv] kmem\_cache\_create\_usercopy() failed with error -22  
> [init → drivers → usb\_drv] Error: Function dump\_stack not implemented yet!  
> [init → drivers → usb\_drv] backtrace “ep”  
> [init → drivers → usb\_drv] 404fed68 1076fc8  
> [init → drivers → usb\_drv] 404fee38 1077074  
> [init → drivers → usb\_drv] 404fee98 10389e0  
> [init → drivers → usb\_drv] 404feed8 1087af4  
> [init → drivers → usb\_drv] 404feee8 108b924  
> [init → drivers → usb\_drv] 404fef58 10790e4  
> [init → drivers → usb\_drv] 404fef98 1086078  
> [init → drivers → usb\_drv] Will sleep forever…  
> [init → scout] png is 101x92 depth=8

It loads , missing things but still progress 🙂  
When it works I need somehow make the build work without hacks… shouldn’t be difficult except for the dtb thing.

---

<div class="post-metadata">

**Author:** ![micken](https://dub1.discourse-cdn.com/flex006/user_avatar/genode.discourse.group/micken/32/22_2.png) [@micken](https://genode.discourse.group/u/micken)\
**Post date:** [August 31, 2024, 9:06pm UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/7 "2024-08-31T21:06:09Z")

</div>

> [init → drivers → usb\_drv] NR\_IRQS: 64, nr\_irqs: 64, preallocated irqs: 0  
> [init → drivers → usb\_drv] clocksource: dde\_counter: mask: 0xffffffffffffff max\_cycles: 0x1d854df40, max\_ids  
> [init → drivers → usb\_drv] sched\_clock: 64 bits at 1000kHz, resolution 1000ns, wraps every 2199023255500ns  
> [init → drivers → usb\_drv] clocksource: jiffies: mask: 0xffffffff max\_cycles: 0xffffffff, max\_idle\_ns: 7645s  
> [init → drivers → usb\_drv] platform ff770000.syscon:phy@f780: Fixing up cyclic dependency with fe330000.mmc  
> [init → drivers → usb\_drv] usbcore: registered new interface driver usbfs  
> [init → drivers → usb\_drv] usbcore: registered new interface driver hub  
> [init → drivers → usb\_drv] usbcore: registered new device driver usb  
> [init → drivers → usb\_drv] Warning: lx\_emul\_random\_gen\_bytes: dummy implementation used, filling buffer wits  
> [init → drivers → usb\_drv] clocksource: Switched to clocksource dde\_counter  
> [init → drivers → usb\_drv] usbcore: registered new interface driver genode  
> [init → drivers → usb\_drv] ehci-platform fe380000.usb: error -6: IRQ index 0 not found

> Getting there! I wonder IRQ index 0?

OK so it doesn’t get the irq number from its platform device. Sounds odd

The only answer duck and google gives me is that it might be a error in dts… but it looks ok

---

<div class="post-metadata">

**Author:** ![micken](https://dub1.discourse-cdn.com/flex006/user_avatar/genode.discourse.group/micken/32/22_2.png) [@micken](https://genode.discourse.group/u/micken)\
**Post date:** [September 2, 2024, 11:13am UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/8 "2024-09-02T11:13:03Z")

</div>

> [@micken](#):
>
> NR\_IRQS: 64, nr\_irqs: 64, preallocated irqs: 0

This looks suspicious. Is this the number of interrupts on my platform? I have 148 SPI.

I found this code in Genode:

> unsigned max\_irq() { return 32 \* (readTyper::It\_lines\_number() + 1) - 1; }

I wonder what that resolves to.

The error message comes from drivers/base/platform.c . If I hardcode a IRQ I get a another error … ~ can’t add device with irq $IRQ.

To add to this is that Genode unmask is only called when timer is initialised. So if the timer should interrupt repeatable interrupts doesn’t work. Unmask timer doesn’t happen unless I mask everything

> msr DAIFSet, #0b1111

I have tried to clear it , unmask it right after timer does unmask. But no luck. I guess timer wasn’t runnig if irqs was on during boot.

Interrupts worked for USB on RK3588, but back then I hacked something together from the old iMX8 code, and that isn’t possible using todays git.  
Another issue is that it doesn’t boot at all with disable\_mmu in boostrap crt0.s. I already mentioned that and it really puzzles me. I found out that I had this commented out in the bootstrap I used for RK3588. Probably not related to interrupts.

I am running unpatched mainline u-boot.

It would be great if someone could tell me how I need to patch mainline in order to boot uImage. That piece of code thus a few things before “go”. I can’t figure out what I need to do during system startup.

---

<div class="post-metadata">

**Author:** ![micken](https://dub1.discourse-cdn.com/flex006/user_avatar/genode.discourse.group/micken/32/22_2.png) [@micken](https://genode.discourse.group/u/micken)\
**Post date:** [September 2, 2024, 2:58pm UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/9 "2024-09-02T14:58:15Z")

</div>

Ok so starting with uImage … actually starts. BUT it doesn’t help much because it fails probably because mmu is off … that is the same thing that happens if mmu\_disable… gnargle ☹  
It seems that I can’t change category. for this thread.

---

<div class="post-metadata">

**Author:** ![ttcoder](https://dub1.discourse-cdn.com/flex006/user_avatar/genode.discourse.group/ttcoder/32/9_2.png) [@ttcoder](https://genode.discourse.group/u/ttcoder)\
**Post date:** [September 2, 2024, 3:10pm UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/10 "2024-09-02T15:10:04Z")

</div>

> [@micken](#):
>
> It seems that I can’t change category. for this thread.

Done ^^  
If that didn’t break thing up I’ll apply the same method for other threads tomorrow.

---

<div class="post-metadata">

**Author:** ![micken](https://dub1.discourse-cdn.com/flex006/user_avatar/genode.discourse.group/micken/32/22_2.png) [@micken](https://genode.discourse.group/u/micken)\
**Post date:** [September 2, 2024, 8:57pm UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/11 "2024-09-02T20:57:40Z")

</div>

OK so here is a more in depth debugging session:  
The boostrap stack is defined to a region defined in bootstrap/init.cc

> static constexpr size\_t STACK\_SIZE = 0x2000;  
> size\_t bootstrap\_stack\_size = STACK\_SIZE;  
> uint8\_t bootstrap\_stack[Board::NR\_OF\_CPUS][STACK\_SIZE]  
> **attribute** ((aligned(get\_page\_size())));

It happens to be that X1 points to SP. when entering Memory\_region constructor.  
The crashing instruction is:

> 3c810420 str q0, [x1], #16

Which gives alignment fault:

> ESR 0x96000061

So why is it not aligned?

---

<div class="post-metadata">

**Author:** ![micken](https://dub1.discourse-cdn.com/flex006/user_avatar/genode.discourse.group/micken/32/22_2.png) [@micken](https://genode.discourse.group/u/micken)\
**Post date:** [September 2, 2024, 9:27pm UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/12 "2024-09-02T21:27:45Z")

</div>

I was tired so that error was because of Genode::raw in init. Sorry  
😕

I am still facing the alignment fault. The default pagesize is 4096 so that hack added nothing 🙂 I have checked where stack is and x1 is in that region if I still can do basic arithmetic 🙂

Memory\_region is used 3 times in the Platform::Board::Board() constructor.  
I bet it is the last of them that fails, something for tomorrow.

---

<div class="post-metadata">

**Author:** ![micken](https://dub1.discourse-cdn.com/flex006/user_avatar/genode.discourse.group/micken/32/22_2.png) [@micken](https://genode.discourse.group/u/micken)\
**Post date:** [September 3, 2024, 11:49am UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/13 "2024-09-03T11:49:52Z")

</div>

The problem is, I can’t access ram if atomic load to a word register. Which means that Genode::raw doesn’t work without mmu on. Is this a compiler issue? Genode::raw calls cxa\_guard\_acquire, which crashes.

I have this line in crt0.s (boostrap) as a test and it crashes.

> ldxr w3,[x1]

ESR:

> 0x96000035

No problem if MMU is on, I expect that u-boot uses a 1:1 map, since I can write to hw regs, and Genode boots to graphics.

This doesn’t explain the alignment fault in Memory\_region.

_updating toolchain_

Unfortunately I am at latest already ☹

---

<div class="post-metadata">

**Author:** ![micken](https://dub1.discourse-cdn.com/flex006/user_avatar/genode.discourse.group/micken/32/22_2.png) [@micken](https://genode.discourse.group/u/micken)\
**Post date:** [September 3, 2024, 2:27pm UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/14 "2024-09-03T14:27:28Z")

</div>

I am soo happy  
Turns out that the recent release works! Git from last week didn’t.

But no usb yet… at least the system starts without mmu, very good.

---

<div class="post-metadata">

**Author:** ![jjkarcher](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@jjkarcher](https://genode.discourse.group/u/jjkarcher)\
**Post date:** [September 3, 2024, 9:52pm UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/15 "2024-09-03T21:52:28Z")

</div>

Congratulations! That’s great news!

---

<div class="post-metadata">

**Author:** ![micken](https://dub1.discourse-cdn.com/flex006/user_avatar/genode.discourse.group/micken/32/22_2.png) [@micken](https://genode.discourse.group/u/micken)\
**Post date:** [September 3, 2024, 10:03pm UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/16 "2024-09-03T22:03:25Z")

</div>

> Congratulations! That’s great news!

I wish I known that git version was sort of borked. It was a not so pleasant debug session, that lasted several days.

😃

---

<div class="post-metadata">

**Author:** ![jjkarcher](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@jjkarcher](https://genode.discourse.group/u/jjkarcher)\
**Post date:** [September 3, 2024, 10:08pm UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/17 "2024-09-03T22:08:10Z")

</div>

That’s software for you! 🙂

---

<div class="post-metadata">

**Author:** ![micken](https://dub1.discourse-cdn.com/flex006/user_avatar/genode.discourse.group/micken/32/22_2.png) [@micken](https://genode.discourse.group/u/micken)\
**Post date:** [September 4, 2024, 12:43pm UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/18 "2024-09-04T12:43:57Z")

</div>

Interrupts are working 😃

proof:

> Kernel: take req: 30  
> Kernel: \_interrupt\_cpu  
> Kernel: take req: 30  
> Kernel: \_interrupt\_cpu  
> Kernel: take req: 30  
> Kernel: \_interrupt\_cpu  
> Kernel: take req: 30  
> Kernel: \_interrupt\_cpu  
> Kernel: take req: 30  
> Kernel: \_interrupt\_cpu  
> Kernel: take req: 30  
> Kernel: \_interrupt\_cpu  
> Kernel: take req: 30  
> Kernel: \_interrupt\_cpu  
> Kernel: take req: 30  
> Kernel: \_interrupt\_cpu  
> Kernel: take req: 30  
> Kernel: \_interrupt\_cpu  
> Kernel: take req: 30  
> Kernel: \_interrupt\_cpu  
> Kernel: take req: 30  
> Kernel: \_interrupt\_cpu  
> Kernel: take req: 30  
> Kernel: \_interrupt\_cpu  
> Kernel: take req: 30  
> Kernel: \_interrupt\_cpu  
> Kernel: take req: 30  
> Kernel: \_interrupt\_cpu  
> Kernel: take req: 30  
> Kernel: \_interrupt\_cpu  
> Kernel: take req: 30  
> Kernel: \_interrupt\_cpu  
> Kernel: take req: 30  
> Kernel: \_interrupt\_cpu

---

<div class="post-metadata">

**Author:** ![micken](https://dub1.discourse-cdn.com/flex006/user_avatar/genode.discourse.group/micken/32/22_2.png) [@micken](https://genode.discourse.group/u/micken)\
**Post date:** [September 4, 2024, 2:55pm UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/19 "2024-09-04T14:55:52Z")

</div>

I got tired of Linux so I have started on a generic EHCI driver. However I ran into logistics problem the first thing. This is how my little driver main looks like:

> struct Ehci::Main  
> {  
> Env & \_env;  
> Platform::Connection \_platform { \_env };  
> Platform::Device \_device { \_platform };  
> ehci\_ctrl \_ehci\_ctrl { \_device };  
> Main(Env &env) : \_env(env)  
> {  
> log(“— Generic EHCI driver —”);  
> \_ehci\_ctrl.init();  
> }  
> };  
> void Component::construct(Genode::Env &env) {  
> static Ehci::Main main(env); }

The greeting isn’t displayed so unsure if the driver actually starts.  
Any hints?

This is the serial output

> [init → drivers] child “generic\_ehci”  
> [init → drivers] RAM quota: 776K  
> [init → drivers] cap quota: 216  
> [init → drivers] ELF binary: rk3399\_ehci\_drv  
> [init → drivers] priority: 0  
> [init → drivers] child “event\_filter”  
> [init → drivers] RAM quota: 776K  
> [init → drivers] cap quota: 46  
> [init → drivers] ELF binary: event\_filter  
> [init → drivers] priority: 0  
> [init → drivers] provides service Event  
> [init → drivers] child “report\_rom” announces service “Report”  
> [init → drivers] child “report\_rom” announces service “ROM”  
> [init → drivers] child “platform\_drv” announces service “Platform”  
> [init → drivers → gui\_fb] — rk3399 fb driver —  
> [init → drivers → gui\_fb] fb init: 0  
> [init → drivers → gui\_fb] fb cfg: 0  
> [init → drivers → gui\_fb] win0en: 0x3a000081  
> [init → drivers → gui\_fb] act info: 0x437077f  
> [init → drivers → gui\_fb] fb init2: 0x46000000  
> [init → drivers → gui\_fb] fbset: 0x46000000  
> [init → drivers → gui\_fb] vop sys: 0x20805800  
> [init → drivers] child “event\_filter” announces service “Event”  
> [init → scout] png is 101x92 depth=8

---

<div class="post-metadata">

**Author:** ![ttcoder](https://dub1.discourse-cdn.com/flex006/user_avatar/genode.discourse.group/ttcoder/32/9_2.png) [@ttcoder](https://genode.discourse.group/u/ttcoder)\
**Post date:** [September 4, 2024, 4:35pm UTC](https://genode.discourse.group/t/rockchip-rk3399-usb/51/20 "2024-09-04T16:35:54Z")

</div>

> [@micken](#):
>
> > void Component::construct(Genode::Env &env) {  
> > static Ehci::Main main(env); }
> 
> The greeting isn’t displayed so unsure if the driver actually starts.  
> Any hints?

What if you add a log() in construct, before the `static...` ctor call.

If that one does work, meaning the ctor itself blocks, I’d comment out the class members until finding out which one is ‘holding up’ the constructor.  
(if that makes sense?)

[Next page](https://genode.discourse.group/t/rockchip-rk3399-usb/51.md?page=2)
