zedboard lab 6 led and driver - university of michigantimtu/site/share/zedboard_lab6_cdma_br… ·...
TRANSCRIPT
![Page 2: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/2.jpg)
Features of design
• Data transmission using HP (High performance) channel.
• CDMA (Central Direct Memory Access) in charge of moving data.
– Driver
– Interrupt handling
• BRAM (Block RAM) control
![Page 3: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/3.jpg)
System Architecture
ARM DDR
GP0
AXI Interconnect1
PS(Processing System)
PL(Programmable Logic)
AXI4-LiteM_AXI
S_AXI
HP0mem
0x00000000 0x1F0000000x1C000000
HP0
AXI Interconnect0
CDMA
BRAMController0
BRAMController1
BRAM
0x500000000x60000000
PortAPortB
0x40000000
AXI4
![Page 4: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/4.jpg)
Enable the AXI GP 0 channel.
![Page 5: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/5.jpg)
Check on the M_AXI_GP0 box.
![Page 6: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/6.jpg)
Click on HP0 and enable it.
![Page 7: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/7.jpg)
Click on Enable S_AXI_HP0 interface.
And set the address to be 0x1C000000 to 0x1FFFFFF
(This is DDR address from 448MB to 512MB)
![Page 8: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/8.jpg)
Add an AXI Central DMA design.
And two AXI BRAM Controller.
(Note: this will create two BRAM automatically, delete one).
Sometimes you need to add BRAM yourself.
![Page 9: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/9.jpg)
CDMA setting:
Set the Data Width to 1024
and Burst Length to 256
![Page 10: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/10.jpg)
Assign 0x40000000 – 0x4000ffff to CDMA
![Page 11: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/11.jpg)
BRAM controller 0 setting:
Set the address from 0x50000000 to 0x5000FFFF (64KB for the BRAM)
Change to Data Width to 64
Click the Slave Single Port BRAM
![Page 12: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/12.jpg)
BRAM controller 1 setting:
Set the address from 0x60000000 to 0x6000FFFF
(Note: The address is different from the previous)
Change to Data Width to 64
Click the Slave Single Port BRAM
![Page 13: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/13.jpg)
Create two AXI interconnect
![Page 14: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/14.jpg)
Connect the design like this.
![Page 15: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/15.jpg)
Connect clock and reset signals.
![Page 16: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/16.jpg)
Click on Clock Generation.
![Page 17: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/17.jpg)
Modify FCLK_CLK2 to be 85MHz
This is the clock we connect to BRAM controller and CDMA.
We need to modify the clock or there will be time violation.
![Page 18: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/18.jpg)
Now we have to set the interrupt.
![Page 19: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/19.jpg)
Move axi_cdma_0 to the other side.
![Page 20: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/20.jpg)
Next
• Export to SDK
– Create BOOT.BIN
– Create devicetree.dtb and make the modification. Also to prevent the kernel from using HP0 memory we should modify bootargs.
• Driver
– Interrupts
– Mutex (Mutual exclusion)
– Linux kernel wait queue
– Kernel/User memory, copy_from_user, copy_to_user
• Java user application.
![Page 21: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/21.jpg)
Interrupts
• Polling v.s Interrupts
– Polling: CPUs keep checking if something need to be handled.
– Interrupt: Devices inform CPU.
• CDMA interrupt
– OS recognized by
IRQ number
– But in OS, this should
be IRQ_number + 32
![Page 22: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/22.jpg)
cdma_probe()
irq handler
![Page 23: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/23.jpg)
Mutex
• Why do we need mutex?
– Under environment of multithread.
– Prevent more than one thread to access resource.
– mutex v.s semaphore
• Easy concepts
– Lock mutex -> execute critical section -> unlock mutex
![Page 24: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/24.jpg)
cdma_write()
![Page 25: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/25.jpg)
Linux Kernel wait queue
• We need to stop the process and wait for CDMA ( or other devices) to complete their works.
• A while loop is not a good idea.
– Occupying CPU resource
• Linux Kernel wait queue is designed to solve this situation.
– Process go to sleep and release CPU resources to other processes.
![Page 26: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/26.jpg)
cdma_write()
go to sleep
wake up and continue
![Page 27: ZedBoard Lab 6 LED and driver - University of Michigantimtu/site/share/zedboard_lab6_cdma_br… · ZedBoard Lab 6 LED and driver Chun-Chen Tu timtu@umich.edu. Features of design •Data](https://reader033.vdocument.in/reader033/viewer/2022052721/5f0b08e87e708231d42e874a/html5/thumbnails/27.jpg)
copy_from_user, copy_to_user
• Why do we need this?
– User space memory is fragmented to pages.
– For security reason.
http://www.ibm.com/developerworks/library/l-kernel-memory-access/