Jump to content

Recommended Posts

Posted

Hi,

Recently I've made a custom kernel for an Olimex Lime board. The NAND driver refused to load and reported "kernel divide by zero". I believe the problem is in drivers/block/sunxi-nand/nfd/nand_block.c in function get_cmu_clk. The function (with my patch line) is:

 

__u32 get_cmu_clk(void)

{

__u32 reg_val;

__u32 div_p, factor_n;

__u32 factor_k, factor_m;

__u32 clock;

 

reg_val = *(volatile unsigned int *)(0xf1c20000 + 0x20);

div_p = (reg_val >> 16) & 0x3;

factor_n = (reg_val >> 8) & 0x1f;

factor_k = ((reg_val >> 4) & 0x3) + 1;

factor_m = ((reg_val >> 0) & 0x3) + 1;

 

div_p = 1 << ((reg_val >> 16) & 0x3)); // SJS 2016-04-30

 

clock = 24 * factor_n * factor_k/div_p/factor_m;

 

return clock;

}

 

The problem occurs on my Lime board because Pll5.FactorP (div_p above) is zero. Other A20 boards have 1 here and I haven't figured why the Lime board is different. The A20 manual states FactorP is a two-bit field that can be 1/2/4/8. This means the value stored here is a power of two rather than a plain divisor. So I added the patch line to calculate the correct divisor.

 

Any opinions or comments please ? The lt;< above is because HTML choke on less-than signs.

 

Update: Testing on other boards shows that NAND access only works when div_p is set to 1. Maybe it should be dropped from the equation.

 

Cheers,

Steven

Posted

I'm using the legacy kernel. Is there a suitable NAND driver in the mainline kernel now ?

 

The bug only afects my Lime board. All other A10/A20 boards I've checked work fine. But on the Lime I was getting "kernel divide by zero" when installing the sunxi_nand module. The odd thing about the Lime boards is that it has 0xB1049491 in the CCU PL5 register whereas other boards have 0xB1059491 or 0xB1059291.

 

Update: I've just found a patch at https://github.com/linux-sunxi/linux-sunxi/blob/sunxi-3.4/drivers/block/sunxi_nand/nfd/nand_blk.cthat fixes the problem. I don't think this patch is in the Armbian 3.4.106 kernel but it might be in the later patches. My bug report here is old news.

 

Cheers,

Steven

Posted

Update: I've just found a patch at https://github.com/l.../nfd/nand_blk.cthat fixes the problem. I don't think this patch is in the Armbian 3.4.106 kernel but it might be in the later patches. My bug report here is old news. 

 

We are using this repository (linux-sunxi) for some time, precisely from 1.9.2015 / 3.4.108, when we added A10 builds. 

Posted

Hi Igor,

 

Thanks for the reply. Is there a repository for your current kernel or do I need to download the linux-sunxi one and apply your patch files ? I'm tempted to drop my modified kernel and start again with yours.

 

Cheers,

Steven

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines