edison-fw / meta-intel-edison

Here is the meta-intel-edison that builds, tries to stay up to date. Master is based on Yocto Poky Gatesgarth LTS 5.10.yy vanilla kernels. It builds a 32bit kernel (Gatesgarth branch 64bit) with ACPI enabled and corresponding rootfs. Telegram group: https://t.me/IntelEdison Web-site:
https://edison-fw.github.io/meta-intel-edison/
MIT License
60 stars 38 forks source link

sketch_reset.service #91

Closed mwallnoefer closed 4 years ago

mwallnoefer commented 4 years ago

We should disable the _sketchreset service if there is no GPIO access:

root@edison:/# systemctl status sketch-reset.service
Unit sketch-reset.service could not be found.
root@edison:/# systemctl status sketch_reset.service
● sketch_reset.service - Daemon to reset sketches
   Loaded: loaded (/lib/systemd/system/sketch_reset.service; enabled; vendor pr>
   Active: failed (Result: exit-code) since Fri 2020-02-21 06:56:08 UTC; 40min >
 Main PID: 552 (code=exited, status=1/FAILURE)

Feb 21 06:56:08 edison sketch_reset[552]: sh: line 0: echo: write error: Invali>
Feb 21 06:56:08 edison sketch_reset[552]: sh: /sys/class/gpio/gpio215/direction>
Feb 21 06:56:08 edison sketch_reset[552]: sh: /sys/class/gpio/gpio215/value: No>
Feb 21 06:56:08 edison sketch_reset[552]: sh: /sys/class/gpio/gpio215/value: No>
Feb 21 06:56:08 edison sketch_reset[552]: sh: line 0: echo: write error: Invali>
Feb 21 06:56:08 edison sketch_reset[552]: sh: /sys/class/gpio/gpio207/direction>
Feb 21 06:56:08 edison sketch_reset[552]: sh: /sys/class/gpio/gpio207/edge: No >
Feb 21 06:56:08 edison sketch_reset[552]: Failed to open:/sys/class/gpio/gpio20>
Feb 21 06:56:08 edison systemd[1]: sketch_reset.service: Main process exited, c>
Feb 21 06:56:08 edison systemd[1]: sketch_reset.service: Failed with result 'ex>
htot commented 4 years ago

I see, needs to be fixed to use libgpio

mwallnoefer commented 4 years ago

@htot Have you fixed also this one in your new zeus branch? So I will re-test everything in one shot.

htot commented 4 years ago

Not yet. I looking if I fix this to use libgpiod.

BTW I am running btrfs branch on top of zeus. I hope I made the split correct. The btrfs branch creates a more or less standalone initrd that I used to manually convert ext4 partitions into a single btrfs pool with @, @home, @boot subvolumes. That will need a script to automate the process, but it doesn't exist yet. I have documented how to send a 2nd rootfs subvolume. Other than that, it works for me but is not yet complete.

htot commented 4 years ago

@mwallnoefer @xlla would you like to have a look at https://github.com/htot/meta-intel-edison/tree/sketch_reset_v1?

I rewrote most of galileo-reset.c to use libgpiod. This uses pin names instead of numbers, so on the command line it also changed. In the make file I had to discard some options to make errors go away, it's crazy. Now there are still many warnings, but only in the clloader code which was probably already the case. Ugly.

I tested this by running on edison:

root@edison:~# systemctl stop sketch_reset
root@edison:~# /opt/edison/sketch_reset -i SHLD_RESET0 -o SHLD_RESET1 -s /opt/edison/sketch_reset.sh
killall: clloader: no process killed
killall: clloader: no process killed
^C
root@edison:~# /opt/edison/sketch_reset -i SHLD_RESET0 -o SHLD_RESET1 -s /opt/edison/sketch_reset.sh -vv
Toggle reset line
Select event received : from GPIO interrupt pin
Sketch Reset button released: Calling /opt/edison/sketch_reset.sh
killall: clloader: no process killed
killall: clloader: no process killed
Select event received : from GPIO interrupt pin
Sketch Reset button pressed:
Select event received : from GPIO interrupt pin
Sketch Reset button released: Calling /opt/edison/sketch_reset.sh
killall: clloader: no process killed
killall: clloader: no process killed

I find at least I got button released and button push mixed up. Line toggle on start I didn't test, may be it's even to fast and needs a timer. For the reset seems to do what it needs - except I'm not sure what it needs :-)

mwallnoefer commented 4 years ago

Will do. Please don't forget my battery-voltage service suggestions!

mwallnoefer commented 4 years ago

Error message which I get when calling bitbake:

Failed to fetch URL file://btrfs.cfg
htot commented 4 years ago

Oops. When I rebased kernel 5.5 recipe patch it must have sneaked in that line. I'll fix that too. In the meanwhile you can remove that. It is supposed to enable btrfs in the kernel, something you don't need now.

mwallnoefer commented 4 years ago

Ok, other issue:

ERROR: oobe-1.2.1+gitAUTOINC+250de53880-r0 do_package_qa: QA Issue: /usr/bin/configure_edison contained in package oobe requires /usr/bin/python, but no providers found in RDEPENDS_oobe? [file-rdeps]
ERROR: oobe-1.2.1+gitAUTOINC+250de53880-r0 do_package_qa: QA run found fatal errors. Please consider fixing them.
ERROR: oobe-1.2.1+gitAUTOINC+250de53880-r0 do_package_qa: 
ERROR: oobe-1.2.1+gitAUTOINC+250de53880-r0 do_package_qa: Function failed: do_package_qa
htot commented 4 years ago

I see, another moved too far down. I think this will go away if you revert eadb3a8.

(actually this happened because I'm working on new oobe, which is completely based on python3, vs. python + nodejs for current version).

mwallnoefer commented 4 years ago

Okay, but now I still get a build error with perf. log.do_compile.31056.txt

htot commented 4 years ago

This might be caused by an old perf? I think you are compiling using make image? That is good as it cleans up yocto and kernel before bitbaking the reset. But you might want to try to manually clean perf too:

cd out/linux64/build
source poky/oe-init-build-env
bitbake -c cleansstate perf

In addition I created v2 taking into account your comments here and in the battery-voltage.c. This time I actually built the branch myself.

I hope it will be smoother for you now.

mwallnoefer commented 4 years ago

Did not work.

htot commented 4 years ago

I will try checking out completely new and rebuilding all.

htot commented 4 years ago

I found make setup does not complete (zeus updated causing patch to fail). Then meta-acpi compatibility not yet set for zeus. So, pushed 1 patch on meta-acpi (automatically pulled with make setup) and one patch on meta-intel-edison.

So best is if you make clean && make setup && make image after pulling meta-intel-edison.

~I am now at 50% (perf not yet built), need another hour.~ Everything built just fine now.

mwallnoefer commented 4 years ago

Okay will re-try the build!

andy-shev commented 4 years ago

perf tool should come from the kernel sources.

xlla commented 4 years ago

it works well.

root@edison:~# systemctl status sketch_reset.service
● sketch_reset.service - Daemon to reset sketches
   Loaded: loaded (/lib/systemd/system/sketch_reset.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-02-15 17:20:07 UTC; 2h 22min ago
 Main PID: 567 (sketch_reset)
   CGroup: /system.slice/sketch_reset.service
           └─567 /opt/edison/sketch_reset -i SHLD_RESET0 -o SHLD_RESET1 -s /opt/edison/sketch_reset.sh

Feb 15 17:20:07 edison systemd[1]: Started Daemon to reset sketches.
root@edison:~# 

htot commented 4 years ago

@andy-shev yes, there is a recipe for kernel and a recipe for perf. After you built both and then switch kernel and rebuild it seems some artifacts from kernel remain interfere with building perf. Cleaning everything, then building seems to help. It's a Yocto problem i think.

mwallnoefer commented 4 years ago

Tried another full rebuild, but always ending up in the perf issue:

make: Leaving directory '/datadisk/edison-fw/out/linux64/build/tmp/work/edison-poky-linux/perf/1.0-r9/perf-1.0/tools/perf'
WARNING: exit code 1 from a shell command.

Referring to your last comment, how may I circumvent this?

htot commented 4 years ago

That is weird. I meant bitbake -c cleansstate perf cleans perf, while make image cleans linux and u-boot and then starts build (all in the right directory).

But if you did make clean && make setup && make image it doesn't get cleaner. I have done this (64 bit) and then again (32 bit) on another machine with no errors. In all cases the host is Ubuntu 19.10.

mwallnoefer commented 4 years ago

That's the bug: https://www.mail-archive.com/openembedded-core@lists.openembedded.org/msg133569.html The mentioned patch did it for me.

htot commented 4 years ago

Yes, but strange that I can build without problem. As I understand the patch makes the native (yocto built) python to be used and not the host python?

mwallnoefer commented 4 years ago

My host is still on Ubuntu 18.04 LTS, this might make the difference (you're on Ubuntu 19.10).

mwallnoefer commented 4 years ago

Btw. is this a new service? Does it make sense to have it enabled per default?

[FAILED] Failed to start Set timezone by geolocation service.
See 'systemctl status run-timezone.service' for details.
htot commented 4 years ago

Run once should be enough, if it succeeds. I haven't figured out what to do here exactly. I just wanted to have time zone set automatically. Did it fail for you?

root@edison:~# systemctl start run-timezone.service
root@edison:~# systemctl status run-timezone.service
● run-timezone.service - Set timezone by geolocation service
   Loaded: loaded (/lib/systemd/system/run-timezone.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

Mar 06 18:18:54 edison systemd[1]: Starting Set timezone by geolocation service...
Mar 06 18:18:54 edison run-timezone[1136641]: PING ipapi.co (104.26.8.44): 56 data bytes
Mar 06 18:18:54 edison run-timezone[1136641]: --- ipapi.co ping statistics ---
Mar 06 18:18:54 edison run-timezone[1136641]: 1 packets transmitted, 1 packets received, 0% packet loss
Mar 06 18:18:54 edison run-timezone[1136641]: round-trip min/avg/max = 16.242/16.242/16.242 ms
Mar 06 18:18:55 edison systemd[1]: run-timezone.service: Succeeded.
Mar 06 18:18:55 edison systemd[1]: Started Set timezone by geolocation service.
root@edison:~# timedatectl 
               Local time: Fri 2020-03-06 18:23:45 CET
           Universal time: Fri 2020-03-06 17:23:45 UTC
                 RTC time: Thu 2000-01-13 18:16:02
                Time zone: Europe/Amsterdam (CET, +0100)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

I'll add a patch to fix perf.

mwallnoefer commented 4 years ago

It fails until you enable connectivity (wifi) with a subsequent reboot respectively service restart operation.

Also here I would not make the service fail (terminate with <>0 exit code), since it is not an exceptional behaviour when the connectivity hasn't been set up yet.

htot commented 4 years ago

Got it. But actually I want it run once on boot without failing. Once it succeeds it can be disabled. But I haven't thought it through completely.

For now I pushed this stuff to zeus including the perf you suggest.

mwallnoefer commented 4 years ago

Okay, so back to sketch_reset.service, this is what I get on branch zeus:

root@edison:~# /opt/edison/sketch_reset -i SHLD_RESET0 -o SHLD_RESET1 -s /opt/edison/sketch_reset.sh
Shield reset input GPIO invalid or not specified

How do I set up the pin mapping with libgpiod?

htot commented 4 years ago

I force pushed. Are you on 443513e4?

There is nothing to map, as it is mapped already through acpi tables. You can see that using gpioinfo.

mwallnoefer commented 4 years ago

Yes, I am on that commit. But in gpioinfo I do not see these ports mapped:

root@edison:~# gpioinfo | grep "SHLD"
root@edison:~# 
htot commented 4 years ago
root@edison:~# gpioinfo | grep "SHLD"
        line   7: "SHLD_RESET0" unused input active-high 
        line  15: "SHLD_RESET1" unused output active-high 

Afaik these are defined in a aml in U-Boot. What do you have when you just gpioinfo?

mwallnoefer commented 4 years ago

gpioinfo.log

htot commented 4 years ago

Wow, you are missing gpiochip1 (see mine below). It might be fixed by doing a cold boot (unplug power).

gpioinfo.log ``` root@edison:~# gpioinfo gpiochip0 - 192 lines: line 0: unnamed unused input active-high line 1: unnamed unused input active-high line 2: unnamed unused output active-high line 3: unnamed unused input active-high line 4: unnamed unused output active-high line 5: unnamed unused output active-high line 6: unnamed unused output active-high line 7: unnamed unused input active-high line 8: unnamed unused input active-high line 9: unnamed unused output active-high line 10: unnamed unused output active-high line 11: unnamed unused output active-high line 12: unnamed unused output active-high line 13: unnamed unused output active-high line 14: unnamed unused input active-high line 15: unnamed "interrupt" input active-high [used] line 16: unnamed unused input active-high line 17: unnamed unused input active-high line 18: unnamed unused input active-high line 19: unnamed unused input active-high line 20: unnamed unused input active-high line 21: unnamed unused input active-high line 22: unnamed unused input active-high line 23: unnamed unused input active-high line 24: unnamed unused input active-high line 25: unnamed unused input active-high line 26: unnamed unused input active-high line 27: unnamed unused input active-high line 28: unnamed unused input active-high line 29: unnamed unused input active-high line 30: unnamed unused input active-high line 31: unnamed unused input active-high line 32: unnamed unused input active-high line 33: unnamed unused input active-high line 34: unnamed unused input active-high line 35: unnamed unused input active-high line 36: unnamed unused input active-high line 37: unnamed unused input active-high line 38: unnamed unused input active-high line 39: unnamed unused input active-high line 40: unnamed "heartbeat" output active-high [used] line 41: unnamed unused input active-high line 42: unnamed unused input active-high line 43: unnamed unused input active-high line 44: unnamed unused input active-high line 45: unnamed unused input active-high line 46: unnamed unused input active-high line 47: unnamed unused input active-high line 48: unnamed unused input active-high line 49: unnamed unused input active-high line 50: unnamed unused output active-high line 51: unnamed unused input active-high line 52: unnamed unused input active-high line 53: unnamed unused input active-high line 54: unnamed unused output active-high line 55: unnamed unused input active-high line 56: unnamed unused input active-high line 57: unnamed unused input active-high line 58: unnamed unused input active-high line 59: unnamed unused input active-high line 60: unnamed unused input active-high line 61: unnamed unused input active-high line 62: unnamed unused input active-high line 63: unnamed unused input active-high line 64: unnamed unused input active-high line 65: unnamed unused input active-high line 66: unnamed unused input active-high line 67: unnamed unused input active-high line 68: unnamed unused input active-high line 69: unnamed unused input active-high line 70: unnamed unused input active-high line 71: unnamed "shutdown" output active-high [used] line 72: unnamed unused input active-high line 73: unnamed unused input active-high line 74: unnamed unused input active-high line 75: unnamed unused input active-high line 76: unnamed unused input active-high line 77: unnamed "sd_cd" input active-high [used] line 78: unnamed unused input active-high line 79: unnamed unused input active-high line 80: unnamed unused input active-high line 81: unnamed unused input active-high line 82: unnamed unused input active-high line 83: unnamed unused input active-high line 84: unnamed unused input active-high line 85: unnamed unused input active-high line 86: unnamed unused input active-high line 87: unnamed unused input active-high line 88: unnamed unused input active-high line 89: unnamed unused input active-high line 90: unnamed unused input active-high line 91: unnamed unused input active-high line 92: unnamed unused input active-high line 93: unnamed unused input active-high line 94: unnamed unused input active-high line 95: unnamed unused input active-high line 96: unnamed "ACPI:OpRegion" output active-high [used] line 97: unnamed unused input active-high line 98: unnamed unused input active-high line 99: unnamed unused input active-high line 100: unnamed unused input active-high line 101: unnamed unused input active-high line 102: unnamed unused input active-high line 103: unnamed unused input active-high line 104: unnamed unused input active-high line 105: unnamed unused input active-high line 106: unnamed unused input active-high line 107: unnamed unused input active-high line 108: unnamed unused input active-high line 109: unnamed unused input active-high line 110: unnamed "cs" output active-high [used] line 111: unnamed "cs" output active-high [used] line 112: unnamed "cs" output active-high [used] line 113: unnamed "cs" output active-high [used] line 114: unnamed unused input active-high line 115: unnamed unused input active-high line 116: unnamed unused input active-high line 117: unnamed unused input active-high line 118: unnamed unused input active-high line 119: unnamed unused input active-high line 120: unnamed unused input active-high line 121: unnamed unused input active-high line 122: unnamed unused input active-high line 123: unnamed unused input active-high line 124: unnamed unused input active-high line 125: unnamed unused input active-high line 126: unnamed unused input active-high line 127: unnamed unused input active-high line 128: unnamed unused input active-high line 129: unnamed unused input active-high line 130: unnamed unused input active-high line 131: unnamed unused input active-high line 132: unnamed unused input active-high line 133: unnamed unused input active-high line 134: unnamed unused input active-high line 135: unnamed unused input active-high line 136: unnamed unused input active-high line 137: unnamed unused input active-high line 138: unnamed unused input active-high line 139: unnamed unused input active-high line 140: unnamed unused input active-high line 141: unnamed unused input active-high line 142: unnamed unused input active-high line 143: unnamed unused input active-high line 144: unnamed unused input active-high line 145: unnamed unused input active-high line 146: unnamed unused input active-high line 147: unnamed unused input active-high line 148: unnamed unused input active-high line 149: unnamed unused input active-high line 150: unnamed unused input active-high line 151: unnamed unused input active-high line 152: unnamed unused input active-high line 153: unnamed unused input active-high line 154: unnamed unused input active-high line 155: unnamed unused input active-high line 156: unnamed unused input active-high line 157: unnamed unused input active-high line 158: unnamed unused input active-high line 159: unnamed unused input active-high line 160: unnamed unused input active-high line 161: unnamed unused input active-high line 162: unnamed unused input active-high line 163: unnamed unused input active-high line 164: unnamed unused input active-high line 165: unnamed unused output active-high line 166: unnamed unused input active-high line 167: unnamed unused input active-high line 168: unnamed unused input active-high line 169: unnamed unused input active-high line 170: unnamed unused input active-high line 171: unnamed unused input active-high line 172: unnamed unused input active-high line 173: unnamed unused output active-high line 174: unnamed unused input active-high line 175: unnamed unused output active-high line 176: unnamed unused output active-high line 177: unnamed unused output active-high line 178: unnamed unused input active-high line 179: unnamed unused output active-high line 180: unnamed unused input active-high line 181: unnamed unused output active-high line 182: unnamed unused output active-high line 183: unnamed unused input active-high line 184: unnamed "device-wakeup" output active-high [used] line 185: unnamed "host-wakeup" input active-high [used] line 186: unnamed unused input active-high line 187: unnamed unused input active-high line 188: unnamed unused input active-high line 189: unnamed unused output active-high line 190: unnamed unused output active-high line 191: unnamed unused input active-high gpiochip1 - 16 lines: line 0: "MUX15_SEL" unused input active-high line 1: "MUX13_SEL" unused input active-high line 2: "MUX11_SEL" unused input active-high line 3: "MUX9_SEL" unused input active-high line 4: "MUX7_SEL" "i2c6-sda-mux" output active-high [used] line 5: "MUX5_SEL" "i2c6-scl-mux" output active-high [used] line 6: "U17_IO0.6" unused input active-high line 7: "SHLD_RESET0" unused input active-high line 8: "A0_PU_PD" unused input active-high line 9: "A1_PU_PD" unused input active-high line 10: "A2_PU_PD" unused input active-high line 11: "A3_PU_PD" unused input active-high line 12: "A4_PU_PD" "i2c6-sda-pu" output active-high [used] line 13: "A5_PU_PD" "i2c6-scl-pu" output active-high [used] line 14: "TRI_STATE_ALL" unused output active-high line 15: "SHLD_RESET1" unused output active-high gpiochip2 - 16 lines: line 0: "DIG0_PU_PD" "uart1-rx-pu" input active-high [used] line 1: "DIG1_PU_PD" "uart1-tx-pu" input active-high [used] line 2: "DIG2_PU_PD" unused input active-high line 3: "DIG3_PU_PD" unused input active-high line 4: "DIG4_PU_PD" unused input active-high line 5: "DIG5_PU_PD" unused input active-high line 6: "DIG6_PU_PD" unused input active-high line 7: "DIG7_PU_PD" unused input active-high line 8: "DIG8_PU_PD" unused input active-high line 9: "DIG9_PU_PD" unused input active-high line 10: "DIG10_PU_PD" unused input active-high line 11: "DIG11_PU_PD" unused input active-high line 12: "DIG12_PU_PD" unused input active-high line 13: "DIG13_PU_PD" unused input active-high line 14: "U39_IO1.6" unused input active-high line 15: "U39_IO1.7" unused input active-high gpiochip3 - 16 lines: line 0: "MUX14_DIR" unused input active-high line 1: "MUX12_DIR" unused input active-high line 2: "MUX10_DIR" unused input active-high line 3: "MUX8_DIR" unused input active-high line 4: "MUX6_DIR" "i2c6-sda-mux" output active-high [used] line 5: "MUX4_DIR" "i2c6-scl-mux" output active-high [used] line 6: "U16_IO0.6" unused input active-high line 7: "U16_IO0.7" unused input active-high line 8: "SPI_FS_SEL" unused input active-high line 9: "SPI_TXD_SEL" unused input active-high line 10: "SPI_RXD_SEL" unused input active-high line 11: "SPI_CLK_SEL" unused output active-high line 12: "U16_IO1.4" unused input active-high line 13: "U16_IO1.5" unused input active-high line 14: "U16_IO1.6" unused input active-high line 15: "U16_IO1.7" unused input active-high gpiochip4 - 16 lines: line 0: "MUX33_DIR" "uart1-rx-oe" output active-high [used] line 1: "MUX31_DIR" "uart1-tx-oe" output active-high [used] line 2: "MUX29_DIR" unused input active-high line 3: "MUX27_DIR" unused input active-high line 4: "MUX24_DIR" unused input active-high line 5: "MUX21_DIR" unused input active-high line 6: "MUX19_DIR" unused input active-high line 7: "MUX32_DIR" unused input active-high line 8: "MUX30_DIR" unused input active-high line 9: "MUX28_DIR" unused input active-high line 10: "MUX26_DIR" unused input active-high line 11: "MUX23_DIR" unused input active-high line 12: "MUX20_DIR" unused input active-high line 13: "MUX18_DIR" unused output active-high line 14: "MUX22_SEL" unused input active-high line 15: "MUX25_SEL" unused input active-high gpiochip5 - 4 lines: line 0: unnamed unused input active-high line 1: unnamed unused input active-high line 2: unnamed unused input active-high line 3: unnamed unused input active-high ```
mwallnoefer commented 4 years ago

That did it, thanks!