arnarg / hddled_tmj33

A linux module for controlling the HDD LEDs on Terramaster NAS devices with Intel J33xx CPU
16 stars 4 forks source link

How to add two extra green LEDs (NIC, POWER) to this modules? #2

Open ataa opened 4 years ago

ataa commented 4 years ago

TerraMaster source listed 2 extra LEDs, how can I add them to your modules?

In their published source, there are 12 LEDs to control instead of 10:

gpbcon[0]  =  (volatile unsigned long *)ioremap(0xfed0d1b8, 16);    //GPIO14       
    gpbcon[1]  =  (volatile unsigned long *)ioremap(0xfed0d028, 16);    //GPIO24
    gpbcon[2]  =  (volatile unsigned long *)ioremap(0xfed0d0b8, 16);    //GPIO18
    gpbcon[3]  =  (volatile unsigned long *)ioremap(0xfed0d0d8, 16);    //GPIO23    

    gpbcon[4]  =  (volatile unsigned long *)ioremap(0xfed0d088, 16);    //GPIO17
    gpbcon[5]  =  (volatile unsigned long *)ioremap(0xfed0d0a8, 16);    //GPIO22
    gpbcon[6]  =  (volatile unsigned long *)ioremap(0xfed0d048, 16);    //GPIO16

    gpbcon[7]  =  (volatile unsigned long *)ioremap(0xfed0d068, 16);    //GPIO21 
    gpbcon[8]  =  (volatile unsigned long *)ioremap(0xfed0d018, 16);    //GPIO15
    gpbcon[9]  =  (volatile unsigned long *)ioremap(0xfed0d038, 16);    //GPIO20
    gpbcon[10] =  (volatile unsigned long *)ioremap(0xfed0d058, 16);    //GPIO25
    gpbcon[11] =  (volatile unsigned long *)ioremap(0xfed0d098, 16);    //GPIO26
arnarg commented 4 years ago

On my unit the NIC led blinks with network activity, I would assume it's wired to the NIC itself and linux is not controlling it at all. And power is constantly on.

In their published source, there are 12 LEDs to control instead of 10

What published source?

ataa commented 4 years ago

Someone has decompiled TerraMaster binary and found the addresses below, He mentioned that he managed to control Lan LED, not sure if the hardware for F5-221 and F4-220 is identical or not. On my F5-221, there are 5 two color LEDs and two green LEDs for Power and Network activity. I wanted to add two extra addresses to your module but couldn't figure out how to do it.

static phys_addr_t map_addrs[12] = {
    0xfed0d1b8,
    0xfed0d028,
    0xfed0d0b8,
    0xfed0d0d8,
    0xfed0d088,
    0xfed0d0a8,
    0xfed0d048,
    0xfed0d068,
    0xfed0d018,
    0xfed0d038,
    0xfed0d058,
    0xfed0d098
};

right now I am using your module to show service status and a simple bootup/shutdown light patterns. Also researching on how to make a simple VU meter using mpd fifo output. so being able to control two extra leds would be nice. Thank you

arnarg commented 4 years ago

You could try increasing the size of hddledDevices and hddleds arrays at the top by one. If that works it will most likely handle NIC and power as a single bi-color LED so you will have to treat one of them as the green and the other as the red color by piping [0-3] into /dev/hddled6.

ataa commented 4 years ago

Thanks for quick reply, I changed them to 6 and increased the version number then build the module with dkms, now piping 0-3 to /dev/hddled6 changes LED 1 and 2. What about adding LED 11,12 addresses to the code? Does it calculate them automatically?

arnarg commented 4 years ago

That actually makes sense. As is explained in the README, there are 10 addresses, the first 5 are the green LEDs and the second 5 are the red ones. So by adding another index to the array we start looking in the red LED area, my bad.

I get the base address of whatever is controlling the LEDs by calling read_base() (this is the only code I copied straight from the source I got from Terramaster and I don't really understand it). Then to find the first green LED by adding the magic number 0xC505B8 (again, something I found in the original source). To get the first red LED I can add 0x28 to the address of the respectable green LED. Then add 0x8 to get the next green LED. This is explained a little better in the README.

I'm not sure where exactly in the address space the power and nic LEDs are though.

cinzas commented 4 years ago

Hi

I believe this can help you: https://github.com/stroyan/led-drv-f4-220

I'm having issues compiling both modules on OpenMediaVault 5.6. Alhtough they work on 5.4

ataa commented 4 years ago

Thanks, I already tried that driver on my F5-221 (J3355), it does not work on mine, later found that the hardware in F4-220 (J1800) is different than mine (tmj33). With minor change in Arnarg code, I was able to compile it in kernel 5.6 upto 5.7.1, I can only control 5 HDD LEDs. Have you managed to control power/nic LED?

cinzas commented 4 years ago

Thanks

Just forked it : https://github.com/cinzas/led-drv-f4-220

I can now compile on omv 5.6.

I can control the nic led.

RonaldJerez commented 2 years ago

Someone has decompiled TerraMaster binary and found the addresses below, He mentioned that he managed to control Lan LED, not sure if the hardware for F5-221 and F4-220 is identical or not. On my F5-221, there are 5 two color LEDs and two green LEDs for Power and Network activity. I wanted to add two extra addresses to your module but couldn't figure out how to do it.

static phys_addr_t map_addrs[12] = {
  0xfed0d1b8,
  0xfed0d028,
  0xfed0d0b8,
  0xfed0d0d8,
  0xfed0d088,
  0xfed0d0a8,
  0xfed0d048,
  0xfed0d068,
  0xfed0d018,
  0xfed0d038,
  0xfed0d058,
  0xfed0d098
};

right now I am using your module to show service status and a simple bootup/shutdown light patterns. Also researching on how to make a simple VU meter using mpd fifo output. so being able to control two extra leds would be nice. Thank you

Can you share those scripts you have? I am looking to do something similar on mine.