Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few suggestions for improvements #2

Open
geerlingguy opened this issue Sep 22, 2022 · 15 comments
Open

A few suggestions for improvements #2

geerlingguy opened this issue Sep 22, 2022 · 15 comments

Comments

@geerlingguy
Copy link
Contributor

geerlingguy commented Sep 22, 2022

I had a few issues with my initial setup of the LCD for my rack unit, and not all of these are problems, but a few suggestions too:

1. Enabling I2C didn't work

Using the provided instructions, when I tried running the display, I got the following error:

Device I2C-1 failed to initialize

Indeed, even with dtparam=i2c_arm=on,i2c_arm_baudrate=400000 appended to my boot config and after a restart, I would keep getting that error.

I found out after a bit of debugging I had to put the dtparam=i2c_arm=on line earlier in my /boot/config.txt file. I was putting it near the end but for some reason that wasn't working. There was a commented line earlier in the file, and I uncommented that line, and everything works.

When I ran sudo raspi-config and enabled the I2C interface via that CLI interface, it also seemed to work, whereas manually enabling it by uncommenting the line didn't always. Not sure why, and I tried on both Buster and Bullseye.

So maybe updating the statement in the README to uncomment the existing line, and add on the i2c_arm_baudrate at the end, would be less prone to failure.

2. IP address always displayed as xxx.xxx.xxx.xxx (see #4)

My Pis are all plugged in via Ethernet, and if I run ip a I see something like:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether dc:a6:32:1a:68:4f brd ff:ff:ff:ff:ff:ff
    inet 10.0.100.10/24 brd 10.0.100.255 scope global dynamic noprefixroute eth0

But the IP address is never shown on the LCD. It looks like lcd_display_cpuLoad calls get_ip_address (though the comment there mentions wireless... it looks like the code looks for eth0...), but for some reason it never gets the IP for my Pis.

3. Simpler display preferred

The default settings make a display that refreshes parts and has four different displays cycling at all times. For my purposes, I would just like the IP address, and maybe the CPU temperature displayed (or something similarly simple, like hostname and IP). It would be great if this script could be customized to just display one thing and refresh every 5 seconds or something... or just display a text string on the screen.

I can see how to do that in the C, but having a little more flexibility could be nice. Otherwise, maybe someone in the community has a nice library that can do it separately... I noticed that the default setup would cause 3-5% CPU load every five seconds or so. Nothing crazy, but it is a lot of load just to update an informational display (which will not be looked at 99% of the time).

@arducamStephen
Copy link

@geerlingguy
Thanks for your constructive suggestion.
About Enabling I2C didn't work, Maybe it is due to the i2c controller has not prepare ok but the display demo has started work,
so it is accessible to enable i2c controller as early as possible. We will update our instructions documentation as soon as possible.
About IP address always displayed as xxx.xxx.xxx.xxx. In the display, you will see if the network adapter is not assigned IP address. it will display xxx.xxx.xxx.xxx which is designed in the code. To see if the network adapter has been assigned IP, you
can use ifconfig command.
About Simpler display preferred. my idea is the same as yours. Our develop team will evaluate your suggestions and update it.
What's more, we would be glad if you could submit a pull request for the code.

@geerlingguy
Copy link
Contributor Author

@arducamStephen - Thanks for the responses!

When I run ifconfig on one of the four Pis (it is currently displaying IP xxx.xxx.xxx.xxx), It has this for eth0:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.100.3  netmask 255.255.255.0  broadcast 10.0.100.255
        inet6 fe80::575c:b03f:9366:5f89  prefixlen 64  scopeid 0x20<link>
        ether dc:a6:32:b0:53:f3  txqueuelen 1000  (Ethernet)
        RX packets 7850591  bytes 11401784444 (10.6 GiB)
        RX errors 1651  dropped 1651  overruns 0  frame 0
        TX packets 2558183  bytes 518677743 (494.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

So for some reason it seems like it's not picking up an IP address, even though there is one on the Pi. I checked on the other four Pis and they all have 10.0.100.x addresses assigned on eth0 as well.

Screen Shot 2022-09-22 at 10 26 26 PM

@geerlingguy
Copy link
Contributor Author

I created a new issue #4 and PR #5 to deal with the IP address issue—my suggestion is to default to the wired LAN port and not WiFi since most rackmounted deployments would use the Ethernet ports.

@arducamStephen
Copy link

@geerlingguy
OK. the ip address seems has been assigned normally. maybe you can try to print some log in the
get_ip_address function to debug. The api is under the https://github.com/UCTRONICS/SKU_RM0004/blob/main/hardware/rpiInfo/rpiInfo.c
file

@dwfa
Copy link

dwfa commented Sep 26, 2022

I had a few issues with my initial setup of the LCD for my rack unit, and not all of these are problems, but a few suggestions too:

1. Enabling I2C didn't work

Using the provided instructions, when I tried running the display, I got the following error:

Device I2C-1 failed to initialize

Indeed, even with dtparam=i2c_arm=on,i2c_arm_baudrate=400000 appended to my boot config and after a restart, I would keep getting that error.

I found out after a bit of debugging I had to put the dtparam=i2c_arm=on line earlier in my /boot/config.txt file. I was putting it near the end but for some reason that wasn't working. There was a commented line earlier in the file, and I uncommented that line, and everything works.

When I ran sudo raspi-config and enabled the I2C interface via that CLI interface, it also seemed to work, whereas manually enabling it by uncommenting the line didn't always. Not sure why, and I tried on both Buster and Bullseye.

So maybe updating the statement in the README to uncomment the existing line, and add on the i2c_arm_baudrate at the end, would be less prone to failure.

2. IP address always displayed as xxx.xxx.xxx.xxx (see #4)

My Pis are all plugged in via Ethernet, and if I run ip a I see something like:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether dc:a6:32:1a:68:4f brd ff:ff:ff:ff:ff:ff
    inet 10.0.100.10/24 brd 10.0.100.255 scope global dynamic noprefixroute eth0

But the IP address is never shown on the LCD. It looks like lcd_display_cpuLoad calls get_ip_address (though the comment there mentions wireless... it looks like the code looks for eth0...), but for some reason it never gets the IP for my Pis.

3. Simpler display preferred

The default settings make a display that refreshes parts and has four different displays cycling at all times. For my purposes, I would just like the IP address, and maybe the CPU temperature displayed (or something similarly simple, like hostname and IP). It would be great if this script could be customized to just display one thing and refresh every 5 seconds or something... or just display a text string on the screen.

I can see how to do that in the C, but having a little more flexibility could be nice. Otherwise, maybe someone in the community has a nice library that can do it separately... I noticed that the default setup would cause 3-5% CPU load every five seconds or so. Nothing crazy, but it is a lot of load just to update an informational display (which will not be looked at 99% of the time).

Hi Jeff - I had same issue as you, I did not move dtparam, but split the two directives and that seemed to work for me
dtparam=i2c_arm=on
dtparam=i2c_arm_baudrate=400000
...

@Dhouti
Copy link

Dhouti commented Sep 28, 2022

None of the above /boot/config.txt configurations worked out of the box for me.

Using sudo raspi-config was the solution that did the trick. The reason why this worked when editing /boot/config.txt didn't was that you also need to enable i2c-dev in /etc/modules.
raspi-config does this for you when you enable the interface.
https://github.com/RPi-Distro/raspi-config/blob/master/raspi-config#L957-L993

@msobadger
Copy link

Thanks for the thread guys! I had the same "Device I2C-1 failed to initialize" error when following the README guide and the tips in this thread all collectively solved the issue - uncommenting dtparam=i2c_arm=on, adding dtparam=i2c_arm_baudrate=400000 on it's own line, and using sudo raspi-config to enable i2c-dev.

I would also love to see @geerlingguy's suggestion #3 above implemented.

@dvlowe
Copy link

dvlowe commented Jan 21, 2023

Thanks Jeff and others, for your info. For others (and my future self), here are some screen shots showing the modifications to be made. Note, if anyone smarter than me sees something I did wrong, or could be better, please correct me.

Display Auto Start
Here is the rc.local file. Note, make sure to change "pi" to the new username if changed from pi. While a given to most, I fumbled here by adding the command at the bottom. A note should be specified to add it just before the "exit 0" command for us noobs. ;)
Display Autostart

Display and Power Boot Settings
Here is the modified /boot/config.txt file to show clearly what needs to be done.
Display and Power

Enabling ARM I2C through RASPI-CONFIG
Also, as mentioned before, hedge your bets and run raspi-config as well to enable arm i2c.
Raspi-1
Raspi-2
Raspi-3

Hope this helps future users and maybe the documentation can be updated to be clearer and more detailed.

@bryborge
Copy link

bryborge commented May 6, 2023

This thread helped clarify the instructions that are bundled with the hardware and resolved my issue Device I2C-1 failed to initialize. Thank you all so much! 🤘🏻

@aXb0t
Copy link

aXb0t commented Aug 20, 2023

Thanks y'all for the extremely helpful discussion and workarounds. I was able to get my Pi Rack PRO OLEDs displaying Pi information. ::thumbsup::

After getting the first Pi OLED up and running, I hacked together an Ansible script to make installing the rest foolproof and repeatable (relatively). Here it is for anybody else who wanders this way:

https://github.com/alexb7217/Pi-Rack-Pro_SKU_RM0004-Install

@pkpfr
Copy link

pkpfr commented Aug 27, 2023

Can I suggest that it is not necessary to compile the display binary on every boot? Just compile it once, move it to /usr/local/bin, delete the project files, and then change the rc.local entry to simply start the binary (/usr/local/bin/display &).

@carlowisse
Copy link

I am not sure if this is a dead thread or not. But I thought I would update with my configs and tools. The reason being is that recently I got the Pi Rack and still could not get the screens to work even with the above.

So I took apart the raspi-config script for i2c and built a bash script and an ansible playbook to get it all to work.

For reference, you can run raspi-config from the command line (soft of) because if you are like me, you live in CLI and rarely use a GUI.

The following will enable i2c within /boot/config.txt, /boot/firmware/config.txt and /etc/modules.

sudo raspi-config nonint do_i2c 0

That being said I went ahead and overkilled it by also manually making sure things are set in the script and the playbook.

I have also included the change to stop compiling on boot and rather move the binary to /usr/local/bin

The boot config I have below also disables Bluetooth and Wi-Fi, as I am using a PoE HAT.

BASH SCRIPT

### REPLACE /boot/config.txt with ../configs/boot.conf ###
sudo sed -i 's/#dtparam=i2c_arm=on/dtparam=i2c_arm=on/g' /boot/config.txt
sudo sed -i '/dtparam=i2c_arm=on/a\dtparam=i2c_arm_baudrate=400000' /boot/config.txt
sudo sed -i '/#dtparam=spi=on/a\dtoverlay=gpio-shutdown,gpio_pin=4,active_low=1,gpio_pull=up' /boot/config.txt

### ENABLE i2c IN FIRMWARE ###
sudo sed -i 's/#dtparam=i2c_arm=on/dtparam=i2c_arm=on/g' /boot/firmware/config.txt

### RASPI ENABLE i2c ###
sudo raspi-config nonint do_i2c 0

### ADD i2c TO /etc/modules ###
sudo echo "i2c-dev" | sudo tee -a /etc/modules >/dev/null

### MAKE SKU_RM0004 ###
git clone https://github.com/UCTRONICS/SKU_RM0004.git
cd SKU_RM0004
make clean
make

### MOVE display TO /usr/local/bin ###
sudo cp display /usr/local/bin

### REMOVE SKU_RM0004 ###
cd ..
sudo rm -rf SKU_RM0004

### ADD TO /etc/rc.local ###
sudo sed -i '/exit 0/i\/usr/local/bin/display &' /etc/rc.local

### REBOOT ###
sudo reboot

ANSIBLE PLAYBOOK

- name: Install SKU_RM0004
  hosts: pis
  become: yes
  tasks:
    - name: Replace /boot/config.txt with ../configs/boot.conf
      copy:
        src: ../configs/boot.conf
        dest: /boot/config.txt

    - name: Enable i2c_arm in /boot/firmware/config.txt
      lineinfile:
        path: /boot/firmware/config.txt
        regexp: '^#dtparam=i2c_arm=on'
        line: 'dtparam=i2c_arm=on'

    - name: Add to /etc/modules
      lineinfile:
        path: /etc/modules
        line: 'i2c-dev'
        create: yes

    - name: Enable I2C
      command: raspi-config nonint do_i2c 0

    - name: Remove existing SKU_RM0004 library
      file:
        path: '/home/pi/SKU_RM0004'
        state: absent

    - name: Clone SKU_RM0004 library
      git:
        repo: 'https://github.com/UCTRONICS/SKU_RM0004.git'
        dest: '/home/pi/SKU_RM0004'

    - name: Clean SKU_RM0004
      make:
        chdir: '/home/pi/SKU_RM0004'
        target: clean

    - name: Make SKU_RM0004
      make:
        chdir: '/home/pi/SKU_RM0004'

    - name: Move display to /usr/local/bin
      copy:
        src: '/home/pi/SKU_RM0004/display'
        dest: '/usr/local/bin/display'
        remote_src: yes
        mode: '0755'

    - name: Remove SKU_RM0004 directory
      file:
        path: '/home/pi/SKU_RM0004'
        state: absent

    - name: Remove existing exit 0 from /etc/rc.local
      lineinfile:
        path: /etc/rc.local
        line: 'exit 0'
        state: absent

    - name: Add to /etc/rc.local
      blockinfile:
        path: /etc/rc.local
        block: |
          /usr/local/bin/display &
          exit 0
        insertafter: EOF

    - name: Reboot
      reboot:

BOOT CONFIG

# For more options and information see
# http://rptl.io/configtxt

# Additional overlays and parameters are documented
# /boot/firmware/overlays/README

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
dtparam=i2c_arm_baudrate=400000
#dtparam=i2s=on
#dtparam=spi=on

# Enable shutdown button
dtoverlay=gpio-shutdown,gpio_pin=4,active_low=1,gpio_pull=up

# Disable WiFi and Bluetooth
dtoverlay=disable-wifi
dtoverlay=disable-bt

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# Automatically load overlays for detected cameras
camera_auto_detect=1

# Automatically load overlays for detected DSI displays
display_auto_detect=1

# Automatically load initramfs files, if found
auto_initramfs=1

# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2

# Don't have the firmware create an initial video= setting in cmdline.txt.
# Use the kernel's default instead.
disable_fw_kms_setup=1

# Run in 64-bit mode
arm_64bit=1

# Disable compensation for displays with overscan
disable_overscan=1

# Run as fast as firmware / board allows
arm_boost=1

# Enable host mode on the 2711 built-in XHCI USB controller.
[cm4]
otg_mode=1

@RNZB
Copy link

RNZB commented Dec 5, 2023

just purchased one of these racks and the code to get this up and running just isn't working. How has there not been any clear solution on the UCTRONICS installation page

@NOLAGT
Copy link

NOLAGT commented Sep 22, 2024

Thanks Jeff and others, for your info. For others (and my future self), here are some screen shots showing the modifications to be made. Note, if anyone smarter than me sees something I did wrong, or could be better, please correct me.

Display Auto Start Here is the rc.local file. Note, make sure to change "pi" to the new username if changed from pi. While a given to most, I fumbled here by adding the command at the bottom. A note should be specified to add it just before the "exit 0" command for us noobs. ;) Display Autostart

Display and Power Boot Settings Here is the modified /boot/config.txt file to show clearly what needs to be done. Display and Power

Enabling ARM I2C through RASPI-CONFIG Also, as mentioned before, hedge your bets and run raspi-config as well to enable arm i2c. Raspi-1 Raspi-2 Raspi-3

Hope this helps future users and maybe the documentation can be updated to be clearer and more detailed.

Old post I know but I was having issues getting my LCD screen running and im completely new to pi and coding. Your post helped me get it done.

I also wanted to put on here if anyone else comes across this post that with a update this year the sudo nano /boot/config.txt file changed. Its now sudo nano /boot/firmware/config.txt

@jpsullivan
Copy link

For those trying this out on a Pi 5, you should know that the following setting auto-triggers a safe shutdown as soon as booting has completed.

# Enable shutdown button
dtoverlay=gpio-shutdown,gpio_pin=4,active_low=1,gpio_pull=up

Commenting that out fixed the issue entirely. I haven't had the time to look into why, but hopefully if anyone else is seeing issues, this should sort it out.

Thanks to everyone above for all the great tips! A bit of a shame it required this much effort to get the rack up and running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests