fusys
Creatures
Posts: 18
|
Post by fusys on Jan 31, 2020 22:15:02 GMT
Hello everybody, I have "TheC64" (maxi) and I'm really happy with it. How complex would it be to enable the userport RS232 emulation (VICE can do that) so that data is sent/received through an USB2Serial cable (FTDI or something) plugged into TheC64? It would be great for an hobby project I'm doing to exchange data between TheC64 and my PC (not interested in adding games, I'm just developing some "terminal-like" software for TheC64). Thanks
|
|
|
Post by jj0 on Jan 31, 2020 23:04:29 GMT
Hello everybody, I have "TheC64" (maxi) and I'm really happy with it. How complex would it be to enable the userport RS232 emulation (VICE can do that) so that data is sent/received through an USB2Serial cable (FTDI or something) plugged into TheC64? It would be great for an hobby project I'm doing to exchange data between TheC64 and my PC (not interested in adding games, I'm just developing some "terminal-like" software for TheC64). Thanks If you're lucky this wasn't disabled by Retro Ltd in the vice emulator code that they've used/modified. Then you can check what options a 2.4 version of vice in a regular Linux or Windows environment enables for it in vicerc. Then you can copy those entries to /root/.vice/vicerc. But if you're unlucky they ripped out the entire code for RS232 emulation.
|
|
fusys
Creatures
Posts: 18
|
Post by fusys on Jan 31, 2020 23:51:48 GMT
Thanks for the suggestion. So, I have a couple more questions...
Do I need the UART mod to access /root/.vice/vicerc?
Can I check if the RS232 code have been ripped out before doing the UART mod? The source code of the modified VICE running in TheC64 should be available since VICE has a GPL2 license... right?
Finally... any hope that the USB2Serial driver is already present in TheC64 linux subsystem?
|
|
|
Post by jj0 on Feb 1, 2020 10:01:01 GMT
Thanks for the suggestion. So, I have a couple more questions... Do I need the UART mod to access /root/.vice/vicerc? Either UART mod, or FEL mode, whichever you like best. Can I check if the RS232 code have been ripped out before doing the UART mod? The source code of the modified VICE running in TheC64 should be available since VICE has a GPL2 license... right? The source code was requested by swingflip and can be found here. Finally... any hope that the USB2Serial driver is already present in TheC64 linux subsystem? Abandon all hope. There are no extra useful modules included in the Linux rootfs. But I managed to compile some usb2serial modules: serial.zip (516.47 KB). You need the included insmod as well to insert them with # insmod -f ussbnet.ko # insmod -f xxxx.ko because the kernel version string doesn't exactly match. The pl2302 one works, the others I'm not sure.
|
|
fusys
Creatures
Posts: 18
|
Post by fusys on Feb 1, 2020 14:28:12 GMT
From a quick look at the sources (thanks for that!), it seems like the rs232 code is there. So, in theory I see no reason why it shouldn't work. Do you suggest the UART or FEL mod?
Another question... internally, TheC64 has a USB keyboard or what? Is it possible to just move the cables out of the case, attach a USB connector and plug it on my PC to control VICE?
|
|
|
Post by jj0 on Feb 1, 2020 15:14:41 GMT
From a quick look at the sources (thanks for that!), it seems like the rs232 code is there. So, in theory I see no reason why it shouldn't work. Do you suggest the UART or FEL mod? Another question... internally, TheC64 has a USB keyboard or what? Is it possible to just move the cables out of the case, attach a USB connector and plug it on my PC to control VICE? FEL mod allows you to modify the system while the actual kernel / rootfs is not running. So it is more difficult to test things. So i'd say UART mod is better. There are people who mad a '3-pin' (or is it 4) C64Maxi to USB connector, and ti works fine apparently.
|
|
fusys
Creatures
Posts: 18
|
Post by fusys on Feb 1, 2020 22:37:01 GMT
Ok, I'll try to solder a connector on the UART pin. The FEL mod is not that useful as I need to drill the case to reach the button. Perhaps, the easiest solution for me is to just expose the "USB keyboard" and install VICE on a Rapberry Pi. I'll let you know if I make some progress
|
|
|
Post by jj0 on Feb 2, 2020 5:37:58 GMT
Ok, I'll try to solder a connector on the UART pin. The FEL mod is not that useful as I need to drill the case to reach the button. Perhaps, the easiest solution for me is to just expose the "USB keyboard" and install VICE on a Rapberry Pi. I'll let you know if I make some progress Raspberry Pi might be be the easiest solution from the software side, but is it as much fun? Btw, you can also avoid soldering by using my (still not patented) 'rubber band' methods 1 or 2. Or run the FEL method once, copy the usbnet.ko and PL2303 usb2serial drivers over to to nand rootfs together with an /etc/init.d script to load them. Then add a line to /etc/inittab below the line # Put a getty on the serial port ttyS0::respawn:/sbin/getty -L ttyS0 0 vt100 # GENERIC_SERIAL
like this: ttyUSB0::respawn:/sbin/getty -L 115200 ttyUSB0 vt100 And if you then piggyback two PL2303 usb2serial converters, insert one of them in the Maxi, the other in your PC you should get a login prompt.
|
|
fusys
Creatures
Posts: 18
|
Post by fusys on Feb 2, 2020 10:23:25 GMT
Raspberry Pi might be be the easiest solution from the software side, but is it as much fun? I agree with that Btw, you can also avoid soldering by using my (still not patented) 'rubber band' methods 1 or 2. Or run the FEL method once, copy the usbnet.ko and PL2303 usb2serial drivers over to to nand rootfs together with an /etc/init.d script to load them. Then add a line to /etc/inittab below the line # Put a getty on the serial port ttyS0::respawn:/sbin/getty -L ttyS0 0 vt100 # GENERIC_SERIAL
like this: ttyUSB0::respawn:/sbin/getty -L 115200 ttyUSB0 vt100 And if you then piggyback two PL2303 usb2serial converters, insert one of them in the Maxi, the other in your PC you should get a login prompt. The rubber band method sounds like a brilliant alternative, considering that I have a bunch of breadboard jumper wires already on my desk. I would like to use an Arduno UNO with the reset pin shorted to ground as USB2Serial converter (in practice is an FTDI converter). I see the ftdi_sio.ko module in the serial.zip file you posted before, so it worth to try...
|
|
|
Post by jj0 on Feb 2, 2020 10:27:16 GMT
Raspberry Pi might be be the easiest solution from the software side, but is it as much fun?  I agree with that Btw, you can also avoid soldering by using my (still not patented) 'rubber band' methods 1 or 2. Or run the FEL method once, copy the usbnet.ko and PL2303 usb2serial drivers over to to nand rootfs together with an /etc/init.d script to load them. Then add a line to /etc/inittab below the line # Put a getty on the serial port ttyS0::respawn:/sbin/getty -L ttyS0 0 vt100 # GENERIC_SERIAL
like this: ttyUSB0::respawn:/sbin/getty -L 115200 ttyUSB0 vt100 And if you then piggyback two PL2303 usb2serial converters, insert one of them in the Maxi, the other in your PC you should get a login prompt. The rubber band method sounds like a brilliant alternative, considering that I have a bunch of breadboard jumper wires already on my desk. I would like to use an Arduno UNO with the reset pin shorted to ground as USB2Serial converter (in practice is an FTDI converter). I see the ftdi_sio.ko module in the serial.zip file you posted before, to it worth to try... Yes, I compiled that one too, but wasn't able to test it. So it will be interesting to see if it works.
|
|
fusys
Creatures
Posts: 18
|
Post by fusys on Feb 2, 2020 22:06:09 GMT
Ok, I have some good and bad news... First of all, following your suggestions I've managed to get root access to my TheC4 maxi without soldering. I used a RasPI 3 as a (powerful) UART dongle so I could easily read-write to UART via SSH... and no messy cables around. Anyway, I've copied both cp210x.ko and ftdi_sio.ko to /root, tweaked the /etc/inittab a bit: ::sysinit:/root/extra_modules/insmod -f /root/extra_modules/serial/usbserial.ko ::sysinit:/root/extra_modules/insmod -f /root/extra_modules/serial/cp210x.ko ::sysinit:/root/extra_modules/insmod -f /root/extra_modules/serial/ftdi_sio.ko ttyUSB0::respawn:/sbin/getty -L 115200 ttyUSB0 vt100 And now when I plug my cp210x-based USB2Serial dongle I have the login prompt! I've closed TheC64 as it was before the surgery (no soldering needed). So... I started messing around with vicerc file. Apparently, the relevant options to add are: [C64] RsDevice1="/dev/ttyUSB0" RsUserEnable=1
I've killed and restarted "the64" process, the /root/.vice/vicerc file is read, but I have this not-so-promising warning: Reading configuration file `/root/.vice/vicerc'. Error - Unknown resource `RsDevice1'. Warning - /root/.vice/vicerc: Unknown resource specification at line 2.
So, what do you think? Looks like the RS232 stuff has been removed after all... any idea? Besides, I had a lot of fun today, thank you again for your great help!
|
|
|
Post by jj0 on Feb 3, 2020 8:25:06 GMT
So... I started messing around with vicerc file. Apparently, the relevant options to add are: [C64] RsDevice1="/dev/ttyUSB0" RsUserEnable=1
I've killed and restarted "the64" process, the /root/.vice/vicerc file is read, but I have this not-so-promising warning: Reading configuration file `/root/.vice/vicerc'. Error - Unknown resource `RsDevice1'. Warning - /root/.vice/vicerc: Unknown resource specification at line 2.
So, what do you think? Looks like the RS232 stuff has been removed after all... any idea? It isn't real fun if it works on the first try, right? I haven't looked through the source, but my guess is that the Retro Ltd guys didn't rip out stuff from Vice, that would bee too risky. More likely they remover/changed some of the lookup strings for .vicerc. I notice it doesn'tcomplain about the 'RsUserEnable' setting. So if you're any good at debugging you could try to see where .vicerc is read and see if you can put the 'RsDevice1' back to being recognised. But that's grasping at straws, really. Also, would /dev/ttyUSB0 not already be in use by the login prompt?
|
|
|
Post by jj0 on Feb 3, 2020 10:28:16 GMT
So... I started messing around with vicerc file. Apparently, the relevant options to add are: [C64] RsDevice1="/dev/ttyUSB0" RsUserEnable=1
I've killed and restarted "the64" process, the /root/.vice/vicerc file is read, but I have this not-so-promising warning: Reading configuration file `/root/.vice/vicerc'. Error - Unknown resource `RsDevice1'. Warning - /root/.vice/vicerc: Unknown resource specification at line 2.
So, what do you think? Looks like the RS232 stuff has been removed after all... any idea? It isn't real fun if it works on the first try, right? I haven't looked through the source, but my guess is that the Retro Ltd guys didn't rip out stuff from Vice, that would bee too risky. More likely they remover/changed some of the lookup strings for .vicerc. I notice it doesn'tcomplain about the 'RsUserEnable' setting. So if you're any good at debugging you could try to see where .vicerc is read and see if you can put the 'RsDevice1' back to being recognised. But that's grasping at straws, really. Also, would /dev/ttyUSB0 not already be in use by the login prompt? Ok, bad news for RS232. From the ' the64_configure' file in the source: ./configure --disable-sdlui --disable-fullscreen --disable-gnomeui --disable-rs232 --disable-midi --disable-lame --disable-nls --disable-dingoo --disable-dingux --disable-ffmpeg --disable-quicktime --disable-ethernet --disable-ipv6 --disable-parsid --disable-bundle --disable-editline --disable-wiz --disable-static-lame --disable-hidmgr --disable-hidutils --with-alsa --without-pulse --without-sdlsound --without-oss --without-png --without-picasso96 --without-cocoa --without-x --no-create --no-recursion So no hope left I guess.
|
|
fusys
Creatures
Posts: 18
|
Post by fusys on Feb 3, 2020 13:25:48 GMT
I used /dev/ttyUSB0 just to try as I had only one USB2serial dongle available at home. Anyway, the problem is that the rs232 is not included at build time Exposing the keyboard seems like the only viable method to me.. or recompile everything which I suppose is something impossible to do
|
|
|
Post by jj0 on Feb 3, 2020 16:06:10 GMT
I used /dev/ttyUSB0 just to try as I had only one USB2serial dongle available at home. Anyway, the problem is that the rs232 is not included at build time Exposing the keyboard seems like the only viable method to me.. or recompile everything which I suppose is something impossible to do Yes, it's a shame. But you can configure the Pi (if that is the device you were going to use) in OTG mode as USB HID keyboard. Then you could use that as artificial input. Or configure it as OTG Mass Storage Device with the simulated USB drive having a THEC64-drive8.d64 file that you manipulate to have your data on it. That still sounds like fun
|
|
fusys
Creatures
Posts: 18
|
Post by fusys on Feb 3, 2020 21:08:03 GMT
Yea, I was already thinking of some alternatives. For example, I would like to use the SID chip to send data to my PC by modulating the audio frequency. For the other way round, simulating a joypad should be feasible, but I'm worried about the limited transfer rate... I'm curious about simulating a Mass Storage... I fear that the underlying Linux system (or maybe VICE) would cache THEC64-drive8.d64 data, so if I automagically change it the new data will not be visible Am I wrong?
|
|
fusys
Creatures
Posts: 18
|
Post by fusys on Feb 5, 2020 21:23:25 GMT
Besides, I've also tried to start the (remote) monitor... with no success
|
|
|
Post by jj0 on Feb 6, 2020 20:16:17 GMT
Besides, I've also tried to start the (remote) monitor... with no success Do you mean GDB?
|
|
fusys
Creatures
Posts: 18
|
Post by fusys on Feb 8, 2020 12:43:58 GMT
No, I mean that VICE has a feature called "remote monitor" in which you could basically telnet to it and debug the code execution (hence read/write to C64 RAM)
|
|
fusys
Creatures
Posts: 18
|
Post by fusys on Feb 11, 2020 21:11:57 GMT
Hello again. I was thinking about using process_vm_readv and process_vm_writev (http://man7.org/linux/man-pages/man2/process_vm_readv.2.html) to directly "peek/poke" the C64 memory from outside (and hence somehow simulate the rs232). Therefore, I need to cross-compile stuff from my Linux box to TheC64 board. Can you give me some advice on how to start? Is there any toolkit already available for that board or I need to compile everything from scratch (I mean the libc and all the other stuff...)?
|
|
|
Post by jj0 on Feb 12, 2020 8:59:59 GMT
Hello again. I was thinking about using process_vm_readv and process_vm_writev (http://man7.org/linux/man-pages/man2/process_vm_readv.2.html) to directly "peek/poke" the C64 memory from outside (and hence somehow simulate the rs232). Therefore, I need to cross-compile stuff from my Linux box to TheC64 board. Can you give me some advice on how to start? Is there any toolkit already available for that board or I need to compile everything from scratch (I mean the libc and all the other stuff...)? I think the easiest way is to avoid cross compiling altogether, and use a suitable armv7l virtual rootfs on a normal PC, like I use as described here. You can use the same rootfs.img or download another one for e.g. OlinuXino-Lime, Cubieboard/Cubietruck. You'll probably need to install the compiler, I don't hink I included it. If the program you'll write is not libc-version and/or kernel-version dependent It should work on TheC64 as well. Otherwise you can use buildroot to create a rootfs from scratch with the same library versions as TheC64. The alternative is to actually boot such a system (on USB) on TheC64 which you can do by interrupting uboot and changing nand root to /dev/sd<x>. But that is rather tedious every time.
|
|
fusys
Creatures
Posts: 18
|
Post by fusys on Feb 13, 2020 22:31:09 GMT
Hi there, I didn't compiled any software yet but I've made some progress to solve my problem. Here is what I did: 1) I downloaded a statically-linked version of GDB for arm7 and copied to the pendrive. It worked like a charm 2) I found the64 PID with ps ax (turned out to be 171) 3) cat /proc/171/maps to get a description of virtual memory regions of the process 4) in the C64 I've poked some memory at $C100 with a know byte pattern (my name 5) gdb attach 171 6) I started searching around in all the read-write memory regions for the byte pattern that I've written before at location $C100. For example: (gdb) find /b 0x00058000, 0x00060000-1, 0x46, 0x49, 0x4c, 0x49 .... 7) Few dozens tries later... I've finally found my pattern around 0xB36903EC (in the linux board memory of course) 8) I tried to modify that memory location: (gdb) set *((unsigned char*)0xb36904ec)=0xFF 9) VoilĂ ! If I poke $C100 now returns 0xFF So, it is feasible to peek/poke the C64 memory from outside while VICE is stopped in GDB (of course it makes sense, but seeing it working is another thing...). The next challenge is to do that with VICE running, but it should work assuming that process_vm_readv and process_vm_writev syscalls are both available. wish me good luck!
|
|
|
Post by jj0 on Feb 14, 2020 5:39:23 GMT
That is actually quite cool, I can see this turning into a PEEK/POKE tool to get infinite live etc on Carousel games đ
|
|
fusys
Creatures
Posts: 18
|
Post by fusys on Feb 29, 2020 23:31:33 GMT
Hi, I'm back. So.. after a while I've found some time to code a simple memory monitor for theC64. It works by invoking the process_vm_readv/process_vm_writev syscalls on the virtual memory regions of the process mapped to the emulated C64 memory. The absolute offset inside the page appears to be constant even if I reset the machine or start in carousel mode. If anybody of you wants to test it, just copy the two files tc64monitor and runtc64mon.sh on the USB flash drive, turn on theC64 and open a shell with the usual UART interface. Then: cd /mnt ./runtc64mon.sh
*** tc64monitor *** v 0.1
*****************************
fusys 2020
PID: 171
BASE ADDR: 0xb23e7000
OFFSET: 0x125f876
C64ADDR: 0x48a
C64MEM: 0xb36463ec
Type ? for help.
> At this point is possible to peek/poke the (emulated) C64 memory as follows: to poke some bytes at <addr>: :<addr> <byte1><byte2>....<byten>
to peek n bytes at <addr>: M<addr> +n For example, if you type: :$05F0 08050C0C0F the word "HELLO" should appear at the center of the screen (assuming that basic is running, otherwise the screen memory region may be different). Note that the process is not stopped as I did previously with GDB. I've successfully used this technique to exchange data between my laptop and the emulated C64 as originally planned by using RS232 interface. Does anybody want to test it? I'm curious to know if it works also on the C64 mini... Attachments:tc64monitor.zip (269.01 KB)
|
|
|
Post by jj0 on Mar 1, 2020 9:09:27 GMT
Hi, I'm back. So.. after a while I've found some time to code a simple memory monitor for theC64. It works by invoking the process_vm_readv/process_vm_writev syscalls on the virtual memory regions of the process mapped to the emulated C64 memory. The absolute offset inside the page appears to be constant even if I reset the machine or start in carousel mode. If anybody of you wants to test it, just copy the two files tc64monitor and runtc64mon.sh on the USB flash drive, turn on theC64 and open a shell with the usual UART interface. Then: .... .... For example, if you type: :$05F0 08050C0C0F the word "HELLO" should appear at the center of the screen (assuming that basic is running, otherwise the screen memory region may be different). Note that the process is not stopped as I did previously with GDB. I've successfully used this technique to exchange data between my laptop and the emulated C64 as originally planned by using RS232 interface. Does anybody want to test it? I'm curious to know if it works also on the C64 mini... Hi, this is pretty cool! It works on the Mini as well. One thing I noted is that it doesn't work on changing the border colour, if I do: > :$D020 10 > M $D020 +1 10
Clearly the value is changed but the border colour doesn't change. If I POKE different values in $D020 in BASIC the values read by the tool don't change. This is probably because of the way the VIC-II registers are mapped? Also if you plan to develop this further, some nice features would be: - Command history
- Search and Search/Replace for binary and text
Thanks for teaching me about process_vm_readv/process_vm_writev syscall, I might use these in the future.
Lastly, any chance of sharing the source for educational purposes?
|
|
fusys
Creatures
Posts: 18
|
Post by fusys on Mar 1, 2020 9:57:17 GMT
I've also noticed it, that's probably because the c64 memory is not mapped as a contiguous region in VICE. Actually, looking at the source code it seems like some areas are managed by the vic20 subsystem and some others by c64. I haven't investigated it further because I just needed to peek-poke some data with no requirement on the specific memory address. Anyway, if you think it's interesting for the community I can improve it. Source code will be available as soon as I clean up the messy parts
|
|
fusys
Creatures
Posts: 18
|
Post by fusys on Mar 1, 2020 19:34:08 GMT
|
|
pod
Creatures
Posts: 15
|
Post by pod on Mar 2, 2020 12:32:36 GMT
|
|
pod
Creatures
Posts: 15
|
Post by pod on Mar 2, 2020 13:37:08 GMT
Quick question, when i'm in c64 interactive (basic) mode, and i connect via UART, input freezes. any one else, and if so, anyone have a solution?
|
|
fusys
Creatures
Posts: 18
|
Post by fusys on Mar 4, 2020 16:58:06 GMT
You mean with my software on in general anytime you connect via UART?
|
|