Skip to content

changcs/notes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 

Repository files navigation

Changcs 的 Notes

一些個人的筆記。

測試引用一。

測試引用二, 粗體字測試,使用OK。 以後再更新。

changcs pic/author.jpg

在 Beaglebone Black上測試openocd

步驟如下

Clone openocd (正在試commit cb317eabf2d162365467aeb89b564828e5e6d6f3)

git clone git://git.code.sf.net/p/openocd/code openocd-code.git

Building openocd

  1. run ./bootstrap
  2. run ./configure --help
  3. run ./configure --enable-jlink
  4. run make

Hooking up the JTAG Adapter

  1. connect Jlink JTAG cable to DUT
  2. connect Jlink to PC with USB cable. You can use lsusb command to check.
  3. power on the target board.
  4. run openocd

cd tcl;

../src/openocd -f interface/jlink.cfg -f board/ti_beaglebone_black.cfg -c “init; halt”

Talk with the OpenOCD server using telnet

Test via telnet interface and use reg command to display registers

$ telnet 127.0.0.1 4444

Building U-Boot

若要進行 JTAG 除錯, 需要從 u-boot 關掉 watchdog timer 。 方法如下: 找出 ti_am335x_common.h 裏面 WATCHDOGdefine ,改為 undef

make am335x_boneblack_defconfig

ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make

製作 U-Boot 的 SD 啟動卡 方法一

劃分一個 vfat partition 在 2048 sector 處,長度 128MB。 並設定成 bootable partition 。

mkfs.vfat -F 32 -n boot /dev/sdX1

mount /dev/sdX1 /mnt

cp MLO u-boot.img /mnt

umount /mnt

製作 U-Boot 的 SD 啟動卡 方法二

這是 Arch Linux 建議的方法。

dd if=/dev/zero of=/dev/sdX bs=1M count=8

fdisk to create an empty partition table and a ext4 FS after 2048 sectors

dd if=MLO of=/dev/sdX count=1 seek=1 conv=notrunc bs=128k

dd if=u-boot.img of=/dev/sdX count=2 seek=1 conv=notrunc bs=384k

安裝 Arch Linux

參考 BeagleBone Black | Arch Linux ARM

  • 若要使用 JTAG debug linux kernel,要加上patch
  • 確定開啟 CONFIG_DEBUG_INFO
git clone git://github.com/beagleboard/linux.git

cd linux

git checkout 4.4

make V=1 distclean

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- V=1 bb.org_defconfig

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- V=1 zImage dtbs modules

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=/new/prefix modules_install

假設 TFTP server 的 IP 是 192.168.1.1。 把 arch/arm/boot/zImagearch/arm/boot/dts/am335x-boneblack.dtb 放到 TFTP directory 之後,接上網路線,用以下 u-boot 命令開機。

dhcp ${loadaddr} 192.168.1.1:zImage

tftpboot ${fdtaddr} 192.168.1.1:am335x-boneblack.dtb

setenv bootargs "console=ttyO0,115200n8 coherent_pool=1M root=/dev/mmcblk1p1 rw rootwait fixrtc"

bootz $loadaddr - $fdtaddr

Talk with the OpenOCD server using gdb

