Closed livingxdead closed 4 years ago
I think I remember mapping all of those pins by looking at the schematic and then confirming the pins by using the command line interface to the sys GPIO driver.
Could we get some assistance on this? I've unsuccessful wasted a few days trying to configure it for the NanoPi Duo 2. What was the mapping table for the NanoPi Duo 2? I'd just like to eliminate this as my possible issue.
You need to look at this diagram and map the GPIO names (e.g. PA11) to the AllWinner H3 GPIO groupings (e.g. A group + 11). Look at my existing AllWinner pin maps for how to do this. I don't have this hardware, so I cannot do testing, but this is how I mapped the other boards that I do own.
Thanks fo the prompt response. I've looked at the pinmaps for the existing boards and although they seem to make sense I just cant figure it out entirely. In what direction do we enter the pins? Why are there extra numbers in the pin maps? Can you provide an example of what you think the pin map for the NanoPi Duo 2 should be and we'll test it?
I really can't work on this right now. Each pin map has 42 entries (0 is invalid), so that pins 1-40 are the equivalent of an RPI header and the 42nd entry is for an on-board button (if present). The value of -1 is used for pins that are not available as GPIO (e.g. GND).
@bitbank2
Is this normal?
spi_lcd.c
// Use one of the following 4 methods for talking to the SPI/GPIO
//#define USE_PIGPIO
//#define USE_BCM2835
//#define USE_WIRINGPI
#define USE_GENERIC
// For generic SPI access (kernel drivers), select the board pinout (only one)
//#define USE_NANOPI2
//#define USE_NANOPIK2
//#define USE_NANOPIDUO
#define USE_NANOPIDUO2
//#define USE_NANOPINEO
//define USE_NANOPIM1
//#define USE_RPI
//#define USE_ORANGEPIZERO
//#define USE_ORANGEPIONE
//#define USE_BANANAPIM2ZERO
//#define USE_BANANAPIM2MAGIC
//#define USE_NANOPINEOCORE
//#define USE_ORANGEPIZEROPLUS2
#ifdef USE_NANOPIDUO2
static int iGenericPins[] = {-1,5,-1,4,-1,-1,-1,11,363,12,203,13,-1,14,-1,16,-1,15,-1,199,-1,198,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
#endif // USE_NANOPIDUO2
main.c
#define LCD LCD_ST7789
int width=240, height=240;
rc = spilcdInit(LCD, 0, 1, 24000000, 198, 199, 203); // LCD type, flip 180, SPI Channel, D/C, RST, LED
make_sample
CFLAGS=-c -Wall -O2
LIBS= -lspi_lcd -lpthread -lm
#LIBS= -lspi_lcd -lpigpio -lpthread -lm
#LIBS= -lspi_lcd -lwiringPi -lm -lpthread
#LIBS= -lspi_lcd -lbcm2835 -lm
all: lcd
lcd: make_sample main.o
$(CC) main.o $(LIBS) -o lcd
main.o: main.c
$(CC) $(CFLAGS) main.c
clean:
rm *.o lcd
Some of the 240x240 ST7789 displays (the ones without an exposed CS line) use SPI_MODE3 instead of SPI_MODE0. Please give that a try. The SPI master device has no way of knowing if a LCD is working since it's only transmitting data and not receiving any status info. This is why it thinks that it's successfully drawing rectangles.
Edit /boot/armbianEnv.txt and add these lines at the end
overlays=uart1 i2c0 spi-spidev spi-add-cs1
param_spidev_spi_bus=1
@bitbank2
spi_lcd.c
int rc, iSPIMode = SPI_MODE_3; // | SPI_NO_CS;
My ST7789V module has CS pin
I know this is closed, but I'm working with the ST7789 as well and also doing so on nanopiduo2. There aren't a lot of walkthroughs out there for this board and these screens. Most of the issues I had were solved, except for a few. I'm just curious what pins on the screen correspond to the gpio pins on the nanopiduo2.
I did my best, but many of these screens have completely different headers and they don't always match the nanopiduo2. For example, dc is not present and I understand that it is supposed to be data command, but again, not clear what to do on that front. My apologies for bumping this when closed. I'll try your code and see if it helps.
You should be able to use any GPIO pins for CS, DC (also called RS), RESET and the backlight. The CLK/MOSI need to be connected to the proper hardware SPI output of your CPU, but the other signals are just toggled in software.
Hey! (I'm in the right repo this time haha) Great work on this by the way.
I am trying to get this working on a NanoPi Duo2 but I cant seem to get them right, I looked at your mapping table in the spi_lcd.c file, chose NanoPi Duo2 as that has the same GPIO Pin out.
Any help where to map the final 2 pins of DC/X and Reset would be most helpful.
Thanks in advance.