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

Does this still work at all with latest Pi OS images? #1

Open
clickworkorange opened this issue Aug 31, 2024 · 8 comments
Open

Does this still work at all with latest Pi OS images? #1

clickworkorange opened this issue Aug 31, 2024 · 8 comments

Comments

@clickworkorange
Copy link

I'm trying to upgrade to Pi OS "bookworm" but the Monarco hat seems to have gone AWOL; both the 1-wire interface and the RTC are missing from i2cdetect -y 1:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- 53 -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --

I would expect to see these devices as 0x6f and 0x18 respectively. Also the EEPROM is absent, which should be on 0x57 - perhaps this is the root cause? 0x53 is an accelerometer that also hangs off i2c-1, this is working as it should, so there's nothing wrong with the i2c bus itself.

@clickworkorange
Copy link
Author

clickworkorange commented Sep 2, 2024

Curiously, they do show up in /sys:

$ ls /sys/bus/i2c/devices/
10-0036  1-0018  1-006f  i2c-0  i2c-1  i2c-10  i2c-11

$ cat /sys/bus/i2c/devices/*/name
ov5647
ds2482
mcp7941x
i2c-11-mux (chan_id 0)
i2c-11-mux (chan_id 1)
bcm2835 (i2c@7e205000)
bcm2835 (i2c@7e804000)

@clickworkorange
Copy link
Author

clickworkorange commented Sep 2, 2024

Trying to run the flash updater with kernel 6.6 I get a write error on /sys/class/gpio:

./monarco-flash.pl flash ./firmware-bin/fw-monarco-hat-2008.bin
Monarco HAT Flash Firmware Downloader, version 1.1
(c) REX Controls 2016, http://www.rexcontrols.com

HAT ID detected:
  Vendor: REX Controls
  Product: Monarco HAT
  Product ID: 0x0001
  Product VER: 0x1105
  UUID: fe0f39bf-7c03-4eb6-9a91-df861ae5abcd

Serial device /dev/ttyAMA0 check OK.

write error at ./monarco-flash.pl line 293.
	main::file_write("/sys/class/gpio/export", 21) called at ./monarco-flash.pl line 261
	main::gpio_init() called at ./monarco-flash.pl line 158

This is most likely caused by the reorganisation of /sys/class/gpio introduced in kernel 6.6: raspberrypi/linux#6037 - the updater still works fine with 6.1:

$ sudo ./monarco-flash.pl flash ./firmware-bin/fw-monarco-hat-2008.bin
Monarco HAT Flash Firmware Downloader, version 1.1
(c) REX Controls 2016, http://www.rexcontrols.com

HAT ID detected:
  Vendor: REX Controls
  Product: Monarco HAT
  Product ID: 0x0001
  Product VER: 0x1105
  UUID: fe0f39bf-7c03-4eb6-9a91-df861ae5abcd

Serial device /dev/ttyAMA0 check OK.

MCU Bootloader ID: [1.60 ChipID: 247DBC0658172069]

Press ENTER to continue ...
XModem: Start, waiting for handshake
XModem: Handshake success
XModem: Sending: ...............................................................................................................................................................................

CRC RESULT: [18] c--CRC: 00009D4D--

OK!

@clickworkorange
Copy link
Author

clickworkorange commented Sep 3, 2024

It seems the hat EEPROM is being read, since it activates both the i2c and spi buses even when these are not enabled in /boot/firmware/config.txt. I'm not sure if the last bit works though, where it remaps uart0&1:

https://github.com/monarco/monarco-hat-firmware-bin/blob/master/device-tree/monarco-hat-4-9.dts#L53-L98

I also see

$ ls /proc/device-tree/hat/
name  product  product_id  product_ver  uuid  vendor

$ cat /proc/device-tree/hat/product
Monarco HAT

But with no changes to my /boot/firmware/config.txt I see a /dev/serial0 device whereas I think the hat EEPROM should change this to /dev/serial1?

@clickworkorange
Copy link
Author

clickworkorange commented Sep 3, 2024

I've downloaded the Rexygen Bookworm image and had a poke around in it, to see if you're doing anything special to get the Monarco Hat working, but I don't spot anything obvious... Still, I'm encouraged that it even exists - that means the hat should work on my set-up as well.

@clickworkorange
Copy link
Author

I see your Rexygen Bookworm image is 32-bit:

# less /media/me/rootfs/etc/apt/sources.list
deb [ arch=armhf ] http://raspbian.raspberrypi.com/raspbian/ bookworm main contrib non-free rpi

Whereas I'm running 64-bit PiOS Bookworm - could that be the issue?

@clickworkorange
Copy link
Author

clickworkorange commented Sep 3, 2024

Here's how the GPIOs are configured on the Pi in question:

$ pinctrl
 0: a0    -- | hi // ID_SDA/GPIO0 = SDA0
 1: a0    -- | hi // ID_SCL/GPIO1 = SCL0
 2: a0    -- | hi // SDA1/GPIO2 = SDA1
 3: a0    -- | hi // SCL1/GPIO3 = SCL1
 4: ip    -- | hi // GPIO_GCLK/GPIO4 = input
 5: ip    -- | hi // GPIO5 = input
 6: ip    -- | hi // GPIO6 = input
 7: op -- -- | hi // SPI_CE1_N/GPIO7 = output
 8: op -- -- | hi // SPI_CE0_N/GPIO8 = output
 9: a0    -- | lo // SPI_MISO/GPIO9 = SPI0_MISO
10: a0    -- | lo // SPI_MOSI/GPIO10 = SPI0_MOSI
11: a0    -- | lo // SPI_SCLK/GPIO11 = SPI0_SCLK
12: ip    -- | lo // GPIO12 = input
13: op -- -- | hi // GPIO13 = output
14: a0    -- | hi // TXD1/GPIO14 = TXD0
15: a0    -- | hi // RXD1/GPIO15 = RXD0
16: ip    -- | lo // GPIO16 = input
17: ip    -- | lo // GPIO17 = input
18: ip    -- | lo // GPIO18 = input
19: ip    -- | lo // GPIO19 = input
20: ip    -- | lo // GPIO20 = input
21: ip    -- | hi // GPIO21 = input
22: ip    -- | lo // GPIO22 = input
23: ip    -- | lo // GPIO23 = input
24: ip    -- | lo // GPIO24 = input
25: ip    -- | lo // GPIO25 = input
26: ip    -- | hi // GPIO26 = input
27: ip    -- | lo // GPIO27 = input
28: ip    -- | hi // HDMI_HPD_N/GPIO28 = input
29: op -- -- | lo // STATUS_LED_G/GPIO29 = output
30: ip    -- | hi // CTS0/GPIO30 = input
31: ip    -- | hi // RTS0/GPIO31 = input
32: ip    -- | hi // TXD0/GPIO32 = input
33: ip    -- | hi // RXD0/GPIO33 = input
34: ip    -- | hi // SD1_CLK/GPIO34 = input
35: ip    -- | hi // SD1_CMD/GPIO35 = input
36: ip    -- | hi // SD1_DATA0/GPIO36 = input
37: ip    -- | hi // SD1_DATA1/GPIO37 = input
38: ip    -- | hi // SD1_DATA2/GPIO38 = input
39: ip    -- | hi // SD1_DATA3/GPIO39 = input
40: a0    -- | lo // PWM0_OUT/GPIO40 = PWM0
41: a0    -- | lo // PWM1_OUT/GPIO41 = PWM1
42: a0    -- | lo // ETH_CLK/GPIO42 = GPCLK1
43: a0    -- | lo // WIFI_CLK/GPIO43 = GPCLK2
44: ip    -- | hi // SDA0/GPIO44 = input
45: ip    -- | hi // SCL0/GPIO45 = input
46: ip    -- | hi // SMPS_SCL/GPIO46 = input
47: op -- -- | hi // SMPS_SDA/GPIO47 = output
48: a0    -- | lo // SD_CLK_R/GPIO48 = SD0_CLK
49: a0    -- | hi // SD_CMD_R/GPIO49 = SD0_CMD
50: a0    -- | hi // SD_DATA0_R/GPIO50 = SD0_DAT0
51: a0    -- | hi // SD_DATA1_R/GPIO51 = SD0_DAT1
52: a0    -- | hi // SD_DATA2_R/GPIO52 = SD0_DAT2
53: a0    -- | hi // SD_DATA3_R/GPIO53 = SD0_DAT3

Looks correct to me?

@clickworkorange
Copy link
Author

Loaded i2c modules:

$ lsmod | grep i2c
i2c_dev                20480  14
regmap_i2c             16384  1 rtc_ds1307
i2c_mux_pinctrl        16384  0
i2c_mux                16384  1 i2c_mux_pinctrl
i2c_bcm2835            20480  8

@clickworkorange
Copy link
Author

clickworkorange commented Sep 3, 2024

Trying to read from the RTC and 1-Wire controller with i2cget fails:

$ i2cget -f 1 0x6f 
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will read from device file /dev/i2c-1, chip address 0x6f, current data
address, using read byte.
Continue? [Y/n] 
Error: Read failed

$ i2cget -f 1 0x18 
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will read from device file /dev/i2c-1, chip address 0x18, current data
address, using read byte.
Continue? [Y/n] 
Error: Read failed

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

1 participant