keirf / flashfloppy-osd

On Screen Display and keyboard controller for FlashFloppy
The Unlicense
57 stars 15 forks source link

Usage of FlashFloppy-OSD in MSX2 computers #48

Closed Wierzbowsky closed 1 year ago

Wierzbowsky commented 1 year ago

First of all - this is an awesome project and I see quite a few use cases for it in the MSX world. In some cases Goteks have to be put in places where they are not visible, so this project comes in very handy! I will start from the slim Gotek and Al-Alamiah AX-350 MSX2 computer and continue with the normal size Gotek and Yamaha YIS-503III converted to MSX2+.

Are there any concerns that I should note when connecting STM32 board to MSX computer? I am going to connect it first to a computer with v9938 and then to the computer with v9959 VDP chips. Both of them have CSYNC and RGB outputs. I presume that it should work like on Amigas - without extra tweaking, but you never know.

Also, it is possible to get 3 outputs from the STM32 board so that all 3 color signals (R+G+B) could be patched and the OSD would be white? In some cases having monochrome output based on one color component would not work.

Connecting to MSX computer's keyboards could be problematic, but technically possible. @keirf could you please check the keyboard connection on this schematics and tell whether it's possible to patch into the keyboard to use SHIFT, CTRL and arrow key combinations? https://sysadminmosaic.ru/_media/msx/yamaha_yis-805-128r2/yis805.pdf

keirf commented 1 year ago

You should be able to hook into msx no problem. To connect to all of rgb you might want to hook the stm rgb output via three tristate buffers and hook each of those to your rgb lines. OSD can be configured to control tristate buffer output enable.

Keyboard will be hard. It is amiga specific and uses the fact amiga keyboard is smart and uses a serial protocol. Msx seems to have an 8 bit style keyboard where matrix scanning is done by main host cpu.

Wierzbowsky commented 1 year ago

Thanks, I will try it later this week. I am a bit familiar with Arduino, so why to use a 3-state buffer when one can configure 2 other outputs of the "Blue Pill" board to do the same as B15 does? Then we have 3 lines doing the same thing and each one can be connected to its own color channel.

keirf commented 1 year ago

Timing is tight and not enough spare timers.

Wierzbowsky commented 1 year ago

I've got my STM boards, but they appear to be STM32F103C6T6A, not STM32F103C8T6. Connected everything, flashed the latest OSD firmware, but nothing works. Will the current FF OSD firmware work on these C6 boards? I presume C6 is a slightly different chip...

Also, would it be possible to activate the green led on the STM board by the firmware when it OSD is on? This could help in debugging...

keirf commented 1 year ago

C6 has less Flash and SRAM. Actually I think it could work except the flash config is saved beyond the end of C6 flash capacity. Maybe a one line change would help...

keirf commented 1 year ago

