2020年4月21日星期二

install ModelSim on Arch linux

My Arch linux is 64-bit, ModelSim only have 32-bit version.

First of all, do what the following blog says.
https://gist.github.com/dries007/36c31fb8b2d712dfb41c6709f16e6e66

ModelSim 17.1 (Starters Edition) for (Arch) Linux

You need to download the setup file yourself. Put in where you run the setup script. Easy DL link It should be named ModelSimSetup-17.1.0.590-linux.run.
  1. Install dependencies (some AUR, both 32 and 64 bit is required.)
    • 64 bit: expat fontconfig freetype2 xorg-fonts-type1 glibc gtk2 libcanberra libpng libpng12 libice libsm util-linux ncurses tcl tcllib zlib libx11 libxau libxdmcp libxext libxft libxrender libxt libxtst
    • 32 bit lib32-expat lib32-fontconfig lib32-freetype2 lib32-glibc lib32-gtk2 lib32-libcanberra lib32-libpng lib32-libpng12 lib32-libice lib32-libsm lib32-util-linux lib32-ncurses lib32-zlib lib32-libx11 lib32-libxau lib32-libxdmcp lib32-libxext lib32-libxft lib32-libxrender lib32-libxt lib32-libxtst
    • ncurses compat libs: ncurses5-compat-libs and lib32-ncurses5-compat-libs
  2. Run setup file, from console, install in default location (~/intelFPGA/17.1) The setup hangs after completing.
  3. Get lib32-freetype2-2.5.0.1 and unpack libs to ~/intelFPGA/17.1/modelsim_ase/lib32
  4. Modify the startup script (~/intelFPGA/17.1/modelsim_ase/vco)
    • Replace linux_rh60 with linux
    • Add LD_LIBRARY_PATH=${dir}/lib32 after $dir is set
A semi automatic script is provided below for the lazy :)


-----the script------
#/bin/bash

echo Installing dependencies...
pacaur -S --needed expat fontconfig freetype2 xorg-fonts-type1 glibc gtk2 libcanberra libpng libpng12 libice libsm util-linux ncurses tcl tcllib zlib libx11 libxau libxdmcp libxext libxft libxrender libxt libxtst lib32-expat lib32-fontconfig lib32-freetype2 lib32-glibc lib32-gtk2 lib32-libcanberra lib32-libpng lib32-libpng12 lib32-libice lib32-libsm lib32-util-linux lib32-ncurses lib32-zlib lib32-libx11 lib32-libxau lib32-libxdmcp lib32-libxext lib32-libxft lib32-libxrender lib32-libxt lib32-libxtst ncurses5-compat-libs lib32-ncurses5-compat-libs

echo Running setup file...
./ModelSimSetup-17.1.0.590-linux.run --modelsim_edition modelsim_ase --accept_eula 1 --mode unattended --unattendedmodeui minimal &
PID=$!
echo Press enter when the setup dialog says \"Setup complete.\"
read -n 1
kill $PID

wget -q --show-progress https://dl.dries007.net/lib32-freetype2-2.5.0.1.tar.xz -O lib32-freetype2-2.5.0.1.tar.xz
tar xf lib32-freetype2-2.5.0.1.tar.xz -C ~/intelFPGA/17.1/modelsim_ase/

cd ~/intelFPGA/17.1/modelsim_ase/
sed -i 's/linux_rh60/linux/' vco
sed -i 's/dir=`dirname "$arg0"`/dir=`dirname "$arg0"`\nexport LD_LIBRARY_PATH=${dir}\/lib32/' vco # adds "export LD_LIBRARY_PATH=${dir}/lib32" after $dir is found.
cat > ~/.local/share/applications/modelsim.desktop <<EOF
[Desktop Entry]
Version=1.0
Name=ModelSim
Comment=ModelSim
Exec=$HOME/intelFPGA/17.1/modelsim_ase/bin/vsim
Icon=applications-electronics
Terminal=true
Type=Application
Categories=Development
EOF

echo "Done, enjoy!"

------------------------------------------------------------------------------------------

To install 32bit lib:

sudo vim /etc/pacman.conf

uncomment multilib:

# If you want to run 32 bit applications on your x86_64 system,
# enable the multilib repositories as required here.

multilib-testing]
Include = /etc/pacman.d/mirrorlist

[multilib]
Include = /etc/pacman.d/mirrorlist


then 
$sudo pacman -Sy
$sudo pacman -Syy


