Wednesday 21 December 2016

Orange Pi - QNX 6.5 Support - Allwinner H3 - Quard Core Cortex-A7 Source Code - porting 1

QNX -Startup Coding 

I am adding Minimal QNX Support to this processor ... Source code will be updated here soon..

I have decided to write the step by step procedure on this ...   It will be helpfull for people who port to QNX ...  Everything will be documented here ...  As I add a new code both code & docoments will be posted here regularly ...

First step is baremetal programming on Orange Pi ...

 You can see my other post where I have mention how to do baremetal programming for orange pi

1.  I have chosen beaglebone board as a reference BSP , You can download this from QNX website .. 
Reason I choose this because it has ARM V7 support & I have a beaglebone board with me.
bsp-nto650-ti-beaglebone-sp1-trunk-201209071340.zip   ... Import it directly to QNX IDE , no unzip..
    
IPL not required , we have Uboot ..

2. Change the image load address to this ( You can see my bare metal code example ) in the startup  .build file 

[image=0x41000000]
#[+compress]
[virtual=armle-v7,raw] .bootstrap = {

3.Change the kernel to " smp "  we have quad core processor ..
PATH=:/proc/boot:/bin:/usr/bin LD_LIBRARY_PATH=:/proc/boot:/lib:/usr/lib:/lib/dll procnto-smp-instr -v
}

4. Go to "main.c" file in the startup , add our baremetal LED blink code here... We just want to make sure that the image is loaded properly in to RAM & the control goes to  "main.c"


#define STARTUP_TEST
#define PIO_BASE 0x01C20800
#define PA_CFG1_REG 0x04
#define PA_DATA_REG 0x10


#ifdef   STARTUP_TEST
// while(1)
    for(j=0;j<3;j++)
{
for (i=0;i<20000000;i++)
{
out32(PIO_BASE+PA_DATA_REG, 0);
//pa15 red led refer schematics
}
for (i=0;i<20000000;i++)
{
out32(PIO_BASE+PA_DATA_REG, 1<<15);
}
}
#endif


Now build it ... You can see the image in the folder   "ifs-ti-beaglebone.bin" , will change the name later ...

5. Now the H3 bootloader has to be writtern in to  the SD card properly , there is a  step to do that  , it has to be done in Linux environment... No need of doing that ..  download Lubuntu_1404_For_OrangePiPC_v0_8_0_.img.xz from orange PI, write it to sd card using "Win32DiskImager"   , you can see "uimage" file ... Thats linux kernel ,delete that ..

6. Put this card in to Orange pi & boot it  ..  Connet UART debugger 115200 , I use "putty "
now this appears ...

7. Copy the  orange pi image "ifs-ti-beaglebone.bin" to the sd card , boot it again ,  enter the below command 
sunxi#  fatload mmc 0 0x41000000 ifs-ti-beaglebone.bin; go 0x41000000

 8. Now you can see the LED blinking 

Serial debug messages support ( dont confuse it with devc driver )

9. Go to hw_seromap.c file , 

#define H3_UART_BASE 0x01C28000

#define H3_UART_RBR  0x00
#define H3_UART_THR  0x00
#define H3_UART_DLL  0x00
#define H3_UART_IER  0x04
#define H3_UART_DLM  0x04
#define H3_UART_FCR  0x08
#define H3_UART_LCR  0x0C
#define H3_UART_MCR  0x10
#define H3_UART_LSR  0x14
#define H3_UART_MSR  0x18
#define H3_UART_SCR  0x1C

void
put_omap(int c)
{
while (( in32(H3_UART_BASE + H3_UART_LSR) & 0x20) == 0) continue;
       out32(H3_UART_BASE + H3_UART_THR,c);
}

No need to change the "init" file now , as its been initialized by uboot

10 . Compile it & boot .... Now you could see debug messages , also an error message " Unsupported CPUID"

11. This is because our BSP does not have cortex -A7 support , cortex -A7 support is added by QNX guys , download those relevent files from other qnx bsps ...   follow Cortex A15 support in the code , now you can guess what is required to up cortex A7 ... 