建議使用 emacsgud-gdb mode 。接下來可以使用 step , next , until 這些命令來除錯。 openwrtgdbstaging_dir/toolchain-arm_*_${libc}*/bin/*-gdb

要看目前的 call stack , 可以使用 info stack 或是 frame 命令。

$ arm-none-eabi-gdb --fullname vmlinux

(gdb) target extended-remote :3334

(gdb) hbreak start_kernel

(gdb) continue

u-boot> dhcp ${loadaddr} 192.168.1.1:zImage

u-boot> tftpboot ${fdtaddr} 192.168.1.1:am335x-boneblack.dtb

u-boot> setenv bootargs "console=ttyO0,115200n8 coherent_pool=1M root=/dev/mmcblk1p1 rw rootwait fixrtc"

u-boot> bootz $loadaddr - $fdtaddr

參考資料

Openwrt and Beaglebone Black

nc543 mentioned Official OpenWrt Support BeagleBone Black. When the menu appear, select Target System as TI OMAP3/4/AM33xx, Target Profile as TI AM335x BeagleBone Black.

Image Configuration

More details can be found here. Actions:

  1. run ./scripts/feeds update -a
  2. run ./scripts/feeds install -a
  3. run make menuconfig and set target
  4. run make defconfig to set default config for build system and device
  5. run make kernel_menuconfig (optional and check CONFIG_COLLECT_KERNEL_DEBUG=y)
  6. run make menuconfig and modify set of package
  7. run ./scripts/diffconfig.sh > diffconfig
  8. run make download
  9. run ./scripts/diffconfig.sh

Building Images

Note make printdb can show available make targets.

ionice -c 3 nice -n19 make V=sc

Writing the image to micro SD card

zcat bin/targets/omap/generic/openwrt-omap-ti_am335x-bone-black-ext4-sdcard.img.gz | sudo dd of=/dev/sdX bs=4096 conv=fsync

Boot Up Beaglebone Black

Plug the SD card into BeagleBone Black, then power on BeagleBone Black with the BOOT button (S2) pressed to boot from SD.

Some U-boot 2017.01 variables

Built-in:

bootcmd=if test ${boot_fit} -eq 1; then run update_to_fit;fi;run findfdt; run init_console; run envboot; run distro_bootcmd

init_console=if test $board_name = A335_ICE; then setenv console ttyO3,115200n8;else setenv console ttyO0,115200n8;fi;

importbootenv=echo Importing environment from mmc${mmcdev} ...; env import -t ${loadaddr} ${filesize}

envboot=mmc dev ${mmcdev}; if mmc rescan; then echo SD/MMC found on device ${mmcdev};if run loadbootscript; then run bootscript;else if run loadbootenv; then echo Loaded env from ${bootenvfile};run importbootenv;fi;if test -n $uenvcmd; then echo Running uenvcmd ...;run uenvcmd;fi;fi;fi;

loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenvfile}

board_name=A335BNLT

findfdt=if test $board_name = A335BONE; then setenv fdtfile am335x-bone.dtb; fi; if test $board_name = A335BNLT; then setenv fdtfile am335x-boneblack.dtb; fi; if test $board_name = BBG1; then setenv fdtfile am335x-bonegreen.dtb; fi; if test $board_name = A33515BB; then setenv fdtfile am335x-evm.dtb; fi; if test $board_name = A335X_SK; then setenv fdtfile am335x-evmsk.dtb; fi; if test $board_name = A335_ICE; then setenv fdtfile am335x-icev2.dtb; fi; if test $fdtfile = undefined; then echo WARNING: Could not determine device tree to use; fi;

loadaddr=0x82000000

fdtaddr=0x88000000

loadimage=load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfile}

uEnv.txt:

bootpart=0:1

bootdir=/

bootfile=zImage

fdtdir=/dtbs

uenvcmd=run loadfdt; run loadimage; run uenvbootargs ; bootz ${loadaddr} - ${fdtaddr}

loadfdt=load mmc ${bootpart} ${fdtaddr} ${fdtdir}/${fdtfile}

devtype=mmc

uenvbootargs=setenv bootargs console=${console} root=/dev/mmcblk0p2 rootwait

Manually Boot Up Beaglebone Black

Plug the SD card into BeagleBone Black, then power on BeagleBone Black with the BOOT button (S2) pressed to boot from SD.

load mmc 0:1 0x88000000 /dtbs/am335x-boneblack.dtb

load mmc 0:1 0x82000000 /zImage

setenv bootargs "console=ttyO0,115200n8 root=/dev/mmcblk0p2 rootwait"

bootz 0x82000000 - 0x88000000

ubus (OpenWrt micro bus architecture)

Openwrt Technical Reference link and git repository.

Working with Gentoo

AMD64 Installation Guide and X86 Installation Guide

Synchronization

emerge –sync # or

emerge-webrsync

emerge –ask –verbose –update –deep –with-bdeps=y –newuse @world # or

emerge -uDNav –with-bdeps=y @world

Create a user account

In the next example, a user call john is created:

root # useradd -m -G users john

Add user into groups

From Adding a user to a group - Gentoo Wiki

root # gpasswd -a larry wheel

Automatic kernel module loading

root # mkdir -p /etc/modules-load.d

root # nano -w /etc/modules-load.d/network.conf

package.provided trick

Browse Gentoo WiKi

Layman and overlay

  1. Install layman by

USE=”git” emerge -av app-portage/layman

layman -L

  1. git clone my gentoo-zh overlay into git-local by

git clone https://github.com/changcs/gentoo-zh.git gentoo-zh.git

  1. Apply temp gentoo-zh2 stash
  2. Add my gentoo-zh overlay

layman -o file:///home/changcs/git-local/gentoo-zh.git/repo.xml -f -a gentoo-zh2

Remap Alt and Ctrl in virtual console

  1. Set windowkeys=NO in /etc/conf.d/keymaps.
  2. Create personal.map.gz by revising /usr/share/keymaps/i386/qwerty/us.map.gz.
  3. Set keymap=personal in /etc/conf.d/keymaps.

Enable ssh root login

  1. Set PermitRootLogin to yes in /etc/ssh/sshd_config.

Enable X Forwarding Over SSH

From How to Enable X Forwarding Over SSH on Gentoo Server. Enable X11Forwarding in /etc/ssh/sshd_config

X11Forwarding yes /etc/init.d/sshd reload

How to make prompt with git branch in bash gentoo

  1. Reference How to make prompt with git branch in bash gentoo
emerge -av app-shells/bash-completion

find /usr -name git-prompt.sh.bz2

cp /usr/share/doc/git-1.8.5.5/git-prompt.sh.bz2 ~

bunzip2 git-prompt.sh.bz2

mv git-prompt.sh .git-prompt.sh

Paste into ~/.bashrc

# Bash completion
if [ -f /etc/bash_completion ]; then
  . /etc/bash_completion
fi

export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\[\033[01;33m\]$(__git_ps1)\[\033[01;34m\] \$\[\033[00m\] '
export GIT_PS1_SHOWDIRTYSTATE=1

source ~/.git-prompt.sh

lftp not support sftp can be fixed by emerging gnutls lib

URL will be provided later.

Disk Quotas

Browse Disk Quotas

LVM setup

emerge -av sys-fs/lvm2

cat sys-fs/lvm2 lvm2create_initrd readline > /etc/portage/package.use/lvm2

pvdisplay

# cfdisk to create a dos extended partition at/dev/sdd6

pvcreate /dev/sdd6

vgcreate home_vg /dev/sdd6

vgdisplay

lvcreate -l 100%FREE -n home home_vg

ls -l /dev/home_vg
home -> ../dm-2

mkfs.ext4 /dev/home_vg/home

mount -t ext4 /dev/home_vg/home /home3

Portage Local Mirror

Browse Portage Local Mirror

Screenshot Using Command Line

sleep 5; xwd -root | xwdtopnm | pnmtopng > capture.png

VirtualBox

Browse Gentoo VirtualBox

echo "app-emulation/virtualbox-bin PUEL" >> /etc/portage/package.license/virtualbox-bin

emerge -av app-emulation/virtualbox

gpasswd -a <user> vboxusers

VirtualBox Headless Mode

vboxmanage startvm VMname --type headless

vboxmanage controlvm VMname poweroff

修正 emacs 在X11下不能使用中文輸入法的問題

Browse 修正 emacs 在X11下不能使用中文輸入法的問題

IBus (Intelligent Input Bus)

Browse Gentoo wiki IBus

Unmasking a package

Browse Gentoo Knowledge Base:Unmasking a package

Hacking a software

Browse Emerge Strategy when hacking a software

When I want to hack a package for which an ebuild exists (say foo-x.y.z.ebuild), this is what I do.

Code:
ebuild /usr/portage/path-to-the-ebuild/foo-x.y.z.ebuild prepare

Go to the extracted source directory:
Code:
cd /tmp/portage/path-to-the-ebuild/foo-x.y.x/work
and there I edit, hack, etc. the sources.
Then I use the command merge to compile the hacked sources and install:
Code:
ebuild  /usr/portage/path-to-the-ebuild/foo-x.y.z.ebuild merge
Everything is installed in the proper places.
I can uninstall with the command ebuild ... unmerge.

Ebuild Predefined Read-Only Variables

Browse Variables - Gentoo Development Guide

Gentoo Binhost

Browse Github gentoo-binhost of coldnew

Prepare SSH key

ssh-keygen -t rsa -C your_email@example.com

Test SSH key after importing to github

  1. The import web page can be found at Settings - SSH and PGP keys.
  2. Then test with
ssh -T git@github.com

LaTeX and CJK

Install necessary packages

emerge -av app-text/texlive dev-texlive/texlive-langcjk

Install necessary fonts

Copy necessary fonts to /usr/share/texmf-dist/fonts directory from Debian latex-cjkchinesearphic-bsmi00lp packages:

/usr/share/texmf/fonts/afm/arphic
/usr/share/texmf/fonts/tfm/arphic
/usr/share/texmf/fonts/vf/arphic
/usr/share/texmf/fonts/type1/arphic
/usr/share/texmf/fonts/map/dvips/arphic

Unmark Map bsmiu.map in /etc/texmf/updmap.d/00updmap.cfg, and run texmf-update. Finally you have to run mktexlsr command to refresh the kpathsea caches.

Optional fix for certain TexLive version

According to todays update breaks fonts in texlive Issue No 28051

sed -i 's:`kpsewhich -var-value=TEXMFROOT`:"/usr/share/texmf-dist":' /usr/bin/updmap

updmap-sys --syncwithtrees

updmap-sys

Please note you may need to copy /usr/share/tlpkg to /usr/share/texmf-dist for updmap-sys to run.

Circular dependencies between certifi and setuptools

Browse How to overcome the circular dependencies between certifi and setuptools

Basic guide to write Gentoo Ebuilds

Browse Basic guide to write Gentoo Ebuilds and ebuild variables

epatch introduction

Browse Gentoo epatch Introduction by coldnew

Fix startx dev tty permission denied problem

rc-update add elogind boot

Home router

Browse Gentoo Home router

Linux kernel

Emacs and Org mode Tips

Dired attach multiple files

turn-on-gnus-dired-mode

C-c C-m C-a to run gnus-dired-attach

Python Tips

Python Zip Executables

zip -r9 library.zip unpacked

echo ‘#!/usr/bin/env python’ > my_executable_zip

cat output_of_setup_py_bdist.zip >> my_executable_zip

chmod +x my_executable_zip

Browse

DrGeo

Embedded Linux Security

HDL

Raspberry Pi

Please browse

J-core

Browse

PyHDL

Browse PyConTW 2013: MyHDL designing digital hardware with Python by Jan Decaluwe

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published