Skip to content

ssd1306 device driver example - #37

Open
DevyatovAndrey wants to merge 12 commits into
Kernel-GL-HRK:masterfrom
DevyatovAndrey:Andrii.Deviatov
Open

ssd1306 device driver example#37
DevyatovAndrey wants to merge 12 commits into
Kernel-GL-HRK:masterfrom
DevyatovAndrey:Andrii.Deviatov

Conversation

@DevyatovAndrey

@DevyatovAndrey DevyatovAndrey commented Nov 20, 2017

Copy link
Copy Markdown

This adds step by step example of writing kernel device driver for OLED LCD display based on ssd1306 controller.

@DevyatovAndrey DevyatovAndrey changed the title Andrii.deviatov ssd1306 device driver example Nov 20, 2017

@AleksandrBulyshchenko AleksandrBulyshchenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DevyatovAndrey,
Thank you for sharing the driver.

But could you rebase the branch onto this repo tree?
Because currently it's impossible to diff separate commits via github.

And also if possible -please fix checkpatch issues (at least for the ssd1306, but it make sense for userapp_analog_clock as well):

${BBB_KERNEL}/scripts/checkpatch.pl --file ${TRAINING_REPO}/ssd1306/*.[ch] --terse

Comment thread ssd1306/Makefile Outdated
obj-m := ssd1306.o

KDIR ?= ${HOME}/BBB/bb_kernel/
#KDIR ?= ~/BBB/KERNEL/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid hardcodding any local path.
And unify expected env. vars with existent mpu6050 driver (see its makefile)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread ssd1306/build_on_x86.sh Outdated
@@ -0,0 +1,41 @@
#!/bin/bash -e

export CROSS_COMPILE=${HOME}/BBB/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hardcodded export will override anything set in user's environment.
Please avoid committing your paths.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -0,0 +1,415 @@
/*

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use the same baseline version of am335x-bone-common.dtsi as mpu6050 uses? (see ee49cc6)

Comment thread userapp_analog_clock/Makefile Outdated

clean:
rm fb_user

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makefile has very odd view.
Does it work at all?

I believe you meant something like the following

CROSS_COMPILE ?= arm-linux-gnueabihf-
CC = $(CROSS_COMPILE)gcc
CFLAGS = -Wall

.PHONY: all clean

all: analog_clock

analog_clock: analog_clock.c
	$(CC) $(CFLAGS) $^ -o $@

clean:
	rm analog_clock

Comment thread userapp_analog_clock/build_user_app.sh Outdated
@@ -0,0 +1,11 @@
#!/bin/bash -e

export CROSS_COMPILE=${HOME}/BBB/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid using hardcoded absolute paths - use just filename and add its location to $PATH

@@ -0,0 +1,11 @@
#!/bin/bash -e

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you have shell script and makefile same time.
I believe something one is enough (preferably Makefile if you don't have to use some complex shell scripting)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just to have an unified way to build and deploy this application

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So which one is correct?
Now they use different options.

  • Either make should be called from the shell script and everything have to be defined in the makefile (as it done for ssd1306);
  • or one of them should be removed to avoid confusion.

@DevyatovAndrey

Copy link
Copy Markdown
Author

@AleksandrBulyshchenko,

  • The branch is rebased onto this repo tree.
  • Fixed checkpatch issues
  • Removed unnesessary export of enviroment variabless

@AleksandrBulyshchenko AleksandrBulyshchenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DevyatovAndrey,
Thank you for the fixes.

Here some more comments:

  • It's better to remove mistakenly added build artefacts right in that commit (8e7c145).
  • What about unifying am335x-bone-common.dtsi base with mpu6050? (will require editing of f243df6)
  • If possible, please provide more descriptive commit messages.

Comment thread ssd1306/ssd1306.c
u8 data[LCD_WIDTH * LCD_HEIGHT / 8];

u8 data[LCD_WIDTH * LCD_HEIGHT / 8];
} ssd1306_data_array;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ssd1306.c:90: WARNING: do not add new typedefs

Comment thread ssd1306/ssd1306.c

if (unlikely(ret < 0)) {
printk(KERN_ERR "i2c_master_send() has returned ERROR %d\n", ret);
return ret;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use pr_err()

Comment thread envsetup.sh
@@ -4,15 +4,15 @@ export CROSS_COMPILE=${HOME}/BBB/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnuea

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this envsetup.sh should be published at all.
It will be different for everybody (and don't have to be at all)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to set up enviroment variables needed for these examples if there is no "envsetup.sh"?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of using environment variables - is exactly to allow to use own environment, which is different for every user (otherwise they should be defined in build scripts instead of passing from environment).
So storing environment settings in VCS doesn't make much sense, because they either will be changed by users and will create a noise in git status or won't be used.

@@ -0,0 +1,11 @@
#!/bin/bash -e

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So which one is correct?
Now they use different options.

  • Either make should be called from the shell script and everything have to be defined in the makefile (as it done for ssd1306);
  • or one of them should be removed to avoid confusion.

Comment thread ssd1306/build_on_x86.sh
echo "configure kernel"
make ARCH=arm config
;;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant space line

Comment thread ssd1306/Makefile
PWD := $(shell pwd)

default:
$(MAKE) ARCH=arm -C $(KDIR) M=$(PWD) modules

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please unify indentation - use single tab

@DevyatovAndrey

Copy link
Copy Markdown
Author

I've updated this PR:

  • removed mistakenly added build artefacts
  • unified am335x-bone-common.dtsi base with mpu6050

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants