Latest product reviews
ARCHOS 50 Diamond
ARCHOS GamePad2
ARCHOS
Smartphones
ARCHOS
TV Connect
ARCHOS 101 XS

A A A
Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Register Lost password?

ClockworkMod (CWM) Recovery easy install for RK3066 and RK3188 -- TWRP/CWM Flash-Tool and root for RK3288

 Please donate to support OMA and CrewRKTablets firmware work, thank you !

sp_Feed sp_TopicIcon
Kernel development Haierpad 1043 (iFive X3 / RK3188): Help with SD and wifi needed
Avatar
DerFetzer
Member
Forum Posts: 11
Member Since:
2016/08/21
sp_UserOfflineSmall Offline
16
2016/08/22 - 22:24
sp_Permalink sp_Print

void machine_rk30_board_init()
{
  signed int v0;
  int *v1;
  int *v2;
  signed int v3;
  int v4;
  int v5;
  int v6;
  int v7;
  int v8;
  int v9;
  signed int v10;
  int v11;
  signed int v12;

  gpio_request(160, "poweronpin");
  gpio_direction_output(160, 1);
  dword_C0E2F0A8 = rk30_pm_power_off;
  gpio_direction_output(160, 1);

  // rk30_i2c_register_board_info()
  i2c_register_board_info(0, "gs_mma8452", 3);
  i2c_register_board_info(1, "ricoh619", 1);
  i2c_register_board_info(2, "light_cm3232", 2);
  i2c_register_board_info(3, "rk616", 0);
  i2c_register_board_info(4, "rk616", 1);
  // end

  platform_add_devices(&devices, 5);

  // rk_platform_add_display_devices()
  platform_device_register(&unk_C0DD1A78);
  printk("<6>lcdc0 is used as external display device contoller!
");
  printk("<6>lcdc1 is used as primary display device controller!
");
  platform_device_register(&unk_C0DD1910);
  if ( &unk_C0DD17A8 )
    platform_device_register(&unk_C0DD17A8);
  v0 = 0;
  platform_device_register(&unk_C0DD1BE0);
  v1 = &dword_C0E3211C;
  gpio_request(205, 0);
  gpio_direction_output(205, 0);
  // end

  // rk29sdk_wifi_bt_gpio_control_init()
  v2 = &dword_C0E3211C;
  while ( 1 )
  {
    v3 = v0 <= 7 ? 4096 : 0x2000;
    v4 = dev_alloc_skb(v3);
    v2[1] = v4;
    ++v2;
    if ( !v4 )
      break;
    ++v0;
    if ( v0 == 16 )
    {
      v5 = 0;
      v6 = 0;
      while ( 1 )
      {
        v7 = _kmalloc(dword_C0DCFA18[v5 + 1], 208);
        dword_C0DCFA18[v5] = v7;
        if ( !v7 )
          break;
        ++v6;
        v5 += 2;
        if ( v6 == 4 )
          goto LABEL_19;
      }
      v8 = 0;
      printk("<3>Failed to mem_alloc for WLAN
");
      while ( v8 < v6 )
      {
        v9 = dword_C0DCFA18[2 * v8++];
        kfree(v9);
      }
      break;
    }
  }
  v10 = 0;
  printk("<3>Failed to skb_alloc for WLAN
");
  while ( v10 < v0 )
  {
    v11 = v1[1];
    ++v1;
    ++v10;
    consume_skb(v11);
  }
LABEL_19:
  iomux_set(0);
  if ( gpio_request(280, "wifi_power") )
  {
    v12 = -1060219719;
  }
  else
  {
    gpio_direction_output(280, 0);
    gpio_request(274, "mmc1-data1");
    gpio_direction_output(274, 0);
    gpio_request(275, "mmc1-data2");
    gpio_direction_output(275, 0);
    gpio_request(276, "mmc1-data3");
    gpio_direction_output(276, 0);
    rk29_sdmmc_gpio_open(1, 0);
    v12 = -1060219647;
  }
  printk(v12, -1061238907);
  // end
}

Avatar
mussonero1

Contributor

Firmware Guru
Forum Posts: 350
Member Since:
2014/08/02
sp_UserOfflineSmall Offline

Thanks Received: 70
17
2016/08/22 - 22:33
sp_Permalink sp_Print

Ok, now it more clear that your stock kernel using config wifi control function , the question now why sdmmc_rescan dose not start up ? .

Avatar
mussonero1

Contributor

Firmware Guru
Forum Posts: 350
Member Since:
2014/08/02
sp_UserOfflineSmall Offline

Thanks Received: 70
18
2016/08/22 - 22:40
sp_Permalink sp_Print sp_EditHistory

edit:

it is ok, my bad your wifi use mmc1

mmc_rescan Begin....[mmc1]

it is too late here and i did not not sleep all day, cya tomorrow

Avatar
DerFetzer
Member
Forum Posts: 11
Member Since:
2016/08/21
sp_UserOfflineSmall Offline
19
2016/08/22 - 23:03
sp_Permalink sp_Print

Yes, no problem.

I noticed a strange thing in function rk29_sdmmc_set_iomux() in rk-sdmmc-ops.c. There output pins are configured to their alternate functions with iomux_set(). But in sdmmc0 part this function is consequently called with values corresponding to RK3066B chip:

// kernel source
iomux_set(rksdmmc0_gpio_init.data1_gpio.iomux.fmux); // --> iomux_set(MMC0_D1) --> iomux_set(0x3B31)

// decompiled
iomux_Set(0x3A51); // --> RK3188: iomux_set(I2C4_SCL), RK3066B: iomux_set(MMC0_D1)

This deviation can also be observed in other functions related to SD using the iomux_set() method. SDIO pins (mmc1) are the right values because there is no difference between RK3188 and RK3066B there.

I've tried to change all the values in my source code accordingly but this leads to worse behaviour as expected. As I see it this could never work anyway because you are configuring the wrong pin with this function. Question is how it can work in the stock kernel? Maybe there is a difference in the iomux_set() function?

 

void __fastcall rk29_sdmmc_set_iomux(int device_id, unsigned int bus_width)
{
  signed int v2;

  if ( device_id )
  {
    if ( device_id == 1 )                       // mmc1
    {
      iomux_set(0x3C01u);                       // MMC1_CMD
      iomux_set(0x3C51u);                       // MMC1_CLKOUT
      iomux_set(0x3C11u);                       // MMC1_D0
      iomux_set(0x3C21u);                       // MMC1_D1
      iomux_set(0x3C31u);                       // MMC1_D2
      iomux_set(0x3C41u);                       // MMC1_D3
      vFED08104 = 0x1000000;
      vFED08100 = 786444;
    }
  }
  else                                          // mmc0
  {
    if ( bus_width == 0xFFFF )
    {
      iomux_set(0x3B01u);                       // MMC0_CLKOUT
      gpio_request(257, "sdmmc-power");
      v2 = 257;
    }
    else
    {
      if ( bus_width == 0x10000 )
        return;
      if ( bus_width == 1 )
      {
        iomux_set(0x3A51u);                     // I2C4_SCL
        iomux_set(0x3A61u);                     // MMC0_RSTNOUT
        iomux_set(0x3A71u);                     // MMC0_PWREN
        return;
      }
      iomux_set(0x3A31u);                       // I2C3_SCL
      iomux_set(0x3A21u);                       // I2C3_SDA
      iomux_set(0x3A41u);                       // I2C4_SDA
      vFED08104 = 0x10000000;
      vFED080FC = 12583104;
      gpio_request(261, "mmc0-data1");
      gpio_direction_output(261, 1);
      gpio_request(262, "mmc0-data2");
      gpio_direction_output(262, 1);
      gpio_request(263, "mmc0-data3");
      v2 = 263;
    }
    gpio_direction_output(v2, 1);
  }
}

 

void __fastcall iomux_set(unsigned int mode)
{
  if ( mode != -1 && mode >> 12 <= 3 )
    *(4 * (((mode >> 8) & 0xF) + 4 * (mode >> 12) + 2142511118)) = ((mode & 0xF) << 2 * (mode >> 4))
                                                                 + (3 << 2 * ((mode >> 4) + 8));
  else
    printk("<6><%s> mode(0x%x) is invalid
", "iomux_set", mode);
}


Avatar
mussonero1

Contributor

Firmware Guru
Forum Posts: 350
Member Since:
2014/08/02
sp_UserOfflineSmall Offline

Thanks Received: 70
20
2016/08/23 - 15:10
sp_Permalink sp_Print

I was wondering why the # CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD is not set 

Is not enabled in your config file?. since you wifi use mmc1 ,, and since was set to  !(!!SDMMC_USE_NEW_IOMUX_API .)..

I think CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD should be enabled .

Avatar
DerFetzer
Member
Forum Posts: 11
Member Since:
2016/08/21
sp_UserOfflineSmall Offline
21
2016/08/23 - 22:53
sp_Permalink sp_Print

I've tried this parameter a while ago. With it the SDMMC0 controller strangely got a bit further but SDMMC1 could not find a host anymore.

...
sdmmc_rescan_try_freq..1913..  ===== Initialize SD-card successfully. [mmc0]
...
sdmmc_rescan..2026..  ====find no SDMMC host. [mmc1]
...

So today I looked at all the positions in the code where this parameter is used and I compared them with the decompiled stock kernel. The result is that I have found not a single trace of those code fragments so I am pretty sure that this parameter was not set when compiling the stock kernel.

Avatar
DerFetzer
Member
Forum Posts: 11
Member Since:
2016/08/21
sp_UserOfflineSmall Offline
22
2016/08/30 - 22:53
sp_Permalink sp_Print sp_EditHistory

As I assumed there was a really simple problem: I do not know how often I had a look at the machine_rk30_board_init() function but until the last time I did not notice that there is an additional GPIO registered (250 --> RK30_PIN1_PB5). This is sort of an enable pin of the AP6210. After requesting this pin I now have working wifi and bluetooth! 🙂

But the thing that is not working yet is SD card. I noticed that behaviour is different when I power off the tablet and power it back on (or booting after stock kernel!) and when I restart it directly. In the first case the SD card is initialized successfully in the beginning but then there are I/O errors when accessing the card:

[  141.841480] end_request: I/O error, dev mmcblk0, sector 62333830
[  152.971412] 1846... cmd=17(arg=0x3b72387), INT_CMD_DONE timeout, errorStep=0xfd, host->state=1 [sd_mmc]
[  152.971471] rk29_sdmmc_command_complete..2908...CMD17(arg=0x3b72387), hoststate=1, errorTimes=1, errorStep=0x1e ! [sd_mmc]
[  152.971542] end_request: I/O error, dev mmcblk0, sector 62333831
[  152.971569] Buffer I/O error on device mmcblk0p1, logical block 7791472
[  166.971469] end_request: I/O error, dev mmcblk0, sector 62333824

In the second case, that means after directly restarting I get the following dmesg outputs as usual:

[    3.760141] rk29_sdmmc_command_complete..2908...CMD8(arg=0x1aa), hoststate=1, errorTimes=1, errorStep=0x1e ! [sd_mmc]
[    3.760631] rk29_sdmmc_command_complete..2908...CMD55(arg=0x0), hoststate=1, errorTimes=1, errorStep=0x1e ! [sd_mmc]
[    3.761967] mmc_sd_get_cid..737..  ====*Identify the card as SD , but OCR error, so fail to initialize.[mmc0]
[    3.762025] mmc0: mmc_sd_init_card() failure (err = -12)
[    3.762057] mmc0: error -12 whilst initialising SD card

While browsing the internet for a solution I found a Rockchip manual describing SD/MMC/SDIO operations. Unfortunately it is in Chinese, but it contains some dmesg output similar to mine. Using an online translation engine I got some hints that this dmesg output is related to problems with voltage and/or board layout.

I then wrote a simple kernel module printing the values of GRF and GPIO registers and compared them between stock and custom kernel. But unfortunately I did not notice any meaningful differences.

Avatar
DerFetzer
Member
Forum Posts: 11
Member Since:
2016/08/21
sp_UserOfflineSmall Offline
23
2016/09/26 - 18:31
sp_Permalink sp_Print

And indeed it had been a problem with the voltage. With a SD breakout board I measured the voltages of the pins. After some time I noticed that the VCC was on at booting of the kernel and turned off shortly after. Strangely this happend at roughly the same time as hearing initialization of the cameras. So I took a look inside the camera driver and noticed by comparison to the stock kernel that there is only one voltage regulator needed. The second one is responsible for SD card.

So long story short: After some other minor problems I now have a fully working self-made kernel for my tablet. 🙂

Thank you for your help!

Avatar
Oma7144

Moderator

Firmware Guru
Forum Posts: 6315
Member Since:
2012/10/06
sp_UserOfflineSmall Offline

Thanks Received: 1378
24
2016/10/02 - 18:28
sp_Permalink sp_Print

Well done!

Feel free to share your work here to make is available for other user.

- Oma -

Forum Timezone: Europe/Paris

Most Users Ever Online: 749

Currently Online:
74 Guest(s)

Currently Browsing this Page:
1 Guest(s)


Devices in use: Desktop (70), Phone (3), Tablet (1)

Top Posters:

finless: 604

DarthJabba: 551

maikal: 394

mussonero1: 350

alex: 252

damo: 243

DanielVd: 237

Mark06: 222

Newest Members:

jone2122

NOnoS

ammie

Andreasse

richard0085

saradavis1

Forum Stats:

Groups: 10

Forums: 185

Topics: 6037

Posts: 60500

 

Member Stats:

Guest Posters: 43

Members: 262194

Moderators: 5

Admins: 1

Administrators: admin

Moderators: globula_neagra, exelletor, JochenKauz, Oma7144, cracktech


CrewRKTablets moderators: JochenKauz and Astralix