I have a software project that is to use an A20-OLinuXino-MICRO-4GB board. I have no control of which board to use, so suggestions about alternates are not helpful.
That has an Allwinner A20 dual core Cortex-A7 processor (armv7a).
I tried doing the work from linux, but even with maximum priority, PTHREAD_EXPLICIT_SCHED and SCHED_FIFO, I could not prevent interrupts of a time critical section of control code (need to process every 10 microseconds, but got 40 microsecond gaps about 40 times a second).
With above constraint, suggestions to access SPI and UART from linux are not helpful either. The timing constraints on the second thread (whole cpu core being dedicated to it), mean that regular linux is not currently a viable alternative. Maybe a full real time linux would do the job, but I do not have the resources to get that built, just to see if it might work.
Current development environment:
Gentoo 4.3.3-hardened-r4
crossdev --kernel =3.18 --libc =2.21-r2 --binutils =2.24-r3 --gcc =4.8.5
Building u-boot does not currently work with 5.x versions of gcc, so not too much room to move there.
So moved to writing as standalone code that is to be started from u-boot. No extra delays there, but now I am missing something to configure other modules of the core. When I try to initialize and configure SPI or UART devices (other than UART0, which is used for the u-boot console), all registers report zero, and stay there even after setting them. It acts as if there is nothing (no hardware) there. UART0 has reasonable/expected values, and configuring standard GPIO pins (input and output) works fine. Configuring the multiplexed GPIO pins to be used by SPI or UART also appear to work, but the modules stubbornly refuse to admit they exist.
Sample code, Makefile, and output for attempting to talk to the SPI modules can be found in the olimex forum. Note that the sample uses include files from the build of u-boot The main documentation used to create that code is A20 User Manual.
Has anyone worked with A20, Cortex-A7, armv7a or similar chips, and figured out how to get access to the capabilities outside of linux?
Does someone know where to get some better documentation about programming at that level?
The user manual I have has lots of information about register addresses, offsets, bit masks, but nothing in the way of code examples. I expect that a simple standalone C (or even assembler) example, that configured any of the (device) modules, and setup an interrupt to handle it, would be so helpful in figuring out the rest.
I actually got the SPI communications to work by bit-banging the I/O pins. That is not going to work for the UART, and SPI looks like a simpler case to work on first.
I've been programming for a lot of years on big systems, and some on very small (6502, 8085, arduinio) systems, but no real experience with development in this kind of environment. I'm not a kernel programmer, or anything close.
EDIT: I added the SPI1 Clock setup into the sample code, but all of the SPI register still show as all zeros, before and after setting them. The code changes:
#include <asm/arch-sunxi/clock_sun4i.h>
struct sunxi_ccm_reg * clockRegister;
#define SPI_SCLK_GATING_CLKON 0x80000000
#define SPI_CLK_SRC_OSC24M 0x00000000
#define SPI_CLK_DIV_RATION_8 0x00030000
// ...
printf ("SPI1 clk cfg %08x\n", clockRegister->spi1_clk_cfg);
clockRegister->spi1_clk_cfg =
SPI_SCLK_GATING_CLKON | SPI_CLK_SRC_OSC24M | SPI_CLK_DIV_RATION_8 | 15;
printf ("SPI1 clk cfg %08x\n", clockRegister->spi1_clk_cfg);
That shows that the clock configuration DID change from 0x00000000 to 0x8003000f