So, I check the documentation, spent few days thinking how to compile and finally… I realise that it’s using I2C instead? (SDA, SCL)
My display does not have any SDA, it has MOSI, MISO, SCK, SDO, etc, and of course it doesn’t work, as there’s no pin to connect SDA to.
I tried searching this on community forum, no luck, all of them are chinese and I don’t understand it a lot, translator doesn’t help much, and also neither of them are for Milk-V Duo S model, which I have, it has different pins and tutorials from forum doesn’t help with that.
Please, can anyone help me connect that SPI display to Milk-V Duo S? Even better if it’s in English.
Portpin needs to be pulled up.
Thanks for the help, but I don’t understand what is “portpin” and how do I pull it up? Sorry, I’m novice here
Portpin refers to MOSI, MISO, SCK, SDO, etc. You can set internally pulled up in device tree, or use external pulled up of 10k’s resistance.
Okay, but how do I connect display physically? Where do I connect DC/CS/RESET? And also question about how to use it in software? I understand I need to pullup, but that doesn’t give me any more information how to connect and run display.
There is only MOSI MISO SCK for data connections on the SPI bus, and then another pin labelled SS or CS for selecting a particular device if you have multiple displays connected in parallel on the SPI bus. The CS line is set low when communications starts, and high when it finishes. MOSI MISO SCK are on specific pins that must be enabled because the hardware is specifically wired to specific pins, and then choose a GPIO pin for CS and tell it which pin it is in software libraries that use SPI bus.
You can use any pin and simulate SPI bus interface by toggling bits manually using say Arduino library code and the Arduino capable distro. That way any pin will do to get it working, and then go for the hardware interface to speed it up.
Third option is to use ChatGPT or similar like Claude3 to get the answers and code written, but depending on your needs to learn details.
Okay, but what is DC pin for? And what about software part - What do I use to interact with display? I can’t use Arduino as Milk-V Duo S doesn’t support it at the moment (Issue #114 - No Arduino Support).
DC can use any pin and is set to 0 when sending commands to initialise the display controller registers, while DC = 1 to send SPI data as fast as possible to the display pixels.
May be you want to purchase a cheap duo to get things working?
There are Arduino drivers for the display - GitHub - cbm80amiga/Arduino_ST7789_Fast: Fast SPI library for the ST7789 IPS display
And duo can switch to Arduino mode - Introduction | Milk-V
The distro you want to run is then version 1.0.9 - the current latest does not have the arduino capability. So you go to Releases · milkv-duo/duo-buildroot-sdk · GitHub, scroll down to 1.0.9, and click on the assets button for 1.0.9 to expand the details and see link for arduino version 1.0.9 (https://github.com/milkv-duo/duo-buildroot-sdk/releases/download/Duo-V1.0.9/arduino-milkv-duo-v1.0.9-2024-0228.img.zip)
You can also convert the Arduino code to C code and compile it in a virtual machine using the guide GitHub - milkv-duo/duo-examples: Milk-V Duo official C/C++ examples.
I already have an Arduino Uno/Arduino Mega 2560/ESP32 and display is working with all of them perfectly.
I’m thinking about the last part - how can I convert Arduino code to C code? If I have working Arduino code, I can convert it and run on Milk-V Duo S, but how?
Arduino code is C/C++ - should be able to write an init function and main loop and copy the contents of Arduino code, taking care to name the pins correctly as its different in C. Then compile it, see which functions fail, and add them from the Arduino library for SPI until all of it converted to C. You may need to add in C libraries in places such as serial comms and SPI.
The alternative is to export the Arduino code from the Arduino IDE as elf file, and then run the elf file on second core. For the duo that is relatively easy with the duo 1.0.9 Arduino distro - see here How to compile v1.0.9 to get the arduino-milkv-duo-v1.0.9-2024-0228.img? . Don’t fully understand how to get the second core working on duoS or a distro like ArchLinux that hasn’t got it yet. Doing a buildroot diff check between Arduino branch and default branch shows too many differences, and at the moment I can’t find any documentation on how its done. Ideally a script or a patch that adds Arduino functionality needed to stop having to hunt for solutions. Or merge the two ‘wasteful’ develop and Arduino branches and use a compile switch to add or remove the Arduino functionality.
Second is a great idea, thanks, but to export elf file, you need to specify a board in Arduino IDE, but Milk-V Duo S in not supported right now.