redbear / IoT_pHAT

WiFi + Bluetooth, designed for the Raspberry Pi Zero
110 stars 32 forks source link

Reprogramming eeprom with dt #10

Closed saper-2 closed 7 years ago

saper-2 commented 7 years ago

Hi,

I had to update eeproms on my pHATs. When I run command to reprogram eeprom (from your guide): sudo ./eepflash.sh -f=IoT_pHAT-with-dt.eep -t=24c32 -w I get error:

pi@raspberrypi:~/phat $ sudo ./eepflash.sh -f=IoT_pHAT-with-dt.eep -t=24c32 -w
This will disable the camera so you will need to REBOOT after this process completes.
This will attempt to write to i2c address 0x50. Make sure there is an eeprom at this address.
This script comes with ABSOLUTELY no warranty. Continue only if you know what you are doing.
Do you wish to continue? (yes/no): yes
Writing...
dd: writing to ‘/sys/class/i2c-adapter/i2c-0/0-0050/eeprom’: Connection timed out
1+0 records in
0+0 records out
0 bytes (0 B) copied, 2.03952 s, 0.0 kB/s
Error doing I/O operation.

Fix:

The script eepfalsh.sh have to be executed from root account not via sudo: (To set password for root user run sudo passwd root )

pi@raspberrypi:~/phat $ su
Password:
root@raspberrypi:/home/pi/phat# ./eepflash.sh -f=IoT_pHAT-with-dt.eep -t=24c32 -w
This will disable the camera so you will need to REBOOT after this process completes.
This will attempt to write to i2c address 0x50. Make sure there is an eeprom at this address.
This script comes with ABSOLUTELY no warranty. Continue only if you know what you are doing.
Do you wish to continue? (yes/no): y
Please type yes or no.
Do you wish to continue? (yes/no): yes
Writing...
6+1 records in
6+1 records out
3344 bytes (3.3 kB) copied, 66.869 s, 0.1 kB/s
Done.

Also please add note that, writing eeprom take about 60-70sec to finish :smile: (Patience is not my virtue :wink: )

ralle12345 commented 7 years ago

You don't need to set a root password. You can also "sudo -i" to get a root shell and execute "./eepflash.sh -f=IoT_pHAT-with-dt.eep -t=24c32 -w" there.

oshank commented 7 years ago

I am still getting that issue regardless of what I am logged in as.

scruss commented 7 years ago

Likewise; still getting that issue regardless of what I am logged in as

saper-2 commented 7 years ago

I have no idea why you have an error.

Try running i2c-detect from root after running eepflash.sh

This is my result (actually I've run this after reboot and didn't disabled i2c_vc :) ):

root@raspberrypi:/home/pi# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@raspberrypi:/home/pi# i2cdetect -y 1
Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory

As you see, there is found EEPROM at address 0x50 on i2c-0 (the GPU I2C ), bus i2c-1 (the "user accessible") is not enabled on my pi0 so there is an error :smile:

I've soldered my 2nd board of IoT-pHAT and just tried updating the eeprom with instructions, here are logs from terminals:

Logs begin

Setup environment & get required files - I did this on Pi3 because it has network connection (it can be done on any Pi with network interface - Pi1, Pi2, Pi3). Raspberry Pi Raspbian with Pixel image: 2016-09-23-raspbian-jessie.img burned on 16Gb micro SD card.

pi@raspberrypi:~ $ cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 76.80
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 1
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 76.80
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 2
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 76.80
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 3
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 76.80
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

