Emcraft Linux and Emwin on custom board

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Ildar on Fri Jul 13 07:41:15 MST 2012
We have custom board based on LPC1788. We have ported linux on it. And we trying use NXP_emWin516_libraries from this site. But emwin crahed in GUI_Init() function!
There is dump of registers:


error_code: 0x0  fault_address: 0x0  pc: 0xa180a640  cpsr: 0x21000000  lr: 0xa180b311  sp: 0xa1a39de0
ip: 0xfffffb00  fp: 0x0  trap_no: 0x0  oldmask: 0x0  r0: 0xf0  r1: 0x4ab00  r2: 0x0
r3: 0x4ab00  r4: 0x130  r5: 0x0  r6: 0x0  r7: 0xf0  r8: 0x140  r9: 0x140  r10: 0xa182c2ed

The error occurs in function _FillRect and call from LCD_FillRect. Program try write to address 0! Why? In LCD_X_DisplayDriver in LCDConf.c I write:

// Required for setting the address of the video RAM for drivers
// with memory mapped video RAM which is passed in the 'pVRAM' element of p


int fd;
unsigned int* fbp;
long int screensize = 320 * 240 * 2;
* Open the framebuffer device file
fd = open("/dev/fb0", O_RDWR);
if (fd == -1) {
perror("Error: cannot open framebuffer device");

* Map the device to memory
fbp = (unsigned int *)mmap(
0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if ((int)fbp == -1) {
perror("Error: failed to map framebuffer device to memory");

//p->pVRAM = malloc((1024 * 1024) * 2);
p->pVRAM = fbp;

printf("\np = 0x%x  pData = 0x%x   p->pVRAM = 0x%x\n", p, pData, p->pVRAM);
return 0;

So virtual address is not null! What am I doing wrong?

0000a484 <_FillRect>:
    a484:e92d 43f7 stmdbsp!, {r0, r1, r2, r4, r5, r6, r7, r8, r9, lr}
    a488:6884      ldrr4, [r0, #8]
    a48a:460d      movr5, r1
    a48c:6b27      ldrr7, [r4, #48]; 0x30
    a48e:4616      movr6, r2
    a490:f8dd 8028 ldr.wr8, [sp, #40]; 0x28
    a494:b147      cbzr7, a4a8 <_FillRect+0x24>
    a496:4c44      ldrr4, [pc, #272]; (a5a8 <_FillRect+0x124>)
    a498:f8cd 8000 str.wr8, [sp]
    a49c:6824      ldrr4, [r4, #0]
    a49e:6824      ldrr4, [r4, #0]
    a4a0:9401      strr4, [sp, #4]
    a4a2:6980      ldrr0, [r0, #24]
    a4a4:47b8      blxr7
    a4a6:e07d      b.na5a4 <_FillRect+0x120>
    a4a8:f1c1 0901 rsbr9, r1, #1
    a4ac:4499      addr9, r3
    a4ae:4b3f      ldrr3, [pc, #252]; (a5ac <_FillRect+0x128>)
    a4b0:f1c2 0701 rsbr7, r2, #1
    a4b4:7c1b      ldrbr3, [r3, #16]
    a4b6:4447      addr7, r8
    a4b8:f013 0f01 tst.wr3, #1
    a4bc:f8d4 801c ldr.wr8, [r4, #28]
    a4c0:d020      beq.na504 <_FillRect+0x80>
    a4c2:6903      ldrr3, [r0, #16]
    a4c4:689b      ldrr3, [r3, #8]
    a4c6:4798      blxr3
    a4c8:69e3      ldrr3, [r4, #28]
    a4ca:fb03 5506 mlar5, r3, r6, r5
    a4ce:f1b9 0f00 cmp.wr9, #0
    a4d2:d067      beq.na5a4 <_FillRect+0x120>
    a4d4:1e7e      subsr6, r7, #1
    a4d6:ea4f 0c88 mov.wip, r8, lsl #2
    a4da:fb08 5806 mlar8, r8, r6, r5
    a4de:f1cc 0c00 rsbip, ip, #0
    a4e2:ea4f 0888 mov.wr8, r8, lsl #2
    a4e6:e00a      b.na4fe <_FillRect+0x7a>
    a4e8:3f01      subsr7, #1
    a4ea:4643      movr3, r8
    a4ec:464a      movr2, r9
    a4ee:6821      ldrr1, [r4, #0]
    a4f0:585d      ldrr5, [r3, r1]
    a4f2:4045      eorsr5, r0
    a4f4:505d      strr5, [r3, r1]
    a4f6:3304      addsr3, #4
    a4f8:3a01      subsr2, #1
    a4fa:d1f8      bne.na4ee <_FillRect+0x6a>
    a4fc:44e0      addr8, ip
    a4fe:2f00      cmpr7, #0
    a500:d1f2      bne.na4e8 <_FillRect+0x64>
    a502:e04f      b.na5a4 <_FillRect+0x120>
    a504:fb08 1502 mlar5, r8, r2, r1
    a508:6823      ldrr3, [r4, #0]
    a50a:f1b9 0f0f cmp.wr9, #15
    a50e:eb03 0585 add.wr5, r3, r5, lsl #2
    a512:4b25      ldrr3, [pc, #148]; (a5a8 <_FillRect+0x124>)
    a514:681b      ldrr3, [r3, #0]
    a516:681a      ldrr2, [r3, #0]
    a518:d92d      bls.na576 <_FillRect+0xf2>
    a51a:f107 4380 add.wr3, r7, #1073741824; 0x40000000
    a51e:ea4f 0188 mov.wr1, r8, lsl #2
    a522:3b01      subsr3, #1
    a524:f1c1 0c00 rsbip, r1, #0
    a528:4638      movr0, r7
    a52a:fb01 5103 mlar1, r1, r3, r5
    a52e:2500      movsr5, #0
    a530:e01d      b.na56e <_FillRect+0xea>
    a532:464c      movr4, r9
    a534:460b      movr3, r1
    a536:3c10      subsr4, #16

    THIS ADDRESS (a538) is PC (0xa180a640) We try write to 0 and crash (SEGMENTATION FAULT)!
    a538:601a      strr2, [r3, #0]

    a53a:605a      strr2, [r3, #4]
    a53c:609a      strr2, [r3, #8]
    a53e:60da      strr2, [r3, #12]
    a540:611a      strr2, [r3, #16]
    a542:615a      strr2, [r3, #20]
    a544:619a      strr2, [r3, #24]
    a546:61da      strr2, [r3, #28]
    a548:621a      strr2, [r3, #32]
    a54a:625a      strr2, [r3, #36]; 0x24
    a54c:629a      strr2, [r3, #40]; 0x28
    a54e:62da      strr2, [r3, #44]; 0x2c
    a550:631a      strr2, [r3, #48]; 0x30
    a552:635a      strr2, [r3, #52]; 0x34
    a554:639a      strr2, [r3, #56]; 0x38
    a556:63da      strr2, [r3, #60]; 0x3c
    a558:3340      addsr3, #64; 0x40
    a55a:2c0f      cmpr4, #15
    a55c:d8eb      bhi.na536 <_FillRect+0xb2>
    a55e:f1a9 0510 sub.wr5, r9, #16
    a562:092d      lsrsr5, r5, #4
    a564:3501      addsr5, #1
    a566:01ad      lslsr5, r5, #6
    a568:194d      addsr5, r1, r5
    a56a:3801      subsr0, #1
    a56c:4461      addr1, ip
    a56e:2800      cmpr0, #0
    a570:d1df      bne.na532 <_FillRect+0xae>
    a572:f009 090f and.wr9, r9, #15
    a576:f1b9 0f00 cmp.wr9, #0
    a57a:d013      beq.na5a4 <_FillRect+0x120>
    a57c:f107 4380 add.wr3, r7, #1073741824; 0x40000000
    a580:ea4f 0888 mov.wr8, r8, lsl #2
    a584:3b01      subsr3, #1
    a586:f1c8 0000 rsbr0, r8, #0
    a58a:fb08 5503 mlar5, r8, r3, r5
    a58e:e007      b.na5a0 <_FillRect+0x11c>
    a590:4629      movr1, r5
    a592:464b      movr3, r9
    a594:3b01      subsr3, #1
    a596:f841 2b04 str.wr2, [r1], #4
    a59a:d1fb      bne.na594 <_FillRect+0x110>
    a59c:3f01      subsr7, #1
    a59e:182d      addsr5, r5, r0
    a5a0:2f00      cmpr7, #0
    a5a2:d1f5      bne.na590 <_FillRect+0x10c>
    a5a4:e8bd 83fe ldmia.wsp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, pc}
    a5a8:000345ac .word0x000345ac
    a5ac:00238490 .word0x00238490

0000b1c0 <LCD_FillRect>:
    b1c0:b573      push{r0, r1, r4, r5, r6, lr}
    b1c2:4e12      ldrr6, [pc, #72]; (b20c <LCD_FillRect+0x4c>)
    b1c4:460c      movr4, r1
    b1c6:f9b6 500c ldrsh.wr5, [r6, #12]
    b1ca:f9b6 1008 ldrsh.wr1, [r6, #8]
    b1ce:42aa      cmpr2, r5
    b1d0:bfb8      itlt
    b1d2:4615      movltr5, r2
    b1d4:4288      cmpr0, r1
    b1d6:bfa8      itge
    b1d8:4601      movger1, r0
    b1da:428d      cmpr5, r1
    b1dc:db14      blt.nb208 <LCD_FillRect+0x48>
    b1de:f9b6 200a ldrsh.wr2, [r6, #10]
    b1e2:f9b6 000e ldrsh.wr0, [r6, #14]
    b1e6:4294      cmpr4, r2
    b1e8:bfa8      itge
    b1ea:4622      movger2, r4
    b1ec:4283      cmpr3, r0
    b1ee:bfa8      itge
    b1f0:4603      movger3, r0
    b1f2:4293      cmpr3, r2
    b1f4:db08      blt.nb208 <LCD_FillRect+0x48>
    b1f6:7c70      ldrbr0, [r6, #17]
    b1f8:eb06 0680 add.wr6, r6, r0, lsl #2
    b1fc:6cf0      ldrr0, [r6, #76]; 0x4c
    b1fe:68c4      ldrr4, [r0, #12]
    b200:9300      strr3, [sp, #0]
    b202:6924      ldrr4, [r4, #16]
    b204:462b      movr3, r5
    b206:47a0      blxr4

    THIS ADDRESS (b208) is LR (0xa180b311)
    b208:bd7c      pop{r2, r3, r4, r5, r6, pc}

    b20a:bf00      nop
    b20c:00238490 .word0x00238490