1
0
mirror of https://github.com/xtacocorex/CHIP_IO synced 2025-07-20 04:43:21 +00:00

More work on #10. PWM0 Loading is complete and verified, i2c-1 loading loads to i2c-3, verification fails, spi2 is loaded, but no verification. No work on custom overlay loading. Fixed issues with test_pwm_setup.py; only 2 tests fail now (when PWM0 is loaded

This commit is contained in:
Robert Wolterman
2016-07-16 10:45:13 -05:00
parent 1c4168cf0d
commit ee8445918e
9 changed files with 25 additions and 220 deletions

View File

@ -9,9 +9,11 @@ def compile():
call(["dtc", "-O", "dtb", "-o", "overlays/chip-pwm0.dtbo", "-b", "o", "-@", "overlays/chip-pwm0.dts"]) call(["dtc", "-O", "dtb", "-o", "overlays/chip-pwm0.dtbo", "-b", "o", "-@", "overlays/chip-pwm0.dts"])
def copy(): def copy():
if not os.path.exists("/lib/firmware/chip_io/"):
os.makedirs("/lib/firmware/chip_io/")
for fl in glob.glob("/lib/firmware/chip_io/chip-*-.dtbo"): for fl in glob.glob("/lib/firmware/chip_io/chip-*-.dtbo"):
os.remove(fl) os.remove(fl)
shutil.move("overlays/chip-spi2.dtbo", "/lib/firmware/chip_io/chip-spi2.dtbo") shutil.copy("overlays/chip-spi2.dtbo", "/lib/firmware/chip_io/chip-spi2.dtbo")
shutil.move("overlays/chip-i2c1.dtbo", "/lib/firmware/chip_io/chip-i2c1.dtbo") shutil.copy("overlays/chip-i2c1.dtbo", "/lib/firmware/chip_io/chip-i2c1.dtbo")
shutil.move("overlays/chip-pwm0.dtbo", "/lib/firmware/chip_io/chip-pwm0.dtbo") shutil.copy("overlays/chip-pwm0.dtbo", "/lib/firmware/chip_io/chip-pwm0.dtbo")

BIN
overlays/chip-i2c1.dtbo Normal file

Binary file not shown.

View File

@ -1,62 +0,0 @@
/*
* Copyright 2016 Free Electrons
* Copyright 2016 NextThing Co
*
* Maxime Ripard <maxime.ripard@free-electrons.com>
*
* This file is dual-licensed: you can use it either under the terms
* of the GPL or the X11 license, at your option. Note that this dual
* licensing only applies to this file, and not this project as a
* whole.
*
* a) This file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* Or, alternatively,
*
* b) Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
/ {
compatible = "nextthing,chip", "allwinner,sun5i-r8";
/* Enable the I2C1 bus and the keyboard */
fragment@1 {
target = <&i2c1>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins_a>;
status = "okay";
};
};
};

BIN
overlays/chip-pwm0.dtbo Normal file

Binary file not shown.

View File

@ -1,61 +0,0 @@
/*
* Copyright 2016 Free Electrons
* Copyright 2016 NextThing Co
*
* Maxime Ripard <maxime.ripard@free-electrons.com>
*
* This file is dual-licensed: you can use it either under the terms
* of the GPL or the X11 license, at your option. Note that this dual
* licensing only applies to this file, and not this project as a
* whole.
*
* a) This file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* Or, alternatively,
*
* b) Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
/dts-v1/;
/plugin/;
/ {
compatible = "nextthing,chip", "allwinner,sun5i-r8";
/* Enable the PWM */
fragment@0 {
target = <&pwm>;
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <&pwm0_pins>;
status = "okay";
};
};
};

BIN
overlays/chip-spi2.dtbo Normal file

Binary file not shown.

View File

@ -1,74 +0,0 @@
/*
* Copyright 2016 Free Electrons
* Copyright 2016 NextThing Co
*
* Maxime Ripard <maxime.ripard@free-electrons.com>
*
* This file is dual-licensed: you can use it either under the terms
* of the GPL or the X11 license, at your option. Note that this dual
* licensing only applies to this file, and not this project as a
* whole.
*
* a) This file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* Or, alternatively,
*
* b) Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
/dts-v1/;
/plugin/;
/ {
compatible = "nextthing,chip", "allwinner,sun5i-r8";
/*
* Enable our SPI device, with an spidev device connected
* to it
*/
fragment@1 {
target = <&spi2>;
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <&spi2_pins_a>,
<&spi2_cs0_pins_a>;
status = "okay";
#address-cells = <1>;
#size-cells = <0>;
spidev@0{
compatible = "spidev";
reg = <0>;
spi-max-frequency = <1000000>;
};
};
};
};

View File

@ -1,6 +1,6 @@
try: try:
from overlays import builder from overlays import builder
builder.compile() #builder.compile()
builder.copy() builder.copy()
except: except:
pass pass

View File

