一、安装软件包
sudo passwd root
sudo apt install cmake python2-dev python3-dev build-essential cmake flex bison -y
sudo apt install universal-ctags cscope vim git -y
sudo apt install python-is-python3 -y
sudo apt-get install build-essential libncurses-dev bison flex libssl-dev
二、下载VIM插件管理器
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
vim ~/.vimrc
" ==============vim基本配置==============
set guifont=Monospace\ 14
set nu! " 显示行号
syntax enable
syntax on
colorscheme desertset autowrite " 自动保存set foldmethod=syntax
set foldlevel=100 " 启动vim时不要自动折叠代码
set textwidth=80
set formatoptions+=t
set cindent
set smartindent
set noerrorbells
set showmatch
set nobackup
set noswapfile
" set cursorline" disable
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>" remap control + arrow key to select windows
noremap <C-Down> <C-W>j
noremap <C-Up> <C-W>k
noremap <C-Left> <C-W>h
noremap <C-Right> <C-W>l
noremap <C-J> <C-W>j
noremap <C-K> <C-W>k
noremap <C-H> <C-W>h
noremap <C-L> <C-W>l" ==============Vundle插件管理==============
" Vundle manage
set nocompatible " be iMproved, required
filetype off " required" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'scrooloose/nerdtree'
" Plugin 'majutsushi/tagbar' " Tag bar"
Plugin 'Xuyuanp/nerdtree-git-plugin'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'vim-airline/vim-airline' | Plugin 'vim-airline/vim-airline-themes' " Status line"
Plugin 'jiangmiao/auto-pairs'
Plugin 'mbbill/undotree'
Plugin 'gdbmgr'
Plugin 'scrooloose/nerdcommenter'
Plugin 'Yggdroot/indentLine' " Indentation level"
Plugin 'bling/vim-bufferline' " Buffer line"
"Plugin 'kepbod/quick-scope' " Quick scope
Plugin 'yianwillis/vimcdoc'
Plugin 'nelstrom/vim-visual-star-search'
Plugin 'ludovicchabant/vim-gutentags'
Plugin 'w0rp/ale'
Plugin 'mbbill/echofunc'
Plugin 'Yggdroot/LeaderF', { 'do': './install.sh' }" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required" ==============YCM==============
let g:ycm_server_python_interpreter='/usr/bin/python'
let g:ycm_global_ycm_extra_conf='~/.vim/.ycm_extra_conf.py'" YCM 查找定义
let mapleader=','
nnoremap <leader>gl :YcmCompleter GoToDeclaration<CR>
nnoremap <leader>gf :YcmCompleter GoToDefinition<CR>
nnoremap <leader>gg :YcmCompleter GoToDefinitionElseDeclaration<CR>
let g:ycm_collect_identifiers_from_tags_files = 1set completeopt=menu,menuone
let g:ycm_add_preview_to_completeopt = 0 " 关闭函数原型提示let g:ycm_show_diagnostics_ui = 0 " 关闭诊断信息
let g:ycm_server_log_level = 'info'
let g:ycm_min_num_identifier_candidate_chars = 2 " 两个字符触发 补全
let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 收集
let g:ycm_complete_in_strings=1noremap <c-z> <NOP>
let g:ycm_key_invoke_completion = '<c-z>' " YCM 里触发语义补全有一个快捷键
let g:ycm_max_num_candidates = 15 " 候选数量let g:ycm_semantic_triggers = {\ 'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'],\ 'cs,lua,javascript': ['re!\w{2}'],\ }" ===========gutentags=============
" 搜索工程目录的标志,碰到这些文件/目录名就停止向上一级目录递归
let g:gutentags_project_root = ['.root', '.svn', '.git', '.hg', '.project', '.gitignore']" 添加ctags额外参数,会让tags文件变大
" let g:gutentags_ctags_extra_args = ['--fields=+niazlS', '--extra=+q']let g:gutentags_ctags_extra_args = ['--fields=+lS']
" let g:gutentags_ctags_extra_args += ['--c++-kinds=+px']
" let g:gutentags_ctags_extra_args += ['--c-kinds=+px']if isdirectory("kernel/") && isdirectory("mm/")let g:gutentags_file_list_command = 'find arch/arm/ mm/ kernel/ include/ init/ lib/'
endif" =======echodoc 显示函数参数===========
" ctags -R --fields=+lS ."======= NetRedTree=========
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
let NERDTreeWinSize=20
"let NERDTreeShowLineNumbers=1
let NERDTreeAutoCenter=1
let NERDTreeShowBookmarks=1let g:winManagerWindowLayout='TagList'
nmap wm :WMToggle<cr>" ======ALE静态语法检测========
let g:ale_sign_column_always = 1
let g:ale_sign_error = '✗'
let g:ale_sign_warning = 'w'
let g:ale_statusline_format = ['✗ %d', '⚡ %d', '✔ OK']
let g:ale_echo_msg_format = '[%linter%] %code: %%s'
let g:ale_lint_on_text_changed = 'normal'
let g:ale_lint_on_insert_leave = 1
"let g:airline#extensions#ale#enabled = 1
let g:ale_c_gcc_options = '-Wall -O2 -std=c99'
let g:ale_cpp_gcc_options = '-Wall -O2 -std=c++14'
let g:ale_c_cppcheck_options = ''
let g:ale_cpp_cppcheck_options = ''" ========airline状态栏=========
let g:airline#extensions#tabline#enabled = 1
let g:airline_section_b = '%-0.10{getcwd()}'
let g:airline_section_c = '%t'
let g:airline#extensions#tagbar#enabled = 1
let g:airline_section_y = ''"--------------------------------------------------------------------------------
" cscope:建立数据库:cscope -Rbq; F5 查找c符号; F6 查找字符串; F7 查找函数定义; F8 查找函数谁调用了,
"--------------------------------------------------------------------------------
if has("cscope")set csprg=/usr/bin/cscopeset csto=1set cstset nocsverb" add any database in current directoryif filereadable("cscope.out")cs add cscope.outendifset csverb
endif:set cscopequickfix=s-,c-,d-,i-,t-,e-nmap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-_>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR>"nmap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR>
"F5 查找c符号; F6 查找字符串; F7 查找函数定义; F8 查找函数谁调用了,
nmap <silent> <F5> :cs find s <C-R>=expand("<cword>")<CR><CR> :botright copen<CR><CR>
nmap <silent> <F6> :cs find t <C-R>=expand("<cword>")<CR><CR> :botright copen<CR><CR>
"nmap <silent> <F7> :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <silent> <F7> :cs find c <C-R>=expand("<cword>")<CR><CR> :botright copen<CR><CR>"--------------------------------------------------------------------------------
" 自动加载ctags: ctags -R
if filereadable("tags")set tags=tags
endif"--------------------------------------------------------------------------------
" global:建立数据库
"--------------------------------------------------------------------------------
if filereadable("GTAGS")set cscopetagset cscopeprg=gtags-cscopecs add GTAGSau BufWritePost *.c,*.cpp,*.h silent! !global -u &
endif
使用以下命令安装
vim
:PluginInstall
三、编译安装YouCompelte
apt install build-essential cmake vim-nox python3-devcd ~/.vim/bundle/YouCompleteMe
编译安装YouCompeltecd ~/.vim/bundle/YouCompleteMe
~/.vim/bundle/YouCompleteMe$ ./install.py --clang-completer~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples$ cp .ycm_extra_conf.py ~/.vim
四、工具链
wget https://snapshots.linaro.org/gnu-toolchain/12.2-2023.04-1/aarch64-linux-gnu/gcc-linaro-12.2.1-2023.04-x86_64_aarch64-linux-gnu.tar.xzexport PATH=$PATH:/opt//opt/gcc-linaro-12.2.1-2023.04-x86_64_aarch64-linux-gnu/binexport CROSS_COMPILE=aarch64-linux-gnu-
五:编译Linux kernel
sudo apt-get install gcc g++
sudo apt-get install libncurses5-dev
sudo apt-get install build-essential
sudo apt-get install kernel-package
sudo apt-get install libssl-dev
sudo apt-get install libc6-dev
sudo apt-get install bin86
sudo apt-get install flex
sudo apt-get install bison
sudo apt-get install qttools5-dev
sudo apt-get install libelf-devgit clone https://mirrors.tuna.tsinghua.edu.cn/git/linux.git
或
git clone https://mirrors.tuna.tsinghua.edu.cn/git/linux-stable.gitmake ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfigmake ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j8ake ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- tags cscope TAGS -j8