You may have conflict files when installing lib32-gtk2. Skipping it is fine.


-------------------------------------------------------------------------------------

When trying to run vsim, this may show up.

[uty@u bin]$ ./vsim 
./../linux/vish: symbol lookup error: /usr/lib32/libfontconfig.so.1: undefined symbol: FT_Done_MM_Var


it means that the version of libfontconfig is too new, it doesn't have FT_Done_MM_Var anymore.
What I installed is :

[uty@u bin]$ pacman -Q lib32-fontconfig
lib32-fontconfig 2:2.13.91+24+g75eadca-2

I didn't find the released binary. 

So do this.

https://j-marjanovic.io/new-ubuntu-old-problems-with-modelsim.html

$ git clone https://gitlab.freedesktop.org/fontconfig/fontconfig.git
$ git checkout -b 2.12.92 2.12.92
$ sudo pacman -S lib32-libxml2

$ aclocal -I m4
$ autoconf
$ libtoolize
$ ./autogen.sh
$ CFLAGS=-m32 LDFLAGS=-L/home/jan/local/packages/freetype-2.4.7-32bit/lib ./configure --prefix=/home/jan/local/packages/fontconfig-2.12.92-32bit --enable-libxml2
$ make
$ make install

Basically, compile it from source code, taking branch 2.12.92.

copy the generated binary to /usr/lib32
[uty@u fontconfig]$ sudo cp src/.libs/libfontconfig.so.1.11.0 /usr/lib32/

[uty@u fontconfig]$ ls /usr/lib32/libfont* -l
lrwxrwxrwx 1 root root     34 Apr 21 15:59 /usr/lib32/libfontconfig.so -> /usr/lib32/libfontconfig.so.1.11.0
lrwxrwxrwx 1 root root     34 Apr 21 15:58 /usr/lib32/libfontconfig.so.1 -> /usr/lib32/libfontconfig.so.1.11.0
-rwxr-xr-x 1 root root 342952 Apr 21 15:55 /usr/lib32/libfontconfig.so.1.11.0
-rwxr-xr-x 1 root root 342952 Apr 21 15:53 /usr/lib32/libfontconfig.so.1.12.0

then create the symbolic link
[uty@u fontconfig]$ sudo ln -sfn /usr/lib32/libfontconfig.so.1.11.0 /usr/lib32/libfontconfig.so


Finally, I can run it.

2020年4月17日星期五

increase dmesg buffer

set log_buf_len in kernel parameters

u@raspberrypi:~ $ cat /boot/cmdline.txt
console=ttyS0,115200 log_buf_len=8M root=PARTUUID=738a4d67-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

hex to bin

