Hi,
Is there any way to set GPIO state before system boot on Omega2? I need low level on hardware PWM output (unfortunately it is high while boot and it complicates my peripherals). I mean configuration file, kernel module etc.
Posts made by Krzysztof Skiba
-
Setting GPIO pin state earliest as possible during boot
-
RE: Will an official KiCAD library and footprint be released for the Omega2S?
Here you are, unofficial (my own project) but usable Kicad library, footprint and 3D shape:
Onion_Omega_2.7z -
RE: How to install gcc compiler
I have not encountered the installation of compiler C on the Onion Omega 2. On the other hand, the cross-compiler LEDE works great. I'm using it with rsync to upload compiled programs to Omega.
My sample Makefile:
CC=mipsel-openwrt-linux-musl-gcc
CFLAGS=-Os -lpthread
LFLAGS=-Os -lpthread
IP=192.168.3.1
PASSWORD=onioneer
SOURCES = main.c GPIO/gpio.h GPIO/gpio.c PAMIEC/pamiec.h PAMIEC/pamiec.c LCD/lcd.h LCD/lcd.c PWM/pwm.h PWM/pwm.c
OBJECTS = main.o gpio.o pamiec.o lcd.o pwm.o
all: kolumnaonionkolumnaonion: $(OBJECTS)
$(CC) $(LFLAGS) $(OBJECTS) -o kolumnaonion
sshpass -p "$(PASSWORD)" rsync -v -a kolumnaonion root@$(IP):/rootmain.o: $(SOURCES)
$(CC) $(CFLAGS) -c $(SOURCES)clean:
rm -f kolumnaonion *.o -
RE: How To Send a command from Omega2+ to another via Network
Hi,
You can use ssh to run command on another Omega.
Example:
sshpass -p "PASSWORD" root@REMOTE_IP COMMANDPASSWORD - default is onioneer
REMOTE_IP - remote device address
COMMAND - app/script etc. to run on remote device (you can use parameters to enable/disable relay) -
RE: [Omega2] Hardware PWM problem
I did this:
PWM0_SEND_DATA0 <- 0xAAAAAAAA (1010101010101....)
PWM0_SEND_DATA1 <- 0xAAAAAAAA (1010101010101....)Clock 100kHz/2 - 50kHz
And for 1% duty (for example):
PWM0_HDURATION <- 500
PWM0_LDURATION <- 50000-PWM0_HDURATIONIt works. I have exactly 10ms step regulation.
My rectification column power regulator is much closer Thanx! -
RE: [Omega2] Hardware PWM problem
Thanks for fast reply.
The problem was "send data register" for pattern. I didn't wrote any value to this register. I have 1Hz signal on GPIO18 pin but I still don't know how to increase resolution of signal regulation. I have 1/64s (for 64 bits pattern) - it is 15,625ms. I need 10ms resolution for AC 50Hz group power regulation. I'll try to do it by regulating high and low signal duration. -
[Omega2] Hardware PWM problem
Hi everyone.
I have some problem with hardware PWM on Omega2. I'm trying to start PWM using registers.
The problem is - no signal on GPIO18 pin. I'm trying to get 1Hz signal.
Here is my code:#ifndef _FCNTL_H
#include <fcntl.h>
#endif#ifndef _STDIO_H
#include <stdio.h>
#endif#ifndef _ERRNO_H
#include <errno.h>
#endif#ifndef _STDINT_H
#include <stdint.h>
#endif#ifndef _STDLIB_H
#include <stdlib.h>
#endif#ifndef _SYS_MMAN_H
#include <sys/mman.h>
#endif#ifndef _UNISTD_H
#include <unistd.h>
#endif// Registers base
#define REGISTER_BASE 0x10000000u// GPIO1_MODE register offset
#define GPIO1_MODE 0x60u
#define PWM_ENABLE 0x5000u
#define PWM0_CON 0x5010u// GPIO18 output setting bits
#define PWM0_MODE0 28
#define PWM0_MODE1 29// PWM0 enable bit
#define PWM0_EN 0// Clock select bit
#define CLKSEL 3#define OLD_PWM_MODE 15
// High level period register offset
#define PWM0_HDURATION 0x5014u// Low level period register offset
#define PWM0_LDURATION 0x5018u// PWM Enable status register offset
#define PWM_EN_STATUS 0x520Cu// Logic levels
#define LOW 0
#define HIGH 1// Registers map pointer
volatile uint32_t *uiBaseAddress;// Set or clear bit in register
void vSetBitInRegister(uint16_t offset,uint8_t bit, uint8_t wartosc)
{
if (wartosc==0)
{
*(uiBaseAddress+(offset/4))&=~(1<<bit);
}
else
{
*(uiBaseAddress+(offset/4))|=(1<<bit);
}
}// Display register
void vViewRegister(uint16_t offset, char *sRegisterName)
{
// Zrzut rejestru
int i = 0;
printf("\n%s register view:\n",sRegisterName);
for (i=31; i>=0; i--)
{
printf("+---");
}
printf("+\n");
for (i=31; i>=0; i--)
{
printf("|%02u ",i+1);
}
printf("|\n");
for (i=31; i>=0; i--)
{
printf("+---");
}
printf("\n");
for (i=31; i>=0; i--)
{if ((*(uiBaseAddress+(offset/4)))&(1<<i)) printf("| 1 "); else printf("| 0 "); } printf("|\n"); for (i=31; i>=0; i--) { printf("+---"); } printf("+\n");
}
int main(int argc, char* argv[])
{
// Memory map descriptor
int iMap;// Opening device /dev/mem for mapping and exit when it fails if ((iMap = open ("/dev/mem", O_RDWR | O_SYNC) ) < 0) { printf("OPEN Error"); return EXIT_FAILURE; } // Mapping MT7688 registers uiBaseAddress = (uint32_t *) mmap(0, 65536, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, iMap, REGISTER_BASE); // Close device descriptor close(iMap); // Exit when map fails if (uiBaseAddress == MAP_FAILED) { printf("MMAP Error"); return EXIT_FAILURE; } // Display GPIO1_MODE register before operation vViewRegister(GPIO1_MODE,"GPIO1_MODE"); // Setting GPIO18 as PWM0 output vSetBitInRegister(GPIO1_MODE,PWM0_MODE0,LOW); vSetBitInRegister(GPIO1_MODE,PWM0_MODE1,LOW); // Display GPIO1_MODE register after opreation vViewRegister(0x60,"GPIO1_MODE"); vViewRegister(PWM_ENABLE,"PWM_ENABLE"); vSetBitInRegister(PWM_ENABLE,PWM0_EN,HIGH); // Enable PWM0 vViewRegister(PWM_ENABLE,"PWM_ENABLE"); vViewRegister(PWM0_CON,"PWM0_CON"); vSetBitInRegister(PWM0_CON,CLKSEL,LOW); // 100kHz clock vSetBitInRegister(PWM0_CON,OLD_PWM_MODE,LOW); // Old PWM Mode vViewRegister(PWM0_CON,"PWM0_CON"); vViewRegister(PWM0_HDURATION,"PWM0_HDURATION"); *(uiBaseAddress+PWM0_HDURATION/4) = 0xC351; // 0,5s high level duration vViewRegister(PWM0_HDURATION,"PWM0_HDURATION"); vViewRegister(PWM0_LDURATION,"PWM0_LDURATION"); *(uiBaseAddress+PWM0_LDURATION/4) = 0xC351; // 0,5s high level duration vViewRegister(PWM0_LDURATION,"PWM0_LDURATION"); // Display PWM Enable status register vViewRegister(PWM_EN_STATUS,"PWM_EN_STATUS"); return EXIT_SUCCESS;
}
-
RE: [Onion Omega2] Direct GPIO register access problem
@Krzysztof-Skiba said in [Onion Omega2] Direct GPIO register access problem:
x10000600
I found in Mediatek MT7688 Datasheet page 109:
https://labs.mediatek.com/en/download/50WkbgbH"Module name: GPIO Base address: (+10000600h)"
Edit: Got it! Seems that datasheet info is incorrect.
Thanks for help!
-
RE: Omega 2 - distance between 2 pins
Here you are my own project - DIY Onion Omega2 adapter:
https://drive.google.com/open?id=0B9u5fY-fTaLrTWZNZVN4SS1DY0k -
[Onion Omega2] Direct GPIO register access problem
Hello everyone.
I have some problems with my Onion. I'm trying to access device registers via mmap function. I've successfully map PWM registers (address: 0x10005000). I can write and read from these registers.
But when I try to change address to 0x10000600 (GPIO access registers) with the same code I can read, but write fails with message Segmentation fault.
I tried to unload all GPIO modules with no effect.
Here is my code (without headers):int main(int argc, char *argv[])
{uint32_t alloc_mem_size, page_mask, page_size; volatile uint32_t *mem_pointer, *virt_addr; const uint32_t mem_address = 0x10000600; const uint32_t mem_size = 0x600; page_size = 4096; alloc_mem_size = (((mem_size / page_size) + 1) * page_size); page_mask = (page_size - 1); int mem_dev = open("/dev/mem", O_RDWR | O_SYNC); mem_pointer = mmap(NULL, alloc_mem_size, PROT_READ | PROT_WRITE, MAP_SHARED, mem_dev, (mem_address & ~page_mask) ); virt_addr = (mem_pointer + (mem_address & page_mask)); int i=0; close(mem_dev); printf("Memory dump before\n"); for(i=0; i<10;i=i+2) { printf("GPIO memory address=0x%016x: 0x%016x\n", virt_addr+i, *(virt_addr+i)); } // Set GPIO_0 direction bit (*(virt_addr))|=(1<<0); printf("Memory dump after\n"); for(i=0; i<10;i=i+2) { printf("GPIO memory address=0x%016x: 0x%016x\n", virt_addr+i, *(virt_addr+i)); }
}
Help please