Skip to content

no issue - question about composite video #9

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

Open
BobSleigh38 opened this issue Dec 12, 2023 · 14 comments
Open

no issue - question about composite video #9

BobSleigh38 opened this issue Dec 12, 2023 · 14 comments

Comments

@BobSleigh38
Copy link

Hello and thank you for sharing your work
I understand that your code for composite video is between bitluni library (esp32lib) and ESP_8_BIT library
Your demo for the clock works fine for me on a car dvd player screen
However I have no image when I use any of bitluni code.
Did you have the same issue than me ? How did you solve it ? Does it have something to do with bad syncing (PLL/APLL) ?
I really enjoy the clock :)

@marciot
Copy link
Owner

marciot commented Dec 12, 2023

Bitluni's video generation code and the one in ESP_8_BIT are very different. They both worked on the monitors I tried, but the code in ESP_8_BIT seemed superior and was more capable. I do not understand either code well enough to say why that might be.

You didn't mention why you you were looking to use Bitluni's code, but if you simply want to run his demos, I made a fork of his code and demos which have been adapted to use the video generator backend from ESP_8_BIT:

https://github.com/marciot/ESP32CompositeColorVideo

You may have better luck with that one.

@BobSleigh38
Copy link
Author

Thank you for your answer.
I have no idea why Bitluni's code is not working.
I actually don't need to stick to Bitluni's library but he made an incredible work on documenting his library, for example on his youtube channel, and it's nice to know how the library work instead of just adding the headers and calling the functions.
I'm also exploring the Fabgl library which work for me
I'm trying to have both graphics and music / sound on an esp32.

@M0NWY
Copy link
Contributor

M0NWY commented Jan 9, 2024

This took me like 3 evenings of swearing to figure out, but you need to downgrade your esp32 tool chain to the one the code was originally written for. Bitluni's code works fine for me on esp32 v1.0.1. and Arduino IDE 2.2.1(Latest).

@BobSleigh38
Copy link
Author

Hello M0NWY and thank you so much for sharing your solution.
However I never compiled bitluni's examples with Expressif toolchain but with Arduino IDE
Which version of toolchain worked for you ?

@M0NWY
Copy link
Contributor

M0NWY commented Jan 10, 2024 via email

@BobSleigh38
Copy link
Author

Hello M0NWY,
I downgraded "esp32 by espressif systems" in arduino manager from 2.0.14 to 1.0.1 as you said.
It works !!! (see photo attached)
Tested with arduino ide 2.2.1 too
Something happened between 2.0.0 (working) and 2.0.1 (not working) they are around 80 commits between the two versions.
Maybe it's possible to locate the exact code change that make this bug happens in espdif github repository but I don't know how to do this investigation as I upgrade/downgrade boards in arduino IDE.
WhatsApp Image 2024-01-25 at 20 02 26

@marciot
Copy link
Owner

marciot commented Jan 25, 2024

@BobSleigh38: Can you provide a link to the two commits you mentioned?

I have a hunch the problem has something to do with the initialization of the APLL hardware. If I can see what changed between the two commits, maybe I can see if anything might have affected the way the APLL hardware is initialized.

@BobSleigh38
Copy link
Author

Hi Marciot !
I don't use commits.
I go to arduino IDE->tools->board->board manager
From there I go to "esp32 by espressif systems" then I downgrade to 2.0.0 (working version) or 2.0.1 (not working version)
Now I'm trying to identify more precisely the changes that made the code not working anymore with git tool and the repository https://github.com/espressif/arduino-esp32
It's not an easy task ....
Hope it helps, and sorry for posting about Bitluni's project on your project repository but this is where I got answers :) !

@BobSleigh38
Copy link
Author

The guilty commit is here : espressif/arduino-esp32@00214d5
But they are so many modifications in this commit (1475 files)
I'm lost !

@marciot
Copy link
Owner

marciot commented Jan 26, 2024

Ah, so I searched that repo for "rtc_clk_apll_enable", which is the function I suspect might have changed, and I did not find it. It looks like the "espressif/arduino-esp32" is just the code that links the Arduino IDE to the underlying espressif code. That code we care about is this other repo:

https://github.com/espressif/esp-idf

So, now the challenge is to figure out which versions of the esp-idf introduced the change. I appears as if the arduino-esp32 repo has commits such as this one which indicate when the underlying IDF is changed:

espressif/arduino-esp32#8943

So with this, it should theoretically be possible to cross reference to the other repo.

@marciot
Copy link
Owner

marciot commented Jan 26, 2024

Okay, so here are my finding based on the information you provided:

