Showing posts with label Orange Pi. Show all posts
Showing posts with label Orange Pi. Show all posts

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 ...