1.必须的依赖包* r* m. G2 I8 k% b# Q7 A8 N2 ^
4 [3 D& c5 m. M8 _" I3 J
- PC gt; sudo apt-get update
0 k9 H/ J( d3 L+ b - PC gt; sudo apt-get install bison flex sed wget curl cvs subversion git-core coreutils unzip texi2html
4 Z3 y2 c6 J' L' p$ L' `% d - texinfo docbook-utils gawk python-pysqlite2 diffstat help2man make gcc build-essential g++ desktop-file-utils chrpath libxml2-utils xmlto docbook
1 f' Z& F% B, k/ S) w$ |. _0 o - bsdmainutils iputils-ping cpio python-wand python-pycryptopp python-crypto) W) c. c3 |+ u8 J% b% y
- 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
4 q6 r- M- _( n, [ - PC gt; sudo apt-get install ncurses-dev bc linux-headers-generic gcc-multilib libncurses5-dev libncursesw5-dev lrzsz dos2unix lib32ncurses5 repo libssl-dev
复制代码 ) f, S- _% r) F2 g/ R
2.repo 获取源码+ q# _: j2 z: _! j/ N% A4 D9 [$ I
( B3 ]7 i4 M& a, Y$ w
#repo init -u -b refs/tags/openstlinux-5.4-dunfell-mp1-20-06-241 ]7 `4 e V. \8 B0 c
8 Q7 `3 z7 ], v$ G( \- @- repo init -u -b refs/tags/openstlinux-20-02-19
复制代码 6 H+ I7 Z* z: E4 N+ k8 ~
fatal: Cannot get % m* M: v" q. B! x3 Z
fatal: error [Errno 101] Network is unreachable
) n( T s1 G7 T5 ?' R解决方法:先单独克隆repo
" H9 ^2 |. e/ ]8 {5 C4 W9 v9 i } v& w- i+ b
- git clone
1 s4 o! g- v8 T, t5 s: A V( | - mkdir .repo
& J( R4 c5 T ~( E* Q5 c! F - mv git-repo/ repo1 C% }& C& p* W& `
- mv repo .repo
1 A+ Z) r2 y/ K/ h, K - repo sync -c -j8
复制代码
! T2 k, z- l0 H T% {# R6 U" Z单独更新
' s2 x4 `7 d8 i% M) L
/ n' s) V1 K3 j8 g- repo sync --force-sync layers/meta-openembedded/! j {1 {6 e/ q0 n3 j" v' ^
- repo sync --force-sync layers/meta-openembedded/1 s6 B. ^. |, _+ d& C3 B; E# l3 W
- repo sync --force-sync layers/meta-st/meta-st-openstlinux/
- c1 k) N/ i- I( R - repo sync --force-sync layers/openembedded-core/. g. ?" W" ]7 w5 n& T- A. D M
- repo sync --force-sync layers/openembedded-core/bitbake/+ k& f' Y1 X0 k' r/ u
- repo sync
复制代码 " f- j( t, @' c) g7 i. V3 i/ o
源码获取完成,编译Distribution Package。( t: H, ^) ?( N3 F# H
- PC gt; DISTRO=openstlinux-weston MACHINE=stm32mp1 source layers/meta-st/scripts/envsetup.sh
! ~/ m# \/ x6 K( b Z: g) G, X7 l - PC gt; bitbake st-image-wseton //编译镜像PC gt; bitbake st-image-weston -c fetchall //编译镜像
复制代码
2 I& G9 h7 l- g! n/ M4.bitbake常用的一些命令
7 O/ t! I0 [8 @" v% s9 C( h! s6 ~7 G0 n
- bitbake st-image-wseton -f //忽略某个包的错误,执行下去。可以减少编译等待时间。
. M! \' w# q! {$ _" \ - bitbake st-image-wseton -c fetchall //-C用于执行特定命令,这里fetchall.9 x2 P9 ^( y6 C. H! S
- bitbake -e linux-imx | grep ^SRC_URI= //软件包下载地址- w* u$ l0 l+ w8 [* R6 ^
- bitbake -s | grep linux //查找所有包并显示包含有linux名字的包
) w+ i {4 e+ }3 b - bitbake -e linux-imx | grep ^S= //编译目录9 a# C% R ^: A2 ~2 }- o
- bitbake linux-imx -C compile //编译内核和dtb,-C的C是大写- q5 k& o9 V$ [' G3 w; l, G8 ^' A5 r
- bitbake opencv -c fetch0 B o. z8 A& k+ M# i+ }
- bitbake opencv -c clean3 R- t1 a' d. |
- 8 l% E9 e" j- b/ s3 n9 ^6 T8 P
- bitbake -k core-image-minimal9 v! W6 J* D1 l& Z5 _
- bitbake xx-image -c listtasks
0 H7 s/ S0 ]! W3 A* y; ~+ M* i; | - bitbake -s | grep packagename
U/ y/ s% }0 ] ~9 d - bitbake -e xxx-image | grep ^SRC_URI=
! w2 w) X. b: N" ~ - 查看软件依赖
/ o' y3 D" p4 @8 L! Q+ K - bitbake -g packagename
复制代码- bitbake -c clean -v u-boot
5 P7 d5 h o: T1 \3 P; H/ k - bitbake -c cleanall xx-image #清除所有编译中间8 X/ M$ f8 \1 p5 p7 a8 B/ b# Y
- bitbake -c cleansstate xx-image #清除编译
! Z$ @- U: n5 T( N# a/ H - 生成编译中的配置文件和类文件5 A* p* O. }* \8 {$ p% r. s1 p2 G
- bitbake -e > mybuild.log9 i; x. x5 b1 a
- ' p# n% H) ]% u
- bitbake -b 加上.bb文件的路径,即可以直接执行这个.bb文件
! N0 B" T$ C2 e# {# B3 R. q* m - #查找包的原路径
J, m+ ^5 V4 n/ x' I$ f - bitbake -e linux-stm32mp | grep ^SRC_URI=
9 U1 y' X8 U* {7 b, V! b2 Q - #查找包的bblayer! M* b, d# b" q* b# s2 c$ x/ e
- bitbake -e linux-stm32mp | grep ^S
复制代码
: J% `8 v( f/ C5.bitbake 命令续/ m4 x( ^6 u2 h) S
- bitbake -e linux-stm32mp | grep ^S=! q: A) Q% E% H3 K
- 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 ?2 f$ u3 @9 N* P
- bitbake -e m4projects-stm32mp1 | grep ^S=
$ r2 S; y' R- [ - S="/home/fdw/32mp1/openstlinux-200219/build-openstlinuxweston-stm32mp1/tmp-glibc/work/stm32mp1-ostl-linux-gnueabi/m4projects-stm32mp1/1.2.0-r0/git
& g' ]; T5 j4 c% L' ~' L1 E# Y! E3 n - % W+ X. A- q9 C% m
- bitbake -s | grep opencv
: M% _+ F3 c# d3 v b0 Q- q - PC gt; find . -type f -iname "opencv*.bb"
0 _4 n& H$ z+ {& A$ w - ./layers/meta-openembedded/meta-oe/recipes-support/opencv/opencv_3.4.3.bb
复制代码
$ E; e7 p7 I% n6.linux 内核实例
" b/ X2 A4 t2 J- q' l1 O- PC gt; devtool modify virtual/kernel7 D8 {) B7 E; z3 F1 E
- PC gt; ls workspace/sources/linux-stm32mp/+ J& T- \6 B" X8 L7 h4 N- G
- * d4 }3 E! y) y! l! w: w) e* u( r# A
- Board gt; dmesg | grep -i cma
0 j( P7 s9 @8 m' H& r1 n - PC gt;grep -i CONFIG_CMA_SIZE_MBYTES ./workspace/sources/linux-stm32mp/ -nr
$ J: a0 l& }2 j - : n$ t; ~* T: e7 m0 p( o. ?/ B
- PC gt; bitbake virtual/kernel -c menuconfig
2 h0 t& [; ]! M4 b0 h - PC gt; bitbake virtual/kernel -C compile) q( Q- d' f, |. H; ?: P# W( u
2 Z3 o4 `1 a6 p) l9 @8 ]8 Q- $ bitbake -c menuconfig virtual/kernel
" f1 A. \; L5 ]8 g; F5 Q - $ bitbake -c compile -f -v virtual/kernel 单独编译内核
; U2 C, Q6 U- }0 _ - $ bitbake -c compile_kernelmodules -f -v virtual/kernel 单独编译模块6 w b ]' l+ u
- $ bitbake -c deploy -f -v virtual/kernel 然后部署编译输出镜像
复制代码- #devtool build because the build makes compile,
3 V& A: }+ L B. @8 A - #compile_kernemodules and install commands
& k H" ?; t* e7 M" K9 c, Q - Board gt; mount /dev/mmcblk0p4 /boot1 t% b0 U5 V# Z7 M1 _
- PC gt; scp <build dir>/../../*.dtb root@<board ip address>:/boot) h+ S- e; {' v- E
- Board gt; cd /boot; sync; systemctl reboot
0 f3 J. G! j+ s - . v$ z, ?5 t$ Q2 a4 \# q+ e3 V
- vim workspace/sources/linux-stm32mp/arch/arm/boot/dts/stm32mp157a-dk1.dts
" Z4 c# F3 g/ |; c - bitbake virtual/kernel -C compile
复制代码- PC gt; vim workspace/sources/linux-stm32mp/drivers/media/platform/vivid/vivid-core.c , E. N3 e6 T, S. A% g
- PC gt; bitbake virtual/kernel -C compile
4 x' y7 C; W$ Z5 A+ W+ c - #Update the vivid kernel module on the board6 u& A' R+ r5 k
- PC gt; devtool deploy-target -Ss linux-stm32mp :/: m' v5 T3 c1 a: m( g
- Board gt; /sbin/depmod -a
5 G0 U! j' Q) u# v/ Z" f0 g - Board gt; sync8 B0 o2 K& ^4 Q1 s$ `# U
- Board gt; modprobe vivid
复制代码- scp tmp-glibc/deploy/images/stm32mp1/stm32mp157*.dtb :/boot8 r& b9 g# N B8 G0 u7 O8 Y. O+ c
- scp tmp-glibc/deploy/images/stm32mp1/uImage*:/boot: L. X3 N7 D! |1 [# F
- rm -rf /home/fdw/.ssh/known_hosts
复制代码 ' A0 P7 G7 v9 U A9 L1 {7 P
6.uboot实例
`4 O& I( U4 ?* w0 x2 c6 y# y- PC gt; devtool search u-boot*
+ i; g7 R# {* ~- C! Q2 Q - PC gt; devtool modify u-boot-stm32mp
5 S) b+ e& _( \0 ~ Z4 ~$ ^+ H% i0 [ - #cd <build dir>/workspace/sources/u-boot-stm32mp
0 l4 G3 k: M8 J& p - PC gt; devtool build u-boot-stm32mp4 W8 K9 U' M1 |+ e
- PC gt; bitbake u-boot-stm32mp -c deploy
1 P% F1 m$ H1 d" h - #ums 0 mmc 0
5 n9 e/ _3 ~& X8 J- ~ - PC gt; dd if=u-boot-<board name>-trusted.stm32 of=/dev/sdc3 bs=1M conv=fdatasync
复制代码 $ p: G. _; X0 W$ m) Q2 ?& B
7.tf-A实例: J! o% O/ Y) t" K2 B# x5 ]) \
- PC gt; devtool search tf-a*
% C7 Y& o# k+ Y+ M2 ^" q- d2 s7 ` - PC gt; devtool modify tf-a-stm32mp4 I( R! E+ [; c0 R2 H/ B
- #PC gt; cd <build dir>/workspace/sources/tf-a-stm32mp
/ g4 y. e1 `1 P' w/ g1 F, x5 x - PC gt; vim ./plat/st/stm32mp1/bl2_io_storage.c
/ Q. Z% k( f1 L" o9 x5 \ - PC gt; devtool build tf-a-stm32mp
/ J+ X+ K+ z( ~, v( t - #bitbake tf-a-stm32mp6 B. C, m! R% [5 ?
- PC gt; bitbake tf-a-stm32mp -c deploy9 M l" S! T! L1 }
- PC gt; dd if=tf-a-<board name>-trusted.stm32 of=/dev/sdc1 bs=1M conv=fdatasync
复制代码
0 U# |9 |3 V m8 b2 X- l7 a8.应用程序 “hello world”/ f4 W* m3 B, b& }" c; V+ D+ E* T( }
' ^8 L4 k6 t$ d2 o, t/ G; q
- PC gt; mkdir hello_world_example
" U0 g( C; d; K - PC gt; cd hello_world_example" X; {; Q6 X% P: ~, L9 y8 ~
- PC gt; vim hello_world_example.c
5 o# u4 F# c7 c6 ^4 Z: c5 B5 k- r- D - PC gt; cd <build dir>
5 E0 I O5 ^" t* `" }8 R: t - #Add a new recipe to the workspace
# J( k9 ~# _# }1 L3 X. j: O8 V - PC gt; devtool add myhelloworld hello_world_example/
* ~4 O3 a5 S* ^7 n - #Adapt recipe( `: a$ x u" O* f: R
- PC gt; devtool edit-recipe myhelloworld
1 C7 O9 l1 P% X' W - PC gt; devtool build myhelloworld
" G# k8 Q* K1 S0 f( g, Z4 n: m - PC gt; devtool deploy-target -s myhelloworld
复制代码 - k, j f; }' p7 h0 m8 ]% h3 M
9.m4projects-stm323 h, j E: i4 E# k( J, T; c
- Board gt; cd <path_to_your_workspace>/build-<name_of_distro>
% @' g R' {( p1 G1 [2 {- T' l - ; \4 Y# _9 U4 q }6 A+ y& @- {; @
- Clean the m4projects build folder2 B- h& R+ y0 y" Y" i8 n6 d+ z
- Board gt; bitbake m4projects-stm32mp1 -f -c cleanall
/ d. B. C0 H+ Z: d8 S& L8 R* u
# p* h2 Q3 |3 Q6 V Y. t" |; A- Rebuild the recipe m4projects; M" D5 k: u1 \, o
- Board gt; bitbake m4projects-stm32mp1
/ i C% d5 z4 i9 b8 w - 9 D4 J: w! f2 D8 N' N- P) c
- Rebuild the image
5 G+ q+ t: T& h2 N. C3 j - Board gt; bitbake st-image-weston
复制代码
3 q1 I4 j3 d: V" M二.devtool的总结4 d! u% K; J3 @6 e" X5 ^5 w4 H
5 V8 j7 y* G. h2 W- devtool modify tf-a-stm32mp
# C9 Z) S7 G, T0 I4 K8 _ - bitbake tf-a-stm32mp8 |+ ]2 T X8 y7 k; X; w' y
A! \# `* V, k- devtool search u-boot*8 v( I1 e7 ]! _
- devtool modify u-boot-stm32mp8 c* M3 |7 _: j0 B* U2 W7 n) l
- bitbake u-boot-stm32mp# h$ f. o9 z/ e* J) H! K
. M& B+ P. }: ?; M- devtool modify linux-stm32mp
- h4 P- h: X, D5 ? ~ - bitbake linux-stm32mp
复制代码- NOTE: Starting bitbake server...
t$ K2 T% V. y6 a7 K# k - usage: devtool [--basepath BASEPATH] [--bbpath BBPATH] [-d] [-q] L& S. m. D: i& r2 L5 O, @
- [--color COLOR] [-h]
# ]; @7 w* E; u - <subcommand> ...$ s- S. y6 [" T& U
- & q3 E, k, T" E: k+ ?9 l; E
- OpenEmbedded development tool
% ^0 ?0 v, h& r6 Z6 ~, C) M - , t3 p/ `8 @/ J! F, v
- options:4 p: o" Y3 f6 S) ^5 J4 l+ r
- --basepath BASEPATH Base directory of SDK / build directory
- ~7 B2 f% H* o) E% @3 o - --bbpath BBPATH Explicitly specify the BBPATH, rather than getting it. J8 M- t" }2 m' M8 W5 A7 n- b" j
- from the metadata
+ w5 H. _& U3 b* {* W - -d, --debug Enable debug output6 N. }) N; q' ~ Y& @: y
- -q, --quiet Print only errors
( X, q$ P0 O% N4 S - --color COLOR Colorize output (where COLOR is auto, always, never)
" D4 D4 h: H" x( Q! v* M5 O - -h, --help show this help message and exit, d, Z2 d% ~. p, X0 |
- ! D j0 F0 \9 X
- subcommands:
3 L6 i0 R3 z; t, ^: v - Beginning work on a recipe:
* x( K5 k: [3 l' a! a8 i - add Add a new recipe
9 N$ O U- f2 z' V) N! | - modify Modify the source for an existing recipe
4 B* a# v$ b( s - upgrade Upgrade an existing recipe
% e+ N, s5 [+ A7 W - Getting information:
8 L" b; A) F/ t+ {8 A8 z0 d/ e! H! \ - status Show workspace status% [. z* d3 b3 D' d8 q* c
- search Search available recipes V4 s4 e8 x- @3 r, ?% K2 D
- Working on a recipe in the workspace:
) o7 Z9 M$ n% m- w, V2 A3 ]' ] - build Build a recipe- w: z' y+ w& G% ^9 o- e, R
- rename Rename a recipe file in the workspace! c+ {3 C' |6 @* G/ B# F% S7 q
- edit-recipe Edit a recipe file in your workspace
$ ]/ L* I7 a2 E! Z; {; a0 y - find-recipe Find a recipe file in your workspace( ^. x( o* _# |
- configure-help Get help on configure script options. N9 s9 @6 m1 }- `
- update-recipe Apply changes from external source tree to recipe, b0 S5 P0 ?0 w3 f" `8 X5 v
- reset Remove a recipe from your workspace2 @, P4 I; W- [0 ^2 j( D
- finish Finish working on a recipe in your workspace7 |& K8 W+ T3 H9 @0 p0 C+ A( b
- Testing changes on target:: `3 | Z9 M: D+ ]6 X0 x* r3 m
- deploy-target Deploy recipe output files to live target machine
/ O* @ c4 h0 y - undeploy-target Undeploy recipe output files in live target machine
. [7 N& K3 Q+ h; ~ - build-image Build image including workspace recipe packages& q! D) H+ H2 a9 m) [
- Advanced:
2 N* R4 t* |2 I% q - create-workspace Set up workspace in an alternative location9 J. T( N8 b' e! U
- import Import exported tar archive into workspace
- O7 l; n6 I4 Q* e4 K/ e - extract Extract the source for an existing recipe
0 s2 x2 R6 O5 Z' {2 } - sync Synchronize the source tree for an existing recipe
( g2 a/ s" d" [2 N! Q W - export Export workspace into a tar archive: W& g9 r/ H/ ]/ g
- Use devtool <subcommand> --help to get help on a specific command
复制代码
: u: i* b6 x' P& I! G
" D# h* Y$ y3 H0 ?& U————————————————. w# Q, {1 n0 B" Z* U( P
版权声明:jacob杰克爸) Y# W" _# }2 g3 x" A& }
9 O5 ]2 ~) \! O9 _3 P |