12. After adding the files 
armv_chip_a7.c
armv_setup_a7.c
callout_catche_a7.S
callout_page_a7.S
Now you can see the below boot messages 



13.. Hey CPU detected , need to configure the Timer & interrupt ... Thats next post ...

Have a nice day ...

9 comments:

  1. Hi guy,
    Please share your source codes to me. I am very interesting it.
    p/s: I also want to know about QNX on raspberry Pi 2. do you have the source code for it?

    ReplyDelete
  2. its uploaded here.. bcm2835 only.. it may not work for raspberry 2..

    https://github.com/varghes/Raspberry-QNX

    ReplyDelete
  3. Hi Varghese,
    I need your help.
    have you met this problem?
    ...
    Section:smp offset:0x00000558 size:0x00000000
    Section:pminfo offset:0x00000558 size:0x00000000
    Section:mdriver offset:0x00000558 size:0x00000000
    Section:boxinfo offset:0x000001c8 size:0x00000028
    hw_flags:00000000
    Section:cpu offset:0x00000128 size:0x00000020
    page_flush:fc404608 page_flush_deferred:fc404658
    upte_ro:00000e6e upte_rw:00000c7e
    kpte_ro:0000065e kpte_rw:0000045e
    mask_nc:000001cc
    ttb_attr:0000004a pte_attr=0000044d
    mmu_cr1:00c51878 set:00803c7f clr:00000000 -> 00c53c7f

    System page at phys:00f8c000 user:fc404000 kern:fc404000
    Starting next program at vfe054938
    cpu_startnext: cpu0 -> fe054938
    cpu_startnext: invoking vstart:002072a0 sysp:fc404000 eip:fe054938 cpu:00000000

    The cpu do not jump to QNX kernel. It is hang at that point. do you have any idea for me?

    Thanks,
    Quyet Luu


    ReplyDelete
  4. bcm2835 ? may be you can try changing sd card.. if ur using 2836/37 thats multi core processor , then some minor change required ..

    ReplyDelete
  5. Hi!
    I am trying starting QNX on Orange PI Zero.
    If I am STARTUP_TEST section, i am catch error

    data abort
    pc : [<41001f4c>] lr : [<41001f40>]
    reloc pc : [<2b0a0f4c>] lr : [<2b0a0f40>]
    sp : 4100fb04 ip : 000004b0 fp : 5bf42928
    r10: 5ffb51d8 r9 : 5bf40ee8 r8 : 00000002
    r7 : 4100fe04 r6 : 4100fb08 r5 : 01c20800 r4 : 4100fe2c
    r3 : 01c28000 r2 : 01c28000 r1 : 00000020 r0 : 4100e17c
    Flags: nZCv IRQs off FIQs off Mode SVC_32
    Resetting CPU ...

    resetting ...

    When STARTUP_TEST not defined i am see next text:

    CPU0: L1 Icache: 1024x32
    CPU0: L1 Dcache: 512x64 WB
    CPU0: L2 Dcache: 8192x64 WB
    CPU0: VFP-d32 FPSID=41023075
    CPU0: NEON MVFR0=10110222 MVFR1=11111111
    CPU0: 410fc075: Cortex A7 rev 5 1200MHz
    Jumping to QNX

    System page at phys:00000000 user:c883ee2c kern:69ddffef
    Starting next program at vdf9ab7f9
    cpu_startnext: cpu0 -> df9ab7f9

    Thanks a lot for this instruction!!!

    ReplyDelete
    Replies
    1. Hi guy,
      can you boot up the QNX??

      thanks,
      Quyet Luu

      Delete
  6. GIC /SMP not configured , thats the problem . hopefully I will implement it in a month

    ReplyDelete
    Replies
    1. Hi Varghese,
      As I know, you can run only 1 core at first. So SMP is not configured may be is not problem. How about the GIC? do you have any idea to set it?

      Delete