1.必须的依赖包/ D+ v& Y0 a% k2 U" P g
( @2 C" Q, W# T
- PC gt; sudo apt-get update- u A2 K0 {3 {$ a
- PC gt; sudo apt-get install bison flex sed wget curl cvs subversion git-core coreutils unzip texi2html 1 m% ]6 X' q; r
- texinfo docbook-utils gawk python-pysqlite2 diffstat help2man make gcc build-essential g++ desktop-file-utils chrpath libxml2-utils xmlto docbook 0 y Z- @( G. Z! ]. z
- bsdmainutils iputils-ping cpio python-wand python-pycryptopp python-crypto$ T+ |* i: A( ]3 l$ R& O; q* w% \
- PC gt; sudo apt-get install libsdl1.2-dev xterm corkscrew nfs-common nfs-kernel-server device-tree-compiler mercurial u-boot-tools libarchive-zip-perl
( B7 H' N3 V' r+ d8 ^: H( U - PC gt; sudo apt-get install ncurses-dev bc linux-headers-generic gcc-multilib libncurses5-dev libncursesw5-dev lrzsz dos2unix lib32ncurses5 repo libssl-dev
复制代码 7 X7 c- v- l4 O- ^/ v8 v3 B" ], M, E
2.repo 获取源码
! P! t5 O8 m. \! a1 g5 D
$ T1 C7 I3 F* q' V; O6 o8 t#repo init -u -b refs/tags/openstlinux-5.4-dunfell-mp1-20-06-24# ?9 D D- N/ m$ N$ G7 p9 A0 ]
8 c& ?, F) N" Z+ a
- repo init -u -b refs/tags/openstlinux-20-02-19
复制代码
! c% ^# T3 }( J' h4 t* `+ Wfatal: Cannot get
$ g# j5 k4 y" B1 ~; R: P* J4 qfatal: error [Errno 101] Network is unreachable; g) c4 I# d: K' r
解决方法:先单独克隆repo# w: w/ {% K9 d$ h8 E; _
: L' e# |. N4 O& j$ v7 n
- git clone
8 X5 n, e" v0 j: `% G - mkdir .repo
. x& [9 X% F" Q; T* I" p( J - mv git-repo/ repo$ \) ~$ C0 a: P" w$ E* k1 t
- mv repo .repo
+ w* K4 v$ `, P - repo sync -c -j8
复制代码 9 r7 w+ v D% P; T P; ~
单独更新+ d l& o) J5 z4 E% t
) N4 Q2 C3 U { S6 |( i
- repo sync --force-sync layers/meta-openembedded/
9 q( K# e3 s4 O) N8 F2 t- @ - repo sync --force-sync layers/meta-openembedded/+ e- c: v* f, V% |
- repo sync --force-sync layers/meta-st/meta-st-openstlinux/, P) p H" U' X
- repo sync --force-sync layers/openembedded-core/% r( a8 c& H1 Q
- repo sync --force-sync layers/openembedded-core/bitbake/1 W- u3 ^1 f8 F7 a3 R
- repo sync
复制代码 G$ ], R E- Y0 X
源码获取完成,编译Distribution Package。( f3 N7 |, W' m: e( g3 b0 P# ~7 v
- PC gt; DISTRO=openstlinux-weston MACHINE=stm32mp1 source layers/meta-st/scripts/envsetup.sh- T1 s S: N5 r0 u" ~
- PC gt; bitbake st-image-wseton //编译镜像PC gt; bitbake st-image-weston -c fetchall //编译镜像
复制代码
. y% }/ {+ k+ C4.bitbake常用的一些命令9 n& q( m- _' o, j* r
& s) Q9 S# e7 Z O! E
- bitbake st-image-wseton -f //忽略某个包的错误,执行下去。可以减少编译等待时间。
" T, s v" O* @7 l7 ^ - bitbake st-image-wseton -c fetchall //-C用于执行特定命令,这里fetchall.
7 D7 u4 ^) J P+ d - bitbake -e linux-imx | grep ^SRC_URI= //软件包下载地址* A1 A) L1 F( g6 ]: ^! A: Z& i
- bitbake -s | grep linux //查找所有包并显示包含有linux名字的包
' Z: m7 e" v% U) X - bitbake -e linux-imx | grep ^S= //编译目录
) B- v9 {7 p7 B% ]$ X7 L s& y S - bitbake linux-imx -C compile //编译内核和dtb,-C的C是大写
& r% U6 Y- K3 X/ S9 D9 Z+ C - bitbake opencv -c fetch% s7 Q9 m8 G; f
- bitbake opencv -c clean3 m; W1 X! [. ]' p$ \2 q" j0 P
* Z% ^, A. W/ N$ W2 o- bitbake -k core-image-minimal
! O6 t) d6 h3 i2 p4 T& D3 A - bitbake xx-image -c listtasks
# J6 q, x/ E# I4 l - bitbake -s | grep packagename6 N3 _ i3 K v# F) |
- bitbake -e xxx-image | grep ^SRC_URI=3 t- K+ o6 i) w
- 查看软件依赖% G3 V: n. k( w
- bitbake -g packagename
复制代码- bitbake -c clean -v u-boot' y' E \; }! L! |1 |1 t0 w6 u
- bitbake -c cleanall xx-image #清除所有编译中间
) q; m- c1 ?/ X! h5 ~ R - bitbake -c cleansstate xx-image #清除编译
1 g+ D; u# j# z0 L/ B - 生成编译中的配置文件和类文件
+ ~$ Q A4 z+ @2 Y3 T - bitbake -e > mybuild.log
1 d5 A E2 d5 _3 m" x, N. Z - ! z2 }5 { z0 |* ~3 N& @
- bitbake -b 加上.bb文件的路径,即可以直接执行这个.bb文件7 q8 C0 B- {2 u+ `% e/ q, R7 Z4 t1 @# s
- #查找包的原路径' }% h: w; b6 f! J
- bitbake -e linux-stm32mp | grep ^SRC_URI=) _' c1 r1 E- H/ a M
- #查找包的bblayer
* ?, }" m; z/ m! S! V6 z! M+ D - bitbake -e linux-stm32mp | grep ^S
复制代码 / E) H& I& b& @
5.bitbake 命令续
& w% n, J# C9 d- bitbake -e linux-stm32mp | grep ^S=
4 Q3 s' p# Z; O, i2 j& D - S="/home/fdw/32mp1/openstlinux-200219/build-openstlinuxweston-stm32mp1/tmp-glibc/work/stm32mp1-ostl-linux-gnueabi/linux-stm32mp/4.19-r0/linux-4.19.94"
. a4 X' R' e5 h+ d - bitbake -e m4projects-stm32mp1 | grep ^S=
: T( u- Y% `% h8 S - S="/home/fdw/32mp1/openstlinux-200219/build-openstlinuxweston-stm32mp1/tmp-glibc/work/stm32mp1-ostl-linux-gnueabi/m4projects-stm32mp1/1.2.0-r0/git1 s% x8 [/ k; e2 f: G2 p0 T& F7 ^
- $ i* U; Z# M A+ _. Q1 `$ B
- bitbake -s | grep opencv% X* C4 ~/ n8 k7 w2 {
- PC gt; find . -type f -iname "opencv*.bb"2 }2 A1 P- G n
- ./layers/meta-openembedded/meta-oe/recipes-support/opencv/opencv_3.4.3.bb
复制代码
) g; X" g; p, |5 _+ ]4 @6.linux 内核实例
1 }8 z1 J: @. e6 V6 @- PC gt; devtool modify virtual/kernel
; [7 k5 f/ {, j3 U$ Y6 b - PC gt; ls workspace/sources/linux-stm32mp/6 G+ ]6 x) @$ E
: _1 z/ v% T. x+ Q- Board gt; dmesg | grep -i cma" Y( d! k" p: ], ~7 v$ P, P
- PC gt;grep -i CONFIG_CMA_SIZE_MBYTES ./workspace/sources/linux-stm32mp/ -nr
0 I4 L% |4 O. p$ t. y/ @# z - 8 x* R+ W/ w' b# l/ j. H6 S
- PC gt; bitbake virtual/kernel -c menuconfig 3 p4 B+ g& |) U7 F8 y+ w+ |
- PC gt; bitbake virtual/kernel -C compile- V' c3 \5 A7 \0 b5 y% R
3 y3 R B3 _6 o7 R: }/ v6 v& [8 C2 F- $ bitbake -c menuconfig virtual/kernel
( a, `: W E F- Y - $ bitbake -c compile -f -v virtual/kernel 单独编译内核1 f L2 R6 W- }
- $ bitbake -c compile_kernelmodules -f -v virtual/kernel 单独编译模块, k) n. z, _5 G0 W
- $ bitbake -c deploy -f -v virtual/kernel 然后部署编译输出镜像
复制代码- #devtool build because the build makes compile,
0 S* c# F2 B5 T8 d" b4 H - #compile_kernemodules and install commands# K/ z1 x5 M" Z. }9 i
- Board gt; mount /dev/mmcblk0p4 /boot
4 l3 W; a+ _- @! J6 t - PC gt; scp <build dir>/../../*.dtb root@<board ip address>:/boot
3 |# b/ T/ B$ ~ @& P - Board gt; cd /boot; sync; systemctl reboot
. H0 O$ g% A3 q. I$ ` - ! X* @% ~" f: b- z1 b- o0 O' K. k
- vim workspace/sources/linux-stm32mp/arch/arm/boot/dts/stm32mp157a-dk1.dts
, h! w% ]/ ` F0 M6 c4 _% G - bitbake virtual/kernel -C compile
复制代码- PC gt; vim workspace/sources/linux-stm32mp/drivers/media/platform/vivid/vivid-core.c 9 z1 j6 C' p8 A. f) }# s* A5 J5 o
- PC gt; bitbake virtual/kernel -C compile' S) S) ?4 O" T. n. ]: T& C
- #Update the vivid kernel module on the board& f/ K% u a. @1 q
- PC gt; devtool deploy-target -Ss linux-stm32mp :/, i; }- J- f/ i
- Board gt; /sbin/depmod -a
' s0 j* A% Z4 `8 B& ^ - Board gt; sync: Q' ]" h2 X+ j* l
- Board gt; modprobe vivid
复制代码- scp tmp-glibc/deploy/images/stm32mp1/stm32mp157*.dtb :/boot3 k4 t2 @: x, Q" E
- scp tmp-glibc/deploy/images/stm32mp1/uImage*:/boot1 w% v' D" I* c* X' u# ]: N: H
- rm -rf /home/fdw/.ssh/known_hosts
复制代码 : I ?, y+ t& I
6.uboot实例 x! x" u- M% M1 k
- PC gt; devtool search u-boot*$ I! M. W6 W$ {8 V
- PC gt; devtool modify u-boot-stm32mp
1 r& l* j& u4 m7 O - #cd <build dir>/workspace/sources/u-boot-stm32mp
& O) h$ g& j& {, O+ w - PC gt; devtool build u-boot-stm32mp- U0 K% V3 x; B3 ?
- PC gt; bitbake u-boot-stm32mp -c deploy
6 T5 Q# z* C6 u8 p* A; H - #ums 0 mmc 0
2 i% c" N* x8 k - PC gt; dd if=u-boot-<board name>-trusted.stm32 of=/dev/sdc3 bs=1M conv=fdatasync
复制代码
# A5 W3 Q8 X5 j3 f7.tf-A实例3 a) ?3 M$ [+ k4 ]' C+ _
- PC gt; devtool search tf-a*
3 ]) s2 h: `) V - PC gt; devtool modify tf-a-stm32mp
1 M! m& s( H$ F+ u8 U - #PC gt; cd <build dir>/workspace/sources/tf-a-stm32mp' h2 p6 F* E8 i! o, i, K8 V8 U. V& r
- PC gt; vim ./plat/st/stm32mp1/bl2_io_storage.c , p% U; C h* V% S
- PC gt; devtool build tf-a-stm32mp# f1 A' j, v8 ]( e; Y L+ m
- #bitbake tf-a-stm32mp( W% f5 s, Y+ d: `$ Q0 f) z
- PC gt; bitbake tf-a-stm32mp -c deploy
, J/ P! b7 b3 u5 C$ V8 G# w8 D4 D - PC gt; dd if=tf-a-<board name>-trusted.stm32 of=/dev/sdc1 bs=1M conv=fdatasync
复制代码 # E, a% {/ ] v
8.应用程序 “hello world”
) j1 I, J6 X4 J0 D/ n3 P; C6 W' z- `( ^0 t, Z A
- PC gt; mkdir hello_world_example
# t6 E9 e$ ^ L1 y6 ? - PC gt; cd hello_world_example" M! M/ k7 A, h5 r8 x: E0 v( ^" [
- PC gt; vim hello_world_example.c) V$ ^$ j! j8 U- B( z3 ]
- PC gt; cd <build dir>
7 ^) ?) J! E9 X2 c - #Add a new recipe to the workspace
O# k/ }: a1 L1 K$ `+ H - PC gt; devtool add myhelloworld hello_world_example/
- d7 W/ u% h- r - #Adapt recipe
; q& Z* _/ o! U- e - PC gt; devtool edit-recipe myhelloworld
* j; W" H2 P( _& f, I - PC gt; devtool build myhelloworld
& p% q- O1 g5 Z0 F1 e - PC gt; devtool deploy-target -s myhelloworld
复制代码 ' t" t. g) n3 j7 @$ ~
9.m4projects-stm32
7 \8 C$ N5 d" ]. \- Board gt; cd <path_to_your_workspace>/build-<name_of_distro>
" F3 \: S# D/ [9 q2 z& d - 3 ]. H6 B* `- W& O3 u
- Clean the m4projects build folder: V- f; j2 E2 }5 T4 w G& W
- Board gt; bitbake m4projects-stm32mp1 -f -c cleanall $ H4 d) D1 x g$ ?1 d, N% s
4 r, |5 n( p% b- B/ x- Rebuild the recipe m4projects1 g" y R( }8 r2 m
- Board gt; bitbake m4projects-stm32mp1 6 l9 i$ q+ l& X% |/ k
- 9 B5 \8 g# F! w+ x9 U* N" G6 b
- Rebuild the image
/ V! |# V# R4 ?( Y1 Y; |$ s: C; A - Board gt; bitbake st-image-weston
复制代码
$ ?9 Y1 F4 }& o' B/ K: _! F8 g( D二.devtool的总结
6 S# Z2 P. y5 Z) f
9 v. y+ n2 W7 J9 F7 i( ?- devtool modify tf-a-stm32mp % S% Y8 [8 G) z9 _1 |, Z9 M
- bitbake tf-a-stm32mp, e8 e, z- L" E1 P% W3 ]/ Z5 G
; E4 I, Q3 X) c; |- devtool search u-boot*
- L2 b* f' A9 Q; u - devtool modify u-boot-stm32mp
7 l) {; p' |6 s2 d( N. J - bitbake u-boot-stm32mp
4 y2 j3 r6 _- d" z* |
: [; @1 ^! [" ~4 Z+ I" D- devtool modify linux-stm32mp. R5 l( L7 D" ]6 K6 H
- bitbake linux-stm32mp
复制代码- NOTE: Starting bitbake server...
x) b0 w3 m" W! U2 e9 U - usage: devtool [--basepath BASEPATH] [--bbpath BBPATH] [-d] [-q]
) z6 h0 {8 ?& K! L+ f* @; l0 D - [--color COLOR] [-h]
; m: D' d" i- `' u3 c: S - <subcommand> ...
" K8 M% p( k; C T6 s
: Z% b: c* K/ ] E3 Z- OpenEmbedded development tool
* d2 _; b, B3 T/ g - ! Y: H) s7 w' |& v+ o
- options:
9 W+ v; b6 C% X - --basepath BASEPATH Base directory of SDK / build directory
6 c- t% x2 a! A3 Q( b - --bbpath BBPATH Explicitly specify the BBPATH, rather than getting it
( l5 [2 E4 y( H" l - from the metadata
% ^0 c3 V. T5 h+ C! x/ s" d - -d, --debug Enable debug output
h+ T8 t5 N1 v/ |; \ - -q, --quiet Print only errors' I+ @; l& Q; }( C8 B; S, l
- --color COLOR Colorize output (where COLOR is auto, always, never); s1 H! S- {& G
- -h, --help show this help message and exit0 F$ n! U, K {# T" B) f9 p9 p# x
+ h% ^% o$ h; Y, l& q3 m- subcommands:0 S( y, ~ A! a
- Beginning work on a recipe:
% {5 t m* L# n5 C - add Add a new recipe
% U, s V: k' z - modify Modify the source for an existing recipe
: i: d0 B, N8 G5 r( S# _6 } - upgrade Upgrade an existing recipe( U+ m! U# {9 \ ]! v4 q3 c& d8 V/ S
- Getting information:
- H3 |! N( D/ W X# _' N3 Z( ~ - status Show workspace status4 L8 J# Q- _/ I Y5 d# r a
- search Search available recipes6 J( n# P6 O1 p" V& I
- Working on a recipe in the workspace:/ E' |: s& {3 s }8 I
- build Build a recipe
! h, f, ~& C/ t1 u% Z* W9 s& b; ? - rename Rename a recipe file in the workspace. K8 w" i" P2 P4 w. g* C/ n4 s* |
- edit-recipe Edit a recipe file in your workspace
# o$ Y+ J! d/ T* @6 E/ y - find-recipe Find a recipe file in your workspace1 U4 D$ d' x6 L1 E+ o
- configure-help Get help on configure script options! o) Q f0 i% k- E) j
- update-recipe Apply changes from external source tree to recipe, `- ~$ i# s& w' s9 w
- reset Remove a recipe from your workspace
- f5 Z) D. o6 ~/ @ - finish Finish working on a recipe in your workspace& z8 s8 V; @5 a1 H
- Testing changes on target:9 ]! W' e6 N4 i) D% X( S; c
- deploy-target Deploy recipe output files to live target machine% x* L- e ?0 o. J
- undeploy-target Undeploy recipe output files in live target machine* e# E( D5 w9 L! B, I" Q2 `
- build-image Build image including workspace recipe packages
, a+ h2 K# {, Z# d - Advanced:
% z+ T% n/ M! x( S - create-workspace Set up workspace in an alternative location: i( u0 N; S9 L4 m F- o
- import Import exported tar archive into workspace1 a( j/ N/ G- M
- extract Extract the source for an existing recipe/ x' H- X% v) [6 B1 v$ J
- sync Synchronize the source tree for an existing recipe
) _' K, a0 i5 y3 G - export Export workspace into a tar archive
+ a; f, x3 V; Q& ]6 @4 g - Use devtool <subcommand> --help to get help on a specific command
复制代码
; S0 W/ v. g$ i& _2 ^$ a* e5 Y' y
6 R% [ n& I0 E7 I5 r————————————————
5 f* a( \ }& J& s9 S7 |版权声明:jacob杰克爸4 \* Z# v) v/ s9 n) W( a# o
) _* R( Z2 X2 e- ?, _ |