FrameOS / frameos

Operating system for single function smart frames
https://frameos.net/
Apache License 2.0
322 stars 8 forks source link

Parse error in frameos/src/drivers/waveshare/driver.nim using waveshare.EPD_4in2_V2 device #42

Closed tallzilla closed 5 months ago

tallzilla commented 5 months ago

Hi there, this project looks powerful!

I'm trying to get the default FrameOS app up and running through my Pi Zero 2 W and a Waveshare 4in2 V2. Happy to help implement and test, but I have a basic question first...

On deploy, I get the below parse error in one of the base auto-generated Waveshare driver files. I understand that 4in2V2 isn't tested yet, but should I be getting the below error in the base files?

Another thing I noticed in driver.nim is that the base driver explicitly pulls width and height from the 2in13 V3.

Thanks! Logs below contains reference to the parse error

2024-01-12 18:40:25 Connecting via SSH to XXX (password)
2024-01-12 18:40:29 Connected via SSH to XXX
2024-01-12 18:40:29 - Getting target architecture
2024-01-12 18:40:29 > uname -m
2024-01-12 18:40:29 armv6l
2024-01-12 18:40:30 - Copying build folders
2024-01-12 18:40:30 - Applying local modifications
2024-01-12 18:40:30 - Generating scene: default
2024-01-12 18:40:30 - Generating app: 4ed62ec9-3b11-4a3a-9d3e-844b137240b1 (frameOSGallery)
2024-01-12 18:40:30 - Creating build archive
2024-01-12 18:40:30 - No cross compilation. Generating source code for compilation on frame.
2024-01-12 18:40:30 $ cd /tmp/tmpmw2dv5jz/frameos && nimble assets -y && nim compile --os:linux --cpu:arm --compileOnly --genScript --nimcache:/tmp/tmpmw2dv5jz/build_wbgvmccqmczf src/frameos.nim 2>&1
2024-01-12 18:40:30 Executing task assets in /tmp/tmpmw2dv5jz/frameos/frameos.nimble
2024-01-12 18:40:30 assets/web/index.html ... ok
2024-01-12 18:40:30 assets/fonts/Ubuntu-Regular_1.ttf ... ok
2024-01-12 18:40:30 Hint: used config file '/opt/nim/config/nim.cfg' [Conf]
2024-01-12 18:40:30 Hint: used config file '/opt/nim/config/config.nims' [Conf]
2024-01-12 18:40:30 Hint: used config file '/tmp/tmpmw2dv5jz/frameos/nim.cfg' [Conf]
2024-01-12 18:40:30 Hint: used config file '/tmp/tmpmw2dv5jz/frameos/config.nims' [Conf]
2024-01-12 18:40:31 .......................................................................................................................................................................................................................................................................
2024-01-12 18:40:31 /tmp/tmpmw2dv5jz/frameos/src/drivers/waveshare/driver.nim(10, 34) Error: invalid token: no whitespace between number and identifier
2024-01-12 18:40:32 The command exited with status 1
2024-01-12 18:40:32 'NoneType' object has no attribute 'split'
2024-01-12 18:40:32 SSH connection closed
mariusandra commented 5 months ago

Hey @tallzilla , I think I just got it working with this: https://github.com/FrameOS/frameos/pull/43

I fixed the error, and the generated output did look like a four-color grayscale image. However without a frame myself I can't test if I got the math right when sending the image to the driver. Once CI completes, there should be a new latest docker tag with these changes.

Very curious to hear if it works.

tallzilla commented 5 months ago

Thanks for the quick response. I updated to the latest docker image... on attempting to re-deploy I get this error on my pi. I tried to ssh in to sudo apt-get install -y liblgpio-dev myself but that library doesn't exist (is this just a typo for libgpiod-dev?)

2024-01-12 22:37:10 Cleaning build script at /tmp/tmpr7l7cpco/build_gtolglvavqwy/compile_frameos.sh
2024-01-12 22:37:11 > dpkg -l | grep -q "^ii ntp" || sudo apt-get install -y ntp
2024-01-12 22:37:11 > dpkg -l | grep -q "^ii build-essential" || sudo apt-get install -y build-essential
2024-01-12 22:37:12 > dpkg -l | grep -q "^ii liblgpio-dev" || sudo apt-get install -y liblgpio-dev
2024-01-12 22:37:13 Reading package lists...
2024-01-12 22:37:15 Building dependency tree...
2024-01-12 22:37:15 Reading state information...
2024-01-12 22:37:16 E: Unable to locate package liblgpio-dev
mariusandra commented 5 months ago

Which OS are you running?

Checking myself, on the latest 64 bit Raspberry Pi OS (Bookworm), I find these packages:

liblgpio-dev/stable,now 0.2.2-1~rpt1 arm64 [installed]
  Control GPIO pins via gpiochip devices - static libraries and headers

liblgpio1/stable,now 0.2.2-1~rpt1 arm64 [installed,automatic]
  Control GPIO pins via gpiochip devices - shared libraries

However on the 32 bit version of Bookworm, I the -dev package is missing :(

liblgpio1/now 0.2.2-1~rpt1 armhf [installed,local]
  Control GPIO pins via gpiochip devices - shared libraries

The non-dev package doesn't include the necessary files like lgpio.h that are needed for compilation. I can't ship them with FrameOS, as they need to match the installed system library exactly.

I'll see what can be done. However the quick solution for you now is to reflash your SD card with the 64bit version of Raspberry Pi OS Bookworm Lite. That's what I've been using. The one Pi Zero W v1 that I have, which runs the 32bit OS out of necessity, is not connected to a Waveshare display, thus I didn't catch this bug.

tallzilla commented 5 months ago

32 bit, lemme reflash and I'll try again...

tallzilla commented 5 months ago

Alright! Deploys are working to my 4.2" V2. Embarrassingly, I used a Pi Zero W for the initial test and bug report (also hence the 32 bit operating system). Tested it on my Pi Zero 2 W / 64-bit Bookworm latest and everything deploys smoothly now.

mariusandra commented 5 months ago

Ah, great to hear. I now added a fix that'll compile lgpio from source on a 32bit OS if no headers are found. This should hopefully fix the problem for now. Longer term, the plan is to get rid of such external dependencies altogether.

Going to close the issue then, since everything seems to be working.

Thanks again for trying and debugging here! I'm also always curious to hear if you have any feedback, and/or photos of frames to share :).