Give this version a go (random version number change so you can track which version you've flashed).

FF_OSD-v1.33.zip

Try to connect over serial or using a rotary encoder as described in the wiki to enter configuration mode. This will display OSD box even if your I2C connection to Gotek isn't working yet.

Wierzbowsky commented 1 year ago

Thanks. But still no image via MSX's RGB. I connected the board to PC via serial IO and got this output:

image

Is the OSD output enabled by default?

keirf commented 1 year ago

Should be. Press space over serial to enter config and see what happens.

Wierzbowsky commented 1 year ago

It shows config entries every time I send "Space", but I can't change anything. And eventually the device stops responding. I connected the B15 via 220 Ohm resistor (could not find 270) to the R input of the video module (see the schematics). The A8 is connected to the SYNC IN input of the video module.

keirf commented 1 year ago

Does it show the config entries on the OSD though?

Wierzbowsky commented 1 year ago

Nope, the screen remains empty (no OSD)

keirf commented 1 year ago

You will probably need to put a scope on the pill output pin to look for signs of life, and take it from there. I think on serial you should see logging when csync is locked on, so absence of that may mean some csync issue.

Wierzbowsky commented 1 year ago

I will do that. What should be the amplitude of the acceptable CSYNC? Now I connect it to the input of the video module, where it is already at TTL levels.

Wierzbowsky commented 1 year ago

Tried to play around with settings. When I select something else for "Display Enable", the red color disappears from the video. Other changes make no effect on the picture. OSD still not visible. But looks like the Flash config works.

When I connect SYNC (A8) directly to the v9938 VDP's CSYNC pin, the video disappears. Serial output says "Sync lost".

When I connect SYNC (A8) to composite video output from the video module, I get "Sync found" once, but then comes "Sync lost". Maybe MSX has somewhat weird CSYNC signal that the firmware can't tune to.

image

keirf commented 1 year ago

Maybe but that would be surprising. What is the horizontal frequency of the msx output?

Wierzbowsky commented 1 year ago

15.7kHz, vertical can be 50 or 60Hz depending on model. I ordered C8 board.

keirf commented 1 year ago

Apologies, I forgot that C6 has only three timer peripherals compared with four on the C8 chip. OSD uses all four timers so it definitely cannot work with C6.

Wierzbowsky commented 1 year ago

No problem, the C8 board is on the way. I will update you when I test with it.

Wierzbowsky commented 1 year ago

I've got the C8 chip, it appears to have 128kb flash, unlike the one shown in this video. This should not be a problem though. Flashing v1.9 firmware worked fine. The firmware reported "corrupted settings" on startup until I saved the configuration via the serial interface.

image image

When I connect the SYNC/A8 to the LS04 chip that brings the CSYNC to TTL levels, there comes the message "sync found" and there's no sync loss until I disconnect the wire. But the OSD still doesn't work. B15 is connected to the RED input signal pin of the video module via the 220 Ohm resistor. The serial interface reports:

image

Are the settings correct?

Btw, there's no "sync found" message on the board's power-up or reset, it shows only when I disconnect and connect the SYNC wire. Probably it would be good to report the sync finding on startup.

P.S. The "sync found" is shown in both 50Hz and 60Hz mode.

P.S.S. When I enable "Display Enable: PA15 Act.LOW" or "Display Enable: PA15 Act.HIGH", the red color disappears from the video feed. When I select "Display Enable: None", the voltage on B15 is 2.6v (normal for the red color), but when I enable Act.HIGH or Act.LOW, the voltage drops to 0.1v (no wonder the red signal is dead). So, something bad happens with the output.

P.S.S.S. Looks like the default setting is "Display Enable: None", so after the first power-up, when the config is set to defaults, there will be no OSD enabled. Maybe on settings corruption the default ones should be restored and saved to the flash chip automatically. And maybe "None" is not the best option to have by default.

Wierzbowsky commented 1 year ago

I've made a few experiments with Gotek + Blue Pill STM board and monitored them with the oscilloscope. The CSYNC signal that is fed to STM board via A8 looks like this:

image image

The RED signal that is connected to B15 without the output from STM board looks like this:

image

There's no activity on B6/B7 - I2C bus when the STM board is connected to Gotek. When I connect the OLED display to Gotek, the screen works and there's expected activity on B6/B7. Should the screen be connected in parallel for the STM board to work? Maybe the STM board doesn't work with I2C bus when it is directly connected?

The jumper A0/A1 is installed. The pull-up 4.7k resistors are installed. Gotek's firmware is v3.34. The setup looks like this:

image

keirf commented 1 year ago

Do you have any cached display-type= setting in the Gotek FF.CFG?

Wierzbowsky commented 1 year ago

Do you have any cached display-type= setting in the Gotek FF.CFG?

This is my FF.CFG, works on all my modded MSXs with Gotek.

FF.zip

keirf commented 1 year ago

I can't read it, I'm afk this week. Does it have a display-type line?

Wierzbowsky commented 1 year ago

I changed the display-type to "auto" and now there's activity on I2C bus. SCK is 100kHz, SDA is alive too. But still no output on B15.

Wierzbowsky commented 1 year ago

The output on B15 while the wire is disconnected looks like this:

image

It can't affect the color signal at all, is it even supposed to look like that?

keirf commented 1 year ago

It's supposed to be tristate outside the box and then push-pull high-low with maybe a 3v swing inside the box. What does the display config look like as printed via serial?

Wierzbowsky commented 1 year ago

It's supposed to be tristate outside the box and then push-pull high-low with maybe a 3v swing inside the box. What does the display config look like as printed via serial?

image

keirf commented 1 year ago

Looks okay I think. Flash blinky on it from greaseweazle firmware repository and see what that says on serial

Wierzbowsky commented 1 year ago

Looks okay I think. Flash blinky on it from greaseweazle firmware repository and see what that says on serial

Sorry, I can't find a HEX file for blinky test. Where can I get it? Thanks.

keirf commented 1 year ago

Download latest release from greaseweazle-firmware repository. Unzip and look under hex/alt iirc

Wierzbowsky commented 1 year ago

Thanks. Found HEX (blinky-test-f1-1.2.hex), flashed it and... garbage on serial output on reset, LED doesn't blink. I am novice to this platform, so I may be doing something in a wrong way...

The same happens with C6 board. No blinking LED, garbled serial output on reset. I am using 115200 speed, 8 bit, even, stopbit1.

keirf commented 1 year ago

No blinking led is bad. No serial is weird. I may have broken the build slightly and it's not currently at 115200 baud. Actually I think that's likely. Try 3000000 baud (three million).

Wierzbowsky commented 1 year ago

image

The device came from a German supplier "AZ-Delivery" who sells on Amazon.de...

keirf commented 1 year ago

Fake and or broken. Actually skip the "or" there.

keirf commented 1 year ago

I can sell compatible at32f403 chip but you will need ability to swap chip over and make some resistor adjustments

Wierzbowsky commented 1 year ago

Could it be that the chip is different from what the program expects to see? In the above mentioned video I've seen the 64kb version of C8 working with OSD, but my chip is 128kb version. I doubt that the German company would sell a fake. I've bought Arduino from them a few times and they always worked.

It could be that this chip is CB, not C8. At least the output shows as 103xB

keirf commented 1 year ago

It's definitely a fake. Unsurprising since genuine simply isn't available. Not necessarily a problem as long as the fake works properly. Clearly this one doesnt

Wierzbowsky commented 1 year ago

Can the firmware be adjusted to run on clones/fakes? Since, as you said, "genuine simply isn't available"... Or maybe you can suggest an alternative board?

keirf commented 1 year ago

They can be broken in various ways. Life is too short.

Wierzbowsky commented 1 year ago

It's not about me wanting the OSD on MSX. I want to bring this project into the MSX community, but I can't do this when people can't get hold of the properly working boards. I could buy a chip and change the resistors - no problem. But this is not suitable for the community. Is there any workaround for this problem? Do you know any supplier of the working boards?

keirf commented 1 year ago

No the source of recent working versions have been using at32f403 either on custom boards (eg zaxxon amigotek osd) or swapped onto blue pill boards to replace bogus chips

keirf commented 1 year ago

I may be able to support other pill like boards if one type looks promising

Wierzbowsky commented 1 year ago

Black Pill? https://www.amazon.de/-/en/STM32F411-Development-STM32F411CEU6-MicroPython-Programming-black/dp/B09DPQN5VX/

Wierzbowsky commented 1 year ago

I still wonder whether anything could be done with those chips where I2C doesn't work well. I doubt that the I2C doesn't work in those chips, it probably works, but with some adjustments. Maybe lowering the bus' frequency or changing the protocol to take into account those known issues would be possible? You are a really good engineer, maybe you could find the solution?

keirf commented 1 year ago

I probably could but I'm not going to. How many of this particular fake are out there? How many other fake types might I have to support? What's the bang for buck for my efforts?

Supporting a completely different pill type I'd at least somewhat more compelling if they are coming with genuine chips or good fakes.

The current situation of needing to use (in practice) at32f403 chips is not ideal since they are hard for people to source except through me or gotek factory in larger quantity. And they need to be soldered.

Wierzbowsky commented 1 year ago

This is, of course, understandable. But as you can see, there's no good solution to use FF OSD in Goteks for now. According to your own statement, almost all available STM32 chips on the Chinese-made pill boards are fakes. And 98% of people won't be able to swap a fake STM32 chip with an Artery's themselves. So, unless you start selling the pill boards with the swapped chips yourself, we are out of options. At least until you choose to support a different, easily obtainable pill board. All the keys are in your hands now, so please help us.

Quite a few MSX systems have Goteks in side slots or mounted sideways, and as a result - the screen is not visible. So, the FF OSD is the best solution for those systems. From my part, I will encourage people to donate to you when FF OSD project will be available for MSX systems. I've already donated for the FF once and I will donate for FF OSD too.

keirf commented 1 year ago

Perhaps I should port to STM32F401 black pill board? These seem generally available for no more than a fake 103c8 blue pill.

Wierzbowsky commented 1 year ago

Received the replacement board from the German company. Blinker still fails.

image

Waiting for the C8 board from 4 different Chinese suppliers. Why would I2C fail on all these boards? They can't be all defective.

Wierzbowsky commented 1 year ago

Finally got 4 Blue Pill boards from China. Opened 3 of them. All of them pass the I2C tests, but all fail on Flash tests. One of them outputs ID, so FF OSD says that it's fake. But all can be programmed, FF OSD saves the config without a problem.

flash_fail1 flash_fail2

Those issues, however don't stop the boards from working. I finally managed to get a working OSD on MSX!

osd_msx

Now I need to identify the best way to locate Blue Pill inside Gotek (especially inside a slim one), best points to connect color signal and sync, as well as try to tune the OSD brightness by playing around with the resistor value on color channel's connection.

keirf commented 1 year ago

Good news. These chips probably have only 64kb Flash but that's all osd requires.