From ee8445918e7fdfffef3bfca9864af4356df8395b Mon Sep 17 00:00:00 2001 From: Robert Wolterman Date: Sat, 16 Jul 2016 10:45:13 -0500 Subject: [PATCH] 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 --- overlays/builder.py | 8 +++-- overlays/chip-i2c1.dtbo | Bin 0 -> 577 bytes overlays/chip-i2c1.dts | 62 --------------------------------- overlays/chip-pwm0.dtbo | Bin 0 -> 399 bytes overlays/chip-pwm0.dts | 61 --------------------------------- overlays/chip-spi2.dtbo | Bin 0 -> 973 bytes overlays/chip-spi2.dts | 74 ---------------------------------------- setup.py | 2 +- test/test_pwm_setup.py | 38 ++++++++++----------- 9 files changed, 25 insertions(+), 220 deletions(-) create mode 100644 overlays/chip-i2c1.dtbo delete mode 100644 overlays/chip-i2c1.dts create mode 100644 overlays/chip-pwm0.dtbo delete mode 100644 overlays/chip-pwm0.dts create mode 100644 overlays/chip-spi2.dtbo delete mode 100644 overlays/chip-spi2.dts diff --git a/overlays/builder.py b/overlays/builder.py index fa01443..74cd4af 100644 --- a/overlays/builder.py +++ b/overlays/builder.py @@ -9,9 +9,11 @@ def compile(): call(["dtc", "-O", "dtb", "-o", "overlays/chip-pwm0.dtbo", "-b", "o", "-@", "overlays/chip-pwm0.dts"]) 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"): os.remove(fl) - shutil.move("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.move("overlays/chip-pwm0.dtbo", "/lib/firmware/chip_io/chip-pwm0.dtbo") + shutil.copy("overlays/chip-spi2.dtbo", "/lib/firmware/chip_io/chip-spi2.dtbo") + shutil.copy("overlays/chip-i2c1.dtbo", "/lib/firmware/chip_io/chip-i2c1.dtbo") + shutil.copy("overlays/chip-pwm0.dtbo", "/lib/firmware/chip_io/chip-pwm0.dtbo") diff --git a/overlays/chip-i2c1.dtbo b/overlays/chip-i2c1.dtbo new file mode 100644 index 0000000000000000000000000000000000000000..45c2402735ce1d98043ce83c40bd94c604d8b33d GIT binary patch literal 577 zcmZuuu};G<5WN!Dmyb9vaYGyTDVSRJJ9kq`~bheH!w2s z2Z%pF+&M`p5+}X*-t)V=*nZpp{sd@W1HdIf>z&qf!Xe>+z@bQg4%y#NtEOADo^o#F z()+nGvwk*L1)$cC${1<;t~3`avNV9BHMKZfNaIII;9TD!?8T@RI_ZK+J|Xf4X*I5d zV2ORlgl_EeY?P!~!V#-MAcHXxwn4kb@0>K~T)#~?`FMH#qV>Q2yx-$JLgOD$&cS?_ za5a%rEVXYmuDPjuvS){Io8RM#4HWDD5n`&AW#Ovhgnmb~-;LK7k`6uEne@ZzB-P9_ z^4x8B;*EP57RqGa>L{s7npvGJUli!oSWBo{Mnva8mzCB6^l&n<(zz&;T07`D^(5=O W>1uF6&(W|1oJU`}&_$5y1i}wLGIp>4 literal 0 HcmV?d00001 diff --git a/overlays/chip-i2c1.dts b/overlays/chip-i2c1.dts deleted file mode 100644 index 648c20d..0000000 --- a/overlays/chip-i2c1.dts +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2016 Free Electrons - * Copyright 2016 NextThing Co - * - * Maxime Ripard - * - * 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"; - }; - }; -}; - diff --git a/overlays/chip-pwm0.dtbo b/overlays/chip-pwm0.dtbo new file mode 100644 index 0000000000000000000000000000000000000000..b0e219e0bbb45bac87ce64654a69b79836374d0a GIT binary patch literal 399 zcmY*TT}s115T5u0iWF23`Y7UqNK4~GLGq$U=na-JZqlWjP1v2-_7tAPD|iM^;0?qZ zNN2i<)`4$lXXg99nUBHG7eMj~0Qa0{oNpLsj8lfh1NVpV`|nM@ql_AAV)Z9=r$`d#qsZt{0XM(9gTS-dFjyk^dHhcnr^ sD{G9)$=h)nCH=1BysjD~^JFzdOX!&nD;<8T6apc&+*nqER535W2J>cANdN!< literal 0 HcmV?d00001 diff --git a/overlays/chip-pwm0.dts b/overlays/chip-pwm0.dts deleted file mode 100644 index a25abb0..0000000 --- a/overlays/chip-pwm0.dts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2016 Free Electrons - * Copyright 2016 NextThing Co - * - * Maxime Ripard - * - * 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"; - }; - }; -}; diff --git a/overlays/chip-spi2.dtbo b/overlays/chip-spi2.dtbo new file mode 100644 index 0000000000000000000000000000000000000000..2f6b18ac6f4fe7086f45ff407b56190ea9ed9b60 GIT binary patch literal 973 zcmah{%}N6?5T05EMFl;G;6HO`;EFCB_1@3Z0mD`$F5(TIy5&JYxBM^zudj z84GVjtoV>IA{0y{8y$UbdS-V^Zb+Cr&y}Z0#oz! zsTb5woBL0fX5i|OF8QSEFga@-qZ97gFK2aH=g9T7FVpNSe-Ulj79E}_OJT~P*e$}< zcYWW7*L;X^TH~G=GsFH>s7y9r;%*}zs*{VUdUsHrnSTknkAHE!d8RXFOoahgtRn|W zlov&f+1bqAyMHdEr*FiaA=jN!B>ooS$?L6YdE6DY5^>vWX3s61*9P*QC%k&jbCmI{ zmV&U4x$;U0@T9!A9Z79Gx0C3=%20!nIvJFs9@p)0E|hq?9SdVBfl$go$;dmA+o%)R gSXDId3j@xpfw9~s2IvkL)nYue@y$9vl3^NyAJ@*lSO5S3 literal 0 HcmV?d00001 diff --git a/overlays/chip-spi2.dts b/overlays/chip-spi2.dts deleted file mode 100644 index d0a0ceb..0000000 --- a/overlays/chip-spi2.dts +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2016 Free Electrons - * Copyright 2016 NextThing Co - * - * Maxime Ripard - * - * 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>; - }; - }; - }; -}; diff --git a/setup.py b/setup.py index ec17c6b..d3cfdc5 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ try: from overlays import builder - builder.compile() + #builder.compile() builder.copy() except: pass diff --git a/test/test_pwm_setup.py b/test/test_pwm_setup.py index e5944dd..48e0e88 100644 --- a/test/test_pwm_setup.py +++ b/test/test_pwm_setup.py @@ -13,8 +13,8 @@ class TestPwmSetup: pwm_test = '/sys/class/pwm/pwmchip0/pwm0' assert os.path.exists(pwm_test) - duty = open(pwm_test + '/duty_cycle').read() - period = open(pwm_test + '/period').read() + duty = open(pwm_test + '/duty_cycle').readline().strip() + period = open(pwm_test + '/period').readline().strip() assert int(duty) == 0 assert int(period) == 500000 PWM.cleanup() @@ -25,12 +25,12 @@ class TestPwmSetup: pwm_test = '/sys/class/pwm/pwmchip0/pwm0' assert os.path.exists(pwm_test) - duty = open(pwm_test + '/duty_cycle').read() - period = open(pwm_test + '/period').read() - polarity = open(pwm_test + '/polarity').read() + duty = open(pwm_test + '/duty_cycle').readline().strip() + period = open(pwm_test + '/period').readline().strip() + polarity = open(pwm_test + '/polarity').readline().strip() assert int(duty) == 0 assert int(period) == 500000 - assert string(polarity) == "inverted" + assert str(polarity) == "inverted" PWM.cleanup() def test_start_pwm_with_polarity_default(self): @@ -39,12 +39,12 @@ class TestPwmSetup: pwm_test = '/sys/class/pwm/pwmchip0/pwm0' assert os.path.exists(pwm_test) - duty = open(pwm_test + '/duty_cycle').read() - period = open(pwm_test + '/period').read() - polarity = open(pwm_test + '/polarity').read() + duty = open(pwm_test + '/duty_cycle').readline().strip() + period = open(pwm_test + '/period').readline().strip() + polarity = open(pwm_test + '/polarity').readline().strip() assert int(duty) == 0 assert int(period) == 500000 - assert string(polarity) == "normal" + assert str(polarity) == "normal" PWM.cleanup() def test_start_pwm_with_polarity_zero(self): @@ -53,12 +53,12 @@ class TestPwmSetup: pwm_test = '/sys/class/pwm/pwmchip0/pwm0' assert os.path.exists(pwm_test) - duty = open(pwm_test + '/duty_cycle').read() - period = open(pwm_test + '/period').read() - polarity = open(pwm_test + '/polarity').read() + duty = open(pwm_test + '/duty_cycle').readline().strip() + period = open(pwm_test + '/period').readline().strip() + polarity = open(pwm_test + '/polarity').readline().strip() assert int(duty) == 0 assert int(period) == 500000 - assert string(polarity) == "normal" + assert str(polarity) == "normal" PWM.cleanup() def test_pwm_start_invalid_pwm_key(self): @@ -113,14 +113,14 @@ class TestPwmSetup: pwm_test = '/sys/class/pwm/pwmchip0/pwm0' assert os.path.exists(pwm_test) - duty = open(pwm_test + '/duty_cycle').read() - period = open(pwm_test + '/period').read() + duty = open(pwm_test + '/duty_cycle').readline().strip() + period = open(pwm_test + '/period').readline().strip() assert int(duty) == 0 assert int(period) == 500000 PWM.set_duty_cycle("PWM0", 100) - duty = open(pwm_test + '/duty_cycle').read() - period = open(pwm_test + '/period').read() + duty = open(pwm_test + '/duty_cycle').readline().strip() + period = open(pwm_test + '/period').readline().strip() assert int(duty) == 500000 assert int(period) == 500000 PWM.cleanup() @@ -180,6 +180,6 @@ class TestPwmSetup: #PWM.start("PWM0", 1) #PWM.stop("PWM0") #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' #PWM.cleanup()