Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Suspected bug in sunxi-nand driver

Featured Replies

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

  • Author

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

  • Author

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.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.