@ -13,8 +13,8 @@ class TestPwmSetup:
pwm_test = '/sys/class/pwm/pwmchip0/pwm0' pwm_test = '/sys/class/pwm/pwmchip0/pwm0'
assert os.path.exists(pwm_test) assert os.path.exists(pwm_test)
duty = open(pwm_test + '/duty_cycle').read() duty = open(pwm_test + '/duty_cycle').readline().strip()
period = open(pwm_test + '/period').read() period = open(pwm_test + '/period').readline().strip()
assert int(duty) == 0 assert int(duty) == 0
assert int(period) == 500000 assert int(period) == 500000
PWM.cleanup() PWM.cleanup()
@ -25,12 +25,12 @@ class TestPwmSetup:
pwm_test = '/sys/class/pwm/pwmchip0/pwm0' pwm_test = '/sys/class/pwm/pwmchip0/pwm0'
assert os.path.exists(pwm_test) assert os.path.exists(pwm_test)
duty = open(pwm_test + '/duty_cycle').read() duty = open(pwm_test + '/duty_cycle').readline().strip()
period = open(pwm_test + '/period').read() period = open(pwm_test + '/period').readline().strip()
polarity = open(pwm_test + '/polarity').read() polarity = open(pwm_test + '/polarity').readline().strip()
assert int(duty) == 0 assert int(duty) == 0
assert int(period) == 500000 assert int(period) == 500000
assert string(polarity) == "inverted" assert str(polarity) == "inverted"
PWM.cleanup() PWM.cleanup()
def test_start_pwm_with_polarity_default(self): def test_start_pwm_with_polarity_default(self):
@ -39,12 +39,12 @@ class TestPwmSetup:
pwm_test = '/sys/class/pwm/pwmchip0/pwm0' pwm_test = '/sys/class/pwm/pwmchip0/pwm0'
assert os.path.exists(pwm_test) assert os.path.exists(pwm_test)
duty = open(pwm_test + '/duty_cycle').read() duty = open(pwm_test + '/duty_cycle').readline().strip()
period = open(pwm_test + '/period').read() period = open(pwm_test + '/period').readline().strip()
polarity = open(pwm_test + '/polarity').read() polarity = open(pwm_test + '/polarity').readline().strip()
assert int(duty) == 0 assert int(duty) == 0
assert int(period) == 500000 assert int(period) == 500000
assert string(polarity) == "normal" assert str(polarity) == "normal"
PWM.cleanup() PWM.cleanup()
def test_start_pwm_with_polarity_zero(self): def test_start_pwm_with_polarity_zero(self):
@ -53,12 +53,12 @@ class TestPwmSetup:
pwm_test = '/sys/class/pwm/pwmchip0/pwm0' pwm_test = '/sys/class/pwm/pwmchip0/pwm0'
assert os.path.exists(pwm_test) assert os.path.exists(pwm_test)
duty = open(pwm_test + '/duty_cycle').read() duty = open(pwm_test + '/duty_cycle').readline().strip()
period = open(pwm_test + '/period').read() period = open(pwm_test + '/period').readline().strip()
polarity = open(pwm_test + '/polarity').read() polarity = open(pwm_test + '/polarity').readline().strip()
assert int(duty) == 0 assert int(duty) == 0
assert int(period) == 500000 assert int(period) == 500000
assert string(polarity) == "normal" assert str(polarity) == "normal"
PWM.cleanup() PWM.cleanup()
def test_pwm_start_invalid_pwm_key(self): def test_pwm_start_invalid_pwm_key(self):
@ -113,14 +113,14 @@ class TestPwmSetup:
pwm_test = '/sys/class/pwm/pwmchip0/pwm0' pwm_test = '/sys/class/pwm/pwmchip0/pwm0'
assert os.path.exists(pwm_test) assert os.path.exists(pwm_test)
duty = open(pwm_test + '/duty_cycle').read() duty = open(pwm_test + '/duty_cycle').readline().strip()
period = open(pwm_test + '/period').read() period = open(pwm_test + '/period').readline().strip()
assert int(duty) == 0 assert int(duty) == 0
assert int(period) == 500000 assert int(period) == 500000
PWM.set_duty_cycle("PWM0", 100) PWM.set_duty_cycle("PWM0", 100)
duty = open(pwm_test + '/duty_cycle').read() duty = open(pwm_test + '/duty_cycle').readline().strip()
period = open(pwm_test + '/period').read() period = open(pwm_test + '/period').readline().strip()
assert int(duty) == 500000 assert int(duty) == 500000
assert int(period) == 500000 assert int(period) == 500000
PWM.cleanup() PWM.cleanup()
@ -180,6 +180,6 @@ class TestPwmSetup:
#PWM.start("PWM0", 1) #PWM.start("PWM0", 1)
#PWM.stop("PWM0") #PWM.stop("PWM0")
#assert os.path.exists('/sys/class/gpio/gpio68') #assert os.path.exists('/sys/class/gpio/gpio68')
#direction = open('/sys/class/gpio/gpio68/direction').read() #direction = open('/sys/class/gpio/gpio68/direction').readline().strip()
#assert direction == 'out\n' #assert direction == 'out\n'
#PWM.cleanup() #PWM.cleanup()