public inbox for outreachy@lists.linux.dev
 help / color / mirror / Atom feed
* Help on Modifying a Driver on Native Linux
@ 2025-04-01 22:36 Richard Akintola
  2025-04-02  5:05 ` Julia Lawall
  2025-04-02  6:13 ` Julia Lawall
  0 siblings, 2 replies; 3+ messages in thread
From: Richard Akintola @ 2025-04-01 22:36 UTC (permalink / raw)
  To: outreachy; +Cc: julia.lawall, princerichard17a

I learnt that e1000 didn't work because the driver is included in VM
images and not on Linux native, and a variant of e1000 on Linux native
is the e1000e driver.

Below are some of the drivers that one could modify on Linux native
in order have the "I can modify Linux kernel\n" effect.

Using the e1000e driver

1. vim drivers/net/ethernet/intel/e1000e/netdev.c

2. Find the probe function

static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
        struct net_device *netdev;
        struct e1000_adapter *adapter;
        struct e1000_hw *hw;
        const struct e1000_info *ei = e1000_info_tbl[ent->driver_data];
        resource_size_t mmio_start, mmio_len;
        resource_size_t flash_start, flash_len;
        static int cards_found;
        u16 aspm_disable_flag = 0;
        u16 eeprom_data = 0;
        u16 eeprom_apme_mask = E1000_EEPROM_APME;
        int bars, i, err;
        s32 ret_val = 0;

        printk(KERN_DEBUG "I can modify the Linux kernel\n");

3. Save the file and recompile the kernel, you should see the text
printed when you run the "dmesg | less" command after rebooting.

Or you could use the bluetooth driver

1. vim drivers/bluetooth/btusb.c

2. Find the probe function

static int btusb_probe(struct usb_interface *intf,
                       const struct usb_device_id *id)
{
        struct usb_endpoint_descriptor *ep_desc;
        struct gpio_desc *reset_gpio;
        struct btusb_data *data;
        struct hci_dev *hdev;
        unsigned ifnum_base;
        int i, err, priv_size;

        printk(KERN_DEBUG "I can modify the Linux Kernel\n");


3. Save the file and recompile the kernel, you should see the text
printed when you run the "dmesg | less" command after rebooting.

I hope this helps.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Help on Modifying a Driver on Native Linux
  2025-04-01 22:36 Help on Modifying a Driver on Native Linux Richard Akintola
@ 2025-04-02  5:05 ` Julia Lawall
  2025-04-02  6:13 ` Julia Lawall
  1 sibling, 0 replies; 3+ messages in thread
From: Julia Lawall @ 2025-04-02  5:05 UTC (permalink / raw)
  To: Richard Akintola; +Cc: outreachy, princerichard17a


Sent from my iPhone

> On 2 Apr 2025, at 00:36, Richard Akintola <princerichard17a@gmail.com> wrote:
> 
> I learnt that e1000 didn't work because the driver is included in VM
> images and not on Linux native, and a variant of e1000 on Linux native
> is the e1000e driver.
> 
> Below are some of the drivers that one could modify on Linux native
> in order have the "I can modify Linux kernel\n" effect.
> 

Super. I will update the tutorial accordingly.

> Using the e1000e driver
> 
> 1. vim drivers/net/ethernet/intel/e1000e/netdev.c
> 
> 2. Find the probe function
> 
> static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> {
>        struct net_device *netdev;
>        struct e1000_adapter *adapter;
>        struct e1000_hw *hw;
>        const struct e1000_info *ei = e1000_info_tbl[ent->driver_data];
>        resource_size_t mmio_start, mmio_len;
>        resource_size_t flash_start, flash_len;
>        static int cards_found;
>        u16 aspm_disable_flag = 0;
>        u16 eeprom_data = 0;
>        u16 eeprom_apme_mask = E1000_EEPROM_APME;
>        int bars, i, err;
>        s32 ret_val = 0;
> 
>        printk(KERN_DEBUG "I can modify the Linux kernel\n");
> 
> 3. Save the file and recompile the kernel, you should see the text
> printed when you run the "dmesg | less" command after rebooting.
> 
> Or you could use the bluetooth driver
> 
> 1. vim drivers/bluetooth/btusb.c
> 
> 2. Find the probe function
> 
> static int btusb_probe(struct usb_interface *intf,
>                       const struct usb_device_id *id)
> {
>        struct usb_endpoint_descriptor *ep_desc;
>        struct gpio_desc *reset_gpio;
>        struct btusb_data *data;
>        struct hci_dev *hdev;
>        unsigned ifnum_base;
>        int i, err, priv_size;
> 
>        printk(KERN_DEBUG "I can modify the Linux Kernel\n");
> 
> 
> 3. Save the file and recompile the kernel, you should see the text
> printed when you run the "dmesg | less" command after rebooting.
> 
> I hope this helps.
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Help on Modifying a Driver on Native Linux
  2025-04-01 22:36 Help on Modifying a Driver on Native Linux Richard Akintola
  2025-04-02  5:05 ` Julia Lawall
@ 2025-04-02  6:13 ` Julia Lawall
  1 sibling, 0 replies; 3+ messages in thread
From: Julia Lawall @ 2025-04-02  6:13 UTC (permalink / raw)
  To: Richard Akintola; +Cc: outreachy



On Tue, 1 Apr 2025, Richard Akintola wrote:

> I learnt that e1000 didn't work because the driver is included in VM
> images and not on Linux native, and a variant of e1000 on Linux native
> is the e1000e driver.

Thanks for the suggested text.  You can see it here:

https://kernelnewbies.org/FirstKernelPatch#DriverChange

julia


>
> Below are some of the drivers that one could modify on Linux native
> in order have the "I can modify Linux kernel\n" effect.
>
> Using the e1000e driver
>
> 1. vim drivers/net/ethernet/intel/e1000e/netdev.c
>
> 2. Find the probe function
>
> static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> {
>         struct net_device *netdev;
>         struct e1000_adapter *adapter;
>         struct e1000_hw *hw;
>         const struct e1000_info *ei = e1000_info_tbl[ent->driver_data];
>         resource_size_t mmio_start, mmio_len;
>         resource_size_t flash_start, flash_len;
>         static int cards_found;
>         u16 aspm_disable_flag = 0;
>         u16 eeprom_data = 0;
>         u16 eeprom_apme_mask = E1000_EEPROM_APME;
>         int bars, i, err;
>         s32 ret_val = 0;
>
>         printk(KERN_DEBUG "I can modify the Linux kernel\n");
>
> 3. Save the file and recompile the kernel, you should see the text
> printed when you run the "dmesg | less" command after rebooting.
>
> Or you could use the bluetooth driver
>
> 1. vim drivers/bluetooth/btusb.c
>
> 2. Find the probe function
>
> static int btusb_probe(struct usb_interface *intf,
>                        const struct usb_device_id *id)
> {
>         struct usb_endpoint_descriptor *ep_desc;
>         struct gpio_desc *reset_gpio;
>         struct btusb_data *data;
>         struct hci_dev *hdev;
>         unsigned ifnum_base;
>         int i, err, priv_size;
>
>         printk(KERN_DEBUG "I can modify the Linux Kernel\n");
>
>
> 3. Save the file and recompile the kernel, you should see the text
> printed when you run the "dmesg | less" command after rebooting.
>
> I hope this helps.
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-04-02  6:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-01 22:36 Help on Modifying a Driver on Native Linux Richard Akintola
2025-04-02  5:05 ` Julia Lawall
2025-04-02  6:13 ` Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox