2021年3月14日星期日

Install driver in Xilinx Vivado

sudo /tools/Xilinx/Vivado/2020.2/data/xicom/cable_drivers/lin64/install_script/install_drivers

login again to apply the setting



2021年3月10日星期三

HLS Important Notes

Vivado CLI execute Tcl script

vivado_hls -f script.tcl


Vivado CLI interactive mode

vivado_hls -i [-l <logfile>]


if not specific the clock uncertainty, default value is 12.5% 


Tcl script example

## Tcl script example from Xilinx Introduction to High-Level Snthesis

open_project my.prj

set_top dct

add_files dct.cpp

add_files -tb dct_test.cpp

add_files -tb in.dat

add_files -tb out.golden.dat

open_solution "solution1"

set_part {xc7k160tfbg848-1}

create_clock -period 10


source "./my.prj/solution1/directives.tcl"

csynth_design

 

Unsupported C Language Constructs

system call (e.g. printf, system, time...etc)

dynamic memory & functions (.e.g. malloc, new)

virtual function

pointer casting

recursive function

Most of STL library which contains recursive and dynamic allocation


Important Notes

Use APCC to compile the intN data type, gcc doesn't support this data type

Must be care if use access pointer with the same function multiple time

 

 

 



2021年3月8日星期一

High Level Synthesis by using Xilinx Vitis

// Analyze the Xilinx Vitis example
 
// C General include header file
#include <ap_cint.h>

// C typedefs for top-level input and output int / fixed-point formats
// [u]int<precision> (1024 bits) 
typedef int7 in_data_t;
typedef uint7 in_data_t;

// C++ General include header file
// ap_[u]int<W> (1024 bits)
// ap_[u]fixed<W,I,Q,O,N> 
#include <ap_int.h>
#include <ap_fixed.h>
#include <hls_stream.h>

// C++ typedefs for top-level input and output int / fixed-point formats
typedef ap_ufixed<IN_BW,IN_IW> in_data_t;
typedef ap_ufixed<OUT_BW,OUT_IW> out_data_t;
typedef ap_uint<IN_BW> data_t;

typedef ap_int<18> dout1_t;
typedef ap_uint<13> dout2_t;

typedef ap_ufixed<10,8, AP_RND, AP_SAT> din1_t;
typedef ap_fixed<36,30> dout_t;

hls::stream<uint8_t> &bytes_in,

// Support array
typedef ap_int<7> din_t;
typedef ap_int<10> dout_t;
dout_t mem_bottleneck_resolved(din_t mem[N]) {
}

2021年3月3日星期三

vscode with cscope

vscode plugin required: scope4code


Build database

Press F1, enter Cscope: Build database to start building


Hotkey

  • Ctrl Alt -    go back
  • Ctrl Shift +    go forward

 

Solve "Visual Studio Code is unable to watch for file changes in this large workspace" (error ENOSPC)# 

Before adjusting platform limits, make sure that potentially large folders, such as Python .venv, are added to the files.watcherExclude setting.

The limit can be increased to its maximum by editing /etc/sysctl.conf (except on Arch Linux, read below) and adding this line to the end of the file:

fs.inotify.max_user_watches=524288

The new value can then be loaded in by running sudo sysctl -p.

Quoted from"https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc"

2021年3月2日星期二

Test devmem in rpi2 by shell script

#!/bin/bash

#Test devmem (Toggle RED LED) in rpi2 by shell script

GPIO_BASE=$((0x3F200000))
LED_GPFSEL=4
LED_GPFBIT=21
LED_GPSET=8
LED_GPCLR=11
LED_GPIO_BIT=3

#addr=$(($GPIO_BASE + $LED_GPFSEL * 4))
#rvalue=$(devmem $(($addr)) 32)

addr=$(($GPIO_BASE + $LED_GPCLR * 4))
devmem $((addr)) 32 $((1 << $LED_GPIO_BIT))

sleep 5

addr=$(($GPIO_BASE + $LED_GPSET * 4))
devmem $((addr)) 32 $((1 << $LED_GPIO_BIT))

2021年3月1日星期一

List Device Tree in Linux (embedded system)

The device tree is located at

cd /proc/device-tree/

lrwxrwxrwx   device-tree -> /sys/firmware/devicetree/base


Install tree package to view the device tree hierarchy


further investigate the content

plain text file: cat (file)

hex file: hexdump -C (file)

Acts as client(WiFi STA) in OpenWRT, connect and download the package when luci haven't installed

Quick config device
wifi config

Enable wlan0
In /etc/config/wireless,
option disabled '0'

Turn on wlan0
wifi up

Turn off wlan0
wifi down

Scan AP
iw wlan0 scan

Connect to AP
In /etc/config/wireless,
config wifi-iface 'wifinet0'
option ssid 'my_ap'
option device 'radio0'
option mode 'sta'
option network 'my_wlan'
option key 'my_password'
option encryption 'psk2' #AP encryption mode

In /etc/config/network,
config interface 'my_wlan'
option proto 'dhcp'
service network restart

Add devmem in OpenWRT

make menuconfig

1) Select Global build settings

2) Select Kernel build options

3) Select [*] /dev/mem virtual device support

4) Return to main menu

5) select Base System

6) select <*> busybox

7) select <*>Customize busybox options

8) select Miscellaneous Utilities

9) select <*> devmem (2.5 kb)


Usage: devmem ADDRESS [WIDTH [VALUE]]

Read/write from physical address

    ADDRESS Address to act upon, for example 0x????????
    WIDTH   Width (8/16/...)
    VALUE   Data to be written, for example 0x????????


read 32bit register: devmem address

read 16bit register: devmem address 16

read 8bit register: devmem address 8

write 32bit register: devmem address 32 value

write 16bit register: devmem address 16 value

write 8bit register: devmem address 8 value


alias grep

alias grepc='grep --include=\*{h,c,cpp}'

alias grepdts='grep --include=\*{dts,dtsi}'

 

List board information in Linux

#!/bin/bash

RED='\033[0;31m'
NC='\033[0m'    # No Color

echo -e "${RED}====uanme====${NC}"
uname -a

for info in cpuinfo meminfo devices interrupts dma filesystems ioports
do
    echo -e "${RED}===='$info'=====${NC}"
    cat /proc/$info
done

echo -e "${RED}====lsmod====${NC}"
lsmod