RK3288 initial rants
Michael Grunditz (467) 531 posts |
Assigning the right irq number helps I guess :) But it doesn’t activate or something… IRQEnable always returns 0. The EHCImodule goes into loop when adding devices. IN new_instance it starts itself again. It loops about 17 times, and then crash. |
Michael Grunditz (467) 531 posts |
OK then here is the complete EHCI status.
So problems..
I have problems with building in debugmode.. But I added a few debug statements. So What is the next step? |
Michael Grunditz (467) 531 posts |
Clocks is on by default * check. |
Jeffrey Lee (213) 6048 posts |
Have you checked that the timer/counter APIs are working correctly? If you’ve got BASIC working, you should be able to use The USB drivers also expect HAL_CounterDelay to be working, so you could check that from BASIC as well (e.g. use the OS_Hardware SWI to call it and ask it to wait for 1 second) If timers are working, I’d suggest trying to fix whatever problems you’re having with building the debug versions of the USB drivers (sometimes the debug build does get broken, but I think it should be OK at the moment). Then you can configure the drivers to log to DADebug and (if necessary) use DADebug’s TickerPrint option to get the output.
Is HAL_USBControllerInfo implemented correctly? EHCIDriver uses it to enumerate the available controllers, so HAL_USBControllerInfo must return 0 once the ‘bus’ number goes out of range, otherwise the OS will think you have an infinite number of USB controllers. |
Michael Grunditz (467) 531 posts |
prints “0” , so it is not working. It is OS_ReadMonotomic right? Where is it taking its time from? What is the correct number to return 0 from in USB? I have one EHCI controller (OTG is another story). |
Michael Grunditz (467) 531 posts |
Some output from EHCI, Now it checks for controller twise init mod EHCIDriver0xf9c00000 mread c000 from f9c00014 |
Michael Grunditz (467) 531 posts |
Status of TIMER HAL. Everything seems in order, but it is clocked at 24Mhz and I don’t know how to slow it down… HAL_CounterDelay isn’t very useful. Ehh never mind , I am blind. There is a multiplier in the delay function , I’l better use that! Yes. TImer is ok now.. But the RISC OS clock doesn’t work..? |
Michael Grunditz (467) 531 posts |
I upgraded the tree last night, and now the EHCImodule doesn’t get anything at all from controllerinfo. SO two questions up now:
|
Colin (478) 2433 posts |
If the OTG controller is EHCI then HAL_USBControllerInfo returns 0 when hal_device is >=2. If the OTG Controller is not EHCI then HAL_USBControllerInfo returns 0 when hal_device is >=1. If you look at your EHCI output the line
Is the initialisation of a new instance of the module the number after the H – 0 in this case – is the last successful hal device number. |
Michael Grunditz (467) 531 posts |
I don’t have I2c in my HAL, is that a problem ? |
Michael Grunditz (467) 531 posts |
Here goes the Interrupt status:
So there are many factors..
Oh gosh! |
Jeffrey Lee (213) 6048 posts |
That shouldn’t be a problem
Yes, that’s normal if there’s no active interrupt. In fact, because of the way the GIC works, when an interrupt fires, the first call to HAL_IRQSource will return the device number, and subsequent calls will return -1 (because it thinks that whatever code made that first call is handling the interrupt). So if HAL_IRQSource is called too often, it may cause the kernel to “miss” an interrupt. And unless there’s a corresponding HAL_IRQClear for each (valid) HAL_IRQSource, the GIC won’t deliver that interrupt (or any lower-priority ones?) to the CPU again. There are some docs here where I’ve attempted to describe the OS’s/HAL’s approach to IRQ handling in more detail than the current HAL docs. It’s mostly written from the perspective of how the IRQ handling is being extended to support SMP, but it also describes how things currently work for single-core OS’s/machines. |
Michael Grunditz (467) 531 posts |
Very good text! If I loop IRQStatus over a enabled interrupt (TIMER0) it reads from the distributor interface. Since it never return anything but zero the device irq never gets to the distributor interface. Very strange! Anyway If the CPU is in Secure mode I have problems.. |
Michael Grunditz (467) 531 posts |
I need to know if RISCOS needs to run in non secure mode, and how it handles it! |
Jeffrey Lee (213) 6048 posts |
Traditionally, the OS has only run in non-secure mode, and there’s no code in the kernel for switching to or from secure mode. I know the IMX6 starts in secure mode (it sets up an SMC handler to allow the L2 cache to be enabled/disabled), and I think it stays there (i.e. SCR.NS remains 0) (I can’t see anything obvious which switches out of secure mode). But I haven’t checked on a running system. |
Michael Grunditz (467) 531 posts |
I know that. RK3288 starts secure. It affects how the GIC works. The i.mx6 port does something for allowing all peripherals in non-secure mode. |
Michael Grunditz (467) 531 posts |
No luck with u-boot.. Now I am trying with the i.mx6 secure handler and do the switch there. The cpu just halts or hangs on the write to p15. It needs to be called after MMU ON . But now the MMU ON fails.. :/ The only difference is that the monitor is installed. |
Michael Grunditz (467) 531 posts |
Now it runs thru and I should be in non-secure mode. No luck with GIC. |
Michael Grunditz (467) 531 posts |
No it didn’t. If I set the NS bit R14 goes void. IF I push LR , do the write, pull it back the monitor returns, but NS bit stays unset. |
Jeffrey Lee (213) 6048 posts |
The ARM ARM says that the preferred/correct way of switching to non-secure state is via performing an exception return from Monitor mode with SCR.NS=1 I.e. the following should work (untested): MRS CPSR_c,#MON32_mode+I32_bit+F32_bit ; switch to monitor mode (editing SCR.NS outside if MON is discouraged) MOV R0,#1+16+32 ; SCR.NS, .FW, .AW set MCR p15, 0, R0, c1, c1, 0 ADR R0,continue MOV R1,#A32_bit+I32_bit+F32_bit+SVC32_mode STMFD R13!,{R0-R1} RFEFD R13! continue ; now in non-secure state Accessing the SCR in non-secure state will abort, so you could use that as a way of testing whether it worked or not. You’ll also have to double-check which CP15 registers are banked between secure & non-secure state, as there’s probably some configuration that will need re-applying. |
Michael Grunditz (467) 531 posts |
Spent the entire night with this. There are problems with hw access in insecure mode. MapInIo doesn’t work. It might be that the ram is added in secure mode. I am going to research a bit more tonight. |
Jeffrey Lee (213) 6048 posts |
There are probably security settings on the bus/interconnect controller, or maybe on each device, to restrict peripherals from being accessed in non-secure mode. |
Michael Grunditz (467) 531 posts |
Perhaps yes. The trm doesn’t cover running in non-secure mode. |
Michael Grunditz (467) 531 posts |
Happy day! I skipped the switch… The problem was silly simple. The Interrupt HAL added 32 to all my IRQ numbers! *time Starting >PRINT TIME |
Andrew McCarthy (3688) 605 posts |
Well done! #applause :) |