Hardware        : BCM2709
Revision        : a02082
Serial          : 00000000xxxxxxxx
pi@raspberrypi:~ $ sudo apt-get update
pi@raspberrypi:~ $ sudo apt-get upgrade
pi@raspberrypi:~ $ sudo raspi-config
* set locale, disable TTY over serial port, set wifi country, etc...
pi@raspberrypi:~ $ git clone https://github.com/redbear/IoT_pHAT.git
pi@raspberrypi:~ $ cd IoT_pHAT
pi@raspberrypi:~/IoT_pHAT $ cd eeprom
pi@raspberrypi:~/IoT_pHAT/eeprom $ cd experimental/v0.3
pi@raspberrypi:~/IoT_pHAT/eeprom/experimental/v0.3 $ ls
eepflash.sh  eeprom_settings.txt  IoT_pHAT.dts  IoT_pHAT-with-dt.eep
pi@raspberrypi:~/IoT_pHAT/eeprom/experimental/v0.3 $
pi@raspberrypi:~/IoT_pHAT/eeprom/experimental/v0.3 $ sudo passwd root
* set the root password
pi@raspberrypi:~/IoT_pHAT/eeprom/experimental/v0.3 $ sudo shutdown

remove card from Pi3, put it into Pi0 with IoT-pHAT, switched power on:

pi@raspberrypi:~ $ cat /proc/cpuinfo
processor   : 0
model name  : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS    : 997.08
Features    : half thumb fastmult vfp edsp java tls 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xb76
CPU revision    : 7

Hardware    : BCM2708
Revision    : 900092
Serial      : 00000000xxxxxxxx
pi@raspberrypi:~ $ su
Password: 
root@raspberrypi:/home/pi# cd IoT_pHAT/eeprom/experimental/v0.3
root@raspberrypi:/home/pi/IoT_pHAT/eeprom/experimental/v0.3# ls -la
total 24
drwxr-xr-x 2 pi pi 4096 Nov 12 00:10 .
drwxr-xr-x 3 pi pi 4096 Nov 12 00:10 ..
-rwxr-xr-x 1 pi pi 3108 Nov 12 00:10 eepflash.sh
-rwxr-xr-x 1 pi pi 3044 Nov 12 00:10 eeprom_settings.txt
-rwxr-xr-x 1 pi pi 2077 Nov 12 00:10 IoT_pHAT.dts
-rwxr-xr-x 1 pi pi 3344 Nov 12 00:10 IoT_pHAT-with-dt.eep
root@raspberrypi:/home/pi/IoT_pHAT/eeprom/experimental/v0.3# ./eepflash.sh -f=IoT_pHAT-with-dt.eep -t=24c32 -w
This will disable the camera so you will need to REBOOT after this process completes.
This will attempt to write to i2c address 0x50. Make sure there is an eeprom at this address.
This script comes with ABSOLUTELY no warranty. Continue only if you know what you are doing.
Do you wish to continue? (yes/no): yes
Writing...
6+1 records in
6+1 records out
3344 bytes (3.3 kB) copied, 66.8789 s, 0.1 kB/s
Done.
root@raspberrypi:/home/pi/IoT_pHAT/eeprom/experimental/v0.3# reboot

Configs:

pi@raspberrypi:~ $ cat /boot/config.txt
# For more options and information see
# http://www.raspberrypi.org/documentation/configuration/config-txt.md
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

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

# Uncomment this to enable the lirc-rpi module
#dtoverlay=lirc-rpi

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

# Enable audio (loads snd_bcm2835)
#dtparam=audio=on
enable_uart=0
dtparam=i2c_vc=on
pi@raspberrypi:~ $ cat /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait usbhid.mousepoll=0
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.4.26+ #915 Thu Oct 20 17:02:14 BST 2016 armv6l GNU/Linux

Here is proof, a screenshot taken by raspi2png: https://drive.google.com/file/d/0BySjzBz--msUZFNRelFVSFdKOEk/view?usp=sharing

If you can't reproduce, you have something broken (one or more): i2c-0 on bcm, eeprom, bad soldering, ... (put there for e.g.: terrorists, solar flare, moon eclipse on Mars...)

Cheong2K commented 7 years ago

@oshank @scruss, have you fixed this yet?

oshank commented 7 years ago

I have gotten it to flash correctly but I am unable to get bluetoothctl to work correctly.

Cheong2K commented 7 years ago

Try using this command to show the status: $ systemctl status hciuart.service

oshank commented 7 years ago

It was something like

Active (dead)

That was using DietPi OS

But I just tried with the newest Raspbian and it worked out of box. I did not need to flash the eeprom. Bluetooth and Wifi worked perfectly.