$xxd -r -p input.txt output.bin
u@raspberrypi:~ $ cat tmp.txt | head -n 16
00 F0 3E B8 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
41 EA 00 03 13 43 9B 07 30 B5 10 D1 0C 68 03 68 
63 40 13 60 4C 68 43 68 63 40 53 60 8C 68 83 68 
63 40 93 60 C9 68 C3 68 4B 40 D3 60 30 BD 00 23 
CD 5C C4 5C 6C 40 D4 54 01 33 10 2B F8 D1 30 BD 
2D E9 F0 4F 8F B0 01 24 0E AD 07 46 0E 46 91 46 
11 46 0D F1 19 00 0D 22 05 F8 20 4D 05 93 DD F8 
68 B0 DD F8 6C 80 9B F0 C9 FE 8D F8 27 40 00 23 
19 9C 38 46 8D F8 26 30 31 46 08 3C 2A 46 23 46 
CD F8 00 B0 CD F8 04 80 00 F0 BE FA 38 BB 0B EB 
04 03 08 EB 04 0A 8D F8 26 00 31 46 8D F8 27 00 
2A 46 8D E8 08 04 38 46 08 23 00 F0 AD FA B0 B9 
18 9B 38 46 8D E8 18 01 0A AC 31 46 4A 46 05 9B 
03 94 00 F0 5F F8 50 B9 20 46 51 46 08 22 9B F0 
8D FE 00 28 14 BF 4F F0 FF 30 00 20 01 E0 4F F0 
u@raspberrypi:~ $ xxd -r -p tmp.txt bcm43455.rom
u@raspberrypi:~ $ hexdump -C bcm43455.rom | head -n 16
00000000  00 f0 3e b8 00 00 00 00  00 00 00 00 00 00 00 00  |..>.............|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  41 ea 00 03 13 43 9b 07  30 b5 10 d1 0c 68 03 68  |A....C..0....h.h|
00000030  63 40 13 60 4c 68 43 68  63 40 53 60 8c 68 83 68  |c@.`LhChc@S`.h.h|
00000040  63 40 93 60 c9 68 c3 68  4b 40 d3 60 30 bd 00 23  |c@.`.h.hK@.`0..#|
00000050  cd 5c c4 5c 6c 40 d4 54  01 33 10 2b f8 d1 30 bd  |.\.\l@.T.3.+..0.|
00000060  2d e9 f0 4f 8f b0 01 24  0e ad 07 46 0e 46 91 46  |-..O...$...F.F.F|
00000070  11 46 0d f1 19 00 0d 22  05 f8 20 4d 05 93 dd f8  |.F.....".. M....|
00000080  68 b0 dd f8 6c 80 9b f0  c9 fe 8d f8 27 40 00 23  |h...l.......'@.#|
00000090  19 9c 38 46 8d f8 26 30  31 46 08 3c 2a 46 23 46  |..8F..&01F.<*F#F|
000000a0  cd f8 00 b0 cd f8 04 80  00 f0 be fa 38 bb 0b eb  |............8...|
000000b0  04 03 08 eb 04 0a 8d f8  26 00 31 46 8d f8 27 00  |........&.1F..'.|
000000c0  2a 46 8d e8 08 04 38 46  08 23 00 f0 ad fa b0 b9  |*F....8F.#......|
000000d0  18 9b 38 46 8d e8 18 01  0a ac 31 46 4a 46 05 9b  |..8F......1FJF..|
000000e0  03 94 00 f0 5f f8 50 b9  20 46 51 46 08 22 9b f0  |...._.P. FQF."..|
000000f0  8d fe 00 28 14 bf 4f f0  ff 30 00 20 01 e0 4f f0  |...(..O..0. ..O.|

2020年4月11日星期六

highlight function names in c code

" Highlight all function names
syntax match cCustomFunc /\w\+\s*(/me=e-1,he=e-1
highlight def link cCustomFunc Function
To use this, put it in ~/.vim/after/syntax/c/highlight_functions.vim. (All files in ~/.vim/after/syntax/[filetype]/ will be sourced when vim opens a file of type [filetype].)

2020年4月10日星期五

install raspbian without monitor

Different from ubuntu, there is no default serial console.

Need to connect raspberry to the network through the ethernet cable.

https://hackernoon.com/raspberry-pi-headless-install-462ccabd75d0

SSH is also not enabled by default.  Need to put a file "ssh" into the boot partition of the SD card.

After reboot

Search subnet.
$ nmap -p 22 192.168.3.1/24

user: pi
pass: raspberry

Next is to enable wifi.

Something called rfkill is in the way.

u@raspberrypi:~ $ sudo rfkill list all
0: phy0: Wireless LAN
Soft blocked: yes
Hard blocked: no
1: hci0: Bluetooth
Soft blocked: no
Hard blocked: no
u@raspberrypi:~ $ sudo rfkill unblock wifi
u@raspberrypi:~ $ sudo rfkill list all
0: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no
1: hci0: Bluetooth
Soft blocked: no
Hard blocked: no
u@raspberrypi:~ $ sudo ifconfig wlan0 up


The rest is the same.

Remember to enable SSH,  that ssh file only good for one time.

2020年4月8日星期三

ubuntu server 18.04 setup wifi

u@ubuntu:~$ ifconfig wlan0 up

u@ubuntu:~$ wpa_passphrase wifiname password | sudo tee /etc/wpa_supplicant.conf

u@ubuntu:~$ sudo wpa_supplicant -B -c /etc/wpa_supplicant.conf -i wlan0

// get ip
u@ubuntu:~$ sudo dhclient wlan0



//test
u@ubuntu:~$ ping 8.8.8.8



make it auto connect wifi.

raspberry pi 4 won't bring up wlan0 on boot.

$ sudo apt-get ifupdown

$ sudo vim /etc/rc.local


edit /etc/rc.local

u@ubuntu:~$ cat /etc/rc.local
ifup wlan0


edit /etc/network/interfacs

u@ubuntu:~$ cat /etc/network/interfaces
# ifupdown has been replaced by netplan(5) on this system.  See
# /etc/netplan for current configuration.
# To re-enable ifupdown on this system, you can run:
#    sudo apt install ifupdown

auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant.conf