1.必须的依赖包; \- m/ H+ [. o5 T, w
' Q) c8 k% x* F! w& b7 l" `2 u- PC gt; sudo apt-get update7 W4 w4 u+ ?3 h' U6 m0 M
- PC gt; sudo apt-get install bison flex sed wget curl cvs subversion git-core coreutils unzip texi2html ) I* V- V+ N. E$ S8 r" t7 ]0 D5 z
- texinfo docbook-utils gawk python-pysqlite2 diffstat help2man make gcc build-essential g++ desktop-file-utils chrpath libxml2-utils xmlto docbook 2 w0 D M G" H
- bsdmainutils iputils-ping cpio python-wand python-pycryptopp python-crypto) Y$ c+ e- D0 q* O
- 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( ]7 H8 b$ J+ w
- PC gt; sudo apt-get install ncurses-dev bc linux-headers-generic gcc-multilib libncurses5-dev libncursesw5-dev lrzsz dos2unix lib32ncurses5 repo libssl-dev
复制代码 2 @3 x/ Z8 G5 T# w: U" b! q
2.repo 获取源码, C5 F: f5 d$ g) |5 P9 s; ^
) v4 b7 d+ \6 v5 |4 p
#repo init -u -b refs/tags/openstlinux-5.4-dunfell-mp1-20-06-240 a R2 a3 ~, l; f2 F+ Q) E' J
# J. c, { A# h. S/ n3 r9 \- repo init -u -b refs/tags/openstlinux-20-02-19
复制代码 3 P, L1 I" z# F: y4 k: ] Y
fatal: Cannot get 6 r! i4 Q/ A9 ~
fatal: error [Errno 101] Network is unreachable
3 z7 L# M% Y$ b( A/ e解决方法:先单独克隆repo4 x& x a; n# u% E
$ S7 @, \1 f4 ~% B# W" f- git clone( ~! X! H( j+ i* t8 O9 |
- mkdir .repo- c1 j8 L& Z# z6 m) o
- mv git-repo/ repo1 a6 U! `; v+ n. ~8 z4 p' V
- mv repo .repo
; L+ N0 G$ N3 |& H5 s - repo sync -c -j8
复制代码
$ I7 U6 j% w7 l' o- \单独更新' Y9 F- q# P$ T% i% y3 Y) v
% W2 R) ^7 t0 l0 c
- repo sync --force-sync layers/meta-openembedded/
/ ~( g1 p* B* U. X) I: H- V m - repo sync --force-sync layers/meta-openembedded/8 J W0 u7 m- A3 Q* ?% k e
- repo sync --force-sync layers/meta-st/meta-st-openstlinux/+ C9 R6 b$ F+ w% ]; m$ P( q# y& ?
- repo sync --force-sync layers/openembedded-core/# ]0 z: p+ b \& v: E
- repo sync --force-sync layers/openembedded-core/bitbake/8 e3 f& e t- V, [" z3 g
- repo sync
复制代码 8 k4 a2 Z! g* f8 }6 p
源码获取完成,编译Distribution Package。
% s% p* O- t/ u) Q- PC gt; DISTRO=openstlinux-weston MACHINE=stm32mp1 source layers/meta-st/scripts/envsetup.sh) q) n( t8 e. a: l5 x
- PC gt; bitbake st-image-wseton //编译镜像PC gt; bitbake st-image-weston -c fetchall //编译镜像
复制代码
5 X/ s) g" x% ]% C( P# y; D+ O4.bitbake常用的一些命令5 g! M3 u, J8 Y9 u. V( b
/ W0 _, @. }* J1 i% l
- bitbake st-image-wseton -f //忽略某个包的错误,执行下去。可以减少编译等待时间。. F# t* j+ G& l9 b2 ?. w
- bitbake st-image-wseton -c fetchall //-C用于执行特定命令,这里fetchall.
, D- J" i8 x8 N( f: A - bitbake -e linux-imx | grep ^SRC_URI= //软件包下载地址
3 P' O2 p V2 ~& p) m9 d - bitbake -s | grep linux //查找所有包并显示包含有linux名字的包 R1 \1 m% R' e- q7 b% ]$ V
- bitbake -e linux-imx | grep ^S= //编译目录4 X- Y* O% t8 I" O. _+ A
- bitbake linux-imx -C compile //编译内核和dtb,-C的C是大写
; ?" C* p" Q; o$ M6 o3 E: Q. J2 e" s - bitbake opencv -c fetch
! m; X! ~; B5 y5 C0 k2 }0 j4 t - bitbake opencv -c clean! I* N0 U1 E4 y. I: v9 Y
- 1 @3 [% l, y5 a8 E% y" d: r
- bitbake -k core-image-minimal
% q& O* S1 S, t, d3 L: T" @ - bitbake xx-image -c listtasks
8 C5 A! X' v7 e; p - bitbake -s | grep packagename1 k. v" P5 n |4 q8 v4 q5 H
- bitbake -e xxx-image | grep ^SRC_URI=
" ?( x. s5 m. P% ~) X9 ^$ [ - 查看软件依赖
9 f& M5 y3 ]4 c - bitbake -g packagename
复制代码- bitbake -c clean -v u-boot
- @- Y9 h4 U1 p1 N - bitbake -c cleanall xx-image #清除所有编译中间
\& ^: A9 w+ F- H' [; n - bitbake -c cleansstate xx-image #清除编译 ( \1 S, }2 V5 } W$ O
- 生成编译中的配置文件和类文件
2 Z* r- R- i! N% f( k N - bitbake -e > mybuild.log
: f/ Y5 [+ r. [ - 0 q8 R2 T$ H( c) I; L" |2 N
- bitbake -b 加上.bb文件的路径,即可以直接执行这个.bb文件
& K4 m K9 [0 R" i R0 T - #查找包的原路径5 S- i- M7 g; u3 Q
- bitbake -e linux-stm32mp | grep ^SRC_URI=+ z, i. o0 v! R9 M
- #查找包的bblayer! {8 u3 z. l, |
- bitbake -e linux-stm32mp | grep ^S
复制代码
d! N0 C$ X% ?3 ~- g7 K5.bitbake 命令续
) Y" x5 r3 q; s. j. c- bitbake -e linux-stm32mp | grep ^S=
2 S" B9 ]* I3 z$ {4 \ - 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"6 f' _* J$ x3 L' w3 |
- bitbake -e m4projects-stm32mp1 | grep ^S=0 U# x; l6 h* @
- S="/home/fdw/32mp1/openstlinux-200219/build-openstlinuxweston-stm32mp1/tmp-glibc/work/stm32mp1-ostl-linux-gnueabi/m4projects-stm32mp1/1.2.0-r0/git' Y. V6 i$ U& S3 z3 t* n
% a8 I4 v: B2 P' U" c- bitbake -s | grep opencv- G7 [( W/ O {
- PC gt; find . -type f -iname "opencv*.bb"- p; H4 Y1 ^8 s+ Z- p+ N
- ./layers/meta-openembedded/meta-oe/recipes-support/opencv/opencv_3.4.3.bb
复制代码 & o3 E' _& p9 I& x, N( d7 _
6.linux 内核实例
6 i/ J* ^% R7 y9 {* W- PC gt; devtool modify virtual/kernel
. q& A/ R2 B6 f+ D; M; R% ` - PC gt; ls workspace/sources/linux-stm32mp// Q5 K8 o* ^0 |9 n9 d0 I0 C
7 b' U5 ]0 N' x+ g7 g0 z, M) H3 x) {- Board gt; dmesg | grep -i cma
4 U) u) f9 o6 A x$ a; H' w - PC gt;grep -i CONFIG_CMA_SIZE_MBYTES ./workspace/sources/linux-stm32mp/ -nr
6 f. w) x! ~* O- @ - 3 g" g7 G" i+ `# F$ ~9 }9 R9 W/ I6 Z
- PC gt; bitbake virtual/kernel -c menuconfig
) h7 b- E0 {' T; Q& l& t - PC gt; bitbake virtual/kernel -C compile& i% X5 i; x, D; {: u* K
. C0 Z3 Q8 X' q5 T- $ bitbake -c menuconfig virtual/kernel
( k( C" n- l# G& k% C - $ bitbake -c compile -f -v virtual/kernel 单独编译内核
: ]6 S6 s+ E1 b. w - $ bitbake -c compile_kernelmodules -f -v virtual/kernel 单独编译模块, S" C3 |) L; W8 k
- $ bitbake -c deploy -f -v virtual/kernel 然后部署编译输出镜像
复制代码- #devtool build because the build makes compile,
! j+ ?! H% z+ z u" Y - #compile_kernemodules and install commands0 h; [% c- z- B& q6 P y4 N. L; m
- Board gt; mount /dev/mmcblk0p4 /boot1 x0 c) _' a q1 u4 X
- PC gt; scp <build dir>/../../*.dtb root@<board ip address>:/boot
8 f& A4 c& {5 l9 A - Board gt; cd /boot; sync; systemctl reboot2 L! E6 u& D5 u
" R: u" l0 ^6 U. ]) M6 O- vim workspace/sources/linux-stm32mp/arch/arm/boot/dts/stm32mp157a-dk1.dts
0 o) j2 h! l- `+ \ - bitbake virtual/kernel -C compile
复制代码- PC gt; vim workspace/sources/linux-stm32mp/drivers/media/platform/vivid/vivid-core.c 7 _$ a( G. i" u& t
- PC gt; bitbake virtual/kernel -C compile
2 F8 L' Z4 {% K1 ?! r- ~( }: z - #Update the vivid kernel module on the board
8 q6 a- a, J/ V, m. b$ i4 J* m' B - PC gt; devtool deploy-target -Ss linux-stm32mp :/
. d. {( T1 }& `9 U# M( V4 M - Board gt; /sbin/depmod -a
% ^, S+ W' r7 \* a/ i - Board gt; sync
+ K0 ^: ?, |5 _: s, q) Z" \ - Board gt; modprobe vivid
复制代码- scp tmp-glibc/deploy/images/stm32mp1/stm32mp157*.dtb :/boot
! \' f! n A* H& I; ]2 m - scp tmp-glibc/deploy/images/stm32mp1/uImage*:/boot
0 |8 H. W" N; y( t - rm -rf /home/fdw/.ssh/known_hosts
复制代码
7 f4 b. C- M- `; @& t: u) R( P6.uboot实例1 W! @2 f; v& @/ [
- PC gt; devtool search u-boot*
0 c1 N2 R2 _2 I. N7 s% [ - PC gt; devtool modify u-boot-stm32mp
( k" ~" m3 s; v" a% F1 Q4 n& V - #cd <build dir>/workspace/sources/u-boot-stm32mp
$ x' t. p9 [& A, h - PC gt; devtool build u-boot-stm32mp- ^; C" x3 N* ^0 `" x
- PC gt; bitbake u-boot-stm32mp -c deploy2 f4 f. O( A1 P4 w0 `
- #ums 0 mmc 0
; D8 Y' h, x4 Q* B - PC gt; dd if=u-boot-<board name>-trusted.stm32 of=/dev/sdc3 bs=1M conv=fdatasync
复制代码 6 e0 d1 i' ^. e4 _. K/ F2 j
7.tf-A实例
. w0 ]7 @1 _$ k; M4 `- PC gt; devtool search tf-a*" `% r u$ A {: H5 e6 ~
- PC gt; devtool modify tf-a-stm32mp
$ w* _6 P! B2 B; F) k6 V' M - #PC gt; cd <build dir>/workspace/sources/tf-a-stm32mp i- q7 u# I( [ c" o
- PC gt; vim ./plat/st/stm32mp1/bl2_io_storage.c 5 S& Z. s* _9 `2 |. D
- PC gt; devtool build tf-a-stm32mp
1 p4 B. F+ O) c/ ]; ` - #bitbake tf-a-stm32mp
5 U' D7 j) t6 o, O+ `2 u - PC gt; bitbake tf-a-stm32mp -c deploy
- r4 z9 y1 {% ?5 p - PC gt; dd if=tf-a-<board name>-trusted.stm32 of=/dev/sdc1 bs=1M conv=fdatasync
复制代码
7 V* s; V( C, ^' p. [( g8.应用程序 “hello world”
/ X$ e( T; w2 H3 Y( O% W6 c0 k9 {& a8 ^
- PC gt; mkdir hello_world_example, v( q0 ]# o$ e" G
- PC gt; cd hello_world_example
/ ^( X7 G& Q7 ]4 |7 R7 J1 r - PC gt; vim hello_world_example.c
, I6 V- p T t+ j8 k/ K6 C - PC gt; cd <build dir>
/ q, L8 [0 a( v( D* A9 L - #Add a new recipe to the workspace
, @, J" Z* v. T - PC gt; devtool add myhelloworld hello_world_example/
0 `# S$ W6 k0 A8 t, d5 D - #Adapt recipe }$ {9 m$ A2 z0 }
- PC gt; devtool edit-recipe myhelloworld0 y" r/ A9 h8 b3 u: s
- PC gt; devtool build myhelloworld' X/ a+ L, c/ ~+ `( N: e
- PC gt; devtool deploy-target -s myhelloworld
复制代码 . W: v$ I4 H) W0 G
9.m4projects-stm32+ ~& ~# J9 v& |4 O: ]. p
- Board gt; cd <path_to_your_workspace>/build-<name_of_distro>
: z: b/ U3 f+ I: s - & H( _6 Z4 T3 L
- Clean the m4projects build folder7 s3 V8 j7 l3 m- l( p' M3 p
- Board gt; bitbake m4projects-stm32mp1 -f -c cleanall
@, h8 J/ x9 t8 x B
6 |2 T+ [' N1 q6 U3 q0 `5 i; o6 }- Rebuild the recipe m4projects
" k, c; }. ^( N, P' [7 A- ^ - Board gt; bitbake m4projects-stm32mp1
5 p" g1 ~2 j1 y2 ^7 N- W6 F) X) B - 0 \/ j* ]" j8 p, G% @7 q6 d7 b* p
- Rebuild the image1 I2 ~, q; J5 P0 b9 P
- Board gt; bitbake st-image-weston
复制代码
. [$ S" X5 E R* t% k8 o4 J二.devtool的总结; Y% i/ a' D2 u& z
4 g6 b! W; S, H4 n- devtool modify tf-a-stm32mp
3 G2 Z) h. T4 L" P' _% f/ n - bitbake tf-a-stm32mp% {: S# ~" h5 Z, L5 r- v6 D' D
- 7 g; b& \, @3 l5 t
- devtool search u-boot*
- w% I- ]1 d, Z0 X. b - devtool modify u-boot-stm32mp& ^' P# w: i: o+ u( Y9 Q+ r' x+ _
- bitbake u-boot-stm32mp
; ]% O, M; P0 w$ P: l6 ~$ K - # ~# f n/ g, ~% o+ a5 U' m* f
- devtool modify linux-stm32mp( ?: b% g: ]5 D" a0 M' }0 m" w
- bitbake linux-stm32mp
复制代码- NOTE: Starting bitbake server...
% {, N" f$ z7 u4 N3 ? - usage: devtool [--basepath BASEPATH] [--bbpath BBPATH] [-d] [-q]
1 E# s7 p# E. T - [--color COLOR] [-h]! `4 |+ l1 R6 Z0 W- {* P
- <subcommand> ...2 ^5 b* R( Z* J# U' |
- * N; ~* {0 k9 ^5 ?
- OpenEmbedded development tool
9 R0 Y: E4 c; u: q, p9 N% E - 2 S7 \/ `" f4 l: w3 k. z
- options:
& W" z4 P4 o- E1 p( ~: n+ x" P9 V - --basepath BASEPATH Base directory of SDK / build directory& @8 L" v, R/ h& b
- --bbpath BBPATH Explicitly specify the BBPATH, rather than getting it
+ @: M9 A2 D9 _$ @( N. W - from the metadata
$ \7 s! O9 Q' X _ - -d, --debug Enable debug output
1 L. z; i9 v9 v& ] - -q, --quiet Print only errors
9 y) [9 m' `% j4 N, m - --color COLOR Colorize output (where COLOR is auto, always, never)
1 e5 h: v' h* Y/ d - -h, --help show this help message and exit w* m; ]& r% A, J( i
- ( w5 L* O+ K/ I# u$ |' n: y
- subcommands:
' O- W; p& F) }$ U* A4 I - Beginning work on a recipe:
7 f( Y( d: z1 `7 L8 ?) C' {& D - add Add a new recipe5 j8 d+ b' N( F! u2 t b
- modify Modify the source for an existing recipe
* v: [* P7 T# j! r2 J g - upgrade Upgrade an existing recipe1 f! W. \+ d/ B7 v! V
- Getting information:
/ T6 s+ r+ e" D - status Show workspace status) k7 N: T% g7 w1 N
- search Search available recipes
3 Y3 r2 A& R* y/ v, Z) E - Working on a recipe in the workspace:
+ f; x+ O5 m; K& i" V8 e6 M! d, Q - build Build a recipe0 B% c" {/ k, c
- rename Rename a recipe file in the workspace
+ U$ U3 R' P! M9 W' E - edit-recipe Edit a recipe file in your workspace
* _9 s. w# B0 i. a( p" e; T: h - find-recipe Find a recipe file in your workspace
: h5 W0 I8 Z/ W0 u4 k - configure-help Get help on configure script options
2 s# H: ~$ n8 m2 E5 K, i8 C' I - update-recipe Apply changes from external source tree to recipe4 Z' D; E, Z9 I0 N- a' }
- reset Remove a recipe from your workspace! I8 d1 i" S e
- finish Finish working on a recipe in your workspace
w% u; i/ _" i. N4 A% I - Testing changes on target:
! j/ a( w# O5 v- B2 B - deploy-target Deploy recipe output files to live target machine
0 a4 @3 P- U( D- |0 X$ k0 P - undeploy-target Undeploy recipe output files in live target machine3 R. ?( b+ _9 K6 D9 z) d+ N0 F
- build-image Build image including workspace recipe packages
6 n' K9 z; p! b, i+ t - Advanced:9 D5 } K, q- \/ p6 S
- create-workspace Set up workspace in an alternative location8 K6 V8 J) P8 `! Y+ |3 b
- import Import exported tar archive into workspace2 ~6 x! [# t$ [" i
- extract Extract the source for an existing recipe2 ^9 b/ O; z) r* R2 v$ Q$ w
- sync Synchronize the source tree for an existing recipe5 u1 ^4 Q$ ]$ v* P
- export Export workspace into a tar archive- _& q0 O. D3 ^! a
- Use devtool <subcommand> --help to get help on a specific command
复制代码 4 s: w S" V% R, d( R
$ z2 v- L* j- {0 a0 Z
————————————————
2 W- a& ^) U$ ?% E' B1 m5 W版权声明:jacob杰克爸
( i( j, L+ R, B- H1 t6 k) v
& {# ^# S% N) X% j, ]( L9 e8 L |