Date arduino-esp32 esp-idf Notes
Nov 22, 2021 espressif/arduino-esp32@a5002c8 Mentions IDF release/v4.4 ddc44956bf
Nov 4, 2021 espressif/arduino-esp32@418ac74 Mentions IDF release/v4.4 6a7d83af19
Oct 25, 2021 https://github.com/espressif/arduino-esp32/releases/tag/2.0.1-RC1 Arduino Release
Oct 24, 2021 espressif/arduino-esp32#5801 Mentions v4.4-dev-3544-g2720d45e71
Oct 13, 2021 espressif/arduino-esp32@34c81be espressif/esp-idf@b86fe0c
Oct 1, 2021 espressif/arduino-esp32@00214d5 espressif/esp-idf@3e370c4 Commit @BobSleigh38 identified
Aug 31, 2021 https://github.com/espressif/arduino-esp32/releases/tag/2.0.0 Arduino-ESP Release Mentions v4.4-dev-2313-gc69f0ec32
Jul 26, 2021 espressif/arduino-esp32@6972695 espressif/esp-idf@c69f0ec

@marciot
Copy link
Owner

marciot commented Jan 26, 2024

So, where I am at. I suspect the code in espressif/esp-idf@c69f0ec from July 26, 2021 is the last working code, which was included in arduino-esp32 2.0.0 which was released on August 31, 2021.

However, it is unclear which version of the esp-idf code is used in the October 25, 2021 release of 2.0.1 RC, as the last reference to the esp-idf repository occurs on October 13, 2021. From that point on, I cannot find valid identifiers I can cross-reference between the two repos.

@marciot
Copy link
Owner

marciot commented Jan 26, 2024

So I am falling down a rabbit hole here. Here is what I don't understand. In the video code, there is a function call that configures the timers. It looks like this:

case 3: rtc_clk_apll_enable(1,0x46,0x97,0x4,2); break; // 10.7386363636 3x NTSC (10.7386398315mhz)

Notice it takes five arguments. When I search the esp-idf repo for that function, I get a much shorter version which does not have the extra arguments:

https://github.com/search?q=repo%3Aespressif%2Fesp-idf%20rtc_clk_apll_enable&type=code

I cannot locate the five argument code in the esp-idf repo, which suggests maybe it isn't the correct code.

If I randomly Google for "rtc_clk_apll_enable", I get what appears to be a fork of esp-idf that does appears to have a "rtc_clk_apll_enable" with the correct number of arguments:

https://github.com/chunhuajiang/esp-idf-zh/blob/6d673f4fa2b9335dcb9df48179bbccf3fafdc290/components/soc/esp32/rtc_clk.c#L152

So I am wondering whether at some point, those extra arguments were removed from esp-idf. Could this possibly be the reason things broke?

I wonder whether it would be possible to take the function out of chunhuajiang's repo and see if using that to initialize the APLL hardware instead of the current function would solve the problem.

@BobSleigh38
Copy link
Author

Thank you so much much for your investigation !!
I will try the code in rtc_clk.c
What did partially work for me is the code from FabGL. I can see the image from bitluni demo (simple composite) on the screen, but the image is not still, it's scrolling very quickly vertically. I managed to get a still image at a moment, but I'm not able to reproduce this again. It's hard to understand the code.
I grabbed the lines from here :
https://github.com/fdivitto/FabGL/blob/master/src/devdrivers/cvbsgenerator.cpp
I2S0.conf.tx_reset = 1;
I2S0.conf.tx_reset = 0;
I2S0.lc_conf.in_rst = 1;
I2S0.lc_conf.in_rst = 0;
...
...
...

I did add those lines in bitluni's simple composite demo, right before the hack to get the 13MHz I2S frequency.
https://github.com/bitluni/ESP32CompositeVideo/blob/master/CompositeVideoSimple/CompositeOutput.h
//this is the hack that enables the highest sampling rate possible ~13MHz, have fun
SET_PERI_REG_BITS(I2S_CLKM_CONF_REG(0), I2S_CLKM_DIV_A_V, 1, I2S_CLKM_DIV_A_S);

Right now I'm using FabGL, but it's using a huge library only for the video part, it takes ages (and memory?) to compile.
That's why I'd be happy to switch back to bare minimal code.

I'm coding a pinball game, based on fantastic 1ko js demo from this guy
https://frankforce.com/lu1ky-pinball-code-deep-dive/
I'm modifying the code so that it's optimized for esp32 (pre-calculation of normals in RLE bitmaps, like old dos games )
https://gamedev.stackexchange.com/questions/43705/2d-collision-detection-for-pinball-game/43719

Thank you again :)

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

3 participants