Brief Introduction to Embedded Systems with FPGA and Linux

FPGA Card + H Bridge with motors
Developing the electronics and software for a CNC machine with DC servo motors
The embedded systems, are highly integrated systems.
They usually are fisically very small and with a very reduced consume of energy.
With the entrance in the market of the FPGA's. the embedded systems can be reduced even more, and we can talk about SoC (system on chip).
In other words, all the integrant parts of a computer system as the processor, the memory, and the peripherals, fit in a single chip.
FPGA's are blank chips,they can be programmed and develop the electronic circuit we desire. These circuits can be described with special languajes as VHDL and Verilog.
The system that I'm going to talk in this articles, consists in a card with a FPGA Spartan3 and memory.
Its goal will be the control of a CNC machine with 3 DC motors, and it will be comprised of a microprocessed system that will control 3 PWM's outputs, 3 optical encoders inputs and other purpose auxiliary inputs and outputs, to support the final race sensors, buttons, etc...
es,etc..
To reach these goals we will develop supporting integrated circuits, so this system will behave in a very faster way than a ultimate PC could ever do with software.
Finally, in the software part, we will put the operating system ucLinux to the integrated processor, so the programs that will control the CNC will be almost the same as the developed in the desktop PC's.
The ucLinux operating system is a kernel derivated from Linux but modified to function in processors that lack MMU (memory management unit), we can say that all the process will share the memory, so if one program is bad engineered, it can crash all the system. Fortunately Linux is caracterized by its stability and ucLinux shows very robust.
To complete our system we must acomplish some goals:
Hardware
I will create multiple circuits to this fpga, these will be:
The card also must have some DDR memory for the use of the processor, and some flash memory to configure the fpga and store the uclinux kernel and programs.
Software
Advanced configurations
Special needings, response times.
Linux is not engineered to control events in real time, it's engineered to be very efficient doing a lot of tasks at the same time, and to be good in this, having to answer in real time to certain events can have a very negative impact in the general speed of the system.
In the embedded world, the goals are very different, sometimes we need that the system reacts in a very short and deterministic frame of time.
The linux kernel 2.6 has enhanced a lot these aspects, but when a hard realtime is needed, the better approach is patch the linux kernel with the rtai or rtlinux code.
These make that the true brain of the system is a microkernel prepared for realtime tasks, and linux becomes a normal process without true priorities
In this way we can code a realtime process that controls one hardware interruption, and the rest of tipical tasks of linux, as the networking, devices, etc..are executed with a lower priority
Uclinux Bootlog, booting the card with a Microblaze softprocessor
On node 0 totalpages: 8192
zone(0): 8192 pages.
zone(1): 0 pages.
zone(2): 0 pages.
CPU: MICROBLAZE
Kernel command line: mtdparts=physmap_auto:256K(boot),256K(bootenv),256K(config), 4M(image),11M(spare) macaddr=00:0a:35:00:22:01
Console: xmbserial on UARTLite
Calibrating delay loop... 32.97 BogoMIPS
Memory: 32MB = 32MB total
Memory: 29692KB available (624K code, 2090K data, 36K init)
Dentry cache hash table entries: 4096 (order: 3, 32768 bytes)
Inode cache hash table entries: 2048 (order: 2, 16384 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 8192 (order: 3, 32768 bytes)
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Microblaze UARTlite serial driver version 1.00
ttyS0 at 0x40600000 (irq = 2) is a Microblaze UARTlite
Starting kswapd
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
physmap_auto flash device: 1000000 at 21000000
physmap_auto probing buswidth 1
cfi_cmdset_0001: Erase suspend on write enabled
0: offset=0x0,size=0x20000,blocks=128
Using buffer write method
physmap_auto: Using Command Line partition definition
Creating 5 MTD partitions on "Physically mapped flash":
0x00000000-0x00040000 : "boot"
0x00040000-0x00080000 : "bootenv"
0x00080000-0x000c0000 : "config"
0x000c0000-0x004c0000 : "image"
0x004c0000-0x00fc0000 : "spare"
uclinux[mtd]: RAM probe address=0x220d3a3c size=0x1d3000
uclinux[mtd]: root filesystem index=6
MicroBlaze auto-config flash probe(0x21000000,8388608,4): 800000 at 21000000
CFI: Found no Flash device at location zero
Search for id:(1818 00) interleave(2) type(2)
Search for id:(1818 00) interleave(2) type(2)
Search for id:(1818 00) interleave(2) type(2)
Search for id:(18 18) interleave(2) type(1)
Search for id:(18 18) interleave(2) type(1)
Search for id:(18 18) interleave(2) type(1)
Search for id:(1818 00) interleave(4) type(2)
Search for id:(1818 00) interleave(4) type(2)
Search for id:(1818 00) interleave(4) type(2)
Search for id:(18 00) interleave(4) type(1)
Search for id:(18 00) interleave(4) type(1)
Search for id:(18 00) interleave(4) type(1)
JEDEC: Found no Flash device at location zero
MicroBlaze auto-config ram probe(0x220d3a3c,1912832,4): 1d3000 at 220d3a3c
Creating 1 MTD partitions on "RAM":
0x00000000-0x001d3000 : "Romfs"
VFS: Mounted root (cramfs filesystem) readonly.
Freeing init memory: 36K
Mounting proc:
Mounting var:
Populating /var:
Running local start scripts.
Mounting /etc/config:
Populating /etc/config:
flatfsd: invalid header magic
flatfsd: Nonexistent or bad flatfs (-183), creating new one...
flatfsd: Wrote 232 bytes to flash in 2 seconds
flatfsd: Created 4 configuration files (124 bytes)
Setting hostname:
Embedded login: root
Password:
# ls
bin dev etc home lib mnt proc sbin tmp usr var
#
Links:
Empresas de FPGA
Linux in microblaze
Free Cores


Intersted in this project
Hi Euge,
I am very interested in your CNC project with FPGA,would you please
send me more information.
My email: shczm1@gmail.com
Regards
John