vroland / epdiy

EPDiy is a driver board for affordable e-Paper (or E-ink) displays.
https://vroland.github.io/epdiy-hardware/
GNU Lesser General Public License v3.0
1.25k stars 178 forks source link

Implement Wokwi testing #325

Open martinberlin opened 1 week ago

martinberlin commented 1 week ago

Wokwi is a simulator. The idea is that we could be able to simulate a v7 board, including it's main two chips:

First step is to simulate this two as "Custom chips" and attach them to an ESP32S3-DEV board. Then we will simulate the existing v7 board attaching this 2 chips in the I2C line and some LEDs as data output.

If everything turns out as expected, this will simulate that the voltages are on (wokwi does not know about voltages), and we should see how the framebuffer signals are outputted on the data LEDs. I propose to use different colors:

@mickeprag if you are interested on this also you can help out in any way. This will take many iterations. The end result would be to truly simulate a v7 board, adding an SVG drawing, and the custom chips inside. All this should run picking up the Firmware built from VSCode. At that point it will look and behave as a real board and the idea is that we could try to put this also in the Github CI, so apart of running the tests, it will also try to run the generated Firmware in our "virtual board"

mickeprag commented 1 week ago

This sounds cool. I am on. Although I have almost zero experience from wokwi...

martinberlin commented 1 week ago

This sounds cool. I am on. Although I have almost zero experience from wokwi...

Thanks for your interest. Same here. I'm still figuring out the very basics. For example here I don't have any idea why IO8 does not turn HIGH. Note I'm lazy to put a resistor to each LED but is not that for sure! UPDATE: Fixed. The thing is that the pin labels is a bit confusing. But now is working: https://wokwi.com/projects/401153784260252673

mickeprag commented 1 week ago

Maybe because IO8 is internally connected to the flash?

martinberlin commented 1 week ago

Ok it was me that I was connecting the wrong pins. The problem with most computer related thing is ourselves except on some rare moments ;) https://wokwi.com/projects/401153784260252673 -> And next blocker is... that I can't seem to tell the Simulator that the MCU has external RAM. Why I don't know, I'm adding the attribute:

{ "type": "board-esp32-s3-devkitc-1", "id": "esp", "top": -0.18, "left": -5.03, 
    "attrs": { "psramSize": "8", "flashSize": "4" }

blocker is now an Issue pending to be resolved https://github.com/wokwi/wokwi-features/issues/809

martinberlin commented 6 days ago

Blocker solved thanks to a hint of Wokwi team:

{
    "type": "board-esp32-s3-devkitc-1",
    "id": "esp",
    "top": -0.18,
    "left": -5.03,
    "attrs": {
        "psramSize": "16",
        "flashSize": "4"
    }
}

@vroland and @mickeprag PSRAM is detected now. What remains is to make the 2 mentioned custom chips otherwise the firmware will hang without being able to communicate with the IO expander or the TI Power mic. As an inspiration and demo source here is a demo using PCF8575 an IO expander that is very similar of v7 PCA9535 and we could use as a base (Not exactly the same but can work adapting it) From TI forum:

The PCF8575 and PCF8575C are not as closely related to these aforementioned two parts. There are multiple feature differences, most notably that the the PCF devices do not implement configuration registers. Also, the TCA9539 and TCA9539-Q1 have reset pin functionality while the PCFs do not.

Started to add this here experimentally: https://wokwi.com/projects/401153784260252673

martinberlin commented 5 days ago

Implemented first time custom chip and it seems the CI action works however I still fail to link it on VSCode diagram.json https://github.com/martinberlin/wokwi-pca9535

martinberlin commented 4 days ago

@vroland I will need the behaviour of "simulated chip" PCA9535 to be reviewed. What I'm getting in the VSCode console only placing this chip with the pins connected as in v7 Schematic is this:

[chip-pca9535] Input mask is now 0xc007
[chip-pca9535] Input mask is now 0x3
[chip-pca9535] Input mask is now 0x2103
[chip-pca9535] Input mask is now 0x2903
[chip-pca9535] Input mask is now 0x3903
[chip-pca9535] Read: reset INT flag

Custom chips are not really easy to use. The fastest way that I've found is to make a repository, add some CI, so it get's compiled (output is Web assembly or WASM), and that's how it's loaded into Wokwi. It's a bit of black magic for me, a bit hard to understand, the internals of how all this works together. Hence I need a bit of a review and some help making custom chip TPS65185. On that topic if I understand that right:

To simulate the power Mic I just need to hear on 0x68 address. And when it get's the TPS_REG_ENABLE I2C signal activates the voltages, pulling TPS_PWR_GOOD low. Is that correct?

Test of IO expander custom chip seems to work but left part looks like a Christmas tree and I've no idea why.