Skip to content
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

Implement Wokwi testing #325

Open
martinberlin opened this issue Jun 18, 2024 · 12 comments
Open

Implement Wokwi testing #325

martinberlin opened this issue Jun 18, 2024 · 12 comments
Assignees
Labels
on hold waiting for something to be completed simulation/CI Enter the simulation

Comments

@martinberlin
Copy link
Collaborator

martinberlin commented Jun 18, 2024

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

  • PCA9535 , I2C 16 bit IO expander, manages eink slow signals
  • TPS65185, also talks I2C, generates the needed voltages to drive the pixels (+15 and -15V) plus to open the FET gates that let pass whose (higher ones + VCOM)

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:

  • Red: Fast signals
  • Orange: Slow signals
  • Blue: Data in pins

@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"

@martinberlin martinberlin added the simulation/CI Enter the simulation label Jun 18, 2024
@martinberlin martinberlin self-assigned this Jun 18, 2024
@mickeprag
Copy link
Contributor

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

@martinberlin
Copy link
Collaborator Author

martinberlin commented Jun 19, 2024

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
Copy link
Contributor

Maybe because IO8 is internally connected to the flash?

@martinberlin
Copy link
Collaborator Author

martinberlin commented Jun 20, 2024

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 wokwi/wokwi-features#809

@martinberlin martinberlin added the on hold waiting for something to be completed label Jun 21, 2024
@martinberlin
Copy link
Collaborator Author

martinberlin commented Jun 24, 2024

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
Copy link
Collaborator Author

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 added a commit that referenced this issue Jun 25, 2024
@martinberlin
Copy link
Collaborator Author

martinberlin commented Jun 26, 2024

@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.

@martinberlin
Copy link
Collaborator Author

Advancing very slowly here. In the next days I'm adding the wokwi-tps65185 custom chip.
What it will do really is just to receive the signal to power up the grid and just turn hi a GPIO. It won't really generate any voltages since wokwi does not know anything about volts ;)

@vroland
Copy link
Owner

vroland commented Aug 5, 2024

No problem, things are slow during the summer ;) Curious where this goes.

@martinberlin
Copy link
Collaborator Author

martinberlin commented Aug 17, 2024

Finished to add new chip:
https://wokwi.com/projects/401153784260252673

Chip itself is in this repository: https://github.com/martinberlin/wokwi-tps65185/
This is just a small wrapper to "emulate" a reply with PWR_GOOD signal since Wokwi does not know about voltages for Eink 🔌
Let's see if I can test it in the next days. Would be cool if someone helps to verify if all connections / signals match the schematic.

UPDATE:
Today I finish writing a full epdiy example with chips and what-not included, but the compiling time is a bit long. Second glass of wine and still building...
Wokwi compiling...

@vroland
Copy link
Owner

vroland commented Aug 26, 2024

Sounds promising! Did it compile in the end?

@martinberlin
Copy link
Collaborator Author

No. There must be something in my tps65185 chip that does not like. But I must say that at this point is a bit weird because it can take forever, instead of prompting some kind of useful error message.
My first thoughts where "Ok this is great to make simple simulations" but when going deeper then unexpected things happen, without proper guidance to the developer trying to implement it. Hopefully I'm wrong and it just deserves some more rounds of fight. But I guess you understand what I'm trying to say.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on hold waiting for something to be completed simulation/CI Enter the simulation
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants