Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页
    1. Home
    2. steward
    • Profile
    • Following 0
    • Followers 5
    • my integral 937
    • Topics 1
    • Posts 17
    • Best 6
    • Groups 0

    司徒LV 4

    @steward

    937
    integral
    7
    Reputation
    19
    Profile views
    17
    Posts
    5
    Followers
    0
    Following
    Joined Last Online
    Website steward-fu.github.io/website/index.htm Location 台灣

    steward Unfollow Follow

    Best posts made by steward

    • Reply: 用 ST7789V LCD 在 lichee pi nano (f1c100s)

      @bankbank long time no see. 💃
      Please post the pinout information of the LCD panel and then we can decide how to connect it to F1C100S.

      posted in Linux
      steward
      司徒
    • Reply: 可以在這裡寫非全志晶片的文章嗎 ?

      @newcastle 是地~正是小弟本人~💃💃

      雖然之前說不玩寨機, 不過我還是偷偷玩, 哈哈~只是以後我不再釋出任何研究成果, 就我自己玩而已, 哈~

      目前是玩 TRIMUI SMART寨機 (Allwinner S3 + RAM 128MB + eMMC 8GB + RTL8723DS), 目前還在逆向研究中, 預期要讓它跑 Linux Kernel + 精簡客製化的 Debian 桌面, 主要是想跑 WINE(arm32) 的逆向遊戲, 網址:https://steward-fu.github.io/website/handheld.htm#trimui-smart

      然後, 之前有一個特別的想法, 想做一台特別的掌機, 用來懷念小時候的樂趣, 目前可能鎖定 RISC-V 晶片, 只是用哪家, 目前還在觀望, 所以我才發貼問一下是否可以寫其它家晶片的問題~哈

      posted in 爱搞机专区
      steward
      司徒
    • Reply: 可以在這裡寫非全志晶片的文章嗎 ?

      @lovexulu 感謝你的資訊, 不過 CV1800B 似乎找不到手冊~

      來個比較表看一下

      • BL808
        CPU RV64GCV(480MHz) + RV32GCP(320MHz) + RV32EMC(160MHz)
        RAM 64MB(PSRAM)
        2D DMA
        WiFi + BT

      • R128
        CPU RV64GCV(600MHz) + Cortex-M33(240MHz)
        RAM 32MB(PSRAM)
        G2D
        WiFi + BT

      • F133
        CPU RV64GCV(533MHz)
        RAM 64MB(DDR2)
        G2D

      BL808 那個 2D DMA 真的蠻屌的, 位移、旋轉、 2D搬移, 這功能真的很適合做遊戲機, 全志 R128 如果把 M33 替換成 F1C100S IP, 繼續延續 F1C100S 生命力, 那就真的很棒, 可惜沒有~

      posted in 爱搞机专区
      steward
      司徒
    • Reply: 可以在這裡寫非全志晶片的文章嗎 ?

      @lovexulu 你對全志晶片好熟悉~小弟給大佬請安💃💃

      V851S這顆晶片也很適合使用, 我希望的需求是:
      QFP包裝
      兩核心(CPU >= 400MHz)
      RAM >= 64MB
      WiFi
      BT

      因為我希望開機有兩種OS模式, 其中一個如果有WiFi協助是最好, 不知道全志有這樣的晶片嗎 ?

      posted in 爱搞机专区
      steward
      司徒
    • Reply: MQ-T113使用xboot驱动GT911时中断无法使用

      目前 XBOOT 有支援 GT-911 的平台如下:

      ./src/arch/riscv64/mach-f133/driver/ts-gt911.c
      ./src/arch/arm32/mach-t113s3jd/driver/ts-gt911.c
      ./src/arch/arm32/mach-t113s3/driver/ts-gt911.c
      ./src/arch/arm32/mach-z11s/driver/ts-gt911.c
      

      手上剛好有 F133 板子, 但是我沒有 GT-911 觸控板, 如果需要或許可以用 Arduino 模擬~
      1.jpg

      不過, 找問題的方式應該大同小異, 因此, 我用 F133 說一下,
      json 檔案確定有設定成 okay

      "ts-f133@0x02009c00": {
              "clock-name": "link-tpadc",
              "interrupt": 78, 
              "reset": 1136,
              "median-filter-length": 5,
              "mean-filter-length": 5,
              "calibration": [168012, -57, -137136144, -344, 8674, -2840431, 65536],
              "status": "okay"
          },  
      
          "ts-gt911": {
              "i2c-bus": "i2c-f133.2",
              "slave-address": 20, 
              "interrupt-gpio": 35, 
              "interrupt-gpio-config": 14, 
              "reset-gpio": 34, 
              "reset-gpio-config": 1,
              "status": "okay"
          }, 
      

      然後埋一些 LOG, 先確定觸控板有被正確配置

      static bool_t gt911_initial(struct i2c_device_t * dev)
      {
          u8_t cfg;
          u8_t id[4];
          u8_t ver[2];
      
          if(!gt911_read(dev, GT911_CONFIG_DATA, &cfg, 1)) {
              LOG("GT911: failed to read config data\n");
              return FALSE;
          }   
          if(!gt911_read(dev, GT911_PRODUCT_ID, &id[0], 4)) {
              LOG("GT911: failed to read product id\n");
              return FALSE;
          }   
          if(!gt911_read(dev, GT911_FIRMWARE_VERSION, &ver[0], 2)) {
              LOG("GT911: failed to read firmware version\n");
              return FALSE;
          }   
      
          LOG("GT911 Version: %c%c%c%c(0x%02x%02x)(0x%02x)", id[0], id[1], id[2], id[3], ver[1], ver[0], cfg);
          return gt911_send_cfg(dev, (u8_t *)gt911_config_data, ARRAY_SIZE(gt911_config_data));
      }
      

      埋好 LOG 之後, 下載測試

      $ make CROSS_COMPILE=/opt/f133/bin/riscv64-unknown-linux-gnu- PLATFORM=riscv64-f133
      $ xfel ddr f133 && xfel write 0x40000000 output/xboot.bin && xfel exec 0x40000000
      

      因為沒有連接 GT-911, 因此, 在讀取 config data 時就會出錯

      [    0.261738]GT911: failed to read config data
      

      因此, 幾個找問題的方式提供給你參考 (跟著訊號的方向找問題就可以)

      1. 確定觸控的資訊可以被正確讀取到, 你應該可以從 UART 看到 "GT911 Version: xxx"
      2. 如果可以讀取到觸控資訊, 那可以往中斷腳位的方向找問題, 例如:沒接好或者被拉高拉低等問題
      posted in 爱搞机专区
      steward
      司徒
    • Reply: MQ-T113使用xboot驱动GT911时中断无法使用

      @Ary_Ye XBoot在T113-S3上的中斷設定確實有問題, 分析如下:

      文章有點長,可以直接拉到底下看workaround方式 💃💃💃

      司徒終於從冰箱找到芒果派T113-S3開發板
      1.jpg

      司徒手上並沒有GT911觸控板,因此,司徒使用Arduino Micro模擬GT911訊號
      2.jpg

      Arduino腳位:
      3.jpg

      T113-S3腳位:
      4.jpg

      司徒將GT911 I2C訊號接到T113-S3 I2C-2,GT911的中斷則是接到T113-S3 PB6(手動觸發)
      5.jpg

      杜邦線連接
      6.jpg

      Arduino模擬GT911程式

      #include <Wire.h>
       
      unsigned short rx = 0;
      void receiveEvent(int howMany) {
        if(howMany == 2){
          rx = Wire.read();
          rx<<= 8;
          rx|= Wire.read();
        }
        else{
          while (Wire.available()) {
            Wire.read();
          }
        }
        Serial.print("howMany:");
        Serial.print(howMany);
        Serial.print("\n");
        Serial.print("0x");
        Serial.print(rx, HEX);
        Serial.print("\n");
      }
       
      unsigned short x = 0;
      unsigned short y = 0;
      void requestEvent() {
        switch(rx){
        case 0x8047:
          Wire.write(byte(0x01));
          break;
        case 0x8140:
          Wire.write('A');
          Wire.write('B');
          Wire.write('C');
          Wire.write('D');
          break;
        case 0x8144:
          Wire.write(byte(0x12));
          Wire.write(byte(0x34));
          break;
        case 0x814e:
          Wire.write(byte(0x80 | 1));
          break;
        case 0x814f:
          Wire.write(byte(0x01));
          Wire.write(byte(x));
          Wire.write(byte(x >> 8));
          Wire.write(byte(y));
          Wire.write(byte(y >> 8));
          Wire.write(byte(0x00));
          Wire.write(byte(0x00));
          Wire.write(byte(0x00));
          x+= 1;
          y+= 1;
          break;
        }
        rx = 0;
      }
       
      void setup() {
        Wire.begin(20);
        Wire.onReceive(receiveEvent);
        Wire.onRequest(requestEvent);
        Serial.begin(115200);
       
      }
       
      void loop() {
        delay(100);
      }
      

      src/arch/arm32/mach-t113s3/romdisk/boot/mangopi.json

      524     "i2c-t113:2@0x02502800": {
      525         "clock-name": "bus-i2c2",
      526         "clock-frequency": 400000,
      527         "reset": 466,
      528         "sda-gpio": 133,
      529         "sda-gpio-config": 4,
      530         "scl-gpio": 132,
      531         "scl-gpio-config": 4
      532     },
      
      662     "ts-gt911": {
      663         "i2c-bus": "i2c-t113.2",
      664         "slave-address": 20,
      665         "interrupt-gpio": 38,
      666         "interrupt-gpio-config": 14,
      667         "reset-gpio": 34,
      668         "reset-gpio-config": 1
      669     },
      

      src/arch/arm32/mach-t113s3/driver/ts-gt911.c

       75 static bool_t gt911_write(struct i2c_device_t * dev, u16_t reg, u8_t * buf, int len)
       76 {
       77     struct i2c_msg_t msg;
       78     u8_t mbuf[256];
       79
       80     if(len > sizeof(mbuf) - 1)
       81         len = sizeof(mbuf) - 1;
       82     mbuf[0] = (reg >> 8) & 0xff;
       83     mbuf[1] = (reg >> 0) & 0xff;
       84     memcpy(&mbuf[2], buf, len);
       85
       86     msg.addr = dev->addr;
       87     msg.flags = 0;
       88     msg.len = 32;//len + 2;
       89     msg.buf = &mbuf[0];
       90
       91     if(i2c_transfer(dev->i2c, &msg, 1) != 1)
       92         return FALSE;
       93     return TRUE;
       94 }
      
      134 static bool_t gt911_initial(struct i2c_device_t * dev)
      135 {
      136     u8_t cfg;
      137     u8_t id[4];
      138     u8_t ver[2];
      139
      140     if(!gt911_read(dev, GT911_CONFIG_DATA, &cfg, 1))
      141         return FALSE;
      142     if(!gt911_read(dev, GT911_PRODUCT_ID, &id[0], 4))
      143         return FALSE;
      144     if(!gt911_read(dev, GT911_FIRMWARE_VERSION, &ver[0], 2))
      145         return FALSE;
      146
      147     LOG("GT911 Version: %c%c%c%c(0x%02x%02x)(0x%02x)\r\n", id[0], id[1], id[2], id[3], ver[1], ver[0], cfg);
      148     return gt911_send_cfg(dev, (u8_t *)gt911_config_data, ARRAY_SIZE(gt911_config_data));
      149 }
      
      151 static void gt911_interrupt(void * data)
      152 {
      153     struct input_t * input = (struct input_t *)data;
      154     struct ts_gt911_pdata_t * pdat = (struct ts_gt911_pdata_t *)input->priv;
      155     u8_t status, buf[40];
      156     u8_t * p;
      157     int count, i;
      158     int id, x, y;
      159
      160     LOG("%s++\r\n", __func__);
      161     disable_irq(pdat->irq);
      162     for(i = 0; i < 5; i++)
      163     {
      164         pdat->node[i].valid = 0;
      165     }
      166     if(gt911_read(pdat->dev, GT911_STATUS, &status, 1) && (status & (1 << 7)))
      167     {
      168         count = status & 0x0f;
      169         if(count > 0 && count < 5)
      170         {
      171             if(gt911_read(pdat->dev, GT911_COOR_ADDR, &buf[0], count << 3))
      172             {
      173                 for(i = 0; i < count; i++)
      174                 {
      175                     p = &buf[i << 3];
      176                     id = p[0];
      177                     x = (p[2] << 8) | (p[1] << 0);
      178                     y = (p[4] << 8) | (p[3] << 0);
      179                     LOG("%s, count:%d, x:%d, y:%d\r\n", __func__, count, x, y);
      ...
      209     enable_irq(pdat->irq);
      210     LOG("%s--\r\n", __func__);
      211 }
      

      編譯、下載

      $ make CROSS_COMPILE=arm-linux-gnueabihf- PLATFORM=arm32-t113s3
      $ xfel ddr t113-s3
      $ xfel write 0x40000000 output/xboot.bin
      $ xfel exec 0x40000000
      

      Arduino GT911可以正常工作,但是,中斷PB6無法被觸發

      [    0.260214]GT911 Version: ABCD(0x3412)(0x01)
      [    0.287074]Probe device 'ts-gt911.0' with ts-gt911
      

      為了方便測試,司徒將PB6加上提昇電阻並且改成Falling中斷觸發

      282     LOG("%s, gpio:%d, gpiocfg:%d, irqnum:%d\r\n", __func__, gpio, gpiocfg, irq);
      283     if(gpio >= 0)
      284     {
      285         if(gpiocfg >= 0)
      286             gpio_set_cfg(gpio, gpiocfg);
      287         gpio_set_pull(gpio, GPIO_PULL_UP);
      288     }
      289     request_irq(pdat->irq, gt911_interrupt, IRQ_TYPE_EDGE_FALLING, input);
      

      PB6=GPIO38、GPIOCFG=14、IRQ=262,這個IRQ應該是抓錯了?

      [    0.266982]ts_gt911_probe, gpio:38, gpiocfg:14, irqnum:262
      

      7.jpg

      src/arch/arm32/mach-t113s3/romdisk/boot/mangopi.json

      388     "irq-gic400@0x03020000": { "interrupt-base": 32, "interrupt-count": 224 },
      389     "irq-t113-gpio@0x02000220": { "interrupt-base": 224, "interrupt-count":  8, "interrupt-parent":  101 },
      390     "irq-t113-gpio@0x02000240": { "interrupt-base": 256, "interrupt-count":  8, "interrupt-parent":  103 },
      391     "irq-t113-gpio@0x02000260": { "interrupt-base": 288, "interrupt-count": 23, "interrupt-parent":  105 },
      392     "irq-t113-gpio@0x02000280": { "interrupt-base": 320, "interrupt-count": 14, "interrupt-parent":  107 },
      393     "irq-t113-gpio@0x020002a0": { "interrupt-base": 352, "interrupt-count":  7, "interrupt-parent":  109 },
      394     "irq-t113-gpio@0x020002c0": { "interrupt-base": 384, "interrupt-count": 16, "interrupt-parent":  111 },
      

      src/driver/interrupt/interrupt.c

      191 bool_t request_irq(int irq, void (*func)(void *), enum irq_type_t type, void * data)
      192 {
      193     struct irqchip_t * chip;
      194     int offset;
      195
      196     if(!func)
      197         return FALSE;
      198
      199     chip = search_irqchip(irq);
      200     if(!chip)
      201         return FALSE;
      202
      203     offset = irq - chip->base;
      204     if(chip->handler[offset].func != null_interrupt_function) {
      205         return FALSE;
      206     }
      207
      208     LOG("%s, irq:%d, chip->base:%d, offset:%d\r\n", __func__, irq, chip->base, offset);
      

      XBoot修改到的中斷地址是屬於PC6,但是司徒的中斷是設定成PB6

      [    0.272634]request_irq, irq:262, chip->base:256, offset:6
      

      src/arch/arm32/mach-t113s3/driver/irq-t113-gpio.c

       92     addr = pdat->virt + GPIO_INT_CFG0 + ((offset >> 3) << 2);
       93     val = read32(addr);
       94     val &= ~(0xf << ((offset & 0x7) << 2));
       95     val |= ((cfg & 0x7) << ((offset & 0x7) << 2));
       96     write32(addr, val);
       97
       98     LOG("%s, addr:%p, type:%d, offset:%d\r\n", __func__, addr, type, offset);
      

      果然修改到PC6 0x02000240

      [    0.268151]ts_gt911_probe, gpio:38, gpiocfg:14, irqnum:262
      [    0.273812]request_irq, irq:262, chip->base:256, offset:6
      [    0.279202]irq_t113_gpio_settype, addr:0x02000240, type:3, offset:6
      [    0.285373]Probe device 'ts-gt911.0' with ts-gt911
      

      PB6是位於0x02000230
      8.jpg

      Workaround (src/driver/interrupt/interrupt.c)

       62 static struct irqchip_t * search_irqchip(int irq)
       63 {
       64     struct device_t * pos, * n;
       65     struct irqchip_t * chip;
       66
       67     list_for_each_entry_safe(pos, n, &__device_head[DEVICE_TYPE_IRQCHIP], head)
       68     {
       69         chip = (struct irqchip_t *)(pos->priv);
       70         if(irq == 230){
       71             if(chip->base == 224){
       72                 return chip;
       73             }
       74             continue;
       75         }
       76         if((irq >= chip->base) && (irq < (chip->base + chip->nirq)))
       77             return chip;
       78     }
       79     return NULL;
       80 }
      
      191 bool_t request_irq(int irq, void (*func)(void *), enum irq_type_t type, void * data)
      192 {
      193     struct irqchip_t * chip;
      194     int offset;
      195
      196     if(!func)
      197         return FALSE;
      198
      199     if(irq == 262){
      200         irq-= 32;
      201     }
      

      修改後,就可以正常中斷觸發並且回報觸控點

      [    0.260653]GT911 Version: ABCD(0x3412)(0x01)
      [    0.266935]ts_gt911_probe, gpio:38, gpiocfg:14, irqnum:262
      [    0.272326]request_irq, irq:230, chip->base:224, offset:6
      [    0.277959]irq_t113_gpio_settype, addr:0x02000220, type:3, offset:6
      [    0.299301]Probe device 'ts-gt911.0' with ts-gt911
      [    0.304091]Probe device 'g2d-t113.0' with g2d-t113
      [    0.310178]Probe device 'fb-t113-rgb.0' with fb-t113-rgb
      [    0.315658]Probe device 'console-uart.0' with console-uart
      [    0.322001]mount /private with 'ram' filesystem
      Press any key to stop auto boot:  0.000
      xboot: /# 
      [    5.434256]gt911_interrupt++
      [    5.440101]gt911_interrupt, count:1, x:1, y:1
      [    5.446270]gt911_interrupt--
      [    9.054572]gt911_interrupt++
      [    9.060405]gt911_interrupt, count:1, x:2, y:2
      [    9.066782]gt911_interrupt--
      
      posted in 爱搞机专区
      steward
      司徒

    Latest posts made by steward

    • Reply: MQ-T113使用xboot驱动GT911时中断无法使用

      @Ary_Ye
      I2C 訊號需要先確定再去看中斷問題, 就我的測試, I2C 應該是可以正常工作, 所以你可以往硬件問題排錯, 例如:I2C 上拉電阻等問題, 或者延長 XBoot 對 GT911 的 Reset 時間~

      posted in 爱搞机专区
      steward
      司徒
    • Reply: MQ-T113使用xboot驱动GT911时中断无法使用

      @Ary_Ye XBoot在T113-S3上的中斷設定確實有問題, 分析如下:

      文章有點長,可以直接拉到底下看workaround方式 💃💃💃

      司徒終於從冰箱找到芒果派T113-S3開發板
      1.jpg

      司徒手上並沒有GT911觸控板,因此,司徒使用Arduino Micro模擬GT911訊號
      2.jpg

      Arduino腳位:
      3.jpg

      T113-S3腳位:
      4.jpg

      司徒將GT911 I2C訊號接到T113-S3 I2C-2,GT911的中斷則是接到T113-S3 PB6(手動觸發)
      5.jpg

      杜邦線連接
      6.jpg

      Arduino模擬GT911程式

      #include <Wire.h>
       
      unsigned short rx = 0;
      void receiveEvent(int howMany) {
        if(howMany == 2){
          rx = Wire.read();
          rx<<= 8;
          rx|= Wire.read();
        }
        else{
          while (Wire.available()) {
            Wire.read();
          }
        }
        Serial.print("howMany:");
        Serial.print(howMany);
        Serial.print("\n");
        Serial.print("0x");
        Serial.print(rx, HEX);
        Serial.print("\n");
      }
       
      unsigned short x = 0;
      unsigned short y = 0;
      void requestEvent() {
        switch(rx){
        case 0x8047:
          Wire.write(byte(0x01));
          break;
        case 0x8140:
          Wire.write('A');
          Wire.write('B');
          Wire.write('C');
          Wire.write('D');
          break;
        case 0x8144:
          Wire.write(byte(0x12));
          Wire.write(byte(0x34));
          break;
        case 0x814e:
          Wire.write(byte(0x80 | 1));
          break;
        case 0x814f:
          Wire.write(byte(0x01));
          Wire.write(byte(x));
          Wire.write(byte(x >> 8));
          Wire.write(byte(y));
          Wire.write(byte(y >> 8));
          Wire.write(byte(0x00));
          Wire.write(byte(0x00));
          Wire.write(byte(0x00));
          x+= 1;
          y+= 1;
          break;
        }
        rx = 0;
      }
       
      void setup() {
        Wire.begin(20);
        Wire.onReceive(receiveEvent);
        Wire.onRequest(requestEvent);
        Serial.begin(115200);
       
      }
       
      void loop() {
        delay(100);
      }
      

      src/arch/arm32/mach-t113s3/romdisk/boot/mangopi.json

      524     "i2c-t113:2@0x02502800": {
      525         "clock-name": "bus-i2c2",
      526         "clock-frequency": 400000,
      527         "reset": 466,
      528         "sda-gpio": 133,
      529         "sda-gpio-config": 4,
      530         "scl-gpio": 132,
      531         "scl-gpio-config": 4
      532     },
      
      662     "ts-gt911": {
      663         "i2c-bus": "i2c-t113.2",
      664         "slave-address": 20,
      665         "interrupt-gpio": 38,
      666         "interrupt-gpio-config": 14,
      667         "reset-gpio": 34,
      668         "reset-gpio-config": 1
      669     },
      

      src/arch/arm32/mach-t113s3/driver/ts-gt911.c

       75 static bool_t gt911_write(struct i2c_device_t * dev, u16_t reg, u8_t * buf, int len)
       76 {
       77     struct i2c_msg_t msg;
       78     u8_t mbuf[256];
       79
       80     if(len > sizeof(mbuf) - 1)
       81         len = sizeof(mbuf) - 1;
       82     mbuf[0] = (reg >> 8) & 0xff;
       83     mbuf[1] = (reg >> 0) & 0xff;
       84     memcpy(&mbuf[2], buf, len);
       85
       86     msg.addr = dev->addr;
       87     msg.flags = 0;
       88     msg.len = 32;//len + 2;
       89     msg.buf = &mbuf[0];
       90
       91     if(i2c_transfer(dev->i2c, &msg, 1) != 1)
       92         return FALSE;
       93     return TRUE;
       94 }
      
      134 static bool_t gt911_initial(struct i2c_device_t * dev)
      135 {
      136     u8_t cfg;
      137     u8_t id[4];
      138     u8_t ver[2];
      139
      140     if(!gt911_read(dev, GT911_CONFIG_DATA, &cfg, 1))
      141         return FALSE;
      142     if(!gt911_read(dev, GT911_PRODUCT_ID, &id[0], 4))
      143         return FALSE;
      144     if(!gt911_read(dev, GT911_FIRMWARE_VERSION, &ver[0], 2))
      145         return FALSE;
      146
      147     LOG("GT911 Version: %c%c%c%c(0x%02x%02x)(0x%02x)\r\n", id[0], id[1], id[2], id[3], ver[1], ver[0], cfg);
      148     return gt911_send_cfg(dev, (u8_t *)gt911_config_data, ARRAY_SIZE(gt911_config_data));
      149 }
      
      151 static void gt911_interrupt(void * data)
      152 {
      153     struct input_t * input = (struct input_t *)data;
      154     struct ts_gt911_pdata_t * pdat = (struct ts_gt911_pdata_t *)input->priv;
      155     u8_t status, buf[40];
      156     u8_t * p;
      157     int count, i;
      158     int id, x, y;
      159
      160     LOG("%s++\r\n", __func__);
      161     disable_irq(pdat->irq);
      162     for(i = 0; i < 5; i++)
      163     {
      164         pdat->node[i].valid = 0;
      165     }
      166     if(gt911_read(pdat->dev, GT911_STATUS, &status, 1) && (status & (1 << 7)))
      167     {
      168         count = status & 0x0f;
      169         if(count > 0 && count < 5)
      170         {
      171             if(gt911_read(pdat->dev, GT911_COOR_ADDR, &buf[0], count << 3))
      172             {
      173                 for(i = 0; i < count; i++)
      174                 {
      175                     p = &buf[i << 3];
      176                     id = p[0];
      177                     x = (p[2] << 8) | (p[1] << 0);
      178                     y = (p[4] << 8) | (p[3] << 0);
      179                     LOG("%s, count:%d, x:%d, y:%d\r\n", __func__, count, x, y);
      ...
      209     enable_irq(pdat->irq);
      210     LOG("%s--\r\n", __func__);
      211 }
      

      編譯、下載

      $ make CROSS_COMPILE=arm-linux-gnueabihf- PLATFORM=arm32-t113s3
      $ xfel ddr t113-s3
      $ xfel write 0x40000000 output/xboot.bin
      $ xfel exec 0x40000000
      

      Arduino GT911可以正常工作,但是,中斷PB6無法被觸發

      [    0.260214]GT911 Version: ABCD(0x3412)(0x01)
      [    0.287074]Probe device 'ts-gt911.0' with ts-gt911
      

      為了方便測試,司徒將PB6加上提昇電阻並且改成Falling中斷觸發

      282     LOG("%s, gpio:%d, gpiocfg:%d, irqnum:%d\r\n", __func__, gpio, gpiocfg, irq);
      283     if(gpio >= 0)
      284     {
      285         if(gpiocfg >= 0)
      286             gpio_set_cfg(gpio, gpiocfg);
      287         gpio_set_pull(gpio, GPIO_PULL_UP);
      288     }
      289     request_irq(pdat->irq, gt911_interrupt, IRQ_TYPE_EDGE_FALLING, input);
      

      PB6=GPIO38、GPIOCFG=14、IRQ=262,這個IRQ應該是抓錯了?

      [    0.266982]ts_gt911_probe, gpio:38, gpiocfg:14, irqnum:262
      

      7.jpg

      src/arch/arm32/mach-t113s3/romdisk/boot/mangopi.json

      388     "irq-gic400@0x03020000": { "interrupt-base": 32, "interrupt-count": 224 },
      389     "irq-t113-gpio@0x02000220": { "interrupt-base": 224, "interrupt-count":  8, "interrupt-parent":  101 },
      390     "irq-t113-gpio@0x02000240": { "interrupt-base": 256, "interrupt-count":  8, "interrupt-parent":  103 },
      391     "irq-t113-gpio@0x02000260": { "interrupt-base": 288, "interrupt-count": 23, "interrupt-parent":  105 },
      392     "irq-t113-gpio@0x02000280": { "interrupt-base": 320, "interrupt-count": 14, "interrupt-parent":  107 },
      393     "irq-t113-gpio@0x020002a0": { "interrupt-base": 352, "interrupt-count":  7, "interrupt-parent":  109 },
      394     "irq-t113-gpio@0x020002c0": { "interrupt-base": 384, "interrupt-count": 16, "interrupt-parent":  111 },
      

      src/driver/interrupt/interrupt.c

      191 bool_t request_irq(int irq, void (*func)(void *), enum irq_type_t type, void * data)
      192 {
      193     struct irqchip_t * chip;
      194     int offset;
      195
      196     if(!func)
      197         return FALSE;
      198
      199     chip = search_irqchip(irq);
      200     if(!chip)
      201         return FALSE;
      202
      203     offset = irq - chip->base;
      204     if(chip->handler[offset].func != null_interrupt_function) {
      205         return FALSE;
      206     }
      207
      208     LOG("%s, irq:%d, chip->base:%d, offset:%d\r\n", __func__, irq, chip->base, offset);
      

      XBoot修改到的中斷地址是屬於PC6,但是司徒的中斷是設定成PB6

      [    0.272634]request_irq, irq:262, chip->base:256, offset:6
      

      src/arch/arm32/mach-t113s3/driver/irq-t113-gpio.c

       92     addr = pdat->virt + GPIO_INT_CFG0 + ((offset >> 3) << 2);
       93     val = read32(addr);
       94     val &= ~(0xf << ((offset & 0x7) << 2));
       95     val |= ((cfg & 0x7) << ((offset & 0x7) << 2));
       96     write32(addr, val);
       97
       98     LOG("%s, addr:%p, type:%d, offset:%d\r\n", __func__, addr, type, offset);
      

      果然修改到PC6 0x02000240

      [    0.268151]ts_gt911_probe, gpio:38, gpiocfg:14, irqnum:262
      [    0.273812]request_irq, irq:262, chip->base:256, offset:6
      [    0.279202]irq_t113_gpio_settype, addr:0x02000240, type:3, offset:6
      [    0.285373]Probe device 'ts-gt911.0' with ts-gt911
      

      PB6是位於0x02000230
      8.jpg

      Workaround (src/driver/interrupt/interrupt.c)

       62 static struct irqchip_t * search_irqchip(int irq)
       63 {
       64     struct device_t * pos, * n;
       65     struct irqchip_t * chip;
       66
       67     list_for_each_entry_safe(pos, n, &__device_head[DEVICE_TYPE_IRQCHIP], head)
       68     {
       69         chip = (struct irqchip_t *)(pos->priv);
       70         if(irq == 230){
       71             if(chip->base == 224){
       72                 return chip;
       73             }
       74             continue;
       75         }
       76         if((irq >= chip->base) && (irq < (chip->base + chip->nirq)))
       77             return chip;
       78     }
       79     return NULL;
       80 }
      
      191 bool_t request_irq(int irq, void (*func)(void *), enum irq_type_t type, void * data)
      192 {
      193     struct irqchip_t * chip;
      194     int offset;
      195
      196     if(!func)
      197         return FALSE;
      198
      199     if(irq == 262){
      200         irq-= 32;
      201     }
      

      修改後,就可以正常中斷觸發並且回報觸控點

      [    0.260653]GT911 Version: ABCD(0x3412)(0x01)
      [    0.266935]ts_gt911_probe, gpio:38, gpiocfg:14, irqnum:262
      [    0.272326]request_irq, irq:230, chip->base:224, offset:6
      [    0.277959]irq_t113_gpio_settype, addr:0x02000220, type:3, offset:6
      [    0.299301]Probe device 'ts-gt911.0' with ts-gt911
      [    0.304091]Probe device 'g2d-t113.0' with g2d-t113
      [    0.310178]Probe device 'fb-t113-rgb.0' with fb-t113-rgb
      [    0.315658]Probe device 'console-uart.0' with console-uart
      [    0.322001]mount /private with 'ram' filesystem
      Press any key to stop auto boot:  0.000
      xboot: /# 
      [    5.434256]gt911_interrupt++
      [    5.440101]gt911_interrupt, count:1, x:1, y:1
      [    5.446270]gt911_interrupt--
      [    9.054572]gt911_interrupt++
      [    9.060405]gt911_interrupt, count:1, x:2, y:2
      [    9.066782]gt911_interrupt--
      
      posted in 爱搞机专区
      steward
      司徒
    • Reply: MQ-T113使用xboot驱动GT911时中断无法使用

      @ary_ye 不過, 從你的圖片看來, 這個 I2C 訊號也不太像是 SCL, SDA 的訊號 ? 這樣你還可以從 xboot 拿到觸控的資料 ?

      posted in 爱搞机专区
      steward
      司徒
    • Reply: MQ-T113使用xboot驱动GT911时中断无法使用

      目前 XBOOT 有支援 GT-911 的平台如下:

      ./src/arch/riscv64/mach-f133/driver/ts-gt911.c
      ./src/arch/arm32/mach-t113s3jd/driver/ts-gt911.c
      ./src/arch/arm32/mach-t113s3/driver/ts-gt911.c
      ./src/arch/arm32/mach-z11s/driver/ts-gt911.c
      

      手上剛好有 F133 板子, 但是我沒有 GT-911 觸控板, 如果需要或許可以用 Arduino 模擬~
      1.jpg

      不過, 找問題的方式應該大同小異, 因此, 我用 F133 說一下,
      json 檔案確定有設定成 okay

      "ts-f133@0x02009c00": {
              "clock-name": "link-tpadc",
              "interrupt": 78, 
              "reset": 1136,
              "median-filter-length": 5,
              "mean-filter-length": 5,
              "calibration": [168012, -57, -137136144, -344, 8674, -2840431, 65536],
              "status": "okay"
          },  
      
          "ts-gt911": {
              "i2c-bus": "i2c-f133.2",
              "slave-address": 20, 
              "interrupt-gpio": 35, 
              "interrupt-gpio-config": 14, 
              "reset-gpio": 34, 
              "reset-gpio-config": 1,
              "status": "okay"
          }, 
      

      然後埋一些 LOG, 先確定觸控板有被正確配置

      static bool_t gt911_initial(struct i2c_device_t * dev)
      {
          u8_t cfg;
          u8_t id[4];
          u8_t ver[2];
      
          if(!gt911_read(dev, GT911_CONFIG_DATA, &cfg, 1)) {
              LOG("GT911: failed to read config data\n");
              return FALSE;
          }   
          if(!gt911_read(dev, GT911_PRODUCT_ID, &id[0], 4)) {
              LOG("GT911: failed to read product id\n");
              return FALSE;
          }   
          if(!gt911_read(dev, GT911_FIRMWARE_VERSION, &ver[0], 2)) {
              LOG("GT911: failed to read firmware version\n");
              return FALSE;
          }   
      
          LOG("GT911 Version: %c%c%c%c(0x%02x%02x)(0x%02x)", id[0], id[1], id[2], id[3], ver[1], ver[0], cfg);
          return gt911_send_cfg(dev, (u8_t *)gt911_config_data, ARRAY_SIZE(gt911_config_data));
      }
      

      埋好 LOG 之後, 下載測試

      $ make CROSS_COMPILE=/opt/f133/bin/riscv64-unknown-linux-gnu- PLATFORM=riscv64-f133
      $ xfel ddr f133 && xfel write 0x40000000 output/xboot.bin && xfel exec 0x40000000
      

      因為沒有連接 GT-911, 因此, 在讀取 config data 時就會出錯

      [    0.261738]GT911: failed to read config data
      

      因此, 幾個找問題的方式提供給你參考 (跟著訊號的方向找問題就可以)

      1. 確定觸控的資訊可以被正確讀取到, 你應該可以從 UART 看到 "GT911 Version: xxx"
      2. 如果可以讀取到觸控資訊, 那可以往中斷腳位的方向找問題, 例如:沒接好或者被拉高拉低等問題
      posted in 爱搞机专区
      steward
      司徒
    • Reply: MQ-T113使用xboot驱动GT911时中断无法使用

      @ary_ye 這邊是愛搞機器的專區, 可以請問你這個是什麼遊戲機嗎?

      posted in 爱搞机专区
      steward
      司徒
    • Reply: 用 ST7789V LCD 在 lichee pi nano (f1c100s)

      No, you need to fix your hardware firstly. Here is the LCD pinout for Lichee Nano:
      1.jpg

      And here is your LCD panel:
      1.png

      posted in Linux
      steward
      司徒
    • Reply: 可以在這裡寫非全志晶片的文章嗎 ?

      @lovexulu 好的~感謝你的資訊~

      posted in 爱搞机专区
      steward
      司徒
    • Reply: 可以在這裡寫非全志晶片的文章嗎 ?

      @aldfaaa 不瞞你說~我也是這樣覺得, 應該不用太折騰 RISC-V 指令集~哈 🏇🏇

      posted in 爱搞机专区
      steward
      司徒
    • Reply: 用 ST7789V LCD 在 lichee pi nano (f1c100s)

      Here is the schematic of PocketGo handheld: https://github.com/steward-fu/archives/releases/download/pocketgo/doc_schematic.pdf

      It seems the pinout are not same as PocketGo. So, you cannot replace it directly.
      1.jpg

      posted in Linux
      steward
      司徒
    • Reply: 可以在這裡寫非全志晶片的文章嗎 ?

      @lovexulu 你對全志晶片好熟悉~小弟給大佬請安💃💃

      V851S這顆晶片也很適合使用, 我希望的需求是:
      QFP包裝
      兩核心(CPU >= 400MHz)
      RAM >= 64MB
      WiFi
      BT

      因為我希望開機有兩種OS模式, 其中一個如果有WiFi協助是最好, 不知道全志有這樣的晶片嗎 ?

      posted in 爱搞机专区
      steward
      司徒