I have tested the code and no joy ;-(
Real Input and Output on the Pi emulation
-
- Posts: 28
- Joined: 23 Sep 2024 16:11
Re: Real Input and Output on the Pi emulation
The issue is that init already goes not correctly:
timoh@raspberrypi:~ $ i2cdump -y 1 0x20
No size specified (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
10: 00 00 bc bc bc 50 00 00 00 00 00 00 00 00 00 00 ..???P..........
20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
I would expect on 0x00 : 0x00 and on 0x01 : 0xff
timoh@raspberrypi:~ $ i2cdump -y 1 0x20
No size specified (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
10: 00 00 bc bc bc 50 00 00 00 00 00 00 00 00 00 00 ..???P..........
20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
I would expect on 0x00 : 0x00 and on 0x01 : 0xff
Re: Real Input and Output on the Pi emulation
OK. I will have to get some hardware set up and test properly.
Have you tried the alternate method using the kernel driver?
-
- Posts: 28
- Joined: 23 Sep 2024 16:11
Re: Real Input and Output on the Pi emulation
No but I have done some hacking in your code ( added logging in the code ) and I see BOOLEAN hw_options (int *pargc, const char ***pargv, int *pi) in hardware.c is never called it also means that hw_read is never called so I2C and GPIO is never configured as it is should ;-(
-
- Posts: 28
- Joined: 23 Sep 2024 16:11
Re: Real Input and Output on the Pi emulation
To get your current code working I have done the following things:
in hardware.c line comment out gio_output (8, pinPOT, 0xFF); ( around line 428 )
in gpio.c
Changed the line if ( ( pdev->fd > 0 ) && ( pdev->iData ) ) xio_put (pdev, pdev->iMask, pdev->iData); into
if ( pdev->fd > 0 )
xio_put (pdev, pdev->iMask, pdev->iData);
( around line 754 in function gio_put
in gpio.c in the function xio_put I have changed the regiters addresses from 0x14 into 0x12
in gpio.c in the function i2c_get changed the line msg[0].len = iLen + 1; into msg[0].len = sizeof(bAddr);
in memu.c
I ihave added the lines under
diag_message(DIAG_ALWAYS, "=== memu started at %s ===", buf);
hw_read ("hardware.cfg");
hw_init ();
around line 3625
-
- Posts: 28
- Joined: 23 Sep 2024 16:11
Re: Real Input and Output on the Pi emulation
Hello I have made a page with software I have written to test the emulator and some photos of the print
https://timohartong.riscos.fr/memotech/
https://timohartong.riscos.fr/memotech/
Re: Real Input and Output on the Pi emulation
Thanks, that will be most helpful when I get my test hardware setup.
-
- Posts: 28
- Joined: 23 Sep 2024 16:11
Re: Real Input and Output on the Pi emulation
Your efforts are highly appreciated I hope to place schematics also today.
-
- Posts: 28
- Joined: 23 Sep 2024 16:11
Re: Real Input and Output on the Pi emulation
Another update : when the unit starts up completely fresh the lines in hardware.c :
gio_input (8, pinPIN, 0xFF);
gio_output (8, pinPOT, 0xFF);
Do work so I have put them back. It is really a bit looking
gio_input (8, pinPIN, 0xFF);
gio_output (8, pinPOT, 0xFF);
Do work so I have put them back. It is really a bit looking
Re: Real Input and Output on the Pi emulation
I have not yet got hardware set-up for testing, however I have been reviewing the code following your comments:
As a result of that definition line 2559 of memu.c becomes a call to hw_options.
I have pushed an update which includes my version of these changes.
It is called, but not obvious from the source code. Note the following line in the CMakeLists.txt file, which is only enabled if HW_GPIO or HW_MCP23017 is defined:TimoHartong wrote: ↑11 Dec 2024 19:05 No but I have done some hacking in your code ( added logging in the code ) and I see BOOLEAN hw_options (int *pargc, const char ***pargv, int *pi) in hardware.c is never called it also means that hw_read is never called so I2C and GPIO is never configured as it is should ;-(
Code: Select all
-DALT_OPTIONS=hw_options
A typo (copy / paste error) on my part. The line should be as follows, replacing iData by iMask in the condition:TimoHartong wrote: ↑11 Dec 2024 16:31 in gpio.c
Changed the line if ( ( pdev->fd > 0 ) && ( pdev->iData ) ) xio_put (pdev, pdev->iMask, pdev->iData); into
if ( pdev->fd > 0 )
xio_put (pdev, pdev->iMask, pdev->iData);
( around line 754 in function gio_put
Code: Select all
if ( ( pdev->fd > 0 ) && ( pdev->iMask ) ) xio_put (pdev, pdev->iMask, pdev->iData);
Address 0x12 is the GPIO register while 0x14 is the OLAT register. From the MCP23017 datasheet:TimoHartong wrote: ↑11 Dec 2024 16:31 in gpio.c in the function xio_put I have changed the regiters addresses from 0x14 into 0x12
Since xio_put is reading and updating the output values, the OLAT register is the correct one to use. The update should not be affected by values on any input pins.The GPIO register reflects the value on the port. Reading from this register reads the port. Writing to this register modifies the Output Latch (OLAT) register.
The OLAT register provides access to the output latches. A read from this register results in a read of the OLAT and not the port itself. A write to this register modifies the output latches that modifies the pins configured as outputs.
Good spot. I agree.TimoHartong wrote: ↑11 Dec 2024 16:31 in gpio.c in the function i2c_get changed the line msg[0].len = iLen + 1; into msg[0].len = sizeof(bAddr);
As above, this is done in hw_options which is called if and only if hardware interfacing is selected as a compilation option.TimoHartong wrote: ↑11 Dec 2024 16:31 in memu.c
I ihave added the lines under
diag_message(DIAG_ALWAYS, "=== memu started at %s ===", buf);
hw_read ("hardware.cfg");
hw_init ();
around line 3625
I have pushed an update which includes my version of these changes.